protected void btCancel_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(VersionId)) { VersionManager.CheckInVersion(VersionId); } Navigation.Communication_News().Redirect(this); }
/// <summary> /// Checks in the current version which is been edited. /// </summary> protected void CheckInVersion() { string versionId = VersionId; if (string.IsNullOrEmpty(versionId)) { versionId = NewVersionId; } VersionItem versionItem = VersionManager.GetVersionById(versionId); VersionManager.CheckInVersion(versionItem.Id); }
protected void RadGrid1ItemCommand(object sender, GridCommandEventArgs e) { ((IFeedback)Page.Master).HideFeedback(); if (e.CommandName == "view") { GridDataItem item = (GridDataItem)e.Item; var lnkbtnView = (LinkButton)e.Item.FindControl("imgBtnView"); AuditManager.Audit(Page.User.Identity.Name, item["Id"].Text, AuditRecord.AuditAction.Viewed); Navigation.Communication_NewsViewItem(lnkbtnView.CommandArgument.ToString(CultureInfo.InvariantCulture)).Redirect(this); } else if (e.CommandName == "editVersion") { //edit link to be be the VersionID VersionItem versionByItem = VersionManager.GetVersionByItemId(e.CommandArgument.ToString()); string groupId = string.Empty; if (versionByItem != null) { groupId = versionByItem.GroupId; string versionId = (VersionManager.GetVersionByGroupId(groupId)).Id; string checkedoutUser = VersionManager.GetCheckedOutUser(groupId); if ((!string.IsNullOrEmpty(checkedoutUser)) && (checkedoutUser != Page.User.Identity.Name)) { ((IFeedback)Page.Master).SetError(GetType(), "Unable to edit: News Item is checked out to " + checkedoutUser); } else { //perform checkout by the user here VersionManager.CheckOutVersion(versionId, Page.User.Identity.Name); Navigation.Communication_NewsEditItem(versionId).Redirect(this); } } else //for existing announcements which dont have a version { //create a version out of the existing announcement string itemId = e.CommandArgument.ToString(); string VersionNumber = VersionManager.GetVersionNumber(VersionType.New, string.Empty); VersionManager.CreateVersionItem(new VersionItem() { ItemId = itemId, GroupId = itemId, VersionNumber = VersionNumber, DateCreated = DateTime.Now, Comments = string.Empty, ModifiedBy = Utilities.GetUserName(Page.User.Identity.Name) }); //get the version by itemId and then check out. string versionId = VersionManager.GetVersionByItemId(itemId).Id; VersionManager.CheckOutVersion(versionId, Utilities.GetUserName(Page.User.Identity.Name)); Navigation.Communication_NewsEditItem(versionId).Redirect(this); } } else if (e.CommandName == "delete") { Item itemToDelete = NewsManager.GetItem(e.CommandArgument.ToString()); string itemNameBeforeDelete = itemToDelete.Title; string groupID = VersionManager.GetVersionByItemId(itemToDelete.Id).GroupId; string checkedoutUser = VersionManager.GetCheckedOutUser(groupID); if ((!string.IsNullOrEmpty(checkedoutUser)) && (checkedoutUser != Page.User.Identity.Name)) { ((IFeedback)Page.Master).SetError(GetType(), "Unable to delete: News Item is checked out to " + checkedoutUser); } else { string itemIdBeforeDelete = itemToDelete.Category.Id; NewsManager.DeleteItemByGroup(groupID); //Controls_TreeView tree = (Controls_TreeView)this.Parent.FindControl("tree1"); //tree.PopulateTreeView<Category>(NewsManager.GetViewableCategories(Page.User.Identity.Name), false, false, string.Empty); //tree.RebindNode(itemIdBeforeDelete, false); ((IFeedback)Page.Master).ShowFeedback(BusiBlocksConstants.Blocks.Administration.ShortName, itemToDelete.GetType().Name, Feedback.Actions.Deleted, itemNameBeforeDelete); } } else if (e.CommandName == RadGrid.FilterCommandName) { Pair filterPair = (Pair)e.CommandArgument; List <NewsGridItem> items = new List <NewsGridItem>(); switch (filterPair.Second.ToString()) { case "Category": TextBox tbPattern = (e.Item as GridFilteringItem)["Category"].Controls[0] as TextBox; FilterExpression = tbPattern.Text; BindWithFilter(items); RadGridManage.DataBind(); if (!string.IsNullOrEmpty(FilterExpression)) { var foundNews = NewsManager.GetCategoryByLikeName(FilterExpression.Split(',').First(), true); int foundCount = foundNews.Count; if (foundCount > 0) { //Controls_TreeView tree = (Controls_TreeView)this.Parent.FindControl("tree1"); //tree.PopulateTreeView<Category>(NewsManager.GetViewableCategories(Page.User.Identity.Name), false, false, string.Empty); //string selectedNode = (foundNews.FirstOrDefault()).Id; //tree.RebindNode(selectedNode, true); } } break; default: break; } } else if (e.CommandName == "approveItem") { VersionItem versionByItem = VersionManager.GetVersionByItemId(e.CommandArgument.ToString()); string groupId = string.Empty; if (versionByItem != null) { groupId = versionByItem.GroupId; string checkedoutUser = VersionManager.GetCheckedOutUser(groupId); if ((!string.IsNullOrEmpty(checkedoutUser)) && (checkedoutUser != Page.User.Identity.Name)) { ((IFeedback)Page.Master).SetError(GetType(), "Unable to approve: News Item is checked out to " + checkedoutUser); } else { string versionId = (VersionManager.GetVersionByGroupId(groupId)).Id; Navigation.Communication_NewsViewItemApproval(versionId).Redirect(this); } } else { Navigation.Communication_NewsViewItemApproval(e.CommandArgument.ToString()).Redirect(this); } } else if (e.CommandName == "checkinItem") { VersionManager.CheckInVersion(e.CommandArgument.ToString()); Navigation.Communication_News().Redirect(this); } else if (e.CommandName == "viewStatus") { // Navigate to the user view status page and pass the item id VersionItem versionByItem = VersionManager.GetVersionByItemId(e.CommandArgument.ToString()); if (versionByItem != null) { Navigation.Communication_UserViewStatus(versionByItem.ItemId, versionByItem.Id).Redirect(this); } } //else if (e.CommandName == "UsersViewed") //{ // Item item = NewsManager.GetItem(e.CommandArgument.ToString()); // VersionItem version = VersionManager.GetVersionByItemId(e.CommandArgument.ToString()); // IList<User> totalUsers = GetTotalUsers(item.Category.Id); // List<User> usersViewed = new List<BusiBlocks.Membership.User>(); // IList<string> personsViewed = new List<string>(); // //get the published id. // List<string> publishedIds = new List<string>(); // publishedIds = GetRespectivePublishedVersions(version.GroupId, version.VersionNumber); // usersViewed = GetViewUsers(AuditRecord.AuditAction.Viewed, totalUsers, publishedIds); // foreach (User user in usersViewed) // personsViewed.Add(user.Person.Id); // Session["personList"] = personsViewed; // Navigation.Directory_Search().Redirect(this); //} //else if (e.CommandName == "UsersNotViewed") //{ // Item item = NewsManager.GetItem(e.CommandArgument.ToString()); // VersionItem version = VersionManager.GetVersionByItemId(e.CommandArgument.ToString()); // IList<User> totalUsers = GetTotalUsers(item.Category.Id); // List<User> usersViewed = new List<BusiBlocks.Membership.User>(); // IList<string> personsNotViewed = new List<string>(); // //get the published id. // List<string> publishedIds = new List<string>(); // publishedIds = GetRespectivePublishedVersions(version.GroupId, version.VersionNumber); // usersViewed = GetViewUsers(AuditRecord.AuditAction.Viewed, totalUsers, publishedIds); // foreach (User user in totalUsers) // if (!usersViewed.Contains(user)) // personsNotViewed.Add(user.Person.Id); // Session["personList"] = personsNotViewed; // Navigation.Directory_Search().Redirect(this); //} //else if (e.CommandName == "UsersAcked") //{ // Item item = NewsManager.GetItem(e.CommandArgument.ToString()); // VersionItem version = VersionManager.GetVersionByItemId(e.CommandArgument.ToString()); // IList<User> totalUsers = GetTotalUsers(item.Category.Id); // List<User> usersViewed = new List<BusiBlocks.Membership.User>(); // IList<string> personsViewed = new List<string>(); // //get the published id. // List<string> publishedIds = new List<string>(); // publishedIds = GetRespectivePublishedVersions(version.GroupId, version.VersionNumber); // usersViewed = GetViewUsers(AuditRecord.AuditAction.Acknowledged, totalUsers, publishedIds); // foreach (User user in usersViewed) // personsViewed.Add(user.Person.Id); // Session["personList"] = personsViewed; // Navigation.Directory_Search().Redirect(this); //} //else if (e.CommandName == "UsersNotAcked") //{ // Item item = NewsManager.GetItem(e.CommandArgument.ToString()); // VersionItem version = VersionManager.GetVersionByItemId(e.CommandArgument.ToString()); // IList<User> totalUsers = GetTotalUsers(item.Category.Id); // List<User> usersViewed = new List<BusiBlocks.Membership.User>(); // IList<string> personsNotViewed = new List<string>(); // //get the published id. // List<string> publishedIds = new List<string>(); // publishedIds = GetRespectivePublishedVersions(version.GroupId, version.VersionNumber); // usersViewed = GetViewUsers(AuditRecord.AuditAction.Acknowledged, totalUsers, publishedIds); // foreach (User user in totalUsers) // if (!usersViewed.Contains(user)) // personsNotViewed.Add(user.Person.Id); // Session["personList"] = personsNotViewed; // Navigation.Directory_Search().Redirect(this); //} }