Пример #1
0
        /// <summary>
        /// Gets the well book detail XML.
        /// </summary>
        /// <param name="action">The action.</param>
        /// <returns></returns>
        private XmlDocument GetWellBookDetailXML(string action)
        {
            XmlDocument xmlWellBookDetails = null;
            string strBookID = string.Empty;
            string strChapterID = string.Empty;
            if (HttpContext.Current.Request.QueryString[QUERYSTRING_BOOKID] != null)
            {
                strBookID = HttpContext.Current.Request.QueryString[QUERYSTRING_BOOKID];
            }
            if (strBookID.Length > 0)
            {
                WellBookBLL objWellBookBLL = new WellBookBLL();
                PrintOptions objPrintOptions = new PrintOptions();
                objPrintOptions.IncludeBookTitle = false;
                objPrintOptions.IncludePageTitle = false;
                objPrintOptions.IncludeStoryBoard = false;

                BookInfo objBookInfo = objWellBookBLL.SetBookDetailDataObject(strParentSiteURL, strBookID, action, true, objPrintOptions);
                CommonBLL objCommonBLL = new CommonBLL();
                HttpContext.Current.Session[SESSION_TREEVIEWDATAOBJECT] = objBookInfo;
                if (HttpContext.Current.Request.QueryString[QUERYSTRING_IDVALUE] != null)
                {
                    strChapterID = HttpContext.Current.Request.QueryString[QUERYSTRING_IDVALUE];
                }
                if (HttpContext.Current.Request.QueryString[QUERYSTRING_CHAPTERID] != null)
                {
                    strChapterID = HttpContext.Current.Request.QueryString[QUERYSTRING_CHAPTERID];
                }
                xmlWellBookDetails = objCommonBLL.CreateWellBookDetailXML(objBookInfo);
            }
            return xmlWellBookDetails;
        }
Пример #2
0
        private PrintOptions SetPrintOptionsProperties(PrintOptions printOptions)
        {
            #region Fetch Hidden field values
            /// If Hidden field containse "true" story board should be included in Print document
            if (string.Compare(hdnIncludeStoryBoard.Value.ToLowerInvariant(), "true") == 0)
            {
                printOptions.IncludeStoryBoard = true;
            }
            else if (string.Compare(hdnIncludeStoryBoard.Value.ToLowerInvariant(), "false") == 0)/// If Hidden field containse "false" story board shouldn't be included in Print document
            {
                printOptions.IncludeStoryBoard = false;
            }
            else  /// If Hidden field otherthan contains "true/false" story board shouldn't be included in Print document
            {
                printOptions.IncludeStoryBoard = false;
            }
            /// If Hidden field containse "true" Page Title should be included in Print document
            if (string.Compare(hdnIncludePageTitle.Value.ToLowerInvariant(), "true") == 0)
            {
                printOptions.IncludePageTitle = true;
            }
            else if (string.Compare(hdnIncludePageTitle.Value.ToLowerInvariant(), "false") == 0)/// If Hidden field containse "false" Page Title shouldn't be included in Print document
            {
                printOptions.IncludePageTitle = false;
            }
            else  /// If Hidden field otherthan contains "true/false" Page Title shouldn't be included in Print document
            {
                printOptions.IncludePageTitle = false;
            }

            //Added few more filter options as per DWBv2.0 requirement
            //Modified by Gopinath
            //Date:11/11/2010

            //PrintMyPages
            if (!string.IsNullOrEmpty(hdnPrintMyPages.Value.Trim()))
                printOptions.PrintMyPages = Convert.ToBoolean(hdnPrintMyPages.Value.Trim().ToString());

            //Include Filter
            if (!string.IsNullOrEmpty(hdnIncludeFilter.Value.Trim()))
                printOptions.IncludeFilter = Convert.ToBoolean(hdnIncludeFilter.Value.Trim().ToString());

            //SignedOff
            if (!string.IsNullOrEmpty(hdnSignedOffPages.Value.Trim()))
                printOptions.SignedOff = hdnSignedOffPages.Value.Trim().ToString();

            //EmptyPages
            if (!string.IsNullOrEmpty(hdnEmptyPages.Value.Trim()))
                printOptions.EmptyPages = hdnEmptyPages.Value.Trim().ToString();

            //PageType
            if (!string.IsNullOrEmpty(hdnPageType.Value.Trim()))
                printOptions.PageType = hdnPageType.Value.Trim().ToString();

            //PageName
            if (!string.IsNullOrEmpty(hdnPageName.Value.Trim()))
                printOptions.PageName = hdnPageName.Value.Trim().ToString();

            //Discipline
            if (!string.IsNullOrEmpty(hdnDiscipline.Value.Trim()))
                printOptions.Discipline = hdnDiscipline.Value.Trim().ToString();

            #endregion Fetch Hidden field values

            printOptions.IncludeBookTitle = true;
            printOptions.IncludeTOC = true;

            return printOptions;
        }
Пример #3
0
        /// <summary>
        /// Handles the Click event of the btnPrint 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 btnPrint_Click(object sender, EventArgs e)
        {
            string strAlertMessage = string.Empty;
            try
            {
                int intPrintedDocID = 0;
                string[] strPrintedDocURL = null;
                CommonBLL objCommonBLL = null;
                string strCamlQuery = string.Empty;
                PrintOptions objPrintOptions = new PrintOptions();

                //Set PrintOptions object properties through hidden fields
                objPrintOptions = SetPrintOptionsProperties(objPrintOptions);

                intPrintedDocID = Print(objPrintOptions, WELLBOOKVIEWERCONTROLBOOK, HttpContext.Current.Request.QueryString[MODEQUERYSTRING]);

                /// Open the generated document to show in IE
                if (intPrintedDocID > 0)
                {
                    objCommonBLL = new CommonBLL();
                    strCamlQuery = @"<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" +
                   intPrintedDocID.ToString() + "</Value></Eq></Where>";
                    strPrintedDocURL = objCommonBLL.GetPrintedDocumentUrl(strParentSiteURL, PRINTEDDOCUMNETLIBRARY, strCamlQuery);
                    strAlertMessage = objCommonBLL.GetAlertMessage(strParentSiteURL, "Book");
                    this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "documentprinted", "alert('" + strAlertMessage + "');", true);
                }
                else if (intPrintedDocID == -1)
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), HIDETABJSKEY, HIDETABJSPAGE);
                    this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "NoDocumentsFound", @"<Script language='javaScript'>alert('Please change the filter criteria');</Script>");
                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), HIDETABJSKEY, HIDETABJSPAGE);
                    this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "documentnotprinted", ALERTDOCUMENTNOTPRINTED, true);
                }
            }
            catch (System.Web.Services.Protocols.SoapException soapEx)
            {
                CommonUtility.HandleException(strParentSiteURL, soapEx, 1);
                lblException.Text = ALERTDOCUMENTNOTPRINTED;
                lblException.Visible = true;
                ExceptionBlock.Visible = true;
                PdfBLL objPdfBLL = new PdfBLL();
                objPdfBLL.PrintLog(strParentSiteURL, soapEx.StackTrace, soapEx.Message, "WellBookSummary.btnPrint_Click");

            }
            catch (WebException webEx)
            {
                CommonUtility.HandleException(strParentSiteURL, webEx, 1);
                lblException.Text = ALERTDOCUMENTNOTPRINTED;
                lblException.Visible = true;
                ExceptionBlock.Visible = true;
                PdfBLL objPdfBLL = new PdfBLL();
                objPdfBLL.PrintLog(strParentSiteURL, webEx.StackTrace, webEx.Message, "WellBookSummary.btnPrint_Click");

            }
            catch (Exception ex)
            {
                CommonUtility.HandleException(strParentSiteURL, ex, 1);
                lblException.Text = ALERTDOCUMENTNOTPRINTED;
                lblException.Visible = true;
                ExceptionBlock.Visible = true;
                PdfBLL objPdfBLL = new PdfBLL();
                objPdfBLL.PrintLog(strParentSiteURL, ex.StackTrace, ex.Message, "WellBookSummary.btnPrint_Click");

            }
            finally
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), HIDETABJSKEY, HIDETABJSPAGE);
            }
        }
Пример #4
0
 /// <summary>
 /// Generates the DWB book XML.
 /// </summary>
 /// <param name="siteURL">The site URL.</param>
 /// <param name="rowId">The row id.</param>
 /// <param name="action">The action.</param>
 /// <param name="bookSelected">if set to <c>true</c> [book selected].</param>
 /// <param name="includeTOC">if set to <c>true</c> [include TOC].</param>
 /// <param name="includeStoryBoard">if set to <c>true</c> [include story board].</param>
 /// <returns></returns>
 public System.Xml.XmlDocument GenerateDWBBookXML(string siteURL, int rowId, string action, bool bookSelected, PrintOptions objPrintOptions)
 {
     BookInfo objBookInfo = null;
     System.Xml.XmlDocument xmlWellBookDetails = null;
     if (rowId > 0)
     {
         objBookInfo = SetBookDetailDataObject(siteURL, rowId.ToString(), action, bookSelected, objPrintOptions);
         objCommonBLL = new CommonBLL();
         xmlWellBookDetails = objCommonBLL.CreateWellBookDetailXML(objBookInfo);
     }
     return xmlWellBookDetails;
 }
Пример #5
0
        /// <summary>
        /// Sets the book detail data object.
        /// </summary>
        public BookInfo SetBookDetailDataObject(string siteURL, string bookID, string action, bool bookSelected, PrintOptions objPrintOptions)
        {
            string strCamlQuery = string.Empty;
            string strViewFields = string.Empty;
            DataTable dtBooks = null;
            DataRow objDataRow;
            BookInfo objBookInfo = null;
            try
            {
                objCommonDAL = new CommonDAL();
                objBookInfo = new BookInfo();
                objBookInfo.BookID = bookID;
                strCamlQuery = @"<Where><And><Eq><FieldRef Name='ID' /><Value Type='Number'>" +
                    bookID + "</Value></Eq><Eq><FieldRef Name='Terminate_Status' /><Value Type='Choice'>No</Value></Eq></And></Where>";
                strViewFields = @"<FieldRef Name='ID' /><FieldRef Name='Title' /><FieldRef Name='Owner' /><FieldRef Name='Team_ID' />";
                dtBooks = objCommonDAL.ReadList(siteURL, DWBBOOKLIST, strCamlQuery, strViewFields);
                for (int intIndex = 0; intIndex < dtBooks.Rows.Count; intIndex++)
                {
                    objDataRow = dtBooks.Rows[intIndex];
                    objBookInfo.BookName = objDataRow[TITLECOLUMN].ToString();
                    objBookInfo.BookOwner = objDataRow["Owner"].ToString();
                    objBookInfo.BookTeamID = objDataRow["Team_ID"].ToString();
                    objBookInfo.Action = action;
                    objBookInfo.IsPrintable = true;
                    objBookInfo.IsTOCApplicatble = objPrintOptions.IncludeTOC;
                    if (bookSelected)
                    {
                        objBookInfo.Chapters = SetChapterDetail(siteURL, bookID, action);
                        int intPageCount = 0;
                        if (objBookInfo.Chapters != null && objBookInfo.Chapters.Count > 0)
                        {
                            foreach (ChapterInfo objChapterInfo in objBookInfo.Chapters)
                            {
                                intPageCount += objChapterInfo.PageInfo.Count;
                            }
                            intPageCount += objBookInfo.Chapters.Count;
                        }
                        objBookInfo.PageCount = intPageCount;
                    }

                    objBookInfo.IsStoryBoardApplicable = objPrintOptions.IncludeStoryBoard;
                    objBookInfo.IsPageTitleApplicable = objPrintOptions.IncludePageTitle;
                    objBookInfo.IsBookTitleApplicable = objPrintOptions.IncludeBookTitle;
                }
            }
            catch (Exception)
            {
                throw;
            }
            if (dtBooks != null)
            {
                dtBooks.Dispose();
            }
            return objBookInfo;
        }
Пример #6
0
        /// <summary>
        /// Handles the Click event of the cmdPrintChapter 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 cmdPrintChapter_Click(object sender, EventArgs e)
        {
            string strAlertMessage = string.Empty;
            int intPrintedDocID = 0;
            string[] strPrintedDocURL = null;
            CommonBLL objCommonBLL = null;
            string strCamlQuery = string.Empty;
            PrintOptions objPrintOptions = new PrintOptions();

            try
            {
                /// If Hidden field containse "true" story board should be included in Print document
                if (string.Compare(hdnIncludeStoryBoard.Value.ToLowerInvariant(), "true", true) == 0)
                {
                    objPrintOptions.IncludeStoryBoard = true;
                }
                else if (string.Compare(hdnIncludeStoryBoard.Value.ToLowerInvariant(), "false", true) == 0)/// If Hidden field containse "false" story board shouldn't be included in Print document
                {
                    objPrintOptions.IncludeStoryBoard = false;
                }
                else  /// If Hidden field otherthan contains "true/false" story board shouldn't be included in Print document
                {
                    objPrintOptions.IncludeStoryBoard = false;
                }
                /// If Hidden field containse "true" Page Title should be included in Print document
                if (string.Compare(hdnIncludePageTitle.Value.ToLowerInvariant(), "true", true) == 0)
                {
                    objPrintOptions.IncludePageTitle = true;
                }
                else if (string.Compare(hdnIncludePageTitle.Value.ToLowerInvariant(), "false", true) == 0)/// If Hidden field containse "false" Page Title shouldn't be included in Print document
                {
                    objPrintOptions.IncludePageTitle = false;
                }
                else  /// If Hidden field otherthan contains "true/false" Page Title shouldn't be included in Print document
                {
                    objPrintOptions.IncludePageTitle = false;
                }

                //Added few more filter options as per DWBv2.0 requirement
                //Modified by Gopinath
                //Date:11/11/2010

                //PrintMyPages
                if (!string.IsNullOrEmpty(hdnPrintMyPages.Value.Trim()))
                    objPrintOptions.PrintMyPages = Convert.ToBoolean(hdnPrintMyPages.Value.Trim().ToString());

                //Include Filter
                if (!string.IsNullOrEmpty(hdnIncludeFilter.Value.Trim()))
                    objPrintOptions.IncludeFilter = Convert.ToBoolean(hdnIncludeFilter.Value.Trim().ToString());

                //SignedOff
                if (!string.IsNullOrEmpty(hdnSignedOffPages.Value.Trim()))
                    objPrintOptions.SignedOff = hdnSignedOffPages.Value.Trim().ToString();

                //EmptyPages
                if (!string.IsNullOrEmpty(hdnEmptyPages.Value.Trim()))
                    objPrintOptions.EmptyPages = hdnEmptyPages.Value.Trim().ToString();

                //PageType
                if (!string.IsNullOrEmpty(hdnPageType.Value.Trim()))
                    objPrintOptions.PageType = hdnPageType.Value.Trim().ToString();

                //PageName
                if (!string.IsNullOrEmpty(hdnPageName.Value.Trim()))
                    objPrintOptions.PageName = hdnPageName.Value.Trim().ToString();

                //Discipline
                if (!string.IsNullOrEmpty(hdnDiscipline.Value.Trim()))
                    objPrintOptions.Discipline = hdnDiscipline.Value.Trim().ToString();

                intPrintedDocID = Print(objPrintOptions, WELLBOOKVIEWERCONTROLCHAPTER, HttpContext.Current.Request.QueryString[MODEQUERYSTRING]);

                /// Open the generated document to show in IE
                if (intPrintedDocID > 0)
                {
                    objCommonBLL = new CommonBLL();
                    strCamlQuery = @"<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" +
                   intPrintedDocID.ToString() + "</Value></Eq></Where>";
                    strPrintedDocURL = objCommonBLL.GetPrintedDocumentUrl(strParentSiteURL, PRINTEDDOCUMNETLIBRARY, strCamlQuery);
                    strAlertMessage = objCommonBLL.GetAlertMessage(strParentSiteURL, "Chapter");
                    if (strPrintedDocURL != null && strPrintedDocURL.Length > 0)
                    {
                        this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "documentprinted", "alert('"+ strAlertMessage +"');", true);
                    }
                }
                else if (intPrintedDocID == -1)
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), HIDETABJSKEY, HIDETABJSPAGE);
                    this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "NoDocumentsFound", @"<Script language='javaScript'>alert('Please change the filter criteria');</Script>");
                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), HIDETABJSKEY, HIDETABJSPAGE);
                    this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "documentnotprinted", "alert(' "+ ALERTDOCUMENTNOTPRINTED + " ')", true);
                }
            }
            catch (System.Web.Services.Protocols.SoapException soapEx)
            {
                CommonUtility.HandleException(strParentSiteURL, soapEx,1);
                lblException.Text = ALERTDOCUMENTNOTPRINTED;
                lblException.Visible = true;
                PdfBLL objPdfBLL = new PdfBLL();
                objPdfBLL.PrintLog(strParentSiteURL, soapEx.StackTrace, soapEx.Message, "Chapter.btnPrint_Click");

            }
            catch (WebException webEx)
            {
                CommonUtility.HandleException(strParentSiteURL, webEx,1);
                lblException.Text = ALERTDOCUMENTNOTPRINTED;
                lblException.Visible = true;
                PdfBLL objPdfBLL = new PdfBLL();
                objPdfBLL.PrintLog(strParentSiteURL, webEx.StackTrace, webEx.Message, "Chapter.btnPrint_Click");

            }
            catch (Exception ex)
            {
                CommonUtility.HandleException(strParentSiteURL, ex,1);
                lblException.Text = ALERTDOCUMENTNOTPRINTED;
                lblException.Visible = true;
                PdfBLL objPdfBLL = new PdfBLL();
                objPdfBLL.PrintLog(strParentSiteURL, ex.StackTrace, ex.Message, "Chapter.btnPrint_Click");

            }
            finally
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), HIDETABJSKEY, HIDETABJSPAGE);
            }
        }
Пример #7
0
        /// <summary>
        /// Handles the ServerClick event of the btnPrint 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 btnPrint_ServerClick(object sender, EventArgs e)
        {
            int intPrintedDocID = 0;
            string[] strPrintedDocURL = null;
            CommonBLL objCommonBLL = null;
            string strCamlQuery = string.Empty;

            PrintOptions objPrintOptions = new PrintOptions();

            try
            {
                PageID = HttpContext.Current.Request.QueryString[PAGEIDQUERYSTRING];
                if (string.Compare(hdnIncludeStoryBoard.Value.ToLowerInvariant(), "true") == 0)
                {
                    objPrintOptions.IncludeStoryBoard = true;
                }
                if (string.Compare(hdnIncludePageTitle.Value.ToLowerInvariant(), "true") == 0)
                {
                    objPrintOptions.IncludePageTitle = true;
                }

                ///  Generate XML to Print PDF and returns the PDF id stored in document library
                intPrintedDocID = Print(objPrintOptions, WELLBOOKVIEWERCONTROLPAGE, HttpContext.Current.Request.QueryString[MODEQUERYSTRING]);

                /// Query the Printed Document library to get the recently printed document and show in IE.
                if (intPrintedDocID > 0)
                {
                    objCommonBLL = new CommonBLL();
                    strCamlQuery = @"<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" +
                   intPrintedDocID.ToString() + "</Value></Eq></Where>";
                    strPrintedDocURL = objCommonBLL.GetPrintedDocumentUrl(strParentSiteURL, PRINTEDDOCUMNETLIBRARY, strCamlQuery);
                    this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "documentprinted", "window.open('" + @strDocumentURL + "', 'PDFViewer', 'scrollbars,resizable,status,toolbar,menubar');", true);
                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "documentnotprinted", ALERTDOCUMENTNOTPRINTED, true);
                }
            }
            catch (System.Web.Services.Protocols.SoapException soapEx)
            {
                CommonUtility.HandleException(strParentSiteURL, soapEx);
                RenderException(soapEx.Message);
                PdfBLL objPdfBLL = new PdfBLL();
                objPdfBLL.PrintLog(strParentSiteURL, soapEx.StackTrace, soapEx.Message, "Type2.btnPrint_Click");

            }
            catch (WebException webEx)
            {
                CommonUtility.HandleException(strParentSiteURL, webEx);
                RenderException(webEx.Message);
                PdfBLL objPdfBLL = new PdfBLL();
                objPdfBLL.PrintLog(strParentSiteURL, webEx.StackTrace, webEx.Message, "Type2.btnPrint_Click");
            }
            catch (Exception ex)
            {
                CommonUtility.HandleException(strParentSiteURL, ex);
                PdfBLL objPdfBLL = new PdfBLL();
                objPdfBLL.PrintLog(strParentSiteURL, ex.StackTrace, ex.Message, "Type2.btnPrint_Click");
            }
        }
Пример #8
0
        /// <summary>
        /// Handles the Click event of the btnPrintPage 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>
        void btnPrintPage_Click(object sender, EventArgs e)
        {
            try
            {
                int intPrintedDocID = 0;
                string[] strPrintedDocURL = null;
                string strCamlQuery = string.Empty;
                PrintOptions objPrintOptions = new PrintOptions();
                /// If Hidden field containse "true" story board should be included in Print document
                if (string.Compare(hdnIncludeStoryBoard.Text.ToLowerInvariant(), "true") == 0)
                {
                    objPrintOptions.IncludeStoryBoard = true;
                }
                /// If Hidden field containse "true" Page Title should be included in Print document
                if (string.Compare(hdnIncludePageTitle.Text.ToLowerInvariant(), "true") == 0)
                {
                    objPrintOptions.IncludePageTitle = true;
                }
                intPrintedDocID = PrintPage(objPrintOptions);

                /// Open the generated document to show in IE
                if (intPrintedDocID > 0)
                {
                    objCommonBLL = new CommonBLL();
                    strCamlQuery = @"<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" +
                    intPrintedDocID.ToString() + "</Value></Eq></Where>";
                    strParentSiteURL = SPContext.Current.Site.Url.ToString();

                    this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "documentprinted", "window.open('" + @strDocumentURL + "', 'PDFViewer', 'scrollbars,resizable,status,toolbar,menubar');", true);
                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "documentnotprinted", "alert('We are not able to Print the document. Please contact the administrator');", true);
                }

            }
            catch (SoapException soapEx)
            {
                if (!string.Equals(soapEx.Message.ToString(), NORECORDSFOUND))
                {
                    CommonUtility.HandleException(strCurrSiteUrl, soapEx, 1);
                }
                if (lblMessage != null)
                {
                    lblMessage.Visible = true;
                    lblMessage.Text = soapEx.Message;
                }
            }
            catch (WebException webEx)
            {
                CommonUtility.HandleException(HttpContext.Current.Request.Url.ToString(), webEx, 1);
                if (lblMessage != null)
                {
                    lblMessage.Visible = true;
                    lblMessage.Text = webEx.Message;
                }
            }
            catch (Exception ex)
            {
                CommonUtility.HandleException(HttpContext.Current.Request.Url.ToString(), ex);
            }
            finally
            {
                StringBuilder renderedOutput = new StringBuilder();
                System.IO.StringWriter strWriter = new System.IO.StringWriter(renderedOutput);
                HtmlTextWriter tWriter = new HtmlTextWriter(strWriter);
                tWriter.Write("<Script language=\"javascript\">setWindowTitle('" + GetEnumDescription(SearchName) + "');</Script>");
            }
        }
Пример #9
0
        /// <summary>
        /// Print the current Page/Selected Pages
        /// </summary>
        private int PrintPage(PrintOptions objPrintOptions)
        {
            bool blnUserControlFound = false;
            RadTreeView objTreeViewWellBook = null;
            WellBookBLL objWellBookBLL = null;
            StringBuilder strPageIds = null;
            ArrayList arlPageDetails = null;
            ArrayList arlChapterCollection = null;
            string strSplitter = ";";
            BookInfo objBookInfo = null;
            ChapterInfo objChapterInfo = null;
            XmlDocument xmlWellBookDetails = null;
            string intPrintedDocID = string.Empty;
            string strChapterIDForPage = string.Empty;
            string strSelectedPageID = string.Empty;
            string strBookID = string.Empty;
            objWellBookBLL = new WellBookBLL();
            objCommonBLL = new CommonBLL();
            arlChapterCollection = new ArrayList();
            /// If in View Mode, take page ID and chapter ID from Query string
            if (HttpContext.Current.Request.QueryString[QUERYSTRING_MODE] == null)
            {
                if (this.Parent.GetType().Equals(typeof(SPWebPartManager)))
                {
                    foreach (Control ctrlWebPart in this.Parent.Controls)
                    {
                        if (ctrlWebPart.GetType().Equals(typeof(TreeViewControl.TreeViewControl)))
                        {

                            Control ctrlTreeView = ctrlWebPart.FindControl("RadTreeView1");
                            if (ctrlTreeView != null && ctrlTreeView.GetType().Equals(typeof(RadTreeView)))
                            {
                                objTreeViewWellBook = (RadTreeView)ctrlWebPart.FindControl("RadTreeView1");
                                blnUserControlFound = true;
                                break;
                            }
                            if (blnUserControlFound)
                            {
                                break;
                            }
                        }
                    }
                }

                if (objTreeViewWellBook != null)
                {
                    /// If selected node is book node, loop into each chapter node
                    /// If chapter node is checked, loop into each page node and create book info object
                    /// Else if selected node is chapter node, loop into each page node
                    /// Add only selected page details to chapter object.
                    /// Else if selected node is page node, create bookinfo which includes only selected page.

                    if (objTreeViewWellBook.SelectedNode.Level == 2)
                    {
                        strBookID = objTreeViewWellBook.SelectedNode.ParentNode.ParentNode.Value;
                        strChapterIDForPage = objTreeViewWellBook.SelectedNode.ParentNode.Value;
                        strSelectedPageID = objTreeViewWellBook.SelectedNode.Value;
                    }
                }
            }
            else
            {
                if (string.Compare(HttpContext.Current.Request.QueryString[QUERYSTRING_MODE], VIEW) == 0)
                {
                    strSelectedPageID = HttpContext.Current.Request.QueryString[QUERYSTRING_PAGEID];
                    strChapterIDForPage = HttpContext.Current.Request.QueryString[QUERYSTRING_CHAPTERID];
                    BookInfo objBookInfoSession = ((BookInfo)HttpContext.Current.Session[SESSION_TREEVIEWDATAOBJECT]);
                    if (objBookInfoSession != null)
                    {
                        strBookID = objBookInfoSession.BookID;
                    }
                }
            }
            strParentSiteURL = SPContext.Current.Site.Url.ToString();
            objBookInfo = objWellBookBLL.SetBookDetailDataObject(strParentSiteURL, strBookID, BOOKACTION_PRINT, false,objPrintOptions);
            objChapterInfo = objWellBookBLL.SetChapterDetails(strParentSiteURL, strChapterIDForPage, false);
            if (objBookInfo != null)
            {
                if (objChapterInfo != null)
                {
                    strPageIds = new StringBuilder();
                    strPageIds.Append(strSelectedPageID);
                    strPageIds.Append(strSplitter);
                    arlPageDetails = objWellBookBLL.SetSelectedPageInfo(strParentSiteURL, strPageIds.ToString(), objChapterInfo.ActualAssetValue, objChapterInfo.ColumnName);
                    if (arlPageDetails != null && arlPageDetails.Count > 0)
                    {
                        objChapterInfo.PageInfo = arlPageDetails;
                        objBookInfo.PageCount = arlPageDetails.Count;
                    }
                    arlChapterCollection.Add(objChapterInfo);
                }
                if (arlChapterCollection != null && arlChapterCollection.Count > 0)
                {
                    objBookInfo.Chapters = arlChapterCollection;
                }
                xmlWellBookDetails = objCommonBLL.CreateWellBookDetailXML(objBookInfo);
            }
            string strSiteURL = strParentSiteURL;

            strSiteURL = GetSslURL(strSiteURL);

            PDFServiceSPProxy objPDFService;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                objPDFService = new PDFServiceSPProxy();
                objPDFService.PreAuthenticate = true;
                SetUserNameDetailsforWebService();
                objPDFService.Credentials = new NetworkCredential(strWebServiceUserName, strWebServicePassword, strWebServiceDomain);
                PdfBLL objPdfBLL = new PdfBLL();
                objPdfBLL.PrintLog(strSiteURL, string.Format("WebService URL : {0}", objPDFService.Url), "Type I Page", "WebService URL");
                if (xmlWellBookDetails != null)
                {
                    string strBookName = xmlWellBookDetails.DocumentElement.Attributes["BookName"].Value.ToString();
                    string strRequestID = Guid.NewGuid().ToString();
                    string strDocumentURLTemp = PortalConfiguration.GetInstance().GetKey("DWBPrintNetworkPath") + string.Format("{0}_{1}", strBookName, strRequestID) + ".pdf";
                    UpdatePagePrintDetails(strRequestID, strDocumentURLTemp, strSiteURL, "temp");
                    intPrintedDocID = objPDFService.GeneratePDFDocument(xmlWellBookDetails.DocumentElement, strParentSiteURL, strRequestID);
                    strDocumentURL = strSiteURL + "/Pages/eWBPDFViewer.aspx?mode=page&requestID=" + strRequestID;
                }
            });
            return 1;
        }
        /// <summary>
        /// Publishes the Well book.
        /// </summary>
        /// <param name="rowId">The book id.</param>
        private void Publish(int rowId)
        {
            WellBookBLL objWellBook = new WellBookBLL();
            CommonBLL objCommonBLL = new CommonBLL();
            string strActionPerformed = string.Empty;
            string strAlertMessage = string.Empty;

            /// Validate the new book name is not already exists in DWB Books list
            if (!CheckDuplicateName(txtNewBookName.Text.Trim(), DWBTITLECOLUMN, DWBBOOKLIST))
            {
                PrintOptions objPrintOptions = new PrintOptions();
                objPrintOptions.IncludeStoryBoard = false;
                objPrintOptions.IncludePageTitle = true;
                objPrintOptions.IncludeBookTitle = true;
                objPrintOptions.IncludeTOC = true;
                System.Xml.XmlDocument objDWBBookXML = objWellBook.GenerateDWBBookXML(strParentSiteURL, rowId, BOOKACTIONPUBLISH, true,objPrintOptions);

                string strSiteURL = strParentSiteURL;
                SslRequiredWebPart objSslRequired = new SslRequiredWebPart();

                strSiteURL = objSslRequired.GetSslURL(strSiteURL);

                string strBookName = objDWBBookXML.DocumentElement.Attributes["BookName"].Value.ToString();
                string strRequestID = Guid.NewGuid().ToString();
                string strCurrentUser = GetUserName();
                string strLiveBookName = txtNewBookName.Text.Trim();
                UpdateDWBBookPrintDetails(strCurrentUser, strRequestID, strBookName, strLiveBookName, objDWBBookXML, rowId);
                TerminateLiveBook(rowId, DWBBOOKLIST);
                pnlPublishBook.Visible = false;
                strAlertMessage = objCommonBLL.GetAlertMessage(strParentSiteURL, "Publish");
                this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "documentprinted", "alert(' " + strAlertMessage + "');window.close();", true);
            }
            else
            {
                ExceptionBlock.Visible = true;
                lblException.Visible = true;
                lblException.Text = BOOKTITLEEXISTSMESSAGE;
            }
        }