Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        public IEnumerable <MailBox> GetTrash(Guid userId)
        {
            try
            {
                var list       = new MailBoxBO().GetUserTrash(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))
                    {
                        item.MailInfo = mailInfoBo.Get(base.ConnectionHandler, item.MailId);

                        foreach (var toId in item.MailInfo.To.Split(','))
                        {
                            if (!string.IsNullOrEmpty(item.MailInfo.ToNames))
                            {
                                item.MailInfo.ToNames += ",";
                            }
                            if (string.IsNullOrEmpty(toId))
                            {
                                continue;
                            }
                            var user = enterpriseNodeFacade.Get(toId.ToGuid());
                            if (user != null)
                            {
                                item.MailInfo.ToNames += user.Title();
                            }
                        }

                        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)
            {
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
        }
Exemplo n.º 3
0
 public IEnumerable <MailBox> GetAllUserMessage(Guid userId)
 {
     try
     {
         var list = new MailBoxBO().Where(this.ConnectionHandler, c => c.ToId == userId);
         return(list);
     }
     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);
     }
 }