public string generateAll(string exportPath, decimal projectId) { int pageCnt = 0; int contentCnt = 0; projectDTO = BLL.BLProject.getProjectInfo(projectId); string path = exportPath + "/" + projectDTO.OwnerUserId + "/" + projectDTO.ProjectId; if (!Directory.Exists(exportPath)) { Directory.CreateDirectory(exportPath); } if (!Directory.Exists(path)) { BLL.BLProject.reCreateResources(exportPath, projectDTO); } string designCnt = BLL.BLProject.makeAllDesign(exportPath, projectDTO); //MultiPanel from templateType templateTypeDTO = BLL.BLTemplateType.getTypeByName("global.js"); mainResult = templateTypeDTO.TokenizeString; //mainResult = replacePageToken(mainResult, pageDTO.ProjectId, pageDTO.PageId); mainResult = replaceGolbalToken(mainResult, templateTypeDTO, projectId); //mainResult = replaceCurrentPage(pageDTO.PageId, pageContentId); mainResult = Parser.removeUnUsableTokens(mainResult); mainResult = Parser.removeUnUsableAttributes(mainResult); globalJsResult = replaceglobalJSToken(globalJsResult, projectId); globalJsResult = Parser.removeUnUsableTokens(globalJsResult); //generatePageAndContents(projectId, templateTypeDTO); List <PageDTO> pageDTOs = BLL.BLProject.getPageList(projectId); foreach (PageDTO pageDTO in pageDTOs) { contentCnt = savePageAndContents(exportPath, pageDTO.PageId, contentCnt); pageCnt++; } generateIndexResult(contentDTO.ProjectId); saveFile(path, "index.html", indexResult); saveFile(path, "global.js", templateTypeglobalJs); saveFile(path, "main.html", mainResult); saveFile(path, "dashboard.js", BLL.BLDashboard.getDashbordJsString(projectDTO.ProjectId)); saveDashboards(path, projectDTO.ProjectId); return("pages:" + pageCnt + " contents: " + contentCnt + " " + designCnt); }
public void TestGetTemplatePlaceHolderList() { BLProject blProject = new BLProject(); //TemplateDTO templateDTO = BLL.BLTemplateType.getTypeByName("");// blProject.getTemplate(1); BLTemplateType bLTemplateType = new BLTemplateType(); TemplateTypeDTO templateTypeDTO = bLTemplateType.getTypeByName("angularJs-Materil"); List <string> tokenList = Parser.getPlaceHolderList(templateTypeDTO.TokenizeString, Constant.pattern); Assert.AreEqual(tokenList.Count, 15); Assert.AreEqual(tokenList[3], "<<<Page.AppName>>>"); }
//private string replaceCurrentPage(decimal pageId, decimal pageContentId) //{ // mainResult = mainResult.Replace("<<<pageId>>>", pageId.ToString()); // mainResult = mainResult.Replace("<<<pageContentId>>>", pageContentId.ToString()); // mainResult = mainResult.Replace("<<<rand>>>", (new Random()).Next().ToString()); // return mainResult; //} private string generateContentDesigns(decimal projectId, decimal pageId, string contentResult, ContentDTO contentDTO) { string files = "'" + contentDTO.FullPath + ".js?r=" + (new Random()).Next().ToString() + "'"; string includeList = ""; void createNextDesign(decimal designId) { List <DesignResultDTO> designResultDTOList = BLL.BLDesign.getDesignResultList(designId); foreach (DesignResultDTO designResultDTO in designResultDTOList) { if (designResultDTO.DestDesignId != null) { files += ",'Design/design" + designResultDTO.DestDesignId + ".js?r=" + (new Random()).Next().ToString() + "'"; includeList += "<div ng-controller=\"Design_" + designResultDTO.DestDesignId + "\"></div>\n"; createNextDesign(designResultDTO.DestDesignId.Value); } } } List <DesignDTO> designDTOs = BLL.BLDesign.getDesignListForPageContent(contentDTO.PageContentId); foreach (DesignDTO designDto in designDTOs) { files += ",'Design/design" + designDto.DesignId + ".js?r=" + (new Random()).Next().ToString() + "'"; includeList += "<div ng-controller=\"Design_" + designDto.DesignId + "\"></div>\n"; if (designDto.isMulipledest == 1) { createNextDesign(designDto.DesignId); } } TemplateTypeDTO PageContentTemplate = BLL.BLTemplateType.getTypeByName("PageContent"); string formName = BLL.BLPage.getPageToken(projectId, pageId, "FormName"); contentDTO = BLL.BLPageContent.getContent(contentDTO.PageContentId); files = BLL.BLContent.getContentLazyFiles(contentDTO, files, layoutDTO); PageContentTemplate.TokenizeString = PageContentTemplate.TokenizeString.Replace("<<<files>>>", files); PageContentTemplate.TokenizeString = PageContentTemplate.TokenizeString.Replace("<<<PageContentId>>>", contentDTO.PageContentId.ToString()); PageContentTemplate.TokenizeString = PageContentTemplate.TokenizeString.Replace("<<<FormName>>>", formName); PageContentTemplate.TokenizeString = PageContentTemplate.TokenizeString.Replace("<<<includeList>>>", includeList); PageContentTemplate.TokenizeString = PageContentTemplate.TokenizeString.Replace("<<<contentResult>>>", contentResult); //contentResult = "<div oc-lazy-load=\"{name:'myApp',files:[" + files + "]}\"> \n" + // "\t"+includeList + // "\t\t<div ng-controller=\"Ctrl" + contentDTO.PageContentId + "\">\n \t" + contentResult + " \n </div>\n" + // "\t\t</div> \n" + // "\t</div> \n" + // "</div> \n"; return(PageContentTemplate.TokenizeString); }
/// <summary> /// 根据m_SQL,获取数据,把列和相应的值生成参数 /// </summary> /// <returns>返回参数</returns> public Dictionary<string, string> GetParams() { Dictionary<string, string> dic = new Dictionary<string, string>(); TemplateTypeDTO templateType = BuildWordInstance.GetTemplateType((int)this.templateTypeID); if (templateType != null) { this.DocTemplateTypeName = templateType.TEMPLATE_TYPE_NAME; this.sql = templateType.SQL_CONTENT; if (this.keyRegex.IsMatch(this.sql)) this.sql = this.keyRegex.Replace(this.sql, this.instanceID.ToString()); dic = BuildWordInstance.GetTemplateParms(this.sql); } return dic; }
private string replaceGolbalToken(string result, TemplateTypeDTO templateTypeDTO, decimal projectId) { WebDefinerDTO templateWebDefinerDTO = BLL.BLWebDefiner.getWebDefinerInfo(templateTypeDTO.WebDefinerId); string allInjectorList = templateWebDefinerDTO.InjectorList; string allVariableList = templateWebDefinerDTO.VariableList; string allParamList = templateWebDefinerDTO.ParamList; result = result.Replace("<<<All.Injectors>>>", Parser.clearExtraComa(allInjectorList)); result = result.Replace("<<<All.Variables>>>", Parser.clearExtraComa(allVariableList)); result = result.Replace("<<<All.Params>>>", Parser.clearExtraComa(allParamList)); result = result.Replace("<<<All.Functions>>>", templateWebDefinerDTO.FunctionList); result = result.Replace("<<<All.JSList>>>", templateWebDefinerDTO.JS); result = result.Replace("<<<All.CSSList>>>", templateWebDefinerDTO.CSS); //result = result.Replace("<<<Title>>>", projectDTO.ProjectName); return(result); }
public int savePageAndContents(string exportPath, decimal pageId, int contentCnt) { PageDTO pageDTO = BLL.BLPage.getPageInfo(pageId); ProjectDTO projectDTO = BLL.BLProject.getProjectInfo(pageDTO.ProjectId); string path = exportPath + "/" + projectDTO.OwnerUserId + "/" + projectDTO.ProjectId; containerTypeDTO = BLL.BLContainerType.getContainerType(pageDTO.ContainerTypeId); List <ContentDTO> contentDTOs = BLL.BLPage.getPageContentList(pageId); contentResult = ""; templateTypeDTO = BLL.BLTemplateType.getTypeByName("global.js"); if (!Directory.Exists(path + "/Content/" + pageDTO.Path)) { Directory.CreateDirectory(path + "/Content/" + pageDTO.Path); } foreach (ContentDTO contentDTO in contentDTOs) { if (!Directory.Exists(path + "/Content/" + contentDTO.Path)) { Directory.CreateDirectory(path + "/Content/" + contentDTO.Path); } layoutDTO = BLL.BLLayout.getLayoutInfo(contentDTO.ContentId, contentDTO.LayoutId); contentResult = replaceLayouutComponent(contentDTO.PageContentId, contentDTO, layoutDTO); //contentResult += BLL.BLNavigation.getNavigationList(pageContentId); contentResult = Parser.removeUnUsableTokens(contentResult); contentResult = Parser.removeUnUsableAttributes(contentResult); contentResult = generateContentDesigns(pageDTO.ProjectId, pageDTO.PageId, contentResult, contentDTO); controllerResult = generateControllerResult(pageDTO.ProjectId, contentDTO, templateTypeDTO, contentDTO.PageContentId); saveFile(path, contentDTO.FullPath + ".html", contentResult); saveFile(path, contentDTO.FullPath + ".js", controllerResult); contentCnt++; } saveFile(path, pageDTO.FullPath + ".html", getPageResult(pageDTO)); return(contentCnt); }
public TemplateTypeDTO GetTemplateType(int templateTypeId) { TemplateTypeDTO result = null; using (BaseDB dbHelper = new OmpdDBHelper()) { try { Dictionary<string, object> dicParms = new Dictionary<string, object>(); dicParms.Add("i_template_type", templateTypeId); var templateTypeList = dbHelper.ExecuteListProc<TemplateTypeDTO>("pkg_redas_build_doc.sp_template_type_get", dicParms); if (templateTypeList.Count > 0) { result = templateTypeList[0]; } } catch { } return result; } }
public string generatePageContent(string exportPath, decimal pageContentId) { contentDTO = BLL.BLPageContent.getContent(pageContentId); pageDTO = BLL.BLPageContent.getPage(pageContentId); layoutDTO = BLL.BLLayout.getLayoutInfo(contentDTO.ContentId, contentDTO.LayoutId); //templateTypeDTO = BLL.BLTemplateType.getProjectTemplateType(contentDTO.ProjectId); //global.js from templateType templateTypeDTO = BLL.BLTemplateType.getTypeByName("global.js"); projectDTO = BLL.BLProject.getProjectInfo(pageDTO.ProjectId); containerTypeDTO = BLL.BLContainerType.getContainerType(pageDTO.ContainerTypeId); //mainResult = getPageResult(); mainResult = templateTypeDTO.TokenizeString; mainResult = replacePageToken(mainResult, pageDTO.ProjectId, pageDTO.PageId); mainResult = replaceGolbalToken(mainResult, templateTypeDTO, pageDTO.ProjectId); //mainResult = replaceCurrentPage(pageDTO.PageId, pageContentId); //mainResult = replacePageControllers(mainResult, pageDTO.PageId); globalJsResult = replaceglobalJSToken(globalJsResult, pageDTO.ProjectId); globalJsResult = Parser.removeUnUsableTokens(globalJsResult); //mainResult = generateDesigns(mainResult, pageDTO.ProjectId, pageDTO.PageId); mainResult = Parser.removeUnUsableTokens(mainResult); mainResult = Parser.removeUnUsableAttributes(mainResult); contentResult = replaceLayouutComponent(pageContentId, contentDTO, layoutDTO); //contentResult += BLL.BLNavigation.getNavigationList(pageContentId); contentResult = Parser.removeUnUsableTokens(contentResult); contentResult = Parser.removeUnUsableAttributes(contentResult); contentResult = generateContentDesigns(projectDTO.ProjectId, pageDTO.PageId, contentResult, contentDTO); controllerResult = generateControllerResult(pageDTO.ProjectId, contentDTO, templateTypeDTO, pageContentId); BLL.BLDesign.savePageContentDesigns(exportPath, projectDTO, pageContentId); generateIndexResult(contentDTO.ProjectId); string path = exportPath + "/" + projectDTO.OwnerUserId + "/" + projectDTO.ProjectId; if (!Directory.Exists(exportPath)) { Directory.CreateDirectory(exportPath); } if (!Directory.Exists(path)) { BLL.BLProject.reCreateResources(exportPath, projectDTO); } saveFile(path, "index.html", indexResult); saveFile(path, "global.js", templateTypeglobalJs); if (!Directory.Exists(path + "/Content/" + pageDTO.Path)) { Directory.CreateDirectory(path + "/Content/" + pageDTO.Path); } if (!Directory.Exists(path + "/Content/" + contentDTO.Path)) { Directory.CreateDirectory(path + "/Content/" + contentDTO.Path); } saveFile(path, pageDTO.FullPath + ".html", getPageResult(pageDTO)); saveFile(path, contentDTO.FullPath + ".html", contentResult); saveFile(path, contentDTO.FullPath + ".js", controllerResult); saveFile(path, "main.html", mainResult); saveFile(path, "path.js", getPathJs(projectDTO)); saveFile(path, "dashboard.js", BLL.BLDashboard.getDashbordJsString(projectDTO.ProjectId)); saveFile(path, "part.js", BLL.BLDashboard.getPartJsString()); saveFile(path, "part.html", BLL.BLDashboard.getPartHTMLString()); saveFile(path, "/Table/table.js", BLL.BLTemplateType.getTypeByName("table.js").TokenizeString); saveDashboards(path, projectDTO.ProjectId); return(""); }
private string generateControllerResult(decimal projectId, ContentDTO contentDTO, TemplateTypeDTO templateTypeDTO, decimal pageContentId) { string allFunctionList = ""; string allDirectiveList = ""; string result = BLL.BLTemplateType.getTypeByName("angularJs-Content").TokenizeString; WebDefinerDTO templateWebDefinerDTO = BLL.BLWebDefiner.getWebDefinerInfo(templateTypeDTO.WebDefinerId); List <WebDefinerDTO> webDefinerList = BLL.BLWebDefiner.getComponentListWebDefinerForPageContent(pageContentId); string allInjectorList = templateWebDefinerDTO.InjectorList; string allVariableList = templateWebDefinerDTO.VariableList; string allParamList = templateWebDefinerDTO.ParamList; foreach (WebDefinerDTO webDefinerDTO in webDefinerList) { allParamList += "," + webDefinerDTO.ParamList; allVariableList += "," + webDefinerDTO.VariableList; allFunctionList += "\n " + webDefinerDTO.FunctionList; allDirectiveList += "\n " + webDefinerDTO.Directive; allInjectorList += "," + webDefinerDTO.InjectorList; } //todo replace App with token result = result.Replace("<<<Page.AppName>>>", BLL.BLProject.getProjectToken(projectId, "Page.AppName")); result = result.Replace("<<<ControllerName>>>", "Ctrl" + contentDTO.PageContentId); result = result.Replace("<<<Variables>>>", Parser.clearExtraComa(allVariableList)); result = result.Replace("<<<Params>>>", Parser.clearExtraComa(allParamList)); result = result.Replace("<<<Functions>>>", "<<<Functions>>> \n" + allFunctionList); result = result.Replace("<<<DirectiveList>>>", allDirectiveList); result = result.Replace("<<<InjectorList>>>", Parser.clearExtraComa(allInjectorList)); string controllerClicks = getControllerClick(contentDTO); result = result.Replace("<<<Functions>>>", controllerClicks); result = Parser.removeUnUsableTokens(result); return(result); }
public TemplateTypeDTO getTemplateType(decimal templateId) { TemplateTypeDTO templateTypeDTO = templateTypeEntity.getTemplateType(templateId); return(templateTypeDTO); }