public static Common.Models.Message GetLatest(this ICache cache) { Common.Models.Message msg = null; if (cache != null) { var collection = cache.Get; if (collection != null && collection.Count() > 0) { msg = collection.Last(); } } return(msg); }
public void MessageMapper() { var fields = new Common.Models.Message() { Id = "SomeId", Text = "Some message", Title = "Test summary", ReceivedAt = DateTime.Now.AddHours(-2) }; var message = fields.MapEx(); Assert.IsType <Web.Models.Message>(message); Assert.Equal(fields.Title, message.Title); Assert.Equal(fields.Text, message.Text); Assert.Equal(fields.ReceivedAt, message.ReceivedAt); Assert.Equal(fields.Id, message.Id); }
public void CreateMessageAsync(Common.Models.Message message, object userState) { if ((this.onBeginCreateMessageDelegate == null)) { this.onBeginCreateMessageDelegate = new BeginOperationDelegate(this.OnBeginCreateMessage); } if ((this.onEndCreateMessageDelegate == null)) { this.onEndCreateMessageDelegate = new EndOperationDelegate(this.OnEndCreateMessage); } if ((this.onCreateMessageCompletedDelegate == null)) { this.onCreateMessageCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnCreateMessageCompleted); } base.InvokeAsync(this.onBeginCreateMessageDelegate, new object[] { message }, this.onEndCreateMessageDelegate, this.onCreateMessageCompletedDelegate, userState); }
void ProcessNewMails() { try { _outlookManager = new Outlook.OutlookManager(); _outlookManager.SetFoldersToMonitor(ConfigurationManager.AppSettings["MAPIFolders"].Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); Observable.FromEventPattern<Outlook.NewMailReceivedEventArgs>(_outlookManager, "MailReceived", Scheduler.ThreadPool). Throttle(TimeSpan.FromSeconds(.7)).ObserveOn(Scheduler.ThreadPool).Subscribe(evt => { var message = new Common.Models.Message(); message.From = evt.EventArgs.FromUser; message.FromEmail = evt.EventArgs.FromEmail; message.Content = evt.EventArgs.Body; message.Subject = evt.EventArgs.Subject; message.When = DateTime.UtcNow; message.IsNew = true; message.UserKey = LoggedUser.Key; //this hint was applied for linking application and its sent messages if (ServerApp != null && !string.IsNullOrEmpty(ServerApp.AppId)) message.AppKey = ServerApp.Key; if (GroupToSend != null) message.GroupKey = GroupToSend.Key; GalaSoft.MvvmLight.Threading.DispatcherHelper.InvokeAsync(() => NewMails.Add(message)); var result = HttpClientHelper.PostSimple<string, Common.Models.Message>(ConfigurationManager.AppSettings["baseUrl"], "/api/messanger/postmessage/", message); if (!string.IsNullOrEmpty(result)) { int key; int.TryParse(result, out key); Infrastructure.LinkManager.Instance.Add(evt.EventArgs.EntryID, key); Infrastructure.LinkManager.Instance.SaveToFile(App.AppMsgsLinkPath); } }, ex => ViewModelLocator.Logger.Error("Error in mail pull workflow", ex) , _cts.Token); } catch (Exception) { if (_outlookManager != null) { _outlookManager.Dispose(); _outlookManager = null; } } }
public static Models.Message MapEx(this Common.Models.Message message) { return(Mapper.Map <Models.Message>(message)); }
public void CreateMessageAsync(Common.Models.Message message) { this.CreateMessageAsync(message, null); }
private System.IAsyncResult OnBeginCreateMessage(object[] inValues, System.AsyncCallback callback, object asyncState) { Common.Models.Message message = ((Common.Models.Message)(inValues[0])); return(this.BeginCreateMessage(message, callback, asyncState)); }
public System.IAsyncResult BeginCreateMessage(Common.Models.Message message, System.AsyncCallback callback, object asyncState) { return(base.Channel.BeginCreateMessage(message, callback, asyncState)); }
public Common.Models.ServerResponse CreateMessage(Common.Models.Message message) { return(base.Channel.CreateMessage(message)); }