/// <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> /// 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> /// 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 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); } }