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