/// <summary> /// Internal method for ExportFinancialAccounts(). /// </summary> private void ExportFinancialAccounts_Internal() { var dvFunds = new DataView(_db.Table("Contribution").Data); // Get primary funds. var dtPrimaryFunds = dvFunds.ToTable(true, "fund_name"); // Get sub-funds. dvFunds.RowFilter = "ISNULL(sub_fund_name, 'Null Column') <> 'Null Column'"; var dtFunds = dvFunds.ToTable(true, "fund_name", "sub_fund_name"); // Merge primary and sub-funds. dtFunds.Merge(dtPrimaryFunds); foreach (DataRow row in dtFunds.Rows) { var importAccount = F1FinancialAccount.Translate(row); if (importAccount != null) { ImportPackage.WriteToPackage(importAccount); } } // Cleanup. dtFunds.Clear(); GC.Collect(); }
/// <summary> /// Takes a CSV filepath and adds all the breeze person note records within that file to the /// exported slingshot data /// </summary> public static void ExportNotes(string notesCsvFilename, BackgroundWorker worker) { try { // Reset the error message ErrorMessage = null; // Open the CSV file and begin reading the Breeze people notes data using (var reader = File.OpenText(notesCsvFilename)) using (var csv = new CsvReader(reader)) { while (csv.Read()) { var recordDictionary = csv.GetRecord <dynamic>() as IDictionary <string, object>; var note = BreezeNote.Translate(recordDictionary); ImportPackage.WriteToPackage(note); // Report percentage for progress bar var percentage = ( double )reader.BaseStream.Position / reader.BaseStream.Length; worker.ReportProgress(( int )(percentage * 100)); } } } catch (Exception ex) { ErrorMessage = ex.Message; } }
//Open file dialog and converted selected image to a bmp object public ImportPackage OpenFile() { //Declare and instatiate a new file selection dialog OpenFileDialog ofd = new OpenFileDialog(); //Declare and Instatiate the Package of Information ImportPackage newPackage = new ImportPackage(); //Set Import Dialog initial location and supported file types ofd.InitialDirectory = "C:\\Images"; ofd.Filter = "Image Files| *.jpg; *.jpeg; *.png; *.bmp"; ofd.RestoreDirectory = true; ofd.Multiselect = true; ofd.Title = "Please Select Source File(s) for Analysis"; //Converted the image if one was selected if (ofd.ShowDialog() == DialogResult.OK) { foreach (var file in ofd.FileNames) { newPackage.importedImageNamesFull.Add(file); newPackage.importedImageNames.Add(file.Substring(file.LastIndexOf("\\") + 1, file.Length - (file.LastIndexOf("\\") + 1))); } } //return the resulting image(s0 return(newPackage); }
/// <summary> /// Exports the contributions. /// </summary> /// <param name="modifiedSince">The modified since.</param> public override void ExportContributions(DateTime modifiedSince, bool exportContribImages) { try { using (var dtHoh = GetTableData(SQL_HEAD_OF_HOUSEHOLD)) using (var dtPeople = GetTableData(SQL_PEOPLE)) using (var dtContributions = GetTableData(SQL_CONTRIBUTIONS)) { var headOfHouseholdMap = GetHeadOfHouseholdMap(dtHoh); var dtCompanies = GetTableData(SQL_COMPANIES); var companyIds = new HashSet <int>(dtCompanies.AsEnumerable().Select(s => s.Field <int>("HOUSEHOLD_ID"))); foreach (DataRow row in dtContributions.Rows) { var importTransaction = F1FinancialTransaction.Translate(row, headOfHouseholdMap, companyIds); if (importTransaction != null) { ImportPackage.WriteToPackage(importTransaction); } } } } catch (Exception ex) { ErrorMessage = ex.Message; } }
/// <summary> /// Exports the individuals. /// </summary> public static void ExportIndividuals(DateTime modifiedSince, string emailType, string campusKey) { try { _modifiedSince = modifiedSince; _emailType = emailType; //load attributes LoadPersonAttributes(); // write out the person attributes WritePersonAttributes(); // export people using (var dtPeople = GetTableData(SQL_PEOPLE)) { foreach (DataRow row in dtPeople.Rows) { var importPerson = AcsPerson.Translate(row, campusKey); if (importPerson != null) { ImportPackage.WriteToPackage(importPerson); } } } // export person notes using (var dtPeopleNotes = GetTableData(SQL_PEOPLE_NOTES)) { foreach (DataRow row in dtPeopleNotes.Rows) { var importNote = AcsPersonNote.Translate(row); if (importNote != null) { ImportPackage.WriteToPackage(importNote); } } } // export family notes using (var dtFamilyNotes = GetTableData(SQL_FAMILY_NOTES)) { foreach (DataRow row in dtFamilyNotes.Rows) { var importNote = AcsFamilyNote.Translate(row); if (importNote != null) { ImportPackage.WriteToPackage(importNote); } } } } catch (Exception ex) { ErrorMessage = ex.Message; } }
/// <summary> /// Initializes the export. /// </summary> public static void InitializeExport(DateTime modifiedSince, DateTime NotBefore) { _modifiedSince = modifiedSince; _ContributionsNotBefore = NotBefore; ImportPackage.InitalizePackageFolder(); }
/// <summary> /// Exports the attendance. /// </summary> public static void ExportAttendance(DateTime modifiedSince) { // export attendance locations using (var dtLocations = GetTableData(SQL_ATTENDANCE_LOCATIONS)) { foreach (DataRow row in dtLocations.Rows) { var importLocation = ElexioLocation.Translate(row); if (importLocation != null) { ImportPackage.WriteToPackage(importLocation); } } } // export attendance using (var dtAttendance = GetTableData(SQL_ATTENDANCE)) { foreach (DataRow row in dtAttendance.Rows) { var importAttendance = ElexioAttendance.Translate(row); if (importAttendance != null) { ImportPackage.WriteToPackage(importAttendance); } } } }
/// <summary> /// Imports the specified import package. /// </summary> /// <param name="package">The package.</param> /// <param name="log">The log.</param> /// <param name="context">The context.</param> /// <exception cref="System.ArgumentNullException">package</exception> static public void Import(ImportPackage package, Action <int, string> log = null, dynamic context = null) { if (package == null) { throw new ArgumentNullException("package"); } log = log ?? NullLogger; // ensure we have a logger of some sort log.Info("Import started"); try { // instantiate each action actor and perform the import foreach (var action in package.Actions.Where(a => a.References == 0)) { try { Import(action, package, log, context); } catch { // exceptions are being handled in the Import method. Logging them here would duplicate information if (action.BreakOnError) { break; } } } log.Info("Import completed"); } catch (Exception ex) { log.Error(ex.Message); log.Info("Import aborted"); } }
/// <summary> /// Exports the financial accounts. /// </summary> public static void ExportFinancialAccounts() { try { _request = new RestRequest(API_GIVING_CATEGORIES, Method.GET); _request.AddQueryParameter("session_id", SessionId); var response = _client.Execute(_request); ApiCounter++; dynamic data = JsonConvert.DeserializeObject(response.Content); JArray records = data.data; if (records.Count > 0) { foreach (var account in records) { FinancialAccount importAccount = ElexioCommunityFinancialAccount.Translate(account); if (importAccount != null) { ImportPackage.WriteToPackage(importAccount); } _accountLookups.Add((int)account["id"], (string)account["name"]); } } } catch (Exception ex) { ErrorMessage = ex.Message; } }
/// <summary> /// Exports the pledges. /// </summary> public override void ExportFinancialPledges() { try { using (var dtPledges = GetTableData(SQL_PLEDGES)) { //Get head of house holds because in F1 pledges can be tied to indiviuals or households var headOfHouseHolds = GetHeadOfHouseholdMap(GetTableData(SQL_HEAD_OF_HOUSEHOLD)); foreach (DataRow row in dtPledges.Rows) { var importPledge = F1FinancialPledge.Translate(row, headOfHouseHolds); if (importPledge != null) { ImportPackage.WriteToPackage(importPledge); } } } } catch (Exception ex) { ErrorMessage = ex.Message; } }
/// <summary> /// Internal method for ExportContributions(). /// </summary> /// <param name="modifiedSince">The modified since.</param> /// <param name="exportContribImages">Indicates whether images should be exported. (WARNING: Not implemented.)</param> private void ExportContributions_Internal(DateTime modifiedSince, bool exportContribImages) { using (var dtHoh = GetTableData(SqlQueries.HEAD_OF_HOUSEHOLD, true)) using (var dtPeople = GetTableData(SqlQueries.PEOPLE, true)) using (var dtContributions = GetTableData(SqlQueries.CONTRIBUTIONS)) { var headOfHouseholdMap = GetHeadOfHouseholdMap(dtHoh); var dtCompanies = GetTableData(SqlQueries.COMPANY, true); var companyIds = new HashSet <int>(dtCompanies.AsEnumerable().Select(s => s.Field <int>("HOUSEHOLD_ID"))); foreach (DataRow row in dtContributions.Rows) { var importTransaction = F1FinancialTransaction.Translate(row, headOfHouseholdMap, companyIds); if (importTransaction != null) { ImportPackage.WriteToPackage(importTransaction); } } // Cleanup - Remember not to Clear() any cached tables. dtContributions.Clear(); GC.Collect(); } }
/// <summary> /// Writes the person attributes. /// </summary> public static void WritePersonAttributes() { foreach (var attrib in PersonAttributes) { var attribute = new PersonAttribute(); // strip out "Ind" from the attribute name and add spaces between words attribute.Name = ExtensionMethods.SplitCase(attrib.Key.Replace("Ind", "")); attribute.Key = attrib.Key; attribute.Category = "Imported Attributes"; switch (attrib.Value) { case "String": attribute.FieldType = "Rock.Field.Types.TextFieldType"; break; case "DateTime": attribute.FieldType = "Rock.Field.Types.DateTimeFieldType"; break; default: attribute.FieldType = "Rock.Field.Types.TextFieldType"; break; } ImportPackage.WriteToPackage(attribute); } }
/// <summary> /// Internal method for ExportNotes(). /// </summary> private void ExportNotes_Internal() { using (var dtUsers = GetTableData(SqlQueries.USERS)) using (var dtNotes = GetTableData(SqlQueries.NOTES)) using (var dtHoh = GetTableData(SqlQueries.HEAD_OF_HOUSEHOLD, true)) { var headOfHouseHoldMap = GetHeadOfHouseholdMap(dtHoh); var users = dtUsers.AsEnumerable().ToArray(); foreach (DataRow row in dtNotes.Rows) { var importNote = F1Note.Translate(row, headOfHouseHoldMap, users); if (importNote != null) { ImportPackage.WriteToPackage(importNote); } } // Cleanup - Remember not to Clear() any cached tables. dtUsers.Clear(); dtNotes.Clear(); GC.Collect(); } }
/// <summary> /// Export the people and household notes /// </summary> public override void ExportNotes() { try { using (var dtUsers = GetTableData(SQL_USERS)) using (var dtNotes = GetTableData(SQL_NOTES)) using (var dtHoh = GetTableData(SQL_HEAD_OF_HOUSEHOLD)) { var headOfHouseHoldMap = GetHeadOfHouseholdMap(dtHoh); var users = dtUsers.AsEnumerable().ToArray(); foreach (DataRow row in dtNotes.Rows) { var importNote = F1Note.Translate(row, headOfHouseHoldMap, users); if (importNote != null) { ImportPackage.WriteToPackage(importNote); } } } } catch (Exception ex) { ErrorMessage = ex.Message; } }
/// <summary> /// Exports the deparments. /// </summary> private static void ExportDeparments() { try { var request = new RestRequest(API_DEPARTMENTS, Method.GET); var response = _client.Execute(request); XDocument xdocCustomFields = XDocument.Parse(response.Content); if (CcbApi.DumpResponseToXmlFile) { xdocCustomFields.Save(Path.Combine(ImportPackage.PackageDirectory, $"API_DEPARTMENTS_ResponseLog.xml")); } var sourceDepartments = xdocCustomFields.Element("ccb_api")?.Element("response")?.Elements("items"); foreach (var sourceDepartment in sourceDepartments.Elements("item")) { var group = new Group(); group.Id = ("9999" + sourceDepartment.Element("id").Value).AsInteger(); group.Name = sourceDepartment.Element("name")?.Value; group.Order = sourceDepartment.Element("order").Value.AsInteger(); group.GroupTypeId = 9999; ImportPackage.WriteToPackage(group); } } catch (Exception ex) { ErrorMessage = ex.Message; } }
/// <summary> /// Exports the contributions. /// </summary> /// <param name="modifiedSince">The modified since.</param> public override void ExportContributions(DateTime modifiedSince, bool exportContribImages) { try { using (var dtContributions = GetTableData(SQL_CONTRIBUTIONS)) { //Get head of house holds because in F1 pledges can be tied to indiviuals or households var headOfHouseHolds = GetTableData(SQL_PEOPLE).Select("household_position = 'Head' "); foreach (DataRow row in dtContributions.Rows) { var importTransaction = F1FinancialTransaction.Translate(row, headOfHouseHolds); if (importTransaction != null) { ImportPackage.WriteToPackage(importTransaction); } } } } catch (Exception ex) { ErrorMessage = ex.Message; } }
/// <summary> /// Writes the group types. /// </summary> /// <param name="selectedGroupTypes">The selected group types.</param> public static void WriteGroupTypes(List <int> selectedGroupTypes) { // hardcode the department and director group types as these are baked into the box ImportPackage.WriteToPackage(new GroupType() { Id = 9999, Name = "Department" }); ImportPackage.WriteToPackage(new GroupType() { Id = 9998, Name = "Director" }); // add custom defined group types var groupTypes = GetGroupTypes(); foreach (var groupType in groupTypes.Where(t => selectedGroupTypes.Contains(t.Id))) { ImportPackage.WriteToPackage(new GroupType() { Id = groupType.Id, Name = groupType.Name }); } }
/// <summary> /// Exports the contributions. /// </summary> /// <param name="modifiedSince">The modified since.</param> public static void ExportContributions(DateTime modifiedSince, bool exportContribImages) { try { var donations = GetDonations(false, modifiedSince, null) .Where(d => d.refunded == false && d.payment_status == "succeeded") .ToList(); foreach (var donation in donations) { var importTransaction = PCOImportDonation.Translate(donation); var importTransactionDetails = PCOImportDesignation.Translate(donation); if (importTransaction != null) { ImportPackage.WriteToPackage(importTransaction); foreach (var detail in importTransactionDetails) { if (detail != null) { ImportPackage.WriteToPackage(detail); } } } } } catch (Exception ex) { ErrorMessage = ex.Message; } }
/// <summary> /// Exports the accounts. /// </summary> public static void ExportFinancialAccounts() { try { var funds = GetFunds(false, null, null); /* * XDocument xdoc = XDocument.Parse( response.Content ); * * if ( PCOApi.DumpResponseToXmlFile ) * { * xdoc.Save( Path.Combine( ImportPackage.PackageDirectory, $"API_FINANCIAL_ACCOUNTS_ResponseLog.xml" ) ); * } */ // process accounts foreach (var fund in funds) { var importFund = PCOImportFund.Translate(fund); if (importFund != null) { ImportPackage.WriteToPackage(importFund); } } } catch (Exception ex) { ErrorMessage = ex.Message; } }
/// <summary> /// Internal method for ExportAttendance(). /// </summary> /// <param name="modifiedSince">The modified since.</param> private void ExportAttendance_Internal(DateTime modifiedSince) { using (var dtAttendance = GetTableData(SqlQueries.ATTENDANCE)) { var dtAttendance_AssignedIds = dtAttendance.Select("Attendance_ID IS NOT NULL").CopyToDataTable_Safe(dtAttendance); var dtAttendance_NullIds = dtAttendance.Select("Attendance_ID IS NULL").CopyToDataTable_Safe(dtAttendance); var uniqueAttendanceIds = new List <int>(); // Process rows with assigned Attendance_ID values, first, to ensure their AttendanceId is preserved. foreach (DataRow row in dtAttendance_AssignedIds.Rows) { var importAttendance = F1Attendance.Translate(row, uniqueAttendanceIds); if (importAttendance != null) { ImportPackage.WriteToPackage(importAttendance); } } // Process remaining rows without assigned Attendance_ID values. These records will have AttendanceId // values generated by an MD5 hash of the Individual_ID, GroupId, and StartDateTime. Collisions for // that hash are relatively common and in cases where that occurs, a random value will be used, instead. foreach (DataRow row in dtAttendance_NullIds.Rows) { var importAttendance = F1Attendance.Translate(row, uniqueAttendanceIds); if (importAttendance != null) { ImportPackage.WriteToPackage(importAttendance); } } // Cleanup - Remember not to Clear() any cached tables. dtAttendance.Clear(); GC.Collect(); } }
/// <summary> /// Exports the groups. /// </summary> /// <param name="selectedGroupTypes">The selected group types.</param> /// <param name="modifiedSince">The modified since.</param> /// <param name="perPage">The people per page.</param> public static void ExportGroups(List <int> selectedGroupTypes, DateTime modifiedSince, int perPage = 500) { // write out the group types WriteGroupTypes(selectedGroupTypes); // export groups using (var dtGroups = GetTableData(SQL_GROUPS)) { foreach (DataRow row in dtGroups.Rows) { var importGroup = ElexioGroup.Translate(row); if (importGroup != null) { ImportPackage.WriteToPackage(importGroup); } } } // export group members using (var dtGroupMembers = GetTableData(SQL_GROUP_MEMBERS)) { foreach (DataRow row in dtGroupMembers.Rows) { var importGroupMember = ElexioGroupMember.Translate(row); if (importGroupMember != null) { ImportPackage.WriteToPackage(importGroupMember); } } } }
private void ExportWorker_DoWork(object sender, DoWorkEventArgs e) { _exportWorker.ReportProgress(0, ""); var exportSettings = ( ExportSettings )e.Argument; // clear filesystem directories BreezeApi.InitializeExport(); // export individuals, phone numbers, and addresses _exportWorker.ReportProgress(1, "Exporting Individuals..."); BreezeApi.ExportPeople(exportSettings.PersonCsvFileName, _exportWorker); if (BreezeApi.ErrorMessage.IsNotNullOrWhitespace()) { ShowError($"Error exporting individuals: {BreezeApi.ErrorMessage}"); return; } // export notes _exportWorker.ReportProgress(1, "Exporting Notes..."); BreezeApi.ExportNotes(exportSettings.NotesCsvFileName, _exportWorker); if (BreezeApi.ErrorMessage.IsNotNullOrWhitespace()) { ShowError($"Error exporting notes: {BreezeApi.ErrorMessage}"); return; } // export gifts _exportWorker.ReportProgress(1, "Exporting Gifts..."); BreezeApi.ExportGiving(exportSettings.GivingCsvFileName, _exportWorker); if (BreezeApi.ErrorMessage.IsNotNullOrWhitespace()) { ShowError($"Error exporting gifts: {BreezeApi.ErrorMessage}"); return; } // export tags _exportWorker.ReportProgress(1, "Exporting Tags..."); BreezeApi.ExportTags(exportSettings.TagsXlsxFileName, _exportWorker); if (BreezeApi.ErrorMessage.IsNotNullOrWhitespace()) { ShowError($"Error exporting tags: {BreezeApi.ErrorMessage}"); return; } // finalize the package if (!hasErrors) { ImportPackage.FinalizePackage("breeze-export.slingshot"); } // schedule the API status to update (the status takes a few mins to update) _apiUpdateTimer.Start(); }
/// <summary> /// Writes the group types. /// </summary> public static void WriteGroupTypes() { // hardcode a generic group type ImportPackage.WriteToPackage(new GroupType() { Id = 9999, Name = "Imported Group" }); }
private void ExportWorker_DoWork(object sender, DoWorkEventArgs e) { exportWorker.ReportProgress(0, ""); var exportSettings = ( ExportSettings )e.Argument; // clear filesystem directories ServantKeeperApi.InitializeExport(); // export individuals and phone numbers if (exportSettings.ExportIndividuals) { exportWorker.ReportProgress(1, "Exporting Individuals..."); ServantKeeperApi.ExportIndividuals(exportSettings.ModifiedSince, exportSettings.ExportEmailType, exportSettings.ExportCampus); if (ServantKeeperApi.ErrorMessage.IsNotNullOrWhitespace()) { txtMessages.Text = $"Error exporting individuals: {ServantKeeperApi.ErrorMessage}"; } /*exportWorker.ReportProgress( 1, "Exporting Phones..." ); * ServantKeeperApi.ExportPhoneNumbers( exportSettings.ModifiedSince ); * * if ( ServantKeeperApi.ErrorMessage.IsNotNullOrWhitespace() ) * { * txtMessages.Text = $"Error exporting phones: {ServantKeeperApi.ErrorMessage}"; * }*/ } // export contributions if (exportSettings.ExportContributions) { exportWorker.ReportProgress(30, "Exporting Funds..."); ServantKeeperApi.ExportFunds(); if (ServantKeeperApi.ErrorMessage.IsNotNullOrWhitespace()) { exportWorker.ReportProgress(31, $"Error exporting funds: {ServantKeeperApi.ErrorMessage}"); } exportWorker.ReportProgress(32, "Exporting Contributions..."); ServantKeeperApi.ExportContributions(exportSettings.ModifiedSince); if (ServantKeeperApi.ErrorMessage.IsNotNullOrWhitespace()) { exportWorker.ReportProgress(33, $"Error exporting contributions: {ServantKeeperApi.ErrorMessage}"); } } // finalize the package ImportPackage.FinalizePackage("servantkeeper-export.slingshot"); // schedule the API status to update (the status takes a few mins to update) _apiUpdateTimer.Start(); }
/// <summary> /// Writes the group attributes. /// </summary> public static void WriteGroupAttributes() { // export person attribute list ImportPackage.WriteToPackage(new GroupAttribute() { Name = "Has Childcare", Key = "HasChildcare", Category = "Small Group", FieldType = "Rock.Field.Types.BooleanFieldType" }); }
public static void WriteFinancialBatch() { // hardcode a generic financial batch ImportPackage.WriteToPackage(new FinancialBatch() { Id = 9999, Name = "Imported Transactions", Status = BatchStatus.Closed, StartDate = DateTime.Now }); }
private void ExportWorker_DoWork(object sender, DoWorkEventArgs e) { exportWorker.ReportProgress(0, ""); var exportSettings = (ExportSettings)e.Argument; // clear filesystem directories ShelbyNextApi.InitializeExport(exportSettings.ModifiedSince, exportSettings.NoContributionsBefore); // export individuals and phone numbers if (exportSettings.ExportIndividuals) { exportWorker.ReportProgress(1, "Exporting Individuals..."); ShelbyNextApi.ExportIndividuals(); if (ShelbyNextApi.ErrorMessage.IsNotNullOrWhitespace()) { txtMessages.Text = $"Error exporting individuals: {ShelbyNextApi.ErrorMessage}"; } } // export contributions if (exportSettings.ExportContributions) { exportWorker.ReportProgress(32, "Exporting Contributions..."); ShelbyNextApi.ExportContributions(); if (ShelbyNextApi.ErrorMessage.IsNotNullOrWhitespace()) { exportWorker.ReportProgress(33, $"Error exporting contributions: {ShelbyNextApi.ErrorMessage}"); } } // export groups if (exportSettings.ExportGroups) { exportWorker.ReportProgress(54, $"Exporting Groups..."); ShelbyNextApi.ExportGroups(exportSettings.SelectedGroups); if (ShelbyNextApi.ErrorMessage.IsNotNullOrWhitespace()) { exportWorker.ReportProgress(54, $"Error exporting groups: {ShelbyNextApi.ErrorMessage}"); } } // finalize the package ImportPackage.FinalizePackage("ShelbyNext.slingshot"); // schedule the API status to update (the status takes a few mins to update) _apiUpdateTimer.Start(); }
/// <summary> /// Exports any contributions. Currently, the ACS export file doesn't include /// batches. /// </summary> public static void ExportContributions(DateTime modifiedSince) { try { // since the ACS export doesn't include batches and Rock expects transactions // to belong to a batch, a default batch is created. WriteFinancialBatch(); using (var dtContributions = GetTableData(SQL_FINANCIAL_TRANSACTIONS)) { foreach (DataRow row in dtContributions.Rows) { var importFinancialTransaction = AcsFinancialTransaction.Translate(row); if (importFinancialTransaction != null) { ImportPackage.WriteToPackage(importFinancialTransaction); } } } using (var dtContributionDetails = GetTableData(SQL_FINANCIAL_TRANSACTIONDETAILS)) { foreach (DataRow row in dtContributionDetails.Rows) { var importFinancialTransactionDetail = AcsFinancialTransactionDetail.Translate(row); if (importFinancialTransactionDetail != null) { ImportPackage.WriteToPackage(importFinancialTransactionDetail); } } } using (var dtPledges = GetTableData(SQL_FINANCIAL_PLEDGES)) { foreach (DataRow row in dtPledges.Rows) { var importFinancialPledge = AcsFinancialPledge.Translate(row); if (importFinancialPledge != null) { ImportPackage.WriteToPackage(importFinancialPledge); } } } } catch (Exception ex) { ErrorMessage = ex.Message; } }
/// <summary> /// Internal method for ExportCompanies(). /// </summary> private void ExportCompanies_Internal() { WriteBusinessAttributes(); using (var dtCommunications = GetTableData(SqlQueries.COMPANY_COMMUNICATIONS)) using (var dtCompanies = GetTableData(SqlQueries.COMPANY, true)) { foreach (DataRow row in dtCompanies.Rows) { var business = F1Business.Translate(row, dtCommunications); if (business != null) { ImportPackage.WriteToPackage(business); } } // export Phone Numbers foreach (DataRow row in dtCommunications.Rows) { var importNumber = F1BusinessPhone.Translate(row); if (importNumber != null) { ImportPackage.WriteToPackage(importNumber); } } // Cleanup - Remember not to Clear() any cached tables. dtCommunications.Clear(); GC.Collect(); } using (var dtAddress = GetTableData(SqlQueries.COMPANY_ADDRESSES)) { foreach (DataRow row in dtAddress.Rows) { var importAddress = F1BusinessAddress.Translate(row); if (importAddress != null) { ImportPackage.WriteToPackage(importAddress); } } // Cleanup - Remember not to Clear() any cached tables. dtAddress.Clear(); GC.Collect(); } }
/// <summary> /// Writes the group types. /// </summary> /// <param name="selectedGroupTypes">The selected group types.</param> public override void WriteGroupTypes(List <int> selectedGroupTypes) { // add custom defined group types var groupTypes = GetGroupTypes(); foreach (var groupType in groupTypes.Where(t => selectedGroupTypes.Contains(t.Id))) { ImportPackage.WriteToPackage(new GroupType() { Id = groupType.Id, Name = groupType.Name }); } }