public JsonResult SaveTemplate(string tempId, string tempName, string icon, string html) { return(this.ExecuteFunctionRun(() => { html = HttpContext.Server.UrlDecode(html); ActionResult result = new ActionResult(true); if (string.IsNullOrEmpty(tempName) || string.IsNullOrEmpty(html)) { result.Success = false; result.Message = "模板名称和HTML不能为空"; return Json(result, JsonRequestBehavior.AllowGet); } Guid guid = Guid.Empty; bool isNeedUpdate = Guid.TryParse(tempId, out guid) && !string.IsNullOrEmpty(tempId); OThinker.H3.Site.SitePageTemplate obj = new OThinker.H3.Site.SitePageTemplate(); if (isNeedUpdate) { obj = this.Engine.SiteManager.GetPageTemplate(tempId); } obj.HtmlContent = html; obj.TemplateName = tempName; obj.Icon = icon; bool b = true; if (isNeedUpdate) { b = this.Engine.SiteManager.UpdatePageTemplate(obj); } else { b = this.Engine.SiteManager.AddPageTemplate(obj); } if (!b) { result.Success = false; result.Message = "保存失败"; } return Json(result, JsonRequestBehavior.AllowGet); })); }
public JsonResult GetAllPages() { return(this.ExecuteFunctionRun(() => { ActionResult result = new ActionResult(true); int recordCount = 0; DataTable dtPages = new DataTable(); OThinker.H3.Site.SitePage[] sitepages = this.Engine.SiteManager.GetAllPages(); recordCount = sitepages.Length; if (sitepages != null && recordCount > 0) { int i = 0; dtPages.Columns.Add("ObjectID"); dtPages.Columns.Add("RowNumber_"); dtPages.Columns.Add("Title"); dtPages.Columns.Add("OrgId"); dtPages.Columns.Add("CreatedBy"); dtPages.Columns.Add("CreatedTime"); dtPages.Columns.Add("LastModifiedTime"); dtPages.Columns.Add("TemplateId"); List <SitePagesViewModel> griddata = new List <SitePagesViewModel>(); foreach (OThinker.H3.Site.SitePage sitepage in sitepages) { DataRow r = dtPages.NewRow(); r["ObjectID"] = sitepage.ObjectID; r["RowNumber_"] = i; r["Title"] = sitepage.Title; r["OrgId"] = sitepage.OrgId; r["CreatedBy"] = sitepage.CreatedBy; r["CreatedTime"] = sitepage.CreatedTime; r["LastModifiedTime"] = sitepage.LastModifiedTime; r["TemplateId"] = sitepage.TemplateId; dtPages.Rows.Add(r); } //解析组织 Dictionary <string, string> unitNames = new Dictionary <string, string>(); if (dtPages != null && dtPages.Rows.Count > 0) { string[] columns = new string[] { OThinker.H3.Site.SitePage.PropertyName_OrgId, OThinker.H3.Site.SitePage.PropertyName_CreatedBy }; unitNames = this.GetUnitNamesFromTable(dtPages, columns); } foreach (OThinker.H3.Site.SitePage sitepage in sitepages) { i++; //时间过滤 string CreatedTime = this.GetValueFromDate(sitepage.CreatedTime, WorkItemTimeFormat); if (CreatedTime.IndexOf("1753") > -1 || CreatedTime.IndexOf("0001") > -1) { CreatedTime = ""; } string LastModifiedTime = this.GetValueFromDate(sitepage.LastModifiedTime, WorkItemTimeFormat); if (LastModifiedTime.IndexOf("1753") > -1 || LastModifiedTime.IndexOf("0001") > -1) { LastModifiedTime = ""; } string TemplateName = ""; OThinker.H3.Site.SitePageTemplate pageTemplate = this.Engine.SiteManager.GetPageTemplate(sitepage.TemplateId); if (pageTemplate != null) { TemplateName = pageTemplate.TemplateName; } griddata.Add(new SitePagesViewModel() { ObjectID = sitepage.ObjectID, RowNumber = i, Title = sitepage.Title, OrgId = sitepage.OrgId, OrgName = this.GetValueFromDictionary(unitNames, sitepage.OrgId), CreatedBy = sitepage.CreatedBy, CreatedName = this.GetValueFromDictionary(unitNames, sitepage.CreatedBy), CreatedTime = CreatedTime, LastModifiedTime = LastModifiedTime, TemplateId = sitepage.TemplateId, TemplateName = TemplateName }); } result.Extend = griddata; } return Json(result, JsonRequestBehavior.AllowGet); })); }