using CRM.Core.DTO; using ICSharpCode.SharpZipLib.Zip; using Newtonsoft.Json; using Ninject; using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Text; using System.Web.Mvc; using WX.CRM.BLL.Base; using WX.CRM.BLL.Redis; using WX.CRM.Common; using WX.CRM.IBLL.Base; using WX.CRM.IBLL.Util; using WX.CRM.IBLL.Wx; using WX.CRM.Model.Entity; using WX.CRM.Model.MAP; using WX.CRM.WEB.Handler; using WX.CRM.WebHelper; namespace WX.CRM.WEB.Controllers.WeiXin { public class WorkAccountController : BaseController { ValidationErrors errors = new ValidationErrors(); [Inject] public IBAS_PARAMETER_Q bas_Parameter_Q_BL { get; set; } [Inject] public IWX_RCONTACT wx_Rcontact_BL { get; set; } [Inject] public ICACHE_Q cache_q { get; set; } [Inject] public IWX_GROUP wx_group_bl { get; set; } [Inject] public IWX_HONGBAO wx_hongbao { get; set; } [Inject] public IWX_EXCLUDEWEIXIN wx_ExcludeWeixin_BL { get; set; } private readonly IWX_LASTMSGTIME _lastmsgtime; private IWX_WORKACCOUNT wx_WorkAccount_BL { get; set; } private IWX_ALIVEIMEI wx_aliveimei { get; set; } [Inject] public IWX_GROUPPERCENT wx_GroupPercent_BL { get; set; } [Inject] public IWX_FAST_USERNAME _wx_fast_username { get; set; } public WorkAccountController(IWX_WORKACCOUNT wx_WorkAccount_BL, IWX_LASTMSGTIME lastmsgtime, IWX_ALIVEIMEI _wx_aliveimei) { _lastmsgtime = lastmsgtime; this.wx_WorkAccount_BL = wx_WorkAccount_BL; this.wx_aliveimei = _wx_aliveimei; } [AuthorizeRedirect(Roles = InitRights.CONST_我的工作微信)] public ActionResult Index() { ControlResource.JudgeSYQ(); //ToolBar ToolBar tool = new ToolBar(); string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.我的工作微信, userRightId); tool.AllowButton(toolbtn); tool.AddOtherButton("Other1", "微信资源详情", "icon-detail", "ResDetail_Click", true); tool.AddOtherButton("Other2", "聊天记录", "icon-detail", "ChatRecord_Click", true); tool.AddOtherButton("Other3", "微信好友", "icon-detail", "Rcontack_Click", true); ViewBag.ToolBar = tool; //table Pager pager = new Pager() { page = 1, rows = 20 }; string tableId = "tablist"; Table tab = new Table(tableId); tab.AddHiddenHeadCol("PKID", "编号"); tab.AddHeadCol("USERNAME", "16%", "微信用户名"); tab.AddHeadCol("ALIAS", "16%", "微信号"); tab.AddHeadCol("NICKNAME", "16%", "昵称"); tab.AddHeadCol("RESID", "16%", "客户ID"); tab.AddHeadCol("CONREMARK", "16%", "备注和标签"); tab.AddHeadCol("CTIME", "16%", "创建时间"); tab.AddHeadRow(); ViewBag.gridTable = tab.GetHead() + Pagination.GetPage(pager, tableId, "5,10,15,20"); ViewBag.inneruserid = UserId; ViewBag.userGroupId = userGroupId; ViewBag.saleDeptId = saleDeptId; ViewBag.roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId); return View(); } [AuthorizeRedirect(Roles = InitRights.CONST_我的工作微信)] public ActionResult GetJobWxChatRecord(string jobWxUserName) { string url = "?jobWxUserName=" + jobWxUserName; Common.Utility.PostData(url, System.Text.Encoding.UTF8); return View(); } [HttpPost] [AuthorizeRedirect(Roles = InitRights.CONST_我的工作微信)] public JsonResult GetHtmlList(Pager pager, string userName, string alias, string resID, string nickName, string conRemark, string stime, string etime, string columns) { ControlResource.JudgeSYQ(); //decimal groupId = Request["groupId"].GetDecimal(0); //decimal userId = Request["userId"].GetDecimal(0); List list = wx_WorkAccount_BL.GetList(ref pager, userName, alias, conRemark, nickName, resID, 0, UserId, null, stime, etime); Table table = new Table(columns, true); table.gridPager = pager; foreach (var model in list) { table.AddHiddenCol(model.PKID); table.AddCol(model.USERNAME); table.AddCol(model.ALIAS); table.AddCol(model.NICKNAME); table.AddCol(model.RESID); table.AddCol(model.CONREMARK); table.AddCol(model.CTIME); table.AddRow(); } var json = new { totalPages = pager.totalPages, totalRows = pager.totalRows, rowsList = table.GetRows() }; return Json(json, JsonRequestBehavior.AllowGet); } [AuthorizeRedirect(Roles = InitRights.CONST_工作微信在线列表)] public ActionResult AliveIndex(string userid) { ControlResource.JudgeSYQ(); UnlineHandle(userid); //ToolBar ToolBar tool = new ToolBar(); string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.工作微信在线列表, userRightId); tool.AllowButton(toolbtn); ViewBag.ToolBar = tool; //table string tableId = "tablist"; Table tab = new Table(tableId); tab.AddHeadCol("UserName", "", "微信用户名"); tab.AddHeadCol("Alias", "", "微信号"); tab.AddHeadCol("Quantity", "", "微信序号", true); tab.AddHeadCol("NickName", "", "昵称"); tab.AddHeadCol("EidAndName", "", "员工"); tab.AddHiddenHeadCol("GroupId", "组ID"); tab.AddHeadCol("GroupName", "", "组别", true); tab.AddHiddenHeadCol("hidOnLine", "微信状态"); tab.AddHeadCol("OnLine", "", "微信状态", true); tab.AddHiddenHeadCol("hidIsAlive", "推广状态"); tab.AddHeadCol("IsAlive", "", "推广状态", true); tab.AddHeadCol("AUDITMEMO", "", "备注", true); tab.AddHeadCol("Version", "", "版本号", true); tab.AddHeadCol("LastTime", "", "最后刷新时间", true); tab.AddHeadCol("LastMsgTime", "", "数据反馈时间", true); tab.AddHeadCol("LastFriendTime", "", "好友反馈时间", true); tab.AddHeadCol("fenghaotime", "", "封号时间", true); tab.AddHiddenHeadCol("isfenghao", "是否封号"); tab.AddHiddenHeadCol("LeaderType", "组长类型"); tab.AddHeadRow(); Pager pager = new Pager() { page = 1, rows = 2000 }; ViewBag.gridTable = tab.GetHead() + Pagination.GetPage(pager, "tablist", "2000"); ViewBag.AllVersion = wx_WorkAccount_BL.GetAllVersion(); return View(); } /// /// 工作微信维护 /// /// public ActionResult WeiHu(string UserName) { WX_UPLOADMAXCREATETIME model = wx_WorkAccount_BL.GetUploadMaxCreateTime(UserName); if (model != null) { if (model.CREATETIME.HasValue) { ViewBag.UploadTime = DateTimeTool.GetTimeFromLinuxTime(Convert.ToInt64(model.CREATETIME.Value)).ToString("yyyy-MM-dd HH:mm:ss"); } if (!string.IsNullOrEmpty(model.QUNFACLIENTID)) { ViewBag.QunFaClientTime = DateTimeTool.GetTimeFromLinuxTime(Convert.ToInt64(model.QUNFACLIENTID)).ToString("yyyy-MM-dd HH:mm:ss"); } } Wx_Fast_UserModel fastmodel = _wx_fast_username.GetFastModel(UserName); if (fastmodel == null) { fastmodel = new Wx_Fast_UserModel() { fast_child = new List(), fast_main = new WX_FAST_USERNAME() { JOBUSERNAME = UserName, PICI = 0, POSITIONSTR = new DateTime(2018, 1, 1) } }; } if (fastmodel.fast_main == null) fastmodel.fast_main = new WX_FAST_USERNAME() { JOBUSERNAME = UserName, PICI = 0, POSITIONSTR = new DateTime(2018, 1, 1) }; if (fastmodel.fast_child == null) fastmodel.fast_child = new List(); ViewBag.Fast_Model = fastmodel; return View(model); } public JsonResult WeiHuSave(string username, int type, DateTime? time) { if (string.IsNullOrEmpty(username) || !time.HasValue) { return JsonHandler.ValidateFailMessage(); } bool result = wx_WorkAccount_BL.UpdateUpdateMaxCreateTime(username, type, time.Value); return JsonHandler.UpdateMessage(errors, result); } public JsonResult FindFastUserName(string username, string jobusername) { if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(jobusername)) { return JsonHandler.ValidateFailMessage(); } Wx_Fast_Search search = _wx_fast_username.GetRcontact(jobusername, username); if (search == null) { return Json(new { type = 0, message = "请输入正确的微信用户名!" }, JsonRequestBehavior.AllowGet); } else { return Json(new { type = 1, message = "成功!", data = search }, JsonRequestBehavior.AllowGet); } } public JsonResult FastUserConfigSave(string jobusername, string usernames, string delusername, DateTime time) { bool result = _wx_fast_username.ManMade_FastUsername(jobusername, usernames, delusername, time); if (result == false) { return Json(new { type = 0, message = "配置失败!" }, JsonRequestBehavior.AllowGet); } else { return Json(new { type = 1, message = "配置成功!" }, JsonRequestBehavior.AllowGet); } } #region 离线查看处理 /// /// 离线查看处理 /// public void UnlineHandle(string userid) { try { if (string.IsNullOrEmpty(userid)) return; wx_aliveimei.UnlineNoticeLook(Convert.ToDecimal(userid)); } catch (Exception e) { LogHelper.Error(e.ToString()); } } #endregion [HttpPost] [AuthorizeRedirect(Roles = InitRights.CONST_工作微信在线列表)] public JsonResult GetAliveHtmlList(Pager pager, int type, string eid, string alias, string GroupName, string version, decimal? zaixian, decimal? friendfankui, decimal? datafankui, decimal? username, string fenghaoguolv, string columns) { ControlResource.JudgeSYQ(); var lastMsgTimeList = _lastmsgtime.GetList(); var lastFriendList = wx_Rcontact_BL.GetJobWeiXinLastFriendList(); decimal?[] decArr = new decimal?[] { 1, 3 }; if (type == 2) { decArr = new decimal?[] { 2 }; } else if (type == 3) { decArr = new decimal?[] { 0 }; } List list = new List(); if (type == 10) //24小时未反馈量列表 { var weixinList = wx_WorkAccount_BL.Get24HoursNoWeixinFriend(); var weixinUserNames = new List(); if (weixinList != null) { foreach (var weixin in weixinList) { var time = wx_WorkAccount_BL.GetWeiXinPauseTime(weixin); if (time < 720) { weixinUserNames.Add(weixin); } } if (weixinUserNames.Count > 0) { list = wx_WorkAccount_BL.Get24HoursNoWeixinFriendAliveList(weixinUserNames); } } } else { list = wx_WorkAccount_BL.GetAliveList(decArr); } Table table = new Table(columns, true); foreach (WX_WORKACCOUNT_ALIVE nalive in list) { nalive.GroupName = InnerUserHelper.Instance.GetGroupName(InnerUserHelper.Instance.GetGroupId(nalive.InnerUserId)); nalive.EidAndName = InnerUserHelper.Instance.GetEidAndTrueName(nalive.InnerUserId); var lastFriendTime = lastFriendList.FirstOrDefault(p => p.JobUserName == nalive.UserName); if (lastFriendTime != null) nalive.FriendLastime = lastFriendTime.CreateTime; var lastMsgTime = lastMsgTimeList.FirstOrDefault(p => p.USERNAME == nalive.UserName); if (lastMsgTime != null) nalive.MsgLasttime = lastMsgTime.LASTTIME; } GetWhereList(ref list, ref pager, eid, alias, GroupName, version, zaixian, friendfankui, datafankui, username, fenghaoguolv); if (list != null) { foreach (var model in list) { table.AddCol(model.UserName); table.AddCol(model.Alias); table.AddCol(model.Quantity); table.AddCol(model.NickName); table.AddCol(model.EidAndName); table.AddHiddenCol(InnerUserHelper.Instance.GetGroupId(model.InnerUserId)); table.AddCol(model.GroupName); if (model.OnLine == 1 && !string.IsNullOrEmpty(model.Uin) && model.Uin != "0") table.AddHiddenCol(1); else if (model.OnLine == 0) table.AddHiddenCol(0); else { table.AddHiddenCol(-1); } if (model.OnLine == 1 && !string.IsNullOrEmpty(model.Uin) && model.Uin != "0") table.AddCol("在线"); else if (model.OnLine == 0) table.AddCol("离线"); else table.AddCol("微信离线"); table.AddHiddenCol(model.IsValid); table.AddCol(getWeixinValidText(model.IsValid)); table.AddCol(model.AuditMemo); table.AddCol(model.Version); table.AddCol(model.LastTime); table.AddCol(model.MsgLasttime);//消息时间 table.AddCol(model.FriendLastime);//好友时间 if (model.ISFENGHAO.HasValue && model.ISFENGHAO.Value == 1) table.AddCol("" + model.FENGHAOTIME.ToUnityString(2) + "");//封号时间 else table.AddCol("");//封号时间 table.AddHiddenCol(model.ISFENGHAO); table.AddHiddenCol(model.LeaderType); table.AddRow(); } } var json = new { totalPages = pager.totalPages, totalRows = pager.totalRows, rowsList = table.GetRows() }; return Json(json, JsonRequestBehavior.AllowGet); } [HttpGet] [AuthorizeRedirect(Roles = InitRights.CONST_工作微信在线列表)] public ActionResult Fenghao(string alias) { var model = new Wx_FengHao() { alias = alias }; return View(); } [HttpPost] [AuthorizeRedirect(Roles = InitRights.CONST_工作微信在线列表)] public JsonResult FenghaoSave(string alias, int isfenghao) { if (string.IsNullOrEmpty(alias)) { return JsonHandler.ValidateFailMessage(); } try { DataTable tab = wx_WorkAccount_BL.UpdateAliasFengHao(alias, isfenghao); DataRow row = tab.Rows[0]; int status = Convert.ToInt32(row["status"]); if (status == 200) return JsonHandler.ManageMessage("标记成功", true); else if (status == 500) return JsonHandler.ManageMessage("请输入正确的微信号", false); else return JsonHandler.ManageMessage("出现错误", false); } catch (Exception e) { LogHelper.Error(e); return JsonHandler.ManageMessage("出现错误", false); } } private void GetWhereList(ref List list, ref Pager pager, string eid, string alias, string GroupName, string version, decimal? zaixian, decimal? friendfankui, decimal? datafankui, decimal? username, string fenghaoguolv) { if (!string.IsNullOrWhiteSpace(eid)) { list = list.Where(m => m.EidAndName.Contains(eid)).ToList(); } if (!string.IsNullOrWhiteSpace(alias)) { list = list.Where(m => m.Alias.Contains(alias)).ToList(); } if (!string.IsNullOrWhiteSpace(GroupName)) { list = list.Where(m => m.GroupName.Contains(GroupName)).ToList(); } if (!string.IsNullOrWhiteSpace(version)) { list = list.Where(m => m.Version != null && m.Version.Equals(version)).ToList(); } if (!string.IsNullOrEmpty(fenghaoguolv)) { fenghaoguolv = fenghaoguolv.Replace(",", ""); if (fenghaoguolv == "1") { list = list.Where(m => m.ISFENGHAO == null || m.ISFENGHAO != 1).ToList(); } } if (zaixian.HasValue) { if (zaixian.Value == 1) { list = list.Where(m => m.OnLine == 1 && m.Uin != null && m.Uin != "0").ToList(); } else if (zaixian.Value == 2) { list = list.Where(m => m.OnLine == 0).ToList(); } else if (zaixian.Value == 3) { string[] imt = { "0", "-1", "" }; list = list.Where(m => m.OnLine == 1 && (m.Uin == null || imt.Contains(m.Uin))).ToList(); } } if (friendfankui.HasValue) { if (friendfankui.Value == 1)//当天有反馈 { DateTime date = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); list = list.Where(m => m.FriendLastime >= date).ToList(); } else if (friendfankui.Value == 2)//1天未反馈 { DateTime date = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); DateTime date2 = Convert.ToDateTime(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")); list = list.Where(m => m.FriendLastime < date && m.FriendLastime >= date2).ToList(); } else if (friendfankui.Value == 3)//2-5天未反馈 { DateTime date = Convert.ToDateTime(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")); DateTime date2 = Convert.ToDateTime(DateTime.Now.AddDays(-5).ToString("yyyy-MM-dd")); list = list.Where(m => m.FriendLastime < date && m.FriendLastime >= date2).ToList(); } else if (friendfankui.Value == 5)//2-5天未反馈 { DateTime date = Convert.ToDateTime(DateTime.Now.AddDays(-5).ToString("yyyy-MM-dd")); list = list.Where(m => m.FriendLastime < date).ToList(); } } if (datafankui.HasValue) { if (datafankui.Value == 1)//当天有反馈 { DateTime date = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); list = list.Where(m => m.MsgLasttime >= date).ToList(); } else if (datafankui.Value == 2)//1天未反馈 { DateTime date = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); DateTime date2 = Convert.ToDateTime(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")); list = list.Where(m => m.MsgLasttime < date && m.FriendLastime >= date2).ToList(); } else if (datafankui.Value == 3)//2-5天未反馈 { DateTime date = Convert.ToDateTime(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")); DateTime date2 = Convert.ToDateTime(DateTime.Now.AddDays(-5).ToString("yyyy-MM-dd")); list = list.Where(m => m.MsgLasttime < date && m.FriendLastime >= date2).ToList(); } else if (datafankui.Value == 5)//2-5天未反馈 { DateTime date = Convert.ToDateTime(DateTime.Now.AddDays(-5).ToString("yyyy-MM-dd")); list = list.Where(m => m.MsgLasttime < date).ToList(); } } if (username.HasValue) { if (username.Value == 1) list = list.Where(m => m.UserName != null && m.UserName != "").ToList(); else if (username.Value == 2) { list = list.Where(m => m.UserName == null || m.UserName == "").ToList(); } } //排序 if (pager.order == "asc") { switch (pager.sort) { case "Quantity": list = list.OrderBy(c => c.Quantity).ToList(); break; case "GroupName": list = list.OrderBy(c => c.GroupName).ToList(); break; case "OnLine": list = list.OrderBy(c => c.OnLine).ToList(); break; case "IsAlive": list = list.OrderBy(c => c.IsValid).ToList(); break; case "AUDITMEMO": list = list.OrderBy(c => c.AuditMemo).ToList(); break; case "Version": list = list.OrderBy(c => c.Version).ToList(); break; case "LastTime": list = list.OrderBy(c => c.LastTime).ToList(); break; case "LastMsgTime": list = list.OrderBy(c => c.MsgLasttime).ToList(); break; case "LastFriendTime": list = list.OrderBy(c => c.FriendLastime).ToList(); break; default: list = list.OrderBy(c => c.LastTime).ToList(); break; } } else { switch (pager.sort) { case "Quantity": list = list.OrderByDescending(c => c.Quantity).ToList(); break; case "GroupName": list = list.OrderByDescending(c => c.GroupName).ToList(); break; case "OnLine": list = list.OrderByDescending(c => c.OnLine).ToList(); break; case "IsAlive": list = list.OrderByDescending(c => c.IsValid).ToList(); break; case "AUDITMEMO": list = list.OrderByDescending(c => c.AuditMemo).ToList(); break; case "Version": list = list.OrderByDescending(c => c.Version).ToList(); break; case "LastTime": list = list.OrderByDescending(c => c.LastTime).ToList(); break; case "LastMsgTime": list = list.OrderByDescending(c => c.MsgLasttime).ToList(); break; case "LastFriendTime": list = list.OrderByDescending(c => c.FriendLastime).ToList(); break; default: list = list.OrderByDescending(c => c.LastTime).ToList(); break; } } pager.totalRows = list.Count(); } private List getAliveList() { var cacheKey = "cache_WxAlive"; if (CacheHelper.Exists(cacheKey)) { return CacheHelper.Get>(cacheKey); } List list = wx_WorkAccount_BL.GetAliveList(null); if (list != null) { CacheHelper.Set>(cacheKey, list, DateTime.Now.AddMinutes(1)); } return list; } /// /// 我的消息页面 /// /// 工作微信名称 /// public ActionResult MyMessage(string workusername, string column, string sort) { List rcontactlist = new List(); string isShow = cache_q.GetValue_Parameter("WeiXin_IsShowGroupMessage");//是否显示群信息 List grouplist = new List(); if (!string.IsNullOrEmpty(workusername)) rcontactlist = wx_WorkAccount_BL.GetRcontactList(workusername, column, sort); foreach (var item in rcontactlist) { item.NICKNAME = PhoneHelper.FormatPhoneUserName(item.NICKNAME); item.CONREMARK = PhoneHelper.FormatPhoneUserName(item.NICKNAME); } if (isShow == "true") { grouplist = wx_WorkAccount_BL.GetGroupsByWorkAccount(workusername, column, sort); } WX_WORKACCOUNT workaccount = wx_WorkAccount_BL.GetWorAccount(workusername); ViewBag.rcontactList = rcontactlist; ViewBag.grouplist = grouplist; ViewBag.isShowGroupMessage = isShow; ViewBag.workAccountName = workaccount != null ? workaccount.NICKNAME : ""; return View(); } public ActionResult MessageDetial(string workusername, string username) { WX_RCONTACT t = wx_Rcontact_BL.GetModel(workusername, username); WX_WORKACCOUNT workaccount = wx_WorkAccount_BL.GetWorAccount(workusername); //ViewBag.workAccountName = workaccount != null ? workaccount.NICKNAME : ""; //ViewBag.customerUserNmae = username; //ViewBag.customerName = WxMessageHandler.GetRcontactNickNameByRcontact(t).Replace("\r", "").Replace("\n", ""); ViewBag.workusername = workusername; ViewBag.workAccountName = workaccount != null ? workaccount.NICKNAME : ""; ViewBag.username = username; ViewBag.nickname = WxMessageHandler.GetRcontactNickNameByRcontact(t).Replace("\r", "").Replace("\n", ""); var model = bas_Parameter_Q_BL.GetModel_Patameter(WX.CRM.Model.Enum.Parameter.WeiXin_IllegalKewords.ToString()); if (model == null) ViewBag.KeyWords = ""; else ViewBag.KeyWords = model.PARAVALUE; if (userRoleCodes.Contains("[GLY]") || userRoleCodes.Contains("[userRoleCodes]"))//合规人员显示合规信息 { ViewBag.IsShowHG = "1"; } else { ViewBag.IsShowHG = "0"; } return View(); } [AuthorizeToolBar(InitRights.CONST_工作微信管理, InitToolBar.CONST_Other5)] //[AuthorizeRedirect(Roles = InitRights.CONST_工作微信管理)] public ActionResult ShowHongBao(string workusername) { Pager pager = new Pager() { page = 1, rows = 20 }; string tableId = "tablist"; Table tab = new Table(tableId); tab.AddHiddenHeadCol("sendid", "红包ID"); tab.AddHeadCol("sendusername", "", "红包发送人"); tab.AddHeadCol("sendNickName", "", "昵称"); tab.AddHeadCol("sendconremark", "", "备注"); tab.AddHeadCol("mntype", "", "红包类型");//--1.普通红包 2.群红包 tab.AddHeadCol("title", "", "红包标题"); tab.AddHeadCol("username", "", "领取人"); tab.AddHeadCol("getNickName", "", "领取人"); tab.AddHeadCol("getconremark", "", "备注"); tab.AddHeadCol("createtime", "", "时间"); tab.AddHeadCol("saleuserid", "", "员工"); tab.AddHeadRow(); ViewBag.gridTable = tab.GetHead(); return View(); } [AuthorizeToolBar(InitRights.CONST_工作微信管理, InitToolBar.CONST_Other5)] [HttpPost] public JsonResult GetShowHongBaoHtmlList(string columns, string workusername, decimal? eid, DateTime? stime, DateTime? etime) { if (etime.HasValue) etime = etime.Value.AddDays(1); DataTable tab = wx_hongbao.ShowWxHongBao(workusername, eid, stime, etime); Table table = new Table(columns, true); foreach (DataRow model in tab.Rows) { table.AddHiddenCol(model["sendid"]); table.AddCol(model["sendusername"]); table.AddCol(model["sendNickName"]); table.AddCol(model["sendconremark"]); table.AddCol(model["mntype"]); table.AddCol(model["title"]); table.AddCol(model["username"]); table.AddCol(model["getNickName"]); table.AddCol(model["getconremark"]); table.AddCol(model["createtime"]); if (model["inneruserid"] == DBNull.Value) table.AddCol(""); else table.AddCol(InnerUserHelper.Instance.GetEidAndTrueName(Convert.ToDecimal(model["inneruserid"]))); table.AddRow(); } var json = new { //totalPages = pager.totalPages, //totalRows = pager.totalRows, rowsList = table.GetRows() }; wx_hongbao.UpdateHongBaoLookStatus(Eid);//更新查看红包状态 return Json(json, JsonRequestBehavior.AllowGet); } /// /// 获取群成员信息 /// /// 群号 /// public JsonResult GetGroupNumber(string chatroom) { DataTable tab = wx_group_bl.GetGroupNumber(chatroom); var json = new List(); if (tab != null) foreach (DataRow item in tab.Rows) { json.Add(new { username = item["username"].ToString(), nickname = item["nickname"].ToString() }); } return Json(json, JsonRequestBehavior.AllowGet); } /// /// 获取聊天 /// /// /// public JsonResult GetMonthMessageJsonList(string chatroom) { List fileList = getPath(Server.MapPath("~/Message/" + chatroom + "/")); return Json(fileList, JsonRequestBehavior.AllowGet); } public List getPath(string path) { List list = new List();//定义list变量,存放获取到的路径 DirectoryInfo dir = new DirectoryInfo(path); FileInfo[] fil = dir.GetFiles(); DirectoryInfo[] dii = dir.GetDirectories(); foreach (FileInfo f in fil) { list.Add(f.Name);//添加文件的路径到列表 } //获取子文件夹内的文件列表,递归遍历 foreach (DirectoryInfo d in dii) { getPath(d.FullName); list.Add(d.FullName);//添加文件夹的路径到列表 } return list; } /// /// 我的消息页面 /// /// 工作微信名称 /// public ActionResult MyMessageOne(string username, string workusername) { WX_RCONTACT t = wx_Rcontact_BL.GetModel(workusername, username); WX_WORKACCOUNT workaccount = wx_WorkAccount_BL.GetWorAccount(workusername); ViewBag.workAccountName = workaccount != null ? workaccount.NICKNAME : ""; ViewBag.customerUserNmae = username; ViewBag.customerName = WxMessageHandler.GetRcontactNickNameByRcontact(t).Replace("\r", "").Replace("\n", ""); return View(); } public ActionResult QwMessageOne() { return View(); } private string getWeixinValidText(decimal? valid) { if (!valid.HasValue) return "待审"; if (valid == 0) return string.Format("{0}", "下线"); else if (valid == 1) return "正常"; else if (valid == 2) return string.Format("{0}", "手工暂停"); else if (valid == 3) return string.Format("{0}", "系统暂停"); else return "待审"; } private static string _shareName; private static string _isShare; [HttpPost] public JsonResult Audio(string url) { if (string.IsNullOrEmpty(url)) { return Json(new retMsg() { result = false, retcode = 500, retmsg = "参数错误!" }, JsonRequestBehavior.AllowGet); } try { bool isNas = false; _isShare = Utility.GetSettingByKey("IsShare"); if (!string.IsNullOrEmpty(_isShare)) { isNas = true; _shareName = Utility.GetSettingByKey("NetUseShareName") ?? @"\\192.168.1.171\weixin"; string user = Utility.GetSettingByKey("NetUseUser") ?? @"192.168.1.171\admin"; string pwd = Utility.GetSettingByKey("NetUsePwd") ?? "read,./1"; NetUseHelper.Build(_shareName, user, pwd, string.Empty);//不指定盘符,避免引起盘符被占用的错误 } var webPath = FileUnit.GetBaseDirectory(); var exePath = webPath + "silk2mp3"; var fileNameWithoutExt = Path.GetFileNameWithoutExtension(url); var basePath = Utility.GetSettingByKey("uploadfile"); var localBasePath = basePath; if (!string.IsNullOrEmpty(_shareName)) { basePath = _shareName + @"\WXFILE\uploadfile\"; } var path = Path.Combine(basePath, "audio");//nas临时目录位置 var localpath = Path.Combine(localBasePath, "audio");//nas临时目录位置 if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (isNas && !Directory.Exists(localpath))//nas的需要建立本地的临时目录 { Directory.CreateDirectory(localpath); } var subUrl = url.Substring(0, url.IndexOf("uploadfile")) + "uploadfile"; var subPath = url.Replace(subUrl, ""); var amrPath = basePath + subPath;//nas amr的地址 var localAmrPath = localBasePath + subPath;//local的amr的地址 if (!System.IO.File.Exists(amrPath)) { return Json(new retMsg() { result = false, retcode = 500, retmsg = "未能找到文件!" }, JsonRequestBehavior.AllowGet); } if (isNas)//nas的走拷贝到本地在进行操作 { string fold = localAmrPath.Substring(0, localAmrPath.LastIndexOf("/")); if (!Directory.Exists(fold)) { Directory.CreateDirectory(fold); } var targetFileNamePcm = Path.Combine(localpath, fileNameWithoutExt + ".pcm"); var targetFileNameMp3 = Path.Combine(localpath, fileNameWithoutExt + ".mp3");//本地的mp3地址 var nastargetFileNameMp3 = Path.Combine(path, fileNameWithoutExt + ".mp3"); if (!System.IO.File.Exists(nastargetFileNameMp3))//判断nas目标是否有此文件,有的话不做转换 { System.IO.File.Copy(amrPath, localAmrPath, true);//拷贝文件 //LogHelper.Info("path:" + nastargetFileNameMp3); var amr = new SilkConvertToMp3(); amr.ConvertToPcm(exePath, localAmrPath, targetFileNamePcm); if (System.IO.File.Exists(targetFileNamePcm)) { amr.ConvertToMp3(exePath, targetFileNamePcm, targetFileNameMp3); } else { amr.ConvertAmrToMp3(exePath, localAmrPath, targetFileNameMp3); } if (System.IO.File.Exists(targetFileNameMp3)) { try { System.IO.File.Copy(targetFileNameMp3, nastargetFileNameMp3);//将文件拷贝的目标nas目录 System.IO.File.Delete(targetFileNameMp3); System.IO.File.Delete(targetFileNamePcm); System.IO.File.Delete(localAmrPath); } catch (Exception e) { LogHelper.Error(e.ToString()); } } else { //LogHelper.Info("找不到:" + targetFileNameMp3); } } } else { var targetFileNamePcm = Path.Combine(path, fileNameWithoutExt + ".pcm"); var targetFileNameMp3 = Path.Combine(path, fileNameWithoutExt + ".mp3"); if (!System.IO.File.Exists(targetFileNameMp3)) { var amr = new SilkConvertToMp3(); amr.ConvertToPcm(exePath, amrPath, targetFileNamePcm); if (System.IO.File.Exists(targetFileNamePcm)) { amr.ConvertToMp3(exePath, targetFileNamePcm, targetFileNameMp3); } else { amr.ConvertAmrToMp3(exePath, amrPath, targetFileNameMp3); } } } return Json(new retMsg() { result = true, retcode = 200, retmsg = subUrl + "/audio/" + fileNameWithoutExt + ".mp3" }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { LogHelper.Error("微信录音获取错误:" + ex.ToString()); return Json(new retMsg() { result = false, retcode = 505, retmsg = "微信录音获取错误!" }, JsonRequestBehavior.AllowGet); } } [HttpPost] public JsonResult WeWorkAudio(string url) { if (string.IsNullOrEmpty(url)) { return JsonHandler.ManageMessage("参数错误!", false); } try { var isShare = Utility.GetSettingByKey("IsShare"); var webPath = FileUnit.GetBaseDirectory(); var exePath = webPath + "silk2mp3"; var fileNameWithoutExt = Path.GetFileNameWithoutExtension(url); var basePath = string.IsNullOrEmpty(isShare) ? Utility.GetSettingByKey("weworkfile") : Utility.GetSettingByKey("NetUseShareName") + @"\WXFILE\uploadfile\"; //var path = basePath + "audio"; var path = Path.Combine(basePath, "audio"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var subUrl = url.Substring(0, url.IndexOf("weworkfile")) + "weworkfile"; var subPath = url.Replace(subUrl, ""); var amrPath = basePath + subPath; if (!System.IO.File.Exists(amrPath)) { return JsonHandler.ManageMessage("未能找到文件!", false); } var targetFileNamePcm = Path.Combine(path, fileNameWithoutExt + ".pcm"); var targetFileNameMp3 = Path.Combine(path, fileNameWithoutExt + ".mp3"); if (!System.IO.File.Exists(targetFileNameMp3)) { SilkConvertToMp3 amr = new SilkConvertToMp3(); amr.ConvertToPcm(exePath, amrPath, targetFileNamePcm); if (System.IO.File.Exists(targetFileNamePcm)) { amr.ConvertToMp3(exePath, targetFileNamePcm, targetFileNameMp3); } else { amr.ConvertAmrToMp3(exePath, amrPath, targetFileNameMp3); } } if (string.IsNullOrEmpty(isShare)) return Json(new { result = "ok", data = subUrl + "/audio/" + fileNameWithoutExt + ".mp3" }, JsonRequestBehavior.AllowGet); else return Json(new { result = "ok", data = "" }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { LogHelper.Error("微信录音获取错误:" + ex.ToString()); return JsonHandler.ManageMessage("微信录音获取错误!", false); } } public FileResult Export(string workusername, string username, string worknickname, string nickname) { var redis = new RedisHelper(); var isShare = Utility.GetSettingByKey("IsShare"); var fileRoot = string.IsNullOrEmpty(isShare) ? Utility.GetSettingByKey("uploadfile") : Utility.GetSettingByKey("NetUseShareName") + @"\WXFILE\uploadfile\"; var fileHost = fileRoot.Replace("uploadfile\\", ""); var webPath = FileUnit.GetBaseDirectory(); var htmlPath = Path.Combine(webPath, "messageexport.html"); var facePath = Path.Combine(webPath, "Face"); var messagePath = Path.Combine(webPath, "Message"); var workUserNamePath = Path.Combine(messagePath, workusername); var tmpPath = Path.Combine(webPath, "temp"); var tmpWorkUserNamePath = Path.Combine(tmpPath, workusername); var tmpWorkUserNameWithUserNamePath = Path.Combine(tmpWorkUserNamePath, username); var contentPath = Path.Combine(tmpWorkUserNameWithUserNamePath, "content"); var userData = new StringBuilder(); var userMonths = new StringBuilder(); if (!Directory.Exists(contentPath)) { Directory.CreateDirectory(contentPath); } try { if (string.IsNullOrEmpty(workusername) || string.IsNullOrEmpty(username)) { LogHelper.Error("参数错误"); return null; } #region js css 文件处理 var jsFiles = new List { Path.Combine(webPath, @"Scripts\jquery.min.js"), Path.Combine(webPath, @"Scripts\op\jquery.rewrite.js"), Path.Combine(webPath, @"Scripts\json2.js"), Path.Combine(webPath, @"Scripts\jquery.easyui.min.js"), Path.Combine(webPath, @"Scripts\jquery.easyui.plus.js"), Path.Combine(webPath, @"Scripts\op\datagrid_op.js"), Path.Combine(webPath, @"Scripts\op\main_op.js"), //Path.Combine(webPath, @"Scripts\My97DatePicker\WdatePicker.js"), Path.Combine(webPath, @"Scripts\op\jquery.tablegrid.js"), Path.Combine(webPath, @"Content\themes\blue\easyui.css"), Path.Combine(webPath, @"Content\Site.css?v=4"), Path.Combine(webPath, @"Scripts\common.js"), Path.Combine(webPath, @"Content\data_grid_list.css") }; jsFiles.ForEach(x => { var tmpFile = Path.Combine(contentPath, Path.GetFileName(x)); if (!System.IO.File.Exists(tmpFile)) System.IO.File.Copy(x, tmpFile); }); var faces = Directory.GetFiles(facePath, "*.*"); faces.ToList().ForEach(x => { var tmpFile = Path.Combine(contentPath, Path.GetFileName(x)); if (!System.IO.File.Exists(tmpFile)) System.IO.File.Copy(x, tmpFile); }); #endregion #region 处理数据文件 //var files = Directory.GetFiles(workUserNamePath, username + "_*.json"); //files.ToList().ForEach(x => //{ // var tmpFile = Path.Combine(contentPath, Path.GetFileName(x)); // if (!System.IO.File.Exists(tmpFile)) // System.IO.File.Copy(x, tmpFile); //}); #endregion #region 处理聊天文件(图片,语音,文件) userData.Append("["); userMonths.Append("["); var userContent = string.Empty; var userMonth = string.Empty; //var datalist = Directory.GetFiles(contentPath, username + "_*.json"); var datalist = Directory.GetFiles(workUserNamePath, username + "_*.json"); foreach (var item in datalist) { //StreamReader sr = new StreamReader(HttpContext.Current.Server.MapPath(Path), System.Text.Encoding.GetEncoding("utf-8")); //string content = sr.ReadToEnd().ToString(); //sr.Close(); var jsonName = Path.GetFileName(item); jsonName = jsonName.Remove(0, jsonName.LastIndexOf('_') + 1); var month = jsonName.Replace(".json", ""); userMonth += "\"" + month + "\","; using (var sr = new StreamReader(item)) { var content = "[" + sr.ReadToEnd() + "]"; var messages = JsonConvert.DeserializeObject>(content); var newMessages = new List(); foreach (var genMessage in messages) { if (genMessage.type == 3 || genMessage.type == 47 || genMessage.type == 34 || genMessage.type == 43 || genMessage.type == 49) { //var fileSubPath = Utility.GetData(fileHost + genMessage.msgSvrId, string.Empty, Encoding.UTF8); //LogHelper.Info("fileSubPath:" + fileSubPath); try { if (!string.IsNullOrEmpty(genMessage.url)) continue; var fileSubPath = redis.Get("wx:" + genMessage.msgSvrId); if (string.IsNullOrEmpty(fileSubPath)) { newMessages.Add(genMessage); continue; } var filePath = Path.Combine(fileHost, fileSubPath.Trim('/').Replace('/', '\\')); var fileName = Path.GetFileName(filePath); if (string.IsNullOrEmpty(genMessage.url)) genMessage.url = fileName; System.IO.File.Copy(filePath, Path.Combine(contentPath, fileName)); } catch { } newMessages.Add(genMessage); } else { if (Utility.IsContainWeixinHongBao(genMessage.content) || !Utility.IsContainMobile(genMessage.content)) { newMessages.Add(genMessage); } //genMessage.content = Utility.ReplaceMobile(genMessage.content);//替换手机号 } } content = "{ \"" + month + "\" : " + JsonConvert.SerializeObject(newMessages) + "}"; userContent += content + ","; sr.Dispose(); sr.Close(); //LogHelper.Info("文件:" + item + "的内容:" + content); } //System.IO.File.Delete(item); } userContent = userContent.Trim(','); userData.Append(userContent); userData.Append("]"); userMonth = userMonth.Trim(','); userMonths.Append(userMonth); userMonths.Append("]"); #endregion #region html文件处理 var exportTemplate = string.Empty; using (StreamReader sr = new StreamReader(htmlPath)) { exportTemplate = sr.ReadToEnd(); sr.Close(); } var scriptHtml = new StringBuilder(); foreach (var jsFile in jsFiles) { var jsFileName = jsFile.Remove(0, jsFile.LastIndexOf('\\') + 1); scriptHtml.AppendFormat(Path.GetExtension(jsFile) == ".js" ? "" : "", "content/" + jsFileName); } exportTemplate = exportTemplate .Replace("{{script}}", scriptHtml.ToString()) .Replace("{{username}}", username) .Replace("{{data}}", userData.ToString()) .Replace("{{month}}", userMonths.ToString()) .Replace("{{worknickname}}", worknickname) .Replace("{{nickname}}", Utility.ReplaceMobile(nickname)); var savePath = Path.Combine(tmpWorkUserNameWithUserNamePath, username + ".html"); using (StreamWriter sw = new StreamWriter(savePath, false, Encoding.GetEncoding("UTF-8"))) { sw.WriteLine(exportTemplate); sw.Flush(); sw.Close(); } #endregion #region 压缩处理 var zipName = worknickname + "与" + nickname + "的聊天记录"; zipName = zipName.Replace('\\', ' ').Replace('/', ' ').Replace(':', ':').Replace('?', '?').Replace('"', '“').Replace('<', '【').Replace('|', ' ').Replace('>', '】').Replace("*", "x");//*在路径名中是非法字符,需要把隐藏手机号的*替换掉 var zipPath = Path.Combine(tmpWorkUserNamePath, zipName + ".zip"); if (System.IO.File.Exists(zipPath)) { System.IO.File.Delete(zipPath); } var fastZip = new FastZip(); fastZip.CreateZip(zipPath, tmpWorkUserNameWithUserNamePath, true, ""); #endregion #region 删除文件处理 DirectoryInfo dir = new DirectoryInfo(tmpWorkUserNameWithUserNamePath); FileSystemInfo[] fileinfo = dir.GetFileSystemInfos(); //返回目录中所有文件和子目录 foreach (FileSystemInfo i in fileinfo) { if (i is DirectoryInfo) { DirectoryInfo subdir = new DirectoryInfo(i.FullName); subdir.Delete(true); } else { System.IO.File.Delete(i.FullName); } } #endregion return File(zipPath, "application/x-zip-compressed", zipName + ".zip"); //return Json(new { result = "ok" }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { LogHelper.Error("微信消息导出错误:" + ex.ToString()); #region 删除文件处理 DirectoryInfo dir = new DirectoryInfo(tmpWorkUserNameWithUserNamePath); FileSystemInfo[] fileinfo = dir.GetFileSystemInfos(); //返回目录中所有文件和子目录 foreach (FileSystemInfo i in fileinfo) { if (i is DirectoryInfo) { DirectoryInfo subdir = new DirectoryInfo(i.FullName); subdir.Delete(true); } else { System.IO.File.Delete(i.FullName); } } #endregion return null; } } [HttpGet] [AuthorizeRedirect(Roles = InitRights.CONST_微信信息批量导出)] public ActionResult BatchExport() { //table string tableId = "tablist"; Table tab = new Table(tableId); tab.isCheckbox = true; tab.AddHeadCol("username", "", "用户名"); tab.AddHeadCol("nickname", "", "客户昵称"); tab.AddHeadCol("conremark", "", "客户备注"); tab.AddHeadCol("eid", "", "员工"); tab.AddHeadCol("jobwxusername", "", "工作微信用户名"); tab.AddHeadCol("wokalias", "", "工作微信号"); tab.AddHeadCol("export", "", "操作"); tab.AddHeadRow(); ViewBag.gridTable = tab.GetHead(); return View(); } [HttpPost] [AuthorizeRedirect(Roles = InitRights.CONST_微信信息批量导出)] public JsonResult BatchExport(string resid, string username, string alias, string nickname, string conremark, string jobusername, string workalias, decimal? eid, string columns) { try { if (string.IsNullOrEmpty(resid) && string.IsNullOrEmpty(username) && string.IsNullOrEmpty(alias) && string.IsNullOrEmpty(nickname) && string.IsNullOrEmpty(conremark) && string.IsNullOrEmpty(jobusername) && string.IsNullOrEmpty(workalias) && !eid.HasValue) { return JsonHandler.ManageMessage("参数错误!", false); } var list = wx_Rcontact_BL.GetChatUser(resid, username, alias, nickname, conremark, jobusername, workalias, eid); Table table = new Table(columns, true); table.isCheckbox = true; foreach (DataRow row in list.Rows) { table.AddCol(row["username"]); table.AddCol(Utility.ReplaceMobile(row["nickname"])); table.AddCol(Utility.ReplaceMobile(row["conremark"])); table.AddCol(string.Format("{0}-{1}", row["eid"], row["uname"])); table.AddCol(row["jobwxusername"]); table.AddCol(row["wokalias"]); table.AddCol(string.Format("{4}", row["jobwxusername"], row["username"], row["worknickname"], row["nickname"], "导出")); table.AddRow(); } var json = new { rowsList = table.GetRows() }; return Json(json, JsonRequestBehavior.AllowGet); } catch (Exception ex) { LogHelper.Error("微信消息导出查询错误:" + ex.ToString()); return JsonHandler.ManageMessage("微信消息导出查询错误!", false); } } [AuthorizeToolBar(InitRights.CONST_微信聊天合规管理, InitToolBar.CONST_Add)] public ActionResult Add() { //BAS_FEEDBACK model = new BAS_FEEDBACK(); //model.SHOWTYPE = 0; return View(); } [HttpPost] [AuthorizeToolBar(InitRights.CONST_微信聊天合规管理, InitToolBar.CONST_Add)] public JsonResult Add(BAS_FEEDBACK model) { if (model == null) { errors.Add("参数不能为空!"); return JsonHandler.InsertMessage(errors, false); } if (string.IsNullOrWhiteSpace(model.CONTENT)) { errors.Add("内容不能为空!"); return JsonHandler.InsertMessage(errors, false); } if (string.IsNullOrWhiteSpace(model.CONTENT)) { errors.Add("内容不能为空!"); return JsonHandler.InsertMessage(errors, false); } model.PKID = new SEQUENCES_BL().Seq_base_get(); model.CTIME = DateTime.Now; model.INNERUSERID = UserId; var flag = 0; return JsonHandler.InsertMessage(errors, flag == 1); } [AuthorizeRedirect(Roles = InitRights.CONST_客服微信列表)] public ActionResult WorkAccountList() { ToolBar tool = new ToolBar(); string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.客服微信列表, userRightId); tool.AllowButton(toolbtn); ViewBag.ToolBar = tool; //table Pager pager = new Pager() { page = 1, rows = 20 }; string tableId = "tablist"; Table tab = new Table(tableId); tab.AddHiddenHeadCol("PKID", "编号"); tab.AddHiddenHeadCol("RESID", "客户ID"); tab.AddHeadCol("USERNAME", "", "微信用户名"); tab.AddHeadCol("ALIAS", "", "微信号"); tab.AddHeadCol("MOBILE", "", "手机号"); tab.AddHeadCol("NICKNAME", "", "昵称"); tab.AddHeadCol("EID", "", "客服工号"); tab.AddHeadCol("GroupName", "", "客服所在组"); tab.AddHeadCol("OnLine", "", "微信状态"); tab.AddHeadRow(); var list = wx_GroupPercent_BL.GetGroupPercentList(); var selectList = new List(); if (list != null) { selectList.Add(new SelectListItem { Value = "", Text = "全部" }); foreach (var item in list) { selectList.Add(new SelectListItem { Value = item.GID.ToString(), Text = item.GNAME }); } } ViewBag.groupList = selectList; ViewBag.gridTable = tab.GetHead(); //+ Pagination.GetPage(pager, tableId, "5,10,15,20"); return View(); } [HttpPost] [AuthorizeRedirect(Roles = InitRights.CONST_客服微信列表)] public JsonResult GetWorkAccountHtmlList(Pager pager, decimal? gid, string columns) { //List list = wx_WorkAccount_BL.GetList(ref pager, userName, alias, conRemark, nickName, resID, groupId, userId, null, stime, etime); var list = wx_WorkAccount_BL.GetWorkAccountAllList(0, gid); var excludeList = wx_ExcludeWeixin_BL.GetList().Select(m => m.ALIAS).ToList(); if (excludeList != null && excludeList.Count > 0) { list = list.Where(m => !excludeList.Contains(m.WxWorkaccount.ALIAS)).ToList(); } Table table = new Table(columns, true); //table.gridPager = pager; foreach (var model in list) { table.AddHiddenCol(model.WxWorkaccount.PKID); table.AddHiddenCol(model.WxWorkaccount.RESID); table.AddCol(model.WxWorkaccount.USERNAME); table.AddCol(model.WxWorkaccount.ALIAS); table.AddCol(model.MOBILE); table.AddCol(model.WxWorkaccount.NICKNAME); table.AddCol(InnerUserHelper.Instance.GetEidAndTrueName(model.WxWorkaccount.INNERUSERID)); table.AddCol(InnerUserHelper.Instance.GetGroupName(InnerUserHelper.Instance.GetGroupId(model.WxWorkaccount.INNERUSERID))); if (model.OnLine == 1 && !string.IsNullOrEmpty(model.Uin) && model.Uin != "0") table.AddCol("在线"); else if (model.OnLine == 0) table.AddCol("离线"); else table.AddCol("微信离线"); //foreach (var item in beforeList) //{ // str += "

" + item.inneruserEid + "——" + item.inneruserName + "(" + item.wx_inneruserJobNum.STARTDATE + "至" + item.wx_inneruserJobNum.ENDDATE + ")

"; //} //table.AddCol(str); table.AddRow(); } var json = new { //totalPages = pager.totalPages, //totalRows = pager.totalRows, rowsList = table.GetRows() }; return Json(json, JsonRequestBehavior.AllowGet); } public class SilkConvertToMp3 { public void ConvertToPcm(string applicationPath, string fileName, string targetFileName) { string para = applicationPath + @"\silk_v3_decoder.exe " + fileName + " " + targetFileName + "&exit"; Cmd(para); } public void ConvertToMp3(string applicationPath, string fileName, string targetFilName) { string c = applicationPath + @"\ffmpeg.exe -y -f s16le -ar 24000 -ac 1 -i " + fileName + " " + targetFilName + "&exit"; ; Cmd(c); } public void ConvertAmrToMp3(string applicationPath, string fileName, string targetFilName) { string c = applicationPath + @"\ffmpeg.exe -i " + fileName + " " + targetFilName + "&exit"; ; Cmd(c); } private void Cmd(string c) { try { System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.FileName = "cmd.exe"; process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardInput = true; process.Start(); process.StandardInput.WriteLine(c); process.StandardInput.AutoFlush = true; //process.StandardInput.WriteLine("exit"); var reader = process.StandardOutput.ReadToEnd(); //截取输出流 process.WaitForExit(); process.Close(); } catch (Exception ex) { LogHelper.Error("转换录音文件失败:" + ex.ToString()); } } } public class GenMessage { public int Id { get; set; } public string msgSvrId { get; set; } public int type { get; set; } public int isSend { get; set; } public long createTime { get; set; } public string talker { get; set; } public string content { get; set; } public string username { get; set; } public string nickname { get; set; } public string url { get; set; } } } }