211 lines
8.2 KiB
C#
211 lines
8.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Mini.Common;
|
|
using Mini.Model.CrmModel;
|
|
using Mini.Model.ViewModel;
|
|
using Mini.Model.WxEntity;
|
|
using Mini.Services.wx;
|
|
using Mini.Web.WebHelper;
|
|
|
|
namespace Mini.Web.Areas.Admin.Controllers
|
|
{
|
|
public class WorkWeChatController : BaseController
|
|
{
|
|
|
|
private readonly Iwx_workwechat_Service _wxworkwechat_service;
|
|
private readonly Ibas_parameter_Service _bas_parameter_service;
|
|
public WorkWeChatController(Iwx_workwechat_Service wxworkwechat_service, Ibas_parameter_Service bas_parameter_service)
|
|
{
|
|
this._wxworkwechat_service = wxworkwechat_service;
|
|
this._bas_parameter_service = bas_parameter_service;
|
|
}
|
|
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_微信监控)]
|
|
[Area("Admin")]
|
|
public IActionResult Index(string weixincrmaccount)
|
|
{
|
|
ViewBag.weixincrmaccount = weixincrmaccount;
|
|
//ToolBar
|
|
ToolBar tool = new ToolBar();
|
|
string[] toolbtn;
|
|
if (!string.IsNullOrEmpty(weixincrmaccount) && userRightId.Contains("-1"))
|
|
{
|
|
toolbtn = new string[] { "Other1", "Other2", "Other3" };
|
|
}
|
|
else
|
|
{
|
|
toolbtn = new ToolButtonView().ToolButtonRight(InitRights.微信监控, userRightId);
|
|
}
|
|
|
|
tool.AllowButton(toolbtn);
|
|
tool.AddOtherButton("Other1", "聊天记录", "", "", true);
|
|
tool.AddOtherButton("Other2", "微信好友", "", "", true);
|
|
tool.AddOtherButton("Other3", "微信红包", "", "", true);
|
|
ViewBag.ToolBar = tool;
|
|
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Area("Admin")]
|
|
//[AuthorizeRedirect(Roles = InitRights.CONST_微信监控)]
|
|
|
|
public JsonResult GetWeWorktHtmlList(Laypage pager, string name)
|
|
{
|
|
|
|
var layUidata = new LayuiData<Wx_WorkAccountModel>();
|
|
try
|
|
{
|
|
List<Wx_WorkAccountModel> list = _wxworkwechat_service.WorList_Get(ref pager, name);
|
|
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);
|
|
}
|
|
//[AuthorizeToolBar(InitRights.CONST_微信监控, InitToolBar.CONST_Other1)]
|
|
[Area("Admin")]
|
|
public IActionResult MyMessage(string workusername, string column, string sort, string weixincrmaccount)
|
|
{
|
|
ViewBag.weixincrmaccount = weixincrmaccount;
|
|
List<WX_WorkRCONTACT> rcontactlist = new List<WX_WorkRCONTACT>();
|
|
string isShow = _bas_parameter_service.GetParameterValue("WeiXin_IsShowGroupMessage");//是否显示群信息
|
|
List<Wx_WorkGroupRcontact> grouplist = new List<Wx_WorkGroupRcontact>();
|
|
if (!string.IsNullOrEmpty(workusername))
|
|
rcontactlist = _wxworkwechat_service.GetRcontactByWorkAccount(workusername, column, sort);
|
|
if (isShow == "true")
|
|
{
|
|
grouplist = _wxworkwechat_service.GetGroupsByWorkAccount(workusername, column, sort);
|
|
}
|
|
Wx_WorkAccount workaccount = _wxworkwechat_service.GetWorAccount(workusername);
|
|
ViewBag.rcontactList = rcontactlist;
|
|
ViewBag.grouplist = grouplist;
|
|
ViewBag.isShowGroupMessage = isShow;
|
|
ViewBag.workAccountName = workaccount != null ? workaccount.nickname : "";
|
|
|
|
|
|
ViewBag.workusername = workusername;
|
|
ViewBag.column = column;
|
|
ViewBag.sort = sort;
|
|
return View();
|
|
}
|
|
//[AuthorizeToolBar(InitRights.CONST_微信监控, InitToolBar.CONST_Other1)]
|
|
[Area("Admin")]
|
|
public IActionResult MessageDetial(string workusername, string username, string nickname, string type, string weixincrmaccount)
|
|
{
|
|
ViewBag.weixincrmaccount = weixincrmaccount;
|
|
ViewBag.workusername = workusername;
|
|
ViewBag.username = username;
|
|
ViewBag.type = type;
|
|
|
|
Wx_WorkAccount workaccount = _wxworkwechat_service.GetWorAccount(workusername);
|
|
ViewBag.workAccountName = workaccount != null ? workaccount.nickname : "";
|
|
if (!string.IsNullOrEmpty(username) && !username.EndsWith("chatroom"))
|
|
{
|
|
Wx_Rcontact t = _wxworkwechat_service.GetRcontact(workusername, username);
|
|
ViewBag.nickname = WxMessageHandler.GetRcontactNickNameByRcontact(t).Replace("\r", "").Replace("\n", "");
|
|
}
|
|
else
|
|
{
|
|
ViewBag.nickname = nickname;
|
|
}
|
|
ViewBag.CoreInterfaceUrl = Utility.GetSettingByKey("NewCoreInterface");
|
|
return View();
|
|
}
|
|
[Area("Admin")]
|
|
//[AuthorizeToolBar(InitRights.CONST_微信监控, InitToolBar.CONST_Other1)]
|
|
public JsonResult GetGroupNumber(string chatroom)
|
|
{
|
|
DataTable tab = _wxworkwechat_service.GetGroupNumber(chatroom);
|
|
var json = new List<object>();
|
|
if (tab != null)
|
|
foreach (DataRow item in tab.Rows)
|
|
{
|
|
json.Add(new { username = item["username"].ToString(), nickname = item["nickname"].ToString() });
|
|
}
|
|
return Json(json);
|
|
}
|
|
public string GeJsontPath(string url)
|
|
{
|
|
string wocha = Utility.GetData(url, "", Encoding.UTF8);
|
|
return wocha;
|
|
}
|
|
|
|
|
|
[Area("Admin")]
|
|
//[AuthorizeToolBar(InitRights.CONST_微信监控, InitToolBar.CONST_Other2)]
|
|
public ActionResult WorRcontact(string jobWxUserName, string weixincrmaccount)
|
|
{
|
|
ViewBag.weixincrmaccount = weixincrmaccount;
|
|
ViewBag.jobWxUserName = jobWxUserName;
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Area("Admin")]
|
|
//[AuthorizeToolBar(InitRights.CONST_企业微信监控, InitToolBar.CONST_Other2)]
|
|
public JsonResult GetWorRcontact(Laypage pager, string jobWxUserName, string keyword, string stime, string etime)
|
|
{
|
|
|
|
var layUidata = new LayuiData<Wx_Rcontact_List>();
|
|
try
|
|
{
|
|
List<Wx_Rcontact_List> list = _wxworkwechat_service.GetRcontactList(ref pager, jobWxUserName, keyword, stime, etime);
|
|
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);
|
|
}
|
|
|
|
|
|
[Area("Admin")]
|
|
//[AuthorizeToolBar(InitRights.CONST_微信监控, InitToolBar.CONST_Other3)]
|
|
public ActionResult HongBao(string workusername, string weixincrmaccount)
|
|
{
|
|
ViewBag.weixincrmaccount = weixincrmaccount;
|
|
ViewBag.jobWxUserName = workusername;
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
[Area("Admin")]
|
|
//[AuthorizeToolBar(InitRights.CONST_企业微信监控, InitToolBar.CONST_Other3)]
|
|
public JsonResult GetHongBao(Laypage pager, string id, string jobWxUserName, DateTime? stime, DateTime? etime)
|
|
{
|
|
var layUidata = new LayuiData<Wx_HongBaoModel>();
|
|
try
|
|
{
|
|
List<Wx_HongBaoModel> list = _wxworkwechat_service.ShowWxHongBao(ref pager, id, jobWxUserName, stime, etime);
|
|
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);
|
|
}
|
|
|
|
}
|
|
} |