341 lines
12 KiB
C#
341 lines
12 KiB
C#
using Ninject;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.TS;
|
|
using WX.CRM.IBLL.Wx;
|
|
using WX.CRM.Model.Entity;
|
|
using WX.CRM.Model.MAP;
|
|
using WX.CRM.WebHelper;
|
|
|
|
namespace WX.CRM.WEB.Controllers.TS
|
|
{
|
|
public class MsgAssistantController : BaseController
|
|
{
|
|
[Inject]
|
|
public WX.CRM.IBLL.Util.ICACHE_Q cache_q { get; set; }
|
|
|
|
[Inject]
|
|
public IBLL.Wx.IWX_RCONTACT wx_Rcontack_BL { get; set; }
|
|
|
|
[Inject]
|
|
public IWX_TS_BATCHMSG wx_ts_batchmsg { get; set; }
|
|
[Inject]
|
|
public IWX_WORKACCOUNT wx_workaccount { get; set; }
|
|
//消息助手控制器
|
|
// GET: /MsgAssistant/
|
|
//
|
|
IWX_TSADDFRIEND wx_tsaddfriend;
|
|
public MsgAssistantController(IWX_TSADDFRIEND _wx_tsaddfriend)
|
|
{
|
|
this.wx_tsaddfriend = _wx_tsaddfriend;
|
|
}
|
|
|
|
public ActionResult Index()
|
|
{
|
|
|
|
Table tab2 = new Table("tablis1");
|
|
tab2.isCheckbox = true;
|
|
tab2.AddHiddenHeadCol("PKID", "pkid");
|
|
tab2.AddHeadCol("USERNAME", "", "微信用户名");
|
|
tab2.AddHeadCol("NICKNAME", "", "昵称");
|
|
tab2.AddHeadCol("CONREMARK", "", "备注");
|
|
tab2.AddHeadRow();
|
|
//添加分割线
|
|
tab2.AddTHeadAndTbodySplit();
|
|
|
|
ViewBag.gridTable2 = tab2.GetTable();
|
|
ViewBag.Eid = Eid;
|
|
|
|
|
|
|
|
DataTable table = wx_tsaddfriend.GetCanSendWorkAlias(UserId);
|
|
ViewBag.AliasTab = table;
|
|
return View();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 查询好友
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ActionResult ChooseRcontact()
|
|
{
|
|
|
|
string isShowAlias = cache_q.GetValue_Parameter("WeiXin_IsShowAlias");//是否显示微信号
|
|
ToolBar tool = new ToolBar();
|
|
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.工作微信好友关系, userRightId);
|
|
tool.AllowButton(toolbtn);
|
|
tool.AddOtherButton("Other1", "导出", "icon-export", "Export_Click", true);
|
|
ViewBag.ToolBar = tool;
|
|
//table
|
|
Pager pager = new Pager() { page = 1, rows = 6000, order = "", sort = "" };
|
|
string tableId = "tablist";
|
|
Table tab = new Table(tableId);
|
|
tab.isCheckbox = true;
|
|
tab.AddHiddenHeadCol("PKID", "编号");
|
|
tab.AddHeadCol("USERNAME", "15%", "微信用户名");
|
|
if (!string.IsNullOrEmpty(isShowAlias) && isShowAlias == "1")
|
|
{
|
|
tab.AddHeadCol("ALIAS", "", "微信号");
|
|
}
|
|
tab.AddHeadCol("NICKNAME", "20%", "昵称");
|
|
tab.AddHeadCol("CONREMARK", "", "通讯录", true);
|
|
//tab.AddHeadCol("RESID", "", "客户ID");
|
|
tab.AddHeadCol("CTIME", "20%", "创建时间", true);
|
|
tab.AddHeadCol("RTYPE", "10%", "类型", true);
|
|
tab.AddHeadRow();
|
|
ViewBag.gridTable = tab.GetHead() + Pagination.GetPage(pager, tableId, "6000");
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult GetChooseRcontactHtmlList(Pager pager, string jobWxUserName, string userName, string nickname, string alias, DateTime? stime, DateTime? etime, int ntype, string nofriend, string columns)
|
|
{
|
|
|
|
int isnofriend = 0;
|
|
if (!string.IsNullOrEmpty(nofriend))
|
|
{
|
|
isnofriend = Convert.ToInt32(nofriend.Replace(",", ""));
|
|
}
|
|
string isShowAlias = cache_q.GetValue_Parameter("WeiXin_IsShowAlias");//是否显示微信号
|
|
//List<WX_RCONTACT> list;
|
|
List<WX_WorkRCONTACT> rcontactlist = new List<WX_WorkRCONTACT>();
|
|
if (string.IsNullOrWhiteSpace(jobWxUserName)) //数据库存在工作微信为空的内容
|
|
{
|
|
rcontactlist = new List<WX_WorkRCONTACT>();
|
|
}
|
|
else
|
|
{
|
|
|
|
rcontactlist = wx_ts_batchmsg.GetRcontactByJobusername(jobWxUserName, userName, alias, nickname, stime, etime, ntype, isnofriend, pager.sort, pager.order);
|
|
//list = wx_Rcontack_BL.GetFilterList(ref pager, jobWxUserName, userName, alias, null, null, stime, etime);
|
|
}
|
|
Table table = new Table(columns, true);
|
|
table.gridPager = pager;
|
|
table.isCheckbox = true;
|
|
foreach (var model in rcontactlist)
|
|
{
|
|
table.AddHiddenCol(model.PKID);
|
|
table.AddCol(model.USERNAME);
|
|
if (!string.IsNullOrEmpty(isShowAlias) && isShowAlias == "1")
|
|
{
|
|
table.AddCol(model.ALIAS);
|
|
}
|
|
|
|
table.AddCol(model.NICKNAME);
|
|
table.AddCol("text-align:left", "", " " + model.CONREMARK);
|
|
table.AddCol(model.ctime);
|
|
table.AddCol(GetRcontactType(model.rtype));
|
|
table.AddRow();
|
|
}
|
|
pager.totalRows = rcontactlist.Count();
|
|
var json = new
|
|
{
|
|
totalPages = pager.totalPages,
|
|
totalRows = pager.totalRows,
|
|
rowsList = table.GetRows()
|
|
};
|
|
return Json(json, JsonRequestBehavior.AllowGet);
|
|
}
|
|
private string GetRcontactType(int type)
|
|
{
|
|
switch (type)
|
|
{
|
|
case 1: return "<font style='color:blue'>被加/推广</font>";
|
|
case 2: return "<font style='color:#65a74a'>我加/其他</font>";
|
|
case 3: return "<font style='color:#AAAAAA'>拉黑/删除</font>";
|
|
case 4: return "<font style='color:red'>未服务推广资源</font>";
|
|
case 5: return "<font style='color:#AAAAAA'>同事</font>";
|
|
default: return "<font style='color:#AAAAAA'>未知</font>";
|
|
}
|
|
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult SendMsg(Wx_Ts_BatchMsgSend model)
|
|
{
|
|
ValidationErrors errors = new ValidationErrors();
|
|
if (!ModelState.IsValid)
|
|
{
|
|
return JsonHandler.ValidateFailMessage();
|
|
}
|
|
if (string.IsNullOrEmpty(model.alias))
|
|
{
|
|
return JsonHandler.ManageMessage("请勾选要发送的微信号!", false);
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(model.rids))
|
|
{
|
|
return JsonHandler.ManageMessage("请添加好友!", false);
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(model.sendmsg))
|
|
{
|
|
return JsonHandler.ManageMessage("发送的内容不能为空", false);
|
|
}
|
|
|
|
model.timeType = 1;
|
|
model.exe_date = "";
|
|
model.exe_time = "";
|
|
bool result = wx_ts_batchmsg.CreateBatchPici(model.rids, model.alias, model.sendmsg, model.timeType, model.exe_date, model.exe_time, ref errors);
|
|
return JsonHandler.UpdateMessage(errors, result);
|
|
}
|
|
|
|
#region 加人日志列表--个人
|
|
public ActionResult TsLog()
|
|
{
|
|
//IBAS_COMPANY_Q doa = WebHelper.Infrastructure.NinjectControllerFactory.ninjectKernel.Get<IBAS_COMPANY_Q>();
|
|
//ToolBar
|
|
|
|
//table
|
|
Pager pager = new Pager() { page = 1, rows = 10 };
|
|
string tableId = "tablist";
|
|
Table tab = new Table(tableId);
|
|
tab.AddHeadCol("pici", "8%", "批次");
|
|
tab.AddHeadCol("alias", "8%", "微信号");
|
|
tab.AddHeadCol("validatemsg", "", "发送消息");
|
|
tab.AddHeadCol("rescount", "8%", "好友数");
|
|
tab.AddHeadCol("ctime", "8%", "创建时间");
|
|
tab.AddHeadCol("executetime", "8%", "执行时间");
|
|
tab.AddHeadCol("snedstuts", "8%", "推送状态");
|
|
tab.AddHeadCol("starttime", "8%", "实际执行时间");
|
|
tab.AddHeadCol("endtime", "8%", "实际结束时间");
|
|
tab.AddHeadCol("erromsg", "12%", "错误信息");
|
|
tab.AddHeadRow();
|
|
|
|
ViewBag.gridTable = tab.GetHead() + Pagination.GetPage(pager, tableId, "10,20,30");
|
|
List<WX_WORKACCOUNT> wock = wx_workaccount.GetMyWorkAccountList(UserId);
|
|
ViewBag.workAccount = wock;
|
|
return View();
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
/// <summary>
|
|
/// 按照条件获取数据
|
|
/// </summary>
|
|
/// <param name="pager"></param>
|
|
/// <param name="queryStr"></param>
|
|
/// <returns></returns>
|
|
public JsonResult TsLogGetHtmlList(Pager pager, string alias, string columns)
|
|
{
|
|
DataTable datable = wx_ts_batchmsg.BatchMsgLogReport(Eid, alias, ref pager);
|
|
Table table = new Table(columns, true);
|
|
table.gridPager = pager;
|
|
foreach (DataRow row in datable.Rows)
|
|
{
|
|
table.AddCol(row["pici"]);
|
|
table.AddCol(row["alias"]);
|
|
table.AddCol(string.Format("<font style='color:green;'>{0}</font>", row["validatemsg"]));
|
|
table.AddCol(row["rescount"]);
|
|
table.AddCol(row["ctime"]);
|
|
table.AddCol(row["executetime"]);
|
|
if (row["snedstuts"] != DBNull.Value)
|
|
{
|
|
table.AddCol(getSendStatus(Convert.ToInt32(row["snedstuts"])));
|
|
}
|
|
else
|
|
{
|
|
table.AddCol("其他");
|
|
}
|
|
table.AddCol(row["starttime"]);
|
|
table.AddCol(row["endtime"]);
|
|
string errMsg = string.Format("{0}", row["erromsg"]);
|
|
if (errMsg.IndexOf("\"ActionStatus\":\"OK\"") > -1)
|
|
table.AddCol("");
|
|
else
|
|
table.AddCol(string.Format("<font style='color:red;'>{0}</font>", row["erromsg"]));
|
|
|
|
|
|
table.AddRow();
|
|
}
|
|
|
|
var json = new
|
|
{
|
|
totalPages = pager.totalPages,
|
|
totalRows = pager.totalRows,
|
|
rowsList = table.GetRows()
|
|
};
|
|
return Json(json, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
public ActionResult TsLog_Detial()
|
|
{
|
|
|
|
//table
|
|
string tableId = "tablist";
|
|
Table tab = new Table(tableId);
|
|
tab.AddHeadCol("pici", "", "批次");
|
|
tab.AddHeadCol("username", "", "微信用户名");
|
|
tab.AddHeadCol("nickname", "", "昵称");
|
|
tab.AddHeadCol("remarks", "", "备注");
|
|
tab.AddHeadCol("state", "", "状态");
|
|
tab.AddHeadRow();
|
|
|
|
ViewBag.gridTable = tab.GetHead();
|
|
return View();
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
/// <summary>
|
|
/// 按照条件获取数据
|
|
/// </summary>
|
|
/// <param name="pager"></param>
|
|
/// <param name="queryStr"></param>
|
|
/// <returns></returns>
|
|
|
|
public JsonResult TsLog_DetialGetHtmlList(decimal pici, string key, string columns)
|
|
{
|
|
|
|
DataTable datable = wx_ts_batchmsg.LogReport_Detial(pici, key);
|
|
Table table = new Table(columns, true);
|
|
//table.gridPager = pager;
|
|
foreach (DataRow row in datable.Rows)
|
|
{
|
|
table.AddCol(row["pici"]);
|
|
table.AddCol(row["username"]);
|
|
table.AddCol(row["nickname"]);
|
|
table.AddCol(row["conremark"]);
|
|
int state = Convert.ToInt32(row["state"]);
|
|
table.AddCol(GetStateStr(state));
|
|
table.AddRow();
|
|
}
|
|
|
|
var json = new
|
|
{
|
|
rowsList = table.GetRows()
|
|
};
|
|
return Json(json, JsonRequestBehavior.AllowGet);
|
|
}
|
|
private string GetStateStr(int state)
|
|
{
|
|
switch (state)
|
|
{
|
|
case 0: return "<font style=\"color:#AAAAAA\">未执行</font>";
|
|
case 100: return "<font style=\"color:blue\">正常</font>";
|
|
case 404: return "<font style=\"color:red\">找不到</font>";
|
|
default: return "其他";
|
|
}
|
|
}
|
|
private string getSendStatus(int sendstatus)
|
|
{
|
|
switch (sendstatus)
|
|
{
|
|
case 0: return "<font style=\"color:#AAAAAA\">未推送</font>"; break;
|
|
case 1: return "<font style=\"color:blue\">发送成功</font>"; break;
|
|
case 2: return "<font style=\"color:red\">发送失败</font>"; break;
|
|
default: return "其他";
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
}
|
|
}
|