public async Task <IActionResult> Create([Bind("Id,FromUser,ToUser,IsEmail,Body")] UserMessageModel userMessageModel) { if (ModelState.IsValid) { userMessageModel.Id = Guid.NewGuid(); var toEmail = userMessageModel.ToUser; userMessageModel.FromUser = (await _userManager.FindByNameAsync(User.Identity.Name)).Id; userMessageModel.ToUser = (await _userManager.FindByNameAsync(userMessageModel.ToUser)).Id; // Check wether message doesn't be sent to myself if (!userMessageModel.FromUser.Equals(userMessageModel.ToUser)) { _context.Add(userMessageModel); await _context.SaveChangesAsync(); if (userMessageModel.IsEmail && _sender != null) { var bodyBuilder = new System.Text.StringBuilder(); bodyBuilder.AppendFormat("<h2>You have new message from {0}</h2>.<br />", User.Identity.Name); bodyBuilder.AppendFormat("<div class=\"message\">{0}</div><br /><br />", userMessageModel.Body); bodyBuilder.AppendFormat("<div class=\"footer\">Pure MVC {0}</div>", DateTime.UtcNow.Year); await _sender.SendEmailAsync(toEmail, "Pure MVC user messages subsystem.", bodyBuilder.ToString()); } } return(RedirectToAction(nameof(Index))); } return(View(userMessageModel)); }
public void SetFriendList(RepeatedField <UserMessageModel> friends) { GameObject friendprefab = FriendsFather.GetChild(0).gameObject; while (FriendsFather.childCount > 1) { GameObject.DestroyImmediate(FriendsFather.GetChild(1).gameObject); } for (int i = 0; i < friends.Count; i++) { GameObject friend = GameObject.Instantiate(friendprefab, FriendsFather); friend.SetActive(true); friend.transform.Find("Txt_FriendName").GetComponent <Text>().text = friends[i].UserName; friend.transform.Find("Txt_FriendAge").GetComponent <Text>().text = friends[i].UserAge.ToString(); friend.transform.Find("Txt_FriendProfession").GetComponent <Text>().text = friends[i].UserProfession; friend.transform.Find("Txt_FriendScore").GetComponent <Text>().text = friends[i].UserScore.ToString(); UserMessageModel userMessage = friends[i]; friend.transform.Find("Btn_ShowMsg").GetComponent <Button>().onClick.AddListener(delegate { GameFacade.RetrieveProxy <UILobbyProxy>().SetChoseFirend(userMessage); }); friend.transform.FindeDeepChild("Tog_Select").GetComponent <Toggle>().onValueChanged.AddListener(ison => { if (ison) { GameFacade.RetrieveProxy <UISelectWorkerProxy>().AddSelect(userMessage); } else { GameFacade.RetrieveProxy <UISelectWorkerProxy>().RemoveSelect(userMessage); } }); } }
/// <summary> /// A simple function that takes a string and does a ToUpper /// </summary> /// <param name="input"></param> /// <param name="context"></param> /// <returns></returns> public async Task <bool> FunctionHandler(UserMessageModel input, ILambdaContext context) { var customerService = new CustomerService(); var result = await customerService.SaveCustomer(input); return(result); }
public async Task <bool> SaveCustomer(UserMessageModel message) { var captchaService = new CaptchaService(); var captchaResult = await captchaService.ValidateCaptcha(message.CaptchaToken); try { var customersTable = Table.LoadTable(client, tableName); var customer = new Document(); customer["Name"] = message.Name; customer["Email"] = message.Email; customer["Message"] = message.Message; customer["CaptchaResponse"] = captchaResult ? "Good" : "Bad"; customer["Date"] = DateTime.Now; await customersTable.PutItemAsync(customer); } catch (Exception e) { Console.WriteLine(e.Message); return(false); } return(true); }
public ActionResult InsertMessageUser(UserMessageModel obj) { SqlConnection conn = new SqlConnection(_conString); SqlCommand cmd = new SqlCommand("Garbage", conn); cmd.Parameters.Add(new SqlParameter("@Name", SqlDbType.NVarChar) { Value = obj.Name }); cmd.Parameters.Add(new SqlParameter("@Email", SqlDbType.NVarChar) { Value = obj.Email }); cmd.Parameters.Add(new SqlParameter("@ContactNo", SqlDbType.NVarChar) { Value = obj.ContactNo }); cmd.Parameters.Add(new SqlParameter("@Message", SqlDbType.NVarChar) { Value = obj.Message }); cmd.Parameters.Add(new SqlParameter("@Action", SqlDbType.NVarChar) { Value = "InsertMessageUser" }); cmd.CommandTimeout = 99999; cmd.CommandType = CommandType.StoredProcedure; conn.Open(); int result = cmd.ExecuteNonQuery(); conn.Close(); return(Json(result, JsonRequestBehavior.AllowGet)); }
public void SetFriendList(RepeatedField <UserMessageModel> friends) { GameObject friendprefab = FriendsFather.GetChild(0).gameObject; while (FriendsFather.childCount > 1) { GameObject.DestroyImmediate(FriendsFather.GetChild(1).gameObject); } for (int i = 0; i < friends.Count; i++) { GameObject friend = GameObject.Instantiate(friendprefab, FriendsFather); friend.SetActive(true); friend.transform.Find("Txt_FriendName").GetComponent <Text>().text = friends[i].UserName; friend.transform.Find("Txt_FriendAge").GetComponent <Text>().text = friends[i].UserAge.ToString(); friend.transform.Find("Txt_FriendProfession").GetComponent <Text>().text = friends[i].UserProfession; friend.transform.Find("Txt_FriendScore").GetComponent <Text>().text = friends[i].UserScore.ToString(); UserMessageModel userMessage = friends[i]; friend.transform.Find("Btn_ShowMsg").GetComponent <Button>().onClick.AddListener(delegate { GameFacade.RetrieveProxy <UILobbyProxy>().SetChoseFirend(userMessage); }); friend.transform.Find("Btn_Black").GetComponent <Button>().onClick.AddListener(delegate { UIManager.ShowMessageBox("拉黑好友", "确认拉黑?", false, delegate { RequestManager.Execute(Protocol.BlackList_Add, GameFacade.RetrieveProxy <PlayerDataProxy>().user.Uid, userMessage.Uid); }); }); friend.transform.Find("Btn_Delete").GetComponent <Button>().onClick.AddListener(delegate { UIManager.ShowMessageBox("删除好友", "确认删除,一旦删除无法恢复", false, delegate { RequestManager.Execute(Protocol.Friend_Delete, GameFacade.RetrieveProxy <PlayerDataProxy>().user.Uid, userMessage.Uid); }); }); } }
public void SetFriendAddition(RepeatedField <UserMessageModel> addition) { GameObject additionprefab = AdditionFriendFather.GetChild(0).gameObject; while (AdditionFriendFather.childCount > 1) { GameObject.DestroyImmediate(AdditionFriendFather.GetChild(1).gameObject); } for (int i = 0; i < addition.Count; i++) { GameObject additionfriend = GameObject.Instantiate(additionprefab, AdditionFriendFather); additionfriend.SetActive(true); additionfriend.transform.Find("Txt_FriendName").GetComponent <Text>().text = addition[i].UserName; additionfriend.transform.Find("Txt_FriendAge").GetComponent <Text>().text = addition[i].UserAge.ToString(); additionfriend.transform.Find("Txt_FriendProfession").GetComponent <Text>().text = addition[i].UserProfession; additionfriend.transform.Find("Txt_FriendScore").GetComponent <Text>().text = addition[i].UserScore.ToString(); UserMessageModel userMessage = addition[i]; additionfriend.transform.FindButton("Btn_ShowMsg", delegate { GameFacade.RetrieveProxy <UILobbyProxy>().SetChoseFirend(userMessage); }); additionfriend.transform.FindButton("Btn_Addition", delegate { RequestManager.Execute(Protocol.Friend_Add, GameFacade.RetrieveProxy <PlayerDataProxy>().user.Uid, userMessage.Uid); }); } }
public void SetFriendApply(RepeatedField <UserMessageModel> apply) { GameObject applyprefab = ApplyFriendFather.GetChild(0).gameObject; while (ApplyFriendFather.childCount > 1) { GameObject.DestroyImmediate(ApplyFriendFather.GetChild(1).gameObject); } for (int i = 0; i < apply.Count; i++) { GameObject applyfriend = GameObject.Instantiate(applyprefab, ApplyFriendFather); applyfriend.SetActive(true); applyfriend.transform.Find("Txt_FriendName").GetComponent <Text>().text = apply[i].UserName; applyfriend.transform.Find("Txt_FriendAge").GetComponent <Text>().text = apply[i].UserAge.ToString(); applyfriend.transform.Find("Txt_FriendProfession").GetComponent <Text>().text = apply[i].UserProfession; applyfriend.transform.Find("Txt_FriendScore").GetComponent <Text>().text = apply[i].UserScore.ToString(); string fID = apply[i].Uid.ToString(); UserMessageModel userMessage = apply[i]; applyfriend.transform.FindButton("Btn_ShowMsg", delegate { GameFacade.RetrieveProxy <UILobbyProxy>().SetChoseFirend(userMessage); }); applyfriend.transform.Find("Btn_Agree").GetComponent <Button>().onClick.AddListener(delegate { RequestManager.Execute(Protocol.FriendApply_Agree, GameFacade.RetrieveProxy <PlayerDataProxy>().user.Uid, fID); }); applyfriend.transform.Find("Btn_Disagree").GetComponent <Button>().onClick.AddListener(delegate { RequestManager.Execute(Protocol.FriendApply_Disagree, GameFacade.RetrieveProxy <PlayerDataProxy>().user.Uid, fID); }); } }
public void SetBlackList(RepeatedField <UserMessageModel> black) { GameObject blackprefab = BlackListFather.GetChild(0).gameObject; while (BlackListFather.childCount > 1) { GameObject.DestroyImmediate(BlackListFather.GetChild(1).gameObject); } for (int i = 0; i < black.Count; i++) { GameObject friend = GameObject.Instantiate(blackprefab, BlackListFather); friend.SetActive(true); friend.transform.Find("Txt_FriendName").GetComponent <Text>().text = black[i].UserName; friend.transform.Find("Txt_FriendAge").GetComponent <Text>().text = black[i].UserAge.ToString(); friend.transform.Find("Txt_FriendProfession").GetComponent <Text>().text = black[i].UserProfession; friend.transform.Find("Txt_FriendScore").GetComponent <Text>().text = black[i].UserScore.ToString(); string fID = black[i].Uid.ToString(); UserMessageModel userMessage = black[i]; friend.transform.FindButton("Btn_ShowMsg", delegate { GameFacade.RetrieveProxy <UILobbyProxy>().SetChoseFirend(userMessage); }); friend.transform.Find("Btn_Delete").GetComponent <Button>().onClick.AddListener(delegate { RequestManager.Execute(Protocol.BlackList_Delete, GameFacade.RetrieveProxy <PlayerDataProxy>().user.Uid, fID); }); } }
private async Task SendInboxNotifications(string sender, List <Entity.UserMessage> messages) { try { foreach (var message in messages) { var notification = new UserMessageModel { Id = message.Id, Sender = sender, Subject = message.Subject, Timestamp = message.Timestamp }; await SendNotification(DataNotificationType.InboxMessage, message.UserId, notification).ConfigureAwait(false); await NotificationService.CreateNotification(new CreateNotificationModel { UserId = message.UserId, Title = "New Message", Message = string.Format("New private message from {0}", sender), Type = NotificationType.Message, Level = NotificationLevelType.Info, }).ConfigureAwait(false); } } catch (Exception) { } }
void SetPlayer(UserMessageModel my) { Txt_UserID.text = my.Uid.ToString(); Ipt_UserName.text = my.UserName; Ipt_UserAge.text = my.UserAge.ToString(); Ipt_UserProfession.text = my.UserProfession; Ipt_UserScore.text = my.UserScore.ToString(); }
public ActionResult Add(string messageText) { string userId = User.Identity.GetUserId(); UserMessageModel userMessageModel = new UserMessageModel(); userMessageModel.addMessage(userId, messageText); return(RedirectToAction("Index", "User")); }
private async Task StatsCommand(UserMessageModel twitchClientCommand) { if (twitchClientCommand.UserMessage.Equals(StatsCommandText)) { var numberOfMessages = Users[twitchClientCommand.UserName]; await _twitchIrcClient.SendPublicChatMessageAsync( $"{twitchClientCommand.UserName} has sent {numberOfMessages} this stream"); } }
public void ShowUserMessage(UserMessageModel userMessageModel) { Txt_UserID.text = userMessageModel.Uid.ToString(); Txt_UserName.text = userMessageModel.UserName; Txt_UserAge.text = userMessageModel.UserAge.ToString(); Txt_UserProfession.text = userMessageModel.UserProfession; Txt_UserScore.text = userMessageModel.UserScore.ToString(); Group_ShowMsg.SetActive(true); }
public long CreateUserMessage(Guid userId, UserSelectedContext catalogInfo, UserMessageModel userMessage) { var newUserMessage = userMessage.ToEFUserMessage(); newUserMessage.UserId = userId; _userMessageRepository.CreateOrUpdate(newUserMessage); _uow.SaveChanges(); return(newUserMessage.Id); }
private async Task ExitBotCommand(UserMessageModel twitchClientCommand) { if (twitchClientCommand.UserName.Equals(_twitchIrcConfig.UserName)) { if (twitchClientCommand.UserMessage.Equals(ExitBotCommandText)) { await _twitchIrcClient.SendPublicChatMessageAsync("Bye! Have a beautiful time!"); Environment.Exit(0); // Stop the program } } }
void HandleUser_Update(CmdType type, object msg) { if (type == CmdType.Presenter) { GameFacade.ShowTips("修改成功"); UserMessageModel user = msg as UserMessageModel; SetPlayer(user); } else if (type == CmdType.Error) { GameFacade.ShowTips(FeedBack.Log((int)msg)); } }
public void UpdateUser(Notify notify) { if (notify.Feedback == FeedBack.Success) { UserMessage_UpdateRsp updateUser = UserMessage_UpdateRsp.Parser.ParseFrom(notify.message); this.user = updateUser.User; GameFacade.SendNotification(notify.Protocol, CmdType.Presenter, this.user); } else { GameFacade.SendNotification(notify.Protocol, CmdType.Error, notify.Feedback); } }
void HandleUserMessage_Look(CmdType type, object obj) { if (type == CmdType.Presenter) { UserMessageModel Rsp = obj as UserMessageModel; RepeatedField <UserMessageModel> addions = new RepeatedField <UserMessageModel>(); addions.Add(Rsp); SetFriendAddition(addions); } else if (type == CmdType.Error) { GameFacade.ShowTips(FeedBack.Log((int)obj)); } }
public ActionResult UserMessageIndex() { var model = new UserMessageModel { Id = GetParams <int>("id"), UserId = GetParams <int>("userid"), Message = GetParams <string>("message"), Status = GetParams <int>("status"), Createtime = GetParams <DateTime>("createtime"), Updatetime = GetParams <DateTime>("updatetime"), }; return(View(model)); }
public static UserMessage ToEFUserMessage(this UserMessageModel userMessage) { return(new KeithLink.Svc.Core.Models.Messaging.EF.UserMessage() { Body = userMessage.Body, MessageReadUtc = userMessage.MessageRead.HasValue ? userMessage.MessageRead.Value.ToUniversalTime() : userMessage.MessageRead, NotificationType = userMessage.NotificationType, Subject = userMessage.Subject, Mandatory = userMessage.Mandatory, Label = userMessage.Label, CustomerName = userMessage.CustomerName, CustomerNumber = userMessage.CustomerNumber, BranchId = userMessage.BranchId }); }
/// <summary> /// 获取用户消息列表 /// </summary> /// <param name="accid"></param> /// <param name="pageIndex"></param> /// <param name="start"></param> /// <param name="end"></param> /// <param name="msgType"></param> /// <param name="content"></param> /// <param name="title"></param> /// <returns></returns> public static UserMessageModel GetUserList(int accid, int pageIndex, string start, string end, int msgType, string content, string title) { UserMessageModel model = new UserMessageModel(); Sys_UserMessageDAL dal = new Sys_UserMessageDAL(); string whereStr = ""; if (!string.IsNullOrEmpty(start)) { whereStr += " PushTime>='" + start + "' "; } if (!string.IsNullOrEmpty(end)) { whereStr += " PushTime<='" + end + "' "; } if (msgType != -99) { whereStr += " ChannelId=" + msgType + " "; } if (!string.IsNullOrEmpty(content)) { whereStr += " PushContent like '%" + content + "%' "; } if (!string.IsNullOrEmpty(title)) { whereStr += " Title like '%" + title + "%' "; } List <Sys_UserMessageModel> list = dal.GetUserMessageList(pageIndex, accid, whereStr); foreach (var item in list) { if (item.ChannelId == 3 || item.ChannelId == 4) { item.PushTime = item.PushTime.AddHours(8); } } model.DataList = list; int count = dal.GetUserMessageCount(accid, whereStr); int pageCount = count % 15 == 0 ? (count / 15) : (count / 15 + 1); model.RowCount = count; model.PageCount = pageCount; return(model); }
public static UserMessagePO ToPO(this UserMessageModel item) { if (item == null) { return(null); } return(new UserMessagePO { Id = item.Id, UserId = item.UserId, Message = item.Message, Status = item.Status, Createtime = item.Createtime, Updatetime = item.Updatetime, }); }
private async Task SendOutboxNotification(Entity.UserMessage message) { try { var notification = new UserMessageModel { Id = message.Id, Recipiants = message.Recipients, Subject = message.Subject, Timestamp = message.Timestamp }; await SendNotification(DataNotificationType.OutboxMessage, message.UserId, notification).ConfigureAwait(false); } catch (Exception) { } }
public void SendCreateUserMessage(UserMessageModel user) { var factory = new ConnectionFactory() { HostName = _hostname, UserName = _username, Password = _password }; using var connection = factory.CreateConnection(); using (var channel = connection.CreateModel()) { channel.QueueDeclare(queue: _queueName, durable: false, exclusive: false, autoDelete: false, arguments: null); var json = JsonConvert.SerializeObject(user); var body = Encoding.UTF8.GetBytes(json); channel.BasicPublish(exchange: "", routingKey: _queueName, basicProperties: null, body: body); } }
public static UserMessageModel ToUserMessageModel(this UserMessage userMessage) { UserMessageModel message = new UserMessageModel() { // replace switch |LOGO| with blank space, if it's in this message in the body Body = userMessage.Body.Replace("|LOGO|", " "), MessageRead = userMessage.MessageReadUtc.HasValue ? DateTime.SpecifyKind(userMessage.MessageReadUtc.Value.ToLocalTime(), DateTimeKind.Unspecified) : userMessage.MessageReadUtc, NotificationType = userMessage.NotificationType, CustomerNumber = userMessage.CustomerNumber, Subject = userMessage.Subject, Mandatory = userMessage.Mandatory, MessageCreated = DateTime.SpecifyKind(userMessage.CreatedUtc.ToLocalTime(), DateTimeKind.Unspecified), UserId = userMessage.UserId, Id = userMessage.Id, Label = userMessage.Label, NotificationTypeDescription = EnumUtils <NotificationType> .GetDescription(userMessage.NotificationType), CustomerName = userMessage.CustomerName, BranchId = userMessage.BranchId }; if (message.Body.IndexOf(string.Format("{0}=", Constants.USERMESSAGES_LINKTOKEN)) > -1) { // extract link from body StringBuilder link = new StringBuilder (message.Body.Substring(message.Body.IndexOf(string.Format("{0}=", Constants.USERMESSAGES_LINKTOKEN)))); link.Remove(0, link.ToString().IndexOf("\"") + 1); link.Remove(link.Length - 1, 1); message.Link = link.ToString(); // remove extracted link from body StringBuilder body = new StringBuilder(message.Body); body.Replace(string.Format("{0}=\"{1}\"", Constants.USERMESSAGES_LINKTOKEN, message.Link), ""); message.Body = body.ToString(); } return(message); }
private void SetView() { GameObject obj = GameObject.Instantiate(Resources.Load <GameObject>(ObjLoadPath), UIManager.UIRoot.transform); obj.transform.localPosition = Vector3.zero; obj.transform.localScale = Vector3.one; obj.transform.name = "UIUsermessage"; @object = obj; Txt_UserID = @object.transform.FindeDeepChild <Text>("Txt_UserID"); Ipt_UserName = @object.transform.FindeDeepChild <InputField>("Ipt_UserName"); Ipt_UserAge = @object.transform.FindeDeepChild <InputField>("Ipt_UserAge"); Ipt_UserProfession = @object.transform.FindeDeepChild <InputField>("Ipt_UserProfession"); Ipt_UserScore = @object.transform.FindeDeepChild <InputField>("Ipt_UserScore"); Btn_ConfirmMsg = @object.transform.FindButton("Btn_ConfirmMsg", OnClickConfirmMsg); Btn_ExitMsg = @object.transform.FindButton("Btn_ExitMsg", OnClickExitMsg); UserMessageModel my = GameFacade.RetrieveProxy <PlayerDataProxy>().user; SetPlayer(my); }
private async Task OnSendMessage(UserMessageModel messageModel) { try { this.ShowMessageSenderModal = false; this.IsLoading = true; await this.UserClientService.SendMessageAsync(messageModel); } catch (Exception ex) { this.ToastifyService.DisplayErrorNotification(ex.Message); } finally { this.ShowMessageSenderModal = false; this.SelectedUser = null; this.IsLoading = false; } }
public ApartmentContactResponseModel Post(UserMessageModel userMessage) { var entity = new UserMessageEntity { Name = userMessage.Name, Email = userMessage.Email, Message = userMessage.Message, ApartmentId = userMessage.ApartmentId, DateSent = DateTime.Now }; _dbContext.UserMessages.Add(entity); _dbContext.SaveChanges(); return(new ApartmentContactResponseModel { Message = "We received your message and will respond within the next 24 hours!" }); }
private async Task WelcomeCommand(UserMessageModel twitchClientCommand) { if (!Users.ContainsKey(twitchClientCommand.UserName)) { var user = await _twitchApiUserClient.GetUser(twitchClientCommand.UserName); var isFollower = await _twitchApiFollowerClient.IsUserAFollower(user.Id); if (isFollower) { await _twitchIrcClient.SendPublicChatMessageAsync($"Hi {twitchClientCommand.UserName}! Welcome back to the stream!"); } else { await _twitchIrcClient.SendPublicChatMessageAsync($"Hello and Welcome {twitchClientCommand.UserName}"); } Users.TryAdd(twitchClientCommand.UserName, 0); } }