Beispiel #1
0
        public async Task <UpdateStatusEnum> UpdateItemAsync(UnifiedSetData unifiedSet)
        {
            UnifiedSetData origData = Auditing.Active ? await GetItemAsync(unifiedSet.UnifiedSetGuid) : null;

            unifiedSet.Updated = DateTime.UtcNow;
            if (unifiedSet.UnifiedMode == PageDefinition.UnifiedModeEnum.SkinDynamicContent)
            {
                unifiedSet.PageList = new List <string>();
            }
            else
            {
                unifiedSet.PageSkin = new SkinDefinition();
            }
            unifiedSet.PageGuids = await UpdatePageGuidsAsync(unifiedSet.UnifiedSetGuid, unifiedSet.PageList);

            UpdateStatusEnum status = await DataProvider.UpdateAsync(unifiedSet.UnifiedSetGuid, unifiedSet.UnifiedSetGuid, unifiedSet);

            if (status != UpdateStatusEnum.OK)
            {
                return(status);
            }

            await Auditing.AddAuditAsync($"{nameof(UnifiedSetDataProvider)}.{nameof(UpdateItemAsync)}", Dataset, Guid.Empty,
                                         $"Update UPS {unifiedSet.Name}",
                                         DataBefore : origData,
                                         DataAfter : unifiedSet
                                         );

            return(status);
        }
Beispiel #2
0
        public async Task <UpdateStatusEnum> UpdateItemAsync(string originalRole, RoleDefinition data)
        {
            if (data.RoleId == RoleDefinitionDataProvider.SuperUserId || data.Name == Globals.Role_Superuser)
            {
                throw new Error(this.__ResStr("cantUpdateSuper", "Can't update built-in superuser role"));
            }
            if (originalRole != data.Name && IsPredefinedRole(originalRole))
            {
                throw new Error(this.__ResStr("cantUpdateUser", "The {0} role can't be updated", originalRole));
            }
            if (YetaWF.Core.Support.Startup.MultiInstance)
            {
                throw new InternalError("Changing roles is not possible when distributed caching is enabled");
            }
            RoleDefinition origRole = Auditing.Active ? await GetItemAsync(originalRole) : null;

            UpdateStatusEnum status = await DataProvider.UpdateAsync(originalRole, data.Name, data);

            if (status == UpdateStatusEnum.OK)
            {
                GetAllUserRoles(true);
            }
            await Auditing.AddAuditAsync($"{nameof(RoleDefinitionDataProvider)}.{nameof(UpdateItemAsync)}", originalRole, Guid.Empty,
                                         "Update Role",
                                         DataBefore : origRole,
                                         DataAfter : data,
                                         ExpensiveMultiInstance : true
                                         );

            return(status);
        }
Beispiel #3
0
        public async Task <bool> RemoveItemAsync(string role)
        {
            if (role == Globals.Role_Superuser)
            {
                throw new Error(this.__ResStr("cantRemoveSuper", "Can't remove built-in superuser role"));
            }
            if (IsPredefinedRole(role))
            {
                throw new Error(this.__ResStr("cantRemoveUser", "The {0} role can't be removed", role));
            }
            if (YetaWF.Core.Support.Startup.MultiInstance)
            {
                throw new InternalError("Removing roles is not possible when distributed caching is enabled");
            }
            RoleDefinition origRole = Auditing.Active ? await GetItemAsync(role) : null;

            if (!await DataProvider.RemoveAsync(role))
            {
                return(false);
            }
            GetAllUserRoles(true);
            await Auditing.AddAuditAsync($"{nameof(RoleDefinitionDataProvider)}.{nameof(RemoveItemAsync)}", role, Guid.Empty,
                                         "Remove Role",
                                         DataBefore : origRole,
                                         DataAfter : null,
                                         ExpensiveMultiInstance : true
                                         );

            return(true);
        }
Beispiel #4
0
        public async Task <bool> RemoveItemByIdentityAsync(int id)
        {
            VoiceMailData origData = Auditing.Active ? await GetItemByIdentityAsync(id) : null;

            if (!await DataProvider.RemoveByIdentityAsync(id))
            {
                return(false);
            }

            await SetupClient();

            try {
                if (YetaWFManager.IsSync())
                {
                    RecordingResource.Delete(pathSid: origData.RecordingSid);
                }
                else
                {
                    await RecordingResource.DeleteAsync(pathSid : origData.RecordingSid);
                }
            } catch (Exception) { }

            await Auditing.AddAuditAsync($"{nameof(VoiceMailDataProvider)}.{nameof(RemoveItemByIdentityAsync)}", Dataset, Guid.Empty,
                                         $"Remove Voice Mail Entry {id}",
                                         DataBefore : origData,
                                         DataAfter : null
                                         );

            return(true);
        }
        public async Task <ActionResult> LocalizeConfig_Partial(Model model)
        {
            using (LocalizeConfigDataProvider dataProvider = new LocalizeConfigDataProvider()) {
                LocalizeConfigData origData = YetaWF.Core.Audit.Auditing.Active ? await dataProvider.GetItemAsync() : null;

                LocalizeConfigData data = await dataProvider.GetItemAsync();// get the original item

                if (!ModelState.IsValid)
                {
                    return(PartialView(model));
                }
                data = model.GetData(data); // merge new data into original
                model.SetData(data);        // and all the data back into model for final display

                LocalizationSupport locSupport = new LocalizationSupport();
                await locSupport.SetUseLocalizationResourcesAsync(model.UseLocalizationResources);

                await locSupport.SetAbortOnFailureAsync(model.AbortOnFailure);

                await dataProvider.UpdateConfigAsync(data);

                await Auditing.AddAuditAsync($"{nameof(LocalizeConfigModuleController)}.{nameof(LocalizeConfig)}", null, Guid.Empty, $"Localization",
                                             DataBefore : origData,
                                             DataAfter : data,
                                             RequiresRestart : true
                                             );
            }
            return(FormProcessed(model, this.__ResStr("okSaved", "Localization settings saved - These settings won't take effect until the site is restarted")));
        }
        private async Task <PageDefinition> CreatePageDefinitionAsync(PageDefinition page)
        {
            using (ILockObject lockObject = await LockDesignedPagesAsync()) {
                PageDefinition.DesignedPage desPage = new PageDefinition.DesignedPage()
                {
                    PageGuid = page.PageGuid, Url = page.Url,
                };
                DesignedPagesDictionaryByUrl designedPagesByUrl = await GetDesignedPagesWithoutLockAsync();

                if (designedPagesByUrl.ContainsKey(desPage.Url.ToLower()))
                {
                    throw new Error(this.__ResStr("pageUrlErr", "A page with Url {0} already exists.", desPage.Url));
                }
                if (!await DataProvider.AddAsync(page))
                {
                    throw new Error(this.__ResStr("pageGuidErr", "A page with Guid {0} already exists.", desPage.PageGuid));
                }
                await SetCachedPageAsync(page);
                await AddDesignedPageAsync(designedPagesByUrl, page.Url.ToLower(), desPage);

                await lockObject.UnlockAsync();
            }
            await Auditing.AddAuditAsync($"{nameof(PageDefinitionDataProvider)}.{nameof(CreatePageDefinitionAsync)}", page.Url, page.PageGuid,
                                         "Create Page",
                                         DataBefore : null,
                                         DataAfter : page,
                                         ExpensiveMultiInstance : true
                                         );

            return(page);
        }
        public async Task <bool> RemovePageDefinitionAsync(Guid pageGuid)
        {
            PageDefinition page;

            using (ILockObject lockObject = await LockDesignedPagesAsync()) {
                page = await LoadPageDefinitionAsync(pageGuid);

                if (page == null)
                {
                    return(false);
                }
                await Manager.StaticPageManager.RemovePageAsync(page.Url);

                await DataProvider.RemoveAsync(pageGuid);
                await RemoveCachedPageAsync(pageGuid);

                DesignedPagesDictionaryByUrl designedPagesUrl = await GetDesignedPagesWithoutLockAsync();
                await RemoveDesignedPageAsync(designedPagesUrl, page.Url);

                await lockObject.UnlockAsync();
            }
            await Auditing.AddAuditAsync($"{nameof(PageDefinitionDataProvider)}.{nameof(RemovePageDefinitionAsync)}", page.Url, page.PageGuid,
                                         "Remove Page",
                                         DataBefore : page,
                                         DataAfter : null,
                                         ExpensiveMultiInstance : true
                                         );

            return(true);
        }
Beispiel #8
0
        public async Task <bool> AddItemAsync(UnifiedSetData unifiedSet)
        {
            unifiedSet.UnifiedSetGuid = Guid.NewGuid();
            unifiedSet.Created        = DateTime.UtcNow;
            if (unifiedSet.UnifiedMode == PageDefinition.UnifiedModeEnum.SkinDynamicContent)
            {
                unifiedSet.PageList = new List <string>();
            }
            else
            {
                unifiedSet.PageSkin = new SkinDefinition();
            }
            unifiedSet.PageGuids = await UpdatePageGuidsAsync(unifiedSet.UnifiedSetGuid, unifiedSet.PageList);

            if (!await DataProvider.AddAsync(unifiedSet))
            {
                return(false);
            }

            await Auditing.AddAuditAsync($"{nameof(UnifiedSetDataProvider)}.{nameof(AddItemAsync)}", Dataset, Guid.Empty,
                                         $"Add UPS {unifiedSet.Name}",
                                         DataBefore : null,
                                         DataAfter : unifiedSet
                                         );

            return(true);
        }
        internal async Task RemoveSiteDefinitionAsync()
        {
            SiteDefinition site = Manager.CurrentSite;

            if (site.IsDefaultSite)
            {
                throw new Error(this.__ResStr("cantDeleteDefault", "The default site of a YetaWF instance cannot be removed"));
            }

            using (await lockObject.LockAsync()) { // protect SiteCache locally
                // remove all saved data
                SiteCache.Remove(site.SiteDomain.ToLower());
                if (!string.IsNullOrWhiteSpace(site.StaticDomain))
                {
                    StaticSiteCache.Remove(site.StaticDomain.ToLower());
                }
                if (!string.IsNullOrWhiteSpace(site.SiteTestDomain))
                {
                    TestSiteCache.Remove(site.SiteTestDomain.ToLower());
                }

                await Package.RemoveSiteDataAsync(Manager.SiteFolder);

                await DataProvider.RemoveAsync(site.SiteDomain);// remove domain
            }
            await Auditing.AddAuditAsync($"{nameof(SiteDefinitionDataProvider)}.{nameof(SaveSiteDefinitionAsync)}", site.SiteDomain, Guid.Empty,
                                         "Remove Site",
                                         DataBefore : site,
                                         DataAfter : null,
                                         ExpensiveMultiInstance : true
                                         );
        }
        public async Task <bool> AddItemAsync(UserDefinition data)
        {
            CleanupRoles(data);

            if (!Manager.HasSuperUserRole)
            {
                int superuserRole = Resource.ResourceAccess.GetSuperuserRoleId();
                if (data.RolesList.Contains(new Role {
                    RoleId = superuserRole
                }, new RoleComparer()))
                {
                    throw new Error(this.__ResStr("noSup", "Only a superuser can assign superuser status to another user"));
                }
            }
            if (data.UserId == SuperuserDefinitionDataProvider.SuperUserId || string.Compare(data.UserName, SuperuserDefinitionDataProvider.SuperUserName, true) == 0)
            {
                using (SuperuserDefinitionDataProvider superDP = new SuperuserDefinitionDataProvider()) {
                    return(await superDP.AddItemAsync(data));
                }
            }
            bool result = await DataProvider.AddAsync(data);

            await Auditing.AddAuditAsync($"{nameof(UserDefinitionDataProvider)}.{nameof(AddItemAsync)}", data.UserName, Guid.Empty,
                                         "Add User",
                                         DataBefore : null,
                                         DataAfter : data
                                         );

            return(result);
        }
        public async Task <UpdateStatusEnum> UpdateItemAsync(Authorization data)
        {
            Authorization origData = Auditing.Active ? await GetItemAsync(data.ResourceName) : null;

            CleanupUsersAndRoles(data);
            if (data.AllowedUsers.Count > Info.MAX_USERS_IN_RESOURCE)
            {
                throw new Error(this.__ResStr("maxUsers", "Only up to {0} users can be authorized for a resource. Consider creating a role instead, and add all users to that role. There is no limit to the number of users that can be added to a role."));
            }
            UpdateStatusEnum status = await DataProvider.UpdateAsync(data.ResourceName, data.ResourceName, data);

            if (status == UpdateStatusEnum.RecordDeleted)
            {
                if (!await DataProvider.AddAsync(data))
                {
                    throw new Error(this.__ResStr("addFail", "Unexpected error adding new record - {0}", status));
                }
                status = UpdateStatusEnum.OK;
            }
            if (status != UpdateStatusEnum.OK)
            {
                throw new Error(this.__ResStr("updFail", "Unexpected error updating record - {0}", status));
            }
            await Auditing.AddAuditAsync($"{nameof(AuthorizationDataProvider)}.{nameof(UpdateItemAsync)}", data.ResourceName, Guid.Empty,
                                         "Add/Update Authorization",
                                         DataBefore : origData,
                                         DataAfter : data,
                                         ExpensiveMultiInstance : true
                                         );

            return(status);
        }
        public async Task ShutTheBackDoorAsync()
        {
            WebConfigHelper.SetValue <string>(AreaRegistration.CurrentPackage.AreaName, "BACKDOOR-IS-WIDE-OPEN", "0");
            await WebConfigHelper.SaveAsync();

            backDoor = false;
            await Auditing.AddAuditAsync($"{nameof(OwinEditModuleController)}.{nameof(ShutTheBackDoorAsync)}", "BACKDOOR-IS-WIDE-OPEN", Guid.Empty,
                                         $"{nameof(ShutTheBackDoorAsync)}", RequiresRestart : true
                                         );
        }
        // APPSETTINGS.JSON

        public async Task SetRunningAsync(bool running)
        {
            if (running != GetRunning())
            {
                WebConfigHelper.SetValue <bool>(AreaRegistration.CurrentPackage.AreaName, "Running", running);
                await WebConfigHelper.SaveAsync();

                await Auditing.AddAuditAsync($"{nameof(SchedulerDataProvider)}.{nameof(SetRunningAsync)}", "Scheduler", Guid.Empty,
                                             $"{nameof(SetRunningAsync)}({running})", RequiresRestart : true
                                             );
            }
        }
        protected async Task <bool> AddItemAsync(MenuInfo data)
        {
            bool result = await DataProvider.AddAsync(data);

            await Auditing.AddAuditAsync($"{nameof(MenuInfoDataProvider)}.{nameof(AddItemAsync)}", "Menu", data.ModuleGuid,
                                         "Add Menu",
                                         DataBefore : null,
                                         DataAfter : data,
                                         ExpensiveMultiInstance : true
                                         );

            return(result);
        }
        public async Task <UpdateStatusEnum> UpdateItemAsync(string originalName, UserDefinition data)
        {
            CleanupRoles(data);

            if (!Manager.HasSuperUserRole)
            {
                int superuserRole = Resource.ResourceAccess.GetSuperuserRoleId();
                if (data.RolesList.Contains(new Role {
                    RoleId = superuserRole
                }, new RoleComparer()))
                {
                    // new data has super user role
                    // get original to make sure superuser role isn't new
                    UserDefinition origData = await GetItemByUserIdAsync(data.UserId);

                    if (!origData.RolesList.Contains(new Role {
                        RoleId = superuserRole
                    }, new RoleComparer()))
                    {
                        throw new Error(this.__ResStr("noSup", "Only a superuser can assign superuser status to another user"));
                    }
                }
            }

            if (string.Compare(data.UserName, SuperuserDefinitionDataProvider.SuperUserName, true) == 0 &&
                string.Compare(originalName, SuperuserDefinitionDataProvider.SuperUserName, true) != 0)
            {
                return(UpdateStatusEnum.NewKeyExists);
            }
            if (string.Compare(originalName, SuperuserDefinitionDataProvider.SuperUserName, true) == 0)
            {
                if (data.UserName != originalName)
                {
                    throw new Error(this.__ResStr("cantRenameSuper", "The user \"{0}\" can't be renamed.", originalName));
                }
                using (SuperuserDefinitionDataProvider superDP = new SuperuserDefinitionDataProvider()) {
                    return(await superDP.UpdateItemAsync(data));
                }
            }
            UserDefinition origUser = Auditing.Active ? await GetItemAsync(originalName) : null;

            UpdateStatusEnum result = await DataProvider.UpdateAsync(originalName, data.UserName, data);

            await Auditing.AddAuditAsync($"{nameof(UserDefinitionDataProvider)}.{nameof(UpdateItemAsync)}", originalName, Guid.Empty,
                                         "Update User",
                                         DataBefore : origUser,
                                         DataAfter : data
                                         );

            return(result);
        }
 public async Task AddConfigAsync(RecaptchaV2Config data)
 {
     data.Key = KEY;
     if (!await DataProvider.AddAsync(data))
     {
         throw new InternalError("Unexpected error adding RecaptchaV2 Settings");
     }
     await Auditing.AddAuditAsync($"{nameof(RecaptchaV2ConfigDataProvider)}.{nameof(AddConfigAsync)}", "Config", Guid.Empty,
                                  "Add RecaptchaV2 Config",
                                  DataBefore : null,
                                  DataAfter : data,
                                  ExpensiveMultiInstance : true
                                  );
 }
Beispiel #17
0
        public async Task <bool> AddItemAsync(HolidayEntry data)
        {
            if (!await DataProvider.AddAsync(data))
            {
                return(false);
            }
            await Auditing.AddAuditAsync($"{nameof(HolidayEntryDataProvider)}.{nameof(AddItemAsync)}", Dataset, Guid.Empty,
                                         $"Add Holiday Entry {data.Id}",
                                         DataBefore : null,
                                         DataAfter : data
                                         );

            return(true);
        }
Beispiel #18
0
 private async Task AddConfigAsync(SearchConfigData data)
 {
     data.Id = KEY;
     if (!await DataProvider.AddAsync(data))
     {
         throw new InternalError("Unexpected error adding settings");
     }
     await Auditing.AddAuditAsync($"{nameof(SearchConfigDataProvider)}.{nameof(AddConfigAsync)}", "Config", Guid.Empty,
                                  "Add Search Config",
                                  DataBefore : null,
                                  DataAfter : data,
                                  ExpensiveMultiInstance : true
                                  );
 }
        public async Task <bool> RemoveItemAsync(int key)
        {
            UserInfo origUserInfo = Auditing.Active ? await GetItemAsync(key) : null;

            bool result = await DataProvider.RemoveAsync(key);

            await Auditing.AddAuditAsync($"{nameof(UserInfoDataProvider)}.{nameof(RemoveItemAsync)}", key.ToString(), Guid.Empty,
                                         "Remove UserInfo",
                                         DataBefore : origUserInfo,
                                         DataAfter : null
                                         );

            return(result);
        }
        public async Task <bool> RemoveItemAsync(Guid moduleGuid)
        {
            MenuInfo origMenu = Auditing.Active ? await GetItemAsync(moduleGuid) : null;

            bool result = await DataProvider.RemoveAsync(moduleGuid);

            await Auditing.AddAuditAsync($"{nameof(MenuInfoDataProvider)}.{nameof(RemoveItemAsync)}", "Menu", moduleGuid,
                                         "Remove Menu",
                                         DataBefore : origMenu,
                                         DataAfter : null,
                                         ExpensiveMultiInstance : true
                                         );

            return(result);
        }
        protected async Task <UpdateStatusEnum> UpdateItemAsync(MenuInfo data)
        {
            MenuInfo origMenu = Auditing.Active ? await GetItemAsync(data.ModuleGuid) : null;

            UpdateStatusEnum result = await DataProvider.UpdateAsync(data.ModuleGuid, data.ModuleGuid, data);

            await Auditing.AddAuditAsync($"{nameof(MenuInfoDataProvider)}.{nameof(UpdateItemAsync)}", "Menu", data.ModuleGuid,
                                         "Update Menu",
                                         DataBefore : origMenu,
                                         DataAfter : data,
                                         ExpensiveMultiInstance : true
                                         );

            return(result);
        }
Beispiel #22
0
        public async Task <bool> AddItemAsync(VoiceMailData data)
        {
            data.Created = DateTime.UtcNow;
            if (!await DataProvider.AddAsync(data))
            {
                return(false);
            }
            await Auditing.AddAuditAsync($"{nameof(VoiceMailDataProvider)}.{nameof(AddItemAsync)}", Dataset, Guid.Empty,
                                         $"Add Voice Mail Entry {data.Id}",
                                         DataBefore : null,
                                         DataAfter : data
                                         );

            return(true);
        }
Beispiel #23
0
        public async Task <ActionResult> OwinEdit_Partial(EditModel model)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView(model));
            }
            if (model.ExpireTimeSpan < new TimeSpan(0, 10, 0))
            {
                ModelState.AddModelError(nameof(model.ExpireTimeSpan), this.__ResStr("timeSpan", "The minimum expiration timespan should be at least 10 minutes"));
                return(PartialView(model));
            }
            if (model.SecurityStampValidationInterval < new TimeSpan(0, 1, 0))
            {
                ModelState.AddModelError(nameof(model.SecurityStampValidationInterval), this.__ResStr("securityInterval", "The minimum validation interval should be at least 1 minute"));
                return(PartialView(model));
            }

            OwinConfigHelper.SetValue <bool>(Module.AreaName, "Password:RequireDigit", model.RequireDigit);
            OwinConfigHelper.SetValue <int>(Module.AreaName, "Password:RequiredLength", model.RequiredLength);
            OwinConfigHelper.SetValue <bool>(Module.AreaName, "Password:RequireNonAlphanumeric", model.RequireNonAlphanumeric);
            OwinConfigHelper.SetValue <bool>(Module.AreaName, "Password:RequireUppercase", model.RequireUppercase);
            OwinConfigHelper.SetValue <bool>(Module.AreaName, "Password:RequireLowercase", model.RequireLowercase);

            OwinConfigHelper.SetValue <bool>(Module.AreaName, "OWin:SlidingExpiration", model.SlidingExpiration);
            OwinConfigHelper.SetValue <long>(Module.AreaName, "OWin:ExpireTimeSpan", model.ExpireTimeSpan.Ticks);
            OwinConfigHelper.SetValue <long>(Module.AreaName, "OWin:SecurityStampValidationInterval", model.SecurityStampValidationInterval.Ticks);
            OwinConfigHelper.SetValue <long>(Module.AreaName, "PasswordRenewal", model.PasswordRenewal.Ticks);

            OwinConfigHelper.SetValue <bool>(Module.AreaName, "MicrosoftAccount:Enabled", model.UseMicrosoft);
            OwinConfigHelper.SetValue <string>(Module.AreaName, "MicrosoftAccount:Public", model.MicrosoftPublic);
            OwinConfigHelper.SetValue <string>(Module.AreaName, "MicrosoftAccount:Private", model.MicrosoftPrivate);
            OwinConfigHelper.SetValue <bool>(Module.AreaName, "GoogleAccount:Enabled", model.UseGoogle);
            OwinConfigHelper.SetValue <string>(Module.AreaName, "GoogleAccount:Public", model.GooglePublic);
            OwinConfigHelper.SetValue <string>(Module.AreaName, "GoogleAccount:Private", model.GooglePrivate);
            OwinConfigHelper.SetValue <bool>(Module.AreaName, "FacebookAccount:Enabled", model.UseFacebook);
            OwinConfigHelper.SetValue <string>(Module.AreaName, "FacebookAccount:Public", model.FacebookPublic);
            OwinConfigHelper.SetValue <string>(Module.AreaName, "FacebookAccount:Private", model.FacebookPrivate);
            OwinConfigHelper.SetValue <bool>(Module.AreaName, "TwitterAccount:Enabled", model.UseTwitter);
            OwinConfigHelper.SetValue <string>(Module.AreaName, "TwitterAccount:Public", model.TwitterPublic);
            OwinConfigHelper.SetValue <string>(Module.AreaName, "TwitterAccount:Private", model.TwitterPrivate);
            await OwinConfigHelper.SaveAsync();

            await Auditing.AddAuditAsync($"{nameof(OwinEditModuleController)}.{nameof(OwinEdit_Partial)}", "Login", Guid.Empty,
                                         $"{nameof(OwinEdit_Partial)}", RequiresRestart : true
                                         );

            return(FormProcessed(model, this.__ResStr("okSaved", "Login provider settings successfully saved - These settings won't take effect until the site (including all instances) is restarted."), NextPage: Manager.CurrentSite.HomePageUrl));
        }
        private async Task AddConfigAsync(BlogConfigData data)
        {
            data.Id = KEY;
            await SaveImagesAsync(ModuleDefinition.GetPermanentGuid(typeof(BlogConfigModule)), data);

            if (!await DataProvider.AddAsync(data))
            {
                throw new InternalError("Unexpected error adding settings");
            }
            await Auditing.AddAuditAsync($"{nameof(BlogConfigDataProvider)}.{nameof(AddConfigAsync)}", "Config", Guid.Empty,
                                         "Add Blog Config",
                                         DataBefore : null,
                                         DataAfter : data,
                                         ExpensiveMultiInstance : true
                                         );
        }
Beispiel #25
0
        public async Task UpdateItemAsync(VoiceMailData data)
        {
            VoiceMailData origEmail = Auditing.Active ? await GetItemAsync(data.CallSid) : null;

            UpdateStatusEnum status = await DataProvider.UpdateByIdentityAsync(data.Id, data);

            if (status != UpdateStatusEnum.OK)
            {
                throw new InternalError("Unexpected error {0} updating item", status);
            }
            await Auditing.AddAuditAsync($"{nameof(VoiceMailDataProvider)}.{nameof(UpdateItemAsync)}", Dataset, Guid.Empty,
                                         $"Update Voice Mail Entry {data.Id}",
                                         DataBefore : origEmail,
                                         DataAfter : data
                                         );
        }
        public async Task <bool> RemoveItemAsync(string resourceName)
        {
            Authorization origData = Auditing.Active ? await GetItemAsync(resourceName) : null;

            if (!await DataProvider.RemoveAsync(resourceName))
            {
                return(false);
            }
            await Auditing.AddAuditAsync($"{nameof(AuthorizationDataProvider)}.{nameof(RemoveItemAsync)}", resourceName, Guid.Empty,
                                         "Remove Authorization",
                                         DataBefore : origData,
                                         DataAfter : null,
                                         ExpensiveMultiInstance : true
                                         );

            return(true);
        }
Beispiel #27
0
        public async Task <bool> RemoveItemByIdentityAsync(int id)
        {
            BlockedNumberEntry origData = Auditing.Active ? await GetItemByIdentityAsync(id) : null;

            if (!await DataProvider.RemoveByIdentityAsync(id))
            {
                return(false);
            }

            await Auditing.AddAuditAsync($"{nameof(BlockedNumberDataProvider)}.{nameof(RemoveItemByIdentityAsync)}", Dataset, Guid.Empty,
                                         $"Remove Blocked Number {id}",
                                         DataBefore : origData,
                                         DataAfter : null
                                         );

            return(true);
        }
Beispiel #28
0
        public async Task <bool> AddItemAsync(BlockedNumberEntry data)
        {
            data.Created = DateTime.UtcNow;
            data.Number  = PhoneNumberAttribute.GetE164(data.Number);

            if (!await DataProvider.AddAsync(data))
            {
                return(false);
            }
            await Auditing.AddAuditAsync($"{nameof(BlockedNumberDataProvider)}.{nameof(AddItemAsync)}", Dataset, Guid.Empty,
                                         $"Add Blocked Number {data.Id}",
                                         DataBefore : null,
                                         DataAfter : data
                                         );

            return(true);
        }
        public async Task <bool> AddItemAsync(UserInfo userInfo)
        {
            userInfo.Created = DateTime.UtcNow;
            if (string.IsNullOrWhiteSpace(userInfo.Country))
            {
                userInfo.Country = Globals.DefaultCountry;
            }
            bool result = await DataProvider.AddAsync(userInfo);

            await Auditing.AddAuditAsync($"{nameof(UserInfoDataProvider)}.{nameof(AddItemAsync)}", userInfo.UserId.ToString(), Guid.Empty,
                                         "Add UserInfo",
                                         DataBefore : null,
                                         DataAfter : userInfo
                                         );

            return(result);
        }
Beispiel #30
0
        public async Task UpdateConfigAsync(SearchConfigData data)
        {
            SearchConfigData origConfig = Auditing.Active ? await GetItemAsync() : null;

            data.Id = KEY;
            UpdateStatusEnum status = await DataProvider.UpdateAsync(data.Id, data.Id, data);

            if (status != UpdateStatusEnum.OK)
            {
                throw new InternalError("Unexpected error saving settings {0}", status);
            }
            await Auditing.AddAuditAsync($"{nameof(SearchConfigDataProvider)}.{nameof(UpdateConfigAsync)}", "Config", Guid.Empty,
                                         "Update Search Config",
                                         DataBefore : origConfig,
                                         DataAfter : data,
                                         ExpensiveMultiInstance : true
                                         );
        }