public IEnumerable <MailBox> GetInbox(Guid userId) { try { var list = new MailBoxBO().GetInbox(this.ConnectionHandler, userId); var outlist = new List <MailBox>(); var mailInfoBo = new MailInfoBO(); var enterpriseNodeFacade = EnterpriseNodeComponent.Instance.EnterpriseNodeFacade; foreach (var item in list) { if (outlist.All(box => box.MailId != item.MailId)) { var mailInfo = mailInfoBo.Get(base.ConnectionHandler, item.MailId); if (mailInfo != null) { item.MailInfo = mailInfo; item.FromEnterpriseNode = enterpriseNodeFacade.Get(item.FromId); } outlist.Add(item); } } return(outlist.OrderByDescending(x => x.MailInfo.Date)); } catch (KnownException ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { throw new KnownException(ex.Message, ex); } }
public IEnumerable <MailInfo> GetDraftbox(Guid userId) { try { var list = new MailInfoBO().Where(this.ConnectionHandler, x => x.FromId == userId ); var outlist = new List <MailInfo>(); var enterpriseNodeFacade = EnterpriseNodeComponent.Instance.EnterpriseNodeFacade; foreach (var item in list) { if (outlist.All(box => box.Id != item.Id)) { if (!item.IsDraft) { continue; } foreach (var toId in item.To.Split(',')) { if (!string.IsNullOrEmpty(item.ToNames)) { item.ToNames += ","; } if (string.IsNullOrEmpty(toId)) { continue; } var user = enterpriseNodeFacade.Get(toId.ToGuid()); if (user != null) { item.ToNames += user.Title(); } } outlist.Add(item); } } return(outlist.OrderByDescending(x => x.Date)); } catch (KnownException ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }