public HttpResponseMessage RemovePhone(string phone) { if (string.IsNullOrWhiteSpace(phone)) { throw new ArgumentException("phone"); } try { log.DebugFormat("RemovePhone phone = {0}", phone); var healthcheckSettings = HealthCheckSettingsAccessor.GetHealthCheckSettings(); phone = phone.ToLower(); if (!healthcheckSettings.PhoneNumbers.Contains(phone)) { log.DebugFormat("No such phone number, phone = {0}", phone); return(ResultHelper.Error(HealthCheckResource.NoSuchPnone)); } healthcheckSettings.PhoneNumbers.Remove(phone); HealthCheckSettingsAccessor.SaveHealthCheckSettings(healthcheckSettings); log.DebugFormat("Remove Phone Success! phone = {0}", phone); return(ResultHelper.Success(HealthCheckResource.RemovePhoneSuccess)); } catch (Exception ex) { log.ErrorFormat("Error on RemovePhone. phone = {0} {1} {2}", phone, ex.ToString(), ex.InnerException != null ? ex.InnerException.Message : string.Empty); return(ResultHelper.Error(HealthCheckResource.RemovePhoneError)); } }
public HttpResponseMessage RemoveEmail(string email) { if (string.IsNullOrWhiteSpace(email)) { throw new ArgumentException("email"); } try { log.DebugFormat("RemoveEmail email = {0}", email); var healthcheckSettings = HealthCheckSettingsAccessor.GetHealthCheckSettings(); email = email.ToLower(); if (!healthcheckSettings.Emails.Contains(email)) { log.DebugFormat("No such email address email = {0}", email); return(ResultHelper.Error(HealthCheckResource.NoSuchEmailAddress)); } healthcheckSettings.Emails.Remove(email); HealthCheckSettingsAccessor.SaveHealthCheckSettings(healthcheckSettings); log.DebugFormat("Remove Email Success! email = {0}", email); return(ResultHelper.Success(HealthCheckResource.RemoveEmailSuccess)); } catch (Exception ex) { log.ErrorFormat("Error on RemoveEmail. email = {0} {1} {2}", email, ex.ToString(), ex.InnerException != null ? ex.InnerException.Message : string.Empty); return(ResultHelper.Error(HealthCheckResource.RemoveEmailError)); } }
public HttpResponseMessage SetNotifySettings(bool sendNotify, int sendEmailSms) { try { log.DebugFormat("SetNotifySettings sendNotify = {0}, sendEmailSms = {1}", sendNotify, sendEmailSms); var healthcheckSettings = HealthCheckSettingsAccessor.GetHealthCheckSettings(); healthcheckSettings.SendNotify = sendNotify; switch (sendEmailSms) { case 0: healthcheckSettings.SendEmail = true; healthcheckSettings.SendSms = false; break; case 1: healthcheckSettings.SendEmail = false; healthcheckSettings.SendSms = true; break; case 2: healthcheckSettings.SendEmail = true; healthcheckSettings.SendSms = true; break; default: log.ErrorFormat("Error on SetNotifySettings. Wrong sendEmailSms = {0}", sendEmailSms); return(ResultHelper.Error(HealthCheckResource.SetNotifySettingsError)); } HealthCheckSettingsAccessor.SaveHealthCheckSettings(healthcheckSettings); log.DebugFormat("Set Notify Settings Success! sendNotify = {0} sendNotify = {1}", sendNotify, sendEmailSms); return(ResultHelper.Success()); } catch (Exception ex) { log.ErrorFormat("Error on SetNotifySettings. {0} {1}", ex.ToString(), ex.InnerException != null ? ex.InnerException.Message : string.Empty); return(ResultHelper.Error(HealthCheckResource.SetNotifySettingsError)); } }
private static int GetFakeTenant() { var fakeTenant = CoreContext.TenantManager.GetTenant(FakeTenantAlias); /* * var tenants = CoreContext.TenantManager.GetTenants(); * * if (fakeTenant != null) * { * tenants = tenants.Where(t => t.TenantId != fakeTenant.TenantId).ToList(); * } * * if (tenants.Count() <= 0 || !CoreContext.TenantManager.GetTenantQuota(tenants.First().TenantId).HealthCheck) * { * log.Debug("Service wasn't started. There is no correct license for HealthCheck."); * return; * }*/ if (fakeTenant == null) { fakeTenant = new Tenant { TenantAlias = FakeTenantAlias }; fakeTenant = CoreContext.TenantManager.SaveTenant(fakeTenant); } if (fakeTenant != null) { var healthcheckSettings = HealthCheckSettingsAccessor.GetHealthCheckSettings(); healthcheckSettings.FakeTenantId = fakeTenant.TenantId; HealthCheckSettingsAccessor.SaveHealthCheckSettings(healthcheckSettings); CoreContext.TenantManager.SetCurrentTenant(fakeTenant.TenantId); return(fakeTenant.TenantId); } return(0); }
public HttpResponseMessage AddPhone(string phone) { if (string.IsNullOrWhiteSpace(phone)) { throw new ArgumentException("phone"); } try { log.DebugFormat("AddPhone phone = {0}", phone); var healthcheckSettings = HealthCheckSettingsAccessor.GetHealthCheckSettings(); phone = phone.ToLower(); if (IsValidPhone(phone)) { if (healthcheckSettings.PhoneNumbers.Contains(phone)) { log.DebugFormat("PhoneNumbers already contains this phone! phone = {0}", phone); return(ResultHelper.Error(HealthCheckResource.AlreadyContainsPhone)); } healthcheckSettings.PhoneNumbers.Add(phone); HealthCheckSettingsAccessor.SaveHealthCheckSettings(healthcheckSettings); log.DebugFormat("Add Phone Success! phone = {0}", phone); return(ResultHelper.Success(HealthCheckResource.AddPhoneSuccess)); } log.DebugFormat("Wrong Phone Number! phone = {0}", phone); return(ResultHelper.Error(HealthCheckResource.WrongPhone)); } catch (Exception ex) { log.ErrorFormat("Error on AddPhone. phone = {0} {1} {2}", phone, ex.ToString(), ex.InnerException != null ? ex.InnerException.Message : string.Empty); return(ResultHelper.Error(HealthCheckResource.AddPhoneError)); } }