public bool DisableMailboxes(IMailboxExp exp) { using (var daoFactory = new DaoFactory()) { var daoMailbox = daoFactory.CreateMailboxDao(); return(daoMailbox.Enable(exp, false)); } }
public bool SetNextLoginDelay(IMailboxExp exp, TimeSpan delay) { using (var daoFactory = new DaoFactory()) { var daoMailbox = daoFactory.CreateMailboxDao(); return(daoMailbox.SetNextLoginDelay(exp, delay)); } }
public Tuple <int, int> GetRangeMailboxes(IMailboxExp exp) { using (var daoFactory = new DaoFactory()) { var daoMailbox = daoFactory.CreateMailboxDao(); return(daoMailbox.GetRangeMailboxes(exp)); } }
public List <Tuple <int, string> > GetMailUsers(IMailboxExp exp) { using (var daoFactory = new DaoFactory()) { var daoMailbox = daoFactory.CreateMailboxDao(); return(daoMailbox.GetMailUsers(exp)); } }
public Mailbox GetMailBox(IMailboxExp exp) { var query = Query() .Where(exp.GetExpression()); return(Db.ExecuteList(query) .ConvertAll(ToMailbox) .SingleOrDefault()); }
public MailboxStatus GetMailboxStatus(IMailboxExp exp) { using (var daoFactory = new DaoFactory()) { var daoMailbox = daoFactory.CreateMailboxDao(); var status = daoMailbox.GetMailBoxStatus(exp); return(status); } }
public bool CanAccessTo(IMailboxExp exp) { var query = new SqlQuery(MailboxTable.TABLE_NAME) .Select(MailboxTable.Columns.Id) .Where(exp.GetExpression()); var foundIds = Db.ExecuteList(query) .ConvertAll(res => Convert.ToInt32(res[0])); return(foundIds.Any()); }
public bool SetNextLoginDelay(IMailboxExp exp, TimeSpan delay) { var query = new SqlUpdate(MailboxTable.TABLE_NAME) .Set(MailboxTable.Columns.IsProcessed, false) .Set(string.Format(SET_LOGIN_DELAY_EXPIRES, (int)delay.TotalSeconds)) .Where(exp.GetExpression()); var result = Db.ExecuteNonQuery(query); return(result > 0); }
public List <Tuple <int, string> > GetMailUsers(IMailboxExp exp) { var query = Query() .Select(MailboxTable.Columns.Tenant, MailboxTable.Columns.User) .Where(exp.GetExpression()); var list = Db.ExecuteList(query) .ConvertAll(r => new Tuple <int, string>(Convert.ToInt32(r[0]), Convert.ToString(r[1]))); return(list); }
public Tuple <int, int> GetRangeMailboxes(IMailboxExp exp) { var query = new SqlQuery(MailboxTable.TABLE_NAME) .SelectMin(MailboxTable.Columns.Id) .SelectMax(MailboxTable.Columns.Id) .Where(exp.GetExpression()); var range = Db.ExecuteList(query) .ConvertAll(r => new Tuple <int, int>(Convert.ToInt32(r[0]), Convert.ToInt32(r[1]))) .SingleOrDefault(); return(range); }
public Mailbox GetNextMailBox(IMailboxExp exp) { var query = Query() .Where(exp.GetExpression()) .OrderBy(MailboxTable.Columns.Id, true) .SetMaxResults(1); var mailbox = Db.ExecuteList(query) .ConvertAll(ToMailbox) .SingleOrDefault(); return(mailbox); }
public MailboxStatus GetMailBoxStatus(IMailboxExp exp) { var query = new SqlQuery(MailboxTable.TABLE_NAME) .Select(MailboxTable.Columns.Id, MailboxTable.Columns.IsRemoved, MailboxTable.Columns.Enabled, MailboxTable.Columns.BeginDate) .Where(exp.GetExpression()); return(Db.ExecuteList(query) .ConvertAll(ToMMailboxStatus) .SingleOrDefault()); }
public bool Enable(IMailboxExp exp, bool enabled) { var query = new SqlUpdate(MailboxTable.TABLE_NAME) .Set(MailboxTable.Columns.Enabled, enabled) .Where(exp.GetExpression()); if (enabled) { query.Set(MailboxTable.Columns.DateAuthError, null); } var result = Db.ExecuteNonQuery(query); return(result > 0); }
public Tuple <MailBoxData, Mailbox> GetMailboxFullInfo(IMailboxExp exp) { using (var daoFactory = new DaoFactory()) { var daoMailbox = daoFactory.CreateMailboxDao(); var mailbox = daoMailbox.GetMailBox(exp); if (mailbox == null) { return(null); } var tuple = GetMailbox(daoFactory, mailbox); return(tuple); } }
public bool TryGetNextMailboxData(IMailboxExp exp, out MailBoxData mailBoxData, out int failedId) { failedId = -1; try { using (var daoFactory = new DaoFactory()) { var daoMailbox = daoFactory.CreateMailboxDao(); var mailbox = daoMailbox.GetNextMailBox(exp); if (mailbox == null) { mailBoxData = null; return(false); } var tuple = GetMailbox(daoFactory, mailbox); if (tuple == null) { Log.WarnFormat("Mailbox id = {0} is not well-formated.", mailbox.Id); mailBoxData = null; failedId = mailbox.Id; return(false); } mailBoxData = tuple.Item1; return(true); } } catch (Exception ex) { Log.Error("TryGetNextMailboxData failed", ex); } mailBoxData = null; return(false); }
public MailBoxData GetMailboxData(IMailboxExp exp) { var tuple = GetMailboxFullInfo(exp); return(tuple == null ? null : tuple.Item1); }