/// <summary> /// Entry method for the Custom Command Modal interface. /// </summary> public void Activate() { // Perform Job Property Validations. if (!JobPropertiesAreValid()) { return; } // Check/Resolve any alternate jobs with pending Approval status. if (AlternatesPendingApprovalExist()) { return; } // Validate pending job edits if (!ResolveJobValidationErrors()) { return; } // Check for existing conflicts if (ConflictsExist()) { return; } // Check for concurrent edits involving jobs that are pending approval and exit if any found. if (ConcurrentEditsExistWithApprovalPending()) { return; } // Check for out of synch WPs and exit if they are not synchronized SharedWriteBackLibrary swbl = new SharedWriteBackLibrary(); if (!swbl.ValidateWorkPoints()) { return; } // If plotting boundaries exist, then attempt plot sheet generation; however, // if they don't exist, then bypass generating and storing the archival prints completely. IGTApplication app = GTClassFactory.Create <IGTApplication>(); string sql = "select count(1) from plotbnd_n where job_id=? and product_type='Construction Print'"; Recordset rs = app.DataContext.OpenRecordset(sql, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, app.DataContext.ActiveJob); // This SQL will always return a record. short boundaryCount = Convert.ToInt16(rs.Fields[0].Value); rs.Close(); rs = null; if (0 < boundaryCount) { // Generate the construction prints string constructionPrints = string.Empty; if (GenerateConstructionPrints(out constructionPrints)) { // There is currently no provision in the design to check whether the construction prints // are generated. Provided there is no processing failure (which will be trapped in an exception // and cause the previous call to generate the prints to return a false), // then since the validations have already checked for the existence of a plotting boundary, // it will be assumed that at least one plot was generated. // Attach the construction prints generated above if (!AttachConstructionPrints(constructionPrints)) { string msg = string.Format("Failed to upload construction prints for archival.{0}{0}Proceed anyway?", System.Environment.NewLine); if (DialogResult.No == MessageBox.Show(msg, "G/Technology", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { return; } } } else { string msg = string.Format("Failed to generate construction prints for archival.{0}{0}Proceed anyway?", System.Environment.NewLine); if (DialogResult.No == MessageBox.Show(msg, "G/Technology", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { return; } } } // Cache these here for use with the SetJobStatus interface (in case something deactivates the job before then). JobManager jm = new JobManager(); this.ActiveWRNbr = jm.WRNumber; this.ActiveJobID = jm.ActiveJob; if (jm.NullNumericFieldValue) { throw new Exception("The WR value for this job is NULL"); } // Check for writeback flag and perform writeback if set if (!DoWriteBack(swbl)) { return; } // Request job status change to ApprovalPending // and set job status to ApprovalPending if request is successful. WMISStatus wMISStatus = new WMISStatus(); wMISStatus.SetJobStatus(this.ActiveJobID, this.ActiveWRNbr.ToString(), approvalPending); }
/// <summary> /// Entry point for the Custom Command Modal interface. /// </summary> public void Activate() { // Perform Job Validations. Return if any fail. if (!JobAttributesAreValid) { return; } if (CompanyNumbersAreEmpty) { return; } // Validate pending job edits if (!ResolveJobValidationErrors()) { return; } SharedWriteBackLibrary swbl = new SharedWriteBackLibrary(); if (!swbl.ValidateWorkPoints()) { return; } // Check for existing conflicts if (ConflictsExist()) { return; } // Post edits for active job if (!PostJobEdits()) { return; } // If plotting boundaries exist, then attempt plot sheet generation; however, // if they don't exist, then bypass generating and storing the archival prints completely. IGTApplication app = GTClassFactory.Create <IGTApplication>(); string sql = "select count(1) from plotbnd_n where job_id=? and product_type='Construction Print'"; Recordset rs = app.DataContext.OpenRecordset(sql, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, app.DataContext.ActiveJob); // This SQL will always return a record. short boundaryCount = Convert.ToInt16(rs.Fields[0].Value); rs.Close(); rs = null; if (0 < boundaryCount) { // Generate the construction prints string constructionPrints = string.Empty; if (GenerateConstructionPrints(out constructionPrints)) { // There is currently no provision in the design to check whether the construction prints // are generated. Provided there is no processing failure (which will be trapped in an exception // and cause the previous call to generate the prints to return a false), // then since the validations have already checked for the existence of a plotting boundary, // it will be assumed that at least one plot was generated. // Attach the construction prints generated above if (!AttachConstructionPrints(constructionPrints)) { string msg = string.Format("Failed to upload construction prints for archival.{0}{0}Proceed anyway?", System.Environment.NewLine); if (DialogResult.No == MessageBox.Show(msg, "G/Technology", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { return; } } } else { string msg = string.Format("Failed to generate construction prints for archival.{0}{0}Proceed anyway?", System.Environment.NewLine); if (DialogResult.No == MessageBox.Show(msg, "G/Technology", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { return; } } } // Cache that here for use with the SetJobStatus interface (in case something deactivates the job before then). JobManager jm = new JobManager(); this.ActiveWRNbr = jm.WRNumber; // Invoke a Writeback if needed. if (!DoWriteBack(swbl)) { return; } // Invoke the ClosurePending status update // and, if successful, set the local Job Status to ClosurePending. WMISStatus wMISStatus = new WMISStatus(); wMISStatus.SetJobStatus(this.ActiveWRNbr.ToString(), closurePending); // Deactivate the active job. // The argument determines whether to keep the job associated with the workspace in read-only mode. // Design doesn't state one way or the other but going with true. jm.DeactivateJob(true); }
private void App_ActiveJobChanged(object sender, GTActiveJobChangedEventArgs e) { string jobStatus = null; string wmisStatus = null; string Job = e.ActiveJob; if (string.IsNullOrEmpty(Job)) //if no job is active, do nothing { return; } IGTApplication app = (IGTApplication)sender; IGTDataContext dc = app.DataContext; string SQL = "select G3E_JOBSTATUS, WMIS_STATUS_C , G3E_ENABLELOGGING FROM G3E_JOB WHERE G3E_IDENTIFIER=?"; ADODB.Recordset RS = dc.OpenRecordset(SQL, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, Job); if (RS != null && RS.RecordCount == 1) { RefreshLoggingProperty(app, Convert.ToString(RS.Fields["G3E_ENABLELOGGING"].Value)); //this section handles various WMIS statuses, then deactivates the job and skips all remaining steps. wmisStatus = Convert.ToString(RS.Fields["WMIS_STATUS_C"].Value).ToUpper().Trim(); if (wmisStatus != "SUCCESS" && wmisStatus != "FAILURE" && !string.IsNullOrEmpty(wmisStatus)) { if (InteractiveMode) { switch (wmisStatus) { case "WRITEBACK": MessageBox.Show("Job cannot be activated while a writeback operation is in progress.", "G/Technology", MessageBoxButtons.OK); break; case "BATCH": MessageBox.Show("Job cannot be activated while a batch operation is in progress.", "G/Technology", MessageBoxButtons.OK); break; case "STATUSCHG": MessageBox.Show("Job cannot be activated while a status change is being communicated to WMIS.", "G/Technology", MessageBoxButtons.OK); break; case "ERROR": MessageBox.Show("Job cannot be activated due to an outstanding error; please notify Support.", "G/Technology", MessageBoxButtons.OK); break; default: break; } } DeactivateJob(Job); //deactivate job return; //skip remaining actions (job status section) } //this section handles various job statuses jobStatus = Convert.ToString(RS.Fields["G3E_JOBSTATUS"].Value).ToUpper().Trim(); if (!string.IsNullOrEmpty(jobStatus)) { switch (jobStatus) { case "APPROVALPENDING": if (InteractiveMode) { DialogResult ApprovalPendingResult = MessageBox.Show("WR is marked for approval. Unmark?", "G/Technology", MessageBoxButtons.YesNo); if (ApprovalPendingResult == DialogResult.Yes) { //change job status to Design and leave job active WMISStatus wMISStatus = new WMISStatus(); wMISStatus.SetJobStatus(Job, "Design"); } if (ApprovalPendingResult == DialogResult.No) { MessageBox.Show("Job is being deactivated and the WR will remain marked for approval.", "G/Technology", MessageBoxButtons.OK); DeactivateJob(Job); //deactivate job } } else // UnattendedMode { //change job status to Design and leave job active WMISStatus wMISStatus = new WMISStatus(); wMISStatus.SetJobStatus(Job, "Design"); } break; case "DESIGN": bool hasAlternateDesign = false; //initialize to false. This will be set in the if statements below if an alternate design exists for the job. //this if/else determines if the active job contains a "-" character. Whether this is true or not determines what the SQL statement looks like. if (Job.Contains("-")) { string jobSubstring = Job.Substring(0, Job.IndexOf("-")); SQL = "select G3E_IDENTIFIER, G3E_JOBSTATUS from G3E_JOB where G3E_IDENTIFIER like ? and G3E_JOBSTATUS=?"; RS = dc.OpenRecordset(SQL, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, jobSubstring + "-%", "ApprovalPending"); } else { SQL = "select G3E_IDENTIFIER, G3E_JOBSTATUS from G3E_JOB where G3E_IDENTIFIER like ? and G3E_JOBSTATUS=?"; RS = dc.OpenRecordset(SQL, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, Job + "-%", "ApprovalPending"); } if (RS != null && RS.RecordCount > 0) //check to see if recordset from above if/else has records. If yes, this job has an alternate design. { hasAlternateDesign = true; } if (hasAlternateDesign) { string altJobIdentifier = Convert.ToString(RS.Fields["G3E_IDENTIFIER"].Value); if (InteractiveMode) { DialogResult DesignResult = MessageBox.Show("An alternate design for this WR is marked for approval. Unmark it so that this alternate may be activated?", "G/Technology", MessageBoxButtons.YesNo); if (DesignResult == DialogResult.Yes) { //update job status to Design for the alternate design, and leave the current job active WMISStatus wMISStatus = new WMISStatus(); wMISStatus.SetJobStatus(altJobIdentifier, "Design"); } if (DesignResult == DialogResult.No) { MessageBox.Show("Job is being deactivated and the alternate design will remain marked for approval.", "G/Technology", MessageBoxButtons.OK); DeactivateJob(Job); //deactivate job } } else // UnattendedMode { //update job status to Design for the alternate design, and leave the current job active WMISStatus wMISStatus = new WMISStatus(); wMISStatus.SetJobStatus(altJobIdentifier, "Design"); } } break; case "CLOSUREPENDING": //SQL = "update G3E_JOB set G3E_JOBSTATUS='ConstructionComplete' where G3E_IDENTIFIER=?"; if (InteractiveMode) { DialogResult ClosurePendingResult = MessageBox.Show("WR is marked for closure. Unmark?", "G/Technology", MessageBoxButtons.YesNo); if (ClosurePendingResult == DialogResult.Yes) { //change job status to ConstructionComplete and leave job active WMISStatus wMISStatus = new WMISStatus(); wMISStatus.SetJobStatus(Job, "ConstructionComplete"); } if (ClosurePendingResult == DialogResult.No) { MessageBox.Show("Job is being deactivated and the WR will remain marked for closure.", "G/Technology", MessageBoxButtons.OK); DeactivateJob(Job); //deactivate job } } else // UnattendedMode { //change job status to ConstructionComplete and leave job active WMISStatus wMISStatus = new WMISStatus(); wMISStatus.SetJobStatus(Job, "ConstructionComplete"); } break; default: break; } } CommonWorkPointDisplayQuery workPointDisplayQuery = new CommonWorkPointDisplayQuery(app); workPointDisplayQuery.RedisplayWorkPoints(); } RS.Close(); }