Exemplo n.º 1
0
 public virtual ActionResult Create(SearchSetting model)
 {
     var entry = new JsonResultEntry();
     try
     {
         model.Repository = Repository;
         Provider.Add(model);
         entry.SetSuccess();
     }
     catch (Exception e)
     {
         entry.AddException(e);
     }
     return Json(entry);
 }
Exemplo n.º 2
0
        private void GetFolderIndexInfoes(TextFolder textFolder, ref List<FolderIndexInfo> list, SearchSetting[] searchSettings)
        {
            if (searchSettings.Where(it => it.FolderName.EqualsOrNullEmpty(textFolder.FullName, StringComparison.OrdinalIgnoreCase)).Count() > 0)
            {
                FolderIndexInfo folderIndexInfo = new FolderIndexInfo();

                folderIndexInfo.Folder = textFolder;
                folderIndexInfo.IndexedContents = SearchHelper.Search(textFolder.Repository, "", 1, 1, textFolder.FullName).TotalItemCount;
                folderIndexInfo.Rebuilding = IsRebuilding(textFolder);
                list.Add(folderIndexInfo);
            }

            foreach (var folder in Kooboo.CMS.Content.Services.ServiceFactory.TextFolderManager.ChildFolders(textFolder))
            {
                GetFolderIndexInfoes(folder, ref list, searchSettings);
            }
        }
Exemplo n.º 3
0
        public virtual ActionResult Delete(SearchSetting[] model)
        {
            var data = new JsonResultData(ModelState);

            data.RunWithTry((resultData) =>
            {
                if (model != null)
                {
                    foreach (var m in model)
                    {
                        m.Repository = Repository;
                        Provider.Remove(m);
                    }
                }
            });

            return Json(data);
        }
Exemplo n.º 4
0
 public virtual ActionResult Create(SearchSetting model, string @return)
 {
     var data = new JsonResultData(ModelState);
     if (ModelState.IsValid)
     {
         data.RunWithTry((resultData) =>
         {
             model.Repository = Repository;
             if (Provider.Get(model) != null)
             {
                 resultData.AddErrorMessage("The item already exists.".Localize());
             }
             else
             {
                 Provider.Add(model);
                 resultData.RedirectUrl = @return;
             }
         });
     }
     return Json(data);
 }
Exemplo n.º 5
0
        public virtual ActionResult Delete(SearchSetting[] model)
        {
            var entry = new JsonResultEntry();

            try
            {
                if (model != null)
                {
                    foreach (var m in model)
                    {
                        m.Repository = Repository;
                        Provider.Remove(m);
                    }
                    entry.SetSuccess();
                }
            }
            catch (Exception e)
            {
                entry.AddException(e);
            }

            return Json(entry);
        }
Exemplo n.º 6
0
 public FolderSearchSettingPath(SearchSetting folderSearchSetting)
 {
     this.PhysicalPath = this.SettingFile = Path.Combine(GetBasePhysicalPath(folderSearchSetting.Repository), folderSearchSetting.FolderName + PathHelper.SettingFileExtension);
 }
Exemplo n.º 7
0
 public FolderSearchSettingPath(SearchSetting folderSearchSetting)
 {
     this.PhysicalPath = this.SettingFile = Path.Combine(GetBasePhysicalPath(folderSearchSetting.Repository), folderSearchSetting.FolderName + PathHelper.SettingFileExtension);
 }
Exemplo n.º 8
0
 private static bool IsIncluded(SearchSetting folderSearchSetting, string key)
 {
     return folderSearchSetting.IncludeAllFields || folderSearchSetting.Fields.Contains(key, StringComparer.OrdinalIgnoreCase);
 }
Exemplo n.º 9
0
 SearchSetting GetEntity(SearchSetting model)
 {
     var r = Provider.Get(new SearchSetting(Repository, model.Name));
     r.Name = model.Name;
     return r;
 }
Exemplo n.º 10
0
        public virtual ActionResult Edit(SearchSetting model, string @return)
        {
            var data = new JsonResultData(ModelState);

            if (ModelState.IsValid)
            {
                data.RunWithTry((resultData) =>
                {
                    model.Repository = Repository;
                    Provider.Update(model, model);
                    resultData.RedirectUrl = @return;
                });
            }
            return Json(data);
        }
Exemplo n.º 11
0
 protected virtual string GenerateContentUrl(TextContent content, SearchSetting searchSetting)
 {
     if (Page_Context.Current.Initialized)
     {
         var routeValues = new RouteValueDictionary();
         if (searchSetting.RouteValueFields != null && searchSetting.RouteValueFields.Count > 0)
         {
             foreach (var routeValue in searchSetting.RouteValueFields)
             {
                 routeValues[routeValue.Key] = EvaluateStringFormulas(content, routeValue.Value);
             }
         }
         return Page_Context.Current.FrontUrl.PageUrl(searchSetting.LinkPage, routeValues).ToString();
     }
     return "";
 }
Exemplo n.º 12
0
        public virtual ActionResult Edit(SearchSetting model)
        {
            var entry = new JsonResultEntry();

            try
            {
                if (ModelState.IsValid)
                {
                    model.Repository = Repository;
                    Provider.Update(model, model);
                    entry.SetSuccess();
                }
                else
                {
                    entry.AddModelState(ModelState).SetFailed();
                }

            }
            catch (Exception e)
            {
                entry.AddException(e);
            }
            return Json(entry);
        }