Ejemplo n.º 1
0
    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);
        }
    }
Ejemplo n.º 2
0
    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);
            }
        }
    }
Ejemplo n.º 3
0
    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);
        }
    }
Ejemplo n.º 4
0
    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;
            }
        }
    }
Ejemplo n.º 5
0
    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;
        }
    }
Ejemplo n.º 6
0
    protected string DeleteDocument(string docId)
    {
        try
        {
            Article article = DocoManager.GetArticle(docId);

            if (SecurityHelper.CanUserEdit(Page.User.Identity.Name, article.Category.Id))
            {
                return(DocoManager.DeleteArticle(article));
            }
            else
            {
                throw new InvalidPermissionException("delete article");
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Ejemplo n.º 7
0
    protected string GetViewArticleUrl(string id, string cMode)
    {
        Article article = DocoManager.GetArticle(id);

        if (article.IsUpload)
        {
            if (!string.IsNullOrEmpty(article.FileName))
            {
                return(Navigation.Doco_ViewUploadedDoc(article.Id).GetAbsoluteClientUrl(true));
            }
            else
            {
                return(string.Empty);
            }
        }
        else
        {
            return(Navigation.Doco_ViewArticle(article.Name, 0).GetServerUrl(false) + "&cMode=" + cMode + "&id=" +
                   article.Category.Id);
        }
    }
Ejemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string documentId;

        documentId = Request["id"]; //check for id in URL

        if (!string.IsNullOrEmpty(documentId))
        {
            Article article = DocoManager.GetArticle(documentId);

            if ((article.RequiresAck && article.Acknowledged) || !article.RequiresAck)
            {
                ackText.Visible = false;
            }
            else
            {
                ackText.Visible = true;
            }

            lnkFileName.BorderStyle = BorderStyle.None;
            lnkFileName.Text        = article.FileName;
            imgFileName.ImageUrl    = Utility.GetImageUrlType(article.FileName.Substring(article.FileName.IndexOf('.') + 1), article.IsUpload);

            lblTitle.Text        = article.Name;
            lblDescription.Text  = article.Description;
            lblCategory.Text     = article.Category.DisplayName;
            lblOwner.Text        = Utilities.GetDisplayUserName(article.Owner);
            lblDocumentType.Text = "Uploaded";
            lblPublished.Text    = Utilities.GetDateTimeForDisplay(article.UpdateDate);
            lblVersion.Text      = "1.0";// article.Version.ToString();
            //lblComments.Text = article.
            SetTrafficLight(article);
            if (!article.RequiresAck)
            {
                ackLabel.InnerText = "Viewed:";
            }
        }
    }
Ejemplo n.º 9
0
    /// <summary>
    /// Handles the Click event of the btnSave control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void btnUploadSave_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            // Leave if no file selected.
            if (!fuUpload.HasFile)
            {
                fuUpload.Focus();
                return;
            }

            // Create the path for the new file.
            string path =
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resource.NewObjectPath,
                    _root,
                    fuUpload.FileName);

            // Save to the current folder.
            fuUpload.SaveAs(path);

            string  articleId = WebFiler.UrlEncoding.Decode(Request.QueryString[Resource.QSAID]);
            Article article   = DocoManager.GetArticle(articleId);
            article.IsUpload    = true;
            article.FileName    = fuUpload.FileName;
            article.RequiresAck = chkAcknowledge.Checked;
            if (chkEnabled.Checked)
            {
                article.Enabled = chkEnabled.Checked;
            }
            DocoManager.UpdateArticle(article, true);

            Navigation.Doco_ViewCategory(article.Category.Id).Redirect(this);
            //Refresh();
        }
    }
Ejemplo n.º 10
0
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName.Equals("Edt"))
        {
            //Navigation.Doco_EditArticle(e.CommandArgument.ToString()).Redirect(this);
            var lnk = (LinkButton)e.Item.FindControl("imgBtnEdit");

            var img = (Image)e.Item.FindControl("imgType");

            if (img.ImageUrl.Contains("onlineDoc"))
            {
                Navigation.Doco_ViewArticle(e.CommandArgument.ToString(), 0, lnk.Attributes["catid"], "draft").Redirect(
                    this);
            }
            else
            {
                Navigation.Doco_EditArticle(e.CommandArgument.ToString()).Redirect(this);
            }
        }
        else if (e.CommandName.Equals("Delete"))
        {
            string docId = e.CommandArgument.ToString();

            Article articleToDelete      = DocoManager.GetArticle(docId);
            string  itemNameBeforeDelete = articleToDelete.Title;
            string  catIdBeforeDel       = articleToDelete.Category.Id;
            DocoManager.DeleteArticle(articleToDelete);

            Controls_TreeView tree = (Controls_TreeView)this.Parent.FindControl("tree1");
            tree.PopulateTreeView <BusiBlocks.DocoBlock.Category>(DocoManager.GetViewableCategories(Page.User.Identity.Name), false, false, string.Empty);
            tree.RebindNode(catIdBeforeDel, false);

            ((IFeedback)Page.Master).ShowFeedback(BusiBlocksConstants.Blocks.Documents.ShortName, articleToDelete.GetType().Name, Feedback.Actions.Deleted, itemNameBeforeDelete);
        }
        else if (e.CommandName == RadGrid.FilterCommandName)
        {
            Pair           filterPair = (Pair)e.CommandArgument;
            List <Article> items      = new List <Article>();

            switch (filterPair.Second.ToString())
            {
            case "Category":
                TextBox tbPattern = (e.Item as GridFilteringItem)["Category"].Controls[0] as TextBox;
                FilterExpression = tbPattern.Text;
                BindWithFilter(items);
                RadGrid1.DataBind();
                if (!string.IsNullOrEmpty(FilterExpression))
                {
                    var foundArticles = DocoManager.GetCategoryByLikeName(FilterExpression.Split(',').First(), true);
                    if (foundArticles.Count > 0)
                    {
                        Controls_TreeView tree = (Controls_TreeView)this.Parent.FindControl("tree1");
                        tree.PopulateTreeView <BusiBlocks.DocoBlock.Category>(DocoManager.GetViewableCategories(Page.User.Identity.Name), false, false, string.Empty);
                        string selectedNode = (foundArticles.FirstOrDefault()).Id;
                        tree.RebindNode(selectedNode, true);
                    }
                }
                break;

            default:
                break;
            }
        }
    }