示例#1
0
        public bool DisableMailboxes(IMailboxExp exp)
        {
            using (var daoFactory = new DaoFactory())
            {
                var daoMailbox = daoFactory.CreateMailboxDao();

                return(daoMailbox.Enable(exp, false));
            }
        }
示例#2
0
        public bool SetNextLoginDelay(IMailboxExp exp, TimeSpan delay)
        {
            using (var daoFactory = new DaoFactory())
            {
                var daoMailbox = daoFactory.CreateMailboxDao();

                return(daoMailbox.SetNextLoginDelay(exp, delay));
            }
        }
示例#3
0
        public Tuple <int, int> GetRangeMailboxes(IMailboxExp exp)
        {
            using (var daoFactory = new DaoFactory())
            {
                var daoMailbox = daoFactory.CreateMailboxDao();

                return(daoMailbox.GetRangeMailboxes(exp));
            }
        }
示例#4
0
        public List <Tuple <int, string> > GetMailUsers(IMailboxExp exp)
        {
            using (var daoFactory = new DaoFactory())
            {
                var daoMailbox = daoFactory.CreateMailboxDao();

                return(daoMailbox.GetMailUsers(exp));
            }
        }
示例#5
0
        public Mailbox GetMailBox(IMailboxExp exp)
        {
            var query = Query()
                        .Where(exp.GetExpression());

            return(Db.ExecuteList(query)
                   .ConvertAll(ToMailbox)
                   .SingleOrDefault());
        }
示例#6
0
        public MailboxStatus GetMailboxStatus(IMailboxExp exp)
        {
            using (var daoFactory = new DaoFactory())
            {
                var daoMailbox = daoFactory.CreateMailboxDao();

                var status = daoMailbox.GetMailBoxStatus(exp);

                return(status);
            }
        }
示例#7
0
        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());
        }
示例#8
0
        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);
        }
示例#9
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);
        }
示例#10
0
        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);
        }
示例#11
0
        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);
        }
示例#12
0
        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());
        }
示例#13
0
        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);
        }
示例#14
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);
            }
        }
示例#15
0
        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);
        }
示例#16
0
        public MailBoxData GetMailboxData(IMailboxExp exp)
        {
            var tuple = GetMailboxFullInfo(exp);

            return(tuple == null ? null : tuple.Item1);
        }