コード例 #1
0
        /// <summary>
        /// 发送订单拦截邮件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSendSOInterceptEmail_Click(object sender, RoutedEventArgs e)
        {
            SOInterceptInfoVM orderEmailInfoVM   = new SOInterceptInfoVM();
            SOInterceptInfoVM financeEmailInfoVM = new SOInterceptInfoVM();

            orderEmailInfoVM.EmailAddress            = this.txtEmailAddresse.Text;
            orderEmailInfoVM.CCEmailAddress          = this.txtCCEmailAddress.Text;
            financeEmailInfoVM.FinanceEmailAddress   = this.txtFinanceEmailAddress.Text;
            financeEmailInfoVM.FinanceCCEmailAddress = this.txtFinanceCCEmailAddress.Text;
            if (CurrentSOVM.InvoiceInfoVM.IsVAT == true)
            {
                if (string.IsNullOrEmpty(orderEmailInfoVM.EmailAddress) ||
                    string.IsNullOrEmpty(orderEmailInfoVM.CCEmailAddress) ||
                    string.IsNullOrEmpty(financeEmailInfoVM.FinanceEmailAddress) ||
                    string.IsNullOrEmpty(financeEmailInfoVM.FinanceCCEmailAddress)
                    )
                {
                    CPApplication.Current.CurrentPage.Context.Window.Alert(ResSOIntercept.Info_SaveSOIntercept_Input_Error, MessageType.Error);
                }
                else
                {
                    ValidationManager.Validate(this.gdOrderEmailInfo);
                    if (orderEmailInfoVM.HasValidationErrors && orderEmailInfoVM.ValidationErrors.Count > 0)
                    {
                        return;
                    }
                    ValidationManager.Validate(this.gdFinanceEmailInfo);
                    if (financeEmailInfoVM.HasValidationErrors && financeEmailInfoVM.ValidationErrors.Count > 0)
                    {
                        return;
                    }
                    SOInterceptInfoVM soInterceptInfoVM = new SOInterceptInfoVM();
                    soInterceptInfoVM.EmailAddress          = orderEmailInfoVM.EmailAddress;
                    soInterceptInfoVM.CCEmailAddress        = orderEmailInfoVM.CCEmailAddress;
                    soInterceptInfoVM.FinanceEmailAddress   = financeEmailInfoVM.FinanceEmailAddress;
                    soInterceptInfoVM.FinanceCCEmailAddress = financeEmailInfoVM.FinanceCCEmailAddress;

                    CurrentSOVM.SOInterceptInfoVMList.Add(soInterceptInfoVM);

                    #region 发送订单拦截邮件
                    SendEmailReq reqSOOrderIntercep = new SendEmailReq();
                    reqSOOrderIntercep.soInfo   = SOFacade.ConvertTOSOInfoFromSOVM(CurrentSOVM);
                    reqSOOrderIntercep.Language = CPApplication.Current.LanguageCode;
                    new SOInterceptFacade().SendSOOrderInterceptEmail(reqSOOrderIntercep, (obj, args) =>
                    {
                        if (!args.FaultsHandle())
                        {
                            CloseDialog(new ResultEventArgs
                            {
                                DialogResult = DialogResultType.OK,
                            });
                        }
                    });
                    #endregion
                    #region 发送增票拦截邮件
                    SendEmailReq reqSOFinanceIntercep = new SendEmailReq();
                    reqSOFinanceIntercep.soInfo   = SOFacade.ConvertTOSOInfoFromSOVM(CurrentSOVM);
                    reqSOFinanceIntercep.Language = CPApplication.Current.LanguageCode;
                    new SOInterceptFacade().SendSOFinanceInterceptEmail(reqSOFinanceIntercep, (obj, args) =>
                    {
                        if (!args.FaultsHandle())
                        {
                            CPApplication.Current.CurrentPage.Context.Window.Alert(ResSOIntercept.Info_SendEmail_Sucessful, MessageType.Information);
                            CloseDialog(new ResultEventArgs
                            {
                                DialogResult = DialogResultType.OK,
                            });
                        }
                    });
                    #endregion
                }
            }
            else
            {
                if (string.IsNullOrEmpty(orderEmailInfoVM.EmailAddress) || string.IsNullOrEmpty(orderEmailInfoVM.CCEmailAddress))
                {
                    CPApplication.Current.CurrentPage.Context.Window.Alert(ResSOIntercept.Info_SaveSOIntercept_Input_Error, MessageType.Error);
                }
                else
                {
                    ValidationManager.Validate(this.gdOrderEmailInfo);
                    if (orderEmailInfoVM.HasValidationErrors && orderEmailInfoVM.ValidationErrors.Count > 0)
                    {
                        return;
                    }
                    SOInterceptInfoVM soInterceptInfoVM = new SOInterceptInfoVM();
                    soInterceptInfoVM.EmailAddress   = orderEmailInfoVM.EmailAddress;
                    soInterceptInfoVM.CCEmailAddress = orderEmailInfoVM.CCEmailAddress;
                    CurrentSOVM.SOInterceptInfoVMList.Add(soInterceptInfoVM);
                    #region 发送订单拦截邮件
                    SendEmailReq reqSOOrderIntercep = new SendEmailReq();
                    reqSOOrderIntercep.soInfo   = SOFacade.ConvertTOSOInfoFromSOVM(CurrentSOVM);
                    reqSOOrderIntercep.Language = CPApplication.Current.LanguageCode;
                    new SOInterceptFacade().SendSOOrderInterceptEmail(reqSOOrderIntercep, (obj, args) =>
                    {
                        if (!args.FaultsHandle())
                        {
                            CPApplication.Current.CurrentPage.Context.Window.Alert(ResSOIntercept.Info_SendEmail_Sucessful, MessageType.Information);
                            CloseDialog(new ResultEventArgs
                            {
                                DialogResult = DialogResultType.OK,
                            });
                        }
                    });
                    #endregion
                }
            }
        }