コード例 #1
0
        public DocumentRecallMailDetail GetRecallMailDetail(Guid DocumentID, string documentTypeCode)
        {
            DocumentRecallMailDetail documentRecallMailDetail = new DocumentRecallMailDetail();

            try
            {
                using (SqlConnection con = _databaseFactory.GetDBConnection())
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        if (con.State == ConnectionState.Closed)
                        {
                            con.Open();
                        }
                        cmd.Connection  = con;
                        cmd.CommandText = "[PSA].[GetRecallMailDetail]";
                        cmd.Parameters.Add("@DocumentID", SqlDbType.UniqueIdentifier).Value = DocumentID;
                        cmd.Parameters.Add("@DocumentTypeCode", SqlDbType.VarChar, 5).Value = documentTypeCode;
                        cmd.CommandType = CommandType.StoredProcedure;
                        using (SqlDataReader sdr = cmd.ExecuteReader())
                        {
                            if ((sdr != null) && (sdr.HasRows))
                            {
                                if (sdr.Read())
                                {
                                    {
                                        documentRecallMailDetail.DocumentType  = (sdr["DocumentType"].ToString() != "" ? sdr["DocumentType"].ToString() : documentRecallMailDetail.DocumentType);
                                        documentRecallMailDetail.DocumentNo    = (sdr["DocumentNo"].ToString() != "" ? sdr["DocumentNo"].ToString() : documentRecallMailDetail.DocumentNo);
                                        documentRecallMailDetail.Approver      = (sdr["Approver"].ToString() != "" ? sdr["Approver"].ToString() : documentRecallMailDetail.Approver);
                                        documentRecallMailDetail.ApproverEmail = (sdr["ApproverEmail"].ToString() != "" ? sdr["ApproverEmail"].ToString() : documentRecallMailDetail.ApproverEmail);
                                        documentRecallMailDetail.DocumentOwner = (sdr["OwnerName"].ToString() != "" ? sdr["OwnerName"].ToString() : documentRecallMailDetail.DocumentOwner);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(documentRecallMailDetail);
        }
コード例 #2
0
        public async Task <bool> SendRecallMails(Guid documentID, string documentTypeCode)
        {
            try
            {
                DocumentRecallMailDetail documentRecallMailDetail = new DocumentRecallMailDetail();
                bool     sendsuccess = false;
                Settings settings    = new Settings();
                documentRecallMailDetail = _documentApprovalRepository.GetRecallMailDetail(documentID, documentTypeCode);
                string mailBody = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Content/MailTemplate/RecallDocument.html"));
                Mail   mail     = new Mail();
                string link     = WebConfigurationManager.AppSettings["AppURL"] + "/Content/images/Pilot1.png";
                mail.Body    = mailBody.Replace("$DocumentOwner$", documentRecallMailDetail.DocumentOwner).Replace("$Approver$", documentRecallMailDetail.Approver).Replace("$Document$", documentRecallMailDetail.DocumentType).Replace("$DocumentNo$", documentRecallMailDetail.DocumentNo).Replace("$DocumentDate$", _pSASysCommon.GetCurrentDateTime().ToString(settings.DateFormat)).Replace("$Logo$", link);
                mail.To      = documentRecallMailDetail.ApproverEmail;
                mail.Subject = "Document Recall";
                //mail.IsBodyHtml = true;
                sendsuccess = await _mailBusiness.MailSendAsync(mail);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }