예제 #1
0
        public static ResultBatches GetBatchesbyJobType(string logJobName, string jobType)
        {
            ResultBatches resultBatches = new ResultBatches();

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

            try
            {
                lock (lockObj)
                {
                    LogManager.Configuration.Variables["JobName"] = logJobName;
                    HttpClient client = new HttpClient();
                    client.Timeout = TimeSpan.FromMinutes(15);
                    string urlParameters         = "";
                    string URL                   = "";
                    HttpResponseMessage response = new HttpResponseMessage();
                    string returnMessage;

                    URL = VFRDuplicateRemoverService.BaseURL + "Batches/GetBatchesInformation?filter=" + "JobType = \"" + jobType + "\"";

                    client.BaseAddress = new Uri(URL);
                    response           = client.GetAsync(urlParameters).Result;

                    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);
                        resultBatches.Message    = "Error:" + "\r\n" + response.ReasonPhrase + "\r\n" + response.RequestMessage;
                        resultBatches.ReturnCode = -1;
                    }
                    else
                    {
                        using (HttpContent content = response.Content)
                        {
                            Task <string> resultTemp = content.ReadAsStringAsync();
                            returnMessage = resultTemp.Result;
                            resultBatches = JsonConvert.DeserializeObject <ResultBatches>(returnMessage);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                lock (lockObj)
                {
                    LogManager.Configuration.Variables["JobName"] = logJobName;
                    nlogger.Fatal(General.ErrorMessage(ex));
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(General.ErrorMessage(ex));
                    Console.ForegroundColor  = ConsoleColor.White;
                    resultBatches.Message    = General.ErrorMessage(ex);
                    resultBatches.ReturnCode = -2;
                }
            }
            return(resultBatches);
        }
예제 #2
0
        /// <summary>
        /// Get Batches
        /// </summary>
        /// <returns></returns>
        public static ResultBatches GetBatches(string logJobName, string jobType, string statusFlag)
        {
            ResultBatches resultBatches = new ResultBatches();

            resultBatches.ReturnCode   = 0;
            resultBatches.Message      = "";
            resultBatches.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 + "Batches/GetBatchesInformation?filter=" + "StatusFlag = \"" + statusFlag + "\" AND JobType = \"" + jobType + "\"";

                    urlParameters      = "";
                    client.BaseAddress = new Uri(URL);
                    response           = client.GetAsync(urlParameters).Result;
                    using (HttpContent content = response.Content)
                    {
                        Task <string> resultTemp = content.ReadAsStringAsync();
                        returnMessage = resultTemp.Result;
                        resultBatches = JsonConvert.DeserializeObject <ResultBatches>(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;
                    resultBatches.ReturnCode = -2;
                    resultBatches.Message    = ex.Message;
                }
            }
            return(resultBatches);
        }
예제 #3
0
        private void ApplyButton_Click(object sender, EventArgs e)
        {
            ResultBatches resultBatches       = new ResultBatches();
            ResultGeneric resultGeneric       = new ResultGeneric();
            string        originalBatchStatus = "";
            Batch         batch          = new Batch();
            DialogResult  result         = DialogResult.No;
            string        action         = "";
            DateTime      currentDate    = DateTime.Now;
            ResultUsers   resultUsers    = new ResultUsers();
            List <User>   users          = new List <User>();
            Boolean       allowDeletion  = false;
            Boolean       allowRecall    = false;
            Boolean       allowRejection = false;

            try
            {
                // Get User Information to control Accesst to Functionality
                resultUsers = DBTransactions.GetUserByName(Environment.UserName);
                users       = resultUsers.ReturnValue;
                foreach (UIFunctionality functionality in users[0].UIFunctionality)
                {
                    switch (functionality.Description)
                    {
                    case "Batch  Rejection":
                        allowRejection = true;
                        break;

                    case "Batch  Recall":
                        allowRecall = true;
                        break;

                    case "Batch  Removal":
                        allowDeletion = true;
                        break;
                    }
                }

                nlogger.Trace("     QC Transaction (Apply Action) for Batch: " + BatchNameTextBox.Text);
                resultBatches = DBTransactions.GetBatchesInformation("BatchNumber = \"" + BatchNameTextBox.Text + "\"", ""); // OR BatchAlias = \"" + BatchNumber.Text + "\"", "");

                batch = resultBatches.ReturnValue[0];
                originalBatchStatus = batch.StatusFlag;

                if (RejectedRadioButton.Checked)
                {
                    action = "Rejected";
                }

                if (RecallRadioButton.Checked)
                {
                    action = "Recall";
                }

                if (DeleteRadioButton.Checked)
                {
                    action = "Delete";
                }

                switch (action)
                {
                case "Rejected":
                    if (allowRejection)
                    {
                        result = MessageBox.Show(this, "Do you want to Reject this Batch : " + BatchNameTextBox.Text + " ?", "Confirmation...", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            batch.RejectedBy       = OperatorTextBox.Text;
                            batch.RejectionReason  = RejectCommentsTextBox.Text;
                            batch.LastTimeRejected = currentDate;
                            batch.RejectedTimes    = batch.RejectedTimes + 1;
                            batch.StatusFlag       = "Rejected";

                            // Update Batch Information
                            nlogger.Trace("     Updating Batch information in Database ...");
                            resultGeneric = DBTransactions.BatchUpdate(batch);
                            if (resultGeneric.ReturnCode == 0)
                            {
                                // Batch Event Tracking
                                nlogger.Trace("     Adding transaction in Tracking Database Table ...");
                                DBTransactions.BatchTrackingEvent(batch.BatchNumber, originalBatchStatus, "Rejected", "Batch Rejected", OperatorTextBox.Text);
                            }
                        }
                    }
                    else
                    {
                        result = MessageBox.Show(this, "You are not auhorized to perform this operation.", "Information ...", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }

                    break;

                case "Recall":
                    if (allowRecall)
                    {
                        result = MessageBox.Show(this, "Do you want to request a Recall this Batch : " + BatchNameTextBox.Text + " ?", "Confirmation...", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            batch.RecallBy     = OperatorTextBox.Text;
                            batch.RecallReason = RecallCommentsTextBox.Text;
                            batch.RecallDate   = currentDate;
                            batch.RecallTimes  = batch.RecallTimes + 1;
                            batch.StatusFlag   = "Recall";

                            // Update Batch Information
                            nlogger.Trace("     Updating Batch information in Database ...");
                            resultGeneric = DBTransactions.BatchUpdate(batch);
                            if (resultGeneric.ReturnCode == 0)
                            {
                                // Batch Event Tracking
                                nlogger.Trace("     Adding transaction in Tracking Database Table ...");
                                DBTransactions.BatchTrackingEvent(batch.BatchNumber, originalBatchStatus, "Recall", "Batch tagged for Recall", OperatorTextBox.Text);
                            }
                        }
                    }
                    else
                    {
                        result = MessageBox.Show(this, "You are not auhorized to perform this operation.", "Information ...", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                    break;

                case "Delete":
                    if (allowDeletion)
                    {
                        result = MessageBox.Show(this, "Do you want to Delete this Batch : " + BatchNameTextBox.Text + " ?", "Confirmation...", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            // Tag Batch for deletion
                            batch.StatusFlag = "Waiting for Deletion";
                            // Update Batch Information
                            nlogger.Trace("     Updating Batch information in Database ...");
                            resultGeneric = DBTransactions.BatchUpdate(batch);
                            if (resultGeneric.ReturnCode == 0)
                            {
                                // Batch Event Tracking
                                nlogger.Trace("     Adding transaction in Tracking Database Table ...");
                                DBTransactions.BatchTrackingEvent(batch.BatchNumber, originalBatchStatus, "Waiting for Deletion", "Batch tagged for Deletion", OperatorTextBox.Text);
                            }
                            MessageBox.Show(this, "This operation is under Construction", "Alert...", MessageBoxButtons.YesNo, MessageBoxIcon.Hand);
                        }
                    }
                    else
                    {
                        result = MessageBox.Show(this, "You are not auhorized to perform this operation.", "Information ...", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                    break;
                }
                ResetValues();
                DisableButtons();
                DisableOptions();
                ExitButton.Enabled = true;
            }
            catch (Exception ex)
            {
                General.ErrorMessage(ex);
            }
        }
예제 #4
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);
            }
        }