Exemplo n.º 1
0
        public ActionResult SortPages(int parentNodeId, int[] orderedChildNodeIds)
        {
            AjaxMessageViewData result = new AjaxMessageViewData();

            try
            {
                this._nodeService.SortNodes(parentNodeId, orderedChildNodeIds);
                result.Message = GetText("PageOrderUpdatedMessage");
            }
            catch (Exception ex)
            {
                Logger.Error("Unexpected error while sorting pages.", ex);
                result.Error = ex.Message;
            }

            return(Json(result));
        }
Exemplo n.º 2
0
        public ActionResult UploadAjax(string uploadpath, HttpPostedFileBase filedata)
        {
            AjaxMessageViewData ajaxResult = new AjaxMessageViewData();

            if (filedata != null)
            {
                try
                {
                    string physicalDataDirectory = Server.MapPath(uploadpath);
                    string physicalFilePath      = Path.Combine(physicalDataDirectory, filedata.FileName);
                    string fileNameAfterUpload   = this._fileManagerService.UploadFile(physicalFilePath, filedata.InputStream);
                    ajaxResult.Message = String.Format(GetText("FileUploadSuccessMessage"), fileNameAfterUpload);
                }
                catch (Exception ex)
                {
                    ajaxResult.Error = ex.Message;
                }
            }
            return(Json(ajaxResult));
        }
Exemplo n.º 3
0
        public ActionResult ArrangeSections(string placeholder, int[] orderedSectionIds)
        {
            AjaxMessageViewData result = new AjaxMessageViewData();

            try
            {
                if (orderedSectionIds != null)
                {
                    this._sectionService.ArrangeSections(placeholder, orderedSectionIds);
                    result.Message = String.Format(GetText("SectionsArrangedMessage"), placeholder);
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Unexpected error while arranging sections.", ex);
                result.Error = ex.Message;
            }

            return(Json(result));
        }
Exemplo n.º 4
0
        public ActionResult SetTemplate(int nodeId, int templateId)
        {
            AjaxMessageViewData result = new AjaxMessageViewData();

            try
            {
                Node node = this._nodeService.GetNodeById(nodeId);
                node.Template = this._templateService.GetTemplateById(templateId);
                this._nodeService.SaveNode(node);
                result.Message = GetText("TemplateSetMessage");
            }
            catch (Exception ex)
            {
                Logger.Error("Unexpected error while setting template.", ex);
                result.Error = ex.Message;
            }
            JsonResult jsonResult = Json(result);

            jsonResult.ContentType = "text/html";             // otherwise the ajax form doesn't handle the callback
            return(jsonResult);
        }
Exemplo n.º 5
0
        public ActionResult UploadTemplates()
        {
            AjaxMessageViewData result = new AjaxMessageViewData();

            try
            {
                if (Request.Files.Count > 0)
                {
                    HttpPostedFileBase theFile = Request.Files[0];
                    if (!theFile.FileName.EndsWith(".zip"))
                    {
                        throw new Exception(GetText("InvalidZipFileMessage"));
                    }
                    string templatesRoot = VirtualPathUtility.Combine(CuyahogaContext.CurrentSite.SiteDataDirectory, "Templates");
                    string filePath      = Path.Combine(Server.MapPath(templatesRoot), theFile.FileName);
                    this._templateService.ExtractTemplatePackage(filePath, theFile.InputStream);
                    result.Message = GetText("TemplatesUploadedMessage");
                }
                else
                {
                    result.Error = GetText("NoFileUploadedMessage");
                }
            }
            catch (InvalidPackageException ex)
            {
                Logger.Error(ex.Message, ex);
                result.Error = GetText(ex.Message);
            }
            catch (Exception ex)
            {
                Logger.Error("Unexpected error while uploading templates.", ex);
                result.Error = ex.Message;
            }

            JsonResult jsonResult = Json(result);

            jsonResult.ContentType = "text/html";             // otherwise the ajax form doesn't handle the callback
            return(jsonResult);
        }