/// <summary> /// Starts an asynchronous writeback to WMIS process /// </summary> private void DoWriteBack(SharedWriteBackLibrary p_swbl) { try { // The shared library does the actual writeback. // Once complete, it will call the WriteBackProcessCompleted event. //SharedWriteBackLibrary swbl = new SharedWriteBackLibrary(); // p_swbl.WriteBackProcessCompleted += swbl_WriteBackProcessCompleted; // Asynchronous call to perform the writeback. Guid taskID = Guid.NewGuid(); JobManager jobManager = new JobManager(); p_swbl.UpdateWriteBack(jobManager.ActiveJob, taskID); // Subscribed to writeback completed event so no longer need a pointer to the library object. p_swbl = null; // 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. jobManager.DeactivateJob(true); } catch (Exception ex) { string exMsg = string.Format("Error occurred in {0} of {1}.{2}{3}", System.Reflection.MethodBase.GetCurrentMethod().Name, this.ToString(), Environment.NewLine, ex.Message); throw new Exception(exMsg); } }
/// <summary> /// Checks writeback flag and, if it is set, starts an asynchronous writeback to WMIS process /// </summary> /// <returns>true if successful; else, false</returns> private bool DoWriteBack(SharedWriteBackLibrary p_swbl) { try { JobManager jobManager = new JobManager(); // ALM 1566 - Requests removal of the check for the write back flag. // Future design change will check for this in a different way // but leaving the conditional statement for clarity until // that change is implemented. if (true /*jobManager.WriteBackNeeded*/) { // The shared library does the actual writeback. // Asynchronous call to perform the writeback. Guid taskID = Guid.NewGuid(); p_swbl.UpdateWriteBack(jobManager.ActiveJob, taskID); // Subscribed to writeback completed event so no longer need a pointer to the library object. p_swbl = null; } return(true); } catch (Exception ex) { string exMsg = string.Format("Error occurred in {0} of {1}.{2}{3}", System.Reflection.MethodBase.GetCurrentMethod().Name, this.ToString(), Environment.NewLine, ex.Message); throw new Exception(exMsg); } }
/// <summary> /// Calls the shared writeback code to set the indicated job status for the indicated WR /// This overload is needed for the Mark for Approval because it needs to set only the active /// job's Job Status. If there are alternates, then merely using the WR sets the JobStatus for /// all the alternates for the WR and only the identified job ID's status should be set. /// </summary> /// <param name="JobID">Job Identifier for which to set JobStatus</param> /// <param name="WR">WR to update</param> /// <param name="status">Status value to set</param> public void SetJobStatus(string JobID, string WR, string status) { try { SharedWriteBackLibrary swbl = new SharedWriteBackLibrary(); swbl.UpdateJobStatusProcessCompleted += swbl_UpdateJobStatusProcessCompleted; Guid taskID = Guid.NewGuid(); swbl.UpdateJobStatus(WR, status, taskID); //Subscribed to the UpdateJobStatusProcessCompleted event so no longer need pointer to the object. swbl = null; // As long as the request to update the Job Status is successful (regardless of whether the process completes successfully), // then update G3E_JOB.G3E_JOBSTATUS for the indicated Job ID. // Can't use the JobManager here since job may not active at this point. string sql = "update g3e_job set g3e_jobstatus=? where g3e_identifier=?"; IGTApplication app = GTClassFactory.Create <IGTApplication>(); app.DataContext.Execute(sql, out int recs, (int)CommandTypeEnum.adCmdText, status, JobID); app.DataContext.Execute("commit", out recs, (int)CommandTypeEnum.adCmdText); } catch (Exception ex) { string exMsg = string.Format("Error occurred in {0} of {1}.{2}{3}", System.Reflection.MethodBase.GetCurrentMethod().Name, this.ToString(), Environment.NewLine, ex.Message); throw new Exception(exMsg); } }
/// <summary> /// Calls the shared writeback code to perform the actual writeback. /// Displays the confirmation dialog box which the user can dismiss if desired (writeback will continue). /// Subscribes to the WriteBackProcessCompleted event so user can be notified when process completes. /// </summary> private void startWriteback(SharedWriteBackLibrary p_swbl) { JobManager jm = new JobManager(); // The shared library does the actual writeback. IGTApplication app = GTClassFactory.Create <IGTApplication>(); // Asynchronous call to perform the writeback. Guid taskID = Guid.NewGuid(); p_swbl.UpdateWriteBack(jm.ActiveJob, taskID); p_swbl = null; // 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); jm = null; }
/// <summary> /// Checks writeback flag and, if it is set, starts an asynchronous writeback to WMIS process /// </summary> /// <returns>true if successful; else, false</returns> private bool DoWriteBack(SharedWriteBackLibrary p_swbl) { try { JobManager jobManager = new JobManager(); // ALM 1566 - Requests removal of the check for the write back flag. // Future design change will check for this in a different way // but leaving the conditional statement for clarity until // that change is implemented. if (true /*jobManager.WriteBackNeeded*/) { // The shared library does the actual writeback. // Once complete, it will call the WriteBackProcessCompleted event. // SharedWriteBackLibrary swbl = new SharedWriteBackLibrary(); // swbl.WriteBackProcessCompleted += swbl_WriteBackProcessCompleted; // Asynchronous call to perform the writeback. Guid taskID = Guid.NewGuid(); p_swbl.UpdateWriteBack(jobManager.ActiveJob, taskID); // Subscribed to writeback completed event so no longer need a pointer to the library object. p_swbl = null; // 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. jobManager.DeactivateJob(true); } return(true); } catch (Exception ex) { string exMsg = string.Format("Error occurred in {0} of {1}.{2}{3}", System.Reflection.MethodBase.GetCurrentMethod().Name, this.ToString(), Environment.NewLine, ex.Message); throw new Exception(exMsg); } }
/// <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); }
/// <summary> /// G/Tech calls this method when the custom command is invoked. /// </summary> public void Activate() { // The Writeback is running for this session if the job's WMIS Status is not empty, SUCCESS, or FAILURE // If it is running, then exit. if (WriteBackIsRunning) { string msg = string.Format("{0}{1}{2}", "Writeback is currently running in this session.", Environment.NewLine, "Please wait until the current writeback is complete before starting another one."); MessageBox.Show(msg, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // Test all the conditions for a writeback. // Exit if any conditions fail. if (!validateJob()) { return; } // Check/Resolve any alternate jobs with pending Approval status. if (AlternatesPendingApprovalExist()) { return; } // Validate pending job edits if (!ResolveJobValidationErrors()) { return; } // Check for out of synch WPs and exit if they are not synchronized SharedWriteBackLibrary swbl = new SharedWriteBackLibrary(); if (!swbl.ValidateWorkPoints()) { return; } //// Evaluate the WriteBack flag and prompt user whether to process accordingly //JobManager jobManager = new JobManager(); //if(jobManager.WriteBackNeeded) //{ // if(DialogResult.Yes == MessageBox.Show("Write job data to WMIS?", "G/Technology", MessageBoxButtons.YesNo)) // { // startWriteback(); // } //} //else //{ // if(DialogResult.Yes == MessageBox.Show("Accounting data has not changed since the previous write to WMIS. Proceed anyway?", "G/Technology", MessageBoxButtons.YesNo)) // { // startWriteback(); // } //} // ALM 1566 eliminates use of the WriteBack flag here; however, there are other methods which, when designed and implemented // will be used in lieu of that flag. Leaving the prompts, etc., commented above as they may still be used with the new methods. // For now, just call the WriteBack with no other checks. startWriteback(swbl); }
/// <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() { try { // Check for out of synch WPs and exit if they are not synchronized SharedWriteBackLibrary swbl = new SharedWriteBackLibrary(); if (!swbl.ValidateWorkPoints()) { return; } TransactionManager.Begin("Post Job"); // PendingEditsExist builds this recordset and we can use it again in // ValidateNetworkDrawings to keep from querying for it again there. Recordset pendingEdits = null; // If there are no pending edits, then nothing else to do here. // PendingEditsExist will close/null the recordset object if there are no pending edits. if (!PendingEditsExist(ref pendingEdits)) { MessageBox.Show("There are no pending edits in the active job. Exiting command.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // Validate pending job edits if (!ResolveJobValidationErrors()) { return; } // Perform Job Validations. Return if any fail. if (!JobAttributesAreValid) { return; } // Check for existing conflicts if (ConflictsExist()) { return; } // Allow user to validate the pertinent network drawings attached to the active job. // ValidateNetworkDrawings will close/null the recordset object when finished with it. if (!ValidateNetworkDrawings(ref pendingEdits)) { return; } TransactionManager.Commit(true); // Post edits for active job if (!PostJobEdits()) { return; } // Since nothing else is updated in this command from here to the end, // a transaction here should not be necessary; however, leaving it just in case. TransactionManager.Begin("Post Job"); // If indicated, then invoke a Writeback // ALM 1566 - Requests removal of the check for the write back flag. // Future design change will check for this in a different way // but leaving the clause in the conditional statement for clarity // until that change is implemented. JobManager jobManager = new JobManager(); if (nonWR != jobManager.JobType /*&& jobManager.WriteBackNeeded*/) { DoWriteBack(swbl); } if (TransactionManager.TransactionInProgress) { TransactionManager.Commit(true); } } catch (Exception ex) { if (TransactionManager.TransactionInProgress) { TransactionManager.Rollback(); } string exMsg = string.Format("Error occurred in {0} of {1}.{2}{3}", System.Reflection.MethodBase.GetCurrentMethod().Name, this.ToString(), Environment.NewLine, ex.Message); throw new Exception(exMsg); } }