123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775 |
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace LYFZ.WanYuKeFu
- {
- public partial class BackgroundProcess : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- string type = "";
- if (Request.QueryString["type"] != null)
- {
- type=Request.QueryString["type"].ToLower().Trim();
- }
- switch(type)
- {
- case "getusername":
- #region 获取登录用名
- if (LYFZ.Command.Command_Session.GetObject("User") != null)
- {
- LYFZ.WanYuKeFuData.Model.User retUser = (LYFZ.WanYuKeFuData.Model.User)LYFZ.Command.Command_Session.GetObject("User");
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求成功, retUser.UserName)));
- }
- else {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败,"未登录")));
- }
- #endregion
- break;
- case "getuserinfo":
- #region 获取登录用户信息
- if (LYFZ.Command.Command_Session.GetObject("User") != null)
- {
- LYFZ.WanYuKeFuData.Model.User retUser = (LYFZ.WanYuKeFuData.Model.User)LYFZ.Command.Command_Session.GetObject("User");
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求成功, JsonConvert.SerializeObject(retUser))));
- }
- else
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, "未登录")));
- }
- #endregion
- break;
- case "updatepwd":
- #region 修改当前登录用户密码
- if (Request.QueryString["newpwd"] != null)
- {
- string newpwd = Request.QueryString["newpwd"];
- if (LYFZ.Command.Command_Session.GetObject("User") != null)
- {
- LYFZ.WanYuKeFuData.Model.User retUser = (LYFZ.WanYuKeFuData.Model.User)LYFZ.Command.Command_Session.GetObject("User");
- retUser.Password = LYFZ.WinAPI.SDKSecurity.MD5Encrypt(newpwd);
- LYFZ.WanYuKeFuData.DAL.User userDal = new LYFZ.WanYuKeFuData.DAL.User(Global.DbConn);
- if (userDal.Update(retUser))
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求成功, "修改成功")));
- }
- else {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, "更新数据库时失败")));
- }
- }
- else
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, "未登录")));
- }
- }
- else {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.参数错误, "新密码不能为空")));
- }
- #endregion
- break;
- case "pushuserlist":
- PushUserList();
- break;
- case "pushmsglist":
- PushMsgList();
- break;
- case "delpushuser":
- DelPushUser();
- break;
- case "delpusmsg":
- DelPusMsg();
- break;
- case "getpushuser":
- GetPushUserList();
- break;
- case "getpushqiyue":
- GetPushQiYueList();
- break;
- case "sendpushmsg":
- SendPushMsg();
- break;
- case "retransmission":
- Retransmission();
- break;
- case "registerpushuser":
- RegisterPushUser();
- break;
- case "badgeclear":
- BadgeClear();
- break;
- case "read":
- SetMsgRead();
- break;
- case "usermsglist":
- GetSpecifiedUserMsgList();
- break;
- case "unreadcount":
- GetUnreadCount();
- break;
- case "wanyukfurl":
- WanYuKFUrl();
- break;
- default:
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.参数错误, "参数错误")));
- break;
- }
-
- }
- }
- LYFZ.WanYuKeFuData.DAL.MsgReadStatus msgReadDal = new LYFZ.WanYuKeFuData.DAL.MsgReadStatus(Global.DbConn);
- /// <summary>
- /// 获取网鱼客服系统url
- /// </summary>
- void WanYuKFUrl()
- {
- try
- {
-
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求成功, LYFZ.WanYuKeFu.ErpGetuiApiSDK.WanYuKFUrl)));
-
- }
- catch (Exception ex)
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, String.Format("错误:{0}", ex.Message))));
- }
- }
- /// <summary>
- /// 设置消息的已读状态
- /// </summary>
- void SetMsgRead()
- {
- try
- {
- long msgID = Convert.ToInt64(GetParameterValue("msgid"));
- string userID = GetParameterValue("userid").Trim();
- if (!msgReadDal.CheckMsgReadExists(msgID, userID))
- {
- LYFZ.WanYuKeFuData.Model.MsgReadStatus msgReadModel = new WanYuKeFuData.Model.MsgReadStatus();
- msgReadModel.MsgID = msgID;
- msgReadModel.UserID = userID.Trim();
- msgReadModel.ReadStatus = 1;
- msgReadModel.ReadTime = DateTime.Now.ToJavaScriptTimeStamp();
- if (msgReadDal.Add(msgReadModel))
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求成功, "OK")));
- }
- }
- else {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求成功, "OK")));
- }
- }
- catch (Exception ex)
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, String.Format("错误:{0}", ex.Message))));
- }
- }
- /// <summary>
- /// 清除badge
- /// </summary>
- void BadgeClear()
- {
- try
- {
- string cid = GetParameterValue("cid");
- int badge = GetParameterIntValue("badge");
- msgPushUserDal.BadgeClear(cid, badge);
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求成功, String.Format("已成功设置为 {0}", badge))));
- }
- catch (Exception ex){
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.参数错误,String.Format("错误:{0}",ex.Message))));
- }
- }
- string GetParameterValue(string key)
- {
- if (Request[key] != null)
- {
- return Request[key];
- }
- else {
- return "";
- }
- }
- int GetParameterIntValue(string key)
- {
- string intValue = GetParameterValue(key);
- try
- {
- if (!String.IsNullOrEmpty(intValue))
- {
- return Convert.ToInt32(intValue);
- }
- else
- {
- return 0;
- }
- }
- catch {
- return 0;
- }
- }
- LYFZ.WanYuKeFuData.DAL.GTMessagePushUser msgPushUserDal = new LYFZ.WanYuKeFuData.DAL.GTMessagePushUser(Global.DbConn);
- /// <summary>
- /// 注册推送用户设备
- /// </summary>
- void RegisterPushUser()
- {
- try
- {
- int userType = GetParameterIntValue("uType");
- string userID = "0";
- string userName = "0";
- int appState = 1;
- string tempAppSatae = GetParameterValue("appState");
- if (!String.IsNullOrEmpty(tempAppSatae))
- {
- if (tempAppSatae.Trim() == "0")
- {
- appState = 0;
- }
- else
- {
- appState = 1;
- }
- }
- string GTClientID = GetParameterValue("CID");
- string LYFZAPPID = GetParameterValue("LYFZAPPID");
- if (String.IsNullOrWhiteSpace(LYFZAPPID))
- {
- LYFZAPPID = "wangyuapp";
- }
- string AppVersion = GetParameterValue("AppVersion");
- if (String.IsNullOrWhiteSpace(AppVersion))
- {
- AppVersion = "1.0";
- }
- if (!String.IsNullOrEmpty(GTClientID))
- {
- LYFZ.WanYuKeFuData.Model.GTMessagePushUser pushUser = msgPushUserDal.GetModel("GTClientID", GTClientID);
- pushUser.GTType = userType;
- pushUser.GTState = 1;
- pushUser.Badge = 0;
- pushUser.APPState = appState;
- pushUser.UserID = userID;
- pushUser.UserName = userName;
- pushUser.GTClientID = GTClientID;
- pushUser.UpdateTime = DateTime.Now.ToJavaScriptTimeStamp();
- pushUser.AppVersion = AppVersion;
- pushUser.LYFZAPPID = LYFZAPPID;
- bool registerState = false;
- if (pushUser.ID > 0)
- {
- registerState = msgPushUserDal.Update(pushUser);
- }
- else
- {
- pushUser.CreationTime = DateTime.Now.ToJavaScriptTimeStamp();
- registerState = msgPushUserDal.Add(pushUser);
- }
- if (registerState)
- {
- msgPushDal.DelMsgHistoryRecord(DateTime.Now.AddDays(-90).ToJavaScriptTimeStamp());
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求成功, "设备注册成功")));
- }
- else
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, "设备注册失败,更新数据库时失败")));
- }
- }
- else
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.参数错误, "设备注册失败,参数错误")));
- }
- }
- catch (Exception ex)
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, "设备注册时出错:" + ex.Message)));
- }
- }
- /// <summary>
- /// 重发
- /// </summary>
- void Retransmission()
- {
- try
- {
- string msgid = GetParameterValue("msgid");
- LYFZ.WanYuKeFuData.Model.GTMsgRecord msgRecord = msgPushDal.GetModel(Convert.ToInt64(msgid));
- if (msgRecord != null && msgRecord.ID > 0)
- {
- msgRecord.SendTime = DateTime.Now.ToJavaScriptTimeStamp();
- string retString = ErpGetuiApiSDK.pushMessageToSingleBatchApp(msgRecord, msgPushUserDal);
- if (retString.ToLower().Contains("result\":\"ok\","))
- {
- msgRecord.State = 1;
- }
- else
- {
- msgRecord.State = 0;
- }
- if (msgRecord.State == 1)
- {
- if (msgPushDal.Update(msgRecord))
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求成功, "重发成功", new { msgid = msgRecord.ID.ToString() })));
- }
- else
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, "更新数据库时失败")));
- }
- }
- else {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, "向客户端推送时失败")));
- }
- }
- else
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, "没有找到指定ID 的数据")));
- }
- }
- catch (Exception ex)
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, "重推时出错:"+ex.Message)));
- }
- }
- LYFZ.WanYuKeFuData.DAL.GTMsgRecord msgPushDal = new LYFZ.WanYuKeFuData.DAL.GTMsgRecord(Global.DbConn);
- /// <summary>
- /// 推送消息
- /// </summary>
- void SendPushMsg()
- {
- try
- {
- string title = GetParameterValue("title");
- string description = GetParameterValue("description");
- string msgData = GetParameterValue("msgData");//.Replace("$_$", "&");
-
- //目标用户 0 为全部用户 1 为特定用户
- int TargetUser = GetParameterIntValue("TargetUser");
- string targetCidList = GetParameterValue("targetList").Trim(',');
- string targetList = String.Format(",{0},", targetCidList);
- string Platform = GetParameterValue("Platform").Trim(',');
- if (String.IsNullOrEmpty(Platform))
- {
- Platform = "IOS,Android";
- }
- if (String.IsNullOrEmpty(title))
- {
- title = "APP消息提醒";
- }
- if (targetList.Split(',').Length <= 100)
- {
- if (!String.IsNullOrEmpty(description) && !String.IsNullOrEmpty(msgData) && (TargetUser == 0 || (TargetUser > 0 && !String.IsNullOrEmpty(targetList))))
- {
- LYFZ.WanYuKeFuData.Model.GTMsgRecord msgRecord = new WanYuKeFuData.Model.GTMsgRecord();
- msgRecord.ID = LYFZ.WinAPI.CustomPublicMethod.GenerateId();
- msgRecord.Title = title;
- msgRecord.Description = description;
- msgRecord.MsgData = msgData;
- msgRecord.Platform = Platform;
- msgRecord.TargetUser = TargetUser;
- msgRecord.TargetList = targetList;
- msgRecord.SendTime = DateTime.Now.ToJavaScriptTimeStamp();
-
- string retString = ErpGetuiApiSDK.pushMessageToSingleBatchApp(msgRecord, msgPushUserDal);
- if (retString.ToLower().Contains("result\":\"ok\","))
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求成功, "消息推送成功")));
- }
- else if (retString.ToLower().Contains("result\":\"-900000\","))
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.没有找到目标用户注册的APP设备, "消息推送失败,指定的用户还有没使用过APP")));
- }
- else {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.推送失败, retString)));
- }
-
- }
- else
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.参数错误, "消息推送失败,参数错误")));
- }
- }
- else {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.推送失败, "每次推送用户数不能超过 100 个用户")));
- }
- }
- catch (Exception ex)
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, "消息推送时出错:" + ex.Message)));
- }
- }
- void GetPushUserList()
- {
- string filedOrder = "CreationTime desc";
- if (String.IsNullOrEmpty(filedOrder))
- {
- filedOrder = "id desc";
- }
- string whereString = "1=1";
- int currentPage = 1;
- int pageSize = 50;
- int _TotalCount = 0;//总记录数
- if (Request.QueryString["page"] != null)
- {
- currentPage = Convert.ToInt32(Request.QueryString["page"]);
- }
- if (Request.QueryString["pageSize"] != null)
- {
- pageSize = Convert.ToInt32(Request.QueryString["pageSize"]);
- }
-
- if (Request.QueryString["keywords"] != null && Request.QueryString["keywords"].ToString().Trim().Length > 0)
- {
- whereString = String.Format("GTClientID like '%{0}%'", Request.QueryString["keywords"].ToString().Trim());
- }
- //if (Request.QueryString["gttype"] != null && Request.QueryString["gttype"].ToString().Trim().Length>0)
- //{
- // whereString += " and [GTType]=" + Request.QueryString["gttype"].ToString();
- //}
- System.Data.DataTable tb = msgPushUserDal.PagingQueryDataTable("tb_GTMessagePushUser", "[GTType],[GTClientID],[GTState],[CreationTime] ,[UpdateTime]", filedOrder, whereString, pageSize, currentPage, out _TotalCount).Tables[0];
- dynamic data = new
- {
- TotalCount = _TotalCount,
- ListData = tb//JsonConvert.SerializeObject(tb)
- };
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求成功, data)));
- //返回参数
- }
- void GetPushQiYueList()
- {
- string filedOrder = "EnterpriseID desc";
- string whereString = "1=1";
- int currentPage = 1;
- int pageSize = 50;
- int _TotalCount = 0;//总记录数
- if (Request.QueryString["page"] != null)
- {
- currentPage = Convert.ToInt32(Request.QueryString["page"]);
- }
- if (Request.QueryString["pageSize"] != null)
- {
- pageSize = Convert.ToInt32(Request.QueryString["pageSize"]);
- }
- if (Request.QueryString["keywords"] != null && Request.QueryString["keywords"].ToString().Trim().Length > 0)
- {
- whereString = String.Format("EnterpriseID like '%{0}%' or EnterpriseName like '%{0}%'", Request.QueryString["keywords"].ToString().Trim());
- }
- System.Data.DataTable tb = msgPushUserDal.PagingQueryDataTable("view_GTEnterpriseIDList", "[EnterpriseID],[EnterpriseName]", filedOrder, whereString, pageSize, currentPage, out _TotalCount).Tables[0];
- dynamic data = new
- {
- TotalCount = _TotalCount,
- ListData = tb//JsonConvert.SerializeObject(tb)
- };
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求成功, data)));
- //返回参数
- }
- void DelPushUser()
- {
- try
- {
- string delIDList = "";
- if (Request.QueryString["delID"] != null)
- {
- delIDList = Request.QueryString["delID"].Trim(',');
- }
- if (msgPushUserDal.Delete(String.Format("id in(" + delIDList + ")")))
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求成功,"删除成功")));
-
- }
- else {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, "删除失败")));
- }
- }
- catch (Exception ex)
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, "删除时出错:" + ex.Message)));
- }
- }
- void DelPusMsg() {
- try
- {
- string delIDList = "";
- if (Request["delID"] != null)
- {
- delIDList = Request["delID"].Trim(',');
- }
- if (msgPushDal.Delete(String.Format("id in(" + delIDList + ")")))
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求成功, "删除成功")));
- }
- else
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, "删除失败")));
- }
- }
- catch (Exception ex)
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, "删除时出错:" + ex.Message)));
- }
- }
- /// <summary>
- /// 获取推送用户集合 分页
- /// </summary>
- void PushUserList()
- {
- try
- {
- string filedOrder = "CreationTime desc";
- if (String.IsNullOrEmpty(filedOrder))
- {
- filedOrder = "id desc";
- }
- string whereString = "1=1";
- int currentPage = 1;
- int pageSize = 50;
- int _TotalCount = 0;//总记录数
- if (Request.QueryString["page"] != null)
- {
- currentPage = Convert.ToInt32(Request.QueryString["page"]);
- }
- if (Request.QueryString["pageSize"] != null)
- {
- pageSize = Convert.ToInt32(Request.QueryString["pageSize"]);
- }
- string keywords = Request.QueryString["keywords"];
- if (!String.IsNullOrWhiteSpace(keywords))
- {
- whereString = String.Format("(GTClientID like '%{0}%' or LYFZAPPID='{0}' or AppVersion='{0}')", keywords);
- }
- System.Data.DataTable tb = msgPushUserDal.PagingQueryDataTable(msgPushUserDal.TableName, msgPushUserDal.TableFieldNameStr + ", CONVERT(nvarchar(20),[ID]) as sid", filedOrder, whereString, pageSize, currentPage, out _TotalCount).Tables[0];
- dynamic data = new {
- TotalCount = _TotalCount,
- ListData = tb//JsonConvert.SerializeObject(tb)
- };
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求成功, data)));
- //返回参数
- }
- catch (Exception ex)
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, "查询数据时出错:"+ex.Message)));
- }
- }
- /// <summary>
- /// 获取推送消息记录 分页
- /// </summary>
- void PushMsgList()
- {
- try
- {
- string filedOrder = "sendTime desc";
- if (String.IsNullOrEmpty(filedOrder))
- {
- filedOrder = "id desc";
- }
- string whereString = "1=1";
- int currentPage = 1;
- int pageSize = 50;
- int _TotalCount = 0;//总记录数
- if (Request.QueryString["page"] != null)
- {
- currentPage = Convert.ToInt32(Request.QueryString["page"]);
- }
- if (Request.QueryString["pageSize"] != null)
- {
- pageSize = Convert.ToInt32(Request.QueryString["pageSize"]);
- }
- if (Request.QueryString["keywords"] != null && Request.QueryString["keywords"].ToString().Trim().Length > 0)
- {
- whereString = String.Format("title like '%{0}%' or EnterpriseName like '%{0}%' or EnterpriseID like '%{0}%' or Platform like '%{0}%' ", Request.QueryString["keywords"].ToString().Trim());
- }
- System.Data.DataTable tb = msgPushDal.PagingQueryDataTable("view_GTMsgRecord", "CONVERT(nvarchar(20),[ID]) as ID,title,[description],msgData,TargetUser,targetList,[state],EnterpriseID,[Platform],sendTime,EnterpriseName ", filedOrder, whereString, pageSize, currentPage, out _TotalCount).Tables[0];
- dynamic data = new
- {
- TotalCount = _TotalCount,
- ListData = tb//JsonConvert.SerializeObject(tb)
- };
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求成功, data)));
- //返回参数
- }
- catch (Exception ex)
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, "查询数据时出错:" + ex.Message)));
- }
- }
- /// <summary>
- /// 获取指定用户收到的推送消息列表 最新的前 100 条
- /// </summary>
- void GetSpecifiedUserMsgList()
- {
- try
- {
- string filedOrder = "sendTime desc";
- if (String.IsNullOrEmpty(filedOrder))
- {
- filedOrder = "id desc";
- }
- string EnterpriseID = "";
- string whereString = "1=1";
- string userID = "";
- int currentPage = 1;
- int pageSize = 100;
- int _TotalCount = 0;//总记录数
- string Platform="IOS";
- if (Request["page"] != null)
- {
- currentPage = Convert.ToInt32(Request["page"]);
- }
- if (Request["EnterpriseID"] != null)
- {
- EnterpriseID = Request["EnterpriseID"];
- }
- if (Request["UID"] != null && Request["UID"].ToString().Trim().Length > 0)
- {
- userID = Request["UID"].ToString().Trim();
- }
- if(Request["Platform"] != null)
- {
- Platform=Request["Platform"].ToString().Trim();
- }
- if (Platform != "IOS")
- {
- Platform = "Android";
- }
- if (!String.IsNullOrEmpty(EnterpriseID) && !String.IsNullOrEmpty(userID))
- {
- string eidAndUid = String.Format("{0}:{1}", EnterpriseID, userID);
- whereString = String.Format("(EnterpriseID='{0}' or EnterpriseID='E1000') and (TargetUser <=1 or [targetList] like '%,{1},%' or [targetList] like '%,{3},%') and [Platform] like '%{2}%'", EnterpriseID.Trim(), userID, Platform, eidAndUid);
- System.Data.DataTable tb = msgPushDal.PagingQueryDataTable("tb_GTMsgRecord", "CONVERT(nvarchar(20),[ID]) as ID,[title],[description],[msgData],[TargetUser],[targetList],[state],[EnterpriseID],[Platform],[sendTime] ", filedOrder, whereString, pageSize, currentPage, out _TotalCount).Tables[0];
- //{"title":"摄控本-安排数量设置 申请授权","content":"{\"JumpURL\":\"http:\/\/webapi.lyfz.net\/#\/RemoteAuthorization?msgid=4629368513340450532&name=Demo&uid=20170623094515297&account=demo&apieid=E6051806481742&apiuid=demo&apimsgid=5438917636193927209\"}","description":"2017年10月30日 16时44分34秒【管理员】向你发起远程授权请求“摄控本-安排数量设置”申请授权","badge":33}
- List<string> ReadMsIDList = msgPushDal.GetReadMsIDList(EnterpriseID, userID, Platform);
- List<object> objList = new List<object>();
- foreach (System.Data.DataRow row in tb.Rows)
- {
- objList.Add(new {
- ID = row["ID"].ToString(),
- title = row["title"],
- description = row["description"],
- msgData = row["msgData"].ToString().Replace("$webapi$", "http://webapi.lyfz.net").Replace("$apiuserid$", userID).Replace("$apimsgid$", row["ID"].ToString()).Replace("$_$", "&"),
- TargetUser = row["TargetUser"],
- ReadState = ReadMsIDList.Contains(row["ID"].ToString())?1:0,
- sendTime = Convert.ToInt64(row["sendTime"]).JavaScriptTimeStampToDateTime().ToYYYY_MM_dd_HH_mm_ss()
- });
- }
-
- dynamic data = new
- {
- TotalCount = _TotalCount,
- ListData = objList.ToArray()//tb//JsonConvert.SerializeObject(tb)
- };
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求成功, data)));
- }
- else {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.参数错误)));
- }
-
- //返回参数
- }
- catch (Exception ex)
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, "查询数据时出错:" + ex.Message)));
- }
- }
- /// <summary>
- /// 获取用户消息未读记录条数
- /// </summary>
- void GetUnreadCount()
- {
- try
- {
- string EnterpriseID = "";
- string userID = "";
- string Platform = "IOS";
- if (Request.QueryString["EnterpriseID"] != null)
- {
- EnterpriseID = Request.QueryString["EnterpriseID"];
- }
- if (Request.QueryString["UID"] != null && Request.QueryString["UID"].ToString().Trim().Length > 0)
- {
- userID = Request.QueryString["UID"].ToString().Trim();
- }
- if (Request.QueryString["Platform"] != null)
- {
- Platform = Request.QueryString["Platform"].ToString().Trim();
- }
- if (Platform != "IOS")
- {
- Platform = "Android";
- }
- if (!String.IsNullOrEmpty(EnterpriseID) && !String.IsNullOrEmpty(userID))
- {
- int uReadCount = msgPushDal.GetUnreadCount(EnterpriseID,userID,Platform);
- dynamic data = new
- {
- UnreadCount = uReadCount,
- };
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求成功, data)));
- }
- else
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.参数错误)));
- }
- //返回参数
- }
- catch (Exception ex)
- {
- Response.Write(JsonConvert.SerializeObject(new AjaxResult(EnumCode.AjaxResultCode.请求失败, "查询数据时出错:" + ex.Message)));
- }
- }
- }
- }
|