protected void Create___Job3_From_Job2(string SId, string Job1ID)
    {
        Int64     recordid = 0;
        DataTable dstbl    = MyCommonfile.selectBZ(" SELECT DISTINCT TOP(1)  dbo.Satellite_Server_Sync_Job_Details.TableID, dbo.Satellite_Server_Sync_Job_Details.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 CheckingStatus=0 Order By TableID  ");

        if (dstbl.Rows.Count > 0)
        {
            DataTable DTTable = MyCommonfile.selectBZ(@" SELECT DISTINCT dbo.ClientProductTableMaster.Id AS TableId, dbo.ClientProductTableMaster.TableName, dbo.SatelliteSyncronisationrequiringTablesMaster_SerWhere.PKTableName, dbo.SatelliteSyncronisationrequiringTablesMaster_SerWhere.PKIdName, dbo.SatelliteSyncronisationrequiringTablesMaster_SerWhere.Select_Query FROM dbo.ClientProductTableMaster INNER JOIN dbo.SatelliteSyncronisationrequiringTablesMaster ON dbo.SatelliteSyncronisationrequiringTablesMaster.TableID = dbo.ClientProductTableMaster.Id INNER JOIN dbo.SatelliteSyncronisationrequiringTablesMaster_SerWhere ON dbo.SatelliteSyncronisationrequiringTablesMaster.TableID = dbo.SatelliteSyncronisationrequiringTablesMaster_SerWhere.TableId Where dbo.ClientProductTableMaster.Id='" + dstbl.Rows[0]["TableId"].ToString() + "' ");
            if (dstbl.Rows.Count > 0)
            {
                recordid++;
                CreateTableDesign(DTTable.Rows[0]["TableName"].ToString(), SId);
                Int64 RecordInserted = Syncro_Tables.InsertJob3____AllRecord__Satelite_Server_Sync_Log_Deatils(dstbl.Rows[0]["ID"].ToString(), DTTable.Rows[0]["TableName"].ToString(), DTTable.Rows[0]["TableId"].ToString(), SId, DTTable.Rows[0]["PKTableName"].ToString(), DTTable.Rows[0]["PKIdName"].ToString(), DTTable.Rows[0]["Select_Query"].ToString());
                lbl_Msg.Text += "<br> From " + DTTable.Rows[0]["TableName"].ToString() + " Total " + RecordInserted + " Record Are Inseted In Job Table ";
                Boolean jobc2heckstatus = Syncro_Tables.UpdateJob2___Satellite_Server_Sync_Job_Details(dstbl.Rows[0]["ID"].ToString(), false, true, DateTime.Now, false, DateTime.Now);
            }
        }
        else
        {
            Boolean status2 = Syncro_Tables.UpdateJob1___Satelitte_Server_Sync_Job_Master(Convert.ToString(Job1ID), true, DateTime.Now);
            img_loading.Visible = false;
            lbl_Msg.Text       += "<br> Job Done Successfully " + DateTime.Now.ToString();
            Timer1.Enabled      = false;
            if (Request.QueryString["2"] == "Transfer" || Request.QueryString["comid"] != null)
            {
                Response.Redirect("Syncro.aspx?comid=" + Request.QueryString["comid"] + "&sid=" + Request.QueryString["sid"].ToString() + "&1=Transfer");
            }
        }
    }
Example #2
0
    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;
        }
    }
Example #3
0
    protected void TransferAtJob1Job2(string SId)
    {
        Int64 tablename = 0;
        Int64 JobID     = Syncro_Tables.InsertJob1___Satelitte_Server_Sync_Job_Master(SId, "Updation " + SId + " on " + Convert.ToString(DateTime.Now), DateTime.Now, false);

        tablename = 0;
        DataTable dsfst = MyCommonfile.selectBZ(" Select DISTINCT TAbleId From Sync_Need_Logs_AtServer where sid='" + SId + "' Order By TAbleId ");

        for (int ii = 0; ii < dsfst.Rows.Count; ii++)
        {
            tablename++;
            Int64 JobDetailID = Syncro_Tables.InsertJob2___Satellite_Server_Sync_Job_Details(Convert.ToString(JobID), dsfst.Rows[ii]["TAbleId"].ToString(), false, false, DateTime.Now, true);
        }
        // lbl_Msg.Text = Convert.ToString(tablename) + " tables added for create job ";
    }
Example #4
0
    protected void CreateServerJob()
    {
        Int64     Count = 0;
        DataTable ds    = MyCommonfile.selectBZ(" Select Count(Logid) as id From Sync_Need_Logs  ");

        for (int iicouts = 0; iicouts < Convert.ToInt32(ds.Rows[0]["id"].ToString()); iicouts++)
        {
            Label1.Text = Convert.ToInt32(ds.Rows[0]["id"].ToString()) + " total record remaining for create server job";
            DataTable DTServerID = MyCommonfile.selectBZ(" SELECT DISTINCT dbo.ServerMasterTbl.Id FROM dbo.CompanyMaster INNER JOIN dbo.PricePlanMaster ON dbo.PricePlanMaster.PricePlanId = dbo.CompanyMaster.PricePlanId INNER JOIN dbo.PortalMasterTbl ON dbo.PricePlanMaster.PortalMasterId1 = dbo.PortalMasterTbl.Id INNER JOIN dbo.VersionInfoMaster ON dbo.PricePlanMaster.VersionInfoMasterId = dbo.VersionInfoMaster.VersionInfoId INNER JOIN dbo.ProductMaster ON dbo.VersionInfoMaster.ProductId = dbo.ProductMaster.ProductId INNER JOIN dbo.ClientMaster ON dbo.ProductMaster.ClientMasterId = dbo.ClientMaster.ClientMasterId INNER JOIN dbo.ServerMasterTbl ON dbo.CompanyMaster.ServerId = dbo.ServerMasterTbl.Id Where  dbo.ServerMasterTbl.Status=1 and dbo.CompanyMaster.Active=1 ");
            for (int iicout = 0; iicout < DTServerID.Rows.Count; iicout++)
            {
                string    RecordID = ds.Rows[iicouts]["RecordID"].ToString();
                DataTable DtWhere  = MyCommonfile.selectBZ(" Select * FROM SatelliteSyncronisationrequiringTablesMaster_SerWhere Where TableId='" + ds.Rows[iicouts]["TableName"].ToString() + "'");
                if (DtWhere.Rows.Count > 0)
                {
                    //Select_Query
                    string PKTableName  = DtWhere.Rows[0]["PKTableName"].ToString();
                    string PKIdName     = DtWhere.Rows[0]["PKIdName"].ToString();
                    string Select_Query = DtWhere.Rows[0]["Select_Query"].ToString();
                    string WhereForPKID = " Where " + PKTableName + "." + PKIdName + "=" + RecordID;
                    string SelectWhere2 = " and PricePlanMaster.PricePlanId IN ( Select PricePlanId From  CompanyMaster Where active=1 and ServerId=" + ViewState["sid"] + ") ";
                    Select_Query = Select_Query + WhereForPKID + SelectWhere2;
                    DataTable DtWhereC = MyCommonfile.selectBZ("" + Select_Query + "");
                    if (DtWhereC.Rows.Count > 0)
                    {
                        Count++;
                        Syncro_Tables.Insert___Sync_Need_Logs_AtServer(ds.Rows[iicouts]["LogId"].ToString(), ds.Rows[iicouts]["RecordID"].ToString(), ds.Rows[iicouts]["ACTION"].ToString(), ds.Rows[iicouts]["TableName"].ToString(), false, DTServerID.Rows[iicout]["Id"].ToString());
                    }
                }
                else
                {
                    Syncro_Tables.Insert___Sync_Need_Logs_AtServer(ds.Rows[iicouts]["LogId"].ToString(), ds.Rows[iicouts]["RecordID"].ToString(), ds.Rows[iicouts]["ACTION"].ToString(), ds.Rows[iicouts]["TableName"].ToString(), false, DTServerID.Rows[iicout]["Id"].ToString());
                }
                //SELECT DISTINCT dbo.ClientProductTableMaster.Id FROM dbo.PricePlanMaster INNER JOIN dbo.Priceplancategory ON dbo.PricePlanMaster.PriceplancatId = dbo.Priceplancategory.ID INNER JOIN dbo.PriceplanrestrictionTbl INNER JOIN dbo.PortalMasterTbl ON dbo.PriceplanrestrictionTbl.PortalId = dbo.PortalMasterTbl.Id ON dbo.Priceplancategory.PortalId = dbo.PortalMasterTbl.Id LEFT OUTER JOIN dbo.ClientProductTableMaster ON dbo.PriceplanrestrictionTbl.TableId = dbo.ClientProductTableMaster.Id  Where  dbo.ClientProductTableMaster.Id='"+ RecordID +"' and PricePlanMaster.PricePlanId IN(Select PricePlanId From  CompanyMaster Where active=1 and ServerId='"+ViewState["sid"]+"')
            }
            Syncro_Tables.DELETE__Sync_Need_Logs__AddDelUpdtSelect(ds.Rows[iicouts]["LogId"].ToString());
        }
        DataTable ds1 = MyCommonfile.selectBZ(" Select * From Sync_Need_Logs  Order By LogId ");

        if (ds1.Rows.Count == 0)
        {
            Timer1.Enabled      = false;
            img_loading.Visible = false;
            lbl_Msg.Text        = " All Record transfer successfully for create server job";
        }
    }
    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);
    }
    public static Int64 All_Table_All_Record_SyncroniceSERID(string Sync_Need_Logs_AtServerSErID, 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 + "!='' and " + TableName + "." + PKIdName + " NOT IN (Select Rcordid as Rcordid From " + Sync_Need_Logs_AtServerSErID + " Where TAbleId='" + TableId + "' and sid=" + 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++;
                Syncro_Tables.Insert___Sync_Need_Logs_AtServerSERID(Sync_Need_Logs_AtServerSErID, RecordID, RecordID, "1", TableId, false, ServerID);
            }
        }
        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++;
                Syncro_Tables.Insert___Sync_Need_Logs_AtServerSERID(Sync_Need_Logs_AtServerSErID, RecordID, RecordID, "1", TableId, false, ServerID);
            }
            //   Syncro_Tables.Insert___Sync_Need_Logs_AtServer(RecordID, RecordID, "1", TableId, false, ServerID);
        }
        return(Count);
    }
Example #7
0
    protected void Create___Job1_Job2(string SId)
    {
        Int64     sateserver = 0;
        Int64     totaltable = 0;
        DataTable DTServerID = MyCommonfile.selectBZ(" SELECT DISTINCT dbo.ServerMasterTbl.Id,dbo.ServerMasterTbl.ServerName FROM dbo.CompanyMaster INNER JOIN dbo.PricePlanMaster ON dbo.PricePlanMaster.PricePlanId = dbo.CompanyMaster.PricePlanId INNER JOIN dbo.PortalMasterTbl ON dbo.PricePlanMaster.PortalMasterId1 = dbo.PortalMasterTbl.Id INNER JOIN dbo.VersionInfoMaster ON dbo.PricePlanMaster.VersionInfoMasterId = dbo.VersionInfoMaster.VersionInfoId INNER JOIN dbo.ProductMaster ON dbo.VersionInfoMaster.ProductId = dbo.ProductMaster.ProductId INNER JOIN dbo.ClientMaster ON dbo.ProductMaster.ClientMasterId = dbo.ClientMaster.ClientMasterId INNER JOIN dbo.ServerMasterTbl ON dbo.CompanyMaster.ServerId = dbo.ServerMasterTbl.Id Where  dbo.ServerMasterTbl.Status=1 and dbo.CompanyMaster.Active=1 and dbo.ServerMasterTbl.Id=" + SId + " ");//

        if (DTServerID.Rows.Count > 0)
        {
            sateserver++;
            Int64 Job1RecordID = Syncro_Tables.InsertJob1___Satelitte_Server_Sync_Job_Master(DTServerID.Rows[0]["id"].ToString(), "Updation " + DTServerID.Rows[0]["ServerName"].ToString() + " on " + Convert.ToString(DateTime.Now), DateTime.Now, false);
            lbl_jo1ID.Text = Convert.ToString(Job1RecordID);
            totaltable     = 0;
            //DataTable dsfst = MyCommonfile.selectBZ(" Select DISTINCT TAbleId From Sync_Need_Logs_AtServer where sid='" + DTServerID.Rows[iicout]["id"].ToString() + "' Order By TAbleId ");
            DataTable DTTable = MyCommonfile.selectBZ(@" SELECT DISTINCT dbo.ClientProductTableMaster.Id AS TableId FROM dbo.ClientProductTableMaster INNER JOIN dbo.SatelliteSyncronisationrequiringTablesMaster ON dbo.SatelliteSyncronisationrequiringTablesMaster.TableID = dbo.ClientProductTableMaster.Id INNER JOIN dbo.SatelliteSyncronisationrequiringTablesMaster_SerWhere ON dbo.SatelliteSyncronisationrequiringTablesMaster.TableID = dbo.SatelliteSyncronisationrequiringTablesMaster_SerWhere.TableId Order By TAbleId ");
            for (int ii = 0; ii < DTTable.Rows.Count; ii++)
            {
                totaltable++;
                Int64 Job2RecordID = Syncro_Tables.InsertJob2___Satellite_Server_Sync_Job_Details(Convert.ToString(Job1RecordID), DTTable.Rows[ii]["TAbleId"].ToString(), false, false, DateTime.Now, true);
            }
            lbl_Msg.Text = "Total " + totaltable + " table need create Job for synchronization record for " + DTServerID.Rows[0]["ServerName"].ToString() + " server. ";
        }
    }
Example #8
0
    protected void InsertAtServer____FromJob3(string SId)
    {
        Boolean connnection  = false;
        int     c            = 0;
        string  Delete_From  = "";
        string  PKname       = "";
        string  deleteJob3ID = "";

        conn = new SqlConnection();
        try
        {
            conn = ServerWizard.ServerDefaultInstanceConnetionTCP_Serverid(SId);
            if (conn.State.ToString() != "Open")
            {
                conn.Open();
            }
            conn.Close();
            connnection = true;
        }
        catch (Exception ex)
        {
        }

        if (connnection == true)
        {
            int       totalrec          = 0;
            string    Bunchinsert       = "";
            string    seridstatus       = "";
            string    Insert_IntoCommon = "";
            DataTable dtcln             = new DataTable();
            DataTable dtJob1            = MyCommonfile.selectBZ(@" SELECT DISTINCT Satelitte_Server_Sync_Job_Master.Id AS Job1ID, Satelitte_Server_Sync_Job_Master.SatelliteServerID,ServerMasterTbl.ServerName,ServerMasterTbl.serverloction, dbo.Satelitte_Server_Sync_Job_Master.JobDateTime FROM dbo.Satelitte_Server_Sync_Job_Master INNER JOIN dbo.ServerMasterTbl ON dbo.Satelitte_Server_Sync_Job_Master.SatelliteServerID = dbo.ServerMasterTbl.Id Where Satelitte_Server_Sync_Job_Master.SatelliteServerID='" + SId + "'");
            if (dtJob1.Rows.Count > 0)
            {
                encstr = ServerWizard.ServerEncrDecriKEY(SId);
                for (int i1 = 0; i1 < dtJob1.Rows.Count; i1++)
                {
                    string    Job1ID     = dtJob1.Rows[i1]["Job1ID"].ToString();
                    string    ServerName = dtJob1.Rows[i1]["ServerName"].ToString();
                    DataTable dtJob2     = MyCommonfile.selectBZ(@" SELECT TOP(1) Satellite_Server_Sync_Job_Details.ID AS Job2ID,Satellite_Server_Sync_Job_Details.TableID, dbo.ClientProductTableMaster.Id, dbo.ClientProductTableMaster.TableName FROM dbo.Satellite_Server_Sync_Job_Details INNER JOIN dbo.ClientProductTableMaster INNER JOIN dbo.SatelliteSyncronisationrequiringTablesMaster ON dbo.SatelliteSyncronisationrequiringTablesMaster.TableID = dbo.ClientProductTableMaster.Id ON dbo.Satellite_Server_Sync_Job_Details.TableID = dbo.SatelliteSyncronisationrequiringTablesMaster.TableID Where Satellite_Server_Sync_Job_Details.Satelitte_Server_Sync_Job_Master_ID='" + Job1ID + "' ");
                    if (dtJob2.Rows.Count > 0)
                    {
                        for (int i2 = 0; i2 < dtJob2.Rows.Count; i2++)
                        {
                            string Job2ID    = dtJob2.Rows[i2]["Job2ID"].ToString();
                            string TableName = dtJob2.Rows[i2]["TableName"].ToString();
                            string TableId   = dtJob2.Rows[i2]["TableID"].ToString();
                            CreateTableDesign(TableName);

                            DataTable dtJob3 = MyCommonfile.selectBZ(@" SELECT TOP(500) Satelite_Server_Sync_Log_Deatils.ID AS Job3ID,Satelite_Server_Sync_Log_Deatils.TypeOfOperationDone , Satelite_Server_Sync_Log_Deatils.RecordID, SyncActionMaster.ActionName FROM Satelite_Server_Sync_Log_Deatils INNER JOIN dbo.SyncActionMaster ON dbo.Satelite_Server_Sync_Log_Deatils.TypeOfOperationDone = dbo.SyncActionMaster.ID Where Satelite_Server_Sync_Log_Deatils.Satellite_Server_Sync_Job_Details_ID='" + Job2ID + "'  ");
                            if (dtJob3.Rows.Count > 0)
                            {
                                Insert_IntoCommon = " INSERT INTO " + TableName + "(  ";
                                DataTable dts1 = MyCommonfile.selectBZ(" select column_name,data_type,CHARACTER_MAXIMUM_LENGTH from INFORMATION_SCHEMA.COLUMNS where table_name='" + TableName + "'");
                                for (int k = 0; k < dts1.Rows.Count; k++)
                                {
                                    Insert_IntoCommon += ("" + dts1.Rows[k]["column_name"] + " ,");
                                }
                                Insert_IntoCommon  = Insert_IntoCommon.Remove(Insert_IntoCommon.Length - 1);
                                Insert_IntoCommon += ") Values ";

                                // DataTable maxiddesid = MyCommonfile.selectBZ(" select column_name,data_type,CHARACTER_MAXIMUM_LENGTH from INFORMATION_SCHEMA.COLUMNS where table_name='" + tablename + "'");
                                PKname = TableRelated.SatelliteSyncronisationrequiringTablesMaster_WherePKIDName(TableId);
                                if (PKname.Length > 0)
                                {
                                }
                                else
                                {
                                    PKname = dts1.Rows[0]["column_name"].ToString();
                                }
                                for (int iii = 0; iii < dtJob3.Rows.Count; iii++)
                                {
                                    string Job3ID        = dtJob3.Rows[iii]["Job3ID"].ToString();
                                    string RecordID      = dtJob3.Rows[iii]["RecordID"].ToString();
                                    string Typeoperation = dtJob3.Rows[iii]["TypeOfOperationDone"].ToString();
                                    deleteJob3ID += Job3ID + ",";
                                    try
                                    {
                                        if (Typeoperation == "1")
                                        {
                                            DataTable dtr = MyCommonfile.selectBZ(" Select * From " + TableName + " where " + PKname + "=" + RecordID + " ");
                                            foreach (DataRow itm in dtr.Rows)
                                            {
                                                c++;
                                                string Insert_Into = "";
                                                Insert_Into += " (";
                                                for (int k = 0; k < dts1.Rows.Count; k++)
                                                {
                                                    Insert_Into += "'" + Encrypted(Convert.ToString(itm["" + dts1.Rows[k]["column_name"] + ""])) + "' ,";
                                                }
                                                Insert_Into  = Insert_Into.Remove(Insert_Into.Length - 1);
                                                Insert_Into += " ),";
                                                Bunchinsert += Insert_Into;
                                                if (c == 200)
                                                {
                                                    Bunchinsert = Bunchinsert.Remove(Bunchinsert.Length - 1);
                                                    string     ss  = Insert_IntoCommon + Bunchinsert;
                                                    SqlCommand ccm = new SqlCommand(ss, conn);
                                                    if (conn.State.ToString() != "Open")
                                                    {
                                                        conn.Open();
                                                    }
                                                    ccm.ExecuteNonQuery();
                                                    conn.Close();

                                                    deleteJob3ID = deleteJob3ID.Remove(deleteJob3ID.Length - 1);
                                                    SqlCommand ccmm = new SqlCommand(" Delete From Satelite_Server_Sync_Log_Deatils Where ID IN (" + deleteJob3ID + ")", con);
                                                    if (con.State.ToString() != "Open")
                                                    {
                                                        con.Open();
                                                    }
                                                    ccmm.ExecuteNonQuery();
                                                    con.Close();

                                                    deleteJob3ID = "";
                                                    Bunchinsert  = "";
                                                    c            = 0;
                                                }
                                            }
                                        }
                                        totalrec++;
                                        //Permanent Record Functionality
                                        //----****
                                        //
                                        // lblmsg.Text = " Successfully synchronization ";//" + totalrec + " records for " + lblname.Text + " server record " + lbl_RecordID.Text + "<br><br>";
                                    }
                                    catch
                                    {
                                        seridstatus  = SId;
                                        Bunchinsert  = "";
                                        lbl_Msg.Text = " Some problem when synchronization with " + ServerName + " server <br><br>";//e1.ToString()+"<br>";
                                    }
                                }//Job1 Loop
                                if (Bunchinsert.Length > 0)
                                {
                                    Bunchinsert = Bunchinsert.Remove(Bunchinsert.Length - 1);
                                    string     ss  = Insert_IntoCommon + Bunchinsert;
                                    SqlCommand ccm = new SqlCommand(ss, conn);
                                    if (conn.State.ToString() != "Open")
                                    {
                                        conn.Open();
                                    }
                                    ccm.ExecuteNonQuery();
                                    conn.Close();

                                    deleteJob3ID = deleteJob3ID.Remove(deleteJob3ID.Length - 1);
                                    SqlCommand ccmm = new SqlCommand(" Delete From Satelite_Server_Sync_Log_Deatils Where ID IN (" + deleteJob3ID + ")", con);
                                    if (con.State.ToString() != "Open")
                                    {
                                        con.Open();
                                    }
                                    ccmm.ExecuteNonQuery();
                                    con.Close();

                                    deleteJob3ID = "";
                                    Bunchinsert  = "";
                                    c            = 0;
                                }
                                //  Boolean DeletestatusJob2 = Syncro_Tables.DeleteJob2____Satelite_Server_Sync_Log_Deatils(Job2ID);
                                //Test
                                DataTable dtfindtab = MyCommonfile.selectBZ(@" SELECT Count(dbo.Satelite_Server_Sync_Log_Deatils.ID) as TotalCount
                                                        From    dbo.Satellite_Server_Sync_Job_Details INNER JOIN dbo.ClientProductTableMaster INNER JOIN dbo.SatelliteSyncronisationrequiringTablesMaster ON dbo.SatelliteSyncronisationrequiringTablesMaster.TableID = dbo.ClientProductTableMaster.Id ON  dbo.Satellite_Server_Sync_Job_Details.TableID = dbo.SatelliteSyncronisationrequiringTablesMaster.TableID AND dbo.Satellite_Server_Sync_Job_Details.TableID = dbo.ClientProductTableMaster.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 INNER JOIN dbo.ServerMasterTbl ON dbo.Satelitte_Server_Sync_Job_Master.SatelliteServerID = dbo.ServerMasterTbl.Id INNER JOIN dbo.Satelite_Server_Sync_Log_Deatils ON dbo.Satellite_Server_Sync_Job_Details.ID = dbo.Satelite_Server_Sync_Log_Deatils.Satellite_Server_Sync_Job_Details_ID INNER JOIN dbo.SyncActionMaster ON dbo.Satelite_Server_Sync_Log_Deatils.TypeOfOperationDone = dbo.SyncActionMaster.ID
                                                        Where ServerMasterTbl.Id='" + SId + "' ");//  and dbo.Satelitte_Server_Sync_Job_Master.Id='" + ViewState["JobID"] + "' and
                                lbl_Msg.Text += " Please waite for some moment we syncronice " + dtfindtab.Rows[0]["TotalCount"] + " record at server ";
                            }
                            else
                            {
                                //Norecord in Job3 for Job2
                                Boolean DeletestatusJob2 = Syncro_Tables.DeleteJob2____Satellite_Server_Sync_Job_Details(Job2ID);
                            }
                        }//Job2 Lopp
                         // Boolean DeletestatusJob1 = Syncro_Tables.DeleteJob1____Satelitte_Server_Sync_Job_Master(Job1ID);
                    }
                    else
                    {
                        //No Record in Job2 for selected job1
                        Boolean DeletestatusJob1 = Syncro_Tables.DeleteJob1____Satelitte_Server_Sync_Job_Master(Job1ID);
                    }
                }//Job1 Loop
            }
            else
            {
                img_loading.Visible = false;
                lbl_Msg.Text       += "<br> Job Done Successfully ";
                Timer1.Enabled      = false;
            }
        }
        else
        {
            lbl_Msg.Text = " No connection possible with server <br> you are tying to connect database with this connection string ( " + conn.ConnectionString + " )";//e1.ToString()+"<br>";
        }
    }