private void OBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { this.Dispatcher.Invoke(() => { EnterEmailPasswordWindow oEnterEmailPasswordWindow = e.Argument as EnterEmailPasswordWindow; var varList = (InstallmentPerLoanGridControl.ItemsSource as System.Collections.Generic.List <ViewModels.InstallmentViewModel>) .Select(current => new { current.AmountRialFormat, current.PersianInstallmentDate, current.PersianPaymentDate, current.IsPayedDescription, }) .ToList(); Stimulsoft.Report.StiReport oStiReport = new Stimulsoft.Report.StiReport(); oStiReport.Load(Properties.Resources.InstallmentListReport); oStiReport.Dictionary.Variables.Add("Today", System.DateTime.Now.ToPersianDate()); oStiReport.Dictionary.Variables.Add("FundName", Utility.CurrentFund.Name); oStiReport.Dictionary.Variables.Add("FundManagerName", Utility.CurrentFund.ManagerName); oStiReport.Dictionary.Variables.Add("MemberName", Utility.CurrentLoan.Member.FullName.ToString()); oStiReport.Dictionary.Variables.Add("LoanAmount", (new ViewModels.LoanViewModel { LoanAmount = Utility.CurrentLoan.LoanAmount }).LoanAmountRialFormat); oStiReport.Dictionary.Variables.Add("RefundAmount", (new ViewModels.LoanViewModel { RefundAmount = Utility.CurrentLoan.RefundAmount }).RefundAmountRialFormat); oStiReport.RegBusinessObject("InstallmentsList", varList); oStiReport.Compile(); oStiReport.RenderWithWpf(); System.IO.MemoryStream oMemoryStream = new System.IO.MemoryStream(); oStiReport.ExportDocument(Stimulsoft.Report.StiExportFormat.Pdf, oMemoryStream); oMemoryStream.Seek(0, System.IO.SeekOrigin.Begin); Utility.SendEmail ( senderEmail: Utility.CurrentUser.EmailAddress, senderPassword: oEnterEmailPasswordWindow.EmailPassword, displayName: Utility.CurrentUser.FullName.ToString(), receiverEmail: Utility.CurrentMember.EmailAddress, subject: Utility.CurrentFund.Name + " | " + "لیست اقساط " + Utility.CurrentMember.FullName.ToString(), body: "لیست اقساط " + Utility.CurrentMember.FullName.ToString() + System.Environment.NewLine + new FarsiLibrary.Utils.PersianDate(System.DateTime.Now).ToString(), attachment: oMemoryStream, attachmentName: "لیست اقساط " + Utility.CurrentMember.FullName.ToString() ); }); }
private void OBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { this.Dispatcher.Invoke(() => { EnterEmailPasswordWindow oEnterEmailPasswordWindow = e.Argument as EnterEmailPasswordWindow; var varObject = new { LoansCount = LoansCountLabel.Content, LoansAmount = LoansAmountLabel.Content, PayedLoansCount = PayedLoansCountLabel.Content, PayedLoansAmount = PayedLoansAmountLabel.Content, InstallmentsCount = InstallmentsCountLabel.Content, InstallmentsAmount = InstallmentsAmountLabel.Content, PayedInstallmentsCount = PayedInstallmentsCountLabel.Content, PayedInstallmentsAmount = PayedInstallmentsAmountLabel.Content, }; Stimulsoft.Report.StiReport oStiReport = new Stimulsoft.Report.StiReport(); oStiReport.Load(Properties.Resources.FundBalanceReport); oStiReport.Dictionary.Variables.Add("Today", System.DateTime.Now.ToPersianDate()); oStiReport.Dictionary.Variables.Add("FundName", Utility.CurrentFund.Name); oStiReport.Dictionary.Variables.Add("FundManagerName", Utility.CurrentFund.ManagerName); oStiReport.Dictionary.Variables.Add("FundBalance", Utility.CurrentFund.Balance.ToRialStringFormat()); oStiReport.RegBusinessObject("MemberBalance", varObject); oStiReport.Compile(); oStiReport.RenderWithWpf(); System.IO.MemoryStream oMemoryStream = new System.IO.MemoryStream(); oStiReport.ExportDocument(Stimulsoft.Report.StiExportFormat.Pdf, oMemoryStream); oMemoryStream.Seek(0, System.IO.SeekOrigin.Begin); Utility.SendEmail ( senderEmail: Utility.CurrentUser.EmailAddress, senderPassword: oEnterEmailPasswordWindow.EmailPassword, displayName: Utility.CurrentUser.FullName.ToString(), receiverEmail: Utility.CurrentMember.EmailAddress, subject: Utility.CurrentFund.Name + " | " + "تراز مالی عضو " + Utility.CurrentMember.FullName.ToString(), body: "تراز مالی " + Utility.CurrentMember.FullName.ToString() + System.Environment.NewLine + new FarsiLibrary.Utils.PersianDate(System.DateTime.Now).ToString(), attachment: oMemoryStream, attachmentName: "تراز مالی " + Utility.CurrentMember.FullName.ToString() ); }); }
public static void ExportToPdf(this Stimulsoft.Report.StiReport report, string reportTitle) { _saveFileDialog = new Microsoft.Win32.SaveFileDialog(); _saveFileDialog.Filter = "PDF Files | *.pdf"; _saveFileDialog.Title = "Save as Pdf"; _saveFileDialog.OverwritePrompt = true; FarsiLibrary.Utils.PersianDate oPersianDate = FarsiLibrary.Utils.PersianDateConverter.ToPersianDate(System.DateTime.Now); _saveFileDialog.FileName = string.Format("{6} {5}-{4}-{3}-{2}-{1}-{0}", oPersianDate.Year, oPersianDate.Month.ToString("00"), oPersianDate.Day.ToString("00"), oPersianDate.Hour.ToString("00"), oPersianDate.Minute.ToString("00"), oPersianDate.Second.ToString("00"), reportTitle ); if (_saveFileDialog.ShowDialog() == true) { string path = System.IO.Path.GetFullPath(_saveFileDialog.FileName); report.ExportDocument(Stimulsoft.Report.StiExportFormat.Pdf, path); System.Windows.MessageBoxResult oDialogResult = Infrastructure.MessageBox.Show ( caption: Infrastructure.MessageBox.Caption.Question, text: "خروجی گزارش با موفقیت ذخیره گردید." + System.Environment.NewLine + "آیا مایل به مشاهده خروجی میباشید؟" ); if (oDialogResult == System.Windows.MessageBoxResult.Yes) { System.Diagnostics.Process.Start(path); } } }
private void OBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { this.Dispatcher.Invoke(() => { EnterEmailPasswordWindow oEnterEmailPasswordWindow = e.Argument as EnterEmailPasswordWindow; var varList = (MembersLoanGridControl.ItemsSource as System.Collections.Generic.List <ViewModels.LoanViewModel>) .OrderBy(current => current.StartDate) .Select(current => new { current.LoanAmountRialFormat, current.RefundAmountRialFormat, current.PersianEndDate, current.PersianStartDate, current.InstallmentsCount, current.IsPayedDescrption, current.Description, }) .ToList(); if (varList.Count == 0) { Infrastructure.MessageBox.Show ( caption: Infrastructure.MessageBox.Caption.Error, text: "اطلاعاتی برای ارسال توسط پست الکترونیکی موجود نمیباشد. " ); return; } Stimulsoft.Report.StiReport oStiReport = new Stimulsoft.Report.StiReport(); oStiReport.Load(Properties.Resources.MembersLoansListReport); oStiReport.Dictionary.Variables.Add("Today", System.DateTime.Now.ToPersianDate()); oStiReport.Dictionary.Variables.Add("FundName", Utility.CurrentFund.Name); oStiReport.Dictionary.Variables.Add("FundManagerName", Utility.CurrentFund.ManagerName); oStiReport.Dictionary.Variables.Add("MemberName", Utility.CurrentMember.FullName.ToString()); oStiReport.Dictionary.Variables.Add("LoanStatus", LoanStatusComboBox.Text); oStiReport.RegBusinessObject("Loans", varList); oStiReport.Compile(); oStiReport.RenderWithWpf(); string fileName = string.Format("گزارش {0} {1}", LoanStatusComboBox.Text, Utility.CurrentMember.FullName.ToString()); System.IO.MemoryStream oMemoryStream = new System.IO.MemoryStream(); oStiReport.ExportDocument(Stimulsoft.Report.StiExportFormat.Pdf, oMemoryStream); oMemoryStream.Seek(0, System.IO.SeekOrigin.Begin); Utility.SendEmail ( senderEmail: Utility.CurrentUser.EmailAddress, senderPassword: oEnterEmailPasswordWindow.EmailPassword, displayName: Utility.CurrentUser.FullName.ToString(), receiverEmail: Utility.CurrentMember.EmailAddress, subject: Utility.CurrentFund.Name + " | " + LoanStatusComboBox.Text + " " + Utility.CurrentMember.FullName.ToString(), body: LoanStatusComboBox.Text + Utility.CurrentMember.FullName.ToString() + System.Environment.NewLine + new FarsiLibrary.Utils.PersianDate(System.DateTime.Now).ToString(), attachment: oMemoryStream, attachmentName: fileName ); }); }
private void OEmailBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { this.Dispatcher.Invoke(() => { DAL.UnitOfWork oUnitOfWork = new DAL.UnitOfWork(); if (SendEmailToggleSwitch.IsChecked == true && IsConnectedToInternet == true) { EnterEmailPasswordWindow oEnterEmailPasswordWindow = new EnterEmailPasswordWindow(); if (oEnterEmailPasswordWindow.ShowDialog() == true) { var varList = oUnitOfWork.InstallmentRepository .Get() .Where(current => current.LoanId == Utility.CurrentLoan.Id) .Select(current => new ViewModels.InstallmentViewModel() { Id = current.Id, Amount = current.PaymentAmount, InstallmentDate = current.InstallmentDate, PaymentDate = current.PaymentDate, IsActive = !(current.IsPayed), IsPayed = current.IsPayed, }) .OrderBy(current => current.InstallmentDate) .ToList() .Select(current => new { current.AmountRialFormat, current.PersianInstallmentDate, current.PersianPaymentDate, current.IsPayedDescription, }) .ToList(); Stimulsoft.Report.StiReport oStiReport = new Stimulsoft.Report.StiReport(); oStiReport.Load(Properties.Resources.InstallmentListReport); oStiReport.Dictionary.Variables.Add("Today", System.DateTime.Now.ToPersianDate()); oStiReport.Dictionary.Variables.Add("FundName", Utility.CurrentFund.Name); oStiReport.Dictionary.Variables.Add("FundManagerName", Utility.CurrentFund.ManagerName); oStiReport.Dictionary.Variables.Add("MemberName", Utility.CurrentMember.FullName.ToString()); oStiReport.Dictionary.Variables.Add("LoanAmount", (new ViewModels.LoanViewModel { LoanAmount = Utility.CurrentLoan.LoanAmount }).LoanAmountRialFormat); oStiReport.Dictionary.Variables.Add("RefundAmount", (new ViewModels.LoanViewModel { RefundAmount = Utility.CurrentLoan.RefundAmount }).RefundAmountRialFormat); oStiReport.RegBusinessObject("InstallmentsList", varList); oStiReport.Compile(); oStiReport.RenderWithWpf(); System.IO.MemoryStream oMemoryStream = new System.IO.MemoryStream(); oStiReport.ExportDocument(Stimulsoft.Report.StiExportFormat.Pdf, oMemoryStream); oMemoryStream.Seek(0, System.IO.SeekOrigin.Begin); Utility.SendEmail ( senderEmail: Utility.CurrentUser.EmailAddress, senderPassword: oEnterEmailPasswordWindow.EmailPassword, displayName: Utility.CurrentUser.FullName.ToString(), receiverEmail: Utility.CurrentMember.EmailAddress, subject: Utility.CurrentFund.Name + " | " + "پرداخت وام" + Utility.CurrentMember.FullName.ToString(), body: "لیست اقساط وام پرداخت شده توسط صندوق به " + Utility.CurrentMember.FullName.ToString() + System.Environment.NewLine + new FarsiLibrary.Utils.PersianDate(System.DateTime.Now).ToString(), attachment: oMemoryStream, attachmentName: "لیست اقساط وام پرداخت شده" ); } else { Utility.MainWindow.MainProgressBar.IsIndeterminate = false; Utility.MainWindow.MainProgressBar.Visibility = System.Windows.Visibility.Hidden; } } else { Utility.MainWindow.MainProgressBar.IsIndeterminate = false; Utility.MainWindow.MainProgressBar.Visibility = System.Windows.Visibility.Hidden; } }); }