private void DeactivateExpiredCompanies() { AspSettings settings = AspSettings.Load(); if (settings.AutoDeactivateExpired) { foreach (Guid cid in CManage.GetCompaniesByCategory(CompanyCategory.Expired, 0, false)) { try { CManage.DeactivateCompany(cid); // Send e-mail to operator if (!string.IsNullOrEmpty(settings.OperatorEmail)) { TemplateVariables vars = CManage.CompanyGetVariables(cid); CManage.SendEmail(settings.OperatorEmail, EmailType.TrialDeactivated, vars); } } catch (Exception ex) { Log.WriteError(ex.ToString()); } } } if (settings.AutoDeactivateUnpaid && settings.UseTariffs) { foreach (Guid cid in CManage.GetCompaniesByCategory(CompanyCategory.BillableForDeactivate, 0, false)) { try { CManage.DeactivateCompany(cid); // Send e-mail to operator if (!string.IsNullOrEmpty(settings.OperatorEmail)) { TemplateVariables vars = CManage.CompanyGetVariables(cid); CManage.SendEmail(settings.OperatorEmail, EmailType.OperatorCompanyDeactivated, vars); } } catch (Exception ex) { Log.WriteError(ex.ToString()); } } } }