public ActiveUp.Net.Mail.DeltaExt.MailUser GetManagedUserByAccount(string userName) { MailUser User = null; using (FAXPECContext dbcontext = new FAXPECContext()) { try { var mailsender = dbcontext.MAIL_SENDERS.Where(x => (x.FLG_MANAGED == "2" || x.FLG_MANAGED == "1") && x.MAIL.ToUpper() == userName.ToUpper()).FirstOrDefault(); int idmailserver = (int)mailsender.ID_MAILSERVER; int idmailuser = (int)mailsender.ID_SENDER; if (idmailserver != 0) { MAILSERVERS m = dbcontext.MAILSERVERS.Where(x => x.ID_SVR == idmailserver).FirstOrDefault(); MailServer s = AutoMapperConfiguration.FromMailServersToModel(m); if (idmailuser != 0) { List <Folder> l = GetMailFolders(idmailuser); User = DaoSQLServerDBHelper.MapToMailUser(mailsender, s, l); } } } catch { User = null; throw; } } return(User); }
public ICollection <ActiveUp.Net.Mail.DeltaExt.MailUser> GetAllManaged() { ICollection <MailUser> users = null; using (FAXPECContext dbcontext = new FAXPECContext()) { try { var mailsenders = dbcontext.MAIL_SENDERS.Where(x => x.FLG_MANAGED != null).ToList(); foreach (MAIL_SENDERS sender in mailsenders) { int idMailServer = (int)sender.ID_MAILSERVER; int idUser = (int)sender.ID_SENDER; if (idMailServer != 0) { MAILSERVERS m = dbcontext.MAILSERVERS.Where(x => x.ID_SVR == idMailServer).FirstOrDefault(); MailServer s = AutoMapperConfiguration.FromMailServersToModel(m); if (idUser != 0) { List <Folder> l = GetMailFolders(idUser); users.Add(DaoSQLServerDBHelper.MapToMailUser(sender, s, l)); } } } } catch { users = null; throw; } } return(users); }
public ActiveUp.Net.Mail.DeltaExt.MailUser GetById(decimal id) { ActiveUp.Net.Mail.DeltaExt.MailUser user = null; using (FAXPECContext dbcontext = new FAXPECContext()) { var mailsender = dbcontext.MAIL_SENDERS.Where(x => x.ID_SENDER == id).FirstOrDefault(); try { int idmailserver = (int)mailsender.ID_MAILSERVER; MAILSERVERS ms = dbcontext.MAILSERVERS.Where(x => x.ID_SVR == idmailserver).FirstOrDefault(); MailServer s = AutoMapperConfiguration.FromMailServersToModel(ms); int idmailuser = (int)mailsender.ID_SENDER; List <Folder> list = GetMailFolders(idmailuser); user = DaoSQLServerDBHelper.MapToMailUser(mailsender, s, list); } catch (Exception ex) { if (!ex.GetType().Equals(typeof(ManagedException))) { ManagedException mEx = new ManagedException(ex.Message, "ERR_ACC_006", string.Empty, string.Empty, ex.InnerException); ErrorLogInfo err = new ErrorLogInfo(mEx); err.objectID = id.ToString(); log.Error(err); } user = null; } } return(user); }
public IList <MailUser> GetUsersByMails(IList <String> mails) { List <MailUser> lMU = null; string[] allMails = mails.ToArray(); try { using (FAXPECContext dbcontext = new FAXPECContext()) { lMU = new List <MailUser>(); List <MAIL_SENDERS> l = (from e in dbcontext.MAIL_SENDERS where allMails.Contains(e.MAIL) select e).ToList(); foreach (MAIL_SENDERS m in l) { int idmailserver = (int)m.ID_MAILSERVER; MAILSERVERS ms = dbcontext.MAILSERVERS.Where(x => x.ID_SVR == idmailserver).FirstOrDefault(); MailServer s = AutoMapperConfiguration.FromMailServersToModel(ms); int idmailuser = (int)m.ID_SENDER; List <Folder> list = GetMailFolders(idmailuser); lMU.Add(DaoSQLServerDBHelper.MapToMailUser(m, s, list)); } } } catch (Exception ex) { if (!ex.GetType().Equals(typeof(ManagedException))) { ManagedException mEx = new ManagedException(ex.Message, "ERR_ACC_001", string.Empty, string.Empty, ex.InnerException); ErrorLogInfo err = new ErrorLogInfo(mEx); err.objectID = string.Empty; log.Error(err); } lMU = null; } return(lMU); }
public IList <MailUser> GetUserByServerAndUsername(decimal idServer, string userName) { List <MailUser> lUser = null; using (FAXPECContext dbcontext = new FAXPECContext()) { var mailsender = dbcontext.MAIL_SENDERS.Where(x => x.ID_MAILSERVER == idServer && x.USERNAME.ToUpper() == userName.ToUpper()).FirstOrDefault(); if (mailsender != null) { try { lUser = new List <MailUser>(); MAIL_SENDERS m = dbcontext.MAIL_SENDERS.Where(x => x.ID_MAILSERVER == idServer).FirstOrDefault(); int idmailserver = (int)m.ID_MAILSERVER; MAILSERVERS ms = dbcontext.MAILSERVERS.Where(x => x.ID_SVR == idmailserver).FirstOrDefault(); int idmailuser = (int)mailsender.ID_SENDER; MailServer s = AutoMapperConfiguration.FromMailServersToModel(ms); if (idmailuser != 0) { List <Folder> l = GetMailFolders(idmailuser); lUser.Add(DaoSQLServerDBHelper.MapToMailUser(mailsender, s, l)); } } catch { lUser = null; throw; } } else { return(lUser); } } return(lUser); }