Пример #1
0
        /// <inheritdoc/>
        public async Task <TemplatesDocument> GetTemplatesDocumentAsync()
        {
            TemplatesDocument document;

            if (!_memoryCache.TryGetValue(CacheKey, out document))
            {
                document = await _session.Query <TemplatesDocument>().FirstOrDefaultAsync();

                if (document == null)
                {
                    lock (_memoryCache)
                    {
                        if (!_memoryCache.TryGetValue(CacheKey, out document))
                        {
                            document = new TemplatesDocument();

                            _session.Save(document);
                            _memoryCache.Set(CacheKey, document);
                            _signal.SignalToken(CacheKey);
                        }
                    }
                }
                else
                {
                    _memoryCache.Set(CacheKey, document);
                    _signal.SignalToken(CacheKey);
                }
            }

            return(document);
        }
Пример #2
0
        public async Task SaveAsync(Models.AdminMenu tree)
        {
            var adminMenuList = await GetAdminMenuList();

            var session = GetSession();


            var preexisting = adminMenuList.AdminMenu.Where(x => x.Id == tree.Id).FirstOrDefault();

            // it's new? add it
            if (preexisting == null)
            {
                adminMenuList.AdminMenu.Add(tree);
            }
            else // not new: replace it
            {
                var index = adminMenuList.AdminMenu.IndexOf(preexisting);
                adminMenuList.AdminMenu[index] = tree;
            }

            session.Save(adminMenuList);

            _memoryCache.Set(AdminMenuCacheKey, adminMenuList);
            _signal.SignalToken(AdminMenuCacheKey);
        }
        public async Task RemoveAsync(string name)
        {
            var document = await GetDocumentAsync();

            document.Settings.Remove(name);
            _session.Save(document);

            _signal.SignalToken(CacheKey);
            _memoryCache.Set(CacheKey, document, ChangeToken);
        }
        // It will invalidate the memory cache and all the dynamic caches which have been tagged.
        public async Task InvalidateCachedDateTimeAsync()
        {
            // As mentioned ISignal service is used to invalidate the memory cache.
            _signal.SignalToken(MemoryCacheKey);

            // ITagCache.RemoveTagAsync will invalidate all the dynamic caches which are tagged with the given tag.
            await _tagCache.RemoveTagAsync(DynamicCacheTag);
        }
Пример #5
0
        private void SignalLayerChanged(ContentItem contentItem)
        {
            var layerMetadata = contentItem.As <LayerMetadata>();

            if (layerMetadata != null)
            {
                _signal.SignalToken(LayerChangeToken);
            }
        }
Пример #6
0
 public void UpdateRoles()
 {
     if (_roles != null)
     {
         _roles.Serial++;
         _session.Save(_roles);
         _signal.SignalToken(Key);
     }
 }
Пример #7
0
        /// <inheritdoc/>
        public async Task <ISite> GetSiteSettingsAsync()
        {
            ISite site;

            if (!_memoryCache.TryGetValue(SiteCacheKey, out site))
            {
                //var session = GetSession();

                site = GetSession().GetCurrentSiteSettings();

                if (site == null)
                {
                    lock (_memoryCache)
                    {
                        if (!_memoryCache.TryGetValue(SiteCacheKey, out site))
                        {
                            site = new SiteSettings
                            {
                                SiteSalt      = Guid.NewGuid().ToString("N"),
                                SiteName      = "My OCore Project Application",
                                TimeZone      = TimeZoneInfo.Local.Id,
                                PageSize      = 10,
                                MaxPageSize   = 100,
                                MaxPagedCount = 0
                            };

                            //session.Save(site);
                            GetSession().CreateCurrentSiteSettings(site as SiteSettings);
                            _memoryCache.Set(SiteCacheKey, site);
                            _signal.SignalToken(SiteCacheKey);
                        }
                    }
                }
                else
                {
                    _memoryCache.Set(SiteCacheKey, site);
                    _signal.SignalToken(SiteCacheKey);
                }
            }
            await Task.Run(() => { });

            return(site);
        }
Пример #8
0
        private void UpdateContentDefinitionRecord()
        {
            _contentDefinitionRecord.Serial++;
            _session.Save(_contentDefinitionRecord);
            _signal.SignalToken(TypeHashCacheKey);

            // Release cached values
            _typeDefinitions.Clear();
            _partDefinitions.Clear();
        }
        public async Task UpdateIndexAsync(LuceneIndexSettings settings)
        {
            if (settings.IsReadonly)
            {
                throw new ArgumentException("The object is read-only");
            }

            using (var session = _store.CreateSession())
            {
                var document = await LoadDocumentAsync(session);

                document.LuceneIndexSettings[settings.IndexName] = settings;

                session.Save(document);
                await session.CommitAsync();
            }

            _signal.SignalToken(CacheKey);
        }
Пример #10
0
        /// <inheritdoc/>
        public async Task <ISite> GetSiteSettingsAsync()
        {
            ISite site;

            if (!_memoryCache.TryGetValue(SiteCacheKey, out site))
            {
                var session = GetSession();

                site = await session.Query <SiteSettings>().FirstOrDefaultAsync();

                if (site == null)
                {
                    lock (_memoryCache)
                    {
                        if (!_memoryCache.TryGetValue(SiteCacheKey, out site))
                        {
                            site = new SiteSettings
                            {
                                SiteSalt      = Guid.NewGuid().ToString("N"),
                                SiteName      = "My Orchard Project Application",
                                PageSize      = 10,
                                MaxPageSize   = 100,
                                MaxPagedCount = 0,
                                TimeZoneId    = _clock.GetSystemTimeZone().TimeZoneId,
                                Culture       = ""
                            };

                            session.Save(site);
                            _memoryCache.Set(SiteCacheKey, site);
                            _signal.SignalToken(SiteCacheKey);
                        }
                    }
                }
                else
                {
                    _memoryCache.Set(SiteCacheKey, site);
                    _signal.SignalToken(SiteCacheKey);
                }
            }

            return(site);
        }
Пример #11
0
        /// <inheritdoc/>
        public async Task <ISite> GetSiteSettingsAsync()
        {
            ISite site;

            if (!_memoryCache.TryGetValue(SiteCacheKey, out site))
            {
                var context = GetDbContext();
                var set     = context.Set <SiteSettings>();
                site = await Task.FromResult(set.FirstOrDefault()); // session.Query<SiteSettings>().FirstOrDefaultAsync();

                if (site == null)
                {
                    lock (_memoryCache)
                    {
                        if (!_memoryCache.TryGetValue(SiteCacheKey, out site))
                        {
                            site = new SiteSettings
                            {
                                SiteSalt        = Guid.NewGuid().ToString("N"),
                                SiteName        = "My Application",
                                PageTitleFormat = "{% page_title Site.SiteName, position: \"after\", separator: \" - \" %}",
                                PageSize        = 10,
                                MaxPageSize     = 100,
                                MaxPagedCount   = 0,
                                TimeZoneId      = _clock.GetSystemTimeZone().TimeZoneId,
                            };
                            set.Add(site as SiteSettings);

                            _memoryCache.Set(SiteCacheKey, site);
                            _signal.SignalToken(SiteCacheKey);
                        }
                    }
                }
                else
                {
                    _memoryCache.Set(SiteCacheKey, site);
                    _signal.SignalToken(SiteCacheKey);
                }
            }

            return(site);
        }
Пример #12
0
        private void UpdateContentDefinitionRecord()
        {
            _contentDefinitionRecord.Serial++;
            _contentDefinitionStore.SaveContentDefinitionAsync(_contentDefinitionRecord).GetAwaiter().GetResult();

            _signal.SignalToken(TypeHashCacheKey);


            // Release cached values
            _typeDefinitions.Clear();
            _partDefinitions.Clear();
        }
Пример #13
0
        /// <inheritdoc/>
        public async Task <ISite> GetSiteSettingsAsync()
        {
            ISite site;

            if (!_memoryCache.TryGetValue(SiteCacheKey, out site))
            {
                site = await _session.QueryAsync <SiteSettings>().FirstOrDefault();

                if (site == null)
                {
                    lock (_memoryCache)
                    {
                        if (!_memoryCache.TryGetValue(SiteCacheKey, out site))
                        {
                            site = new SiteSettings
                            {
                                SiteSalt      = Guid.NewGuid().ToString("N"),
                                SiteName      = "My Orchard Project Application",
                                TimeZone      = TimeZoneInfo.Local.Id,
                                PageSize      = 10,
                                MaxPageSize   = 100,
                                MaxPagedCount = 0
                            };

                            _session.Save(site);
                            _memoryCache.Set(SiteCacheKey, site);
                            _signal.SignalToken(SiteCacheKey);
                        }
                    }
                }
                else
                {
                    _memoryCache.Set(SiteCacheKey, site);
                    _signal.SignalToken(SiteCacheKey);
                }
            }

            return(site);
        }
Пример #14
0
        public override async Task <IDisplayResult> UpdateAsync(TransformalizeFormPart part, IUpdateModel updater, UpdatePartEditorContext context)
        {
            var model = new EditTransformalizeFormPartViewModel();

            if (await updater.TryUpdateModelAsync(model, Prefix))
            {
                part.Arrangement.Text = model.Arrangement.Text;
                part.LocationEnableHighAccuracy.Value = model.LocationEnableHighAccuracy.Value;
                part.LocationMaximumAge.Value         = model.LocationMaximumAge.Value;
                part.LocationTimeout.Value            = model.LocationTimeout.Value;
            }

            try {
                var logger  = new MemoryLogger(LogLevel.Error);
                var process = _configurationContainer.CreateScope(model.Arrangement.Text, part.ContentItem, new Dictionary <string, string>(), false).Resolve <Process>();
                if (process.Errors().Any())
                {
                    foreach (var error in process.Errors())
                    {
                        updater.ModelState.AddModelError(Prefix, S[error]);
                    }
                }

                if (process.Warnings().Any())
                {
                    foreach (var warning in process.Warnings())
                    {
                        _notifier.Warning(H[warning]);
                    }
                }

                if (!process.Connections.Any(c => c.Table != "[default]" && !string.IsNullOrEmpty(c.Table)))
                {
                    updater.ModelState.AddModelError(Prefix, S["A form requires one connection to have a table defined.  The submissions are stored in this table."]);
                }

                if (process.Parameters.Where(p => p.PrimaryKey).Count() != 1)
                {
                    updater.ModelState.AddModelError(Prefix, S["A form requires one parameter to be marked as the primary key."]);
                }
            } catch (Exception ex) {
                updater.ModelState.AddModelError(Prefix, S[ex.Message]);
            }

            if (updater.ModelState.IsValid)
            {
                _signal.SignalToken(Common.GetCacheKey(part.ContentItem.Id));
            }

            return(Edit(part, context));
        }
Пример #15
0
        public async Task <ISiteInfo> GetSiteInfoAsync()
        {
            if (!_memoryCache.TryGetValue(SiteCacheKey, out ISiteInfo site))
            {
                var dbContext       = GetDbContext();
                var siteSettingsSet = dbContext.Set <SiteSettings>();
                site = await Task.FromResult(siteSettingsSet.FirstOrDefault());

                if (site == null)
                {
                    lock (_memoryCache)
                    {
                        if (!_memoryCache.TryGetValue(SiteCacheKey, out site))
                        {
                            var siteSettings = new SiteSettings
                            {
                                SiteName = "Seed Application"
                            };
                            siteSettingsSet.Add(siteSettings);

                            dbContext.SaveChanges();

                            site = siteSettings;

                            _memoryCache.Set(SiteCacheKey, site);
                            _signal.SignalToken(SiteCacheKey);
                        }
                    }
                }
                else
                {
                    _memoryCache.Set(SiteCacheKey, site);
                    _signal.SignalToken(SiteCacheKey);
                }
            }

            return(site);
        }
Пример #16
0
        public async Task DeleteQueryAsync(string name)
        {
            // Ensure QueriesDocument exists
            await GetDocumentAsync();

            // Load the currently saved object otherwise it would create a new document
            // as the new session is not tracking the cached object.
            // TODO: Solve by having an Import method in Session

            var existing = await _session.QueryAsync <QueriesDocument>().FirstOrDefault();

            if (existing.Queries.ContainsKey(name))
            {
                existing.Queries.Remove(name);
            }

            _session.Save(existing);

            _memoryCache.Set(QueriesDocumentCacheKey, existing);
            _signal.SignalToken(QueriesDocumentCacheKey);

            return;
        }
Пример #17
0
        public async Task <IProfile> GetProfileAsync()
        {
            IProfile profile;

            if (!_memoryCache.TryGetValue(ProfileCacheKey, out profile))
            {
                var session = GetSession();

                profile = await session.Query <Profile>().FirstOrDefaultAsync();

                if (profile == null)
                {
                    lock (_memoryCache)
                    {
                        if (!_memoryCache.TryGetValue(ProfileCacheKey, out profile))
                        {
                            profile = new Profile
                            {
                                UserName = "******"
                            };

                            session.Save(profile);
                            _memoryCache.Set(ProfileCacheKey, profile);
                            _signal.SignalToken(ProfileCacheKey);
                        }
                    }
                }
                else
                {
                    _memoryCache.Set(ProfileCacheKey, profile);
                    _signal.SignalToken(ProfileCacheKey);
                }
            }

            return(profile);
        }
Пример #18
0
        public async Task SaveRoleModule(SysRoleModuleViewModel model)
        {
            _rolemoduleRepository.Delete(a => a.RoleId == model.RoleId);
            List <SysRoleModules> list = new List <SysRoleModules>();

            foreach (SysModuleBase moduleBase in model.ModuleBases)
            {
                list.Add(new SysRoleModules()
                {
                    ModuleId = SequenceQueue.NewIdString(""), PurviewSum = moduleBase.PurviewSum, ApplicationId = "", RoleId = model.RoleId, ControllerName = moduleBase.ControllerName
                });
            }
            await _rolemoduleRepository.AddRangeAsync(list);

            _context.SaveChanges();
            _signal.SignalToken(model.RoleId);//设置过期
        }
Пример #19
0
        public async Task <IActionResult> UpdatePosition(string contentItemId, double position, string zone)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageLayers))
            {
                return(StatusCode(401));
            }

            // Load the latest version first if any
            var contentItem = await _contentManager.GetAsync(contentItemId, VersionOptions.Latest);

            if (contentItem == null)
            {
                return(StatusCode(404));
            }

            var layerMetadata = contentItem.As <LayerMetadata>();

            if (layerMetadata == null)
            {
                return(StatusCode(403));
            }

            layerMetadata.Position = position;
            layerMetadata.Zone     = zone;

            contentItem.Apply(layerMetadata);

            _session.Save(contentItem);

            // Clear the cache
            _signal.SignalToken(LayerMetadataHandler.LayerChangeToken);

            if (Request.Headers != null && Request.Headers["X-Requested-With"] == "XMLHttpRequest")
            {
                return(StatusCode(200));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Пример #20
0
        public override async Task <IDisplayResult> UpdateAsync(TransformalizeTaskPart part, IUpdateModel updater, UpdatePartEditorContext context)
        {
            var model = new EditTransformalizeTaskPartViewModel();

            if (await updater.TryUpdateModelAsync(model, Prefix))
            {
                part.Arrangement.Text = model.Arrangement.Text;
            }

            try {
                var logger  = new MemoryLogger(LogLevel.Error);
                var process = _container.CreateScope(model.Arrangement.Text, part.ContentItem, new Dictionary <string, string>(), false).Resolve <Process>();
                if (process.Errors().Any())
                {
                    foreach (var error in process.Errors())
                    {
                        updater.ModelState.AddModelError(Prefix, S[error]);
                    }
                }
                if (process.Warnings().Any())
                {
                    foreach (var warning in process.Warnings())
                    {
                        _notifier.Warning(H[warning]);
                    }
                }
            } catch (Exception ex) {
                updater.ModelState.AddModelError(Prefix, S[ex.Message]);
            }

            if (updater.ModelState.IsValid)
            {
                _signal.SignalToken(Common.GetCacheKey(part.ContentItem.Id));
            }

            return(Edit(part, context));
        }
Пример #21
0
 public string InvalidateCacheWithSignal()
 {
     _signal.SignalToken(SignalKey);
     return("OK");
 }
Пример #22
0
        public async Task <IActionResult> UpdatePosition(string contentItemId, double position, string zone)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageLayers))
            {
                return(StatusCode(401));
            }

            // Load the latest version first if any
            var contentItem = await _contentManager.GetAsync(contentItemId, VersionOptions.Latest);

            if (contentItem == null)
            {
                return(StatusCode(404));
            }

            var layerMetadata = contentItem.As <LayerMetadata>();

            if (layerMetadata == null)
            {
                return(StatusCode(403));
            }

            layerMetadata.Position = position;
            layerMetadata.Zone     = zone;

            contentItem.Apply(layerMetadata);

            _session.Save(contentItem);

            // In case the moved contentItem is the draft for a published contentItem we update it's position too.
            // We do that because we want the position of published and draft version to be the same.
            if (contentItem.IsPublished() == false)
            {
                var publishedContentItem = await _contentManager.GetAsync(contentItemId, VersionOptions.Published);

                if (publishedContentItem != null)
                {
                    layerMetadata = contentItem.As <LayerMetadata>();

                    if (layerMetadata == null)
                    {
                        return(StatusCode(403));
                    }

                    layerMetadata.Position = position;
                    layerMetadata.Zone     = zone;

                    publishedContentItem.Apply(layerMetadata);

                    _session.Save(publishedContentItem);
                }
            }

            // Clear the cache
            _signal.SignalToken(LayerMetadataHandler.LayerChangeToken);

            if (Request.Headers != null && Request.Headers["X-Requested-With"] == "XMLHttpRequest")
            {
                return(StatusCode(200));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
        public override async Task <IDisplayResult> UpdateAsync(TransformalizeReportPart part, IUpdateModel updater, UpdatePartEditorContext context)
        {
            // this driver override makes sure all the
            // part fields are updated before the arrangement model is updated / validated

            //_notifier.Information(H["Part - Bulk Actions:{0}", part.BulkActions.Value]);
            //_notifier.Information(H["Part - Bulk Action Field:{0}", part.BulkActionValueField.Text]);

            var model = new EditTransformalizeReportPartViewModel();

            if (await updater.TryUpdateModelAsync(model, Prefix))
            {
                //_notifier.Information(H["Model - Bulk Actions:{0}", model.BulkActions.Value]);
                //_notifier.Information(H["Model - Bulk Action Field:{0}", model.BulkActionValueField.Text]);

                part.Arrangement.Text       = model.Arrangement.Text;
                part.PageSizes.Text         = model.PageSizes.Text;
                part.PageSizesExtended.Text = model.PageSizes.Text;

                part.BulkActions.Value          = model.BulkActions.Value;
                part.BulkActionValueField.Text  = model.BulkActionValueField.Text;
                part.BulkActionCreateTask.Text  = model.BulkActionCreateTask.Text;
                part.BulkActionWriteTask.Text   = model.BulkActionWriteTask.Text;
                part.BulkActionSummaryTask.Text = model.BulkActionSummaryTask.Text;
                part.BulkActionRunTask.Text     = model.BulkActionRunTask.Text;
                part.BulkActionSuccessTask.Text = model.BulkActionSuccessTask.Text;
                part.BulkActionFailTask.Text    = model.BulkActionFailTask.Text;

                part.Map.Value                = model.Map.Value;
                part.MapColorField.Text       = model.MapColorField.Text;
                part.MapDescriptionField.Text = model.MapDescriptionField.Text;
                part.MapLatitudeField.Text    = model.MapLatitudeField.Text;
                part.MapLongitudeField.Text   = model.MapLongitudeField.Text;
                part.MapRadiusField.Text      = model.MapRadiusField.Text;
                part.MapOpacityField.Text     = model.MapOpacityField.Text;

                part.Calendar.Value          = model.Calendar.Value;
                part.CalendarClassField.Text = model.CalendarClassField.Text;
                part.CalendarIdField.Text    = model.CalendarIdField.Text;
                part.CalendarTitleField.Text = model.CalendarTitleField.Text;
                part.CalendarUrlField.Text   = model.CalendarUrlField.Text;
                part.CalendarStartField.Text = model.CalendarStartField.Text;
                part.CalendarEndField.Text   = model.CalendarEndField.Text;
            }

            if (model.BulkActions.Value)
            {
                if (string.IsNullOrEmpty(model.BulkActionValueField.Text))
                {
                    updater.ModelState.AddModelError(Prefix, S["Please set the bulk action value field for bulk actions."]);
                }
            }

            CheckPageSizes(model.PageSizes, updater);
            CheckPageSizes(model.PageSizesExtended, updater);

            try {
                var logger  = new MemoryLogger(LogLevel.Error);
                var process = _container.CreateScope(model.Arrangement.Text, part.ContentItem, new Dictionary <string, string>(), false).Resolve <Process>();
                if (process.Errors().Any())
                {
                    foreach (var error in process.Errors())
                    {
                        updater.ModelState.AddModelError(Prefix, S[error]);
                    }
                }
                if (process.Warnings().Any())
                {
                    foreach (var warning in process.Warnings())
                    {
                        _notifier.Warning(H[warning]);
                    }
                }
                if (process.Entities.Any())
                {
                    var fields = process.Entities[0].GetAllFields().ToArray();

                    if (part.BulkActions.Value)
                    {
                        if (!string.IsNullOrEmpty(part.BulkActionValueField.Text))
                        {
                            if (fields.All(f => f.Alias != part.BulkActionValueField.Text))
                            {
                                updater.ModelState.AddModelError(Prefix, S["The field {0} does not exist.", part.BulkActionValueField.Text]);
                            }
                        }
                    }

                    if (part.Calendar.Value)
                    {
                        if (fields.All(f => f.Alias != part.CalendarIdField.Text))
                        {
                            updater.ModelState.AddModelError(Prefix, S["The field {0} used for calendar id does not exist.", part.CalendarIdField.Text]);
                        }
                        if (fields.All(f => f.Alias != part.CalendarUrlField.Text))
                        {
                            updater.ModelState.AddModelError(Prefix, S["The field {0} used for calendar URL does not exist.", part.CalendarUrlField.Text]);
                        }
                        if (fields.All(f => f.Alias != part.CalendarTitleField.Text))
                        {
                            updater.ModelState.AddModelError(Prefix, S["The field {0} used for calendar title does not exist.", part.CalendarTitleField.Text]);
                        }
                        if (fields.All(f => f.Alias != part.CalendarClassField.Text))
                        {
                            updater.ModelState.AddModelError(Prefix, S["The field {0} used for calendar class does not exist.", part.CalendarClassField.Text]);
                        }
                        if (fields.All(f => f.Alias != part.CalendarStartField.Text))
                        {
                            updater.ModelState.AddModelError(Prefix, S["The field {0} used for calendar start does not exist.", part.CalendarStartField.Text]);
                        }
                        if (fields.All(f => f.Alias != part.CalendarEndField.Text))
                        {
                            updater.ModelState.AddModelError(Prefix, S["The field {0} used for calendar end does not exist.", part.CalendarEndField.Text]);
                        }
                    }

                    if (part.Map.Value)
                    {
                        if (fields.All(f => f.Alias != part.MapDescriptionField.Text))
                        {
                            updater.ModelState.AddModelError(Prefix, S["The field {0} used for map description does not exist.", part.MapDescriptionField.Text]);
                        }
                        if (fields.All(f => f.Alias != part.MapLatitudeField.Text))
                        {
                            updater.ModelState.AddModelError(Prefix, S["The field {0} used for map latitude does not exist.", part.MapLatitudeField.Text]);
                        }
                        if (fields.All(f => f.Alias != part.MapLongitudeField.Text))
                        {
                            updater.ModelState.AddModelError(Prefix, S["The field {0} used for map longitude does not exist.", part.MapLongitudeField.Text]);
                        }

                        // Map Color #ffc0cb
                        if (string.IsNullOrWhiteSpace(part.MapColorField.Text))
                        {
                            part.MapColorField.Text = "#ffc0cb";
                        }
                        else
                        {
                            if (fields.All(f => f.Alias != part.MapColorField.Text))
                            {
                                updater.ModelState.AddModelError(Prefix, S["The field {0} used for map color does not exist.", part.MapColorField.Text]);
                            }
                        }

                        // Map Opacity
                        if (string.IsNullOrWhiteSpace(part.MapOpacityField.Text))
                        {
                            part.MapOpacityField.Text = "0.8";
                        }
                        else
                        {
                            if (double.TryParse(part.MapOpacityField.Text, out double opacity))
                            {
                                if (opacity < 0 || opacity > 1)
                                {
                                    updater.ModelState.AddModelError(Prefix, S["Map opacity must be between 0 and 1."]);
                                }
                            }
                            else
                            {
                                if (fields.All(f => f.Alias != part.MapOpacityField.Text))
                                {
                                    updater.ModelState.AddModelError(Prefix, S["The field {0} used for map opacity does not exist.", part.MapOpacityField.Text]);
                                }
                            }
                        }

                        // Map Radius
                        if (string.IsNullOrWhiteSpace(part.MapRadiusField.Text))
                        {
                            part.MapRadiusField.Text = "7";
                        }
                        else
                        {
                            if (!int.TryParse(part.MapRadiusField.Text, out int radius))
                            {
                                if (fields.All(f => f.Alias != part.MapRadiusField.Text))
                                {
                                    updater.ModelState.AddModelError(Prefix, S["The field {0} used for map radius does not exist.", part.MapRadiusField.Text]);
                                }
                            }
                        }
                    }
                }
                else
                {
                    updater.ModelState.AddModelError(Prefix, S["Please define an entity."]);
                }
            } catch (Exception ex) {
                updater.ModelState.AddModelError(Prefix, S[ex.Message]);
            }

            if (updater.ModelState.IsValid)
            {
                _signal.SignalToken(Common.GetCacheKey(part.ContentItem.Id));
            }

            return(Edit(part, context));
        }
 private void UpdateContentDefinitionRecord()
 {
     _contentDefinitionRecord.Serial++;
     _session.Save(_contentDefinitionRecord);
     _signal.SignalToken(TypeHashCacheKey);
 }
Пример #25
0
 public virtual void FlushCache()
 {
     _signal.SignalToken(DeploymentCacheKeys.LatestDeployment);
 }