/// <summary> /// Create Manual Extract /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CreateFamilyExtractForPersons(System.Object sender, EventArgs e) { if (ucoExtractMasterList.GetSelectedDetailRow() != null) { TPartnerExtractsMain.CreateFamilyExtractForPersons(FindForm(), ucoExtractMasterList.GetSelectedDetailRow()); } else { TPartnerExtractsMain.CreateFamilyExtractForPersons(FindForm(), null); } }
private void CreateContactLogExtract(System.Object sender, EventArgs e) { TPartnerExtractsMain.PartnerByContactLogExtract(FindForm()); }
/// <summary> /// Create Partner By Subscription Extract /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CreatePartnerBySubscriptionExtract(System.Object sender, EventArgs e) { TPartnerExtractsMain.PartnerBySubscriptionExtract(FindForm()); }
/// <summary> /// Create Partner By Relationship Extract /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CreatePartnerByRelationshipExtract(System.Object sender, EventArgs e) { TPartnerExtractsMain.PartnerByRelationshipExtract(FindForm()); }
/// <summary> /// Create Manual Extract /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CreateManualExtract(System.Object sender, EventArgs e) { TPartnerExtractsMain.PartnerNewManualExtract(FindForm()); }
/// <summary> /// Create General Extract /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CreateGeneralExtract(System.Object sender, EventArgs e) { TPartnerExtractsMain.PartnerByGeneralCriteriaExtract(FindForm()); }
/// <summary> /// This is the main routine that does the work /// </summary> private void BtnOK_Click(object sender, EventArgs e) { // Enforce some validation rules if (txtExtractName.Text.Trim().Length == 0) { MessageBox.Show(Catalog.GetString("Please enter a name for the extract."), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (TRemote.MPartner.Partner.WebConnectors.ExtractExists(txtExtractName.Text)) { MessageBox.Show(Catalog.GetString("An extract with this name already exists. Please enter a new name."), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } // Import the text string importString = null; if (rbtClipboard.Checked) { // Import from the clipboard importString = Clipboard.GetText(TextDataFormat.UnicodeText); if ((importString == null) || (importString.Length == 0)) { MessageBox.Show(Catalog.GetString("Please first copy data from your spreadsheet application!"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { // Import from the specified file string pathToFile = txtFileName.Text; if (!File.Exists(pathToFile)) { MessageBox.Show(Catalog.GetString( "Cannot find the file to import from."), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } string extension = Path.GetExtension(pathToFile); if (".txt.csv.".Contains(extension + ".") == false) { MessageBox.Show(Catalog.GetString("You must choose either a text or CSV file with a file extension of .txt or .csv"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } System.Text.Encoding FileEncoding = TTextFile.GetFileEncoding(pathToFile); // // If it failed to open the file, GetFileEncoding returned null. if (FileEncoding == null) { MessageBox.Show(Catalog.GetString("Could not open the file."), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } StreamReader reader = new StreamReader(pathToFile, FileEncoding, false); while (!reader.EndOfStream) { importString = reader.ReadToEnd(); } reader.Close(); if (importString.Length == 0) { MessageBox.Show(Catalog.GetString("The file was empty!"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } // So we know we have some text rather than an empty string // The partner keys must be the first column of a row List <Int64> partnerKeyList = new List <Int64>(); string[] rows = importString.Split('\n'); for (int i = 0; i < rows.Length; i++) { string row = rows[i].TrimEnd('\r'); if ((row.Length == 0) || row.StartsWith("#") || row.StartsWith("/*") || row.StartsWith(";")) { // Empty line or a comment continue; } // The row has some length. Columns can be separated by tab, comma or semicolon // Partner key must be in the first column string[] cols = row.Split(new char[] { '\t', ',', ';' }); Int64 partnerKey; // See if it is a number (remove any quotes around the string first) if (Int64.TryParse(cols[0].Replace("\"", ""), out partnerKey) && (partnerKey != 0)) { partnerKeyList.Add(partnerKey); } } if (MessageBox.Show(string.Format(Catalog.GetString("Found {0} partners to import. Continue?"), partnerKeyList.Count), this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } // Convert our list to a datatable DataTable table = new DataTable(); table.Columns.Add("Key", typeof(System.Int64)); foreach (Int64 item in partnerKeyList) { DataRow dr = table.NewRow(); dr[0] = item; table.Rows.Add(dr); } // Call the main method. If it succeeds we can close bool bSuccess = false; try { this.Cursor = Cursors.WaitCursor; Application.DoEvents(); bSuccess = TPartnerExtractsMain.CreateNewExtractFromPartnerKeys(txtExtractName.Text, txtExtractDescription.Text, table, 0, chkExcludeInactive.Checked, chkExcludeNonMailing.Checked, chkExcludeNoSolicitations.Checked, this); } finally { this.Cursor = Cursors.Default; } if (bSuccess) { Close(); } }
/// <summary> /// Create Manual Extract /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CreateFamilyExtractForPersons(System.Object sender, EventArgs e) { TPartnerExtractsMain.FamilyExtractForPersons(FindForm()); }
/// <summary> /// Create Manual Extract /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CreateFamilyMembersExtract(System.Object sender, EventArgs e) { TPartnerExtractsMain.FamilyMembersExtract(FindForm()); }