private void PerformOperation(InboxType inboxType, EmailActionType actionType, DateTime occured) { // log.Info("Hello logging world!"); MailManager bLManager = new MailManager(); bLManager.Process(actionType, inboxType, occured); // }
public void Process(EmailActionType processingType, InboxType doneIn, DateTime date) { WriteToLog($"[Process Start]"); PrintMailElements(mailElements); WriteToLog($"{processingType} {doneIn} "); var actionListScoped = this.actionList.Where(x => x.DoneIn == doneIn && x.Action == processingType).ToList(); var withPrevious = actionListScoped.Where(x => x.AndPreviousAction != EmailActionType.None); //List<ActionItem> withoutHistoryList = this.list.Where(x => x.AndPreviousAction == EmailActionType.None).ToList(); //List<ActionItem> withtHistoryList = this.list.Where(x => x.AndPreviousAction != EmailActionType.None).ToList(); foreach (var currentAction in withPrevious) { var element = mailElements.FirstOrDefault(x => x.Value.PreviousAction == currentAction.AndPreviousAction && x.Value.PreviousDoneIn == currentAction.PreviousDoneIn && x.Value.AddedDate.AddMilliseconds(milisecondsDelay) > DateTime.Now ); if (element.Value != null) { WriteToLog($"Perform action: {currentAction.Id}"); MailElement x; mailElements.TryRemove(element.Key, out x); currentAction.ThenPerform(date); mailElements.TryAdd(Guid.NewGuid(), new MailElement(processingType, doneIn)); return; } } var withoutPrevious = actionListScoped.Single(x => x.AndPreviousAction == EmailActionType.None); WriteToLog($"Perform action: {withoutPrevious.Id}"); withoutPrevious.ThenPerform(date); mailElements.TryAdd(Guid.NewGuid(), new MailElement(processingType, doneIn)); return; }
/// <summary> /// Returns a list of private messages from the specified inbox type. /// Note that it will return up to 25 messages, depending on the specified page. /// This variant runs asychronously. /// </summary> public async Task <List <PrivateMessageInformation> > GetPrivateMessagesAsync(InboxType box = InboxType.Inbox, int page = 1) { PrivateMessageContainer container = await GetPrivateMessageContainerAsync(box, page); return(container.PMs); }
/// <summary> /// Returns a list of private messages from the specified inbox type. /// Note that it will return up to 25 messages, depending on the specified page. /// </summary> public List <PrivateMessageInformation> GetPrivateMessages(InboxType box = InboxType.Inbox, int page = 1) { PrivateMessageContainer container = GetPrivateMessageContainer(box, page); return(container.PMs); }
/// <summary> /// Returns a struct containing information about the specified InboxType alongside a list of messages. /// This variant runs asychronously. /// </summary> public async Task <PrivateMessageContainer> GetPrivateMessageContainerAsync(InboxType box = InboxType.Inbox, int page = 1) { string path = "pmbox/" + box + "?page=" + page; return(await Client.ApiGetAsync <PrivateMessageContainer>(path)); }
/// <summary> /// Returns a struct containing information about the specified InboxType alongside a list of messages. /// </summary> public PrivateMessageContainer GetPrivateMessageContainer(InboxType box = InboxType.Inbox, int page = 1) { string path = "pmbox/" + box + "?page=" + page; return(Client.ApiGet <PrivateMessageContainer>(path)); }
public MailElement(EmailActionType processingType, InboxType inboxType) { this.AddedDate = DateTime.Now; this.PreviousAction = processingType; this.PreviousDoneIn = inboxType; }
public void ProcessMail(InboxType inboxType, EmailActionType actionType, DateTime occured) { PerformOperation(inboxType, actionType, occured); }
public void ProcessOutlookMail(InboxType inboxType, EmailActionType actionType) { this.Client.ProcessMail(inboxType, actionType, Now); (this.Client as IClientChannel).Close(); }
public ActionResult ModeratorMail(InboxType type, string subName = null, int? pageNumber = null, int? pageSize = null) { ViewBag.ManageNavigationKey = "moderatormail"; if (pageNumber == null || pageNumber < 1) pageNumber = 1; if (pageSize == null) pageSize = 25; if (pageSize > 100) pageSize = 100; if (pageSize < 1) pageSize = 1; var skip = (pageNumber - 1) * pageSize; var take = pageSize; var moderatingSubs = _moderationDao.GetSubsModeratoredByUserWithPermissions(_userContext.CurrentUser.Id); var model = new InboxViewModel { InboxType = type }; model.IsModerator = moderatingSubs.Count > 0; if (!string.IsNullOrEmpty(subName)) { var sub = _subDao.GetSubByName(subName); if (sub == null) throw new NotFoundException(); // make the sure that the user is allowed to see this mod mail if (!_userContext.CurrentUser.IsAdmin) { if (!moderatingSubs.ContainsKey(sub.Id)) throw new UnauthorizedException(); if (!moderatingSubs[sub.Id].HasPermission(ModeratorPermissions.Mail)) throw new UnauthorizedException(); } model.Sub = sub; model.ModeratorMailForSubs = new List<Guid> { sub.Id }; } else { model.ModeratorMailForSubs = new List<Guid>(); foreach (var key in moderatingSubs.Keys) { if (moderatingSubs[key].HasPermission(ModeratorPermissions.Mail)) model.ModeratorMailForSubs.Add(key); } } SeekedList<Guid> messages; if (moderatingSubs.Count == 0) messages = new SeekedList<Guid>(); else switch (type) { case InboxType.ModeratorMail: messages = _messageDao.GetModeratorMailForSubs(moderatingSubs.Select(x => x.Key).ToList(), skip, take); break; case InboxType.ModeratorMailUnread: messages = _messageDao.GetUnreadModeratorMailForSubs(moderatingSubs.Select(x => x.Key).ToList(), skip, take); break; case InboxType.ModeratorMailSent: messages = _messageDao.GetSentModeratorMailForSubs(moderatingSubs.Select(x => x.Key).ToList(), skip, take); break; default: throw new Exception("invalid type"); } model.Messages = new PagedList<MessageWrapped>(_messageWrapper.Wrap(messages, _userContext.CurrentUser), pageNumber.Value, pageSize.Value, messages.HasMore); return View(model); }
public ActionResult Inbox(InboxType type, int? pageNumber, int? pageSize) { ViewBag.ManageNavigationKey = "inbox"; if (pageNumber == null || pageNumber < 1) pageNumber = 1; if (pageSize == null) pageSize = 25; if (pageSize > 100) pageSize = 100; if (pageSize < 1) pageSize = 1; var skip = (pageNumber - 1) * pageSize; var take = pageSize; SeekedList<Guid> messages; switch (type) { case InboxType.All: messages = _messageDao.GetAllMessagesForUser(_userContext.CurrentUser.Id, skip, take); break; case InboxType.Unread: messages = _messageDao.GetUnreadMessagesForUser(_userContext.CurrentUser.Id, skip, take); break; case InboxType.Messages: messages = _messageDao.GetPrivateMessagesForUser(_userContext.CurrentUser.Id, skip, take); break; case InboxType.CommentReplies: messages = _messageDao.GetCommentRepliesForUser(_userContext.CurrentUser.Id, skip, take); break; case InboxType.PostReplies: messages = _messageDao.GetPostRepliesForUser(_userContext.CurrentUser.Id, skip, take); break; case InboxType.Mentions: messages = _messageDao.GetMentionsForUser(_userContext.CurrentUser.Id, skip, take); break; default: throw new Exception("Unknown inbox type"); } var model = new InboxViewModel(); model.InboxType = type; model.IsModerator = _moderationDao.GetSubsModeratoredByUser(_userContext.CurrentUser.Id).Count > 0; model.Messages = new PagedList<MessageWrapped>(_messageWrapper.Wrap(messages, _userContext.CurrentUser), pageNumber.Value, pageSize.Value, messages.HasMore); return View(model); }
public ActionResult Inbox(InboxType type, int?pageNumber, int?pageSize) { ViewBag.ManageNavigationKey = "inbox"; if (pageNumber == null || pageNumber < 1) { pageNumber = 1; } if (pageSize == null) { pageSize = 25; } if (pageSize > 100) { pageSize = 100; } if (pageSize < 1) { pageSize = 1; } var skip = (pageNumber - 1) * pageSize; var take = pageSize; SeekedList <Guid> messages; switch (type) { case InboxType.All: messages = _messageDao.GetAllMessagesForUser(_userContext.CurrentUser.Id, skip, take); break; case InboxType.Unread: messages = _messageDao.GetUnreadMessagesForUser(_userContext.CurrentUser.Id, skip, take); break; case InboxType.Messages: messages = _messageDao.GetPrivateMessagesForUser(_userContext.CurrentUser.Id, skip, take); break; case InboxType.CommentReplies: messages = _messageDao.GetCommentRepliesForUser(_userContext.CurrentUser.Id, skip, take); break; case InboxType.PostReplies: messages = _messageDao.GetPostRepliesForUser(_userContext.CurrentUser.Id, skip, take); break; case InboxType.Mentions: messages = _messageDao.GetMentionsForUser(_userContext.CurrentUser.Id, skip, take); break; default: throw new Exception("Unknown inbox type"); } var model = new InboxViewModel(); model.InboxType = type; model.IsModerator = _moderationDao.GetSubsModeratoredByUser(_userContext.CurrentUser.Id).Count > 0; model.Messages = new PagedList <MessageWrapped>(_messageWrapper.Wrap(messages, _userContext.CurrentUser), pageNumber.Value, pageSize.Value, messages.HasMore); return(View(model)); }
public ActionResult ModeratorMail(InboxType type, string subName = null, int?pageNumber = null, int?pageSize = null) { ViewBag.ManageNavigationKey = "moderatormail"; if (pageNumber == null || pageNumber < 1) { pageNumber = 1; } if (pageSize == null) { pageSize = 25; } if (pageSize > 100) { pageSize = 100; } if (pageSize < 1) { pageSize = 1; } var skip = (pageNumber - 1) * pageSize; var take = pageSize; var moderatingSubs = _moderationDao.GetSubsModeratoredByUserWithPermissions(_userContext.CurrentUser.Id); var model = new InboxViewModel { InboxType = type }; model.IsModerator = moderatingSubs.Count > 0; if (!string.IsNullOrEmpty(subName)) { var sub = _subDao.GetSubByName(subName); if (sub == null) { throw new NotFoundException(); } // make the sure that the user is allowed to see this mod mail if (!_userContext.CurrentUser.IsAdmin) { if (!moderatingSubs.ContainsKey(sub.Id)) { throw new UnauthorizedException(); } if (!moderatingSubs[sub.Id].HasPermission(ModeratorPermissions.Mail)) { throw new UnauthorizedException(); } } model.Sub = sub; model.ModeratorMailForSubs = new List <Guid> { sub.Id }; } else { model.ModeratorMailForSubs = new List <Guid>(); foreach (var key in moderatingSubs.Keys) { if (moderatingSubs[key].HasPermission(ModeratorPermissions.Mail)) { model.ModeratorMailForSubs.Add(key); } } } SeekedList <Guid> messages; if (moderatingSubs.Count == 0) { messages = new SeekedList <Guid>(); } else { switch (type) { case InboxType.ModeratorMail: messages = _messageDao.GetModeratorMailForSubs(moderatingSubs.Select(x => x.Key).ToList(), skip, take); break; case InboxType.ModeratorMailUnread: messages = _messageDao.GetUnreadModeratorMailForSubs(moderatingSubs.Select(x => x.Key).ToList(), skip, take); break; case InboxType.ModeratorMailSent: messages = _messageDao.GetSentModeratorMailForSubs(moderatingSubs.Select(x => x.Key).ToList(), skip, take); break; default: throw new Exception("invalid type"); } } model.Messages = new PagedList <MessageWrapped>(_messageWrapper.Wrap(messages, _userContext.CurrentUser), pageNumber.Value, pageSize.Value, messages.HasMore); return(View(model)); }