コード例 #1
0
        private void SendEmailButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            bool internetConnected = Utility.CheckForInternetConnection();

            if (internetConnected == true)
            {
                EnterEmailPasswordWindow oEnterEmailPasswordWindow = new EnterEmailPasswordWindow();

                if (oEnterEmailPasswordWindow.ShowDialog() == true)
                {
                    Utility.MainWindow.MainProgressBar.IsIndeterminate = true;
                    Utility.MainWindow.MainProgressBar.Visibility      = System.Windows.Visibility.Visible;

                    System.ComponentModel.BackgroundWorker oBackgroundWorker = new System.ComponentModel.BackgroundWorker();

                    oBackgroundWorker.DoWork += OBackgroundWorker_DoWork;
                    oBackgroundWorker.RunWorkerAsync(oEnterEmailPasswordWindow);
                }
                else
                {
                    Utility.MainWindow.MainProgressBar.IsIndeterminate = false;
                    Utility.MainWindow.MainProgressBar.Visibility      = System.Windows.Visibility.Hidden;

                    return;
                }
            }
            else
            {
                Utility.MainWindow.MainProgressBar.IsIndeterminate = false;
                Utility.MainWindow.MainProgressBar.Visibility      = System.Windows.Visibility.Hidden;

                Infrastructure.MessageBox.Show
                (
                    caption: Infrastructure.MessageBox.Caption.Error,
                    text: "اتصال به اینترنت برقرار نمی‌باشد. از اتصال دستگاه خود با اینترنت اطمینان حاصل فرمایید."
                );

                return;
            }
        }
コード例 #2
0
        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;
                }
            });
        }