Exemple #1
0
 /// <summary>
 /// Check whether all jobs are not running, if any job is running state then prompt user
 /// Based on user's feedback, close the form
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (GridView.Rows.Count > 0)
     {
         Log.WriteMessage("Form closing event starts!");
         foreach (DataGridViewRow drData in GridView.Rows)
         {
             Log.WriteMessage("Prompt user as Jobs are in Running state!");
             if (drData.Cells[2].Value.ToString() == "Running")
             {
                 DialogResult drUserResponse = MessageBox.Show("Few of the Job(s) are running. Closing form will stop all Job(s). Do you wish to continue?\n\nClicking 'Yes' will stop all jobs and closes form.\nClicking 'No' will do nothing.", "Live Feed", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                 if (drUserResponse == System.Windows.Forms.DialogResult.No)
                 {
                     Log.WriteMessage("User confirmed to cancel the form close event!");
                     e.Cancel = true;
                     return;
                 }
                 else
                 {
                     Log.WriteMessage("User confirmed to abort process and close form!");
                     AbortProcess();
                     m_hstJobCollections = null;
                     m_xdData            = null;
                     objPollPushService  = null;
                     Log.Close();
                     return;
                 }
             }
         }
     }
     Log.Close();
     m_hstJobCollections = null;
     m_xdData            = null;
     objPollPushService  = null;
 }
Exemple #2
0
        /// <summary>
        /// Processes selected job.
        /// </summary>
        /// <param name="SelectedRow">DataGridViewRow, selected row to process</param>
        private void ProcessSelectedFeed(DataGridViewRow SelectedRow)
        {
            if (SelectedRow.Cells[0].Value.ToString() == "Start Job")
            {
                Log.WriteMessage("Job Started...");
                XmlNode xnJobs          = m_xdData.SelectSingleNode("/Jobs/Job[@Name='" + SelectedRow.Cells[Helper.JOBNAME].Value.ToString() + "']");
                string  sConnectionData = xnJobs.InnerXml;

                XmlNode xnConnectionData = xnJobs.SelectSingleNode("./Connection");

                //Source
                string sSourceServerName = xnConnectionData.Attributes["SourceServerName"].Value;
                string sSourceDbName     = xnConnectionData.Attributes["SourceDatabaseName"].Value;
                string sSourceUserName   = xnConnectionData.Attributes["SourceUserID"].Value;
                string sSourcePwd        = Helper.Decrypt(xnConnectionData.Attributes["SourcePwd"].Value);

                //Destination
                string sClientID       = xnConnectionData.Attributes["ClientID"].Value;
                string sUserID         = xnConnectionData.Attributes["UserName"].Value;
                string sUserPwd        = Helper.Decrypt(xnConnectionData.Attributes["Password"].Value);
                string DestDatasetName = xnConnectionData.Attributes["DatasetName"].Value;

                UserCredential uc = new UserCredential(sUserID, sUserPwd);

                Log.WriteMessage("Fetching Source and Destination details");

                string JobName = SelectedRow.Cells[Helper.JOBNAME].Value.ToString();

                string sConnectionString = Helper.ConnectionString(sSourceServerName, sSourceDbName, sSourceUserName, sSourcePwd);

                Log.WriteMessage("Created Connection string!");

                objPollPushService                    = new PollPushService();
                objPollPushService.ClientID           = sClientID;
                objPollPushService.SelectedRow        = SelectedRow;
                objPollPushService.UserCredential     = uc;
                objPollPushService.TableName          = SelectedRow.Cells[Helper.JOBDATASET].Value.ToString();
                objPollPushService.RecordsAffected    = 0;
                objPollPushService.ConnectionString   = sConnectionString;
                objPollPushService.PowerBIDatasetName = DestDatasetName;
                objPollPushService.datasetId          = xnConnectionData.Attributes["DatasetID"].Value;

                objPollPushService.Interval     = Convert.ToInt32(SelectedRow.Cells[Helper.JOBINTERVAL].Value);
                objPollPushService.IsIntialLoad = Convert.ToBoolean(xnConnectionData.Attributes["IsFullLoad"].Value);

                Hashtable hstVersion = new Hashtable();    //Get the versions based on table
                foreach (XmlNode xnMetadata in xnJobs.SelectNodes("./JobMetadata"))
                {
                    hstVersion.Add(xnMetadata.Attributes["Datasetname"].Value.ToString(), xnMetadata.Attributes["Version"].Value.ToString());
                }

                objPollPushService.CurrentVersion = hstVersion;
                objPollPushService.JobDetails     = xnJobs;

                objPollPushService.RefreshJobDetailUI = UpdateJobUI;
                Thread tPollPushService = new Thread(objPollPushService.PushData);
                tPollPushService.Start();

                if (m_hstJobCollections.Contains(SelectedRow.Cells[Helper.JOBNAME].Value.ToString()) == false)
                {
                    m_hstJobCollections.Add(SelectedRow.Cells[Helper.JOBNAME].Value.ToString(), tPollPushService);    //Adding to collection for tracking
                }
                Log.WriteMessage("Thread Started");
                SelectedRow.Cells[Helper.JOBSTATUS].Value = "Running";
                SelectedRow.Cells[0].Value = "Stop Job";
            }    //end ( if (SelectedRow.Cells[0].Value.ToString() == "Start Job"))
            else
            {
                Log.WriteMessage("Job stopped...");
                JobStatus.Text = SelectedRow.Cells[Helper.JOBNAME].Value.ToString() + " job is in 'Stopped' status";

                if (m_hstJobCollections.Contains(SelectedRow.Cells[Helper.JOBNAME].Value))
                {
                    Thread objService = m_hstJobCollections[SelectedRow.Cells[Helper.JOBNAME].Value] as Thread;
                    objService.Abort();
                    objService.Join();
                    m_hstJobCollections.Remove(SelectedRow.Cells[Helper.JOBNAME].Value);
                    SelectedRow.Cells[0].Value = "Start Job";

                    if (SelectedRow.Cells[Helper.JOBSTATUS].Value.ToString() != "Failed")
                    {
                        SelectedRow.Cells[Helper.JOBSTATUS].Value = "Stopped";
                    }
                } //end (if (m_hstJobCollections.Contains(SelectedRow)))
            }     //end (else of  if (SelectedRow.Cells[0].Value.ToString() == "Start Job"))
        }
Exemple #3
0
        /// <summary>
        /// Processes selected job.
        /// </summary>
        /// <param name="SelectedRow">DataGridViewRow, selected row to process</param>
        private void ProcessSelectedFeed(DataGridViewRow SelectedRow)
        {
            if (SelectedRow.Cells[0].Value.ToString() == "Start Job")
                {
                    Log.WriteMessage("Job Started...");
                    XmlNode xnJobs = m_xdData.SelectSingleNode("/Jobs/Job[@Name='" + SelectedRow.Cells[Helper.JOBNAME].Value.ToString() + "']");
                    string sConnectionData = xnJobs.InnerXml;

                    XmlNode xnConnectionData = xnJobs.SelectSingleNode("./Connection");

                    //Source
                    string sSourceServerName = xnConnectionData.Attributes["SourceServerName"].Value;
                    string sSourceDbName = xnConnectionData.Attributes["SourceDatabaseName"].Value;
                    string sSourceUserName = xnConnectionData.Attributes["SourceUserID"].Value;
                    string sSourcePwd = Helper.Decrypt(xnConnectionData.Attributes["SourcePwd"].Value);

                    //Destination
                    string sClientID = xnConnectionData.Attributes["ClientID"].Value;
                    string sUserID = xnConnectionData.Attributes["UserName"].Value;
                    string sUserPwd = Helper.Decrypt(xnConnectionData.Attributes["Password"].Value);
                    string DestDatasetName = xnConnectionData.Attributes["DatasetName"].Value;

                    UserCredential uc = new UserCredential(sUserID, sUserPwd);

                    Log.WriteMessage("Fetching Source and Destination details");

                    string JobName = SelectedRow.Cells[Helper.JOBNAME].Value.ToString();

                    string sConnectionString = Helper.ConnectionString(sSourceServerName, sSourceDbName, sSourceUserName, sSourcePwd );

                    Log.WriteMessage("Created Connection string!");

                    objPollPushService = new PollPushService();
                    objPollPushService.ClientID = sClientID;
                    objPollPushService.SelectedRow = SelectedRow;
                    objPollPushService.UserCredential = uc;
                    objPollPushService.TableName = SelectedRow.Cells[Helper.JOBDATASET].Value.ToString();
                    objPollPushService.RecordsAffected = 0;
                    objPollPushService.ConnectionString = sConnectionString;
                    objPollPushService.PowerBIDatasetName = DestDatasetName;
                    objPollPushService.datasetId = xnConnectionData.Attributes["DatasetID"].Value;

                    objPollPushService.Interval = Convert.ToInt32(SelectedRow.Cells[Helper.JOBINTERVAL].Value);
                    objPollPushService.IsIntialLoad = Convert.ToBoolean(xnConnectionData.Attributes["IsFullLoad"].Value);

                    Hashtable hstVersion = new Hashtable();//Get the versions based on table
                    foreach (XmlNode xnMetadata in xnJobs.SelectNodes("./JobMetadata"))
                        hstVersion.Add(xnMetadata.Attributes["Datasetname"].Value.ToString(), xnMetadata.Attributes["Version"].Value.ToString());

                    objPollPushService.CurrentVersion = hstVersion;
                    objPollPushService.JobDetails = xnJobs;

                    objPollPushService.RefreshJobDetailUI = UpdateJobUI;
                    Thread tPollPushService = new Thread(objPollPushService.PushData);
                    tPollPushService.Start();

                    if (m_hstJobCollections.Contains(SelectedRow.Cells[Helper.JOBNAME].Value.ToString()) == false)
                        m_hstJobCollections.Add(SelectedRow.Cells[Helper.JOBNAME].Value.ToString(), tPollPushService);//Adding to collection for tracking
                    Log.WriteMessage("Thread Started");
                    SelectedRow.Cells[Helper.JOBSTATUS].Value = "Running";
                    SelectedRow.Cells[0].Value = "Stop Job";

                }//end ( if (SelectedRow.Cells[0].Value.ToString() == "Start Job"))
                else
                {
                    Log.WriteMessage("Job stopped...");
                    JobStatus.Text = SelectedRow.Cells[Helper.JOBNAME].Value.ToString() + " job is in 'Stopped' status" ;

                    if (m_hstJobCollections.Contains(SelectedRow.Cells[Helper.JOBNAME].Value))
                    {
                        Thread objService = m_hstJobCollections[SelectedRow.Cells[Helper.JOBNAME].Value] as Thread;
                        objService.Abort();
                        objService.Join();
                        m_hstJobCollections.Remove(SelectedRow.Cells[Helper.JOBNAME].Value);
                        SelectedRow.Cells[0].Value = "Start Job";

                        if (SelectedRow.Cells[Helper.JOBSTATUS].Value.ToString() != "Failed")
                            SelectedRow.Cells[Helper.JOBSTATUS].Value = "Stopped";
                    }//end (if (m_hstJobCollections.Contains(SelectedRow)))

                }//end (else of  if (SelectedRow.Cells[0].Value.ToString() == "Start Job"))
        }
Exemple #4
0
 /// <summary>
 /// Check whether all jobs are not running, if any job is running state then prompt user
 /// Based on user's feedback, close the form
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (GridView.Rows.Count > 0)
         {
             Log.WriteMessage("Form closing event starts!");
             foreach (DataGridViewRow drData in GridView.Rows)
             {
                 Log.WriteMessage("Prompt user as Jobs are in Running state!");
                 if (drData.Cells[2].Value.ToString() == "Running")
                 {
                     DialogResult drUserResponse = MessageBox.Show("Few of the Job(s) are running. Closing form will stop all Job(s). Do you wish to continue?\n\nClicking 'Yes' will stop all jobs and closes form.\nClicking 'No' will do nothing.", "Live Feed", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                     if (drUserResponse == System.Windows.Forms.DialogResult.No)
                     {
                         Log.WriteMessage("User confirmed to cancel the form close event!");
                         e.Cancel = true;
                         return;
                     }
                     else
                     {
                         Log.WriteMessage("User confirmed to abort process and close form!");
                         AbortProcess();
                         m_hstJobCollections = null;
                         m_xdData = null;
                         objPollPushService = null;
                         Log.Close();
                         return;
                     }
                 }
             }
         }
         Log.Close();
         m_hstJobCollections = null;
         m_xdData = null;
         objPollPushService = null;
 }