Esempio n. 1
0
        /// <summary>
        /// Get Jobs
        /// </summary>
        /// <returns></returns>
        public static ResultJobsExtended GetJobs()
        {
            ResultJobsExtended resultJobs = new ResultJobsExtended();

            resultJobs.ReturnCode   = 0;
            resultJobs.Message      = "";
            resultJobs.RecordsCount = 0;

            try
            {
                lock (lockObj)
                {
                    LogManager.Configuration.Variables["JobName"] = "General";
                    string urlParameters = "";
                    string URL           = "";
                    string returnMessage = "";

                    HttpResponseMessage response = new HttpResponseMessage();
                    HttpClient          client   = new HttpClient();
                    client.Timeout = TimeSpan.FromMinutes(15);
                    URL            = VFRDuplicateRemoverService.BaseURL + "Jobs/GetJobs";

                    urlParameters      = "";
                    client.BaseAddress = new Uri(URL);
                    response           = client.GetAsync(urlParameters).Result;
                    using (HttpContent content = response.Content)
                    {
                        Task <string> resultTemp = content.ReadAsStringAsync();
                        returnMessage = resultTemp.Result;
                        resultJobs    = JsonConvert.DeserializeObject <ResultJobsExtended>(returnMessage);
                    }
                    if (!response.IsSuccessStatusCode)
                    {
                        nlogger.Error("Error:" + "\r\n" + response.ReasonPhrase + "\r\n" + response.RequestMessage);
                        Console.WriteLine("Error:" + "\r\n" + response.ReasonPhrase + "\r\n" + response.RequestMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                lock (lockObj)
                {
                    LogManager.Configuration.Variables["JobName"] = "General";
                    nlogger.Fatal(General.ErrorMessage(ex));
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(General.ErrorMessage(ex));
                    Console.ForegroundColor = ConsoleColor.White;
                    resultJobs.ReturnCode   = -2;
                    resultJobs.Message      = ex.Message;
                }
            }
            return(resultJobs);
        }
Esempio n. 2
0
        /// <summary>
        /// Get Job by a given ID
        /// </summary>
        /// <param name="jobID"></param>
        /// <returns></returns>
        public static ResultJobsExtended GetJobByID(string logJobName, int jobID)
        {
            ResultJobsExtended resultJobs = new ResultJobsExtended();

            resultJobs.ReturnCode   = 0;
            resultJobs.Message      = "";
            resultJobs.RecordsCount = 0;
            try
            {
                lock (lockObj)
                {
                    string urlParameters = "";
                    string URL           = "";
                    string returnMessage = "";

                    HttpResponseMessage response = new HttpResponseMessage();
                    HttpClient          client   = new HttpClient();
                    client.Timeout = TimeSpan.FromMinutes(15);
                    URL            = BatchRemoverService.BaseURL + "Jobs/GetJobByID?jobID=" + jobID.ToString();

                    urlParameters      = "";
                    client.BaseAddress = new Uri(URL);
                    response           = client.GetAsync(urlParameters).Result;
                    using (HttpContent content = response.Content)
                    {
                        Task <string> resultTemp = content.ReadAsStringAsync();
                        returnMessage = resultTemp.Result;
                        resultJobs    = JsonConvert.DeserializeObject <ResultJobsExtended>(returnMessage);
                    }
                    if (!response.IsSuccessStatusCode)
                    {
                        General.Logger(General.LogLevel.Error, "Error:" + "\r\n" + response.ReasonPhrase + "\r\n" + response.RequestMessage, logJobName);
                        Console.WriteLine("Error:" + "\r\n" + response.ReasonPhrase + "\r\n" + response.RequestMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                lock (lockObj)
                {
                    General.Logger(General.LogLevel.Error, General.ErrorMessage(ex), logJobName);
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(General.ErrorMessage(ex));
                    Console.ForegroundColor = ConsoleColor.White;
                    resultJobs.ReturnCode   = -2;
                    resultJobs.Message      = ex.Message;
                }
            }
            return(resultJobs);
        }
Esempio n. 3
0
        private void CheckBatchNumber()
        {
            string             batchName          = "";
            ResultBatches      resultBatches      = new ResultBatches();
            ResultJobsExtended resultJobsExtended = new ResultJobsExtended();
            Batch        batch = new Batch();
            DialogResult result;
            string       originalBatchStatus = "";

            try
            {
                nlogger.Trace("         Operator entered the following Batch Name: " + BatchNumber.Text);

                if (BatchNumber.Text.Length > 0)
                {
                    resultBatches = DBTransactions.GetBatchesInformation("BatchNUmber = \"" + BatchNumber.Text + "\" OR BatchAlias = \"" + BatchNumber.Text + "\"", "");
                    if (resultBatches.RecordsCount == 0)
                    {
                        // Batch not found
                        nlogger.Trace("         Batch Name " + BatchNumber.Text + " entered could not be found");
                        result = MessageBox.Show(this, "The Batch Name entered could not be found.", "Info ....", MessageBoxButtons.OK,
                                                 MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                    }
                    else
                    {
                        // Batch Found
                        batch = resultBatches.ReturnValue[0];

                        resultJobsExtended = DBTransactions.GetJobByName(batch.JobType);

                        batchName = batch.BatchNumber;
                        if (BatchNumber.Text == resultBatches.ReturnValue[0].BatchAlias)
                        {
                            nlogger.Trace("         Batch Name " + BatchNumber.Text + " entered is an Alias. The corresponding Batch Name is: " + batchName);
                            result = MessageBox.Show(this, "The number entered is a Batch Alias Name. The corresponing Box Number/Name is: " + batchName, "Info ....", MessageBoxButtons.OK,
                                                     MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                        }
                        ResetValues();

                        BatchNameTextBox.Text      = batchName;
                        CurrentStatusTextBox.Text  = batch.StatusFlag;
                        originalBatchStatus        = batch.StatusFlag;
                        BatchAliasNameTextBox.Text = batch.BatchAlias;
                        RecallCommentsTextBox.Text = batch.RecallReason;
                        RejectCommentsTextBox.Text = batch.RejectionReason;

                        //Only Batches in the following stages are allowed to be change:
                        //Waiting for Validation, Waiting for QC, QC on Hold, QC Failed, Rejected, and Waiting for PDF Conversion
                        if (CurrentStatusTextBox.Text == "Waiting for Validation" || CurrentStatusTextBox.Text == "Waiting for QC" ||
                            CurrentStatusTextBox.Text == "QC on Hold" || CurrentStatusTextBox.Text == "QC Failed" ||
                            CurrentStatusTextBox.Text == "Waiting for Approval" || CurrentStatusTextBox.Text == "Waiting for PDF Conversion")
                        {
                            EnableButtons();
                            nlogger.Trace("         Enable / Disable Options based on current Status.");

                            switch (CurrentStatusTextBox.Text)
                            {
                            case "Waiting for Approval":
                                RejectedRadioButton.Enabled = true;
                                RecallRadioButton.Enabled   = true;
                                DeleteRadioButton.Enabled   = true;
                                break;

                            case "Waiting for Validation":
                            case "Waiting for PDF Conversion":
                            case "QC on Hold":
                            case "QC Failed":
                            case "Waiting for QC":
                                RejectedRadioButton.Enabled = false;
                                RecallRadioButton.Enabled   = true;
                                DeleteRadioButton.Enabled   = true;
                                break;
                            }
                        }
                        else
                        {
                            RejectedRadioButton.Enabled = false;
                            RecallRadioButton.Enabled   = false;
                            nlogger.Trace("         Batch Number " + batchName + " can only be set for Deletion.");
                            result = MessageBox.Show(this, "Batch Number " + batchName + " can only be set for Deletion.", "Message...", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                ApplyButton.Enabled = false;
                ClearButton.Enabled = true;
            }
            catch (Exception ex)
            {
                General.ErrorMessage(ex);
            }
        }
Esempio n. 4
0
        private void ProcessForm_Load(object sender, EventArgs e)
        {
            try
            {
                this.Text = (currentProcessName + " Service Configuration").ToUpper();

                ResultJobsExtended    resultJobs         = new ResultJobsExtended();
                ResultProcesses       resultProcess      = new ResultProcesses();
                List <JobExtended>    jobs               = new List <JobExtended>();
                List <ServiceStation> serviceStations    = new List <ServiceStation>();
                List <ServiceStation> pdfServiceStations = new List <ServiceStation>();

                // Load Process List View
                string returnMessage = "";
                Cursor.Current = Cursors.WaitCursor;

                string urlParameters         = "";
                string URL                   = "";
                HttpResponseMessage response = new HttpResponseMessage();

                // Get Jobs
                HttpClient client1 = new HttpClient();
                client1.Timeout     = TimeSpan.FromMinutes(15);
                URL                 = BaseURL + "Jobs/GetJobs";
                urlParameters       = "";
                client1.BaseAddress = new Uri(URL);
                response            = client1.GetAsync(urlParameters).Result;
                using (HttpContent content = response.Content)
                {
                    Task <string> resultTemp = content.ReadAsStringAsync();
                    returnMessage = resultTemp.Result;
                    resultJobs    = JsonConvert.DeserializeObject <ResultJobsExtended>(returnMessage);
                }
                if (response.IsSuccessStatusCode)
                {
                    jobs = resultJobs.ReturnValue;
                    // Add especial Job tothe Jobs List
                    JobExtended job = new JobExtended();
                    job.JobName = "ALL";
                    job.JobID   = 0;
                    jobs.Add(job);
                    JobsComboBox.Items.Add("");
                    foreach (var item in jobs)
                    {
                        JobsComboBox.Items.Add(item.JobName.Trim());
                    }
                }
                else
                {
                    MessageBox.Show("Error:" + "\r\n" + response.ReasonPhrase + "\r\n" + response.RequestMessage,
                                    "Transaction Error...", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (!string.IsNullOrEmpty(Data.GlovalVariables.currentJobName))
                {
                    // This is the case where this template is called from a Job configuration
                    JobsComboBox.Enabled = false;
                    JobsComboBox.Text    = Data.GlovalVariables.currentJobName.Trim();
                }

                // Get Service Stations
                HttpClient client2 = new HttpClient();
                client2.Timeout = TimeSpan.FromMinutes(15);
                ResultServiceStations resultResultStations = new ResultServiceStations();
                URL                 = BaseURL + "GeneralSettings/GetServiceStations";
                urlParameters       = "";
                client2.BaseAddress = new Uri(URL);
                response            = client2.GetAsync(urlParameters).Result;
                using (HttpContent content = response.Content)
                {
                    Task <string> resultTemp = content.ReadAsStringAsync();
                    returnMessage        = resultTemp.Result;
                    resultResultStations = JsonConvert.DeserializeObject <ResultServiceStations>(returnMessage);
                }
                if (response.IsSuccessStatusCode)
                {
                    ServiceStationsComboBox.Items.Add("");
                    PDFServiceStationsComboBox.Items.Add("");
                    serviceStations = resultResultStations.ReturnValue;
                    foreach (ServiceStation serviceStation in serviceStations)
                    {
                        ServiceStationsComboBox.Items.Add(serviceStation.StationName.Trim());
                        // Identify if Station is use for PDF Conversion
                        if (serviceStation.PDFStationFlag)
                        {
                            pdfServiceStations.Add(serviceStation);
                            PDFServiceStationsComboBox.Items.Add(serviceStation.StationName.Trim());
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Error:" + "\r\n" + response.ReasonPhrase + "\r\n" + response.RequestMessage,
                                    "Transaction Error...", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                resultProcess = GetProcess();
                string enableFlag      = "";
                string cronDescription = "";
                string cronJob         = "";

                // Table Definition - We will use this definition for Any Process in the System
                DataTable dt = new DataTable("Processes");
                dt.Columns.Add("ProcessID", typeof(string));
                dt.Columns.Add("JobID", typeof(string));
                dt.Columns.Add("StationID", typeof(string));
                dt.Columns.Add("PDFStationID", typeof(string));

                dt.Columns.Add("Status", typeof(string));
                dt.Columns.Add("CustomerName", typeof(string));
                dt.Columns.Add("JobName", typeof(string));
                dt.Columns.Add("ServiceStation", typeof(string));
                dt.Columns.Add("PDFServiceStation", typeof(string));
                dt.Columns.Add("Schedule", typeof(string));
                dt.Columns.Add("CronDescription", typeof(string));

                // Load Table Information
                // this condition is to support load balancing associated to FIle Conversion Stations
                if (Data.GlovalVariables.currentProcessName == "Load Balancer???")
                {
                    ServiceStationsComboBox.Enabled    = true;
                    PDFServiceStationsComboBox.Enabled = true;
                    foreach (JobExtended job in jobs)
                    {
                        foreach (ServiceStation serviceStation in serviceStations)
                        {
                            foreach (ServiceStation pdfserviceStation in pdfServiceStations)
                            {
                                enableFlag      = "No Configured";
                                cronDescription = "";
                                cronJob         = "";
                                foreach (var process in resultProcess.ReturnValue)
                                {
                                    if (process.ProcessID.ToString() == Data.GlovalVariables.currentProcessID.ToString() && process.JobID.ToString() == job.JobID.ToString() &&
                                        process.StationID.ToString() == serviceStation.StationID.ToString() && process.PDFStationID.ToString() == pdfserviceStation.StationID.ToString())
                                    {
                                        enableFlag      = Convert.ToString(process.EnableFlag);
                                        cronDescription = process.CronDescription;
                                        cronJob         = process.ScheduleCronFormat;
                                        break;
                                    }
                                }

                                if (Data.GlovalVariables.currentJobName == job.JobName || string.IsNullOrEmpty(Data.GlovalVariables.currentJobName))
                                {
                                    DataRow dr = dt.NewRow();
                                    dr["ProcessID"]    = Data.GlovalVariables.currentProcessID.ToString();
                                    dr["JobID"]        = job.JobID.ToString();
                                    dr["StationID"]    = serviceStation.StationID.ToString();
                                    dr["PDFStationID"] = pdfserviceStation.StationID.ToString();
                                    dr["Status"]       = enableFlag;
                                    if (job.JobName.Trim() == "ALL")
                                    {
                                        dr["CustomerName"] = "";
                                    }
                                    else
                                    {
                                        dr["CustomerName"] = job.CustomerName.Trim();
                                    }
                                    dr["JobName"]           = job.JobName.Trim();
                                    dr["ServiceStation"]    = serviceStation.StationName.Trim();
                                    dr["PDFServiceStation"] = pdfserviceStation.StationName.Trim();
                                    dr["Schedule"]          = cronJob;
                                    dr["CronDescription"]   = cronDescription;
                                    dt.Rows.Add(dr);
                                }
                            }
                        }
                    }
                }
                else
                {
                    ServiceStationsComboBox.Enabled    = true;
                    PDFServiceStationsComboBox.Enabled = false;
                    string serviceStation   = "";
                    string serviceStationID = "";
                    foreach (JobExtended job in jobs)
                    {
                        enableFlag      = "No Configured";
                        serviceStation  = "";
                        cronDescription = "";
                        cronJob         = "";
                        foreach (var process in resultProcess.ReturnValue)
                        {
                            if (process.ProcessID.ToString() == Data.GlovalVariables.currentProcessID.ToString() && process.JobID.ToString() == job.JobID.ToString())
                            {
                                enableFlag       = Convert.ToString(process.EnableFlag);
                                serviceStationID = process.StationID.ToString();
                                serviceStation   = process.StationName;
                                cronDescription  = process.CronDescription;
                                cronJob          = process.ScheduleCronFormat;
                                break;
                            }
                        }
                        DataRow dr = dt.NewRow();
                        dr["ProcessID"] = Data.GlovalVariables.currentProcessID.ToString();
                        dr["JobID"]     = job.JobID.ToString();
                        dr["StationID"] = serviceStationID;
                        //dr["PDFStationID"] = pdfserviceStation.StationID.ToString();
                        dr["Status"] = enableFlag;
                        if (job.JobName.Trim() == "ALL")
                        {
                            dr["CustomerName"] = "";
                        }
                        else
                        {
                            dr["CustomerName"] = job.CustomerName.Trim();
                        }
                        dr["JobName"]        = job.JobName.Trim();
                        dr["ServiceStation"] = serviceStation.Trim();
                        //dr["PDFServiceStation"] = pdfserviceStation.StationName.Trim();
                        dr["Schedule"]        = cronJob;
                        dr["CronDescription"] = cronDescription;
                        dt.Rows.Add(dr);
                    }
                }

                bs.DataSource = dt;

                // Define DataGrid
                // Filter Header based on Process Type { Synchronizer, Indexer, Load Balancer, Batch Delivery, etc }
                ProcessGridView.DataSource = dt;
                ProcessGridView.Columns["ProcessID"].Visible           = false;
                ProcessGridView.Columns["JobID"].Visible               = false;
                ProcessGridView.Columns["StationID"].Visible           = false;
                ProcessGridView.Columns["PDFStationID"].Visible        = false;
                ProcessGridView.Columns["CustomerName"].Visible        = false;
                ProcessGridView.Columns["CustomerName"].AutoSizeMode   = DataGridViewAutoSizeColumnMode.AllCells;
                ProcessGridView.Columns["CustomerName"].HeaderText     = "Customer Name";
                ProcessGridView.Columns["Status"].AutoSizeMode         = DataGridViewAutoSizeColumnMode.AllCells;
                ProcessGridView.Columns["Status"].ReadOnly             = true;
                ProcessGridView.Columns["JobName"].AutoSizeMode        = DataGridViewAutoSizeColumnMode.AllCells;
                ProcessGridView.Columns["JobName"].ReadOnly            = true;
                ProcessGridView.Columns["JobName"].HeaderText          = "Job Name";
                ProcessGridView.Columns["ServiceStation"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                ProcessGridView.Columns["ServiceStation"].ReadOnly     = true;
                ProcessGridView.Columns["ServiceStation"].HeaderText   = "Service Station";
                // The following condition is to be considered for future implementation
                if (Data.GlovalVariables.currentProcessName == "Load Balancer ???")
                {
                    ProcessGridView.Columns["PDFServiceStation"].Visible = true;
                }
                else
                {
                    ProcessGridView.Columns["PDFServiceStation"].Visible = false;
                }
                ProcessGridView.Columns["PDFServiceStation"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                ProcessGridView.Columns["PDFServiceStation"].ReadOnly     = true;
                ProcessGridView.Columns["PDFServiceStation"].HeaderText   = "PDF Service Station";
                ProcessGridView.Columns["Schedule"].AutoSizeMode          = DataGridViewAutoSizeColumnMode.AllCells;
                ProcessGridView.Columns["Schedule"].ReadOnly            = true;
                ProcessGridView.Columns["CronDescription"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                ProcessGridView.Columns["CronDescription"].ReadOnly     = true;
                ProcessGridView.Columns["CronDescription"].HeaderText   = "Cron Description";

                ProcessGridView.AllowUserToAddRows    = false;
                ProcessGridView.RowHeadersVisible     = true;
                ProcessGridView.AllowUserToAddRows    = false;
                ProcessGridView.AllowUserToResizeRows = false;
            }
            catch (Exception ex)
            {
                //MainForm.ErrorMessage(ex);
                nlogger.Fatal(General.ErrorMessage(ex));
                MessageBox.Show(General.ErrorMessage(ex), "Error ...", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }