Пример #1
0
        private void _SQLAgentJob(SqlInstances sqlInstances)
        {
            SQLAgentJob sAJ = new SQLAgentJob(credentials);

            sAJ.SetComputerName(sqlInstances.Server);
            sAJ.SetInstance(sqlInstances.ServerInstance);
            if (!string.IsNullOrEmpty(subsystemFilter))
            {
                sAJ.SetSubsystemFilter(subsystemFilter);
            }
            ;
            if (!string.IsNullOrEmpty(keywordFilter))
            {
                sAJ.SetKeywordFilter(keywordFilter);
            }
            ;
            if (usingProxyCredentials)
            {
                sAJ.SetUsingProxyCredFilter();
            }
            ;
            if (!string.IsNullOrEmpty(proxyCredentials))
            {
                sAJ.SetProxyCredentialFilter(proxyCredentials);
            }
            ;
            sAJ.Query();
            _PrintOutput(sAJ.GetResults());
        }
Пример #2
0
        /// <summary>
        /// schedule increment data load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_scheduleIDL_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            Tables tbl = new Tables(Databasename, tablename.Substring(tablename.IndexOf("_") + 1));

            if (!tbl._primary_key_enabled)
            {
                MessageBox.Show("Increment load can be done on tables with primary key constraint.", "SQLCDCApp Info!!!");
                return;
            }

            if (string.IsNullOrEmpty(textBox_Server.Text))
            {
                MessageBox.Show("Destination server can't be empty", "SQLCDCApp Info!!!");
                textBox_Server.Focus();
                return;
            }
            if (string.IsNullOrEmpty(comboBox_Database.Text))
            {
                MessageBox.Show("Destination Database can't be empty", "SQLCDCApp Info!!!");
                comboBox_Database.Focus();
                return;
            }
            if (string.IsNullOrEmpty(comboBox_Tables.Text))
            {
                MessageBox.Show("Destination table can't be empty", "SQLCDCApp Info!!!");
                comboBox_Tables.Focus();
                return;
            }

            try
            {
                // make an entry in meta tables

                //    obj.fn_Updatemetatables(Settings1.Default.Server.ToString(), textBox_Server.Text, Databasename, comboBox_Database.Text, tablename, desttable, comboBox_capturedinstances.Text, textBox_User.Text, Crypto.Crypto.Encrypt(textBox_password.Text, true));

                string      _sqljobname = "SQLCDCApp_IDL_" + Databasename + "_" + tablename + "_" + comboBox_capturedinstances.Text;
                SQLAgentJob _sajob      = new SQLAgentJob(Settings1.Default.Server, Settings1.Default.User, Crypto.Crypto.Encrypt(Settings1.Default.Password, true), Settings1.Default.AuthenticationType);
                _sajob.SQLJob(_sqljobname);
                string    userid = Settings1.Default.User, password = Crypto.Crypto.Encrypt(Settings1.Default.Password, true);
                Guid      _sqljobid = _sajob.SQLJobID;
                SQLCDCApp _obj      = new SQLCDCApp();

                _obj.fn_Updatemetatables(Settings1.Default.Server.ToString(), textBox_Server.Text, Databasename,
                                         comboBox_Database.Text, tablename, desttable, comboBox_capturedinstances.Text, textBox_User.Text,
                                         Crypto.Crypto.Encrypt(textBox_password.Text, true));
                _obj.fn_setsqljobid(_sqljobid, comboBox_capturedinstances.Text, Databasename, tablename, desttable, comboBox_Database.Text, textBox_Server.Text);
                if (string.IsNullOrEmpty(Settings1.Default.User) || Settings1.Default.AuthenticationType == "Windows")
                {
                    userid = "$$@#$$";
                }

                string _cmd = Directory.GetCurrentDirectory() + "//" + "SQLCDCIDLoader.exe " + _sqljobid + " " +
                              Settings1.Default.Server + " " + userid + " " + password;
                _sajob.SQLJobStep(_cmd, _sqljobname);

                MessageBox.Show(_sqljobname + " created on " + Settings1.Default.Server + ". Schedule accordingly from SQL Server Agent.", "SQLCDCApp");

                Cursor.Current = Cursors.Arrow;
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "SQLCDCApp Error!!!");
            }
            // update meta tables with sql job id.
        }