Esempio n. 1
0
        public ActionResult UpdateRepEmail(ContactInfo _contact)
        {
            decimal _ck = -1;

            try
            {
                decimal _status = 1;
                if (_contact.FileBase_File_Url != null)
                {
                    _contact.URL = AppLoadHelpers.PushFileToServer(_contact.FileBase_File_Url, AppUpload.Search);
                }
                if (_contact.FileBase_File_Url02 != null)
                {
                    _contact.URL01 = AppLoadHelpers.PushFileToServer(_contact.FileBase_File_Url02, AppUpload.Search);
                }
                Contact_BL _bl = new Contact_BL();
                // update trạng thái phản hồi status = 1 và nội jdung phản hồi
                _ck = _bl.Contact_UpdateStatus(_contact.ID, _status, _contact.ReplyContent, _contact.ReplySubject, SessionData.CurrentUser.Username, _contact.URL, _contact.URL01);
                if (_ck > 0)
                {
                    string        _content       = _contact.ReplyContent.Replace("\n", "<br><br>");
                    List <string> _LstAttachment = new List <string>();
                    if (_contact.URL != null)
                    {
                        _LstAttachment.Add(System.Web.HttpContext.Current.Server.MapPath(_contact.URL));
                    }
                    if (_contact.URL01 != null)
                    {
                        _LstAttachment.Add(System.Web.HttpContext.Current.Server.MapPath(_contact.URL01));
                    }
                    string     content     = AppsCommon.SetContentMailTemplate(_content, yourref: "", outref: _contact.Case_Code, dearname: _contact.ContactName);
                    Email_Info _Email_Info = new Email_Info
                    {
                        EmailFrom     = EmailHelper.EmailOriginal.EMailFrom_Business,
                        Pass          = EmailHelper.EmailOriginal.PassWord_Business,
                        Display_Name  = EmailHelper.EmailOriginal.DisplayName_Business,
                        EmailTo       = _contact.Email,
                        EmailCC       = "",
                        Subject       = _contact.ReplySubject,
                        Content       = content,
                        LstAttachment = _LstAttachment,
                    };
                    CommonFunction.AppsCommon.EnqueueSendEmail(_Email_Info);
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
            return(Json(new { status = _ck }));
        }
Esempio n. 2
0
        public ActionResult do_SendEmail(Email_Info pInfo)
        {
            try
            {
                List <string> _LstAttachment = new List <string>();
                if (pInfo.File_Attach_1 != null)
                {
                    var _url_File_Attach_1 = AppLoadHelpers.PushFileToServer(pInfo.File_Attach_1, AppUpload.App);
                    _LstAttachment.Add(System.Web.HttpContext.Current.Server.MapPath(_url_File_Attach_1));
                }

                if (pInfo.File_Attach_2 != null)
                {
                    var _url_File_Attach_2 = AppLoadHelpers.PushFileToServer(pInfo.File_Attach_2, AppUpload.App);
                    _LstAttachment.Add(System.Web.HttpContext.Current.Server.MapPath(_url_File_Attach_2));
                }

                pInfo.LstAttachment = _LstAttachment;

                if (pInfo.EmailFrom == "*****@*****.**")
                {
                    pInfo.EmailFrom    = EmailHelper.EmailOriginal.EMailFrom_Business;
                    pInfo.Pass         = EmailHelper.EmailOriginal.PassWord_Business;
                    pInfo.Display_Name = EmailHelper.EmailOriginal.DisplayName_Business;
                }
                else
                {
                    pInfo.EmailFrom    = EmailHelper.EmailOriginal.EMailFrom;
                    pInfo.Pass         = EmailHelper.EmailOriginal.PassWord;
                    pInfo.Display_Name = EmailHelper.EmailOriginal.DisplayName;
                }

                string _content = pInfo.Content.Replace("<br />", "<br /><br />");  //.Replace("\n", "<br><br>");


                _content = AppsCommon.SetContentMailTemplate(_content, yourref: pInfo.Your_Ref, outref: pInfo.Out_Ref,
                                                             dearname: pInfo.Customer_Name, p_namereply: pInfo.Sign, p_position_name: pInfo.Position);
                pInfo.Content = _content;

                pInfo.Created_by = SessionData.CurrentUser.Username;
                CommonFunction.AppsCommon.EnqueueSendEmail(pInfo);

                return(Json(new { success = 1 }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { success = "-1" }));
            }
        }
Esempio n. 3
0
        public ActionResult DoAdminConfirm(string p_case_code, decimal p_status, string p_note)
        {
            try
            {
                SearchObject_BL _con = new SearchObject_BL();

                decimal _ck = _con.Admin_Update(p_case_code, p_status, p_note, AppsCommon.GetCurrentLang(), SessionData.CurrentUser.Username);

                // nếu thành công thì gửi email cho khách hàng
                if (_ck != -1 && p_status == (decimal)CommonSearch.Stt_DaPhanHoi)
                {
                    // lấy thông tin search
                    SearchObject_BL _searchBL = new SearchObject_BL();
                    List <SearchObject_Detail_Info> _ListDetail        = new List <SearchObject_Detail_Info>();
                    SearchObject_Question_Info      _QuestionInfo      = new SearchObject_Question_Info();
                    List <AppClassDetailInfo>       search_Class_Infos = new List <AppClassDetailInfo>();
                    SearchObject_Header_Info        _HeaderInfo        = _searchBL.SEARCH_HEADER_GETBY_CASECODE(p_case_code, ref _ListDetail, ref _QuestionInfo, ref search_Class_Infos);

                    // lấy thông tin người dùng
                    UserBL   _UserBL  = new UserBL();
                    UserInfo userInfo = _UserBL.GetUserByUsername(_HeaderInfo.CREATED_BY.Trim());

                    #region Bỏ đi vì đã có trong email

                    //string _fileTemp = System.Web.HttpContext.Current.Server.MapPath("/Content/Report/Search Report.doc");
                    //if (_HeaderInfo.Customer_Country != Common.Common.Country_VietNam_Id)
                    //    _fileTemp = System.Web.HttpContext.Current.Server.MapPath("/Content/Report/Search Report_En.doc");
                    //DocumentModel document = DocumentModel.Load(_fileTemp);

                    //// Fill export_header
                    //string fileName = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "Search_report" + p_case_code.ToString() + ".pdf");
                    //document.MailMerge.FieldMerging += (sender, e) =>
                    //{
                    //    if (e.IsValueFound)
                    //    {
                    //        if (e.FieldName == "Text")
                    //            ((Run)e.Inline).Text = e.Value.ToString();
                    //    }
                    //};

                    //string _search_type = "";
                    //if (_ListDetail.Count > 0)
                    //{
                    //    _search_type = _ListDetail[0].SEARCH_TYPE_NAME;
                    //}

                    //document.MailMerge.Execute(new { DateNo = DateTime.Now.ToString("dd-MM-yyyy") });
                    //document.MailMerge.Execute(new { Case_Name = _HeaderInfo.CASE_NAME });
                    //document.MailMerge.Execute(new { Client_Reference = _HeaderInfo.CLIENT_REFERENCE });
                    //document.MailMerge.Execute(new { Case_Code = _HeaderInfo.CASE_CODE });
                    //document.MailMerge.Execute(new { Applicant_Name = _HeaderInfo.Customer_Name });
                    //document.MailMerge.Execute(new { Customer_Country_Name = _HeaderInfo.Customer_Country_Name });
                    //document.MailMerge.Execute(new { Object = _HeaderInfo.Object_Search_Name });
                    //document.MailMerge.Execute(new { Result = _QuestionInfo.RESULT });
                    //document.MailMerge.Execute(new { Search_Type = _search_type });

                    //if (userInfo != null)
                    //{
                    //    document.MailMerge.Execute(new { Contact_Person = userInfo.Contact_Person });
                    //    document.MailMerge.Execute(new { Address = userInfo.Address });
                    //    document.MailMerge.Execute(new { FullName = userInfo.FullName });
                    //}
                    //else
                    //{
                    //    document.MailMerge.Execute(new { Contact_Person = "" });
                    //    document.MailMerge.Execute(new { Address = "" });
                    //    document.MailMerge.Execute(new { FullName = "" });
                    //}

                    //document.Save(fileName, SaveOptions.PdfDefault);
                    //byte[] fileContents;
                    //var options = SaveOptions.PdfDefault;
                    //// Save document to DOCX format in byte array.
                    //using (var stream = new MemoryStream())
                    //{
                    //    document.Save(stream, options);
                    //    fileContents = stream.ToArray();
                    //}
                    //Convert.ToBase64String(fileContents);
                    #endregion

                    string _emailTo = userInfo.Email;
                    string _emailCC = "";
                    //string _emailCC = userInfo.Copyto;
                    List <string> _LstAttachment = new List <string>();

                    //20190812 bỏ đi vì đã gửi trong email rồi
                    //_LstAttachment.Add(fileName);

                    if (_QuestionInfo.FILE_URL != null && _QuestionInfo.FILE_URL != "")
                    {
                        _LstAttachment.Add(System.Web.HttpContext.Current.Server.MapPath(_QuestionInfo.FILE_URL));
                    }

                    if (_QuestionInfo.FILE_URL02 != null && _QuestionInfo.FILE_URL02 != "")
                    {
                        _LstAttachment.Add(System.Web.HttpContext.Current.Server.MapPath(_QuestionInfo.FILE_URL02));
                    }

                    if (_HeaderInfo.Billing_Id > 0)
                    {
                        // lấy thông tin billing
                        Billing_BL          _Billing_BL          = new Billing_BL();
                        Billing_Header_Info _Billing_Header_Info = _Billing_BL.Billing_GetBy_Id(_HeaderInfo.Billing_Id, AppsCommon.GetCurrentLang());
                        if (_Billing_Header_Info.Billing_Id > 0 && _Billing_Header_Info.Status == (decimal)CommonEnums.Billing_Status.Approved)
                        {
                            //_LstAttachment.Add(System.Web.HttpContext.Current.Server.MapPath(_HeaderInfo.Url_Billing));

                            // kết xuất thông tin
                            string _mapPath_Report = Server.MapPath("~/Report/");
                            string _mapPath        = Server.MapPath("~/");

                            string _fileName = AppsCommon.Export_Billing_Crytal_View(_Billing_Header_Info.Case_Code, _mapPath_Report, _mapPath);
                            _LstAttachment.Add(System.Web.HttpContext.Current.Server.MapPath(_fileName));
                        }
                    }

                    string _content = _QuestionInfo.RESULT.Replace("\n", "<br><br>");
                    _content = AppsCommon.SetContentMailTemplate(_content, yourref: _QuestionInfo.CLIENT_REFERENCE, outref: p_case_code, dearname: userInfo.Username);

                    Email_Info _Email_Info = new Email_Info
                    {
                        EmailFrom     = EmailHelper.EmailOriginal.EMailFrom_Business,
                        Pass          = EmailHelper.EmailOriginal.PassWord_Business,
                        Display_Name  = EmailHelper.EmailOriginal.DisplayName_Business,
                        EmailTo       = _emailTo,
                        EmailCC       = _emailCC,
                        Subject       = "Search Report",
                        Content       = _content,
                        LstAttachment = _LstAttachment,
                    };

                    CommonFunction.AppsCommon.EnqueueSendEmail(_Email_Info);
                }

                return(Json(new { success = _ck }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { success = "-1" }));
            }
        }