/// <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);
            }
        }
Example #2
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);
            }
        }
        /// <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");
            }
        }