/// <summary> /// load or reload the navigation /// </summary> public void LoadNavigationUI(bool ADontUseDefaultLedger = false) { // Force re-calculation of available Ledgers and correct setting of FCurrentLedger FLedgersAvailableToUser = null; XmlNode MainMenuNode = BuildNavigationXml(ADontUseDefaultLedger); XmlNode DepartmentNode = MainMenuNode.FirstChild; lstFolders.MultiLedgerSite = FMultiLedgerSite; lstFolders.CurrentLedger = FCurrentLedger; lstFolders.ConferenceSelected = FConferenceSelected; lstFolders.ClearFolders(); lstFolders.SubmoduleChanged += delegate(TTaskList ATaskList, XmlNode ATaskListNode, LinkLabel AItemClicked, object AOtherData) { OnSubmoduleChanged(ATaskList, ATaskListNode, AItemClicked); }; lstFolders.LedgerChanged += delegate(int ALedgerNr, string ALedgerName) { OnLedgerChanged(ALedgerNr, ALedgerName); }; TPnlModuleNavigation.SubSystemLinkStatus += delegate(int ALedgerNr, TPnlCollapsible APnlCollapsible) { UpdateSubsystemLinkStatus(ALedgerNr, APnlCollapsible); }; TFrmGLEnableSubsystems.FinanceSubSystemLinkStatus += delegate() { UpdateFinanceSubsystemLinkStatus(); }; TLstTasks.Init(UserInfo.GUserInfo.UserID, HasAccessPermission, FTaxDeductiblePercentageEnabled); while (DepartmentNode != null) { lstFolders.AddFolder(DepartmentNode, UserInfo.GUserInfo.UserID, HasAccessPermission); DepartmentNode = DepartmentNode.NextSibling; } lstFolders.Dashboard = this.dsbContent; lstFolders.Statusbar = this.stbMain; SetTaskTileSize(TUserDefaults.GetInt16Default(TUserDefaults.MAINMENU_VIEWOPTIONS_TILESIZE, 2)); SetTasksSingleClickExecution(TUserDefaults.GetBooleanDefault(TUserDefaults.MAINMENU_VIEWOPTIONS_SINGLECLICKEXECUTION, false)); if (TUserDefaults.GetStringDefault(TUserDefaults.MAINMENU_VIEWOPTIONS_VIEWTASKS, VIEWTASKS_TILES) == VIEWTASKS_TILES) { ViewTasksAsTiles(this, null); } else { ViewTasksAsList(this, null); } lstFolders.SelectFirstAvailableFolder(); }
private void FilterToggledManual(bool IsCollapsed) { // We resize the grid whenever the filter toggles. When it is collapsed the headers are included in the column width. // When it is visible the headers are excluded from the column width, which keeps all the columns in the same space as when it is collapsed. grdDetails.AutoResizeGrid(); // The first time the panel is shown we want to set the 'Retired' checkbox to unticked so all retired users get excluded if ((FFilterAndFindObject.FilterFindPanel != null) && !FFilterAndFindObject.FilterFindPanel.IsCollapsed && !FInitialActiveUserCheckSet) { short defaultValue = TUserDefaults.GetInt16Default("MaintainUsers_InitialFilter", 2); CheckBox chk = (CheckBox)FFilterAndFindObject.FilterPanelControls.FindControlByName("chkRetired"); chk.CheckState = (CheckState)defaultValue; FInitialActiveUserCheckSet = true; } }
/// <summary></summary> public void InitializeManualCode() { txtEmailBody.AcceptsReturn = true; txtAccountPswd.UseSystemPasswordChar = true; LoadEmailDefaults(); txtServerName.Text = TUserDefaults.GetStringDefault("SmtpHost"); txtPort.Text = TUserDefaults.GetInt16Default("SmtpPort").ToString(); chkUseSsl.Checked = TUserDefaults.GetBooleanDefault("SmtpUseSsl"); txtAccountName.Text = TUserDefaults.GetStringDefault("SmtpUser"); txtAccountPswd.Text = TUserDefaults.GetStringDefault("SmtpPassword"); txtSenderAddress.Text = TUserDefaults.GetStringDefault("SmtpFromAccount"); txtDisplayName.Text = TUserDefaults.GetStringDefault("SmtpDisplayName"); txtReplyTo.Text = TUserDefaults.GetStringDefault("SmtpReplyTo"); txtCopyMessagesTo.Text = TUserDefaults.GetStringDefault("SmtpCcTo"); txtEmailBody.Text = TUserDefaults.GetStringDefault("SmtpEmailBody"); chkReportsAsAttachment.Checked = TUserDefaults.GetBooleanDefault("SmtpSendAsAttachment"); }
private void InitializeManualCode() { DataTable CultureTable = new DataTable(); CultureTable.Columns.Add("Value", typeof(string)); CultureTable.Columns.Add("Display", typeof(string)); foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures)) { if (!ci.IsNeutralCulture) { DataRow row = CultureTable.NewRow(); row[0] = ci.Name; row[1] = ci.EnglishName; CultureTable.Rows.Add(row); } } CultureTable.DefaultView.Sort = "Display"; cmbCulture.DisplayMember = "Display"; cmbCulture.ValueMember = "Value"; cmbCulture.DataSource = CultureTable.DefaultView; // load languages from names of language sub directories string[] LanguageDirectories = Directory.GetDirectories(TAppSettingsManager.ApplicationDirectory); string LanguagesAvailable = "en-EN"; foreach (String directory in LanguageDirectories) { if (File.Exists(directory + Path.DirectorySeparatorChar + "OpenPetra.resources.dll")) { LanguagesAvailable = StringHelper.AddCSV( LanguagesAvailable, directory.Substring( directory.LastIndexOf(Path.DirectorySeparatorChar) + 1)); } } cmbLanguage.SetDataSourceStringList(LanguagesAvailable); // for the moment default to english, because translations are not fully supported, and the layout does not adjust string LanguageCode = "en-EN"; string CultureCode = CultureInfo.CurrentCulture.Name; TRemote.MSysMan.Maintenance.WebConnectors.GetLanguageAndCulture(ref LanguageCode, ref CultureCode); cmbCulture.SetSelectedString(CultureCode); cmbLanguage.SetSelectedString(LanguageCode); llbLaunchpadLink.Click += LaunchpadLinkClicked; // Get the number of recent partners that the user has set, if not found take 10 as default value. nudNumberOfPartners.Value = TUserDefaults.GetInt16Default(MSysManConstants.USERDEFAULT_NUMBEROFRECENTPARTNERS, 10); nudNumberOfPartners.Maximum = 10; // Other preferences chkEscClosesScreen.Checked = TUserDefaults.GetBooleanDefault(TUserDefaults.NamedDefaults.USERDEFAULT_ESC_CLOSES_SCREEN, true); chkSaveWindowProperties.Checked = TUserDefaults.GetBooleanDefault(TUserDefaults.NamedDefaults.USERDEFAULT_SAVE_WINDOW_POS_AND_SIZE, true); WasSaveWindowPropertiesInitiallyChecked = chkSaveWindowProperties.Checked; }
/// <summary> /// The report will be sent to a list of email addresses derived from the Cost Centres in the supplied CostCentreFilter. /// </summary> /// <param name="ACalc"></param> /// <param name="ALedgerNumber"></param> /// <param name="ACostCentreFilter"></param> public void AutoEmailReports(TRptCalculator ACalc, Int32 ALedgerNumber, String ACostCentreFilter) { Int32 SuccessfulCount = 0; String NoEmailAddr = ""; String FailedAddresses = ""; // // I need to find the email addresses for the linked partners I'm sending to. DataTable LinkedPartners = TRemote.MFinance.Setup.WebConnectors.GetLinkedPartners(ALedgerNumber, ACostCentreFilter); LinkedPartners.DefaultView.Sort = "CostCentreCode"; foreach (DataRowView rv in LinkedPartners.DefaultView) { DataRow LinkedPartner = rv.Row; if (LinkedPartner["EmailAddress"].ToString() != "") { ACalc.AddStringParameter("param_linked_partner_cc", LinkedPartner["CostCentreCode"].ToString()); FPetraUtilsObject.WriteToStatusBar("Generate " + FReportName + " Report for " + LinkedPartner["PartnerShortName"]); MemoryStream ReportStream = FPetraUtilsObject.FFastReportsPlugin.ExportToStream(ACalc, FastReportsWrapper.ReportExportType.Html); ReportStream.Position = 0; TUC_EmailPreferences.LoadEmailDefaults(); TSmtpSender EmailSender; try { EmailSender = new TSmtpSender( TUserDefaults.GetStringDefault("SmtpHost"), TUserDefaults.GetInt16Default("SmtpPort"), TUserDefaults.GetBooleanDefault("SmtpUseSsl"), TUserDefaults.GetStringDefault("SmtpUser"), TUserDefaults.GetStringDefault("SmtpPassword"), ""); EmailSender.CcEverythingTo = TUserDefaults.GetStringDefault("SmtpCcTo"); EmailSender.ReplyTo = TUserDefaults.GetStringDefault("SmtpReplyTo"); } catch (Exception) { MessageBox.Show(Catalog.GetString( "Failed to set up the email server.\nPlease check the settings in Preferences / Email."), Catalog.GetString("Auto-email to linked partners")); return; } String EmailBody = ""; if (TUserDefaults.GetBooleanDefault("SmtpSendAsAttachment")) { EmailBody = TUserDefaults.GetStringDefault("SmtpEmailBody"); EmailSender.AttachFromStream(ReportStream, FReportName + ".html"); } else { StreamReader sr = new StreamReader(ReportStream); EmailBody = sr.ReadToEnd(); } Boolean SentOk = EmailSender.SendEmail( TUserDefaults.GetStringDefault("SmtpFromAccount"), TUserDefaults.GetStringDefault("SmtpDisplayName"), "*****@*****.**", //LinkedPartner["EmailAddress"] FReportName + " Report for " + LinkedPartner["PartnerShortName"] + ", Address=" + LinkedPartner["EmailAddress"], EmailBody); if (SentOk) { SuccessfulCount++; } else // Email didn't send for some reason { FailedAddresses += ("\r\n" + LinkedPartner["EmailAddress"]); } } else // No Email Address for this Partner { NoEmailAddr += ("\r\n" + LinkedPartner["PartnerKey"] + " " + LinkedPartner["PartnerShortName"]); } } String SendReport = ""; if (SuccessfulCount > 0) { SendReport += String.Format(Catalog.GetString("Reports emailed to {0} addresses."), SuccessfulCount) + "\r\n\r\n"; } if (NoEmailAddr != "") { SendReport += (Catalog.GetString("These Partners have no email addresses:") + NoEmailAddr + "\r\n\r\n"); } if (FailedAddresses != "") { SendReport += (Catalog.GetString("Failed to send email to these addresses:") + FailedAddresses + "\r\n\r\n"); } MessageBox.Show(SendReport, Catalog.GetString("Auto-email to linked partners")); FPetraUtilsObject.WriteToStatusBar(""); } // AutoEmailReports
/// <summary> /// The report will be sent to a list of email addresses derived from the Cost Centres in the supplied CostCentreFilter. /// </summary> /// <returns>Status string that should be shown to the user</returns> public static String AutoEmailReports(TFrmPetraReportingUtils FormUtils, FastReportsWrapper ReportEngine, TRptCalculator ACalc, Int32 ALedgerNumber, String ACostCentreFilter) { Int32 SuccessfulCount = 0; String NoEmailAddr = ""; String FailedAddresses = ""; String SendReport = ""; // // I need to find the email addresses for the linked partners I'm sending to. DataTable LinkedPartners = null; LinkedPartners = TRemote.MFinance.Setup.WebConnectors.GetLinkedPartners(ALedgerNumber, ACostCentreFilter); LinkedPartners.DefaultView.Sort = "CostCentreCode"; foreach (DataRowView rv in LinkedPartners.DefaultView) { DataRow LinkedPartner = rv.Row; if (LinkedPartner["EmailAddress"].ToString() != "") { ACalc.AddStringParameter("param_linked_partner_cc", LinkedPartner["CostCentreCode"].ToString()); FormUtils.WriteToStatusBar("Generate " + ReportEngine.FReportName + " Report for " + LinkedPartner["PartnerShortName"]); MemoryStream ReportStream = ReportEngine.ExportToStream(ACalc, FastReportsWrapper.ReportExportType.Html); if (ReportStream.Position < 1000) { continue; // Don't send an empty report } ReportStream.Position = 0; TUC_EmailPreferences.LoadEmailDefaults(); TSmtpSender EmailSender = new TSmtpSender( TUserDefaults.GetStringDefault("SmtpHost"), TUserDefaults.GetInt16Default("SmtpPort"), TUserDefaults.GetBooleanDefault("SmtpUseSsl"), TUserDefaults.GetStringDefault("SmtpUser"), TUserDefaults.GetStringDefault("SmtpPassword"), ""); EmailSender.CcEverythingTo = TUserDefaults.GetStringDefault("SmtpCcTo"); EmailSender.ReplyTo = TUserDefaults.GetStringDefault("SmtpReplyTo"); if (!EmailSender.FInitOk) { return(String.Format( Catalog.GetString( "Failed to set up the email server.\n Please check the settings in Preferences / Email.\n Message returned : \"{0}\""), EmailSender.FErrorStatus)); } String EmailBody = ""; if (TUserDefaults.GetBooleanDefault("SmtpSendAsAttachment")) { EmailBody = TUserDefaults.GetStringDefault("SmtpEmailBody"); EmailSender.AttachFromStream(ReportStream, ReportEngine.FReportName + ".html"); } else { StreamReader sr = new StreamReader(ReportStream); EmailBody = sr.ReadToEnd(); } Boolean SentOk = EmailSender.SendEmail( TUserDefaults.GetStringDefault("SmtpFromAccount"), TUserDefaults.GetStringDefault("SmtpDisplayName"), "*****@*****.**", //LinkedPartner["EmailAddress"] ReportEngine.FReportName + " Report for " + LinkedPartner["PartnerShortName"] + ", Address=" + LinkedPartner["EmailAddress"], EmailBody); if (SentOk) { SuccessfulCount++; } else // Email didn't send for some reason { SendReport += String.Format( Catalog.GetString("\r\nFailed to send to {0}. Message returned: \"{1}\"."), LinkedPartner["EmailAddress"], EmailSender.FErrorStatus ); FailedAddresses += ("\r\n " + LinkedPartner["EmailAddress"]); } } else // No Email Address for this Partner { NoEmailAddr += ("\r\n " + LinkedPartner["PartnerKey"] + " " + LinkedPartner["PartnerShortName"]); } } if (SuccessfulCount > 0) { SendReport += String.Format(Catalog.GetString("\r\n{0} emailed to {1} addresses."), ReportEngine.FReportName, SuccessfulCount) + "\r\n\r\n"; } if (NoEmailAddr != "") { SendReport += (Catalog.GetString("\r\nThese Partners have no email addresses:") + NoEmailAddr + "\r\n"); } if (FailedAddresses != "") { SendReport += (Catalog.GetString("Failed to send email to these addresses:") + FailedAddresses + "\r\n\r\n"); } FormUtils.WriteToStatusBar(""); return(SendReport); } // AutoEmailReports
private void InitializeManualCode() { if (TUserDefaults.GetStringDefault(TUserDefaults.MAINMENU_VIEWOPTIONS_VIEWTASKS, "Tiles") == "List") { rbtList.Checked = true; ViewTasks = "List"; } TaskSize = TUserDefaults.GetInt16Default(TUserDefaults.MAINMENU_VIEWOPTIONS_TILESIZE, 2); if (TaskSize == 2) { rbtMedium.Checked = true; } else if (TaskSize == 3) { rbtSmall.Checked = true; } if (TUserDefaults.GetBooleanDefault(TUserDefaults.MAINMENU_VIEWOPTIONS_SINGLECLICKEXECUTION, false) == true) { chkSingleClickExecution.Checked = true; SingleClickExecution = true; } // get user's current prefered grid colours OriginalBackgroundColour = System.Drawing.ColorTranslator.FromHtml( TUserDefaults.GetStringDefault(TUserDefaults.NamedDefaults.COLOUR_GRID_BACKGROUND, System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.White))); OriginalCellBackgroundColour = System.Drawing.ColorTranslator.FromHtml( TUserDefaults.GetStringDefault(TUserDefaults.NamedDefaults.COLOUR_GRID_CELLBACKGROUND, System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.White))); AlternateColour = System.Drawing.ColorTranslator.FromHtml( TUserDefaults.GetStringDefault(TUserDefaults.NamedDefaults.COLOUR_GRID_ALTERNATE, System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(230, 230, 230)))); GridlinesColour = System.Drawing.ColorTranslator.FromHtml( TUserDefaults.GetStringDefault(TUserDefaults.NamedDefaults.COLOUR_GRID_GRIDLINES, System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(211, 211, 211)))); FilterColour = System.Drawing.ColorTranslator.FromHtml( TUserDefaults.GetStringDefault(TUserDefaults.NamedDefaults.COLOUR_FILTER_PANEL, System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.LightBlue))); FindColour = System.Drawing.ColorTranslator.FromHtml( TUserDefaults.GetStringDefault(TUserDefaults.NamedDefaults.COLOUR_FIND_PANEL, System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.BurlyWood))); BackgroundColorDialog.Color = OriginalBackgroundColour; CellBackgroundColorDialog.Color = OriginalCellBackgroundColour; AlternateColorDialog.Color = AlternateColour; GridlinesColorDialog.Color = GridlinesColour; FilterColorDialog.Color = FilterColour; FindColorDialog.Color = FindColour; string SelectionColourUserDefault; // The UserDefault for the Selection colour stores a decimal Alpha value appended to the HTML representation of the colour // because the Selection needs to be transparent to a certain degree in order to let the data of a selected Grid Row shine through! // Example: "#00FFAA;50": A=140 (decimal 140), R=15 (hex 0F), G=255 (hex FF), B=170 (hex AA) SelectionColourUserDefault = TUserDefaults.GetStringDefault(TUserDefaults.NamedDefaults.COLOUR_GRID_SELECTION, String.Empty); if (SelectionColourUserDefault.Length > 0) { SelectionColour = System.Drawing.ColorTranslator.FromHtml(SelectionColourUserDefault.Split(';')[0]); SelectionAlpha = Convert.ToInt32(SelectionColourUserDefault.Split(';')[1]); } else { // No UserDefault for the Selection in the DB; use a hard-coded default SelectionColour = System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.Highlight); SelectionAlpha = 120; } SelectionColorDialog.Color = SelectionColour; nudAlpha.Maximum = 255; nudAlpha.Value = 255 - SelectionAlpha; SetButtonColours(); // create DataTable and DataRows for an example grid DataTable ExampleTable = new DataTable("Example"); DataColumn Column1 = new DataColumn("Column1"); DataColumn Column2 = new DataColumn("Column2"); ExampleTable.Columns.Add(Column1); ExampleTable.Columns.Add(Column2); grdExample.AddTextColumn(Catalog.GetString("Column1"), Column1); grdExample.AddTextColumn(Catalog.GetString("Column2"), Column2); DataRow ExampleRow1 = ExampleTable.NewRow(); DataRow ExampleRow2 = ExampleTable.NewRow(); DataRow ExampleRow3 = ExampleTable.NewRow(); DataRow ExampleRow4 = ExampleTable.NewRow(); DataRow ExampleRow5 = ExampleTable.NewRow(); ExampleRow1[0] = "Row 1"; ExampleRow1[1] = "Row 1"; ExampleRow2[0] = "Row 2"; ExampleRow2[1] = "Row 2"; ExampleRow3[0] = "Row 3"; ExampleRow3[1] = "Row 3"; ExampleRow4[0] = "Row 4"; ExampleRow4[1] = "Row 4"; ExampleRow5[0] = "Row 5"; ExampleRow5[1] = "Row 5"; ExampleTable.Rows.Add(ExampleRow1); ExampleTable.Rows.Add(ExampleRow2); ExampleTable.Rows.Add(ExampleRow3); ExampleTable.Rows.Add(ExampleRow4); ExampleTable.Rows.Add(ExampleRow5); DataView MyDataView = ExampleTable.DefaultView; MyDataView.AllowNew = false; grdExample.DataSource = new DevAge.ComponentModel.BoundDataView(MyDataView); }
public static String ExportToIntranet(Boolean AExportDonationData, Boolean AExportFieldData, Boolean AExportPersonData, String AServerEmailAddress, String APswd, Int32 ADaySpan, String AOptionalMetadata, String ReplyToEmail) { try { FZipFileNames.Clear(); FExportFilePath = TAppSettingsManager.GetValue("OpenPetra.PathTemp") + @"\"; FExportTrace = "Exporting (Temporary path: " + FExportFilePath + ")\r\n"; FTransaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadCommitted); if (AExportDonationData) { ExportDonations(ADaySpan); AddZipFile("donor.csv"); AddZipFile("donation.csv"); AddZipFile("recipient.csv"); } if (AExportFieldData) { if (ExportField()) { AddZipFile("field.csv"); } } if (AExportPersonData) { ExportPersonnel(); AddZipFile("position.csv"); AddZipFile("person.csv"); AddZipFile("email.csv"); } ExportMetadata(AOptionalMetadata, APswd); AddZipFile("metadata.csv"); MemoryStream ZippedStream = TFileHelper.Streams.Compression.DeflateFilesIntoMemoryStream(FZipFileNames.ToArray(), false, ""); TFileHelper.Streams.FileHandling.SaveStreamToFile(ZippedStream, FExportFilePath + "data.zip"); FExportTrace += "\r\nFiles compressed to " + FExportFilePath + "data.zip."; if (EncryptUsingPublicKey("data.zip", AServerEmailAddress)) { TSmtpSender SendMail = new TSmtpSender( TUserDefaults.GetStringDefault("SmtpHost"), TUserDefaults.GetInt16Default("SmtpPort"), TUserDefaults.GetBooleanDefault("SmtpUseSsl"), TUserDefaults.GetStringDefault("SmtpUser"), TUserDefaults.GetStringDefault("SmtpPassword"), ""); String SenderAddress = ReplyToEmail; MailMessage msg = new MailMessage(SenderAddress, AServerEmailAddress, "Data from OpenPetra", "Here is the latest data from my field."); msg.Attachments.Add(new Attachment(FExportFilePath + "data.zip.gpg")); if (SendMail.SendMessage(msg)) { FExportTrace += ("\r\nEmail sent to " + msg.To[0].Address); } else { FExportTrace += ("\r\nNo Email was sent."); } msg.Dispose(); // If I don't call this, the attached files are still locked! } else { FExportTrace += "\r\nError: Data encryption failed."; } } catch (Exception e) { FExportTrace += ("\r\nException: " + e.Message); } finally { DBAccess.GDBAccessObj.RollbackTransaction(); DeleteTemporaryFiles(); DonorList.Clear(); RecipientList.Clear(); // These lists are static so they'll stick around for ever, // but I don't need to keep the data which is taking up memory. } return(FExportTrace); }
} // Load Hosa Report Data private Boolean LoadStewardshipReportData(TRptCalculator ACalc) { Dictionary <String, TVariant> paramsDictionary = InitialiseDictionary(ACalc); DataTable ReportTable = TRemote.MReporting.WebConnectors.GetReportDataTable("Stewardship", paramsDictionary); if (this.IsDisposed) { return(false); } if (ReportTable == null) { FPetraUtilsObject.WriteToStatusBar("Report Cancelled."); return(false); } MyFastReportsPlugin.RegisterData(ReportTable, "Stewardship"); Boolean HasData = (ReportTable.Rows.Count > 0); if (!HasData) { FStatusMsg += Catalog.GetString("No Stewardship entries found for selected Run Number."); } TParameterList Params = ACalc.GetParameters(); if ((!Params.Get("param_design_template").ToBool()) && (rbtEmailStewardship.Checked)) { TUC_EmailPreferences.LoadEmailDefaults(); TSmtpSender EmailSender = new TSmtpSender( TUserDefaults.GetStringDefault("SmtpHost"), TUserDefaults.GetInt16Default("SmtpPort"), TUserDefaults.GetBooleanDefault("SmtpUseSsl"), TUserDefaults.GetStringDefault("SmtpUser"), TUserDefaults.GetStringDefault("SmtpPassword"), ""); EmailSender.CcEverythingTo = TUserDefaults.GetStringDefault("SmtpCcTo"); EmailSender.ReplyTo = TUserDefaults.GetStringDefault("SmtpReplyTo"); if (!EmailSender.FInitOk) { FStatusMsg += String.Format( Catalog.GetString( "\r\nFailed to set up the email server.\n Please check the settings in Preferences / Email.\n Message returned: \"{0}\""), EmailSender.FErrorStatus ); return(false); } String MyCostCentreCode = String.Format("{0:##00}00", FLedgerNumber); String PeriodEnd = Params.Get("param_end_date").ToDate().ToString("dd/MM/yyyy"); Int32 RunNumber = Params.Get("param_cmbICHNumber").ToInt32(); String CsvAttachment = String.Format("\"{0}\",{1},\"{2}\",{3},\"{4}\",{5}\n", // "OP:1",30/11/2014,\"0200\",09/12/2014,\"USD\",0" "OP:1", // software originator and version ID PeriodEnd, MyCostCentreCode, // Field Cost Centre Code DateTime.Now.ToString("dd/MM/yyyy"), FLedgerRow.BaseCurrency, // Stewardship Report CSV always in Base Currency RunNumber // Run number ); foreach (DataRow Row in ReportTable.Rows) { CsvAttachment += String.Format("\"{0}\",{1},{2},{3}\n", Row["CostCentreCode"].ToString(), Convert.ToDecimal(Row["Income"]).ToString("0.00", CultureInfo.InvariantCulture), // Stewardship Report CSV always in Base Currency Convert.ToDecimal(Row["Expense"]).ToString("0.00", CultureInfo.InvariantCulture), Convert.ToDecimal(Row["Xfer"]).ToString("0.00", CultureInfo.InvariantCulture) ); } String EmailBody = TUserDefaults.GetStringDefault("SmtpEmailBody"); EmailSender.AttachFromStream(new MemoryStream(Encoding.ASCII.GetBytes(CsvAttachment)), "Stewardship_" + MyCostCentreCode + ".csv"); Boolean SentOk = EmailSender.SendEmail( TUserDefaults.GetStringDefault("SmtpFromAccount"), TUserDefaults.GetStringDefault("SmtpDisplayName"), "*****@*****.**", //[email protected] "Stewardship Report [" + MyCostCentreCode + "] Period end: " + PeriodEnd + " Run#: " + RunNumber, EmailBody); if (SentOk) { FStatusMsg += Catalog.GetString("\r\nStewardship report emailed to ICH."); } else { FStatusMsg += Catalog.GetString("\r\nFailed to send Stewardship email to ICH."); } return(false); } return(HasData); } // Load Stewardship Report Data