protected void AddApproverButton(string versionId, string versionItemId, GridDataItem item) { //get news item for the latest version. //checked the status of the item and add approve button. Item newsLatestEditVersion = NewsManager.GetItem(versionItemId); //to be approved by owner when sent by editor if (newsLatestEditVersion.ApprovalStatus.Name == ItemApprovalStatusManager.GetForEditApprovalStatus().Name) { if (Page.User.Identity.Name.ToLower().Equals(item["Owner"].Text.ToLower())) { ((LinkButton)item["Actions"].FindControl("lnkApproveItem")).CommandArgument = versionItemId; item["Actions"].FindControl("lnkApproveItem").Visible = true; } } //to be approved by approver else if (newsLatestEditVersion.ApprovalStatus.Name == ItemApprovalStatusManager.GetForApprovalStatus().Name) { if (BusiBlocks.ApproverLayer.ApproverManager.IsApprover(Utilities.GetUserName(Page.User.Identity.Name), versionId)) { ((LinkButton)item["Actions"].FindControl("lnkApproveItem")).CommandArgument = versionItemId; item["Actions"].FindControl("lnkApproveItem").Visible = true; } } }
protected void btnApprove_Click(object sender, EventArgs e) { if (Item.ApprovalStatus.Id == ItemApprovalStatusManager.GetForEditApprovalStatus().Id) { Item.ApprovalStatus = ItemApprovalStatusManager.GetForApprovalStatus(); } else if (Item.ApprovalStatus.Id == ItemApprovalStatusManager.GetForApprovalStatus().Id) { Item.ApprovalStatus = ItemApprovalStatusManager.GetApprovalStatus(); } Item.ApprovalStatus = ItemApprovalStatusManager.GetApprovalStatus(); Item.UpdateDate = DateTime.Now; //Versioning //update the version item as well. //if person is approver only then change the major/minor version for publishing. if (Request.QueryString.Get("mode") == "approve") { VersionType versionType = VersionType.Draft; //if trEditDetails not visible then this is the first publish! if (trEditDetails.Visible == true) { if (!string.IsNullOrEmpty(rblEditDetails.SelectedValue)) { versionType = (rblEditDetails.SelectedValue == "major") ? VersionType.Major : VersionType.Minor; } } else { versionType = VersionType.Major; } VersionItem approveVersion = VersionManager.GetVersionById(VersionId); approveVersion.VersionNumber = VersionManager.GetVersionNumber(versionType, approveVersion.ItemId); VersionManager.UpdateVersionItem(approveVersion); } NewsManager.UpdateItem(Item); Navigation.Communication_News().Redirect(this); }
private void SaveItem(Category category, SaveType saveType) { if (txtTitle.Text.Length >= 100) { ((IFeedback)Page.Master).SetError(GetType(), "The announcement title must be less than 100 characters long"); return; } Item.Category = category; Item.Description = txtDescription.Content; Item.Title = txtTitle.Text; Item.Tag = rblAcknowledge.Items.FindByValue("required").Selected.ToString() + ":" + rblApproval.Items.FindByValue("required").Selected.ToString(); //Item.Expiry = rdpExpiry.SelectedDate; string versionId = VersionId; if (string.IsNullOrEmpty(versionId)) { versionId = NewVersionId; } VersionItem versionItem = VersionManager.GetVersionById(versionId); VersionType versionType = VersionType.Draft; string GroupID = Item.Id; string VersionNumber = VersionManager.GetVersionNumber(VersionType.New, string.Empty); ItemApprovalStatus approvalStatus = new ItemApprovalStatus(); if (rblApproval.SelectedValue.Equals("required")) { if (saveType == SaveType.CheckIn) { approvalStatus = ItemApprovalStatusManager.GetDraftStatus(); } else if (saveType == SaveType.Publish) { approvalStatus = (Item.Author.Equals(Utilities.GetUserName(Page.User.Identity.Name)) == true) ? ItemApprovalStatusManager.GetForApprovalStatus() : Item.ApprovalStatus = ItemApprovalStatusManager.GetForEditApprovalStatus(); } else { approvalStatus = new ItemApprovalStatus() { Id = string.Empty, Name = string.Empty } }; } else { if (saveType == SaveType.CheckIn) { approvalStatus = ItemApprovalStatusManager.GetDraftStatus(); } else if (saveType == SaveType.Publish) { approvalStatus = ItemApprovalStatusManager.GetStatusByName("Published"); versionType = (rblEditDetails.SelectedIndex == 0) ? VersionType.Minor : VersionType.Major; } } if (versionItem != null) { //Create a new record only when saving after editing an existing version //if it's being put on hold then don't create a new record if (saveType == SaveType.Hold) { NewsManager.UpdateItem(Item); } else { Item = CreateItem(category, ddlOwner.SelectedItem.Text, txtTitle.Text, txtDescription.Content, approvalStatus); } GroupID = versionItem.GroupId; VersionNumber = VersionManager.GetVersionNumber(versionType, versionItem.ItemId); } //this applies to announcements when they don't have any versions previously. else { Item.ApprovalStatus = approvalStatus; NewsManager.UpdateItem(Item); } //save version item only when checkin or publish. if (saveType != SaveType.Hold) { NewVersionId = SaveVersionItem(GroupID, VersionNumber, saveType); } }