protected void lnkFileName_Click(object sender, EventArgs e) { string documentId = Request["id"]; //check for id in URL if (!string.IsNullOrEmpty(documentId)) { Article article = DocoManager.GetArticle(documentId); AuditManager.Audit(Page.User.Identity.Name, article.Id, AuditRecord.AuditAction.Viewed); article = DocoManager.GetArticle(documentId); SetTrafficLight(article); string navigateUrl = string.Format( CultureInfo.InvariantCulture, Resource.NewObjectPath, "Files", article.Category.Id); if (!string.IsNullOrEmpty(article.FileName)) { navigateUrl = string.Format( CultureInfo.InvariantCulture, Resource.DocoFilesLoc + Resource.FileOpen, UrlEncoding.Encode(Path.Combine(navigateUrl, article.FileName))); navigateUrl = navigateUrl.Insert(navigateUrl.IndexOf("&"), "&aid=" + article.Id); // go to that url Page.Response.Redirect(navigateUrl); } } }
protected static void SaveDraft(string ChaptId, string Content, string chapName) { try { // if (IsNameChanged) // { ChapterVersion cv = DocoManager.GetAllChapterVersion().Where(x => x.Id.Equals(ChaptId)).First <ChapterVersion>(); if (chapName != cv.Name) { cv.Name = chapName; DocoManager.UpdateChapterVersion(cv); } // IsNameChanged = false; // } Draft draft = new Draft(); draft.VersionId = ChaptId; draft.Content = Content; draft.SaveDate = DateTime.Now; draft = BusiBlocks.DocoBlock.DocoManager.UpsertDraft(draft); //divDraftsList.InnerHtml = BindDrafts(ChaptId); } catch (Exception ex) { //Log - unable to save current draft. throw ex; } }
protected Draft SaveDraft(string ChaptId, string Content) { try { //if (IsNameChanged) // { ChapterVersion cv = DocoManager.GetAllChapterVersion().Where(x => x.Id.Equals(ChaptId)).First <ChapterVersion>(); if (txtBoxChapterName.Text != cv.Name) { cv.Name = txtBoxChapterName.Text; DocoManager.UpdateChapterVersion(cv); } //IsNameChanged = false; //} Draft draft = new Draft(); draft.VersionId = ChaptId; draft.Content = Content; draft.SaveDate = DateTime.Now; draft = BusiBlocks.DocoBlock.DocoManager.UpsertDraft(draft); //divDraftsList.InnerHtml = BindDrafts(ChaptId); //Reconstruct Menu; CreateSubChapterMenu(Content); return(draft); } catch (Exception ex) { //Log - unable to save current draft. throw ex; } }
protected void btnUpload_Click(object sender, EventArgs e) { Article article = DocoManager.GetArticleByName(ArticleName, true); article.FileName = UploadFile(article.Category.Id); DocoManager.UpdateArticle(article, false); }
protected string GetViewArticleUrl(string id) { Article article = DocoManager.GetArticle(id); string root = Server.MapPath(Path.Combine("~/Doco/", System.Web.Configuration.WebConfigurationManager.AppSettings.Get(Resources.Resource.Root))); string path = string.Format( CultureInfo.InvariantCulture, Resource.NewObjectPath, root, article.Category.Id); if (!string.IsNullOrEmpty(article.FileName)) { string url = string.Format( CultureInfo.InvariantCulture, Resource.DocoFilesLoc + Resource.FileOpen, UrlEncoding.Encode(Path.Combine(path, article.FileName))); return(url); } else { return(string.Empty); } }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="nodeType"></param> /// <param name="isAdmin"></param> /// <param name="showNodeItems"></param> /// <param name="userAdminList"></param> protected void AddParentNode <T>(T nodeType, bool isAdmin, bool showNodeItems, IList <T> userAdminList, string personId) { var tempNodeType = typeof(T); string nodeText = ""; string nodeID; var t = nodeType; List <T> temp = new List <T>(); // todo the following code is dodgey. The check for a parent needs to be handled better. switch (tempNodeType.Name) { case "Category": if (tempNodeType.FullName.Contains("News")) { if ((nodeType as BusiBlocks.CommsBlock.News.Category).ParentCategory == null) { return; } nodeText = (nodeType as BusiBlocks.CommsBlock.News.Category).ParentCategory.Name; BusiBlocks.CommsBlock.News.Category x = NewsManager.GetCategoryByName(nodeText, true); t = (T)Convert.ChangeType(x, typeof(T)); } else if (tempNodeType.FullName.Contains("Doco")) { if ((nodeType as BusiBlocks.DocoBlock.Category).ParentCategory == null) { return; } nodeText = (nodeType as BusiBlocks.DocoBlock.Category).ParentCategory.DisplayName; nodeID = (nodeType as BusiBlocks.DocoBlock.Category).ParentCategory.Id; BusiBlocks.DocoBlock.Category x = DocoManager.GetCategory(nodeID); t = (T)Convert.ChangeType(x, typeof(T)); } break; case "Region": nodeText = (nodeType as Region).ParentRegion.Name; break; default: break; } if (RadTreeView1.FindNodeByText(nodeText) != null) { AddSubNode(nodeType, isAdmin, showNodeItems, userAdminList, personId); } else { //Add the parent node that does not have a parent node to a list. temp.Add(nodeType); AddParentNode(t, isAdmin, showNodeItems, userAdminList, personId); foreach (T item in temp) { AddSubNode(item, isAdmin, showNodeItems, userAdminList, personId); } } }
public void DeleteCategory(string Id) { // Need to figure out if this is a comms block category or a doco block category. if (!string.IsNullOrEmpty(Id)) { BusiBlocks.CommsBlock.News.Category news = null; try { news = NewsManager.GetCategory(Id); } catch (NewsCategoryNotFoundException) { } if (news != null) { NewsManager.DeleteCategory(news); } else { BusiBlocks.DocoBlock.Category doco = null; try { doco = DocoManager.GetCategory(Id); } catch (DocoCategoryNotFoundException) { } if (doco != null) { DocoManager.DeleteCategory(doco); } } } }
protected void btSave_Click(object sender, EventArgs e) { try { string id = Request["id"]; Category category; IList <Category> categories = GetAllViewableCategories(); //Edit if (id != null) { category = DocoManager.GetCategory(id); category.DisplayName = txtDisplayName.Text; } else //New { category = DocoManager.CreateCategory(txtDisplayName.Text); } Category parentCategory = categories[cmbParentCategory.SelectedIndex]; // The parent category can be assiged as the same category, do not allow this. // Also do not allow the root category (with parent null) to be changed. if (!parentCategory.Id.Equals(category.Id) && category.ParentCategory != null) { category.ParentCategory = categories[cmbParentCategory.SelectedIndex]; } category.Description = txtDescription.Text; DocoManager.UpdateCategory(category); IList <Access> currentAccess = AccessManager.GetItemAccess(category.Id); foreach (Access access in currentAccess) { AccessManager.RemoveAccess(access.Id); } foreach (Access a in AccessControl1.AccessList) { a.Id = null; a.ItemId = category.Id; a.ItemType = ItemType.DocoCategory; AccessManager.AddAccess(a); } ((IFeedback)this.Page.Master).QueueFeedback( BusiBlocksConstants.Blocks.Documents.LongName, "Category", Feedback.Actions.Saved, category.DisplayName ); Navigation.Admin_ManageDoco().Redirect(this); } catch (Exception ex) { throw ex; ((IFeedback)Master).SetException(GetType(), ex); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string id = Request["id"]; string parentCategoryId = Request["parentCategory"]; // Find all the categories which this user has permission to view. IList <Category> viewableCategories = GetAllViewableCategories(); cmbParentCategory.DataSource = viewableCategories; cmbParentCategory.DataTextField = "Breadcrumb"; cmbParentCategory.DataBind(); //Edit if (id != null) { Category category = DocoManager.GetCategory(id); if (category.ParentCategory == null) { cmbParentCategory.SelectedIndex = -1; } else { IEnumerable <int> index = from x in viewableCategories where x.Id.Equals(category.ParentCategory.Id) select viewableCategories.IndexOf(x); if (index.Any()) { cmbParentCategory.SelectedIndex = index.First(); } } txtDisplayName.Text = category.DisplayName; AccessControl1.CategoryId = category.Id; txtDescription.Text = category.Description; } else //New { if (!string.IsNullOrEmpty(parentCategoryId)) { // Populate the parent category combo with this category. IEnumerable <int> index = from x in viewableCategories where x.Id.Equals(parentCategoryId) select viewableCategories.IndexOf(x); if (index.Any()) { cmbParentCategory.SelectedIndex = index.First(); } } } } txtDisplayName.Focus(); }
public static bool wmCheckChapterName(string ChapName) { if (DocoManager.CheckChapterName(ArticleId, ChapName)) { return(true); } return(false); }
private void LoadList(Category category) { //Get the standard articles IList <Article> articles = DocoManager.GetArticles(category, ArticleStatus.All, false); // Add all the document instances to the list. string[] arr = articles.Select(x => x.Id).ToArray(); list.SetState(string.Join(",", arr)); }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(CategoryId)) { Category category = DocoManager.GetCategory(CategoryId); //sectionApprove.Visible = !category.AutoApprove; -- uncomment once the Acknowledge feature is available. pmm.LoadPermissionsView(category.Id, category.DisplayName); } }
private void AddArticles(BusiBlocks.DocoBlock.Category category, IList <Article> articles) { IList <Article> artls = DocoManager.GetArticles(category, ArticleStatus.All, false); foreach (Article article in artls) { articles.Add(article); } }
public static object wmGetNextChapter(string ChaptId) { List <string> chapPaginationIds = new List <string>(); chapPaginationIds.Add(DocoManager.GetPreviousChapter(ChaptId, ArticleId).Id); chapPaginationIds.Add(DocoManager.GetNextChapter(ChaptId, ArticleId).Id); return(chapPaginationIds); }
public string ChangeChapterName(string chaptId, string chapName) { var cv = DocoManager.GetAllChapterVersion().Where(x => x.Id.Equals(chaptId)).First <ChapterVersion>(); if (chapName != cv.Name) { cv.Name = chapName; DocoManager.UpdateChapterVersion(cv); } return(cv.Name); }
//Binding Chapters' sub sections to the insert link list protected void rptChapsList_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType != ListItemType.Footer || e.Item.ItemType != ListItemType.Header) { HiddenField hfChapId = (HiddenField)e.Item.FindControl("hdnChapId"); Repeater rptChapSecList = (Repeater)e.Item.FindControl("rptChapSecList"); rptChapSecList.DataSource = DocoManager.GetChapterSubSection(hfChapId.Value); rptChapSecList.DataBind(); } }
public void CreateCategoryTest() { BusiBlocksDocoProvider target = new BusiBlocksDocoProvider(); // TODO: Initialize to an appropriate value string displayName = "Unit Test Category"; // TODO: Initialize to an appropriate value Category expected = DocoManager.CreateCategory(displayName); // TODO: Initialize to an appropriate value Category actual; actual = target.CreateCategory(displayName); Assert.AreEqual(expected, actual); Assert.Inconclusive("Able to create a test category"); }
protected void Page_Load(object sender, EventArgs e) { var link = new HtmlLink(); link.Href = Navigation.Doco_CategoryRss(null).GetServerUrl(true); link.Attributes.Add("rel", "alternate"); link.Attributes.Add("type", "application/rss+xml"); link.Attributes.Add("title", "Doco news"); Header.Controls.Add(link); tree1.PopulateTreeView <Category>(DocoManager.GetViewableCategories(User.Identity.Name), false, false, string.Empty); }
public object GetSelectedItemBelow(string nodeName, string treeViewType, string treeViewName) { List <KeyValuePair <string, string> > listItems = new List <KeyValuePair <string, string> >(); switch (treeViewType) { case "Category": switch (treeViewName) { case "Doco": BusiBlocks.DocoBlock.Category cat = DocoManager.GetCategoryByName(nodeName, true); listItems.Add(new KeyValuePair <string, string>(cat.Id, cat.DisplayName)); IList <BusiBlocks.DocoBlock.Category> docoCategories = DocoManager.GetAllCategoriesBelow(cat.Id); foreach (BusiBlocks.DocoBlock.Category item in docoCategories) { listItems.Add(new KeyValuePair <string, string>(item.Id, item.DisplayName)); } break; case "News": BusiBlocks.CommsBlock.News.Category selectedNews = NewsManager.GetCategoryByName(nodeName, true); IList <BusiBlocks.CommsBlock.News.Category> news = NewsManager.GetCategories(selectedNews.Id, true); foreach (BusiBlocks.CommsBlock.News.Category newsItem in news) { listItems.Add(new KeyValuePair <string, string>(newsItem.Id, newsItem.Name)); } break; default: break; } break; case "Region": BusiBlocks.SiteLayer.Region selectedRegion = SiteManager.GetRegionByName(nodeName); if (selectedRegion != null) { listItems.Add(new KeyValuePair <string, string>(selectedRegion.Id, selectedRegion.Name)); IList <Region> regions = SiteManager.GetAllRegionsBelow(selectedRegion); foreach (Region region in regions) { listItems.Add(new KeyValuePair <string, string>(region.Id, region.Name)); } } break; default: break; } return(listItems); }
public static object wmBindDraftsList(string chapterVersionId) { try { IList <Draft> draftsList = DocoManager.GetDraftsByChapterId(chapterVersionId); return(draftsList); } catch (Exception ex) { throw ex; } }
public void Bind() { IList <BusiBlocks.DocoBlock.Category> categories = DocoManager.GetViewableCategories(Page.User.Identity.Name); List <Article> allArticles = new List <Article>(); foreach (BusiBlocks.DocoBlock.Category category in categories) { List <Article> articles = (List <Article>)DocoManager.GetArticles(category, ArticleStatus.All, false); articles.ToList().ForEach(x => allArticles.Add(x)); } RadGrid1.DataSource = allArticles; }
protected void AddCategoryClick(object sender, EventArgs e) { string categoryName = popAddCategory.Value; string categoryId = popAddCategory.ReferrerId; string categoryTypeName = string.Empty; // Need to figure out if this is a comms block category or a doco block category. if (!string.IsNullOrEmpty(categoryId)) { BusiBlocks.CommsBlock.News.Category news = null; try { news = NewsManager.GetCategory(categoryId); categoryTypeName = news.GetType().Name; } catch (NewsCategoryNotFoundException) { } if (news != null) { BusiBlocks.CommsBlock.News.Category childCategory = NewsManager.CreateCategory(categoryName); childCategory.ParentCategory = news; NewsManager.UpdateCategory(childCategory); this.PopulateTreeView <BusiBlocks.CommsBlock.News.Category>(NewsManager.GetAllCategories(), true, false, string.Empty); } else { BusiBlocks.DocoBlock.Category doco = null; try { doco = DocoManager.GetCategory(categoryId); categoryTypeName = doco.GetType().Name; } catch (DocoCategoryNotFoundException) { } if (doco != null) { BusiBlocks.DocoBlock.Category childDocoCategory = DocoManager.CreateCategory(categoryName); childDocoCategory.ParentCategory = doco; DocoManager.UpdateCategory(childDocoCategory); this.PopulateTreeView <BusiBlocks.DocoBlock.Category>(DocoManager.GetAllCategories(), true, false, string.Empty); } } RadTreeView1.DataBind(); RadTreeView1.FindNodeByText(categoryName).ExpandParentNodes(); RadTreeView1.FindNodeByText(categoryName).Selected = true; ((IFeedback)this.Page.Master).ShowFeedback( BusiBlocksConstants.Blocks.Administration.LongName, categoryTypeName, Feedback.Actions.Created, categoryName ); } }
/// <summary> /// Binds the articles to the list in link selection div. /// </summary> protected void BindArticles() { try { rptDocusList.DataSource = DocoManager.GetAllArticles(); rptDocusList.DataBind(); } catch (Exception ex) { //Log - unable to bind articles list. throw ex; } }
/// <summary> /// Saves content for the ediotr. Creates a new version entry in the DB /// </summary> protected void SaveContent(string ChapID, string sender) { try { ChapterVersion chapterVersion = new ChapterVersion(); IList <ChapterVersion> allChapters = DocoManager.GetAllItemsByArticleId(ArticleId); chapterVersion = allChapters.First(x => x.Id.Equals(ChapID)); string temp = chapterVersion.Content; // chapterVersion.Content = UltimateEditor1.EditorHtml; BusiBlocks.XHTMLText htmlText = new BusiBlocks.XHTMLText(); //chapterVersion.Content = htmlText.FormatXHTML(txtEditor.Content); chapterVersion.Content = txtEditor.Content; //check if the user has changed the Chapter Name. if (txtBoxChapterName.Visible && !string.IsNullOrEmpty(txtBoxChapterName.Text) && txtBoxChapterName.Text != chapterVersion.Name) { chapterVersion.Name = txtBoxChapterName.Text; } //if this is the first chapter and no content has been uploaded then if (string.IsNullOrEmpty(temp)) // if the content is empty or is being added for the first time it will update the only existing single record. { BusiBlocks.DocoBlock.DocoManager.UpdateChapterVersion(chapterVersion); } else //Check if the chapter name has changed at all - if yes then pass in VersionUpdateType.Chapter //Update chapter ID if using the button to save content, if not then do no update since the wmLoadChapter does it. { if (sender == "button") { ChapterId = BusiBlocks.DocoBlock.DocoManager.CreateChapterVersion(ArticleId, chapterVersion, VersionUpdateType.Content).Id; } else { BusiBlocks.DocoBlock.DocoManager.CreateChapterVersion(ArticleId, chapterVersion, VersionUpdateType.Content); } } //perform draft operations. //DeleteDraft(chapterVersion.Id); } catch (Exception ex) { //Log - unable to save current content for the selected chapter. throw ex; } lblLastDraft.Text = "<i>Chapter content saved on: " + DateTime.Now.ToShortDateString() + " - " + DateTime.Now.ToShortTimeString() + "</i>"; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ViewState["RefUrl"] = Request.UrlReferrer.ToString(); } //check previous page's URL for the id if Id hasn't been brought forward. if (Request.UrlReferrer.Query.Contains("?id")) { CategoryId = Request.UrlReferrer.Query.Substring(Request.UrlReferrer.Query.IndexOf("id") + 3); } else { CategoryId = Request["id"]; //check for id in URL } if (!string.IsNullOrEmpty(CategoryId)) { Category category = null; if (!string.IsNullOrEmpty(CategoryId)) { category = DocoManager.GetCategory(CategoryId); } if (!SecurityHelper.CanUserView(User.Identity.Name, category.Id)) { // If the user cannot view the category, then return silently. object refUrl = ViewState["RefUrl"]; if (refUrl != null) { Response.Redirect((string)refUrl); } } lblDisplayName.InnerText = category.DisplayName; HtmlLink link = new HtmlLink(); link.Href = Navigation.Doco_CategoryRss(CategoryId).GetServerUrl(true); link.Attributes.Add("rel", "alternate"); link.Attributes.Add("type", "application/rss+xml"); link.Attributes.Add("title", "Category " + category.DisplayName + " Announcements"); Header.Controls.Add(link); //commenting this till the Creation row is finalised. string URL = Navigation.Doco_NewArticle(CategoryId).GetAbsoluteClientUrl(true); bool Access = SecurityHelper.CanUserEdit(Page.User.Identity.Name, category.Id); newLink = new Navigation.NavigateNewItem(URL, Access); pmm.LoadPermissionsView(category.Id, category.DisplayName); LoadList(category); } }
/// <summary> /// Retrieve all the articles. /// </summary> private void LoadArticles() { var articles = new List <Article>(); // Get eligible document categories // todo Refactor Versioning so that I can pass the categories that I'm interested in (viewable news categories), // and then it returns be all the versionItems that are in those categories. IList <Access> accessibleList = AccessManager.GetUsersAccessibleItems(Page.User.Identity.Name, BusiBlocks.ItemType.DocoCategory, BusiBlocks.AccessType.View); foreach (Access accessItem in accessibleList) { Category category = DocoManager.GetCategory(accessItem.ItemId); articles.AddRange(DocoManager.GetArticles(category, ArticleStatus.EnabledAndApproved, false) .Where(x => x.RequiresAck) .Distinct(new KeyEqualityComparer <Article>(x => x.Name))); } // Filter articles to only include those that have not been viewed or ack'd var itemsToList = new List <Article>(); foreach (Article article in articles) { if (!itemsToList.Exists(i => i.Id == article.Id)) { if (article.RequiresAck) { if (article.Acknowledged) { continue; } } else { if (article.Viewed) { continue; } } //restricting to display only 5 items for each dashboard. if (itemsToList.Count < 5) { itemsToList.Add(article); } } } lblNoResults.Visible = itemsToList.Count == 0; listRepeater.DataSource = itemsToList; listRepeater.DataBind(); }
protected void btnAcknowledge_Click(object sender, EventArgs e) { string documentId; documentId = Request["id"]; //check for id in URL if (!string.IsNullOrEmpty(documentId)) { Article article = DocoManager.GetArticle(documentId); AuditManager.Audit(Page.User.Identity.Name, article.Id, AuditRecord.AuditAction.Acknowledged); article = DocoManager.GetArticle(documentId); SetTrafficLight(article); } }
private void BindTrafficLight() { // The RadTabStrip1 is the edit/preview strip. This is visible when we are in edit mode. // Therefore don't show the acknowledge checkbox if we are in edit mode. if (this.RadTabStrip1.Visible) { ackText.Visible = false; } else { Article article = DocoManager.GetArticle(ArticleId); if (SecurityHelper.CanUserView(Page.User.Identity.Name, article.Category.Id)) { if (!string.IsNullOrEmpty(Request.QueryString["mode"]) && Request.QueryString["mode"].Equals("approve")) { divAckButton.Attributes["class"] = "divAckChecked"; btnAcknowledge.Enabled = false; } else if (article.RequiresAck) { if (article.Acknowledged) { divAckButton.Attributes["class"] = "divAckChecked"; btnAcknowledge.Enabled = false; } else { divAckButton.Attributes["class"] = "divAckButton"; } } else { //check the auti record for the article- audit if no records found. IList <AuditRecord> records = AuditManager.GetAuditItems(Page.User.Identity.Name, ArticleId, AuditRecord.AuditAction.Viewed); if (records.Count == 0) { AuditManager.Audit(Page.User.Identity.Name, ArticleId, AuditRecord.AuditAction.Viewed); } ackText.Visible = false; } } else { divAckButton.Visible = false; spanAcked.Visible = false; } } }
/// <summary> /// Binds the reorder list on left to the chapters. Also binds the chapters to the list in link selection div. /// </summary> protected void BindSequence() { IList <ChapterVersion> dsChapters = DocoManager.GetAllItemsByArticleId(ArticleId); //bind chapters to the list ReorderList1.DataSource = dsChapters; ReorderList1.DataBind(); ReorderList2.DataSource = dsChapters; ReorderList2.DataBind(); //bind chapters to the select list rptChapsList.DataSource = dsChapters; rptChapsList.DataBind(); }
protected void SaveContent(string ChapID, int sequence) { try { ChapterVersion chapterVersion = new ChapterVersion(); BusiBlocks.XHTMLText xhtml = new BusiBlocks.XHTMLText(); IList <ChapterVersion> allChapters = DocoManager.GetAllItemsByArticleId(ArticleId); chapterVersion = allChapters.First(x => x.Id.Equals(ChapID)); Draft draft = DocoManager.GetDraftByChapterId(chapterVersion.Id); string temp = chapterVersion.Content; if (draft != null) { chapterVersion.Content = draft.Content; } //add anchor tags for subchapters. chapterVersion.Sequence = sequence; chapterVersion.Content = xhtml.AddAnchorTags(chapterVersion.Content); //if this is the first time chapter content is added and no content has been uploaded then if (string.IsNullOrEmpty(temp)) // if the content is empty or is being added for the first time it will update the only existing single record. { BusiBlocks.DocoBlock.DocoManager.UpdateChapterVersion(chapterVersion); } else //Update chapter ID if using the button to save content, if not then do no update since the wmLoadChapter does it. { BusiBlocks.DocoBlock.DocoManager.CreateChapterVersion(ArticleId, chapterVersion, VersionUpdateType.Content); } Article a = DocoManager.GetArticle(ArticleId); a.UpdateDate = DateTime.Now; DocoManager.UpdateArticle(a, false); } catch (Exception ex) { //Log - unable to save current content for the selected chapter. throw ex; } }