1316 lines
58 KiB
C#
1316 lines
58 KiB
C#
using DAL.Redis;
|
||
using Newtonsoft.Json;
|
||
using Ninject;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Runtime.Serialization;
|
||
using System.ServiceModel;
|
||
using System.ServiceModel.Web;
|
||
using System.Text;
|
||
using System.Text.RegularExpressions;
|
||
using System.Threading.Tasks;
|
||
using System.Web;
|
||
using WX.CRM.Common;
|
||
using WX.CRM.DAL;
|
||
using WX.CRM.DAL.Redis;
|
||
using WX.CRM.IBLL.Base;
|
||
using WX.CRM.IBLL.Res;
|
||
using WX.CRM.IBLL.TS;
|
||
using WX.CRM.IBLL.Wx;
|
||
using WX.CRM.Model.DTO;
|
||
using WX.CRM.Model.Enum;
|
||
using WX.CRM.Model.MAP;
|
||
using WX.CRM.WebHelper.Infrastructure;
|
||
using WxService.Wx;
|
||
|
||
namespace WxService
|
||
{
|
||
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码、svc 和配置文件中的类名“WxMessageSvr”。
|
||
// 注意: 为了启动 WCF 测试客户端以测试此服务,请在解决方案资源管理器中选择 WxMessageSvr.svc 或 WxMessageSvr.svc.cs,然后开始调试。
|
||
public class WxMessageSvr : IWxMessageSvr
|
||
{
|
||
private const string WxFix = "wxid:";
|
||
private const string WxMsgFix = "wxmsgid:";
|
||
private RedisSet<string> _redisSet = new RedisSet<string>();
|
||
private RedisString<string> _redisMsg = new RedisString<string>();
|
||
private readonly PubSub _sub = new PubSub();
|
||
public IWX_ALIVE _aliveBll = NinjectControllerFactory.ninjectKernel.Get<IWX_ALIVE>();
|
||
public IWX_ALIVEIMEI _aliveImeiBll = NinjectControllerFactory.ninjectKernel.Get<IWX_ALIVEIMEI>();
|
||
public IWX_RCONTACT _rcontact = NinjectControllerFactory.ninjectKernel.Get<IWX_RCONTACT>();
|
||
public ISEQUENCES sequencesbll = NinjectControllerFactory.ninjectKernel.Get<ISEQUENCES>();
|
||
public IWX_GROUP wx_group = NinjectControllerFactory.ninjectKernel.Get<IWX_GROUP>();
|
||
public IWX_HONGBAO wx_hongbao = NinjectControllerFactory.ninjectKernel.Get<IWX_HONGBAO>();
|
||
public IWX_TSADDFRIEND wx_tsaddfriend = NinjectControllerFactory.ninjectKernel.Get<IWX_TSADDFRIEND>();
|
||
public IWX_TS_QUNWORALIAS wx_tsqunworalias = NinjectControllerFactory.ninjectKernel.Get<IWX_TS_QUNWORALIAS>();
|
||
public IWX_TS_BATCHMSG wx_ts_batchmsg = NinjectControllerFactory.ninjectKernel.Get<IWX_TS_BATCHMSG>();
|
||
public IWX_TS_CMD wx_ts_cmd = NinjectControllerFactory.ninjectKernel.Get<IWX_TS_CMD>();
|
||
public IRES_CUSTOMER_Q _customerQ = NinjectControllerFactory.ninjectKernel.Get<IRES_CUSTOMER_Q>();
|
||
private IWx_MsgKey wx_msgkey = NinjectControllerFactory.ninjectKernel.Get<IWx_MsgKey>();
|
||
private IWX_FAST_USERNAME wx_fast_username = NinjectControllerFactory.ninjectKernel.Get<IWX_FAST_USERNAME>();
|
||
public async Task<JsonResult<string>> RContactPut(IList<rcontact> content)
|
||
{
|
||
var userNames = new List<string>();
|
||
Rcontact_RK rk = new Rcontact_RK();
|
||
foreach (var item in content)
|
||
{
|
||
#region
|
||
item.alias = HttpUtility.UrlDecode(item.alias, Encoding.UTF8);
|
||
item.nickname = HttpUtility.UrlDecode(item.nickname, Encoding.UTF8);
|
||
item.conRemark = HttpUtility.UrlDecode(item.conRemark, Encoding.UTF8);
|
||
#endregion
|
||
var key = item.username == item.jobwxusername ? "rcontact1" : "rcontact0";
|
||
var username = await PushRcontactAsync<rcontact>(item, key, item.jobwxusername, item.username, item.alias, item.conRemark);
|
||
if (item.username == item.jobwxusername)
|
||
{
|
||
if (rk.WxWorkAccount(item) == false)
|
||
userNames.Add(username);
|
||
}
|
||
else
|
||
{
|
||
if (rk.WxRcontact(item))
|
||
{
|
||
userNames.Add(username);
|
||
}
|
||
}
|
||
//if (!string.IsNullOrEmpty(username))
|
||
// userNames.Add(username);
|
||
}
|
||
if (userNames.Count > 0)
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功但有错误, retmsg = string.Join(",", userNames.ToArray()) };
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "调用成功" };
|
||
}
|
||
|
||
public JsonResult<string> FriendPut(IList<friend> friends)
|
||
{
|
||
try
|
||
{
|
||
//LogHelper.Info("接收到参数:" + JsonConvert.SerializeObject(friends));
|
||
var userNames = new List<string>();
|
||
foreach (var item in friends)
|
||
{
|
||
var ret = true;
|
||
decimal pici = _rcontact.extractToBeFriendsDataFromMsg(item.type, item.talker, item.jobusername, DateTimeTool.GetTimeFromLinuxTime(item.createtime), ref ret);
|
||
if (pici > 0)
|
||
{
|
||
//MsgHelper msg = new MsgHelper(EnumMsgs.SendMsg);
|
||
//var messageDto = new MessageQueueDTO() { MsgType = pici, MsgData = "web_push_updateUser" };
|
||
//msg.SendMsg(messageDto);//触发推送通知
|
||
}
|
||
if (!ret)
|
||
{
|
||
userNames.Add(item.talker);
|
||
}
|
||
}
|
||
if (userNames.Count > 0)
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功但有错误, retmsg = string.Join(",", userNames.ToArray()) };
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "调用成功" };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.ToString());
|
||
return new JsonResult<string> { result = false, retcode = (int)EnumInterfaceErrcode.系统错误, retmsg = null };
|
||
}
|
||
}
|
||
|
||
public async Task<JsonResult<string>> MessagePut(message content)
|
||
{
|
||
try
|
||
{
|
||
#region
|
||
if (content == null || (content.msgSvrId == 0 && content.talker == null && content.username == null && content.msgType == null))
|
||
{
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "success" };
|
||
}
|
||
//LogHelper.Info("解码前content:" + content.content);
|
||
content.nickname = HttpUtility.UrlDecode(content.nickname, Encoding.UTF8);
|
||
content.content = HttpUtility.UrlDecode(content.content, Encoding.UTF8);
|
||
if (!string.IsNullOrEmpty(content.filePath))
|
||
content.filePath = HttpUtility.UrlDecode(content.filePath, Encoding.UTF8);
|
||
//LogHelper.Info("解码后content:" + content.content);
|
||
#endregion
|
||
bool ret = true;
|
||
|
||
|
||
//if (content.type != 10000 && content.type != 1)
|
||
//{
|
||
// //LogHelper.Info(Utility.ConvertToJSON(content));
|
||
// return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "success" };
|
||
//}
|
||
#region 群信息,群消息,普通红包,群红包,领取红包 识别
|
||
|
||
bool isExists = true;
|
||
string chekkeyname = string.Empty;
|
||
TimeSpan span = new TimeSpan(60, 0, 0, 0, 0);//保留60天
|
||
if (content.msgType == "2")//===========群发助手
|
||
{
|
||
chekkeyname = WxMsgFix + content.msgSvrId + "|" + content.username;
|
||
isExists = await _redisMsg.ExistsAsync(chekkeyname);
|
||
}
|
||
else if (content.msgType == "6")//======群信息
|
||
{
|
||
DateTime time = DateTimeTool.GetTimeFromLinuxTime(content.createTime.Value);
|
||
content.imgPath = HttpUtility.UrlDecode(content.imgPath, Encoding.UTF8);
|
||
content.filePath = HttpUtility.UrlDecode(content.filePath, Encoding.UTF8);
|
||
//content.nickname = HttpUtility.UrlDecode(content.filePath, Encoding.UTF8);
|
||
//LogHelper.Info(string.Format("content:{0},imgPath:{1}", content.content, content.imgPath));
|
||
string name = content.filePath;
|
||
string shortName = content.imgPath;
|
||
if (content.imgPath.Length > 20)
|
||
shortName = shortName.Substring(0, 20) + "...";
|
||
ret = wx_group.WxGroupMaintain(content.talker, name, content.username, time, shortName);//===维护群信息
|
||
|
||
string[] memberlist = content.content.Split(';');//==群成员列表
|
||
|
||
string[] displayname = content.imgPath.Split('、');//===群成员昵称列表
|
||
string nickname = string.Empty;
|
||
//LogHelper.Info(content.nickname);
|
||
for (int i = 0; i < memberlist.Count(); i++)
|
||
{
|
||
nickname = string.Empty;
|
||
if (content.url == memberlist[i])
|
||
{
|
||
nickname = content.nickname;
|
||
}
|
||
|
||
wx_group.WxGroupMemberMaintain(content.talker, memberlist[i], displayname[i], nickname, content.url);
|
||
}
|
||
|
||
}
|
||
else if (content.msgType == "4")//======普通红包消息
|
||
{
|
||
DateTime time = DateTimeTool.GetTimeFromLinuxTime(content.createTime.Value);
|
||
string[] ncontect = content.content.Split('#');//发送人#标题
|
||
if (string.IsNullOrEmpty(content.imgPath))
|
||
ret = true;
|
||
else
|
||
ret = wx_hongbao.WxHongBao(content.imgPath.ToString(), content.msgSvrId.ToString(), content.talker, ncontect[0], 1, time, ncontect[1], "", content.username);
|
||
}
|
||
else if (content.msgType == "5")//======群红包消息
|
||
{
|
||
DateTime time = DateTimeTool.GetTimeFromLinuxTime(content.createTime.Value);
|
||
string[] ncontect = content.content.Split('#');//发送人#标题
|
||
if (string.IsNullOrEmpty(content.imgPath))
|
||
ret = true;
|
||
else
|
||
ret = wx_hongbao.WxHongBao(content.imgPath, content.msgSvrId.ToString(), content.talker, ncontect[0], 2, time, ncontect[1], content.talker, content.username);
|
||
}
|
||
else if (content.msgType == "7")//======领取红包信息
|
||
{
|
||
DateTime time = DateTimeTool.GetTimeFromLinuxTime(content.createTime.Value);
|
||
if (string.IsNullOrEmpty(content.imgPath))
|
||
ret = true;
|
||
else
|
||
wx_hongbao.WxHongBaoReceuve(content.imgPath, content.msgSvrId.ToString(), content.talker, time, content.username);
|
||
}
|
||
else//普通消息
|
||
{
|
||
if (content.talker.Contains("chatroom"))
|
||
{
|
||
chekkeyname = WxMsgFix + content.msgSvrId + "|" + content.talker;
|
||
isExists = await _redisMsg.ExistsAsync(chekkeyname);
|
||
}
|
||
else
|
||
{
|
||
chekkeyname = WxMsgFix + content.msgSvrId + "|" + content.username;
|
||
isExists = await _redisMsg.ExistsAsync(chekkeyname);
|
||
}
|
||
}
|
||
if (!isExists)
|
||
{
|
||
isExists = wx_msgkey.HasMsgKey(chekkeyname);//redis中找不到,就再从数据库中找一次
|
||
}
|
||
#endregion
|
||
|
||
|
||
if (!isExists)
|
||
{
|
||
if (content.talker.Contains("chatroom"))
|
||
{
|
||
if (content.isSend == 1 && (content.content == null || content.content.IndexOf(":") == -1))
|
||
{
|
||
content.content = content.username + ":" + content.content;
|
||
}
|
||
await _redisMsg.SetAsync(chekkeyname, string.Empty, span);
|
||
}
|
||
else
|
||
await _redisMsg.SetAsync(chekkeyname, string.Empty, span);
|
||
ret = await PushRedisAndPublish<message>(content, "message");
|
||
//ret = await PushRedisAndPublish<message>(content, "list_message");
|
||
wx_msgkey.CheckAndSetKey(chekkeyname);
|
||
}
|
||
if (ret)
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "success" };
|
||
return new JsonResult<string> { result = false, retcode = (int)EnumInterfaceErrcode.调用成功但有错误, retmsg = "successbuterr" };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error("错误JSON:" + Utility.ConvertToJSON(content) + ex.ToString());
|
||
return new JsonResult<string> { result = false, retcode = (int)EnumInterfaceErrcode.系统错误, retmsg = null };
|
||
}
|
||
}
|
||
|
||
public JsonResult<string> AlivePut(alive info)
|
||
{
|
||
info.lasttime = DateTime.Now.ToString();
|
||
ValidationErrors errors = new ValidationErrors();
|
||
string uin = string.Empty;
|
||
try
|
||
{
|
||
uin = _aliveImeiBll.AliveUpload(info.imei, info.username, info.version, info.uin, ref errors);//改成过程逻辑方式
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error("心跳异常:" + ex.ToString());
|
||
errors.Add(ex.ToString());
|
||
}
|
||
|
||
if (errors.Count == 0)
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = uin };
|
||
return new JsonResult<string> { result = false, retcode = (int)EnumInterfaceErrcode.调用成功但有错误, retmsg = "调用成功但有错误" };
|
||
}
|
||
public JsonResult<MsgConfig> MsgConfigGet(string username)
|
||
{
|
||
MsgConfig msg = new MsgConfig() { fileCreateTime = 0, friendCreateTime = 0, msgCreateTime = 0 };
|
||
ValidationErrors errors = new ValidationErrors();
|
||
try
|
||
{
|
||
Wx_MsgConfig msgconfig = _rcontact.GetMsgConfig(username);
|
||
msg.msgCreateTime = msgconfig.createTime;
|
||
msg.friendCreateTime = msgconfig.friendCreateTime.HasValue ? Utility.ConvertDateTimeToInt(msgconfig.friendCreateTime.Value) : 0;
|
||
msg.fileCreateTime = msgconfig.fileCreateTime;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error("获取消息配置异常:" + ex.ToString());
|
||
errors.Add(ex.ToString());
|
||
}
|
||
if (errors.Count == 0)
|
||
return new JsonResult<MsgConfig> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = msg };
|
||
return new JsonResult<MsgConfig> { result = false, retcode = (int)EnumInterfaceErrcode.调用成功但有错误, retmsg = msg };
|
||
}
|
||
|
||
public JsonResult<IList<MessageHisViewModel>> MessageGet(string userName)
|
||
{
|
||
if (string.IsNullOrEmpty(userName))
|
||
return new JsonResult<IList<MessageHisViewModel>> { result = false, retcode = (int)EnumInterfaceErrcode.参数错误, retmsg = null };
|
||
try
|
||
{
|
||
var list = GetMessages(userName);
|
||
return new JsonResult<IList<MessageHisViewModel>> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = list };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.ToString());
|
||
return new JsonResult<IList<MessageHisViewModel>> { result = false, retcode = (int)EnumInterfaceErrcode.系统错误, retmsg = null };
|
||
}
|
||
|
||
}
|
||
|
||
public async Task<JsonResult<string>> FriendAndRcontactPut(friendAndRcontact friend)
|
||
{
|
||
try
|
||
{
|
||
//LogHelper.Info("friend.jobusername:" + friend.jobusername + ",friend.jobwxusername:" + friend.jobwxusername + ",item.username:" + friend.username);
|
||
var ret = true;
|
||
Rcontact_RK rk = new Rcontact_RK();
|
||
rcontact item = new rcontact();
|
||
item.upstatus = friend.upstatus;
|
||
item.alias = friend.alias;
|
||
item.conRemark = friend.conRemark;
|
||
item.nickname = friend.nickname;
|
||
item.jobwxusername = friend.jobusername;
|
||
item.username = friend.talker;
|
||
#region
|
||
item.alias = HttpUtility.UrlDecode(item.alias, Encoding.UTF8);
|
||
item.nickname = HttpUtility.UrlDecode(item.nickname, Encoding.UTF8);
|
||
item.conRemark = HttpUtility.UrlDecode(item.conRemark, Encoding.UTF8);
|
||
item.type = friend.rcontactType;
|
||
#endregion
|
||
|
||
if (item.username != item.jobwxusername)
|
||
{
|
||
decimal pici = _rcontact.extractToBeFriendsDataFromMsg(friend.type, friend.talker, friend.jobusername, DateTimeTool.GetTimeFromLinuxTime(friend.createtime), ref ret);
|
||
//LogHelper.Info("ret:"+ret);
|
||
if (pici > 0)
|
||
{
|
||
//MsgHelper msg = new MsgHelper(EnumMsgs.SendMsg);
|
||
//var messageDto = new MessageQueueDTO() { MsgType = pici, MsgData = "web_push_updateUser" };
|
||
//msg.SendMsg(messageDto);//触发推送通知
|
||
}
|
||
}
|
||
|
||
|
||
/// var key = item.username == item.jobwxusername ? "rcontact1" : "rcontact0";
|
||
// var username = await PushRcontactAsync<rcontact>(item, key, item.jobwxusername, item.username, item.alias, item.conRemark);
|
||
if (item.username == item.jobwxusername)
|
||
{
|
||
if (rk.WxWorkAccount(item) == false)
|
||
{
|
||
ret = false;
|
||
// LogHelper.Info("WxWorkAccount:" + ret);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//LogHelper.Info("11friend.jobwxusername:" + item.jobwxusername + ",item.username:" + item.username);
|
||
if (rk.WxRcontact(item) == false)
|
||
{
|
||
ret = false;
|
||
//LogHelper.Info("WxRcontact:" + ret);
|
||
}
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(friend.resid))//客户ID 不为空 进行关系绑定
|
||
{
|
||
// LogHelper.Info("数据:"+JsonConvert.SerializeObject(friend));
|
||
wx_tsaddfriend.AddFriendRelation(friend.jobusername, friend.username, friend.resid, DateTimeTool.GetTimeFromLinuxTime(friend.createtime));
|
||
}
|
||
//LogHelper.Info("ret:" + ret);
|
||
if (ret)
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "调用成功" };
|
||
else
|
||
return new JsonResult<string> { result = false, retcode = (int)EnumInterfaceErrcode.系统错误, retmsg = "执行错误" };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//LogHelper.Info("出现错误!");
|
||
LogHelper.Error(ex.ToString());
|
||
return new JsonResult<string> { result = false, retcode = (int)EnumInterfaceErrcode.系统错误, retmsg = "系统出错" };
|
||
}
|
||
}
|
||
|
||
#region private method
|
||
private async Task<string> PushRcontactAsync<T>(T model, string key, string jobWxUserName, string userName, string alias, string conRemark)
|
||
{
|
||
try
|
||
{
|
||
//如果是工作微信直接写入队列(更新工作微信的信息),不是的话写入联系人队列(根据jobwxusername,username,alias,conRemark判断是否存在,存在了不更新,不存在写入队列)
|
||
if (key == "rcontact1")
|
||
{
|
||
await PushRedisAndPublish<T>(model, key);//写入队列
|
||
}
|
||
else
|
||
{
|
||
var isExists = await _redisSet.Contains(WxFix + jobWxUserName, userName + ":" + alias + ":" + conRemark);
|
||
if (!isExists)
|
||
{
|
||
var ret = await PushRedisAndPublish<T>(model, key);//写入队列
|
||
if (ret)
|
||
await _redisSet.AddAsync(WxFix + jobWxUserName, userName + ":" + alias + ":" + conRemark); //写入微信好友关系
|
||
}
|
||
}
|
||
|
||
return string.Empty;
|
||
}
|
||
catch
|
||
{
|
||
return userName;
|
||
}
|
||
}
|
||
|
||
private async Task<bool> PushRedisAndPublish<T>(T model, string key)
|
||
{
|
||
try
|
||
{
|
||
//写入队列
|
||
var result = await new RedisList<T>().LeftPushAsync(key, model);
|
||
if (result > 0)
|
||
{
|
||
//发送订阅通知
|
||
await _sub.PublishAsync("sub:" + key, "");
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.ToString());
|
||
return false;
|
||
}
|
||
|
||
}
|
||
|
||
private IList<MessageHisViewModel> GetMessages(string userName)
|
||
{
|
||
var sql = "select * from wx_message" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + " where username = @username order by createtime desc";
|
||
var para = new List<SqlParameter>()
|
||
{
|
||
new SqlParameter("@username", userName)
|
||
};
|
||
var ds = SqlHelper.GetDataSet(SqlHelper.DatabaseType.AYCRM, sql, CommandType.Text, para.ToArray());
|
||
var list = new List<MessageHisViewModel>();
|
||
foreach (DataRow dataRow in ds.Tables[0].Rows)
|
||
{
|
||
var model = new MessageHisViewModel
|
||
{
|
||
MSGSVRID = string.Format("{0}", dataRow["msgsvrid"]),
|
||
NICKNAME = string.Format("{0}", dataRow["nickname"]),
|
||
USERNAME = string.Format("{0}", dataRow["username"]),
|
||
CREATETIME = long.Parse(string.Format("{0}", dataRow["createtime"])),
|
||
TALKER = string.Format("{0}", dataRow["talker"]),
|
||
MSG_CONTENT = string.Format("{0}", dataRow["msgcontent"]),
|
||
MSG_URL = string.Format("{0}", dataRow["msgurl"]),
|
||
MSG_TYPE = string.Format("{0}", dataRow["msgtype"])
|
||
};
|
||
if (string.IsNullOrEmpty(model.MSG_URL))
|
||
{
|
||
var hasFile = HasFile(model.MSG_TYPE == null ? 0 : Int32.Parse(model.MSG_TYPE));
|
||
if (hasFile)
|
||
{
|
||
if (model.MSGSVRID != null)
|
||
{
|
||
model.MSG_URL = "/html/go.html?id=" + model.MSGSVRID;
|
||
}
|
||
}
|
||
else
|
||
model.MSG_URL = "";
|
||
|
||
}
|
||
list.Add(model);
|
||
}
|
||
return list;
|
||
}
|
||
private bool HasFile(int typeId)
|
||
{
|
||
bool ret = false;
|
||
switch (typeId)
|
||
{
|
||
case 3:
|
||
ret = true;
|
||
break;
|
||
case 34:
|
||
ret = true;
|
||
break;
|
||
case 47:
|
||
ret = true;
|
||
break;
|
||
case 62:
|
||
ret = true;
|
||
break;
|
||
case 49:
|
||
ret = true;
|
||
break;
|
||
default:
|
||
ret = false;
|
||
break;
|
||
}
|
||
return ret;
|
||
}
|
||
#endregion
|
||
|
||
public JsonResult<string> AppletMsg(AppletMsgModel appletMsg)
|
||
{
|
||
LogHelper.Info(string.Format("FromUserName:{0},MsgId:{1},MsgType:{2},ToUserName:{3},Content:{4}", appletMsg.FromUserName, appletMsg.MsgId, appletMsg.MsgType, appletMsg.ToUserName, appletMsg.Content));
|
||
return new JsonResult<string> { result = false, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "成功" };
|
||
}
|
||
|
||
|
||
public JsonResult<string> TSExecInfoPut(TSExecInfo info)
|
||
{
|
||
ValidationErrors errors = new ValidationErrors();
|
||
try
|
||
{
|
||
DateTime? starttime = null;
|
||
DateTime? endtime = null;
|
||
if (info.starttime != 0)
|
||
{
|
||
starttime = Utility.JavaLongToDateTime(info.starttime);
|
||
}
|
||
if (info.endTime != 0)
|
||
{
|
||
endtime = Utility.JavaLongToDateTime(info.endTime);
|
||
}
|
||
|
||
info.remarks = HttpUtility.UrlDecode(info.remarks, Encoding.UTF8);
|
||
//v_isStart number:= null,v_startTime date:= null,v_isEnd number:= null,v_endTime
|
||
wx_tsaddfriend.UpdatePiciExecStatus(info.pici, info.isStart, starttime, info.isEnd, endtime, info.remarks, ref errors);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error("心跳异常:" + ex.ToString());
|
||
errors.Add(ex.ToString());
|
||
}
|
||
if (errors.Count == 0)
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "调用成功" };
|
||
return new JsonResult<string> { result = false, retcode = (int)EnumInterfaceErrcode.调用成功但有错误, retmsg = "调用成功但有错误" };
|
||
}
|
||
|
||
public JsonResult<string> GetNewestScriptVersion()
|
||
{
|
||
ValidationErrors errors = new ValidationErrors();
|
||
tsscriptversion ver = new tsscriptversion();
|
||
try
|
||
{
|
||
|
||
DataTable dataTable = wx_tsaddfriend.GetNewestScriptVersion();
|
||
ver.content = dataTable.Rows[0]["content"].ToString();
|
||
ver.version = dataTable.Rows[0]["version"].ToString();
|
||
ver.scriptname = dataTable.Rows[0]["scriptname"].ToString();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error("脚本异常:" + ex.ToString());
|
||
errors.Add(ex.ToString());
|
||
}
|
||
if (errors.Count == 0)
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = JsonConvert.SerializeObject(ver) };
|
||
return new JsonResult<string> { result = false, retcode = (int)EnumInterfaceErrcode.调用成功但有错误, retmsg = "调用成功但有错误" };
|
||
}
|
||
|
||
public JsonResult<string> AddFriendPiciLog(IList<FriendPiciLog> logs)
|
||
{
|
||
try
|
||
{
|
||
foreach (var item in logs)
|
||
{
|
||
var zdtime = DateTimeTool.GetTimeFromLinuxTime(item.zitime);
|
||
wx_tsaddfriend.AddFriendPiciLog(item.alias, item.resid, item.eid, item.pici, item.state, item.remark, item.zitime, zdtime);
|
||
}
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "调用成功" };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.ToString());
|
||
return new JsonResult<string> { result = false, retcode = (int)EnumInterfaceErrcode.系统错误, retmsg = ex.ToString() };
|
||
}
|
||
}
|
||
|
||
public JsonResult<string> TSFriendMsgPut(tsfriendmsg friend)
|
||
{
|
||
try
|
||
{
|
||
string nresid = HttpUtility.UrlDecode(friend.resid, Encoding.UTF8);
|
||
int oneIndex = nresid.IndexOf("@");
|
||
int lastIndex = nresid.LastIndexOf("@");
|
||
nresid = nresid.Substring(oneIndex + 1, (lastIndex - oneIndex) - 1);
|
||
//LogHelper.Info("resid:" + nresid);
|
||
if (!IsNumber(nresid))
|
||
{
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "调用成功" };
|
||
}
|
||
bool result = wx_tsaddfriend.AddFriendRelation(friend.jobusername, friend.username, nresid, DateTimeTool.GetTimeFromLinuxTime(friend.createtime));
|
||
if (result)
|
||
return new JsonResult<string> { result = result, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "调用成功" };
|
||
return new JsonResult<string> { result = result, retcode = (int)EnumInterfaceErrcode.调用成功但有错误, retmsg = "调用成功但有错误" };
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex.ToString());
|
||
LogHelper.Error("错误json:" + JsonConvert.SerializeObject(friend));
|
||
return new JsonResult<string> { result = false, retcode = (int)EnumInterfaceErrcode.系统错误, retmsg = ex.ToString() };
|
||
}
|
||
}
|
||
public JsonResult<string> QunFaPiciLlogPut(QunFaPiciLog info)
|
||
{
|
||
ValidationErrors errors = new ValidationErrors();
|
||
try
|
||
{
|
||
DateTime? starttime = null;
|
||
DateTime? endtime = null;
|
||
if (info.starttime != 0)
|
||
{
|
||
starttime = Utility.JavaLongToDateTime(info.starttime);
|
||
}
|
||
if (info.endTime != 0)
|
||
{
|
||
endtime = Utility.JavaLongToDateTime(info.endTime);
|
||
}
|
||
|
||
info.remarks = HttpUtility.UrlDecode(info.remarks, Encoding.UTF8);
|
||
//v_isStart number:= null,v_startTime date:= null,v_isEnd number:= null,v_endTime
|
||
wx_tsqunworalias.UpdatePiciExecStatus(info.pici, info.isStart, starttime, info.isEnd, endtime, info.remarks, ref errors);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error("QunFaPiciLlogPut异常:" + ex.ToString());
|
||
errors.Add(ex.ToString());
|
||
}
|
||
if (errors.Count == 0)
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "调用成功" };
|
||
return new JsonResult<string> { result = false, retcode = (int)EnumInterfaceErrcode.调用成功但有错误, retmsg = "调用成功但有错误" };
|
||
}
|
||
/// <summary>
|
||
/// 判断字符串是否是数字
|
||
/// </summary>
|
||
public static bool IsNumber(string s)
|
||
{
|
||
if (string.IsNullOrWhiteSpace(s))
|
||
return false;
|
||
const string pattern = "^[0-9]*$";
|
||
Regex rx = new Regex(pattern);
|
||
return rx.IsMatch(s);
|
||
}
|
||
|
||
public JsonResult<string> Service_AlivePut(service_alive info)
|
||
{
|
||
ValidationErrors errors = new ValidationErrors();
|
||
try
|
||
{
|
||
_aliveImeiBll.ServiceAliveUpload(info.alias, info.version, info.imei, info.phonemode, ref errors);//改成过程逻辑方式
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error("心跳异常:" + ex.ToString());
|
||
errors.Add(ex.ToString());
|
||
}
|
||
|
||
if (errors.Count == 0)
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "调用成功" };
|
||
return new JsonResult<string> { result = false, retcode = (int)EnumInterfaceErrcode.调用成功但有错误, retmsg = "调用成功但有错误" };
|
||
}
|
||
|
||
public JsonResult<string> MsgBatchLog_put(batchmsg info)
|
||
{
|
||
ValidationErrors errors = new ValidationErrors();
|
||
try
|
||
{
|
||
if (!string.IsNullOrEmpty(info.remarks))
|
||
info.remarks = HttpUtility.UrlDecode(info.remarks);
|
||
wx_ts_batchmsg.BatchMsgLogUP(info, ref errors);//改成过程逻辑方式
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error("心跳异常:" + ex.ToString());
|
||
errors.Add(ex.ToString());
|
||
}
|
||
if (errors.Count == 0)
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "调用成功" };
|
||
return new JsonResult<string> { result = false, retcode = (int)EnumInterfaceErrcode.调用成功但有错误, retmsg = "调用成功但有错误" };
|
||
}
|
||
public JsonResult<string> FriendScircleContentGet(string pici)
|
||
{
|
||
try
|
||
{
|
||
decimal npici = Convert.ToInt64(pici);
|
||
DataTable tab = wx_ts_cmd.GetFriendScircleTxtByPici(npici);//改成过程逻辑方式
|
||
FriendScircleModel model = null;
|
||
|
||
if (tab != null && tab.Rows.Count > 0)
|
||
{
|
||
model = new FriendScircleModel();
|
||
model.pici = Convert.ToInt64(tab.Rows[0]["pici"]);
|
||
model.txt = HttpUtility.UrlEncode(tab.Rows[0]["txt"].ToString());
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = JsonConvert.SerializeObject(model) };
|
||
}
|
||
else
|
||
{
|
||
return new JsonResult<string> { result = false, retcode = (int)EnumInterfaceErrcode.调用成功但有错误, retmsg = "找不到数据" };
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error("获取朋友圈内容失败:" + ex.ToString());
|
||
return new JsonResult<string> { result = false, retcode = (int)EnumInterfaceErrcode.调用成功但有错误, retmsg = "调用成功但有错误" };
|
||
}
|
||
|
||
}
|
||
|
||
public JsonResult<IList<WxRcontactView>> GetWxRcontact(string resId)
|
||
{
|
||
var customer = _customerQ.getResCustomerByResId(resId);
|
||
if (customer == null)
|
||
return new JsonResult<IList<WxRcontactView>> { result = false, retcode = (int)EnumInterfaceErrcode.参数错误, retmsg = null };
|
||
var customerId = customer.CUSTOMERID;
|
||
var ds = _rcontact.GetChatUserByResId(customerId);
|
||
return new JsonResult<IList<WxRcontactView>> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = ds.ToList<WxRcontactView>() };
|
||
}
|
||
public JsonResult<IList<QwRcontactView>> GetQwRcontact(string resId)
|
||
{
|
||
var customer = _customerQ.getResCustomerByResId(resId);
|
||
if (customer == null)
|
||
return new JsonResult<IList<QwRcontactView>> { result = false, retcode = (int)EnumInterfaceErrcode.参数错误, retmsg = null };
|
||
var customerId = customer.CUSTOMERID;
|
||
var ds = _rcontact.GetChatQwByResId(customerId);
|
||
return new JsonResult<IList<QwRcontactView>> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = ds.ToList<QwRcontactView>() };
|
||
}
|
||
|
||
private static string _shareName;
|
||
private static string _isShare;
|
||
public JsonResult<string> GetWxAudio(string url)
|
||
{
|
||
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 = basePath + "audio";
|
||
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 JsonHandler.ManageMessage("未能找到文件!", false);
|
||
return new JsonResult<string> { result = false, retcode = 404, retmsg = "地址:" + amrPath };
|
||
}
|
||
|
||
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 new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = subUrl + "/audio/" + fileNameWithoutExt + ".mp3" };
|
||
}
|
||
|
||
public JsonResult<string> GetQwAudio(string url)
|
||
{
|
||
var webPath = FileUnit.GetBaseDirectory();
|
||
var exePath = webPath + "silk2mp3";
|
||
var fileNameWithoutExt = Path.GetFileNameWithoutExtension(url);
|
||
var basePath = Utility.GetSettingByKey("weworkfile");
|
||
//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 new JsonResult<string> { result = false, retcode = 404, retmsg = "" };
|
||
}
|
||
|
||
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 new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = subUrl + "/audio/" + fileNameWithoutExt + ".mp3" };
|
||
}
|
||
|
||
public JsonResult<IList<WorkOrderUser>> GetWorkOrderUser(string username)
|
||
{
|
||
try
|
||
{
|
||
DataTable table = _rcontact.GetOrderUserName(username);
|
||
if (table == null)
|
||
{
|
||
return new JsonResult<IList<WorkOrderUser>> { result = false, retcode = (int)EnumInterfaceErrcode.调用成功但有错误, retmsg = null };
|
||
}
|
||
List<WorkOrderUser> list = new List<WorkOrderUser>();
|
||
foreach (DataRow item in table.Rows)
|
||
{
|
||
WorkOrderUser user = new WorkOrderUser();
|
||
user.jobwxusername = item["jobwxusername"].ToString();
|
||
user.nickname = HttpUtility.UrlEncode(item["nickname"].ToString());
|
||
user.username = item["username"].ToString();
|
||
list.Add(user);
|
||
}
|
||
return new JsonResult<IList<WorkOrderUser>> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = list };
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
LogHelper.Error(e);
|
||
return new JsonResult<IList<WorkOrderUser>> { result = false, retcode = (int)EnumInterfaceErrcode.调用成功但有错误, retmsg = null };
|
||
}
|
||
}
|
||
|
||
|
||
public JsonResult<FastUser> GetFastUser(string username)
|
||
{
|
||
FastUser user = new FastUser();
|
||
try
|
||
{
|
||
Wx_Fast_UserModel fastmodel = wx_fast_username.GetFastModel(username);
|
||
|
||
//LogHelper.Error("fastmodel:" + JsonConvert.SerializeObject(fastmodel));
|
||
if (fastmodel == null || fastmodel.fast_main == null)
|
||
{
|
||
return new JsonResult<FastUser> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功 };
|
||
}
|
||
user = new FastUser()
|
||
{
|
||
code = fastmodel.fast_main.CODE,
|
||
jobwxusername = fastmodel.fast_main.JOBUSERNAME,
|
||
//nickname = "",// fastmodel.fast_main.JOBNICKNAME,怕有特殊字符,直接隐藏
|
||
positiontime = Convert.ToInt64(fastmodel.fast_main.POSITIONTIME),
|
||
//positiontimestr = "",// fastmodel.fast_main.POSITIONSTR.ToString("yyyy年MM月dd日HH时mm分ss秒"),
|
||
status = Convert.ToInt32(fastmodel.fast_main.STATUS),
|
||
pici = fastmodel.fast_main.PICI.ToString()
|
||
};
|
||
user.fastuserdl = new List<FastUserDL>();
|
||
if (fastmodel.fast_child != null)
|
||
{
|
||
foreach (var item in fastmodel.fast_child)
|
||
{
|
||
user.fastuserdl.Add(new FastUserDL() { username = item.USERNAME });
|
||
}
|
||
}
|
||
return new JsonResult<FastUser> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = user };
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
LogHelper.Error(e.ToString());
|
||
return new JsonResult<FastUser> { result = false, retcode = (int)EnumInterfaceErrcode.调用成功但有错误 };
|
||
}
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 完成批次
|
||
/// </summary>
|
||
/// <param name="username"></param>
|
||
/// <param name="pici"></param>
|
||
/// <returns></returns>
|
||
public JsonResult<string> FastUserComplete(string pici, string status)
|
||
{
|
||
try
|
||
{
|
||
if (string.IsNullOrEmpty(status))
|
||
{
|
||
return new JsonResult<string> { result = false, retcode = (int)EnumInterfaceErrcode.调用成功但有错误, retmsg = "参数错误" };
|
||
}
|
||
int nstatus = Convert.ToInt32(status);
|
||
bool result = wx_fast_username.UpdateComplete(pici, nstatus);
|
||
return new JsonResult<string> { result = true, retcode = (int)EnumInterfaceErrcode.调用成功, retmsg = "修改[" + status + "]成功" };
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
LogHelper.Error(e);
|
||
return new JsonResult<string> { result = false, retcode = (int)EnumInterfaceErrcode.调用成功但有错误, retmsg = "修改[" + status + "]错误" };
|
||
}
|
||
}
|
||
}
|
||
public class FriendScircleModel
|
||
{
|
||
public long pici { get; set; }
|
||
public string txt { get; set; }
|
||
}
|
||
public class MsgConfig
|
||
{
|
||
public long msgCreateTime { get; set; }
|
||
public long fileCreateTime { get; set; }
|
||
|
||
public long friendCreateTime { get; set; }
|
||
}
|
||
|
||
public class MessageHisViewModel
|
||
{
|
||
public string MSGSVRID { get; set; }
|
||
public string NICKNAME { get; set; }
|
||
public string USERNAME { get; set; }
|
||
public long CREATETIME { get; set; }
|
||
public string TALKER { get; set; }
|
||
public string MSG_CONTENT { get; set; }
|
||
public string MSG_URL { get; set; }
|
||
public string MSG_TYPE { get; set; }
|
||
}
|
||
public class AppletMsgModel
|
||
{
|
||
public string ToUserName { get; set; }
|
||
public string FromUserName { get; set; }
|
||
public long CreateTime { get; set; }
|
||
public string MsgType { get; set; }
|
||
public string Content { get; set; }
|
||
public long MsgId { get; set; }
|
||
|
||
}
|
||
|
||
public class WxRcontactView
|
||
{
|
||
public string username { get; set; }
|
||
public string jobwxusername { get; set; }
|
||
public string alias { get; set; }
|
||
public string conremark { get; set; }
|
||
public string nickname { get; set; }
|
||
public string resid { get; set; }
|
||
public decimal inneruserid { get; set; }
|
||
public decimal eid { get; set; }
|
||
public string uname { get; set; }
|
||
public string wokalias { get; set; }
|
||
}
|
||
public class WorkOrderUser
|
||
{
|
||
public string username { get; set; }
|
||
public string jobwxusername { get; set; }
|
||
public string nickname { get; set; }
|
||
|
||
}
|
||
|
||
public class FastUser
|
||
{
|
||
public string pici { get; set; }
|
||
/// <summary>
|
||
/// 编码
|
||
/// </summary>
|
||
public string code { get; set; }
|
||
public string jobwxusername { get; set; }
|
||
//public string nickname { get; set; }
|
||
/// <summary>
|
||
/// 上传位置
|
||
/// </summary>
|
||
public long positiontime { get; set; }
|
||
/// <summary>
|
||
/// 状态
|
||
/// </summary>
|
||
public int status { get; set; }
|
||
//public string positiontimestr { get; set; }
|
||
public List<FastUserDL> fastuserdl { get; set; }
|
||
}
|
||
public class FastUserDL
|
||
{
|
||
public string username { get; set; }
|
||
}
|
||
|
||
public class QwRcontactView
|
||
{
|
||
public string vid { get; set; }
|
||
public string remoteid { get; set; }
|
||
public string customername { get; set; }
|
||
public string companyremark { get; set; }
|
||
public string realremark { get; set; }
|
||
public string remarkphone { get; set; }
|
||
public string remarks { get; set; }
|
||
public string username { get; set; }
|
||
public string realname { get; set; }
|
||
}
|
||
|
||
|
||
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());
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
[ServiceContract]
|
||
public interface IWxMessageSvr
|
||
{
|
||
[OperationContract]
|
||
[WebInvoke(Method = "POST",
|
||
RequestFormat = WebMessageFormat.Json,
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "RContact/Put")]
|
||
Task<JsonResult<string>> RContactPut(IList<rcontact> content);
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "POST",
|
||
RequestFormat = WebMessageFormat.Json,
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "Friend/Put")]
|
||
JsonResult<string> FriendPut(IList<friend> content);
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "POST",
|
||
RequestFormat = WebMessageFormat.Json,
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "Message/Put")]
|
||
Task<JsonResult<string>> MessagePut(message content);
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "*",
|
||
RequestFormat = WebMessageFormat.Json,
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "Alive/Put")]
|
||
JsonResult<string> AlivePut(alive content);
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "*",
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "Message/Get/{username}")]
|
||
JsonResult<IList<MessageHisViewModel>> MessageGet(string userName);
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "*",
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "MsgConfig/Get/{username}")]
|
||
JsonResult<MsgConfig> MsgConfigGet(string username);
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "POST",
|
||
RequestFormat = WebMessageFormat.Json,
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "FriendAndRcontactPut/Put")]
|
||
Task<JsonResult<string>> FriendAndRcontactPut(friendAndRcontact friend);
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "POST",
|
||
RequestFormat = WebMessageFormat.Json,
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "AppletMsg/Put")]
|
||
JsonResult<string> AppletMsg(AppletMsgModel appletMsg);
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "*",
|
||
RequestFormat = WebMessageFormat.Json,
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "TSExecInfo/Put")]
|
||
JsonResult<string> TSExecInfoPut(TSExecInfo info);
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "*",
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
UriTemplate = "NewestScriptVersion/Get")]
|
||
JsonResult<string> GetNewestScriptVersion();
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "*",
|
||
RequestFormat = WebMessageFormat.Json,
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "AddFriendPiciLog/Put")]
|
||
JsonResult<string> AddFriendPiciLog(IList<FriendPiciLog> content);
|
||
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "POST",
|
||
RequestFormat = WebMessageFormat.Json,
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "TSFriendMsgPut/Put")]
|
||
JsonResult<string> TSFriendMsgPut(tsfriendmsg msg);
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "*",
|
||
RequestFormat = WebMessageFormat.Json,
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "QunFaPiciLlog/Put")]
|
||
JsonResult<string> QunFaPiciLlogPut(QunFaPiciLog info);
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "*",
|
||
RequestFormat = WebMessageFormat.Json,
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "Service_Alive/Put")]
|
||
JsonResult<string> Service_AlivePut(service_alive content);
|
||
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "*",
|
||
RequestFormat = WebMessageFormat.Json,
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "MsgBatchLog/Put")]
|
||
JsonResult<string> MsgBatchLog_put(batchmsg info);
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "*",
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "FriendScircleContent/Get/{pici}")]
|
||
JsonResult<string> FriendScircleContentGet(string pici);
|
||
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "*",
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "WxRcontact/Get/{resId}")]
|
||
JsonResult<IList<WxRcontactView>> GetWxRcontact(string resId);
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "*",
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "QwRcontact/Get/{resId}")]
|
||
JsonResult<IList<QwRcontactView>> GetQwRcontact(string resId);
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "*",
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
RequestFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "WxAudio/Get?url={url}")]
|
||
JsonResult<string> GetWxAudio(string url);
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "*",
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
RequestFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "QxAudio/Get?url={url}")]
|
||
JsonResult<string> GetQwAudio(string url);
|
||
|
||
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "*",
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "WorkAccount/OrderUserGet/{username}")]
|
||
JsonResult<IList<WorkOrderUser>> GetWorkOrderUser(string username);
|
||
|
||
|
||
[OperationContract]
|
||
[WebInvoke(Method = "*",
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "FastUserGet/{username}")]
|
||
JsonResult<FastUser> GetFastUser(string username);
|
||
|
||
//完成批次
|
||
[OperationContract]
|
||
[WebInvoke(Method = "*",
|
||
ResponseFormat = WebMessageFormat.Json,
|
||
BodyStyle = WebMessageBodyStyle.Bare,
|
||
UriTemplate = "FastUserComplete/{pici}/{status}")]
|
||
JsonResult<string> FastUserComplete(string pici, string status);
|
||
|
||
}
|
||
}
|
||
|
||
[DataContract]
|
||
public class JsonResult<T>
|
||
{
|
||
[DataMember]
|
||
public bool result { get; set; }
|
||
[DataMember]
|
||
public int retcode { get; set; }
|
||
[DataMember]
|
||
public T retmsg { get; set; }
|
||
}
|
||
|
||
|