protected void CreateJob3(string SId) { Int64 recordid = 0; recordid = 0; DataTable ds32 = MyCommonfile.selectBZ(" Select Count(id) as id From Sync_Need_Logs_AtServer where sid='" + SId + "' "); DataTable ds3 = MyCommonfile.selectBZ(" Select TOP(1) * From Sync_Need_Logs_AtServer where sid='" + SId + "' "); if (Convert.ToInt32(ds32.Rows[0]["id"].ToString()) > 0) { Label1.Text = ds32.Rows[0]["id"].ToString() + " total record remaining for create job"; DataTable dstbl = MyCommonfile.selectBZ(" SELECT DISTINCT TOP(1) dbo.Satellite_Server_Sync_Job_Details.TableID, dbo.Satellite_Server_Sync_Job_Details.ID, Satelitte_Server_Sync_Job_Master.Id FROM dbo.Satellite_Server_Sync_Job_Details INNER JOIN dbo.Satelitte_Server_Sync_Job_Master ON dbo.Satellite_Server_Sync_Job_Details.Satelitte_Server_Sync_Job_Master_ID = dbo.Satelitte_Server_Sync_Job_Master.Id where Satelitte_Server_Sync_Job_Master.SatelliteServerID='" + SId + "' and Satellite_Server_Sync_Job_Details.TableID='" + ds3.Rows[0]["TableID"].ToString() + "' "); for (int ii = 0; ii < dstbl.Rows.Count; ii++) { DataTable ds = MyCommonfile.selectBZ(" Select TOP(50)* From Sync_Need_Logs_AtServer where sid='" + SId + "' and TAbleId='" + dstbl.Rows[ii]["TableID"].ToString() + "' Order By LogId "); for (int iii = 0; iii < ds.Rows.Count; iii++) { recordid++; string ID = ds.Rows[iii]["ID"].ToString(); string LogId = ds.Rows[iii]["LogId"].ToString(); string Rcordid = ds.Rows[iii]["Rcordid"].ToString(); string TableId = ds.Rows[iii]["TAbleId"].ToString(); // Int64 Satallite_Server_Sync_RecordsMasterTblID = Insert___Satallite_Server_Sync_RecordsMasterTbl(DTServerID.Rows[iicout]["id"].ToString(), TableId, DateTime.Now); string action = "1"; if (ds.Rows[iii]["ACTION"].ToString() == "INSERT") { action = "1"; } else if (ds.Rows[iii]["ACTION"].ToString() == "Updated") { action = "2"; } else if (ds.Rows[iii]["ACTION"].ToString() == "Deleted") { action = "3"; } Int64 Job3DID = Syncro_Tables.InsertJob3___Satelite_Server_Sync_Log_Deatils(dstbl.Rows[ii]["ID"].ToString(), Rcordid, DateTime.Now, action, "", false); Syncro_Tables.DELETE___Sync_Need_Logs_AtServer(ID); } } } DataTable ds1 = MyCommonfile.selectBZ(" Select TOP(1)* From Sync_Need_Logs_AtServer where sid='" + SId + "' "); if (ds1.Rows.Count == 0) { Timer1.Enabled = false; img_loading.Visible = false; } }
public static Int64 InsertJob3____AllRecord__Satelite_Server_Sync_Log_Deatils(string Job2ID, string TableName, string TableId, string ServerID, string PKTableName, string PKIdName, string Select_Query) { Int64 Count = 0; string WhereForPKID = ""; //WhereForPKID = " Where " + PKTableName + "." + PKIdName + "=" + RecordID; string SelectWhere3 = " Where " + TableName + "." + PKIdName + " NOT IN (Select RecordID as Rcordid FROM dbo.Satelite_Server_Sync_Log_Deatils INNER JOIN dbo.Satellite_Server_Sync_Job_Details ON dbo.Satelite_Server_Sync_Log_Deatils.Satellite_Server_Sync_Job_Details_ID = dbo.Satellite_Server_Sync_Job_Details.ID INNER JOIN dbo.Satelitte_Server_Sync_Job_Master ON dbo.Satellite_Server_Sync_Job_Details.Satelitte_Server_Sync_Job_Master_ID = dbo.Satelitte_Server_Sync_Job_Master.Id Where Satellite_Server_Sync_Job_Details.TableID='" + TableId + "' and Satelitte_Server_Sync_Job_Master.SatelliteServerID=" + ServerID + ")"; string SelectWhere2 = " and PricePlanMaster.PricePlanId IN ( Select PricePlanId From CompanyMaster Where active=1 and ServerId=" + ServerID + ") "; string FinalSelect_Query = Select_Query + WhereForPKID + SelectWhere3 + SelectWhere2; if (Select_Query.Length > 0) { DataTable DtWhereC = MyCommonfile.selectBZ("" + FinalSelect_Query + ""); for (int iicouts = 0; iicouts < DtWhereC.Rows.Count; iicouts++) { string RecordID; RecordID = DtWhereC.Rows[iicouts][0].ToString(); if (PKIdName.Length > 0) { RecordID = DtWhereC.Rows[iicouts][PKIdName].ToString(); } Count++; Int64 ReturnID2 = Syncro_Tables.InsertJob3___Satelite_Server_Sync_Log_Deatils(Job2ID, RecordID, DateTime.Now, "1", "", false); } } else { Count++; DataTable DtWhereC = MyCommonfile.selectBZ(" Select * From " + TableName + " " + SelectWhere3); for (int iicouts = 0; iicouts < DtWhereC.Rows.Count; iicouts++) { string RecordID; RecordID = DtWhereC.Rows[iicouts][0].ToString(); if (PKIdName.Length > 0) { RecordID = DtWhereC.Rows[iicouts][PKIdName].ToString(); } Count++; Int64 ReturnID2 = Syncro_Tables.InsertJob3___Satelite_Server_Sync_Log_Deatils(Job2ID, RecordID, DateTime.Now, "1", "", false); } //Syncro_Tables.Insert___Sync_Need_Logs_AtServer(RecordID, RecordID, "1", TableId, false, ServerID); } return(Count); }