using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data.SqlClient; using System.Data; using Microsoft.Practices.EnterpriseLibrary.Data; using DSWeb.Areas.Mobile.Models.Login; using DSWeb.TruckMng.Helper; using DSWeb.Areas.Mobile.Models; using DSWeb.Areas.Mobile.Models.TemplateMessage; using DSWeb.Areas.Account.Models.Chfee_payapplication; using DSWeb.Areas.Account.DAL.Chfee_payapplication; using System.Configuration; namespace DSWeb.Areas.Mobile.DAL.TemplateMessage { public class TemplateMessageModelConverter { /// /// 生成消息模板模型 /// /// /// 0:付费申请 /// 1:应收应付审批 /// /// [WorkFlow_Using].BSNO业务编号 /// public static List CreateModel ( int tempid, string bsno ) { if (tempid == 0) { return FFSPDo(bsno); } else { return null; } } /// /// 付费审批模板消息生成 /// /// [WorkFlow_Using].BSNO业务编号 /// private static List FFSPDo (string bsno) { List list = new List(); string creator = ""; string createtime = ""; string customername = ""; try { //获取当前流程信息 List mapdata = FlowMapDal.GetMap(bsno); if (mapdata.Count > 0) { creator = mapdata[0].Acts[0].Oper; createtime = mapdata[0].CreateTime; } //获取审批人的UserID List listUid = new List(); DBLog.Log("FFSPDo", "0"); foreach (FlowMapModel flow in mapdata) { foreach (FlowMapActionModel fa in flow.Acts) { if (fa.IsCurr == 1 && fa.UserID != "" && fa.OperOpenId != "") { //需要发送用户的openid集合 listUid.Add(fa.OperOpenId); } } } //获取客户信息 string sql = "select top 1 CUSTOMERNAME from ch_fee_payapplication where billno='" + bsno + "'"; Database db = DatabaseFactory.CreateDatabase(); var customer = db.ExecuteScalar(CommandType.Text, sql); if (customer != null && customer != DBNull.Value && customer.ToString() != "") { customername = customer.ToString(); } DBLog.Log("FFSPDo","1"); TMDataFFSPDoModel FFSPData = new TMDataFFSPDoModel(); FFSPData.first = new TMValue { value = "新流程需要审核", color = "#000000" }; FFSPData.keyword1 = new TMValue { value = "付费申请【" + bsno + "】", color = "#000000" }; FFSPData.keyword2 = new TMValue { value = creator, color = "#000000" }; FFSPData.keyword3 = new TMValue { value = createtime, color = "#000000" }; FFSPData.keyword4 = new TMValue { value = "客户信息:[" + customername + "]", color = "#000000" }; FFSPData.remark = new TMValue { value = "点击进行审批", color = "#000000" }; string template_id = ConfigurationManager.AppSettings["TMFFSPID"].ToString(); DBLog.Log("FFSPDo", "2"); foreach (var u in listUid) { TMBase tm = new TMBase(); tm.data = FFSPData; tm.template_id = template_id; tm.touser = u; string domain = ConfigurationManager.AppSettings["Domain"].ToString(); string url = domain + "/Mobile/Approval/FFSPDetails?billno=" + bsno+"&openid="+u; tm.url = url; DBLog.Log("生成模板消息URL",tm.url); list.Add(tm); } } catch (Exception ex) { DBLog.Log("FFSPDo","ERROR",ex.Message); throw ex; } return list; } } }