Пример #1
0
        public async Task CreateOrganizationSettingAsync(
            OrganizationSetting setting,
            CancellationToken cancellationToken = default)
        {
            if (setting == null)
            {
                throw new ArgumentNullException(nameof(setting));
            }

            await _organizationAccessControlService.CheckOrganizationUpdateAccessAsync(setting.OrganizationId);

            if (await _context.OrganizationSettings
                .AnyAsync(s => s.OrganizationId == setting.OrganizationId &&
                          s.Name == setting.Name, cancellationToken))
            {
                throw new DuplicateException(
                          $"Setting {setting.Name} already exists for organization {setting.OrganizationId}");
            }

            try
            {
                await _context.OrganizationSettings.AddAsync(setting, cancellationToken);

                await _context.SaveChangesAsync(cancellationToken);

                _organizationSettingsCache.InvalidateCacheForOrganization(setting.OrganizationId);
            }
            catch (DbUpdateException e) when(e.IsUniqueKeyViolation())
            {
                _context.OrganizationSettings.Remove(setting);
                throw new DuplicateException(
                          $"Setting {setting.Name} already exists for organization {setting.OrganizationId}", e);
            }
        }
        public static string GetOrganizationSetting(RestCommand command, int organizationSettingID)
        {
            OrganizationSetting organizationSetting = OrganizationSettings.GetOrganizationSetting(command.LoginUser, organizationSettingID);

            if (organizationSetting.OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            return(organizationSetting.GetXml("OrganizationSetting", true));
        }
Пример #3
0
        public async Task RemoveOrganizationSettingAsync(
            OrganizationSetting setting,
            CancellationToken cancellationToken = default)
        {
            if (setting == null)
            {
                throw new ArgumentNullException(nameof(setting));
            }

            await _organizationAccessControlService.CheckOrganizationUpdateAccessAsync(setting.OrganizationId);

            await _context.DeleteAsync(setting, cancellationToken);

            _organizationSettingsCache.InvalidateCacheForOrganization(setting.OrganizationId);
        }
Пример #4
0
 private static void InitOrganizationSetting()
 {
     try
     {
         var xmlPath = DataDir + "\\OrganizationSetting";
         var xmlMgr  = new XmlHandler(xmlPath);
         OrganizationSetting = xmlMgr.ConvertToObject <OrganizationSetting>();
         //+2
         //OrganizationSetting.RunAsAdminLocalAccountPassword = EncryptionHelper.SmDecrypt(OrganizationSetting.RunAsAdminLocalAccountPassword);
         //OrganizationSetting.RunAsAdminDomainAccountPassword = EncryptionHelper.SmDecrypt(OrganizationSetting.RunAsAdminDomainAccountPassword);
     }
     catch (Exception ex)
     {
         throw new ArgumentException("\n>> " + TypeName + ".InitOrganizationSetting Error:" + ex.Message);
     }
 }
Пример #5
0
        public static async Task <IDisposableEntity <OrganizationSetting> > CreateOrganizationSettingAsync(
            this TestServiceScope scope,
            Organization organization,
            string name, string value)
        {
            var setting = new OrganizationSetting
            {
                OrganizationId = organization.OrganizationId,
                Name           = name,
                Value          = value
            };

            await scope.Db.OrganizationSettings.AddAsync(setting);

            await scope.Db.SaveChangesAsync();

            return(new DisposableEntity <OrganizationSetting>(setting, scope.Db));
        }
Пример #6
0
        public async Task UpdateOrganizationSettingAsync(
            OrganizationSetting setting,
            CancellationToken cancellationToken = default)
        {
            if (setting == null)
            {
                throw new ArgumentNullException(nameof(setting));
            }

            try
            {
                await _organizationAccessControlService.CheckOrganizationUpdateAccessAsync(setting.OrganizationId);

                await _context.UpdateAsync(setting, cancellationToken);

                _organizationSettingsCache.InvalidateCacheForOrganization(setting.OrganizationId);
            }
            catch (DbUpdateException e) when(e.IsUniqueKeyViolation())
            {
                _context.DisableChangeTracking(setting);
                throw new DuplicateException(
                          $"Setting {setting.Name} already exists for organization {setting.OrganizationId}", e);
            }
        }
 public void DeleteSetting(OrganizationSetting organizationSetting)
 {
 }
 public void DeleteSetting(OrganizationSetting organizationSetting)
 {
     ObjectContext.OrganizationSettings.Remove(organizationSetting);
 }