public PageContentInfo GetForumThreadsInfo(List <int> forumIds, int page = 1, int threadsPerPage = 20) { int offset = (page - 1) * threadsPerPage; var info = new PageContentInfo(page, threadsPerPage); string sqlThreadIds = $@" SELECT t.threadid FROM thread t WHERE t.forumid IN @forumIds AND t.visible = 1 ORDER BY t.lastpost DESC LIMIT @offset, @threadsPerPage"; var sqlThreadArgs = new { forumIds, offset, threadsPerPage }; info.ContentIds = db.Query <int>(sqlThreadIds, sqlThreadArgs).ToList(); var totalPagesArgs = new { forumIds, threadsPerPage }; string sqlTotalPages = @" SELECT CEIL(COUNT(*) / @threadsPerPage) AS pages FROM thread WHERE visible = 1 AND forumId IN @forumIds"; info.TotalPages = db.QueryFirstOrDefault <int>(sqlTotalPages, totalPagesArgs); return(info); }
public PageContentInfo GetPrivateMessagesConversationsInfo(int userId, int page = 1, int conversationsPerPage = 10) { int offset = (page - 1) * conversationsPerPage; var info = new PageContentInfo(page, conversationsPerPage); // pm.parentpmid = 0 not added since it filters PMs send to multiple users. Filtering the recipient is enough to avoid fetching single pms instead of conversations // We filter for userid AND fromuserid to fetch both send and received messages => send messages are displayed in the ordering and timestamp // ToDo: By filtering to folderid != -1, we dont get send messages without reply (yet). Consider including them (requires checking the folder on displaying) string fromWhereSql = @"FROM pm, pmtext AS txt WHERE pm.pmtextid = txt.pmtextid AND (pm.userid = @userId OR txt.fromuserid = @userId) AND pm.folderid != -1"; var args = new { userId, offset, conversationsPerPage }; // Filtering by paremtpmid = 0 would exclude PNs that were written by the other user without reply. // So we need to group by the parentpmid. But we only can do this if its not the first PM (parentpmid = 0) to avoid grouping with other first messages. // MIN(pm.pmid) make sure that we get the id from the FIRST message with the original subject (no "AW: " prefix) while still sorting the messages by their write time. // But since it shows the last message, it seems okay to fetch the reply message instead of the first pm string pmIds = $@" SELECT pm.pmid {fromWhereSql} GROUP BY IF(pm.parentpmid != 0, pm.parentpmid, pm.pmid) ORDER BY txt.dateline DESC LIMIT @offset, @conversationsPerPage"; info.ContentIds = db.Query <int>(pmIds, args) .ToList(); string sqlTotalPages = $@" SELECT CEIL(COUNT(*)/ @conversationsPerPage) AS pages {fromWhereSql}"; info.TotalPages = db.QueryFirstOrDefault <int>(sqlTotalPages, args); return(info); }
public ActionResult Create(PageItemContentCreateOrEditViewModel vmObj) { var parent = db.Pages.Where(x => x.Id == vmObj.ParentId).FirstOrDefault(); if (parent == null) { return(new EmptyResult()); } return(CreateRelatedObjectUsingViewModel <Page, PageContent>(parent.Id, vmObj, (p) => { //Convert the ViewModel to DB Object (Model) //var translation = db.ContentTranslations.Where(x => x.Id == vmObj.ContentTranslationId).FirstOrDefault(); var pageItemContentData = new PageItemContentData() { Title = vmObj.Title, Body = vmObj.BodyHtml, //Keywords = vmObj.Keywords, //Translation = translation TranslationId = db.BlogWebsiteSettings.FirstOrDefault().DefaultLanguageId }; db.PageItemContentDatas.Add(pageItemContentData); var pageContentInfo = new PageContentInfo() { HasRSS = false,// vmObj.HasRSS, IsDraft = vmObj.IsDraft, IsPublished = vmObj.IsPublished, PublishedBy = vmObj.PublishedBy, PublishedOn = vmObj.PublishedOn, ActiveFrom = vmObj.ActiveFrom, ActiveTo = vmObj.ActiveTo }; db.PageContentInfos.Add(pageContentInfo); var pageItemContent = new PageItemContent() { Id = vmObj.Id, //Title = vmObj.Title, //Body = vmObj.BodyHtml, //Keywords = vmObj.Keywords, //Description = vmObj.Description, PageContentInfo = pageContentInfo }; pageItemContent.ContentData.Add(pageItemContentData); db.PageItemContents.Add(pageItemContent); var pageContent = new PageContent() { PageItemContent = pageItemContent, //ImageContent = null, //Index = vmObj.Index, //ViewName = vmObj.ViewName, ViewTemplateId = vmObj.ViewTemplateId, PageId = vmObj.ParentId, PageContentType = db.PageContentTypes.Where(x => x.Name.Equals("PageItem")).FirstOrDefault() }; db.PageContents.Add(pageContent); return pageContent; })); }
public List <VBLightForumThread> GetForumThreads(PageContentInfo info) { var param = new { info.ContentIds }; var builder = GetForumThreadsQueryBuilder(); builder.Where("threadid IN @ContentIds") .OrderBy("thread.lastpost DESC"); return(BuildForumThreadsQuery(builder, param)); }
public void Result(bool success, PageContentInfo result) { this.longLoadWarning = null; this.Completed = true; if (this.handler != null) { this.handler(success, result); } this.handler = null; }
/// <summary> /// Fetches PM conversations (without the replys) for display in the inbox /// </summary> public List <VBLightPrivateMessage> GetPrivateMessagesConversations(int userId, PageContentInfo pageInfo, int textPreviewWords = 0) { string contentIdsRaw = string.Join(",", pageInfo.ContentIds); // Logically we dont need any count because we have not more than RowsPerPage ids. Its just passed to keep GetPrivateMessages flexible without being over complicated. return(GetPrivateMessages(userId, $"AND pm.pmid IN({contentIdsRaw})", readState: null, count: pageInfo.RowsPerPage, textPreviewWords: textPreviewWords)); }
private void AddPage(BootstrapContext db, string pageName, bool isBlogItem = true, bool isRssFeed = false) { if (db.Pages.Where(x => x.Name.ToLower().Equals(pageName)).FirstOrDefault() == null) { var permaLink = new Permalink() { Name = pageName, Type = null, ChangeEvent = new ChangeEvent() { CreatedByUserIdCode = "bha", CreatedOn = DateTime.Now, UpdatedByUserIdCode = "bha", UpdatedOn = DateTime.Now } }; db.Permalinks.Add(permaLink); Page page = new Page() { Name = pageName, Title = pageName, Permalink = permaLink, IncludeInMenu = false, IsDraft = false, IsPublished = true, IsRssFeed = false, ChangeEvent = new ChangeEvent() { CreatedByUserIdCode = "bha", CreatedOn = DateTime.Now, UpdatedByUserIdCode = "bha", UpdatedOn = DateTime.Now } }; PageContent pageContent = null; if (!isRssFeed && isBlogItem) { var contentData = new BlogItemContentData() { Title = pageName, Description = "", Body = pageName, Excerpt = "", Translation = db.ContentTranslations.Where(x => x.Language.ToLower().Equals("fo")).FirstOrDefault() }; db.BlogItemContentDatas.Add(contentData); var pageContentInfo = new PageContentInfo() { HasRSS = true, IsDraft = false, IsPublished = true, PublishedBy = "bha", PublishedOn = DateTime.Now }; db.PageContentInfos.Add(pageContentInfo); var blogItemContent = new BlogItemContent() { PageContentInfo = pageContentInfo }; blogItemContent.ContentData.Add(contentData); db.BlogItemContents.Add(blogItemContent); pageContent = new PageContent() { ViewTemplate = isBlogItem ? db.ViewTemplates.Where(x => x.Name.ToLower().Equals("_BlogItem")).FirstOrDefault() : null, Page = page, PageContentType = db.PageContentTypes.Where(x => x.Name.Equals("BlogItem")).FirstOrDefault(), ChangeEvent = new ChangeEvent() { CreatedByUserIdCode = "bha", CreatedOn = DateTime.Now, UpdatedByUserIdCode = "bha", UpdatedOn = DateTime.Now } }; if (isBlogItem) { pageContent.BlogItemContent = blogItemContent; } db.PageContents.Add(pageContent); } if (isRssFeed && !isBlogItem) { page.IsRssFeed = true; pageContent = new PageContent() { Page = page, PageContentType = db.PageContentTypes.Where(x => x.Name.Equals("BlogList")).FirstOrDefault(), ChangeEvent = new ChangeEvent() { CreatedByUserIdCode = "bha", CreatedOn = DateTime.Now, UpdatedByUserIdCode = "bha", UpdatedOn = DateTime.Now } }; db.PageContents.Add(pageContent); } //if (isBlogItem) //{ // page.Content.Add(pageContent); //} db.Pages.Add(page); db.SaveChanges(); } }
static void CreateTestData_PageContentInfo() { Repository <PageContentInfo> repository = new Repository <PageContentInfo>(); int idx = 0; PageContentInfo pageContentInfo = new PageContentInfo(); var ser = GetNavigationInfo("关于我们"); pageContentInfo = new PageContentInfo() { NavigationID = ser.Id, Title = "公司介绍", Content = @"<p style=\""text - indent:2em\""> <strong> Banana科技股份公司 </strong> 坐落于美丽的绿城南宁,是广西首家致力于发展“互联网 +”水果行业的科技企业,由广西规模最大的国家甲级水果设计单位——<a href = \""http://www.baidu.com\\"" target = \""_blank\""> 水果集团 </a> 牵头组建。集团是由19家专业公司和机构共同组成,在工程设计咨询、工程总承包、投资与房地产开发、智力运动与文化产业领域开展经营,致力于成为卓越的城乡建设领域综合服务提供商。 </p> <p style = \""text -indent:2em\""> Banana公司依托集团在设计咨询、工程总包、投资与房地产开发等领域的深厚积累,利用互联网、IT技术打造行业信息服务新模式,专注于建筑行业产业链上下游的互联互通,推动产业的跨界融合创新,创造建筑行业新生态圈。 公司现诚邀有识青年、互联网爱好者、IT精英加盟,我们将为您提供广阔的发展平台、富有竞争力的薪酬福利及完善的培训体系。带上你的学识、创意和激情加入Banana,我们一起携手共进、共创“专筑”未来! </p>", ImgUrl = "/images/bg-img/nanguoyiyuan.jpg", IconCode = "", IsDisable = EYesOrNo.No, Sort = idx++, UpdateTime = DateTime.Now, IsHomePageShows = EYesOrNo.Yes, SectionName = "关于我们", Subhead = "About us", ContentType = EContentType.ImageText }; repository.Insert(pageContentInfo); pageContentInfo = new PageContentInfo() { NavigationID = ser.Id, Title = "公司团队", Content = @"<p style=\""text - indent:2em\""> 这是一群充满热心与朝气的年轻人。 这是一群充满热心与朝气的年轻人。 这是一群充满热心与朝气的年轻人。 这是一群充满热心与朝气的年轻人。 这是一群充满热心与朝气的年轻人。 这是一群充满热心与朝气的年轻人。 这是一群充满热心与朝气的年轻人。 这是一群充满热心与朝气的年轻人。 这是一群充满热心与朝气的年轻人。 这是一群充满热心与朝气的年轻人。 这是一群充满热心与朝气的年轻人。 这是一群充满热心与朝气的年轻人。 </ p> <p style = \""text -indent:2em\""> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAA </ p> ", ImgUrl = "/images/bg-img/team.jpg", IconCode = "", IsDisable = EYesOrNo.No, Sort = idx++, UpdateTime = DateTime.Now, IsHomePageShows = EYesOrNo.No, ContentType = EContentType.ImageText }; repository.Insert(pageContentInfo); ser = GetNavigationInfo("产品服务"); pageContentInfo = new PageContentInfo() { NavigationID = ser.Id, Title = "网站建设", Content = @"<p> Life is not easy for any of us.We must work, and above all we must believe in ourselves.We must believe that each one of us is able to do something well, and that, when we discover what this something is, we must work hard at it until we succeed </p>", ImgUrl = "/images/bg-img/5.png", IconCode = "fa fa-code", IsDisable = EYesOrNo.No, Sort = idx++, UpdateTime = DateTime.Now, IsHomePageShows = EYesOrNo.Yes, SectionName = "产品服务", Subhead = "Service", ContentType = EContentType.IconList }; repository.Insert(pageContentInfo); pageContentInfo = new PageContentInfo() { NavigationID = ser.Id, Title = "微信开发", Content = @"<p> Life is not easy for any of us.We must work, and above all we must believe in ourselves.We must believe that each one of us is able to do something well, and that, when we discover what this something is, we must work hard at it until we succeed </p>", ImgUrl = "/images/bg-img/5.png", IconCode = "fa fa-wechat", IsDisable = EYesOrNo.No, Sort = idx++, UpdateTime = DateTime.Now, IsHomePageShows = EYesOrNo.Yes, SectionName = "产品服务", Subhead = "Service", ContentType = EContentType.IconList }; repository.Insert(pageContentInfo); pageContentInfo = new PageContentInfo() { NavigationID = ser.Id, Title = "软件开发", Content = @"<p> Life is not easy for any of us.We must work, and above all we must believe in ourselves.We must believe that each one of us is able to do something well, and that, when we discover what this something is, we must work hard at it until we succeed </p>", ImgUrl = "/images/bg-img/5.png", IconCode = "fa fa-connectdevelop", IsDisable = EYesOrNo.No, Sort = idx++, UpdateTime = DateTime.Now, IsHomePageShows = EYesOrNo.Yes, SectionName = "产品服务", Subhead = "Service", ContentType = EContentType.IconList }; repository.Insert(pageContentInfo); pageContentInfo = new PageContentInfo() { NavigationID = ser.Id, Title = "平面设计 / 字体设计", Content = @"<p> Life is not easy for any of us.We must work, and above all we must believe in ourselves.We must believe that each one of us is able to do something well, and that, when we discover what this something is, we must work hard at it until we succeed </p>", ImgUrl = "/images/bg-img/5.png", IconCode = "fa fa-font", IsDisable = EYesOrNo.No, Sort = idx++, UpdateTime = DateTime.Now, IsHomePageShows = EYesOrNo.Yes, SectionName = "产品服务", Subhead = "Service", ContentType = EContentType.IconList }; repository.Insert(pageContentInfo); ser = GetNavigationInfo("测试分页"); idx = 1; for (; idx < 100;) { pageContentInfo = new PageContentInfo() { NavigationID = ser.Id, Title = "分页标题————————:" + idx, Content = info(), ImgUrl = "/images/bg-img/5.png", IconCode = "fa fa-code", IsDisable = EYesOrNo.No, Sort = idx++, UpdateTime = DateTime.Now, IsHomePageShows = EYesOrNo.No, ContentType = EContentType.PageList, CreateTime = DateTime.Now }; repository.Insert(pageContentInfo); } ser = GetNavigationInfo("测试图文列表"); idx = 1; for (; idx < 5;) { pageContentInfo = new PageContentInfo() { NavigationID = ser.Id, Title = "测试图文列表:" + idx, Content = @"<p> Life is not easy for any of us.We must work, and above all we must believe in ourselves.We must believe that each one of us is able to do something well, and that, when we discover what this something is, we must work hard at it until we succeed </p>", ImgUrl = "/images/bg-img/5.png", IconCode = "fa fa-code", IsDisable = EYesOrNo.No, Sort = idx++, UpdateTime = DateTime.Now, IsHomePageShows = EYesOrNo.Yes, SectionName = "其他服务", Subhead = "Other", ContentType = EContentType.ImageText, CreateTime = DateTime.Now }; repository.Insert(pageContentInfo); } }
private void OnPageContentLoaded(bool success, PageContentInfo pageContent) { if (success) { this.PrepareForContnentLoad(); this.HideConnectionError(); this.waitingForPageResponse = false; this.scrolledToBottom = true; bool flag = false; float num = 0f; int num2 = 0; if (pageContent.Featured != null && !pageContent.Featured.IsEmpty()) { if (GeneralSettings.IsOldDesign) { this.featured.gameObject.SetActive(true); this.featured.LoadContent(pageContent.Featured); num2 = this.featured.SectionHeight; } else { this.featuredSection.gameObject.SetActive(true); this.featuredSection.LoadContent(pageContent.Featured); num2 = this.featuredSection.SectionHeight; } this.scroll.AddTopOffset(num2); num += (float)num2; flag = true; } if (pageContent.CategoryInfos != null && pageContent.CategoryInfos.Count > 0) { if (this.isOldDesign) { this.categoriesFilter.Compose(pageContent.CategoryInfos, SelectPage.FilterCompleted); this.categoriesMenu.gameObject.SetActive(true); if (flag) { this.categoriesMenu.AddTopOffset(num2); } this.scroll.AddTopOffset(this.categoriesMenu.SectionHeight); this.scroll.SetScrollTitleOffset(this.categoriesMenu.SectionHeight); num += (float)this.categoriesMenu.SectionHeight; } else { this.categoryBar.gameObject.SetActive(true); this.categoryBar.Compose(pageContent.CategoryInfos, SelectPage.FilterCompleted); if (flag) { this.categoryBar.AddTopOffset(num2); } this.scroll.AddTopOffset(this.categoryBar.SectionHeight); this.scroll.SetScrollTitleOffset(this.categoryBar.SectionHeight); num += (float)this.categoryBar.SectionHeight; } } List <PictureData> pics = pageContent.Pics; if (pics != null && pics.Count > 0) { this.scroll.LoadContent(pics); int num3 = SharedData.Instance.CalculateLibCompletePercent(); if (num3 != -1) { AnalyticsManager.UpdateUserLibProgressProperty(num3); } } this.OpenCategory(SelectPage.LastCategory, true); if (pageContent.UpdateDialog != null && Gameboard.pictureData == null && (pageContent.UpdateDialog.ver == 0 || pageContent.UpdateDialog.ver > GeneralSettings.UpdateDialogVersion)) { GeneralSettings.UpdateDialogVersion = pageContent.UpdateDialog.ver; AppState.SystemUtilsPause(); SystemUtils.ShowUpdateDialog(pageContent.UpdateDialog); } RectTransform rectTransform = (RectTransform)base.transform; this.fbBackgroundLabel.anchoredPosition = new Vector2(0f, -rectTransform.rect.height / 2f - num / 2f); if (!GeneralSettings.IsOldDesign) { this.scroll.GetComponent <ScrollConstraints>().Init(); } if (pageContent.BonusCategoryConfig != null && pageContent.BonusCategoryConfig.links != null) { for (int i = 0; i < pageContent.BonusCategoryConfig.links.Count; i++) { if (pageContent.BonusCategoryConfig.links[i].place != null) { if (pageContent.BonusCategoryConfig.links[i].place.Equals("background")) { this.fbPageBackground.Init(pageContent.BonusCategoryConfig.links[i].scheme, pageContent.BonusCategoryConfig.links[i].url); } else if (pageContent.BonusCategoryConfig.links[i].place.Equals("categoryBar")) { this.fbPageCatBar.Init(pageContent.BonusCategoryConfig.links[i].scheme, pageContent.BonusCategoryConfig.links[i].url); } } } } if (pageContent.News != null) { this.newsPage.LoadContent(pageContent.News); } base.StartCoroutine(base.DelayAction(5, 0f, new Action(this.ContentLoadComplete))); } else { this.ShowConnectionError(); } this.pageContentTask = null; this.loadIndicator.SetActive(false); if (this.ContentLoaded != null) { this.ContentLoaded(); } }
public ActionResult Create(BlogItemContentCreateOrEditViewModel vmObj) { //var parent = db.Pages.Where(x => x.Id == vmObj.ParentId).FirstOrDefault(); //if (parent == null) //{ // return new EmptyResult(); //} //return CreateRelatedObjectUsingViewModel<Page, PageContent>(parent.Id, vmObj, (p) => //{ // //Convert the ViewModel to DB Object (Model) // var pageContent = new PageContent() // { // Index = vmObj.Index, // //ViewName = vmObj.ViewName, // ViewTemplateId = vmObj.ViewTemplateId, // PageId = vmObj.ParentId, // PageContentType = db.PageContentTypes.Where(x => x.Name.Equals("BlogList")).FirstOrDefault() // }; // db.PageContents.Add(pageContent); // return pageContent; //}); var parent = db.Pages.Where(x => x.Id == vmObj.ParentId).FirstOrDefault(); if (parent == null) { return(new EmptyResult()); } return(CreateRelatedObjectUsingViewModel <Page, PageContent>(parent.Id, vmObj, (p) => { //Convert the ViewModel to DB Object (Model) //var translation = db.ContentTranslations.Where(x => x.Id == vmObj.ContentTranslationId).FirstOrDefault(); var blogItemContentData = new BlogItemContentData() { Title = vmObj.Title, Body = vmObj.Body,// vmObj.BodyHtml, Excerpt = vmObj.Excerpt, //Keywords = vmObj.Keywords, Description = vmObj.Description, TranslationId = db.BlogWebsiteSettings.FirstOrDefault().DefaultLanguageId //Translation = translation }; db.BlogItemContentDatas.Add(blogItemContentData); var pageContentInfo = new PageContentInfo() { HasRSS = vmObj.HasRSS, IsDraft = vmObj.IsDraft, IsPublished = vmObj.IsPublished, PublishedBy = vmObj.PublishedBy, PublishedOn = vmObj.PublishedOn, ActiveFrom = vmObj.ActiveFrom, ActiveTo = vmObj.ActiveTo }; db.PageContentInfos.Add(pageContentInfo); var blogItemContent = new BlogItemContent() { Id = vmObj.Id, //Title = vmObj.Title, //Body = vmObj.BodyHtml, //Excerpt = vmObj.Excerpt, ////Keywords = vmObj.Keywords, //Description = vmObj.Description, PageContentInfo = pageContentInfo }; blogItemContent.ContentData.Add(blogItemContentData); db.BlogItemContents.Add(blogItemContent); var pageContent = new PageContent() { BlogItemContent = blogItemContent, Index = vmObj.Index, //ViewName = vmObj.ViewName, ViewTemplateId = vmObj.ViewTemplateId, PageId = vmObj.ParentId, PageContentType = db.PageContentTypes.Where(x => x.Name.Equals("BlogItem")).FirstOrDefault() }; var index = 0; //var files = AddFiles(vmObj.Files); //foreach (var file in files) //{ // db.Files.Add(file); // var imageInfo = new ImageInfo() // { // Description = "", // Height = -1, // Width = -1, // ChangeEvent = CreateChangeEvent() // }; // using (FileStream fs = new FileStream(Server.MapPath(Path.Combine("~/SimpleCMS/Data/Images", file.Name)), FileMode.Open, FileAccess.Read)) // { // using (Image img = Image.FromStream(stream: fs, // useEmbeddedColorManagement: false, // validateImageData: false)) // { // float width = img.PhysicalDimension.Width; // float height = img.PhysicalDimension.Height; // //float hresolution = img.HorizontalResolution; // //float vresolution = img.VerticalResolution; // imageInfo.Width = (int)width; // imageInfo.Height = (int)height; // } // fs.Close(); // } // db.Images.Add(imageInfo); // var pageContentFile = new PageContentFile() // { // PageContent = pageContent, // ImageInfo = imageInfo, // Index = index, // ChangeEvent = CreateChangeEvent() // }; // db.PageContentFiles.Add(pageContentFile); // pageContent.BlogItemContent.Files.Add(pageContentFile); // index++; //} //db.PageContents.Add(pageContent); var images = base.SaveImages(vmObj.Files); if (images != null && images.Count > 0) { foreach (var imageInfo in images) { var pageContentFile = new PageContentFile() { ImageInfo = imageInfo, Index = index, PageContent = pageContent, ChangeEvent = CreateChangeEvent() }; pageContent.BlogItemContent.Files.Add(pageContentFile); db.PageContents.Add(pageContent); //db.SaveChanges(); index++; } } return pageContent; })); }