예제 #1
0
 /// 发送邮件给接收人和抄送人
 /// <summary>
 /// 发送邮件给接收人和抄送人
 /// </summary>
 /// <param name="jsondata"></param>
 /// <param name="sysinfo"></param>
 /// <param name="worderinfo"></param>
 public void SendEMail(WOrderProcessJsonData jsondata, SysRightUserInfo sysinfo, WOrderInfoInfo worderinfo)
 {
     try
     {
         //状态校验
         WorkOrderStatus status = (WorkOrderStatus)worderinfo.WorkOrderStatus_Value;
         if (status == WorkOrderStatus.Pending || status == WorkOrderStatus.Processing || status == WorkOrderStatus.Untreated)
         {
             //查询邮件地址
             string[] ccUserID = jsondata.Recevicer.Select(x => x.UserID_Out.ToString()).ToArray();
             string[] toUserID = jsondata.ExtendRecev.Select(x => x.UserID_Out.ToString()).ToArray();
             List <SysRightUserInfo> cc_sysinfos = BLL.EmployeeSuper.Instance.GetSysRightUserInfo(string.Join(",", ccUserID));
             List <SysRightUserInfo> to_sysinfos = BLL.EmployeeSuper.Instance.GetSysRightUserInfo(string.Join(",", toUserID));
             //邮箱
             string[] cc_email = cc_sysinfos.Where(x => !string.IsNullOrEmpty(x.Email)).Select(x => x.Email).ToArray();
             string[] to_email = to_sysinfos.Where(x => !string.IsNullOrEmpty(x.Email)).Select(x => x.Email).ToArray();
             //查询个人用户信息
             CustTypeEnum ctype = CustTypeEnum.T01_个人;
             DataTable    dt    = BLL.WOrderInfo.Instance.GetCBInfoByPhone(worderinfo.CBID_Value, "");
             if (dt != null && dt.Rows.Count > 0)
             {
                 ctype = (CustTypeEnum)CommonFunction.ObjectToInteger(dt.Rows[0]["CustCategoryID"]);
             }
             //获取工单类型
             WOrderCategoryEnum wtype = (WOrderCategoryEnum)worderinfo.CategoryID_Value;
             //测试数据
             //cc_email = new string[] { "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" };
             //to_email = new string[] { "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" };
             //邮件正文1
             string body1 = "你有一张<strong style='color:red;'>" + BLL.Util.GetEnumOptText(typeof(CustTypeEnum), (int)ctype) +
                            BLL.Util.GetEnumOptText(typeof(WOrderCategoryEnum), (int)wtype) + "</strong>工单!";
             //邮件正文2
             string body2 = worderinfo.Content_Value;
             //cc系统地址
             string weburl = BitAuto.Utils.Config.ConfigurationUtil.GetAppSettingValue("ExitAddress");
             //发邮件
             if (cc_email.Length > 0)
             {
                 WOrderInfo.LogToLog4("工单处理发送邮件:接收人" + string.Join(";", cc_email));
                 string title = "您有一张工单[" + worderinfo.OrderID_Value + "]待处理";
                 string a     = "<a href='" + weburl + "/WOrderV2/WOrderProcess.aspx?OrderID=" + worderinfo.OrderID_Value + "'>工单处理</a>";
                 EmailHelper.Instance.SendMail(title, cc_email, new string[] { body1, body2, a }, "WOrderV2");
             }
             if (to_email.Length > 0)
             {
                 WOrderInfo.LogToLog4("工单处理发送邮件:抄送人" + string.Join(";", to_email));
                 string title = "您有一张工单[" + worderinfo.OrderID_Value + "]待查看";
                 string a     = "<a href='" + weburl + "/WOrderV2/WorkOrderView.aspx?OrderID=" + worderinfo.OrderID_Value + "'>工单查看</a>";
                 EmailHelper.Instance.SendMail(title, to_email, new string[] { body1, body2, a }, "WOrderV2");
             }
         }
     }
     catch (Exception ex)
     {
         WOrderInfo.ErrorToLog4("工单处理发送邮件异常", ex);
     }
 }
 public bool Validate(out string msg)
 {
     if (!Common.Validate())
     {
         msg = Common.Message;
         return(false);
     }
     else if (!CustBaseInfo.Validate())
     {
         msg = CustBaseInfo.Message;
         return(false);
     }
     else if (!WOrderInfo.Validate())
     {
         msg = WOrderInfo.Message;
         return(false);
     }
     else
     {
         msg = "";
         return(true);
     }
 }