コード例 #1
0
ファイル: LabelController.cs プロジェクト: nishizhen/CMS
        public virtual ActionResult Delete(string[] docs, string[] folders)
        {
            var data = new JsonResultData(ModelState);
            data.RunWithTry((resultData) =>
            {
                var category = ControllerContext.RequestContext.GetRequestValue("Category");

                if (docs != null)
                {
                    foreach (var uuid in docs)
                    {
                        var label = new Label() { Site = Site, UUID = uuid };
                        Remove(label);
                    }
                }

                if (folders != null)
                {
                    foreach (var c in folders)
                    {
                        Manager.RemoveCategory(Site, c);
                    }
                }

                resultData.ReloadPage = true;
            });
            return Json(data);
        }
コード例 #2
0
ファイル: TextFolderController.cs プロジェクト: jason1234/CMS
        public virtual ActionResult Create(TextFolder model, string folderName, string @return)
        {
            //compatible with the Folder parameter changed to FolderName.
            folderName = folderName ?? this.ControllerContext.RequestContext.GetRequestValue("Folder");

            var data = new JsonResultData(ModelState);
            if (ModelState.IsValid)
            {
                data.RunWithTry((resultData) =>
                {

                    Folder parent = null;
                    if (!string.IsNullOrEmpty(folderName))
                    {
                        parent = FolderHelper.Parse<TextFolder>(Repository, folderName);
                    }
                    model.Parent = parent;
                    model.UtcCreationDate = DateTime.UtcNow;
                    Manager.Add(Repository, model);

                    resultData.RedirectUrl = @return;
                });

            }

            return Json(data);
        }
コード例 #3
0
ファイル: LogOnController.cs プロジェクト: royaso/CMS
        public virtual ActionResult Ajax(LoginModel loginModel, int redirect)
        {
            var data = new JsonResultData(ModelState);
            if (ModelState.IsValid)
            {
                data.RunWithTry((resultData) =>
                {
                    if (UserServices.ValidateUser(loginModel.UserName, loginModel.Password) != null)
                    {
                        System.Web.Security.FormsAuthentication.SetAuthCookie(loginModel.UserName, loginModel.RememberMe);
                        if (redirect == 0)
                        {
                            resultData.RedirectUrl = Request.UrlReferrer.ToString();
                        }
                        else
                        {
                            resultData.RedirectUrl = System.Web.Security.FormsAuthentication.DefaultUrl;
                        }

                    }
                    else
                    {
                        resultData.AddFieldError("UserName", "Username and/or password are incorrect.".Localize());
                    }
                });
            }
            return Json(data);
        }
コード例 #4
0
 public virtual ActionResult CopyContent(string schema, string uuid)
 {
     var data = new JsonResultData(ModelState);
     data.RunWithTry((resultData) =>
     {
         var content = Kooboo.CMS.Content.Services.ServiceFactory.TextContentManager.Copy(new Schema(Repository.Current, schema), uuid);
         resultData.Model = new
         {
             uuid = content.UUID,
             schema = content.SchemaName,
             published = string.Empty,
             editUrl = Url.Action("InlineEdit", new
             {
                 controller = "TextContent",
                 Area = "Contents",
                 RepositoryName = content.Repository,
                 SiteName = Site.FullName,
                 FolderName = content.FolderName,
                 UUID = content.UUID
             }),
             summary = HttpUtility.HtmlAttributeEncode(content.GetSummary())
         };
     });
     return Json(data);
 }
コード例 #5
0
        public virtual ActionResult Install(InstallModuleModel installModel, string @return)
        {
            var data = new JsonResultData(ModelState);
            if (ModelState.IsValid)
            {
                data.RunWithTry((resultData) =>
                {
                    var moduleFile = this.Request.Files["ModuleFile"];

                    StringBuilder log = new StringBuilder();
                    var moduleName = System.IO.Path.GetFileNameWithoutExtension(moduleFile.FileName);

                    var moduleInfo = Manager.Install(moduleName, moduleFile.InputStream, ref log);

                    if (moduleInfo == null && log.Length != 0)
                    {
                        data.Success = false;
                        data.AddMessage(log.ToString());
                    }
                    else
                    {
                        data.RedirectUrl = @return;
                    }
                });
            }

            return Json(data);
        }
コード例 #6
0
        public virtual ActionResult Install(InstallModuleModel installModel, string @return)
        {
            var data = new JsonResultData(ModelState);
            if (ModelState.IsValid)
            {
                data.RunWithTry((resultData) =>
                {
                    var moduleFile = this.Request.Files["ModuleFile"];

                    StringBuilder log = new StringBuilder();
                    var moduleName = System.IO.Path.GetFileNameWithoutExtension(moduleFile.FileName);

                    var moduleInfo = Manager.Install(moduleName, moduleFile.InputStream, ref log);

                    if (moduleInfo == null && log.Length != 0)
                    {
                        data.Success = false;
                        data.AddMessage(log.ToString());
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(moduleInfo.InstallingTemplate))
                        {
                            data.RedirectUrl = Url.Action("OnInstalling", ControllerContext.RequestContext.AllRouteValues().Merge("ModuleName", moduleName));
                        }
                        else
                        {
                            data.RedirectUrl = @return;
                        }
                    }
                });
            }

            return Json(data);
        }
コード例 #7
0
ファイル: ShippingPlugin.cs プロジェクト: Wipcore/Ecommerce
        public System.Web.Mvc.ActionResult Submit(Sites.Models.Site site, System.Web.Mvc.ControllerContext controllerContext, Sites.Models.SubmissionSetting submissionSetting)
        {
            var request = controllerContext.HttpContext.Request;
            var action = request["action"];

            var jsonResultData = new JsonResultData();
            object result = null;

            try
            {
                if (action == "get-addresses")
                {
                    result = GetAddresses(site, controllerContext);
                }

                jsonResultData.Success = true;
                jsonResultData.Model = result;
            }
            catch (Exception ex)
            {
                jsonResultData.Success = false;
                jsonResultData.AddException(ex);
            }

            return new JsonResult { Data = jsonResultData, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
        }
コード例 #8
0
ファイル: LabelController.cs プロジェクト: nikolai80/CMS
        public virtual ActionResult Delete(string[] docs, string[] folders)
        {
            var data = new JsonResultData(ModelState);
            data.RunWithTry((resultData) =>
            {
                var category = ControllerContext.RequestContext.GetRequestValue("Category");

                if (docs != null)
                {
                    foreach (var name in docs)
                    {
                        var m = new Element() { Name = name };
                        m.Category = category;
                        Remove(m);
                    }
                }

                if (folders != null)
                {
                    foreach (var c in folders)
                    {
                        Manager.RemoveCategory(Site, c);
                    }
                }

                resultData.ReloadPage = true;
            });
            return Json(data);
        }
コード例 #9
0
        public virtual ActionResult Create(string[] folderName, SendingSetting sendingSetting, string @return)
        {
            if (folderName == null || folderName.Length == 0)
            {
                ModelState.AddModelError("FolderName", "Folder name is required.".Localize());
            }
            var data = new JsonResultData(ModelState);
            data.RunWithTry((resultData) =>
            {
                if (ModelState.IsValid)
                {
                    foreach (var item in folderName)
                    {
                        if (Manager.Get(Repository, item) == null)
                        {
                            sendingSetting.FolderName = item;
                            Manager.Add(Repository, sendingSetting);
                        }

                    }
                    resultData.RedirectUrl = @return;
                }
            });
            return Json(data);
        }
コード例 #10
0
 public virtual ActionResult Import(TextContentImportModel model, string @return)
 {
     var data = new JsonResultData(ModelState);
     data.RunWithTry((resultData) =>
     {
         model.TextContentExporter.Import(new TextFolder(Repository, model.FolderName), model.File.InputStream);
         data.RedirectUrl = @return;
     });
     return Json(data);
 }
コード例 #11
0
ファイル: WorkflowController.cs プロジェクト: ebojangi/CMS
        public virtual ActionResult Delete(Workflow[] model)
        {
            var data = new JsonResultData(ModelState);
            data.RunWithTry((resultData) =>
            {
                Manager.Delete(model, Repository);
            });

            return Json(data);
        }
コード例 #12
0
ファイル: FileController.cs プロジェクト: ebojangi/CMS
        public virtual ActionResult CreateFolder(string folderPath, string folderName, string @return)
        {
            var data = new JsonResultData(ModelState);
            data.RunWithTry((resultData) =>
            {
                FileManager.AddDirectory(Site, folderPath, folderName);

                data.ReloadPage = true;
            });
            return Json(data);
        }
コード例 #13
0
        public virtual ActionResult Copy(CopyModel copyModel, string @return)
        {
            var data = new JsonResultData(ModelState);
            data.RunWithTry((resultData) =>
            {
                Manager.Copy(Repository, copyModel.UUID, copyModel.DestinationName);
                data.RedirectUrl = @return;
            });

            return Json(data);
        }
コード例 #14
0
 public ActionResult Delete(DeleteModel[] model)
 {
     var resultEntry = new JsonResultData(ModelState);
     if (ModelState.IsValid)
     {
         var uuids = model.Select(it => it.UUID).ToArray();
         this._manager.Delete(uuids);
         resultEntry.ReloadPage = true;
     }
     return Json(resultEntry);
 }
コード例 #15
0
 public virtual ActionResult Index(string body)
 {
     JsonResultData data = new JsonResultData(ModelState);
     data.RunWithTry((resultData) =>
     {
         Robots_Txt robot_txt = new Robots_Txt(Site);
         robot_txt.Save(body);
         data.AddMessage("The robots.txt has been saved.".Localize());
     });
     return Json(data);
 }
コード例 #16
0
ファイル: SettingController.cs プロジェクト: Godoy/CMS
        public ActionResult Index(Setting setting)
        {
            JsonResultData data = new JsonResultData(ModelState);
            data.RunWithTry((resultData) =>
            {
                SettingProvider.Update(setting, setting);
                resultData.AddMessage("The setting has been saved.".Localize());
            });

            return Json(data);
        }
コード例 #17
0
        public virtual ActionResult Reject(string workflowName, string roleName, string UUID, string comment, string @return)
        {
            var data = new JsonResultData(ModelState);

            data.RunWithTry((resultData) =>
            {
                Manager.ProcessPendingWorkflowItem(Repository, workflowName, roleName, UUID, User.Identity.Name, false, comment);
                resultData.RedirectUrl = @return;
            });

            return Json(data);
        }
コード例 #18
0
 public ActionResult PublishPage(RemotePagePublishingModel model, string @return)
 {
     var resultEntry = new JsonResultData(ModelState);
     if (ModelState.IsValid)
     {
         if (model.Schedule && !model.UtcTimeToPublish.HasValue && !model.UtcTimeToUnpublish.HasValue)
         {
             resultEntry.AddErrorMessage("UtcTimeToPublish and UtcTimeToUnpublish can not be both empty.".Localize());
         }
         else
         {
             foreach (string uuid in model.Pages)
             {
                 foreach (string endpoint in model.RemoteEndPoints)
                 {
                     var queue = new RemotePublishingQueue()
                     {
                         PublishingObject = PublishingObject.Page,
                         SiteName = Site.Name,
                         UserId = User.Identity.Name,
                         UtcCreationDate = DateTime.UtcNow,
                         RemoteEndpoint = endpoint,
                         ObjectUUID = uuid,
                         ObjectTitle = uuid,
                         Status = QueueStatus.Pending
                     };
                     if (model.Schedule)
                     {
                         if (model.UtcTimeToPublish.HasValue)
                         {
                             queue.UtcTimeToPublish = model.UtcTimeToPublish.Value.ToUniversalTime();
                         }
                         if (model.UtcTimeToUnpublish.HasValue)
                         {
                             queue.UtcTimeToUnpublish = model.UtcTimeToUnpublish.Value.ToUniversalTime();
                         }
                     }
                     else
                     {
                         queue.UtcTimeToPublish = DateTime.UtcNow;
                     }
                     resultEntry.RunWithTry((data) =>
                     {
                         _manager.Add(queue);
                     });
                 }
             }
             resultEntry.RedirectUrl = @return;
         }
     }
     return Json(resultEntry);
 }
コード例 #19
0
ファイル: SettingController.cs プロジェクト: Godoy/CMS
 public virtual ActionResult Index(Repository model)
 {
     JsonResultData data = new JsonResultData(ModelState);
     data.RunWithTry((resultData) =>
     {
         if (ModelState.IsValid)
         {
             Manager.Update(model, Manager.Get(model.Name));
             data.ReloadPage = true;
         }
     });
     return Json(data);
 }
コード例 #20
0
 public virtual ActionResult Create(CreateRepositoryModel model)
 {
     JsonResultData data = new JsonResultData(ModelState);
     data.RunWithTry((resultData) =>
     {
         if (ModelState.IsValid)
         {
             Manager.Create(model.Name, model.Template);
             resultData.RedirectUrl = Url.Action("Index", new { controller = "home", repositoryName = model.Name });
         }
     });
     return Json(data);
 }
コード例 #21
0
ファイル: ContactSitePlugin.cs プロジェクト: Godoy/CMS
        public System.Web.Mvc.ActionResult Submit(Models.Site site, System.Web.Mvc.ControllerContext controllerContext, Models.SubmissionSetting submissionSetting) {
            JsonResultData resultData = new JsonResultData();
            string redirectUrl;
            if (!ContactSiteCore(controllerContext, submissionSetting, out redirectUrl)) {
                resultData.AddModelState(controllerContext.Controller.ViewData.ModelState);
                resultData.Success = false;
            } else {
                resultData.RedirectUrl = redirectUrl;
                resultData.Success = true;
            }
            return new JsonResult() { Data = resultData };

        }
コード例 #22
0
ファイル: BlogController.cs プロジェクト: Qupy/Extensions
 public ActionResult Delete(Blog[] model)
 {
     JsonResultData data = new JsonResultData();
     data.RunWithTry((resultData) =>
     {
         foreach (var item in model)
         {
             _provider.Delete(item);
         }
         data.RedirectUrl = Url.Action("Index", ControllerContext.RequestContext.AllRouteValues().Merge("id", null));
     });
     return Json(data);
 }
コード例 #23
0
ファイル: MembershipUserController.cs プロジェクト: Godoy/CMS
 public virtual ActionResult ChangePassword(ChangePasswordModel model, string @return)
 {
     JsonResultData data = new JsonResultData(ModelState);
     if (ModelState.IsValid)
     {
         data.RunWithTry((resultData) =>
         {
             _manager.ChangePassword(Membership, model.UUID, model.NewPassword);
             resultData.RedirectUrl = @return;
         });
     }
     return Json(data);
 }
コード例 #24
0
        public virtual ActionResult CopyInstallationFiles(string moduleName)
        {
            var data = new JsonResultData(ModelState);
            if (ModelState.IsValid)
            {
                data.RunWithTry((resultData) =>
                {
                    _moduleInstaller.CopyAssemblies(moduleName, true);
                });
            }

            return Json(data);
        }
コード例 #25
0
ファイル: RolesController.cs プロジェクト: Godoy/CMS
 public virtual ActionResult Delete(Role[] model)
 {
     var data = new JsonResultData(ModelState);
     data.RunWithTry((resultData) =>
     {
         foreach (var role in model)
         {
             RoleManager.Delete(role.Name);
         }
         resultData.ReloadPage = true;
     });
     return Json(data);
 }
コード例 #26
0
 public ActionResult Create(RemoteEndpointSetting setting, string @return)
 {
     var resultEntry = new JsonResultData(ModelState);
     if (ModelState.IsValid)
     {
         resultEntry.RunWithTry((data) =>
         {
             _manager.Add(setting);
             data.RedirectUrl = @return;
         });
     }
     return Json(resultEntry);
 }
コード例 #27
0
ファイル: RepositoryController.cs プロジェクト: Godoy/CMS
 public virtual ActionResult Create(Repository repository)
 {
     JsonResultData data = new JsonResultData(ModelState);
     data.RunWithTry((resultData) =>
     {
         if (ModelState.IsValid)
         {
             Manager.Add(repository);
             resultData.RedirectUrl = Url.Action("Guide", new { controller = "Repository", repositoryName = repository.Name });
         }
     });
     return Json(data);
 }
コード例 #28
0
        public virtual ActionResult Delete(string membershipName)
        {
            ModelState.Clear();
            var data = new JsonResultData(ModelState);
            data.RunWithTry((resultData) =>
            {
                _manager.Delete(new Kooboo.CMS.Member.Models.Membership() { Name = membershipName });

                data.ReloadPage = true;
            });

            return Json(data);
        }
コード例 #29
0
        public ActionResult PublishPage(LocalPagePublishingModel model, string @return)
        {
            var resultEntry = new JsonResultData(ModelState);
            if (ModelState.IsValid)
            {
                if (model.Schedule && !model.UtcTimeToPublish.HasValue && !model.UtcTimeToUnpublish.HasValue)
                {
                    resultEntry.AddErrorMessage("UtcTimeToPublish and UtcTimeToUnpublish can not be both empty".Localize());
                }
                else if (model.Schedule)
                {
                    foreach (string uuid in model.Pages)
                    {
                        var queue = new LocalPublishingQueue()
                        {
                            PublishingObject = PublishingObject.Page,
                            SiteName = Site.Name,
                            UserId = User.Identity.Name,
                            UtcCreationDate = DateTime.UtcNow,
                            ObjectUUID = uuid,
                            ObjectTitle = uuid,
                            Status = QueueStatus.Pending
                        };
                        if (model.UtcTimeToPublish.HasValue)
                        {
                            queue.UtcTimeToPublish = model.UtcTimeToPublish.Value.ToUniversalTime();
                        }
                        if (model.UtcTimeToUnpublish.HasValue)
                        {
                            queue.UtcTimeToUnpublish = model.UtcTimeToUnpublish.Value.ToUniversalTime();
                        }

                        resultEntry.RunWithTry((data) =>
                        {
                            _manager.Add(queue);
                        });
                    }
                    resultEntry.RedirectUrl = @return;
                }
                else
                {
                    foreach (string uuid in model.Pages)
                    {
                        var page = new Page(Site, uuid);
                        Kooboo.CMS.Sites.Services.ServiceFactory.PageManager.Publish(page, false, false, false, DateTime.UtcNow, DateTime.UtcNow, User.Identity.Name);
                    }
                    resultEntry.RedirectUrl = @return;
                }
            }
            return Json(resultEntry);
        }
コード例 #30
0
        public ActionResult Create(Kooboo.CMS.Membership.Models.Membership membership, string @return)
        {
            JsonResultData data = new JsonResultData(ModelState);
            if (ModelState.IsValid)
            {
                data.RunWithTry((resultData) =>
                {
                    _manager.Add(membership);
                    resultData.RedirectUrl = @return;
                });
            }

            return Json(data);
        }