private void ResponseAskComplete() { if (this.Data.Task == null) { this.Complete(); return; } var rTask = this.Data.Task; var tp = new ButtonTemplateMessage(); tp.RecipientID = this.RecipientID; tp.Text = this.Text(BotTextKey.AskTaskComplete) + Environment.NewLine + rTask.Title; { var bt = new PostbackButton(); bt.Title = this.Text(TextKey.Confirm_Yes); bt.SetPayload(BotCommandName.TaskComplete, "TaskCompleted", rTask.TaskCD.ToString()); tp.Buttons.Add(bt); } { var bt = new PostbackButton(); bt.Title = this.Text(TextKey.Confirm_No); bt.SetPayload(BotCommandName.TaskComplete, "TaskInCompleted", rTask.TaskCD.ToString()); tp.Buttons.Add(bt); } { var bt = new PostbackButton(); bt.Title = this.Text(TextKey.Suspend); bt.SetPayload(BotCommandName.TaskComplete, "TaskSuspend", ""); tp.Buttons.Add(bt); } var cl = new FacebookBotClient(); cl.SendMessage(tp); }
private void ResponseAskProject() { var dc = new ProjectDataContext(this.UserCD); var l = new List <IButton>(); foreach (var rProject in dc.CreateProjectList_Get()) { var bt = new PostbackButton(); bt.Title = rProject.DisplayName; var cm = new PayloadCommand(); cm.CommandName = BotCommandName.TaskAdd; cm.MethodName = "SelectProject"; cm.Value = rProject.ProjectCD.ToString(); bt.SetPayload(cm); l.Add(bt); } var cl = new FacebookBotClient(); foreach (var item in ButtonTemplateMessage.Create(this.RecipientID , this.TextManager.Text(BotTextKey.PleaseSelectProject), l)) { cl.SendMessage(item); } }
public override HandleMessageResult HandleMessage(UserActionMessage message) { if (message.ActionType == UserActionType.Postback && message.Command.CommandName == BotCommandName.StartCommand) { if (message.Command.MethodName == "StartCommand") { var commandName = message.Command.Value.ToEnum <BotCommandName>().Value; this.StartCommand(commandName); } else if (message.Command.MethodName == "RestartCommand") { var dc = new BotDataContext(this.UserCD); var commandCD = Guid.Parse(message.Command.Value); dc.BotCommand_Restart(commandCD); var r = dc.BotCommand_Get(commandCD); if (r == null) { var cl = new FacebookBotClient(); cl.SendMessage(this.RecipientID, this.Text(BotTextKey.ThisCommandMayBeDeleted)); } else { var cm = BotCommand.Create(this.RecipientID, this.BotCD, r); cm.ResponseMessage(); } } return(new HandleMessageResult(true)); } return(new HandleMessageResult(false)); }
private void ResponseAskIsStartDateAndEndDateSame() { var tm = this.TextManager; var tp = new ButtonTemplateMessage(); tp.RecipientID = this.RecipientID; tp.Text = this.Text(BotTextKey.IsStartDateAndEndDateSame); { var bt = new PostbackButton(); bt.Title = tm.Text(TextKey.Confirm_Yes); bt.SetPayload(new PayloadCommand(BotCommandName.ScheduleAdd, nameof(State.AskIsStartDateAndEndDateSame) , "True")); tp.Buttons.Add(bt); } { var bt = new PostbackButton(); bt.Title = tm.Text(TextKey.Confirm_No); bt.SetPayload(new PayloadCommand(BotCommandName.ScheduleAdd, nameof(State.AskIsStartDateAndEndDateSame) , "False")); tp.Buttons.Add(bt); } var cl = new FacebookBotClient(); cl.SendMessage(tp); }
public void ResponseCommandListMessage() { var dc = new BotDataContext(this.UserCD); var l = new List <IButton>(); { var bt = new PostbackButton(); bt.Title = this.Text(BotTextKey.AddNewSchedule); var cm = new PayloadCommand(); cm.CommandName = BotCommandName.StartCommand; cm.MethodName = "StartCommand"; cm.Value = nameof(BotCommandName.ScheduleAdd); bt.SetPayload(cm); l.Add(bt); } { var bt = new PostbackButton(); bt.Title = this.Text(BotTextKey.AddNewTask); var cm = new PayloadCommand(); cm.CommandName = BotCommandName.StartCommand; cm.MethodName = "StartCommand"; cm.Value = nameof(BotCommandName.TaskAdd); bt.SetPayload(cm); l.Add(bt); } { var bt = new PostbackButton(); bt.Title = this.Text(BotTextKey.TaskConfirmation); var cm = new PayloadCommand(); cm.CommandName = BotCommandName.StartCommand; cm.MethodName = "StartCommand"; cm.Value = nameof(BotCommandName.TaskComplete); bt.SetPayload(cm); l.Add(bt); } foreach (var item in dc.BotCommand_List_Get()) { if (item.CommandName == BotCommandName.StartCommand) { continue; } var cm = BotCommand.Create(this.RecipientID, this.BotCD, item); var bt = new PostbackButton(); bt.Title = cm.GetText(); bt.SetPayload(BotCommandName.StartCommand, "RestartCommand", item.CommandCD.ToString()); l.Add(bt); } this.SendImage(BotActionType.Greeting); var cl = new FacebookBotClient(); foreach (var item in ButtonTemplateMessage.Create(this.RecipientID , this.TextManager.Text(BotTextKey.CanIHelpYou), l)) { cl.SendMessage(item); } dc.BotCommand_Update(_Record); }
private void ResponseAskEndTime() { var cl = new FacebookBotClient(); var text = String.Format("{0} {1}" , this.TextManager.Text(TextKey.StartTime), this.Data.StartTime.Value.ToString("yyyy/MM/dd HH:mm")); cl.SendMessage(this.RecipientID, text); cl.SendMessage(this.RecipientID, this.TextManager.Text(BotTextKey.AskEndTime)); }
private void ResponseAskDescription() { var cl = new FacebookBotClient(); if (this.Data.DueDate.HasValue) { var text = String.Format("{0} {1}", this.TextManager.Text(TextKey.DueDate), this.Data.DueDate.Value.ToString("yyyy/MM/dd")); cl.SendMessage(this.RecipientID, text); } cl.SendMessage(this.RecipientID, this.TextManager.Text(BotTextKey.AskDescription)); }
private void AddSchedule() { var dc = new ScheduleDataContext(this.UserCD); dc.Schedule_Insert(this.Data); var cl = new FacebookBotClient(); cl.SendMessage(this.RecipientID, this.Text(BotTextKey.ScheduleAdded)); this.DeleteCommandData(); }
private void AddTask() { var dc = new TaskDataContext(this.UserCD); dc.Task_Insert(this.Data); var cl = new FacebookBotClient(); cl.SendMessage(this.RecipientID, this.Text(BotTextKey.TaskAdded)); this.DeleteCommandData(); }
private void ResponseAskUser() { var dc = new ProjectDataContext(this.UserCD); var l = new List <IButton>(); { var rUser = WebApp.Current.DatabaseCache.User.SelectByPrimaryKey(this.UserCD); var bt = new PostbackButton(); bt.Title = this.Text(TextKey.ByMyself); var cm = new PayloadCommand(); cm.CommandName = BotCommandName.TaskAdd; cm.MethodName = "SelectUser"; cm.Value = this.UserCD.ToString(); bt.SetPayload(cm); l.Add(bt); } { var bt = new PostbackButton(); bt.Title = this.Text(TextKey.NotAssigned); var cm = new PayloadCommand(); cm.CommandName = BotCommandName.TaskAdd; cm.MethodName = "SelectUser"; cm.Value = ""; bt.SetPayload(cm); l.Add(bt); } foreach (var item in dc.Project_User_List_Data_Get(this.Data.ProjectCD.Value)) { if (item.UserCD == this.UserCD) { continue; } var rUser = item.User; var bt = new PostbackButton(); bt.Title = rUser.DisplayName; var cm = new PayloadCommand(); cm.CommandName = BotCommandName.TaskAdd; cm.MethodName = "SelectUser"; cm.Value = rUser.UserCD.ToString(); bt.SetPayload(cm); l.Add(bt); } var cl = new FacebookBotClient(); foreach (var item in ButtonTemplateMessage.Create(this.RecipientID , this.TextManager.Text(BotTextKey.PleaseSelectTaskUser), l)) { cl.SendMessage(item); } }
private void Complete() { var cl = new FacebookBotClient(); if (this.Data.HasData) { cl.SendMessage(this.RecipientID, this.Text(BotTextKey.AllTaskDone)); } else { cl.SendMessage(this.RecipientID, this.Text(BotTextKey.ThereIsNoInCompleteTask)); } this.DeleteCommandData(); }
protected void SendImage(BotActionType actionType) { var cl = new FacebookBotClient(); cl.SuppressThrowException = true; var l = WebApp.Current.DatabaseCache.BotActionImage .Where(el => el.BotCD == this.BotCD && el.ActionType == actionType).ToList(); if (l.Count == 0) { return; } var index = _Random.Next(l.Count); var rImage = l[index]; HttpResponse res = null; var rAttachment = WebApp.Current.DatabaseCache.FacebookAttachment.FirstOrDefault(el => el.Url == rImage.ImageUrl); if (rAttachment == null) { res = cl.SendImage(this.RecipientID, rImage.ImageUrl); if (res.StatusCode == HttpStatusCode.OK) { try { var o = JsonConvert.DeserializeObject <SendMediaResponse>(res.BodyText); rAttachment = new FacebookAttachmentRecord(); rAttachment.AttachmentID = o.Attachment_ID; rAttachment.Url = rImage.ImageUrl; rAttachment.CreateTime = DateTimeInfo.GetNow(); var dc = new SystemDataContext(); dc.FacebookAttachment_Insert(rAttachment); } catch (Exception ex) { HignullLog.Current.Add(ex); } } } else { res = cl.SendAttachment(this.RecipientID, rAttachment.AttachmentID); } }
protected void ResponseAskYesNo(String title, BotCommandName commandName, String methodName) { var tp = new ButtonTemplateMessage(); tp.RecipientID = this.RecipientID; tp.Text = title; { var bt = new PostbackButton(); bt.Title = this.Text(TextKey.Confirm_Yes); bt.SetPayload(commandName, methodName, "True"); tp.Buttons.Add(bt); } { var bt = new PostbackButton(); bt.Title = this.Text(TextKey.Confirm_No); bt.SetPayload(commandName, methodName, "False"); tp.Buttons.Add(bt); } var cl = new FacebookBotClient(); cl.SendMessage(tp); }
private void ResponseAskStartTime() { var tm = this.TextManager; var cl = new FacebookBotClient(); cl.SendMessage(this.RecipientID, this.TextManager.Text(BotTextKey.AskStartTime)); var tp = new ButtonTemplateMessage(); tp.RecipientID = this.RecipientID; tp.Text = " "; var bt = new PostbackButton(); bt.Title = tm.Text(BotTextKey.DisplayDateTimeSample); var cm = new PayloadCommand(); cm.CommandName = BotCommandName.ScheduleAdd; cm.MethodName = nameof(BotTextKey.DateTimeSample); cm.Value = ""; bt.SetPayload(cm); tp.Buttons.Add(bt); cl.SendMessage(tp); }
private void ResponseAskSuspend() { if (this.Data.Task == null) { this.Complete(); return; } var rTask = this.Data.Task; var tp = new ButtonTemplateMessage(); tp.RecipientID = this.RecipientID; tp.Text = this.Text(BotTextKey.AskTaskSuspend); { var bt = new PostbackButton(); bt.Title = String.Format(this.Text(BotTextKey.DayAfter_DayFormat), 1); bt.SetPayload(BotCommandName.TaskComplete, "SuspendDay", "1"); tp.Buttons.Add(bt); } { var bt = new PostbackButton(); bt.Title = String.Format(this.Text(BotTextKey.DayAfter_DayFormat), 3); bt.SetPayload(BotCommandName.TaskComplete, "SuspendDay", "3"); tp.Buttons.Add(bt); } { var bt = new PostbackButton(); bt.Title = this.Text(BotTextKey.DayAfter_1Week); bt.SetPayload(BotCommandName.TaskComplete, "SuspendDay", "7"); tp.Buttons.Add(bt); } var cl = new FacebookBotClient(); cl.SendMessage(tp); }
private void ResponseAskViewPermission() { var tm = this.TextManager; var l = new List <IButton>(); foreach (var item in Enum <ScheduleViewPermission> .GetValues()) { var bt = new PostbackButton(); bt.Title = tm.Text(item); var cm = new PayloadCommand(); cm.CommandName = BotCommandName.ScheduleAdd; cm.MethodName = nameof(State.AskViewPermission); cm.Value = item.ToStringFromEnum(); bt.SetPayload(cm); l.Add(bt); } var cl = new FacebookBotClient(); foreach (var item in ButtonTemplateMessage.Create(this.RecipientID , this.TextManager.Text(BotTextKey.PleaseSelectViewPermission), l)) { cl.SendMessage(item); } }
public override void ResponseMessage() { var cl = new FacebookBotClient(); cl.SendMessage(this.RecipientID, this.TextManager.Text(BotTextKey.CanIHelpYou)); }
private void ResponseEndTimeMustBeLargerThanStartTime() { var cl = new FacebookBotClient(); cl.SendMessage(this.RecipientID, this.TextManager.Text(TextKey.EndTimeMustBeLargerThanStartTime)); }
private void ResponseShowSampleDateTimeFormat() { var cl = new FacebookBotClient(); cl.SendMessage(this.RecipientID, this.TextManager.Text(BotTextKey.DateTimeSample)); }
private void ResponseAskDueDate() { var cl = new FacebookBotClient(); cl.SendMessage(this.RecipientID, this.TextManager.Text(BotTextKey.AskDueDate)); }