private void UpdateCommandData(State nextState) { this.Data.State = nextState; _Record.RetryTime = null; _Record.ExpireTime = DateTimeInfo.GetNow().AddMinutes(ExpireMinutes); _Record.CommandData = JsonConvert.SerializeObject(this.Data); this.UpdateCommandData(); }
private void StartTaskAddCommand() { var dc = new BotDataContext(this.UserCD); var data = new BotCommand_TaskAdd.CommandData(); var rBotCommand = dc.BotCommand_Add(DatabaseSetting.NewGuid(), this.UserCD, BotCommandName.TaskAdd, null , DateTimeInfo.GetNow().AddMinutes(BotCommand_TaskAdd.ExpireMinutes), JsonConvert.SerializeObject(data)); var cm = new BotCommand_TaskAdd(this.RecipientID, this.BotCD, rBotCommand); cm.ResponseMessage(); }
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); } }
public Boolean IsExpired() { return(_Record.ExpireTime.HasValue && _Record.ExpireTime < DateTimeInfo.GetNow()); }