You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/Mobile/DAL/TemplateMessage/TemplateMessageModelConvert...

117 lines
4.5 KiB
C#

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
{
/// <summary>
/// 生成消息模板模型
/// </summary>
/// <param name="tempid">
/// 0:付费申请
/// 1:应收应付审批
/// </param>
/// <param name="bsno">[WorkFlow_Using].BSNO业务编号</param>
/// <returns></returns>
public static List<TMBase> CreateModel ( int tempid, string bsno )
{
if (tempid == 0)
{
return FFSPDo(bsno);
}
else
{
return null;
}
}
/// <summary>
/// 付费审批模板消息生成
/// </summary>
/// <param name="bsno">[WorkFlow_Using].BSNO业务编号</param>
/// <returns></returns>
private static List<TMBase> FFSPDo (string bsno) {
List<TMBase> list = new List<TMBase>();
string creator = "";
string createtime = "";
string customername = "";
try
{
//获取当前流程信息
List<FlowMapModel> mapdata = FlowMapDal.GetMap(bsno);
if (mapdata.Count > 0)
{
creator = mapdata[0].Acts[0].Oper;
createtime = mapdata[0].CreateTime;
}
//获取审批人的UserID
List<string> listUid = new List<string>();
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;
}
}
}