/// <summary> /// Called from a delegate set up by me. /// </summary> /// <param name="ACalc"></param> public void GenerateExtract(TRptCalculator ACalc) { ACalc.GetParameters().Add("param_design_template", false); if (FDataGetter == null) { MessageBox.Show(Catalog.GetString("Fault: No Data Table available."), Catalog.GetString("GenerateExtract")); return; } if (!FDataGetter(ACalc)) { return; } FExtractPartnerKeyName = SelectColumnNameForExract(FClientDataTable, FExtractPartnerKeyName); if (FExtractPartnerKeyName == "") { return; } Int32 partnerKeyColumnNum = FClientDataTable.Columns[FExtractPartnerKeyName].Ordinal; TFrmExtractNamingDialog ExtractNameDialog = new TFrmExtractNamingDialog(FPetraUtilsObject.GetForm()); string ExtractName; string ExtractDescription; ExtractNameDialog.ShowDialog(); if (ExtractNameDialog.DialogResult != System.Windows.Forms.DialogResult.Cancel) { /* Get values from the Dialog */ ExtractNameDialog.GetReturnedParameters(out ExtractName, out ExtractDescription); } else { // dialog was cancelled, do not continue with extract generation return; } ExtractNameDialog.Dispose(); FPetraUtilsObject.GetForm().UseWaitCursor = true; // Create extract with given name and description and store it int ExtractId = 0; IPartnerUIConnectorsPartnerNewExtract PartnerExtractObject = TRemote.MPartner.Extracts.UIConnectors.PartnerNewExtract(); Boolean CreateOk = PartnerExtractObject.CreateExtractFromListOfPartnerKeys( ExtractName, ExtractDescription, out ExtractId, FClientDataTable, partnerKeyColumnNum, false); FPetraUtilsObject.GetForm().UseWaitCursor = false; if (CreateOk) { MessageBox.Show(String.Format(Catalog.GetString("Extract Created with {0} Partners."), FClientDataTable.Rows.Count), Catalog.GetString("Generate Extract")); } else { MessageBox.Show(Catalog.GetString("Creation of extract failed"), Catalog.GetString("Generate Extract"), MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
/// <summary> /// prompt user for name of a new manual extract, create it and open screen for it /// </summary> /// <param name="AParentForm"></param> public static void PartnerNewManualExtract(Form AParentForm) { TFrmExtractNamingDialog ExtractNameDialog = new TFrmExtractNamingDialog(AParentForm); int ExtractId = 0; string ExtractName; string ExtractDescription; ExtractNameDialog.ShowDialog(); if (ExtractNameDialog.DialogResult != System.Windows.Forms.DialogResult.Cancel) { /* Get values from the Dialog */ ExtractNameDialog.GetReturnedParameters(out ExtractName, out ExtractDescription); } else { // dialog was cancelled, do not continue with extract generation return; } ExtractNameDialog.Dispose(); // create empty extract with given name and description and store it in db if (TRemote.MPartner.Partner.WebConnectors.CreateEmptyExtract(ref ExtractId, ExtractName, ExtractDescription)) { NewExtractCreated(ExtractName, ExtractId, AParentForm); } else { MessageBox.Show(Catalog.GetString("Creation of extract failed"), Catalog.GetString("Generate Manual Extract"), MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } }
/// <summary> /// Guide user through process to create extract which contains all family records of /// Persons in a base extract. /// </summary> /// <param name="AParentForm"></param> /// <param name="AExtractMasterRow"></param> public static void CreateFamilyExtractForPersons(Form AParentForm, MExtractMasterRow AExtractMasterRow) { TFrmExtractFindDialog ExtractFindDialog = new TFrmExtractFindDialog(AParentForm); TFrmExtractNamingDialog ExtractNameDialog = new TFrmExtractNamingDialog(AParentForm); int BaseExtractId = 0; string BaseExtractName; string BaseExtractDescription; int ExtractId = 0; string ExtractName; string ExtractDescription; if (AExtractMasterRow != null) { BaseExtractId = AExtractMasterRow.ExtractId; // inform user what this extract is about and what will happen if (MessageBox.Show(Catalog.GetString("A new Extract will be created that will contain all Families of the Persons" + " that exist in the Extract '" + AExtractMasterRow.ExtractName + "'."), Catalog.GetString("Generate Family Extract for Persons"), MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.Cancel) { return; } } else { // inform user what this extract is about and what will happen MessageBox.Show(Catalog.GetString("Please select an existing Extract with the Find Screen that follows.\r\n\r\n" + "A new Extract will be created that will contain all Families of the Persons" + " that exist in the selected Extract."), Catalog.GetString("Generate Family Extract for Persons"), MessageBoxButtons.OK, MessageBoxIcon.Information); // let the user select base extract ExtractFindDialog.ShowDialog(true); // get data for selected base extract ExtractFindDialog.GetResult(out BaseExtractId, out BaseExtractName, out BaseExtractDescription); ExtractFindDialog.Dispose(); } // only continue if a base extract was selected if (BaseExtractId >= 0) { ExtractNameDialog.ShowDialog(); if (ExtractNameDialog.DialogResult != System.Windows.Forms.DialogResult.Cancel) { /* Get values from the Dialog */ ExtractNameDialog.GetReturnedParameters(out ExtractName, out ExtractDescription); ExtractNameDialog.Dispose(); } else { // dialog was cancelled, do not continue with extract generation ExtractNameDialog.Dispose(); return; } // create extract with given name and description and store it in db if (TRemote.MPartner.Partner.WebConnectors.CreateFamilyExtractForPersons(BaseExtractId, ref ExtractId, ExtractName, ExtractDescription)) { NewExtractCreated(ExtractName, ExtractId, AParentForm); } else { MessageBox.Show(Catalog.GetString("Creation of extract failed"), Catalog.GetString("Generate Family Extract for Persons"), MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } } }
/// <summary> /// Subtract Extracts (open a screen to select extracts to subtract from each other) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SubtractExtracts(System.Object sender, EventArgs e) { TFrmExtractCombineIntersectSubtractDialog ExtractSubtractDialog = new TFrmExtractCombineIntersectSubtractDialog(this.ParentForm); String BaseExtractName; List <Int32>AIntersectExtractIdList; // initialize dialog ExtractSubtractDialog.SetMode(TFrmExtractCombineIntersectSubtractDialog.TMode.ecisSubtractMode); // show dialog so the user can select extracts to be subtracted ExtractSubtractDialog.ShowDialog(); if (ExtractSubtractDialog.DialogResult != System.Windows.Forms.DialogResult.Cancel) { // Get values from the Dialog ExtractSubtractDialog.GetReturnedParameters(out BaseExtractName, out AIntersectExtractIdList); // now first the user needs to give the new intersected extract a name TFrmExtractNamingDialog ExtractNameDialog = new TFrmExtractNamingDialog(this); int NewExtractId = 0; string NewExtractName; string NewExtractDescription; ExtractNameDialog.ShowDialog(); if (ExtractNameDialog.DialogResult != System.Windows.Forms.DialogResult.Cancel) { /* Get values from the Dialog */ ExtractNameDialog.GetReturnedParameters(out NewExtractName, out NewExtractDescription); } else { // dialog was cancelled, do not continue with extract generation return; } ExtractNameDialog.Dispose(); if (TRemote.MPartner.Partner.WebConnectors.SubtractExtracts (NewExtractName, NewExtractDescription, BaseExtractName, AIntersectExtractIdList, out NewExtractId)) { ucoExtractMasterList.RefreshExtractList(sender, e); } } ExtractSubtractDialog.Dispose(); }
/// <summary> /// Guide user through process to create extract which contains all family member records (Persons) /// of families and persons in a base extract. /// </summary> /// <param name="AParentForm"></param> public static void FamilyMembersExtract(Form AParentForm) { TFrmExtractFindDialog ExtractFindDialog = new TFrmExtractFindDialog(AParentForm); TFrmExtractNamingDialog ExtractNameDialog = new TFrmExtractNamingDialog(AParentForm); int BaseExtractId = 0; string BaseExtractName; string BaseExtractDescription; int ExtractId = 0; string ExtractName; string ExtractDescription; // inform user what this extract is about and what will happen MessageBox.Show(Catalog.GetString("Please select an existing Extract with the Find Screen that follows.\r\n\r\n" + "The new Extract will contain all Family Members (Persons) of the Families" + " that exist in the selected Extract."), Catalog.GetString("Generate Family Members Extract"), MessageBoxButtons.OK, MessageBoxIcon.Information); // let the user select base extract ExtractFindDialog.ShowDialog(true); // get data for selected base extract ExtractFindDialog.GetResult(out BaseExtractId, out BaseExtractName, out BaseExtractDescription); ExtractFindDialog.Dispose(); // only continue if a base extract was selected if (BaseExtractId >= 0) { ExtractNameDialog.ShowDialog(); if (ExtractNameDialog.DialogResult != System.Windows.Forms.DialogResult.Cancel) { /* Get values from the Dialog */ ExtractNameDialog.GetReturnedParameters(out ExtractName, out ExtractDescription); ExtractNameDialog.Dispose(); } else { // dialog was cancelled, do not continue with extract generation ExtractNameDialog.Dispose(); return; } // create extract with given name and description and store it in db if (TRemote.MPartner.Partner.WebConnectors.CreateFamilyMembersExtract(BaseExtractId, ref ExtractId, ExtractName, ExtractDescription)) { // now open Screen for new extract so user can see the result TFrmExtractMaintain frm = new TFrmExtractMaintain(AParentForm); frm.ExtractId = ExtractId; frm.ExtractName = ExtractName; frm.Show(); } else { MessageBox.Show(Catalog.GetString("Creation of extract failed"), Catalog.GetString("Generate Family Members Extract"), MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void tbtCreateExtractClick(System.Object sender, System.EventArgs e) { XmlDocument doc = Results.WriteXmlDocument(Parameters, true); DataTable Tbl = new DataTable(); Tbl.Columns.Add("PartnerKey", typeof(Int64)); XmlNodeList Rows = doc.SelectNodes("*/Element"); XmlNode FirstRow = Rows[0]; String ColumnName = SelectColumnNameForExract(FirstRow); this.UseWaitCursor = true; foreach (XmlNode node in Rows) { XmlAttribute Attr = node.Attributes[ColumnName]; if (Attr != null) { Int64 intPartnerKey; if (Int64.TryParse(Attr.Value, out intPartnerKey)) { DataRow Row = Tbl.NewRow(); Row["PartnerKey"] = intPartnerKey; Tbl.Rows.Add(Row); } } } this.UseWaitCursor = false; if (Tbl.Rows.Count < 1) { MessageBox.Show(Catalog.GetString("Error - no Partner keys found"), Catalog.GetString("Generate Extract")); return; } TFrmExtractNamingDialog ExtractNameDialog = new TFrmExtractNamingDialog(this); string ExtractName; string ExtractDescription; ExtractNameDialog.ShowDialog(); if (ExtractNameDialog.DialogResult != System.Windows.Forms.DialogResult.Cancel) { /* Get values from the Dialog */ ExtractNameDialog.GetReturnedParameters(out ExtractName, out ExtractDescription); } else { // dialog was cancelled, do not continue with extract generation return; } ExtractNameDialog.Dispose(); this.UseWaitCursor = true; // Create extract with given name and description and store it int ExtractId = 0; IPartnerUIConnectorsPartnerNewExtract PartnerExtractObject = TRemote.MPartner.Extracts.UIConnectors.PartnerNewExtract(); Boolean CreateOk = PartnerExtractObject.CreateExtractFromListOfPartnerKeys(ExtractName, ExtractDescription, out ExtractId, Tbl, 0, false); this.UseWaitCursor = false; if (CreateOk) { MessageBox.Show(String.Format(Catalog.GetString("Extract Created with {0} Partners."), Tbl.Rows.Count), Catalog.GetString("Generate Extract")); } else { MessageBox.Show(Catalog.GetString("Creation of extract failed"), Catalog.GetString("Generate Extract"), MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private void CreateNewExtractFromFoundPartners() { TFrmExtractNamingDialog ExtractNameDialog = new TFrmExtractNamingDialog(FPetraUtilsObject.GetForm()); int ExtractId = 0; string ExtractName; string ExtractDescription; TVerificationResultCollection VerificationResult; ExtractNameDialog.ShowDialog(); if (ExtractNameDialog.DialogResult != System.Windows.Forms.DialogResult.Cancel) { // Get values from the Dialog ExtractNameDialog.GetReturnedParameters(out ExtractName, out ExtractDescription); } else { // dialog was cancelled, do not continue with extract generation return; } ExtractNameDialog.Dispose(); this.Cursor = Cursors.WaitCursor; /* Make Server call to add all found Partners to the new Extract. * Note: Partners will not be included more than once in the extract. * If a partner is included more than once then the 'best location' location key is used. * Otherwise the location key that is found by Partner Find is the one that is used. */ try { int ExtractPartners = FPartnerFindObject.AddAllFoundPartnersToExtract( ExtractName, ExtractDescription, ExtractId, out VerificationResult); if (ExtractPartners != -1) { string MessageText; if (ExtractPartners == 1) { MessageText = MPartnerResourcestrings.StrPartnersAddedToExtractText; } else { MessageText = MPartnerResourcestrings.StrPartnersAddedToExtractPluralText; } MessageBox.Show(String.Format(MessageText, ExtractPartners), MPartnerResourcestrings.StrPartnersAddedToExtractTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (VerificationResult != null) { MessageBox.Show(Messages.BuildMessageFromVerificationResult(null, VerificationResult)); } else { MessageBox.Show(Catalog.GetString("Creation of extract failed"), MPartnerResourcestrings.StrPartnersAddedToExtractTitle, MessageBoxButtons.OK, MessageBoxIcon.Stop); } } } finally { this.Cursor = Cursors.Default; Application.DoEvents(); } }
/// <summary> /// Generate an extract /// </summary> public void MI_GenerateExtract_Click(System.Object sender, System.EventArgs e) { if ((FGenerateExtractThread != null) && FGenerateExtractThread.IsAlive) { // cancel the extract //TODO FCalculator.CancelExtractCalculation(); return; } // open dialog to prompt the user to enter a name for new extract TFrmExtractNamingDialog ExtractNameDialog = new TFrmExtractNamingDialog(this.FWinForm); string ExtractName; string ExtractDescription; ExtractNameDialog.ShowDialog(); if (ExtractNameDialog.DialogResult != System.Windows.Forms.DialogResult.Cancel) { /* Get values from the Dialog */ ExtractNameDialog.GetReturnedParameters(out ExtractName, out ExtractDescription); } else { // dialog was cancelled, do not continue with extract generation return; } ExtractNameDialog.Dispose(); // read the settings and parameters from the controls if (!ReadControlsWithErrorHandling(TReportActionEnum.raGenerate)) { return; } // add extract name and description to parameter list // (don't add it earlier as the list gets cleared while reading controls from screens) FCalculator.AddParameter("param_extract_name", ExtractName); FCalculator.AddParameter("param_extract_description", ExtractDescription); if (TClientSettings.DebugLevel >= TClientSettings.DEBUGLEVEL_REPORTINGDATA) { FCalculator.GetParameters().Save(TClientSettings.PathLog + Path.DirectorySeparatorChar + "debugParameter.xml", true); } this.FWinForm.Cursor = Cursors.WaitCursor; FormCursor = FWinForm.Cursor; TLogging.SetStatusBarProcedure(this.WriteToStatusBar); // Open Extract Mast Screen if not already open. // (If being opened, the screen will not actually be shown at theis stage.) if (TCommonScreensForwarding.OpenExtractMasterScreen != null) { TCommonScreensForwarding.OpenExtractMasterScreenHidden.Invoke(((ToolStripButton)sender).GetCurrentParent().FindForm()); } if ((FGenerateExtractThread == null) || (!FGenerateExtractThread.IsAlive)) { ((IFrmReporting)FTheForm).EnableBusy(true); FGenerateExtractThread = new Thread(GenerateExtract); FGenerateExtractThread.IsBackground = true; FGenerateExtractThread.Start(); } }
/// <summary> /// Subtract Extracts (open a screen to select extracts to subtract from each other) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SubtractExtracts(System.Object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; TFrmExtractCombineIntersectSubtractDialog ExtractSubtractDialog = new TFrmExtractCombineIntersectSubtractDialog(this.ParentForm); String BaseExtractName; List <Int32>AIntersectExtractIdList; // initialize dialog ExtractSubtractDialog.SetMode(TFrmExtractCombineIntersectSubtractDialog.TMode.ecisSubtractMode); if (ucoExtractMasterList.GetSelectedDetailRow() != null) { // Show currently selected extract in the grid in the dialog ExtractSubtractDialog.PreSelectExtract(ucoExtractMasterList.GetSelectedDetailRow()); } // show dialog so the user can select extracts to be subtracted ExtractSubtractDialog.ShowDialog(); if (ExtractSubtractDialog.DialogResult != System.Windows.Forms.DialogResult.Cancel) { // Get values from the Dialog ExtractSubtractDialog.GetReturnedParameters(out BaseExtractName, out AIntersectExtractIdList); // now first the user needs to give the new intersected extract a name TFrmExtractNamingDialog ExtractNameDialog = new TFrmExtractNamingDialog(this); int NewExtractId = 0; string NewExtractName; string NewExtractDescription; ExtractNameDialog.ShowDialog(); if (ExtractNameDialog.DialogResult != System.Windows.Forms.DialogResult.Cancel) { /* Get values from the Dialog */ ExtractNameDialog.GetReturnedParameters(out NewExtractName, out NewExtractDescription); } else { // dialog was cancelled, do not continue with extract generation return; } this.Cursor = Cursors.WaitCursor; ExtractNameDialog.Dispose(); if (TRemote.MPartner.Partner.WebConnectors.SubtractExtracts (NewExtractName, NewExtractDescription, BaseExtractName, AIntersectExtractIdList, out NewExtractId)) { ucoExtractMasterList.RefreshExtractList(sender, e); MessageBox.Show(Catalog.GetString("Subtract Extracts successful.")); } } ExtractSubtractDialog.Dispose(); } finally { this.Cursor = Cursors.Default; } }
private void CreateExtract_Click(System.Object sender, EventArgs e) { TFrmExtractNamingDialog ExtractNameDialog = new TFrmExtractNamingDialog(this); IPartnerUIConnectorsPartnerNewExtract PartnerExtractObject = TRemote.MPartner.Extracts.UIConnectors.PartnerNewExtract(); int ExtractId = 0; string ExtractName; string ExtractDescription; ExtractNameDialog.ShowDialog(); if (ExtractNameDialog.DialogResult != System.Windows.Forms.DialogResult.Cancel) { /* Get values from the Dialog */ ExtractNameDialog.GetReturnedParameters(out ExtractName, out ExtractDescription); } else { // dialog was cancelled, do not continue with extract generation return; } ExtractNameDialog.Dispose(); this.Cursor = Cursors.WaitCursor; DataTable PartnerKeysTable = ((DevAge.ComponentModel.BoundDataView)grdApplications.DataSource).DataView.ToTable(); // create empty extract with given name and description and store it in db if (PartnerExtractObject.CreateExtractFromListOfPartnerKeys(ExtractName, ExtractDescription, out ExtractId, PartnerKeysTable, 0, false)) { this.Cursor = Cursors.Default; if (MessageBox.Show( string.Format( Catalog.GetString( "Extract Created with {0} Partners.{1}{1}Do you want to open the 'Maintain Extract' screen now?"), PartnerKeysTable.Rows.Count, "\n"), Catalog.GetString("Create Extract"), MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { // now open Screen for new extract so user can add partner records manually TFrmExtractMaintain frm = new TFrmExtractMaintain(this); frm.ExtractId = ExtractId; frm.ExtractName = ExtractName; frm.Show(); } } else { this.Cursor = Cursors.Default; MessageBox.Show(Catalog.GetString("Creation of extract failed"), Catalog.GetString("Generate Manual Extract"), MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } }