Exemplo n.º 1
0
        protected void cGenButton_Click(object sender, System.EventArgs e)
        {
            DbPorting pt = new DbPorting();
            DataTable dt = (DataTable)Session[KEY_dtDataTier];
            string    TarUdFunctionDb = dt.Rows[cDataTierId.SelectedIndex]["DesDatabase"].ToString();

            cSqlTo.Text = pt.SqlToSybase(Int16.Parse(cEntityId.SelectedValue), TarUdFunctionDb, cSqlFr.Text, LcAppConnString, LcAppPw);
        }
Exemplo n.º 2
0
 protected void cGenButton_Click(object sender, System.EventArgs e)
 {
     cMsgLabel.Text = string.Empty;
     if (!(cSrcSystemId.Items.Count > 0 && cTarSystemId.Items.Count > 0))
     {
         PreMsgPopup("Please make sure the table \"Systems\" in both source and target have valid database entries and try again.");
     }
     else if (cSrcSystemId.SelectedValue != cTarSystemId.SelectedValue)
     {
         PreMsgPopup("Please make sure the source and target \"Database\" are the same and try again.");
     }
     else if (cExecScript.Checked && cSrcDataTierId.SelectedValue == cTarDataTierId.SelectedValue)
     {
         PreMsgPopup("Source and Target data tier can be the same if and only if script is not being executed, please try again.");
     }
     else
     {
         string    ss;
         DataTable dt = (DataTable)Session[KEY_dtDataTier];
         string    SrcDbProviderCd = dt.Rows[cSrcDataTierId.SelectedIndex]["DbProviderCd"].ToString();
         string    SrcPortBinPath  = dt.Rows[cSrcDataTierId.SelectedIndex]["PortBinPath"].ToString();
         string    SrcScriptPath   = dt.Rows[cSrcDataTierId.SelectedIndex]["ScriptPath"].ToString();
         string    TarDbProviderCd = dt.Rows[cTarDataTierId.SelectedIndex]["DbProviderCd"].ToString();
         string    TarPortBinPath  = dt.Rows[cTarDataTierId.SelectedIndex]["PortBinPath"].ToString();
         string    TarPortCmdName;
         if (TarDbProviderCd == "S")
         {
             TarPortCmdName = TarPortBinPath + "isql.exe";
         }
         else
         {
             TarPortCmdName = "osql.exe";
         }
         string    TarScriptPath   = dt.Rows[cTarDataTierId.SelectedIndex]["ScriptPath"].ToString();
         string    TarUdFunctionDb = dt.Rows[cTarDataTierId.SelectedIndex]["DesDatabase"].ToString();
         DbScript  ds = new DbScript(cExemptText.Text, false);
         DbPorting pt = new DbPorting();
         if (cClearDb.Checked)
         {
             ss = ds.ScriptClearDb(SrcDbProviderCd, TarDbProviderCd, cTable.Checked, cBcpIn.Checked, cIndex.Checked, cView.Checked, cSp.Checked, base.CSrc, base.CTar);
             Robot.WriteToFile("M", SrcScriptPath + "OClearDb.sql", ss);
             if (TarDbProviderCd == "S")
             {
                 ss = pt.SqlToSybase(Int16.Parse(cEntityId.SelectedValue), TarUdFunctionDb, ss, LcAppConnString, LcAppPw);
             }
             Robot.WriteToFile("M", TarScriptPath + "NClearDb.sql", ss);
             // ds.ExecScript need to be changed to Utils.WinProc in order for SQL Server on a separate server to work:
             if (cExecScript.Checked)
             {
                 ds.ExecScript(TarDbProviderCd, "Clear Database", TarPortCmdName, TarScriptPath + "NClearDb.sql", base.CSrc, base.CTar, LcAppConnString, LcAppPw);
             }
             sbWarnMsg.Append(pt.sbWarning.ToString()); sbWarnMsg.Append(ds.sbWarning.ToString());
         }
         if (cTable.Checked)
         {
             ss = ds.ScriptCreateTables(SrcDbProviderCd, SrcDbProviderCd, true, base.CSrc, base.CTar);
             Robot.WriteToFile("M", SrcScriptPath + "OTable.sql", ss);
             if (TarDbProviderCd == "S")
             {
                 ss = ds.ScriptCreateTables(SrcDbProviderCd, TarDbProviderCd, true, base.CSrc, base.CTar);
                 ss = pt.SqlToSybase(Int16.Parse(cEntityId.SelectedValue), TarUdFunctionDb, ss, LcAppConnString, LcAppPw);
             }
             Robot.WriteToFile("M", TarScriptPath + "NTable.sql", ss);
             // ds.ExecScript need to be changed to Utils.WinProc in order for SQL Server on a separate server to work:
             if (cExecScript.Checked)
             {
                 ds.ExecScript(TarDbProviderCd, "Script Tables", TarPortCmdName, TarScriptPath + "NTable.sql", base.CSrc, base.CTar, LcAppConnString, LcAppPw);
             }
             sbWarnMsg.Append(pt.sbWarning.ToString()); sbWarnMsg.Append(ds.sbWarning.ToString());
         }
         if (cBcpOut.Checked)
         {
             ss = ds.GenerateBCPFiles("M", TarDbProviderCd, SrcDbProviderCd, SrcPortBinPath, true, TarScriptPath + @"Data\", "~@~", false, base.CSrc, base.CTar);
             Robot.WriteToFile("M", TarScriptPath + "BcpOut.bat", ss);
             // ds.ExecScript need to be changed to Utils.WinProc in order for SQL Server on a separate server to work:
             if (cExecScript.Checked)
             {
                 ds.ExecScript(string.Empty, "Bcp Out", TarScriptPath + "BcpOut.bat", string.Empty, base.CSrc, base.CTar, LcAppConnString, LcAppPw);
             }
             sbWarnMsg.Append(ds.sbWarning.ToString());
         }
         if (cBcpIn.Checked)
         {
             ss = ds.ScriptTruncData(SrcDbProviderCd, true, base.CSrc, base.CTar);
             if (TarDbProviderCd == "S")
             {
                 ss = pt.SqlToSybase(Int16.Parse(cEntityId.SelectedValue), TarUdFunctionDb, ss, LcAppConnString, LcAppPw);
             }
             Robot.WriteToFile("M", TarScriptPath + "BcpIn.sql", ss);
             ss = ds.GenerateBCPFiles("M", TarDbProviderCd, TarDbProviderCd, TarPortBinPath, false, TarScriptPath + @"Data\", "~@~", false, base.CSrc, base.CTar);
             Robot.WriteToFile("M", TarScriptPath + "BcpIn.bat", ss);
             // ds.ExecScript need to be changed to Utils.WinProc in order for SQL Server on a separate server to work:
             if (cExecScript.Checked)
             {
                 ds.ExecScript(TarDbProviderCd, "Truncate Data", TarPortCmdName, TarScriptPath + "BcpIn.sql", base.CSrc, base.CTar, LcAppConnString, LcAppPw);
                 ds.ExecScript(TarDbProviderCd, "Bcp In", TarScriptPath + "BcpIn.bat", string.Empty, base.CSrc, base.CTar, LcAppConnString, LcAppPw);
             }
             sbWarnMsg.Append(pt.sbWarning.ToString()); sbWarnMsg.Append(ds.sbWarning.ToString());
         }
         if (cIndex.Checked)
         {
             ss = ds.ScriptIndexFK(SrcDbProviderCd, SrcDbProviderCd, true, base.CSrc, base.CTar);
             Robot.WriteToFile("M", SrcScriptPath + "OIndex.sql", ss);
             if (TarDbProviderCd == "S")
             {
                 ss = ds.ScriptIndexFK(SrcDbProviderCd, TarDbProviderCd, true, base.CSrc, base.CTar);
                 ss = pt.SqlToSybase(Int16.Parse(cEntityId.SelectedValue), TarUdFunctionDb, ss, LcAppConnString, LcAppPw);
             }
             Robot.WriteToFile("M", TarScriptPath + "NIndex.sql", ss);
             // ds.ExecScript need to be changed to Utils.WinProc in order for SQL Server on a separate server to work:
             if (cExecScript.Checked)
             {
                 ds.ExecScript(TarDbProviderCd, "Script Indexes", TarPortCmdName, TarScriptPath + "NIndex.sql", base.CSrc, base.CTar, LcAppConnString, LcAppPw);
             }
             sbWarnMsg.Append(pt.sbWarning.ToString()); sbWarnMsg.Append(ds.sbWarning.ToString());
         }
         if (cView.Checked)
         {
             ss = ds.ScriptView(SrcDbProviderCd, SrcDbProviderCd, true, base.CSrc, base.CTar);
             Robot.WriteToFile("M", SrcScriptPath + "OView.sql", ss);
             if (TarDbProviderCd == "S")
             {
                 ss = ds.ScriptView(SrcDbProviderCd, TarDbProviderCd, true, base.CSrc, base.CTar);
                 ss = pt.SqlToSybase(Int16.Parse(cEntityId.SelectedValue), TarUdFunctionDb, ss, LcAppConnString, LcAppPw);
             }
             Robot.WriteToFile("M", TarScriptPath + "NView.sql", ss);
             // ds.ExecScript need to be changed to Utils.WinProc in order for SQL Server on a separate server to work:
             if (cExecScript.Checked)
             {
                 ds.ExecScript(TarDbProviderCd, "Script View", TarPortCmdName, TarScriptPath + "NView.sql", base.CSrc, base.CTar, LcAppConnString, LcAppPw);
             }
             sbWarnMsg.Append(pt.sbWarning.ToString()); sbWarnMsg.Append(ds.sbWarning.ToString());
         }
         if (cSp.Checked)
         {
             ss = ds.ScriptSProcedures(SrcDbProviderCd, SrcDbProviderCd, true, base.CSrc, base.CTar);
             Robot.WriteToFile("M", SrcScriptPath + "OSp.sql", ss);
             if (TarDbProviderCd == "S")
             {
                 ss = ds.ScriptSProcedures(SrcDbProviderCd, TarDbProviderCd, true, base.CSrc, base.CTar);
                 ss = pt.SqlToSybase(Int16.Parse(cEntityId.SelectedValue), TarUdFunctionDb, ss, LcAppConnString, LcAppPw);
             }
             if (cEncryptSp.Checked)
             {
                 ss = ds.EncryptSProcedures(SrcDbProviderCd, TarDbProviderCd, ss, true, base.CSrc, base.CTar);
             }
             Robot.WriteToFile("M", TarScriptPath + "NSp.sql", ss);
             // ds.ExecScript need to be changed to Utils.WinProc in order for SQL Server on a separate server to work:
             if (cExecScript.Checked)
             {
                 ds.ExecScript(TarDbProviderCd, "Script Stored Procedures", TarPortCmdName, TarScriptPath + "NSp.sql", base.CSrc, base.CTar, LcAppConnString, LcAppPw);
             }
             sbWarnMsg.Append(pt.sbWarning.ToString()); sbWarnMsg.Append(ds.sbWarning.ToString());
         }
         if (SrcScriptPath != TarScriptPath)
         {
             cMsgLabel.Text = "Please check directories " + TarScriptPath + " and " + TarScriptPath + " to see if all the scripts have been generated successfully.";
         }
         else
         {
             cMsgLabel.Text = "Please check directory " + TarScriptPath + " to see if all the scripts have been generated successfully.";
         }
         if (sbWarnMsg.ToString() != string.Empty)
         {
             PreMsgPopup(sbWarnMsg.ToString());
         }
     }
 }