In case of Old data of coop is not properly restore then

  • stop work of that coop from all places
  • Login to Master Panel
  • Org List and Org Edit respective organisation
  • Change DB name to old fiscal year db like “coop_md197”
  • Open Org List page
  • Find restore matchin copy of db in that org
  • Open Org Edit panel of resepective Organisation
  • Change DB name to New Fiscal year DB like ‘coop_md197_7576
  • Confirm Organisation Login via next browser
  • Verify data
  • Inform COOP so that they can start work.

Madhyapur Hospital Backup Plan

Application/Files/Database to backup

SN Application Description Runtime User Uploads Database
1 Main MIS Web Application Yes Yes Yes
2 Desktop Application Yes No No
3 Payroll Application Yes Yes Yes
4 Inventory Application Yes No Yes
5 Main MIS Web Application [2073] Yes No Yes
6 Old Record Check Application Yes Yes Yes

Fix User Server Principal authentication error after db restore

use database_name;
— ALTER DATABASE database_name SET READ_WRITE

——– Reset SQL user account guids ———————
DECLARE @UserName nvarchar(255)
DECLARE orphanuser_cur cursor for
SELECT UserName = su.name
FROM sysusers su
JOIN sys.server_principals sp ON sp.name = su.name
WHERE issqluser = 1 AND
(su.sid IS NOT NULL AND su.sid <> 0x0) AND
suser_sname(su.sid) is null
ORDER BY su.name

OPEN orphanuser_cur
FETCH NEXT FROM orphanuser_cur INTO @UserName

WHILE (@@fetch_status = 0)
BEGIN
–PRINT @UserName + ‘ user name being resynced’
exec sp_change_users_login ‘Update_one’, @UserName, @UserName
FETCH NEXT FROM orphanuser_cur INTO @UserName
END

CLOSE orphanuser_cur
DEALLOCATE orphanuser_cur

Getting Started with .Net MVC c#

Using DB First Approach

Database Part MSSQL Management Studio

  • Create DB Tables,
  • Views and
  • Stored Procedure as requirement

Visual Studio Application Part

  • Create New Project
  • Create Separate Projects for DAL
  • Add Reference of DAL Project to main project
  • Add Nuget package of Entity Framework to both projects [DAL and Main]
  • Create EDMX Model from Database to project in DAL Project
  • Build Project
  • Add scaffolding Controllers
  • Test Application

Using Code First Approach

Visual Studio Application Part

  • Create New Project
  • Create Separate Projects for DAL
  • Add Reference of DAL Project to main project
  • Add Nuget package of Entity Framework to both projects [DAL and Main]
  • Create Models and DB Context required for matching database structure
  • Build Project
  • Add scaffolding Controllers
  • Test Application

TSQL Clear All Database objects

use dbname;

DECLARE @Sql NVARCHAR(500) DECLARE @Cursor CURSOR

SET @Cursor = CURSOR FAST_FORWARD FOR
SELECT DISTINCT sql = ‘ALTER TABLE [‘ + tc2.TABLE_NAME + ‘] DROP [‘ + rc1.CONSTRAINT_NAME + ‘]’
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc1
LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc2 ON tc2.CONSTRAINT_NAME =rc1.CONSTRAINT_NAME

OPEN @Cursor FETCH NEXT FROM @Cursor INTO @Sql

WHILE (@@FETCH_STATUS = 0)
BEGIN
Exec sp_executesql @Sql
FETCH NEXT FROM @Cursor INTO @Sql
END

CLOSE @Cursor DEALLOCATE @Cursor
GO

EXEC sp_MSforeachtable ‘DROP TABLE ?’
GO

Steps to add model for MFI UI project which is same as API Request Model

  • Add Common Models to MFI_API_MODEL Project
  • Build project and make error free
  • Change Nuget Package Version in MFI_API_MODEL.nuspec file
  • Generate Nuget Package from CMD using command:
    • nuget pack mfi_api_model.nuspec -prop configuration=release
  • Host Nuget Package to accessible server location in Ants or local computer
  • Open Own UI project,
  • Update Package version

MSSQL Check Running Queries

SELECT sqltext.TEXT,
req.session_id,
req.status,
req.command,
req.cpu_time,
req.total_elapsed_time
FROM sys.dm_exec_requests req
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext