private void bindTransDrop( PageCategory category ) { List<PageCategory> xlist = getTransList( category ); xlist.ForEach( x => x.data["TransLink"] = to( TransPage, x.Id ) ); bindList( "transList", "x", xlist ); }
/// <summary> /// Initializes a new instance of the <see cref="RenderPageCategoryViewModel" /> class. /// </summary> public RenderPageCategoryViewModel(PageCategory category) { if (category != null) { Id = category.Id; Version = category.Version; Name = category.Category.Name; } }
private List<PageCategory> getTransList( PageCategory category ) { List<PageCategory> list = pageService.GetCategories( ctx.owner.obj ); List<PageCategory> xlist = new List<PageCategory>(); foreach (PageCategory x in list) { if (x.Id != category.Id) { xlist.Add( x ); } } return xlist; }
public static DataTable GetList(int PageIndex,int PageSize,PageCategory pageCate,out int RecordCount) { int PageLowerBound = 0, PageUpperBount = 0; PageLowerBound = (PageIndex - 1) * PageSize; PageUpperBount = PageLowerBound + PageSize; string sqlCount = String.Format("select count(0) from cmspage where category={0}", (int)pageCate); string sqlData = @" select * from (select row_number() over(order by pageid desc) as nid,* from cmspage where category={0}) as sp where sp.nid>{1} and sp.nid<={2}"; RecordCount = Convert.ToInt32(db.ExecuteScalar(CommandType.Text,sqlCount)); return db.ExecuteDataSet(CommandType.Text, String.Format(sqlData,(int)pageCate,PageLowerBound,PageUpperBount)).Tables[0]; }
public async Task <PageCategoryDto> Handle(Command request, CancellationToken cancellationToken) { var pageCategory = new PageCategory { Title = request.Title, Pid = request.Pid, Prop1 = request.Prop1, Prop2 = request.Prop2, Prop3 = request.Prop3, Prop4 = request.Prop4 }; _context.PageCategorys.Add(pageCategory); var success = await _context.SaveChangesAsync() > 0; if (success) { var toReturn = _mapper.Map <PageCategory, PageCategoryDto>(pageCategory); return(toReturn); } throw new Exception("Problem saving changes"); }
public virtual void SaveSort() { int id = ctx.PostInt("id"); String cmd = ctx.Post("cmd"); PageCategory data = pageService.GetCategoryById(id, ctx.owner.obj); List <PageCategory> list = pageService.GetCategories(ctx.owner.obj); if (cmd == "up") { new SortUtil <PageCategory>(data, list).MoveUp(); echoJsonOk(); } else if (cmd == "down") { new SortUtil <PageCategory>(data, list).MoveDown(); echoJsonOk(); } else { echoError(lang("exUnknowCmd")); } }
public static DataTable GetTemplateList(PageCategory pageCate) { /* 建立模板时的命名规则 */ // Template_HomePage_Index.aspx // Template_{PageCategoryName}_{TemplateName}.aspx string TemplateRootPath = ConfigurationManager.AppSettings["templateRootPath"]; Regex reg = new Regex(@"Template_(?<cate>\w+)_(?<page>\w+).aspx"); DataTable dt = new DataTable(); dt.Columns.Add("fullname"); dt.Columns.Add("cate"); dt.Columns.Add("name"); foreach (string f in Directory.GetFiles(TemplateRootPath)) { Match match = reg.Match(f); if (match.Success) { DataRow row = dt.NewRow(); row["fullname"] = "\\cms" + Regex.Split(f, "cms", RegexOptions.IgnoreCase)[1]; row["cate"] = match.Groups["cate"].Value; row["name"] = f.Substring(f.LastIndexOf("\\") + 1); dt.Rows.Add(row); } } DataTable newTable = dt.Clone(); foreach (DataRow row in dt.Select("cate = '" + pageCate.ToString() + "'")) { newTable.ImportRow(row); } return(newTable); }
private void LoadNewScene(PageCategory view) { PageModule scene = null; switch (view) { case PageCategory.LandingPage: scene = ((PackedScene)GD.Load(LandingPagePath)).Instance() as PageModule; break; case PageCategory.LogicEditor: scene = ((PackedScene)GD.Load(EditorPath)).Instance() as PageModule; break; case PageCategory.Simulation: if (!string.IsNullOrEmpty(_openedLesson.SimulationPath)) { scene = ((PackedScene)GD.Load(SimulationPath)).Instance() as PageModule; } break; case PageCategory.Examination: if (!string.IsNullOrEmpty(_openedLesson.TestPath)) { scene = ((PackedScene)GD.Load(_openedLesson.TestPath)).Instance() as PageModule; } break; } _currentPage = scene; if (_currentPage != null) { _currentPage.InitialiseWith(_mainNode, _openedLesson); _mainNode.AddChild(_currentPage); _mainNode.MoveChild(_currentPage, 0); } }
private Boolean hasPermission(PageCategory category) { if (ctx.viewer.IsLogin == false) { return(false); } if (ctx.viewer.IsAdministrator()) { return(true); } if (category.OpenStatus == OpenStatus.Close) { return(false); } if (category.OpenStatus == OpenStatus.Open) { return(true); } if (userIsEditor(ctx.viewer.Id, category.EditorIds)) { return(true); } return(false); }
public async Task CreateCategoryPageAsync(CreateCategoryPageViewModel form) { var page = new Data.Models.Page { PageName = form.PageName }; var pictures = new List <Picture>(); foreach (var pictureUrl in form.PageCategory.Pictures) { pictures.Add(new Picture { Url = pictureUrl, Name = "Categories", CreatedOn = DateTime.UtcNow, ModificationDate = DateTime.UtcNow }); } var pageCategory = new PageCategory { CategoryName = form.PageCategory.CategoryName, AllHref = form.PageCategory.AllHref, AllName = form.PageCategory.AllName, Pictures = pictures, }; var itemCategories = new List <ItemsCategory>(); foreach (var ic in form.PageCategory.ItemsCategories) { var pageCategoryItems = new List <PageCategoryItems>(); if (string.IsNullOrEmpty(ic.Category)) { continue; } foreach (var item in ic.Items) { if (string.IsNullOrEmpty(item.Text) || string.IsNullOrEmpty(item.Href)) { } else { pageCategoryItems.Add(new PageCategoryItems { Href = item.Href, Text = item.Text, }); } } itemCategories.Add(new ItemsCategory { Category = ic.Category, Items = pageCategoryItems }); } pageCategory.ItemsCategories = itemCategories; page.Categories.Add(pageCategory); await this.context.Pages.AddAsync(page); await this.context.SaveChangesAsync(); }
/// <summary> /// Requests a change of the current page to the new page. /// Used to provide the possibility for the user to save or cancel the action. /// </summary> public void UserRequestsChangeTo(PageCategory page) { }
/// <summary> /// Changes the main page to the given view. Forced. /// </summary> public void ChangePageTo(PageCategory page) { }
private Boolean hasPermission( PageCategory category ) { if (ctx.viewer.IsLogin == false) return false; if (ctx.viewer.IsAdministrator()) return true; if (category.OpenStatus == OpenStatus.Close) return false; if (category.OpenStatus == OpenStatus.Open) return true; if (userIsEditor( ctx.viewer.Id, category.EditorIds )) return true; return false; }
private List<BlogPost> GetFakeBlogPosts() { var blog = new BlogPost { Id = Guid.NewGuid(), Author = new Author { Id = Guid.NewGuid(), Name = "Test Author" }, PageUrl = "/test/url/", Title = "Test title", MetaTitle = "Test Meta Title", CreatedOn = new DateTime(2012, 10, 9), ModifiedOn = new DateTime(2012, 10, 15), Description = "Intro Text", PageContents = new List<PageContent> { new PageContent { Content = new BlogPostContent { Html = "Unpbulished content <p>with HTML</p>" } }, new PageContent { Content = new BlogPostContent { Html = "Test content <p>with HTML</p>", Status = ContentStatus.Published } } } }; var categoryTree = new CategoryTree { Title = "Test Category Tree" }; var category = new Category { Id = Guid.NewGuid(), Name = "Test Category", CategoryTree = categoryTree }; category.CategoryTree = categoryTree; var pageCategory = new PageCategory { Category = category, Page = blog }; categoryTree.Categories = new List<Category> { pageCategory.Category }; blog.Categories = new List<PageCategory> { pageCategory }; return new List<BlogPost> { blog }; }
public virtual Result InstallModule(string assemblyName, string toPath = null) { var mod = MoldsterModulesConfig.Modules.Where(d => d.AssemblyName == assemblyName).FirstOrDefault(); if (mod == null) { return new Result { Code = 1, Message = $"Module not registered '{assemblyName}'" } } ; mod.Categories = mod.Categories ?? new List <ModuleCategoryDTO>(); mod.Resources = mod.Resources ?? new string[0]; toPath = toPath ?? mod.InstallPath; List <string> resNames = new List <string>(); resNames.AddRange(mod.Resources); //resNames.AddRange(mod.Categories.Where(d => d.Resource != null).Select(d => d.Resource).ToList()); resNames = resNames.Distinct().ToList(); List <Resource> res = new List <Resource>(); Dictionary <string, Domain> dic = new Dictionary <string, Domain>(); List <Domain> createdDomains = new List <Domain>(); foreach (var r in resNames) { string domain = null; string resourceName = r; if (r.Contains(":")) { var spl = r.Split(':'); domain = spl[1]; resourceName = spl[0]; } var rs = unit.ResourceRepository.GetResource(resourceName, domain, createdDomains); res.Add(rs); } Utils.ClearDirectory(tmpLocation); var scrPath = Path.Combine(tmpLocation, mod.AssemblyName + ".scripts"); var scrArch = GetScriptArchive(mod.AssemblyName); var scripts = DecompressFolder(scrArch, scrPath, "*.ts"); var vwsPath = Path.Combine(tmpLocation, mod.AssemblyName + ".views"); var vwsArch = GetHtmlArchive(mod.AssemblyName); var views = DecompressFolder(vwsArch, vwsPath, "*.cshtml"); List <Tuple <string, string> > files = new List <Tuple <string, string> >(); foreach (var view in views) { string viewPath = view.Replace(vwsPath + "\\", "").Replace("\\", "/").Replace(".cshtml", ""); var conf = mod.Categories.Where(d => d.Path == viewPath).FirstOrDefault(); if (conf != null) { PageCategory cat = new PageCategory(); Resource rs = null; if (!string.IsNullOrEmpty(conf.Resource)) { rs = res.FirstOrDefault(d => d.Name == conf.Resource); } cat.BaseComponent = conf.Base; cat.ViewPath = Utils.CombineUrl(toPath, viewPath); Out.Write($"Adding template '{cat.ViewPath}'"); if (unit.PageCategoryRepository.Exist(d => d.ViewPath == cat.ViewPath)) { Out.Write("Already Exists"); } else { string domPath = cat.ViewPath.GetBeforeLast("/"); Domain dom = null; if (!dic.TryGetValue(domPath, out dom)) { dom = unit.DomainRepository.GetOrCreatePath(domPath, ref createdDomains); dic[domPath] = dom; } unit.PageCategoryRepository.Add(cat, dom, rs); WriteSuccess(); } Out.WriteLine(); } string htmlPath = Path.Combine(paths.ConfigRoot, "Views", toPath, viewPath + ".cshtml"); files.Add(new Tuple <string, string>(view, htmlPath)); } foreach (var s in scripts) { string scriptName = s.Replace(scrPath + "\\", ""); string scriptPath = Path.Combine(paths.UIRoot, "Core", paths.CoreAppName, toPath, scriptName); files.Add(new Tuple <string, string>(s, scriptPath)); } var resp = unit.SaveChanges(); if (resp.IsSuccess) { Out.WriteLine("Module Added to Database [Affected : " + resp.AffectedRows + "]"); foreach (var f in files) { WriteFileOperation("Adding", Path.GetFileName(f.Item2), false); if (File.Exists(f.Item2)) { GotoColumn(SuccessCol); Out.Write("Already Exists"); } else { Utils.CreateFolderForFile(f.Item2); File.Move(f.Item1, f.Item2); WriteSuccess(); } Out.WriteLine(); } } Utils.ClearDirectory(tmpLocation); return(resp); } string[] DecompressFolder(byte[] zipFile, string arch, string pattern) { Utils.CreateFolderForFile(arch); File.WriteAllBytes(arch + ".zip", zipFile); FileUtils.DecompressDirectory(arch + ".zip", arch); return(Directory.GetFiles(arch, pattern, SearchOption.AllDirectories)); } byte[] CompressFolder(string fold, string name) { var arch = Path.Combine(tmpLocation, name) + ".zip"; FileUtils.CompressDirectory(fold, arch); var byts = File.ReadAllBytes(arch); File.Delete(arch); return(byts); }
/// <summary> /// 生成栏目页 /// </summary> /// <param name="Ids"></param> public void MakeCategoryPage(string Ids) { int iSuccessCount = 0; //成功条数 int iFalseCount = 0; //失败条数 var allCategoryList = mangae.db.TG_Category.OrderBy(m => m.ID).AsQueryable().ToList(); //所有栏目数据 var allTempletList = mangae.db.TG_Templet.OrderBy(m => m.ID).AsQueryable().ToList(); //所有模板数据 var listIds = Ids.Split(',').Select(m => Convert.ToInt32(m)).ToList(); var CategoryList = allCategoryList.Where(m => listIds.Contains(m.ID)).ToList(); //要生成栏目数据 //循环生成栏目页 foreach (var category in CategoryList) { var templet = allTempletList.Where(m => m.ID == category.iTemplateId).SingleOrDefault(); if (templet != null) { //模板存在 if (category.bIsRedirect != true) { //跳转栏目不生成页面 //判断栏目是或否内容栏目 if (category.bIsContentCategory != null) {//内容栏目直接生成页面 string templetHtmlString = RazorHelper.ParseString(templet.sTempletEnName, category); if (!string.IsNullOrEmpty(templetHtmlString)) { string sHtmlPath = FuncHelper.Instance.GetHtmlPath(category, allCategoryList); if (RazorHelper.MakeHtml(sHtmlPath, category.sEnName, templetHtmlString)) { iSuccessCount++; } else { iFalseCount++; } } else { iFalseCount++; } } else { //文章分页栏目 //获取栏目下面所有文章数量 var articleTotalCount = mangae.db.TG_Article. Where(m => m.iCategoryId == category.ID && m.bIsDeleted == false && m.bIsRelease == true).Count(); int categoryHtmlCount = (int)Math.Ceiling((double)articleTotalCount / (double)20); //生成栏目页的个数 var pageCategory = new PageCategory(); pageCategory.Category = category; pageCategory.Rows = categoryHtmlCount;//总页数 for (var i = 1; i <= categoryHtmlCount; i++) { pageCategory.Page = i; string templetHtmlString = RazorHelper.ParseString(templet.sTempletEnName, pageCategory); if (!string.IsNullOrEmpty(templetHtmlString)) { string sHtmlPath = FuncHelper.Instance.GetHtmlPath(category, allCategoryList); string sFileName = string.Format("{0}_{1}", category.sEnName, i); if (RazorHelper.MakeHtml(sHtmlPath, sFileName, templetHtmlString)) { iSuccessCount++; } else { iFalseCount++; } } else { iFalseCount++; } } } } } } result.success = true; result.data = new { iSuccessCount = iSuccessCount, iFalseCount = iFalseCount, iTatolCount = iSuccessCount + iFalseCount }; }
private PageCategory validate( PageCategory data ) { int orderid = ctx.PostInt( "OrderId" ); int parentid = ctx.PostInt( "ParentId" ); String name = ctx.Post( "Name" ); String description = ctx.Post( "Description" ); String logo = ctx.Post( "Logo" ); if (strUtil.IsNullOrEmpty( name )) errors.Add( lang( "exName" ) ); data.OrderId = orderid; data.ParentId = parentid; data.Name = name; data.Description = description; data.Logo = logo; data.OpenStatus = ctx.PostInt( "OpenStatus" ); data.EditorIds = getEditorIds( data ); data.IsShowWiki = ctx.PostIsCheck( "IsShowWiki" ); return data; }
/// <summary> /// Loads the page which can be applied as a child to the main view. /// </summary> public void ApplyPage(PageCategory page) { StoreOldScene(); LoadNewScene(page); }
public void MakeArticleHtml(TG_Article article) { try { //获取文章所属栏目 var category = mangae.db.TG_Category.Find(article.iCategoryId); var allCategoryList = mangae.db.TG_Category.OrderBy(m => m.ID).AsQueryable().ToList(); TG_Templet templetArticle; //生成文章的模板 if (article.iTemplateId != 0) { //存在独立文章模板 templetArticle = mangae.db.TG_Templet.Find(article.iTemplateId); } else { //获取栏目的文章模板ID templetArticle = mangae.db.TG_Templet.Find(category.iArticleTemplateId); } if (templetArticle != null) { string templetHtmlString = RazorHelper.ParseString(templetArticle.sTempletEnName, article); string ArticlePath = category.sEnName + FuncHelper.Instance.GetHtmlPath(category, allCategoryList); RazorHelper.MakeHtml(ArticlePath, article.ID.ToString(), templetHtmlString); } //生成文章页栏目 if (category.bIsContentCategory == null && category.bIsRedirect == null) {//文章栏目 var category_templet = mangae.db.TG_Templet.Where(m => m.ID == category.iTemplateId).SingleOrDefault(); //文章分页栏目 //获取栏目下面所有文章数量 var articleTotalCount = mangae.db.TG_Article. Where(m => m.iCategoryId == category.ID && m.bIsDeleted == false && m.bIsRelease == true).Count(); int categoryHtmlCount = (int)Math.Ceiling((double)articleTotalCount / (double)20); //生成栏目页的个数 var pageCategory = new PageCategory(); pageCategory.Category = category; pageCategory.Rows = categoryHtmlCount;//总页数 for (var i = 1; i <= categoryHtmlCount; i++) { pageCategory.Page = i; string templetHtmlString = RazorHelper.ParseString(category_templet.sTempletEnName, pageCategory); if (!string.IsNullOrEmpty(templetHtmlString)) { string sHtmlPath = FuncHelper.Instance.GetHtmlPath(category, allCategoryList); string sFileName = string.Format("{0}_{1}", category.sEnName, i); RazorHelper.MakeHtml(sHtmlPath, sFileName, templetHtmlString); } } } //生成首页 var index_category = FuncHelper.Instance.GetCategoryByEnName("index"); var index_templet = mangae.db.TG_Templet.Where(m => m.ID == index_category.iTemplateId).SingleOrDefault(); if (index_templet != null) {//模板存在 string templetHtmlString = RazorHelper.ParseString(index_templet.sTempletEnName, index_category); string sHtmlPath = FuncHelper.Instance.GetHtmlPath(index_category, allCategoryList); RazorHelper.MakeHtml(sHtmlPath, index_category.sEnName, templetHtmlString); } } finally { } }
private string getUserList( PageCategory data ) { if (strUtil.IsNullOrEmpty( data.EditorIds )) return ""; List<User> users = userService.GetByIds( data.EditorIds ); if (users.Count == 0) return ""; String ulist = ""; int[] arrIds = cvt.ToIntArray( data.EditorIds ); for (int i = 0; i < arrIds.Length; i++) { String userName = getUserName( arrIds[i], users ); if (strUtil.IsNullOrEmpty( userName )) continue; ulist += userName; if (i < arrIds.Length - 1) ulist += ", "; } return ulist.Trim().TrimEnd( ',' ); }
private void createPage( String title, PageCategory category, Boolean isFooter ) { Page page = new Page(); page.Creator = new User( 1 ); page.OwnerType = typeof( Site ).FullName; page.OwnerUrl = "/"; page.Title = title; page.Content = title; page.Category = category; page.EditReason = "创建页面"; pageService.Insert( page ); // FooterMenu if (isFooter == false) return; FooterMenu fm = new FooterMenu(); fm.Name = page.Name; fm.Link = Link.To( Site.Instance, new Common.PageController().Show, page.Id ); fm.insert(); }
/// <summary> /// Requests a change of the current page to the new page. /// Used to provide the possibility for the user to save or cancel the action. /// </summary> public virtual void OnUserRequestsChange(IMainNode mainNode, PageCategory nextPage) { mainNode.ChangePageTo(nextPage); }
public static DataTable GetList(int PageIndex, int PageSize, PageCategory pageCate, out int RecordCount) { return(PageDataAccess.GetList(PageIndex, PageSize, pageCate, out RecordCount)); }
public static DataTable GetList(int PageIndex, int PageSize, PageCategory pageCate, out int RecordCount) { return PageDataAccess.GetList(PageIndex, PageSize, pageCate, out RecordCount); }
/// <summary> /// Requests a change of the current page to the new page. /// Used to provide the possibility for the user to save or cancel the action. /// </summary> public void UserRequestsChangeTo(PageCategory page) { _lessonController.UserRequestsChangeTo(page); }
private PageCategory createCategory( String name ) { PageCategory category = new PageCategory(); category.Creator = new User( 1 ); category.OwnerType = typeof( Site ).FullName; category.OwnerUrl = "/"; category.Name = name; db.insert( category ); return category; }
private void CloneCategories(PageCategory category, PageProperties newPage) { var newPageCategory = new PageCategory { Page = newPage, Category = category.Category }; repository.Save(newPageCategory); }
private string getEditorIds( PageCategory data ) { if (data.OpenStatus != OpenStatus.Editor) return ""; String userList = ctx.Post( "userList" ); if (strUtil.IsNullOrEmpty( userList )) return ""; String[] arrUser = userList.Split( new char[] { ',', '��' } ); String ids = ""; for (int i = 0; i < arrUser.Length; i++) { User u = userService.IsExist( arrUser[i].Trim() ); if (u == null) continue; ids += u.Id + ", "; } return ids.Trim().TrimEnd( ',' ); }
public void CreatePageCategory(PageCategory category) { _databaseContext.PageCategories.Add(category); _databaseContext.SaveChanges(); }