public void OnActionExecuted(ActionExecutedContext context) { if (context.Result.GetType().Name == "ObjectResult") { ObjectResult contextResult = (ObjectResult)context.Result; if (contextResult.Value.GetType().Name == "BaseReturnResult") { BaseReturnResult returnResult = (BaseReturnResult)contextResult.Value; if (returnResult.reqSqlAction == 1) //rAjax { var resObj = new cusResult <object>(); resObj.resCode = 1; resObj.result = returnResult.rResult; resObj.resultMsg = MsgContent.getMsg(MessageCode.Success); //success context.Result = new OkObjectResult(resObj); } else if (returnResult.reqSqlAction == 2) //cudAjax { var resObj = new cusResult <object>(); var result = returnResult.cudResult; resObj.resCode = (result <= 0 || result >= 1000)? 0 : 1; //1000以上 MariaDB Error Codes resObj.result = result; resObj.resultMsg = MsgContent.getMsg(result); context.Result = new OkObjectResult(resObj); } } } /*var err = new errorMsg(){}; * var result = new cusResult<dynamic>{ * Code = 200, Error = err, Result = context.Result, status="success" * }; * context.Result = new OkObjectResult(result);*/ }
/// <summary> /// 添加信息 /// </summary> /// <param name="accountId"></param> /// <param name="model"></param> /// <returns></returns> public ResponsResult AddMsgInfo(string accountId, AddRpwModel model) { ResponsResult result = new ResponsResult(); if (string.IsNullOrEmpty(model.Content)) { return(result.SetStatus(ErrorCode.RpwMsgEmpty)); } if (model.Pics.Count <= 0) { return(result.SetStatus(ErrorCode.PicsEmpty)); } MsgContent msgContent = new MsgContent() { AccountId = accountId, AreaType = (int)model.Type, ContextType = (int)MsgContextType.hot, Status = (int)MsgStatus.NoReviewed, Content = model.Content, Pics = model.Pics.GetJson(), CreateTime = DateTime.Now, Longtude = model.Longtude, Latiude = model.Latitude }; base.Add(msgContent, true); return(result); }
public ActionResult Send(string ToUserName, string ContentBody, string MsgType) { MsgParams msgParams = new MsgParams(); msgParams.touser = ToUserName; msgParams.msgtype = MsgType; MsgContent msgContent = new MsgContent(); msgContent.content = ContentBody; msgParams.text = msgContent; string req0 = JsonConvert.SerializeObject(msgParams); string r1 = MsgService.Send(msgParams); return(Content(req0 + r1)); //SendMsgResponse response =(SendMsgResponse)JsonConvert.DeserializeObject(MsgService.Send(msgParams),typeof(SendMsgResponse)); //if (response.errcode == "0") //{ // return View("SendForm"); //}else //{ // return View("SendError"); //} }
/// <summary> /// 菜单点击事件 /// </summary> /// <param name="xmldoc"></param> /// <returns></returns> private async Task <string> ClickHandle(XmlDocument xmldoc) { MessgeText messgeText = new MessgeText(); messgeText.ToUserName = xmldoc.SelectSingleNode("/xml/FromUserName").InnerText; messgeText.FromUserName = xmldoc.SelectSingleNode("/xml/ToUserName").InnerText; string strEventKey = xmldoc.SelectSingleNode("/xml/EventKey").InnerText; switch (strEventKey) { case "HongBao": messgeText.Content = MsgContent.HongBao(); break; case "Free": messgeText.Content = MsgContent.Free(); break; default: messgeText.Content = "我只能默认了……。" + strEventKey; break; } await Task.Run(() => { new UserInfoBll().Update(messgeText.ToUserName); }); return(await Task.Run(() => { return messgeText.Messge; })); }
/// <summary> /// 刷新 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void RefreshButton_Click(object sender, RoutedEventArgs e) { _totalHtml = ChatBoxTool.BaseChatHtml; if (App.Theme == ApplicationTheme.Dark) { _totalHtml += "<style>body{background-color:black;color:white;}</style>"; } List <CNMessageItem> refresh_items = await UserService.GetMessageItems(_msg_id); if (refresh_items != null) { string msgs = ""; foreach (CNMessageItem item in refresh_items) { if (item.Send) //自己发的 { msgs += ChatBoxTool.Send(item.AuthorAvatar, item.AuthorName, item.Content, item.Time); } else //别人发的 { msgs += ChatBoxTool.Receive(item.AuthorAvatar, item.AuthorName, item.Content, item.Time); } } //msgs += "<a id='ok'></a>"; _totalHtml = _totalHtml.Replace("<a id='ok'></a>", "") + msgs + "<a id='ok'></a>"; MsgContent.NavigateToString(_totalHtml); Loading.IsActive = false; } }
public long PushMsg(MsgContent msg) { var content = msg.ToJson(); var result = CacheHelper.Push(content); return(result); }
public HttpResponse StopLiveMsg(int id = 0, string username = "", string t = "", long uid = 0) { HttpResponse output = new HttpResponse(); Niu.Cabinet.Logging.LogRecord log = new Niu.Cabinet.Logging.LogRecord("logpath"); log.WriteSingleLog("SendMsg.txt", string.Format("创建直播 222 ,usertoken:{0};id:{1};username:{2}", uid, id, username)); MsgContent cont = new MsgContent() { msgId = Guid.NewGuid().ToString().Substring(0, 31), attach = "close", isRobot = 0, isAudit = 1, ismanger = "1", ext = new Ext() { mstype = 10 } }; switch (id) { case 99999: //停止 //通知用户刷新直播 break; case 88888: //开始 cont.name = "System"; cont.ext.mstype = 1; cont.roleId = 14;//老师的roleid cont.addtime = Niu.Cabinet.Time.TimeStmap.DateTimeToUnixTimeStmap(DateTime.Now); cont.attach = "直播马上开始啦!!!"; break; case 77777: //发送一条喊单信息 cont.ext.mstype = 8; cont.attach = string.Format("{0}发布了一条{1}策略", username, t); cont.name = username; cont.roleId = 14;//老师的roleid cont.addtime = Niu.Cabinet.Time.TimeStmap.DateTimeToUnixTimeStmap(DateTime.Now); break; } #region 发送请求 记录到数据库 #endregion //发送消息 //var temp = Niu.Live.Chat.Core.Provider.Chatroom.NeteaseIm_SendMsg(cont.msgId, Niu.Live.Chat.Core.Provider.ChatroomMessageType.Custom, 9072833, imUser.accid, 0, id == 77777 ? cont.attach : "", Newtonsoft.Json.JsonConvert.SerializeObject(cont), 1, 0, id == 77777 ? 1 : 0, id == 77777 || id == 88888 ? 14 : 0); return(output); }
public void WriteXml(XmlWriter writer) { new XmlSerializer(Sender.GetType()).Serialize(writer, Sender); new XmlSerializer(Receiver.GetType()).Serialize(writer, Receiver); new XmlSerializer(Topic.GetType()).Serialize(writer, Topic); new XmlSerializer(MsgContent.GetType()).Serialize(writer, MsgContent); if (AttachmentList != null) { new XmlSerializer(AttachmentList.GetType()).Serialize(writer, AttachmentList); } if (CopyReceiver != null) { new XmlSerializer(CopyReceiver.GetType()).Serialize(writer, CopyReceiver); } }
public LC_Msg UserSave() { LC_Msg msg = new LC_Msg(); using (LiveChatEntities db = new LiveChatEntities()) { msg = db.sp_LC_SearchMsg(MsgID).ToList().First(); msg.MsgContent += MsgContent; if (MsgContent.Equals("<li>" + msg.FName + ": Agent has left.</li>")) { msg.Status = "F"; } db.SaveChanges(); return(msg); } }
/// <summary> /// 关注 /// </summary> private string Subscribe(XmlDocument xmldoc) { MessgeText messgeText = new MessgeText(); messgeText.ToUserName = xmldoc.SelectSingleNode("/xml/FromUserName").InnerText; messgeText.FromUserName = xmldoc.SelectSingleNode("/xml/ToUserName").InnerText; string lvParenOpenID = xmldoc.SelectSingleNode("/xml/EventKey").InnerText; if (!string.IsNullOrEmpty(lvParenOpenID)) { lvParenOpenID = lvParenOpenID.Split('_')[1]; } else { lvParenOpenID = ""; } messgeText.Content = MsgContent.Subscribe(); return(messgeText.Messge); }
/// <summary> /// 界面加载 /// </summary> /// <param name="e"></param> protected async override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); object[] parameters = e.Parameter as object[]; //页面导航参数 if (parameters != null) { if (parameters.Length == 2 && !(bool)parameters[1]) //消息ID 页面显示方式 { Back.Visibility = Visibility.Collapsed; } _msg_id = parameters[0].ToString(); _totalHtml = ChatBoxTool.BaseChatHtml; if (App.Theme == ApplicationTheme.Dark) { _totalHtml += "<style>body{background-color:black;color:white;}</style>"; } List <CNMessageItem> refresh_items = await UserService.GetMessageItems(_msg_id); if (refresh_items != null) { string msgs = ""; foreach (CNMessageItem item in refresh_items) { if (item.Send) //自己发的 { msgs += ChatBoxTool.Send(item.AuthorAvatar, item.AuthorName, item.Content, item.Time); } else //别人发的 { msgs += ChatBoxTool.Receive(item.AuthorAvatar, item.AuthorName, item.Content, item.Time); } } //msgs += "<a id='ok'></a>"; _totalHtml = _totalHtml.Replace("<a id='ok'></a>", "") + msgs + "<a id='ok'></a>"; MsgContent.NavigateToString(_totalHtml); Loading.IsActive = false; } } }
/// <summary> /// 发布回复 /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private async void MyReply_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) { if (!MyReply.Text.Equals("")) { MyReply.IsEnabled = false; string reply = MyReply.Text; MyReply.Text = "正在发送回复..."; object result = await UserService.ReplyMsg(_msg_id, reply); if (result != null) { _totalHtml = _totalHtml.Replace("<a id='ok'></a>", "") + ChatBoxTool.Send(App.LoginedUser.Avatar, App.LoginedUser.Name, reply, DateTime.Now.ToString()) + "<a id='ok'></a>"; MsgContent.NavigateToString(_totalHtml); } else { await(new MessageDialog("回复失败!")).ShowAsync(); } MyReply.IsEnabled = true; MyReply.Text = ""; } }
private void Btn_Submit_Click(object sender, EventArgs e) { MsgContent.CheckInput(); MsgTitle.CheckInput(); if (!MsgTitle.ValidateState) { return; } Hashtable ht = new SqlServerHelper().GetHashTableByControl(this.P8.Controls); ht["LOGINID"] = loginid; ht["USERNAME"] = AppDomain.CurrentDomain.GetData("USERNAME").ToString(); bool result = new SqlServerHelper().Submit_AddOrEdit("User_FeedBack", "MsgID", "", ht); string _info = result ? "提交成功!" : "提交失败!"; MsgTitle.Text = ""; MsgContent.Text = ""; UnsubscribeID.Text = ""; Msg.Show(_info); }
public static void TianData() { var msgType = ""; var msgTo = ""; var msgContent = new MsgContent(); var messageInfo = new List <Message>(); for (var i = 0; i < 2; i++) { msgType = "phoNE"; msgTo = "17317832559"; msgContent.MsgBody = "ASDFGHFHGDFDSZ"; msgContent.MsgSubject = "值班系统通知"; messageInfo.Add(new Message() { MsgType = msgType, MsgTo = msgTo, MsgContent = msgContent }); } PostTest(messageInfo); }
public AopResult <PublishMsgResponse> Post(PublishMsgRequest request) { // 发布消息,需注册应用和事件 if (!base.ValidateApp(request.AppNo, request.AppEvent)) { return(AopResult.Fail <PublishMsgResponse>("非法调用!")); } var msgNo = NumHelper.GetRandomNo(); var msg = new MsgContent { MsgNo = msgNo, AppNo = request.AppNo, AppEvent = request.AppEvent, Content = request.Content }; // 记录消息日志 ServerHelper.GetLogImp.AddLog(msg); // 推送消息到队列 var queueId = ServerHelper.GetQueueImp.PushMsg(msg); return(AopResult.Success(new PublishMsgResponse { QueueId = queueId.ToString(), MsgNo = msgNo })); }
public void AddLog(MsgContent msgContent) { Resource.ListLog.Add(new LogContent { AppEvent = msgContent.Content, AppNo = msgContent.AppNo, Content = msgContent.Content, CreateTime = DateTime.Now, MsgNo = msgContent.MsgNo }); if (!Resource.LogTaskIsRun) { TaskManager.RunWriteLog(); } if (!Resource.LogFlushTaskIsRun) { TaskManager.RunLogFlush(); } if (!Resource.NeedValidateCollection) { DbHelper.ValidateCollection(); } }
public void Process(WorkflowPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); ProcessorItem processorItem = args.ProcessorItem; if (processorItem != null) { Item innerItem = processorItem.InnerItem; string fullPath = innerItem.Paths.FullPath; string sendFrom = GetText(innerItem, "SendFrom", args); string toUser = GetText(innerItem, "ToUser", args); //string host = GetText(innerItem, "mail server", args); string messageTitle = GetText(innerItem, "MessageTitle", args); string messageBody = GetText(innerItem, "MessageBody", args); Error.Assert(toUser.Length > 0, "The 'To' field is not specified in the mail action item: " + fullPath); Error.Assert(sendFrom.Length > 0, "The 'From' field is not specified in the mail action item: " + fullPath); Error.Assert(messageTitle.Length > 0, "The 'Subject' field is not specified in the mail action item: " + fullPath); //Error.Assert(host.Length > 0, // "The 'Mail server' field is not specified in the mail action item: " + fullPath); //var message = new MailMessage(from, to); //message.Subject = subject; //message.Body = body; //new SmtpClient(host).Send(message); QYMsgParams qymsgParams = new QYMsgParams(); qymsgParams.touser = toUser; qymsgParams.msgtype = "text"; qymsgParams.agentid = AgentID; qymsgParams.safe = "0"; MsgContent msgContent = new MsgContent(); msgContent.content = messageBody; qymsgParams.text = msgContent; string r1 = MsgService.QYSend(qymsgParams); } }
/// <summary> /// .post发送消息 /// </summary> /// <param name="collection"></param> /// <returns></returns> public JsonResult SendMsg(FormCollection collection) { if (collection == null) { return(Json(new { result = 0, code = 11, message = "" })); } string userToken = _convert.ObjectConvert.ChangeType <string>(Request.Headers["usertoken"] ?? collection["usertoken"]); if (string.IsNullOrEmpty(userToken)) { return(Json(new { result = 0, code = 11, message = "" })); } long roomId = _convert.ObjectConvert.ChangeType <long>(collection["roomId"]); if (roomId <= 0) { return(Json(new { result = 0, code = 11, message = "" })); } string content = _convert.ObjectConvert.ChangeType <string>(collection["content"] ?? null); string sourceMsgId = _convert.ObjectConvert.ChangeType <string>(collection["sourceMsgId"]); string msgtype = _convert.ObjectConvert.ChangeType <string>(collection["msgtype"] ?? null); int isRobot = _convert.ObjectConvert.ChangeType <int>(collection["isRobot"] == null ? 0 : Convert.ToInt32(collection["isRobot"])); int _roleId = _convert.ObjectConvert.ChangeType <int>(collection["roleId"] ?? collection["roleId"], 0); string userIp = Niu.Cabinet.Web.ExtensionMethods.RequestExtensions.ClientIp(Request); string returnExt = string.Empty; long userID = 0; Niu.Live.User.IModel.TokenManager.TokenUserInfo userInfo; Niu.Live.User.Provider.TokenManager.TokenManager.ValidateUserToken(userToken, out userInfo); if (userInfo == null) { return(Json(new { result = 1, code = 13, message = "token error" })); } userID = userInfo.userId; if (Niu.Live.Chat.Core.Access.Chatroom.QueryBlock(new { roomId = roomId, target = userID })) { return(Json(new { result = 1, code = 15, message = "您当前不能发言" })); } string attach = string.Empty; //消息主体 string ext = string.Empty; //消息扩展字段 #region 图片内容 MsgContent msgcontent = new MsgContent() { userId = userInfo.userId, ismanger = userInfo.isManage.ToString(), name = userInfo.nickName, roleId = _roleId == 0 ? userInfo.roleId : _roleId }; int[] arry = new int[] { 5, 6, 7, 13, 14 }; //管理员id列表 if (arry.Contains(userInfo.roleId) || isRobot == 1 || isRobot == 2) //isRobot ==2为礼物 { msgcontent.isAudit = 1; } if (isRobot == 1) { msgcontent.roleId = _roleId; } msgcontent.ext = new Ext(); var resultdata = PhotoHandler.Upload(userID, Request.Files); if (resultdata != null && resultdata.data != null && resultdata.data.Count > 0) { ext = Newtonsoft.Json.JsonConvert.SerializeObject(new { w = resultdata.data[0].width, h = resultdata.data[0].height }); attach = resultdata.data[0].url; msgcontent.ext.width = resultdata.data[0].width; msgcontent.ext.height = resultdata.data[0].height; msgcontent.ext.mstype = 2; msgcontent.ext.url = attach; //原图地址 msgcontent.attach = string.Format("{0}/200", attach); //为啥要标注200不知道 } #endregion else { #region 文本内容 if (resultdata == null || resultdata.data == null || resultdata.data.Count == 0) { ////发送彩条时候,重写消息体 if (string.IsNullOrEmpty(content) || content.Length <= 0 || content.Length > 300) { return(Json(new { result = 0, code = 31, message = "内容过长度不匹配" })); } msgcontent.attach = attach = content; msgcontent.ext.mstype = 1; if (!string.IsNullOrEmpty(msgtype)) { msgcontent.ext.mstype = int.Parse(msgtype); //彩条信息 switch (msgcontent.ext.mstype) { case 13: msgcontent.ext.url = "https://live.fxtrade888.com/chatroom/images/dingyige.gif"; //顶 msgcontent.attach = "https://live.fxtrade888.com/chatroom/images/dingyige.gif"; //顶 break; case 12: msgcontent.ext.url = "https://live.fxtrade888.com/chatroom/images/zanyige.gif"; //赞 msgcontent.attach = "https://live.fxtrade888.com/chatroom/images/zanyige.gif"; //赞 break; case 11: msgcontent.ext.url = "https://live.fxtrade888.com/chatroom/images/zhangsheng.gif"; //掌 msgcontent.attach = "https://live.fxtrade888.com/chatroom/images/zhangsheng.gif"; //掌 break; case 14: msgcontent.ext.url = "https://live.fxtrade888.com/chatroom/images/xianhua.gif"; //花 msgcontent.attach = "https://live.fxtrade888.com/chatroom/images/xianhua.gif"; //花 break; case 5: msgcontent.ext.url = "https://live.fxtrade888.com/chatroom/images/kanzhang.gif"; //看涨 msgcontent.attach = "https://live.fxtrade888.com/chatroom/images/kanzhang.gif"; //看涨 break; case 6: msgcontent.ext.url = "https://live.fxtrade888.com/chatroom/images/kandie.gif"; //看跌 msgcontent.attach = "https://live.fxtrade888.com/chatroom/images/kandie.gif"; //看跌 break; case 7: msgcontent.ext.url = "https://live.fxtrade888.com/chatroom/images/zhendang.gif"; //震荡 msgcontent.attach = "https://live.fxtrade888.com/chatroom/images/zhendang.gif"; //震荡 break; } msgcontent.isAudit = 1; } } #endregion } long sourceId = 0; string sourceUserName = string.Empty; string sourceContent = string.Empty; #region 引用数据 if (!string.IsNullOrEmpty(sourceMsgId)) { Niu.Live.Chat.Core.Model.Im_Chatroom_Msg sourceMsg = Niu.Live.Chat.Core.Access.Chatroom.ChatroomGetMsg(sourceMsgId); if (sourceMsg != null && !string.IsNullOrEmpty(sourceMsg.attach)) { var fromuserinfo = Niu.Live.Chat.Core.Access.User.UserQuery(sourceMsg.fromAccId); var touserinof = Niu.Live.Chat.Core.Access.User.QueryImUserByUserId(userInfo.userId); msgcontent.ext.other = new { from = userInfo.nickName, to = fromuserinfo.name, content = sourceMsg.attach }; msgcontent.attach = content; msgcontent.ext.mstype = 3; sourceId = sourceMsg.id; sourceContent = sourceMsg.attach; } } #endregion #region 发送请求 string jsonext = string.Empty; string msgId = Niu.Live.Chat.Core.Utils.UniqueValue.GenerateGuid(); msgcontent.msgId = msgId; msgcontent.addtime = Cabinet.Time.TimeStmap.DateTimeToUnixTimeStmap(DateTime.Now); Im_User imUser = new Im_User(); if (isRobot == 1) { imUser.accid = Guid.NewGuid().ToString().Substring(0, 31); imUser.name = _convert.ObjectConvert.ChangeType <string>(collection["Robotname"] ?? ""); msgcontent.isRobot = 1; msgcontent.Robotname = imUser.name; Niu.Live.Chat.Core.Provider.User.NeteaseIm_CreateRobot(imUser.accid, imUser.name); } else { imUser = Niu.Live.Chat.Core.Provider.User.NeteaseIm_Create(userID.ToString(), userInfo.nickName, ""); } //#if DEBUG // roomId = 9884735; //#endif #endregion var temp = Niu.Live.Chat.Core.Provider.Chatroom.NeteaseIm_SendMsg(msgId, Niu.Live.Chat.Core.Provider.ChatroomMessageType.Custom, roomId, imUser.accid, 0, attach, Newtonsoft.Json.JsonConvert.SerializeObject(msgcontent), msgcontent.isAudit, userInfo.isManage, 1, _roleId == 0 ? userInfo.roleId : _roleId); return(Json(new { result = 0, code = temp.code, msg = temp.desc })); }
/// <summary> /// 添加红包信息 /// </summary> /// <param name="accountId"></param> /// <param name="model"></param> /// <returns></returns> public ResponsResult AddRpwInfo(string accountId, AddRpwModel model) { ResponsResult result = new ResponsResult(); if (string.IsNullOrEmpty(model.Content)) { return(result.SetStatus(ErrorCode.RpwMsgEmpty)); } if (model.Pics.Count < 0) { return(result.SetStatus(ErrorCode.PicsEmpty)); } if (!model.RpwCounts.HasValue) { return(result.SetStatus(ErrorCode.TotalAmount)); } if (!model.RpwTotalAmount.HasValue) { return(result.SetStatus(ErrorCode.AmountEmpty)); } if (model.RpwCounts <= 0 || model.RpwTotalAmount <= 0) { return(result.SetStatus(ErrorCode.AmountPub)); } MsgContent msgContent = new MsgContent() { AccountId = accountId, AreaType = (int)model.Type, ContextType = (int)MsgContextType.Rpw, Status = (int)MsgStatus.NoReviewed, Content = model.Content, Pics = model.Pics.GetJson(), CreateTime = DateTime.Now, Longtude = model.Longtude, Latiude = model.Latitude, RemainCounts = model.RpwCounts, TotalCounts = model.RpwCounts, TotalPrice = model.RpwTotalAmount }; if (model.IsHasOutLink && !string.IsNullOrEmpty(model.OutLinkStr)) { msgContent.OutLink = model.OutLinkStr; } base.Add(msgContent); //写入订单记录 Orders orders = new Orders() { Id = this.GenNewGuid(), AccountId = accountId, SourceId = msgContent.Id.ToString(), OrderType = (int)OrderType.RpwRecharge, Amount = model.RpwTotalAmount ?? 0, PayType = (int)PayType.None, OrderStatus = (int)OrderStatus.Pending, ActualAmount = model.RpwTotalAmount ?? 0, CreateTime = DateTime.Now, }; base.Add(orders, true); return(result); }