private void ShowPreviousVersionDocLink()
 {
     if (doc.PreviousVersionId < 1)
     {
         PanPreviousVersionDocView.Visible = false;
     }
     else
     {
         ArrayList docEnum = new ArrayList();
         docEnum.Add(doc.PreviousVersionId);
         DataTable tab = DocumentEnt.FindEnum(docEnum);
         if (tab == null || tab.Rows.Count < 1)
         {
             PanPreviousVersionDocView.Visible = false;
         }
         else
         {
             PanPreviousVersionDocView.Visible = true;
             string sid = DbConvert.ToString(tab.Rows[0]["Id"]);
             PanPreviousVersionDocInfo.Rows[0].Cells[1].InnerHtml =
                 "<a href='javascript:ViewDoc(" + sid + ")' >" +
                 HttpUtility.HtmlEncode(DbConvert.ToString(tab.Rows[0]["Header"])) +
                 "</a>";
         }
     }
 }
示例#2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if (Request["btnCancel"] != null)
                {
                    DocumentTransaction.End();
                    Response.Redirect("~/CloseWindow.html");
                    return;
                }

                if (!DocumentTransaction.IsActive())
                {
                    throw new BipFatalException();
                }
                doc = DocumentTransaction.Current.Document;
                if (doc.Id < 1)
                {
                    btnUpdate.Visible = false;
                }
                else
                {
                    btnCreate.Visible = false;
                }
                CtrlDocInfoView.Document = doc;
                DataBind();
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }
示例#3
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     try
     {
         DocumentEnt doc = new DocumentEnt();
         doc.New();
         DocumentTransaction.Begin(doc);
         Response.Redirect("DocFileUpload.aspx");
     }
     catch (Exception ex)
     {
         this.ProcessException(ex);
     }
 }
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if (Request["btnCancel"] != null)
                {
                    DocumentTransaction.End();
                    Response.Redirect("~/CloseWindow.html");
                    return;
                }
                PanPreview.Visible = false;

                if (!DocumentTransaction.IsActive())
                {
                    throw new BipFatalException();
                }

                doc = DocumentTransaction.Current.Document;
                lblFileName.Text = doc.FileName;
                if (Page.IsPostBack == false)
                {
                    ddlFileType.DataSource     = DocFileType.FindAll();
                    ddlFileType.DataTextField  = "Name";
                    ddlFileType.DataValueField = "Id";
                    ddlFileType.DataBind();
                    //ddlFileType.Items.Insert(0, new ListItem("", "0"));
                    ListUtils.SelectSingleListItem(ddlFileType.Items, doc.FileTypeId.ToString());
                }
                else
                {
                    int fileType = Convert.ToInt32(ddlFileType.SelectedItem.Value);
                    if (fileType == 0)
                    {
                        throw new BipGenericException(Bip.Components.BipResources.GetString("StMustSelectFileType"));
                    }
                    doc.ConfigureFileType(Convert.ToInt32(ddlFileType.SelectedItem.Value));
                }

                if (doc.Id > 0)
                {
                    btnBack.Visible = false;
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                int         id  = Convert.ToInt32(Request["Id"]);
                DocumentEnt doc = new DocumentEnt();
                doc.Load(id);
                DocumentTransaction.Begin(doc);
                Response.Redirect("DocumentEdit.aspx");
            }

            catch (Exception ex)
            {
                this.ProcessException(ex);
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (Request["Id"] == null && ViewState["Id"] == null)
            {
                ProcessException(new BipFatalException());
                return;
            }

            try
            {
                if (Request["Id"] != null)
                {
                    m_DocumentId = Convert.ToInt32(Request["Id"]);
                }
                else
                {
                    m_DocumentId = Convert.ToInt32(ViewState["Id"]);
                }

                if (!Page.IsPostBack)
                {
                    ViewState["Id"] = m_DocumentId.ToString();
                }

                m_Document = new DocumentEnt();
                m_Document.Load(m_DocumentId);

                Control header = Page.FindControl("PageHeader");
                if (header != null)
                {
                    Bip.WebControls.DocumentMenuCtrl docMenu = (Bip.WebControls.DocumentMenuCtrl)Page.LoadControl("~/WebControls/DocumentMenuCtrl.ascx");
                    docMenu.DocumentId = m_DocumentId;
                    header.Controls.Add(docMenu);
                    docMenu.DataBind();

                    string strJSTitleValue = m_Document.Header.Replace("\\", "\\\\").Replace("\"", "\\\"");
                    string strSetTitleCtrl = "<script language=javascript>	window.document.title=\""+ strJSTitleValue +
                                             "\";   if(window.parent != null)  window.parent.document.title = \"" + strJSTitleValue +
                                             "\"; </script>";
                    header.Controls.Add(new LiteralControl(strSetTitleCtrl));
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }
示例#7
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if (Page.IsPostBack)
                {
                    if (Request["btnCancel"] != null)
                    {
                        DocumentTransaction.End();
                        Response.Redirect("~/CloseWindow.html");
                        return;
                    }

                    if (UploadedFile.PostedFile == null ||
                        UploadedFile.PostedFile.ContentLength == 0 ||
                        UploadedFile.PostedFile.FileName == null)
                    {
                        throw new BipGenericException(Bip.Components.BipResources.GetString("StrFileUploadError"));
                    }

                    DocumentEnt doc = null;
                    if (!DocumentTransaction.IsActive())
                    {
                        doc = new DocumentEnt();
                        doc.New();
                        DocumentTransaction.Begin(doc);
                    }
                    else
                    {
                        doc = DocumentTransaction.Current.Document;
                    }

                    doc.UploadFile(UploadedFile.PostedFile.InputStream, System.IO.Path.GetFileName(UploadedFile.PostedFile.FileName));
                    //doc.FileName = ;
                    Response.Redirect("DocFileTypeEdit.aspx");
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }

            // Put user code to initialize the page here
        }
 private void ShowPreviousVersionDocLink(DocumentEnt doc)
 {
     if (doc.PreviousVersionId < 1)
     {
         PanPreviousVersionDocView.Visible = false;
     }
     else
     {
         ArrayList docEnum = new ArrayList();
         docEnum.Add(doc.PreviousVersionId);
         DataTable tab = DocumentEnt.FindEnum(docEnum);
         if (tab == null || tab.Rows.Count < 1)
         {
             PanPreviousVersionDocView.Visible = false;
         }
         else
         {
             PanPreviousVersionDocView.Visible = true;
             //PanPreviousVersionDocView.Rows[0].Cells[1].InnerText= DbConvert.ToString(tab.Rows[0]["Id"]);
             PanPreviousVersionDocView.Rows[0].Cells[2].InnerText = DbConvert.ToString(tab.Rows[0]["Header"]);
         }
     }
 }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                bool isInFrame = (Request["frame"] != null);
                PanFileNotShown.Visible = false;
                try
                {
                    string s_id          = Request["Id"];
                    string s_transaction = Request["TC"];
                    bool   original      = true;
                    if (Request["Org"] == null || Request["Org"].Length == 0)
                    {
                        original = false;
                    }
                    bool isInline = (Request["inline"] != null &&
                                     Request["inline"].Length > 0);

                    DocumentEnt doc = new DocumentEnt();

                    if (s_id != null && s_id.Length > 0)
                    {
                        int id = Convert.ToInt32(s_id);
                        doc.Load(id);
                    }
                    else
                    if (s_transaction == "1" && DocumentTransaction.IsActive())
                    {
                        doc = DocumentTransaction.Current.Document;
                    }
                    else
                    {
                        throw new BipFatalException();
                    }



                    DocFileType fileType = new DocFileType(doc.FileTypeId);
                    bool        isText   = (fileType.ContentType.Trim().ToLower() == "text/plain");
                    if (isInline == false)
                    {
                        Response.Clear();
                        Response.ContentType = fileType.ContentType;
                        Response.AppendHeader("Content-Disposition", "attachment; filename=\"" + doc.FileName + "\"");
                        Response.BinaryWrite(doc.DownloadFile(original));
                        Response.End();
                        return;
                    }

                    if (isText == false)
                    {
                        if (fileType.ShowInBrowser == false)
                        {
                            PanFileNotShown.Visible = true;
                            lblFileType.Text        = fileType.Name;
                            if (s_transaction == null)
                            {
                                hlDownload.NavigateUrl = "~/Documents/DocFileDownload.aspx?id=" + doc.Id.ToString();
                            }
                            else
                            {
                                hlDownload.NavigateUrl = "~/Documents/DocFileDownload.aspx?TC=1";
                            }
                            hlDownload.Text = doc.FileName;
                            return;
                        }

                        Response.Clear();
                        Response.ContentType = fileType.ContentType;
                        Response.AppendHeader("Content-Disposition", "inline; filename=\"" + doc.FileName + "\"");
                        Response.BinaryWrite(doc.DownloadFile(original));
                        Response.End();
                        return;
                    }


                    byte [] buffer = doc.DownloadFile(original);
                    // this should not be hardcoded
                    Decoder d     = Encoding.GetEncoding("Windows-1252").GetDecoder();
                    char [] chars = new char[buffer.Length];
                    d.GetChars(buffer, 0, buffer.Length, chars, 0);
                    textFileContents.InnerText = new string(chars);
                }
                catch (Exception ex)
                {
                    if (ex is System.Threading.ThreadAbortException ||
                        ex is System.Threading.ThreadInterruptedException)
                    {
                        throw ex;
                    }

                    if (!isInFrame)
                    {
                        throw ex;
                    }
                    Response.Clear();
                    Response.Redirect("~/Error.aspx?error=" + HttpUtility.UrlEncode(ex.Message));
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
            //HttpUtility.HtmlEncode(
        }
        public override void DataBind()
        {
            if (Request["Id"] != null)
            {
                IsEditMode = false;
                doc        = new DocumentEnt();
                doc.Load(Convert.ToInt32(Request["Id"]));

                hlDownloadFile.NavigateUrl = "~/Documents/DocFileDownload.aspx?Org=1&Id=" + doc.Id.ToString();
                if (Page.IsPostBack == false &&
                    Request.UrlReferrer != null &&
                    Session["MAIN_PAGE"] == null)
                {
                    if (Request.UrlReferrer.AbsolutePath.ToLower().IndexOf("Documents") == -1)
                    {
                        Session["MAIN_PAGE"] = Request.UrlReferrer.ToString();
                    }
                }
            }
            else
            {
                //Session.Remove("MAIN_PAGE");
                IsEditMode = true;
                if (!DocumentTransaction.IsActive())
                {
                    throw new BipFatalException();
                }
                doc = DocumentTransaction.Current.Document;

                hlDownloadFile.NavigateUrl = "~/Documents/DocFileDownload.aspx?Org=1&TC=1";
            }

            if (doc.Id < 1)
            {
                PanExistingDocAttrs.Visible = false;
            }
            else
            {
                lblId.Text           = doc.Id.ToString();
                lblCreationTime.Text = doc.CreationTime.ToString();
            }



            ShowParentDocLink();
            ShowPreviousVersionDocLink();

            if (doc.RefDocuments != null)
            {
                doc.RefDocuments.GetEnumerator().Reset();
            }
            if (doc.RefDocuments == null ||
                !doc.RefDocuments.GetEnumerator().MoveNext())
            {
                PanRelatedDocView.Visible = false;
            }
            else
            {
                grdRelatedDocs.DataSource = DocumentEnt.FindEnum(doc.RefDocuments);
                grdRelatedDocs.DataBind();
            }

            if (doc.Groups != null)
            {
                dlGroups.DataSource = GroupEnt.FindEnum(doc.Groups);
                dlGroups.DataBind();
            }
            else
            {
                dlGroups.Visible = false;
            }



            LoadAttributes();
        }
示例#11
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if (Page.IsPostBack && Request["_BIP_ACTION"] == "AddRelatedDoc")
                {
                    ArrayList docEnum = new ArrayList();
                    if (m_Document.RefDocuments != null)
                    {
                        foreach (int ids in m_Document.RefDocuments)
                        {
                            docEnum.Add(ids);
                        }
                    }

                    int id = Convert.ToInt32(Request["_BIP_ACTION_ARGS"]);
                    if (Request["_BIP_ACTION"] == "AddRelatedDoc")
                    {
                        if (docEnum.IndexOf(id) == -1)
                        {
                            docEnum.Add(id);
                        }
                    }
                    m_Document.RefDocuments = docEnum;
                    m_Document.Update();
                }

                ddlDocLinks.Items.Clear();
                System.Collections.ArrayList docList = new System.Collections.ArrayList();
                if (m_Document.ParentId > 0)
                {
                    docList.Add(m_Document.ParentId);
                }
                if (m_Document.PreviousVersionId > 0)
                {
                    docList.Add(m_Document.PreviousVersionId);
                }
                foreach (object obj in m_Document.RefDocuments)
                {
                    docList.Add(obj);
                }
                DataTable tab = DocumentEnt.FindEnum(docList);
                if (tab != null)
                {
                    ddlDocLinks.DataSource     = tab;
                    ddlDocLinks.DataValueField = "Id";
                    ddlDocLinks.DataTextField  = "Header";
                    ddlDocLinks.DataBind();
                    tab.Dispose();
                }

                ddlDocLinks.Items.Insert(0, new ListItem("<" + Bip.Components.BipResources.GetString("StrRelatedDocuments") + ">", "0"));

                PanAddDocLink.Visible = m_Document.CanEdit;


                if (m_Document.CanEdit || tab != null)
                {
                    PanOpenRefDocuments.Visible = true;
                }
                else
                {
                    PanOpenRefDocuments.Visible = false;
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if (!DocumentTransaction.IsActive())
                {
                    throw new BipFatalException();
                }

                doc = DocumentTransaction.Current.Document;

                if (Request["btnCancel"] != null)
                {
                    DocumentTransaction.End();
                    Response.Redirect("~/CloseWindow.html");
                    return;
                }


                if (Page.IsPostBack == false)
                {
                    if (doc.Id < 1)
                    {
                        PanExistingDocAttrs.Visible = false;
                        btnBack.Text  = "< " + BipResources.GetString("StrBtnBackCaption");
                        btnBack.Width = new Unit("100px");
                    }

                    LoadDropDownList(ddlDocCategory, DocCategoryEnt.FindAll());
                    LoadDropDownList(ddlDocType, DocTypeEnt.FindAll());
                    LoadDropDownList(ddlDocSource, DocSourceEnt.FindAll());

                    dlGroups.DataSource = Bip.Components.GroupEnt.FindAll();
                    dlGroups.DataBind();


                    LoadAttributes();
                }

                // ParentDocID ---------------------------------
                if (Page.IsPostBack == false ||
                    Request["_BIP_ACTION"] == "SelectParentDoc")
                {
                    if (Request["_BIP_ACTION"] == "SelectParentDoc")
                    {
                        doc.ParentId = Convert.ToInt32(Request["_BIP_ACTION_ARGS"]);
                    }
                    ShowParentDocLink(doc);
                }

                // PreviousVersionDocID ---------------------------------
                if (Page.IsPostBack == false ||
                    Request["_BIP_ACTION"] == "SelectPreviousVersionDoc")
                {
                    if (Request["_BIP_ACTION"] == "SelectPreviousVersionDoc")
                    {
                        doc.PreviousVersionId = Convert.ToInt32(Request["_BIP_ACTION_ARGS"]);
                    }
                    ShowPreviousVersionDocLink(doc);
                }

                // RelatedDocs ---------------------------------
                if (Page.IsPostBack == false ||
                    Request["_BIP_ACTION"] == "AddRelatedDoc" ||
                    Request["_BIP_ACTION"] == "RemoveRelatedDoc")
                {
                    if (Request["_BIP_ACTION"] == "AddRelatedDoc" ||
                        Request["_BIP_ACTION"] == "RemoveRelatedDoc")
                    {
                        ArrayList docEnum = new ArrayList();
                        if (doc.RefDocuments != null)
                        {
                            foreach (int ids in doc.RefDocuments)
                            {
                                docEnum.Add(ids);
                            }
                        }

                        int id = Convert.ToInt32(Request["_BIP_ACTION_ARGS"]);
                        if (Request["_BIP_ACTION"] == "AddRelatedDoc")
                        {
                            if (docEnum.IndexOf(id) == -1)
                            {
                                docEnum.Add(id);
                            }
                        }
                        else
                        {
                            docEnum.Remove(id);
                        }

                        doc.RefDocuments = docEnum;
                    }

                    grdDocRefRelated.DataSource = DocumentEnt.FindEnum(doc.RefDocuments);
                    grdDocRefRelated.DataBind();
                }

                string s1, s2;
                bool   showInBrowser = false;
                DocFileType.GetTypeInfo(doc.FileTypeId, out s1, out s2, out showInBrowser);
                btnShowHidePreview.Visible = showInBrowser;
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }