// once an extract has been created, this will refresh extract master screen and open maintainance screen for extract private static void NewExtractCreated(string AExtractName, int AExtractId, Form AParentForm) { // refresh extract master screen if it is open TFormsMessage BroadcastMessage = new TFormsMessage(TFormsMessageClassEnum.mcExtractCreated); BroadcastMessage.SetMessageDataName(AExtractName); TFormsList.GFormsList.BroadcastFormMessage(BroadcastMessage); // now open Screen for new extract so user can add partner records manually TFrmExtractMaintain frm = new TFrmExtractMaintain(AParentForm); frm.ExtractId = AExtractId; frm.ExtractName = AExtractName; frm.Show(); }
/// <summary> /// this is where all the calculations take place /// </summary> /// <returns> /// true if the report was successfully generated /// </returns> public Boolean GenerateResultRemoteClient() { Boolean ReturnValue; Thread ProgressCheckThread; ReturnValue = false; FReportingGenerator = TRemote.MReporting.UIConnectors.ReportGenerator(); FKeepUpProgressCheck = true; try { this.Results = new TResultList(); FReportingGenerator.Start(this.Parameters.ToDataTable()); ProgressCheckThread = new Thread(new ThreadStart(AsyncProgressCheckThread)); ProgressCheckThread.Start(); } catch (Exception e) { TLogging.Log(e.Message); // Release the server object FReportingGenerator = null; return false; } // todo: allow canceling of the calculation of a report while (FKeepUpProgressCheck) { Thread.Sleep(500); } ReturnValue = FReportingGenerator.GetSuccess(); // Do not release the server object, we still might want to send an email... // FReportingGenerator = null; if (ReturnValue) { if (FCalculatesExtract) { TLogging.Log("Extract calculation finished. Look for extract '" + Parameters.Get("param_extract_name").ToString() + "' in Extract Master List.", TLoggingType.ToStatusBar); TFormsMessage BroadcastMessage = new TFormsMessage(TFormsMessageClassEnum.mcExtractCreated); BroadcastMessage.SetMessageDataName(Parameters.Get("param_extract_name").ToString()); TFormsList.GFormsList.BroadcastFormMessage(BroadcastMessage); } else { TLogging.Log("Report calculation finished.", TLoggingType.ToStatusBar); } } return ReturnValue; }
/// <summary> /// this is where all the calculations take place /// </summary> /// <returns>true if the report was successfully generated /// </returns> public Boolean GenerateResultRemoteClient() { Boolean ReturnValue; Thread ProgressCheckThread; ReturnValue = false; FReportingGenerator = TRemote.MReporting.UIConnectors.ReportGenerator(); FKeepUpProgressCheck = true; // Register Object with the TEnsureKeepAlive Class so that it doesn't get GC'd TEnsureKeepAlive.Register(FReportingGenerator); try { this.Results = new TResultList(); FReportingGenerator.Start(this.Parameters.ToDataTable()); ProgressCheckThread = new Thread(new ThreadStart(AsyncProgressCheckThread)); ProgressCheckThread.Start(); } catch (Exception e) { TLogging.Log(e.Message); // UnRegister Object from the TEnsureKeepAlive Class so that the Object can get GC'd on the PetraServer TEnsureKeepAlive.UnRegister(FReportingGenerator); return false; } // todo: allow canceling of the calculation of a report while (FKeepUpProgressCheck) { Thread.Sleep(500); } ReturnValue = FReportingGenerator.GetSuccess(); // UnRegister Object from the TEnsureKeepAlive Class so that the Object can get GC'd on the PetraServer TEnsureKeepAlive.UnRegister(FReportingGenerator); if (ReturnValue) { if (FCalculatesExtract) { TLogging.Log("Extract calculation finished. Look for extract '" + Parameters.Get("param_extract_name").ToString() + "' in Extract Master List.", TLoggingType.ToStatusBar); TFormsMessage BroadcastMessage = new TFormsMessage(TFormsMessageClassEnum.mcExtractCreated); BroadcastMessage.SetMessageDataName(Parameters.Get("param_extract_name").ToString()); TFormsList.GFormsList.BroadcastFormMessage(BroadcastMessage); } else { TLogging.Log("Report calculation finished.", TLoggingType.ToStatusBar); } } return ReturnValue; }
/// <summary> /// save the changes on the screen (code is copied from auto-generated code) /// </summary> /// <returns></returns> public bool SaveChanges() { bool ReturnValue = false; FPetraUtilsObject.OnDataSavingStart(this, new System.EventArgs()); if (FPetraUtilsObject.VerificationResultCollection.Count == 0) { foreach (DataRow InspectDR in FMainDS.MExtract.Rows) { InspectDR.EndEdit(); } if (!FPetraUtilsObject.HasChanges) { return true; } else { FPetraUtilsObject.WriteToStatusBar("Saving data..."); this.Cursor = Cursors.WaitCursor; TSubmitChangesResult SubmissionResult; //Ict.Common.Data.TTypedDataTable SubmitDT = FMainDS.MExtract.GetChangesTyped(); MExtractTable SubmitDT = new MExtractTable(); SubmitDT.Merge(FMainDS.MExtract.GetChangesTyped()); if (SubmitDT == null) { // There is nothing to be saved. // Update UI FPetraUtilsObject.WriteToStatusBar(Catalog.GetString("There is nothing to be saved.")); this.Cursor = Cursors.Default; // We don't have unsaved changes anymore FPetraUtilsObject.DisableSaveButton(); return true; } // Submit changes to the PETRAServer try { SubmissionResult = TRemote.MPartner.Partner.WebConnectors.SaveExtract (FExtractId, ref SubmitDT); } catch (ESecurityDBTableAccessDeniedException Exp) { FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException); this.Cursor = Cursors.Default; TMessages.MsgSecurityException(Exp, this.GetType()); ReturnValue = false; FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue)); return ReturnValue; } catch (EDBConcurrencyException Exp) { FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException); this.Cursor = Cursors.Default; TMessages.MsgDBConcurrencyException(Exp, this.GetType()); ReturnValue = false; FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue)); return ReturnValue; } catch (Exception) { FPetraUtilsObject.WriteToStatusBar(MCommonResourcestrings.StrSavingDataException); this.Cursor = Cursors.Default; FPetraUtilsObject.OnDataSaved(this, new TDataSavedEventArgs(ReturnValue)); throw; } switch (SubmissionResult) { case TSubmitChangesResult.scrOK: // Call AcceptChanges to get rid now of any deleted columns before we Merge with the result from the Server FMainDS.MExtract.AcceptChanges(); // Merge back with data from the Server (eg. for getting Sequence values) FMainDS.MExtract.Merge(SubmitDT, false); // need to accept the new modification ID FMainDS.MExtract.AcceptChanges(); // Update UI FPetraUtilsObject.WriteToStatusBar("Data successfully saved."); this.Cursor = Cursors.Default; // TODO EnableSave(false); // We don't have unsaved changes anymore FPetraUtilsObject.DisableSaveButton(); SetPrimaryKeyReadOnly(true); // refresh extract master screen if it is open TFormsMessage BroadcastMessage = new TFormsMessage(TFormsMessageClassEnum.mcExtractCreated); BroadcastMessage.SetMessageDataName(ExtractName); TFormsList.GFormsList.BroadcastFormMessage(BroadcastMessage); this.Focus(); // keeps the focus on the current form // TODO OnDataSaved(this, new TDataSavedEventArgs(ReturnValue)); return true; case TSubmitChangesResult.scrError: // TODO scrError this.Cursor = Cursors.Default; break; case TSubmitChangesResult.scrNothingToBeSaved: // TODO scrNothingToBeSaved this.Cursor = Cursors.Default; return true; case TSubmitChangesResult.scrInfoNeeded: // TODO scrInfoNeeded this.Cursor = Cursors.Default; break; } } } return false; }