259 lines
10 KiB
C#
259 lines
10 KiB
C#
using CRM.Core.DTO;
|
|
using Newtonsoft.Json;
|
|
using Ninject;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using WX.CRM.BLL.Util;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.Common.Layui;
|
|
using WX.CRM.IBLL.MsgTool;
|
|
using WX.CRM.IBLL.Ww;
|
|
using WX.CRM.WebHelper;
|
|
|
|
namespace WX.CRM.WEB.Controllers.MsgTool
|
|
{
|
|
public class MsgToolPlanController : BaseController
|
|
{
|
|
|
|
[Inject]
|
|
public IMsgToolPlan _msgToolQ { get; set; }
|
|
[Inject]
|
|
public IWw_huser _iww_hhuser_service { get; set; }
|
|
CACHE_BL _cache = new CACHE_BL();
|
|
public MsgToolPlanController()
|
|
{
|
|
|
|
}
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_群发计划列表)]
|
|
public ActionResult Index(int indexType = 1)
|
|
{
|
|
//ToolBar
|
|
ToolBar tool = new ToolBar();
|
|
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.群发计划列表, userRightId);
|
|
tool.AllowButton(toolbtn);
|
|
tool.AddOtherButton("Other1", "复制群发计划", "icon-detail", "Copy_Click", true);
|
|
tool.AddOtherButton("Other2", "取消分发", "icon-group", "Cancel_Click", true);
|
|
tool.AddOtherButton("Other3", "分发任务", "icon-search", "Send_Click", true);
|
|
ViewBag.ToolBar = tool;
|
|
ViewBag.IndexType = indexType;
|
|
var faceList = _cache.GetValue_Parameter("FaceSetting");
|
|
if (!string.IsNullOrWhiteSpace(faceList))
|
|
{
|
|
ViewBag.faceList = JsonConvert.DeserializeObject<List<string>>(faceList);
|
|
ViewBag.faceListJson = string.Join(",", ViewBag.faceList);
|
|
}
|
|
return View();
|
|
}
|
|
[HttpPost]
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_群发计划列表)]
|
|
public JsonResult GetHtmlList(Laypage pager, MsgToolPlanQueryDto dto)
|
|
{
|
|
var layUidata = new LayuiData<MsgToolPlanRepeatViewModel>();
|
|
try
|
|
{
|
|
List<MsgToolPlanRepeatViewModel> list = _msgToolQ.GetPlanList(ref pager, dto);
|
|
|
|
layUidata.msg = "数据加载成功";
|
|
layUidata.code = 0;
|
|
layUidata.data = list;
|
|
layUidata.count = pager.count;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex.ToString());
|
|
layUidata.SetFail(1, "出现错误!" + ex.Message);
|
|
}
|
|
return Json(layUidata);
|
|
}
|
|
public ActionResult MsgToolPlanTab()
|
|
{
|
|
|
|
return View();
|
|
}
|
|
[HttpPost]
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_群发计划列表)]
|
|
public JsonResult GetRepeatIndexHtmlList(Laypage pager, MsgToolPlanQueryDto dto)
|
|
{
|
|
var layUidata = new LayuiData<MsgToolPlanRepeatViewModel>();
|
|
try
|
|
{
|
|
List<MsgToolPlanRepeatViewModel> list = _msgToolQ.GetPlanList(ref pager, dto);
|
|
|
|
layUidata.msg = "数据加载成功";
|
|
layUidata.code = 0;
|
|
layUidata.data = list;
|
|
layUidata.count = pager.count;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex.ToString());
|
|
layUidata.SetFail(1, "出现错误!" + ex.Message);
|
|
}
|
|
return Json(layUidata);
|
|
}
|
|
[HttpGet]
|
|
[AuthorizeToolBar(InitRights.CONST_群发计划列表, InitToolBar.CONST_Add)]
|
|
public ActionResult Add(decimal? id)
|
|
{
|
|
var croplist = _iww_hhuser_service.Corp_GetByCompanyCode(companyCode);
|
|
ViewBag.AllChannel = JsonHelper.ObjDivertToJson(croplist);
|
|
MsgEditModel model = new MsgEditModel();
|
|
if (id.HasValue)
|
|
{
|
|
ViewBag.id = id;
|
|
model = _msgToolQ.GetMsgPlanEditModel(id.Value);
|
|
}
|
|
//生成临时接口请求键
|
|
var help = new AliHelper("LTAI5tERfeaQymj1CD7eycnw", "WScg5brbLlKWJvfRofCGnjso6Wi0Rx", "2015-04-01");
|
|
Dictionary<string, object> ditParam = new Dictionary<string, object>();
|
|
ditParam.Add("Action", "AssumeRole");
|
|
ditParam.Add("DurationSeconds", 3600);
|
|
ditParam.Add("RoleArn", "acs:ram::1497042271361001:role/oss-cms");
|
|
ditParam.Add("RoleSessionName", "test");
|
|
var res = help.HttpGetUrl("https://sts.aliyuncs.com/", ditParam);
|
|
|
|
Credentials credentials = new Credentials();
|
|
if (res.IndexOf("Credentials") > -1)
|
|
{
|
|
credentials = JsonHelper.JsonDivertToObj<Credentials>(res.Substring(res.IndexOf("Credentials") + 13).Replace("}}", "}"));
|
|
}
|
|
ViewBag.OssModel = credentials;
|
|
ViewBag.File_Server = _cache.GetValue_Parameter("File_Server");
|
|
var faceList = _cache.GetValue_Parameter("FaceSetting");
|
|
if (!string.IsNullOrWhiteSpace(faceList))
|
|
{
|
|
ViewBag.faceList = JsonConvert.DeserializeObject<List<string>>(faceList);
|
|
ViewBag.faceListJson = string.Join(",", ViewBag.faceList);
|
|
}
|
|
return View(model);
|
|
}
|
|
|
|
[HttpPost]
|
|
[AuthorizeToolBar(InitRights.CONST_群发计划列表, InitToolBar.CONST_Add)]
|
|
public JsonResult Add(MsgToolPlanCreateDto model)
|
|
{
|
|
try
|
|
{
|
|
model.Eid = Eid;
|
|
model.JSONDATA = model.JSONDATA.Replace("\u200c", "");
|
|
bool result = _msgToolQ.AddMsgPlan(model);
|
|
retMsg ret = new retMsg() { result = result, retcode = 200, retmsg = "保存成功!" };
|
|
return Json(ret);
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
retMsg ret = new retMsg() { result = false, retcode = 200, retmsg = "设置失败:"+ex.Message };
|
|
return Json(ret);
|
|
}
|
|
}
|
|
[HttpGet]
|
|
[AuthorizeToolBar(InitRights.CONST_群发计划列表, InitToolBar.CONST_Add)]
|
|
public ActionResult ChoosePeople(string data)
|
|
{
|
|
ViewBag.Data = data;
|
|
return View();
|
|
}
|
|
[HttpGet]
|
|
public ActionResult UserGroup(string data)
|
|
{
|
|
ViewBag.Data = data;
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
[AuthorizeToolBar(InitRights.CONST_群发计划列表, InitToolBar.CONST_Add)]
|
|
public JsonResult ConfirmSend(MsgToolPlanCreateDto model)
|
|
{
|
|
try
|
|
{
|
|
model.Eid = Eid;
|
|
model.Type = 2;
|
|
bool result = _msgToolQ.AddMsgPlan(model);
|
|
retMsg ret = new retMsg() { result = result, retcode = 200, retmsg = "确认分发成功!" };
|
|
return Json(ret);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
retMsg ret = new retMsg() { result = false, retcode = 200, retmsg = "确认分发失败:" + ex.Message };
|
|
return Json(ret);
|
|
}
|
|
}
|
|
[HttpGet]
|
|
[AuthorizeToolBar(InitRights.CONST_群发计划列表, InitToolBar.CONST_Add)]
|
|
public ActionResult CopyPlan(decimal? id)
|
|
{
|
|
var croplist = _iww_hhuser_service.Corp_GetByCompanyCode(companyCode);
|
|
ViewBag.AllChannel = JsonHelper.ObjDivertToJson(croplist);
|
|
MsgEditModel model = new MsgEditModel();
|
|
if (id.HasValue)
|
|
{
|
|
ViewBag.id = id;
|
|
model = _msgToolQ.GetMsgPlanEditModel(id.Value);
|
|
model.PKID = null;
|
|
}
|
|
ViewBag.File_Server = _cache.GetValue_Parameter("File_Server");
|
|
var faceList = _cache.GetValue_Parameter("FaceSetting");
|
|
//生成临时接口请求键
|
|
var help = new AliHelper("LTAI5tERfeaQymj1CD7eycnw", "WScg5brbLlKWJvfRofCGnjso6Wi0Rx", "2015-04-01");
|
|
Dictionary<string, object> ditParam = new Dictionary<string, object>();
|
|
ditParam.Add("Action", "AssumeRole");
|
|
ditParam.Add("DurationSeconds", 3600);
|
|
ditParam.Add("RoleArn", "acs:ram::1497042271361001:role/oss-cms");
|
|
ditParam.Add("RoleSessionName", "test");
|
|
var res = help.HttpGetUrl("https://sts.aliyuncs.com/", ditParam);
|
|
Credentials credentials = new Credentials();
|
|
if (res.IndexOf("Credentials") > -1)
|
|
{
|
|
credentials = JsonHelper.JsonDivertToObj<Credentials>(res.Substring(res.IndexOf("Credentials") + 13).Replace("}}", "}"));
|
|
}
|
|
ViewBag.OssModel = credentials;
|
|
if (!string.IsNullOrWhiteSpace(faceList))
|
|
{
|
|
ViewBag.faceList = JsonConvert.DeserializeObject<List<string>>(faceList);
|
|
ViewBag.faceListJson = string.Join(",", ViewBag.faceList);
|
|
}
|
|
return View("add",model);
|
|
}
|
|
[HttpPost]
|
|
[AuthorizeToolBar(InitRights.CONST_群发计划列表, InitToolBar.CONST_Other3)]
|
|
public JsonResult CreateTask(decimal planId)
|
|
{
|
|
try
|
|
{
|
|
bool result = _msgToolQ.CreateTask(planId);
|
|
retMsg ret = new retMsg() { result = result, retcode = 200, retmsg = "操作成功!" };
|
|
return Json(ret);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
retMsg ret = new retMsg() { result = false, retcode = 200, retmsg = "操作失败:" + ex.Message };
|
|
return Json(ret);
|
|
}
|
|
}
|
|
[HttpPost]
|
|
[AuthorizeToolBar(InitRights.CONST_群发计划列表, InitToolBar.CONST_Other2)]
|
|
public JsonResult CancelTask(decimal planId)
|
|
{
|
|
try
|
|
{
|
|
bool result = _msgToolQ.CancelTask(planId);
|
|
retMsg ret = new retMsg() { result = result, retcode = 200, retmsg = "操作成功!" };
|
|
return Json(ret);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
retMsg ret = new retMsg() { result = false, retcode = 200, retmsg = "操作失败:" + ex.Message };
|
|
return Json(ret);
|
|
}
|
|
}
|
|
public JsonResult GetGroupList()
|
|
{
|
|
var objjson = _msgToolQ.GetGroupList(Eid);
|
|
return Json(objjson, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
}
|
|
} |