Beispiel #1
0
        public static bool IsTenantQuotaEnded(this MailBox mailbox, long minBalance, ILogger log = null)
        {
            var quotaEnded = false;

            log = log ?? new NullLogger();

            try
            {
                var quotaController = new TennantQuotaController(mailbox.TenantId);
                var quota           = CoreContext.TenantManager.GetTenantQuota(mailbox.TenantId);
                var usedQuota       = quotaController.QuotaCurrentGet();
                quotaEnded = quota.MaxTotalSize - usedQuota < minBalance;
                log.Debug("IsTenantQuotaEnded: {0} Tenant = {1}. Tenant quota = {2}Mb ({3}), used quota = {4}Mb ({5}) ",
                          quotaEnded,
                          mailbox.TenantId,
                          MailUtil.BytesToMegabytes(quota.MaxTotalSize), quota.MaxTotalSize,
                          MailUtil.BytesToMegabytes(usedQuota), usedQuota);
            }
            catch (Exception ex)
            {
                log.Error("IsQuotaExhausted(Tenant={0}) Exception: {1}", mailbox.TenantId, ex.Message);
            }

            return(quotaEnded);
        }
Beispiel #2
0
        public static bool IsTenantQuotaEnded(this MailBox mailbox, long minBalance, ILogger log = null)
        {
            var result = false;

            log = log ?? new NullLogger();

            try
            {
                var quotaController = new TennantQuotaController(mailbox.TenantId);
                var quota           = CoreContext.TenantManager.GetTenantQuota(mailbox.TenantId);
                var usedQuota       = quotaController.QuotaCurrentGet();
                log.Debug("Tenant = {0}. Tenant quota = {1}Mb ({2}), used quota = {3}Mb ({4})", mailbox.TenantId,
                          MailUtil.BytesToMegabytes(quota.MaxTotalSize), quota.MaxTotalSize, MailUtil.BytesToMegabytes(usedQuota), usedQuota);
                result = quota.MaxTotalSize - usedQuota < minBalance;
            }
            catch (Exception ex)
            {
                log.Error("IsQuotaExhausted with param tenant={0} Exception:\r\n{0}\r\n", mailbox.TenantId, ex.ToString());
            }

            return(result);
        }