Пример #1
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);
            }
        }
Пример #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);
            }
        }
Пример #3
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");
            }
        }
Пример #4
0
        /// <summary>
        /// Generates the book.
        /// </summary>
        /// <param name="xmldocCriteria">The xmldoc criteria.</param>
        public int GenerateBook(XPathDocument xpDocument, String strContext)
        {
            try
            {
                LicensingManager.LicenseKey = PortalConfiguration.GetInstance().FindWebServiceKey("WinnovativeLicenseKey", strContext,true);
                objPdfhelper = new PDFHelper();
                objPdfBLL = new PdfBLL();
                objBookTOC = new WellBookTOC();
                blnIsTOCApplicable = new Boolean();
                ///Once Book Title is obtained get the First Page of PDF ready with Book Title and
                ///Current Date and time Below it.
                PDFDocument = new Document();

                LibraryName = objPdfBLL.GetAttributeBookInfo(xpDocument, "Type");
                if (LibraryName.Equals("pdf"))
                    LibraryName = Constant.LISTPUBLISHED;
                else if (LibraryName.Equals("print"))
                    LibraryName = Constant.LISTPRINTED;
                blnIsTOCApplicable = Convert.ToBoolean(objPdfBLL.GetAttributeBookInfo(xpDocument, "IsTOCApplicable"));
                blnIsStoryBoardApplicable = Convert.ToBoolean(objPdfBLL.GetAttributeBookInfo(xpDocument, "IsStoryBoardApplicable"));
                blnIsPageTitleApplicable = Convert.ToBoolean(objPdfBLL.GetAttributeBookInfo(xpDocument, "IsPageTitleApplicable"));
                objPdfhelper.PrintLog(strContext, "PDF generation for {" + objPdfBLL.GetAttributeBookInfo(xpDocument, "BookName") + " }is Started.Calling GenerateTOC to generate PDF", "BookDetails.GenerateBook", "BeforeUploading");

                objBookTOC.GenerateTOC(PDFDocument, xpDocument, strContext, blnIsTOCApplicable, blnIsStoryBoardApplicable, blnIsPageTitleApplicable);
                if ((Convert.ToBoolean(objPdfBLL.GetAttributeBookInfo(xpDocument, "IsBookTitleApplicable"))))
                {
                    objPdfhelper.AddBookTitle(PDFDocument, xpDocument, blnIsTOCApplicable, LibraryName);
                }

                PDFDocument.CompressionLevel = CompressionLevel.BestCompression;
                objPdfhelper.PrintLog(strContext, "PDF for {" + objPdfBLL.GetAttributeBookInfo(xpDocument, "BookName") + " }is generated.Calling UploadPublishedDocument to upload to document library", "BookDetails.GenerateBook", "BeforeUploading");

                intResult = objPdfBLL.UploadPublishedDocument(strContext, objPdfBLL.GetAttributeBookInfo(xpDocument, "BookID"), PDFDocument, objPdfBLL.GetAttributeBookInfo(xpDocument, "BookName"), LibraryName);
                if (intResult > 0)
                {
                    objPdfhelper.PrintLog(strContext, "PDF for {" + objPdfBLL.GetAttributeBookInfo(xpDocument, "BookName") + "} is uploaded successfully.", "BookDetails.GenerateBook", "AfterUploading");

                }
                else
                {
                    objPdfhelper.PrintLog(strContext, "PDF for {" + objPdfBLL.GetAttributeBookInfo(xpDocument, "BookName") + "} is NOT uploaded successfully.", "BookDetails.GenerateBook", "AfterUploading");

                }
                return intResult;
            }
            catch (Exception ex)
            {
                objPdfhelper.PrintLog(strContext, ex.Message, "BookDetails.GenerateBook", "Exception");
                objPdfhelper.PrintLog(strContext, ex.StackTrace, "BookDetails.GenerateBook", "Exception");
                throw;
            }
            finally
            {
                PDFDocument.Close();
            }
        }
Пример #5
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;
        }
Пример #6
0
        /// <summary>
        /// Prints the Book/Chapter/Page.
        /// </summary>
        /// <param name="objPrintOptions">The PrintOptions object.</param>
        /// <param name="controlType">Type of the control.</param>
        /// <param name="mode">The mode.</param>
        /// <returns></returns>
        protected int Print(DWBDataObjects.PrintOptions objPrintOptions, string controlType, string mode)
        {
            bool blnUserControlFound = false;
            Telerik.Web.UI.RadTreeView trvWellBook = null;
            WellBookBLL objWellBookBLL;
            StringBuilder strPageIds;
            ArrayList arlPageDetails;
            ArrayList arlChapterCollection;
            string strSplitter = ";";
            DWBDataObjects.BookInfo objBookInfo;
            DWBDataObjects.ChapterInfo objChapterInfo;
            XmlDocument xmlWellBookDetails = null;
            string intPrintedDocID = string.Empty;
            int intNoOfPrintedPages = 0;
            bool blnIsPagePrint = false;
            bool blnIsChapterPrint = false;
            bool blnIsBookPrint = false;

            SetUserNameDetailsforWebService();
            if (string.Compare(mode, VIEW, true) != 0)
            {
                if (this.Parent.Parent.GetType().Equals(typeof(SPWebPartManager)))
                {
                    foreach (Control ctrlWebPart in this.Parent.Parent.Controls)
                    {
                        if (ctrlWebPart.GetType().Equals(typeof(TreeViewControl)))
                        {
                            Control ctrlTreeView = ctrlWebPart.FindControl("RadTreeView1");
                            if (ctrlTreeView != null && ctrlTreeView.GetType().Equals(typeof(RadTreeView)))
                            {
                                trvWellBook = (RadTreeView)ctrlWebPart.FindControl("RadTreeView1");
                                blnUserControlFound = true;
                                break;
                            }
                            if (blnUserControlFound)
                            {
                                break;
                            }
                        }
                    }
                }
            }

            objWellBookBLL = new WellBookBLL();
            objCommonBLL = new CommonBLL();
            arlChapterCollection = new ArrayList();
            /// 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.

            //Added By Gopinath
            //Date : 10/11/2010
            //Description : Making Filter CAML query for Filter options which are loaded from PrintByPageType

            #region Building CAML Query using Print Options
            StringBuilder sbFilterCAMLQuery = new StringBuilder();

            //Check for Current User as Page Owner
            string strCurrentUser = string.Empty;
            object ObjPrivileges = CommonUtility.GetSessionVariable(this.Page, enumSessionVariable.UserPrivileges.ToString());
            DWBDataObjects.Privileges objStoredPriviledges = null;
            if (ObjPrivileges != null)
            {
                objStoredPriviledges = (DWBDataObjects.Privileges)ObjPrivileges;
            }
            strCurrentUser = GetUserName();

            #region CAML Query
            if (objStoredPriviledges != null && objStoredPriviledges.SystemPrivileges != null)
            {
                if (!objStoredPriviledges.SystemPrivileges.PageOwner)
                {
                    //Only for BO/AD
                    if ((!objPrintOptions.PrintMyPages && objPrintOptions.IncludeFilter) || (objPrintOptions.PrintMyPages && objPrintOptions.IncludeFilter))
                    {
                        //Page Name

                        if ((!string.Equals(objPrintOptions.PageName, "all")) && (!string.IsNullOrEmpty(objPrintOptions.PageName)))
                            sbFilterCAMLQuery.Append(@"<Eq><FieldRef Name='Page_Name' /><Value Type='Text'>" + objPrintOptions.PageName + "</Value></Eq>");
                        else
                            sbFilterCAMLQuery.Append(@"<IsNotNull><FieldRef Name='Page_Name' /></IsNotNull>");

                        if (string.Equals(objPrintOptions.PageName, "all")) //If page name selected then no need to consider discipline and page type.
                        {
                            //Discipline
                            if ((!string.Equals(objPrintOptions.Discipline, "all")) && (!string.IsNullOrEmpty(objPrintOptions.Discipline)))
                                sbFilterCAMLQuery.Append(@"<Eq><FieldRef Name='Discipline' /><Value Type='Text'>" + objPrintOptions.Discipline + "</Value></Eq>");
                            else
                                sbFilterCAMLQuery.Append(@"<IsNotNull><FieldRef Name='Discipline' /></IsNotNull>");
                        }
                        else
                        {
                            sbFilterCAMLQuery.Append(@"<IsNotNull><FieldRef Name='Discipline' /></IsNotNull>");
                        }
                        sbFilterCAMLQuery.Append("</And>");
                        sbFilterCAMLQuery.Insert(0, "<And>");

                        //Page Type
                        if (string.Equals(objPrintOptions.PageName, "all")) //If page name selected then no need to consider discipline and page type.
                        {
                            #region Page Type
                            //PageType contain values 0,1,2
                            if (!string.Equals(objPrintOptions.PageType, "none"))
                            {
                                char[] chSplitterComma = { ',' };
                                string[] strPageType = objPrintOptions.PageType.Split(chSplitterComma);
                                if (strPageType != null && strPageType.Length > 0)
                                {
                                    for (int index = 0; index < strPageType.Length; index++)
                                    {
                                        switch (strPageType[index])
                                        {
                                            case "0":
                                                {
                                                    sbFilterCAMLQuery.Append(@"<Eq><FieldRef Name='Connection_Type' /> <Value Type='Text'>1 - Automated</Value></Eq></And>");
                                                    sbFilterCAMLQuery.Insert(0, "<And>");
                                                }
                                                break;
                                            case "1":
                                                {
                                                    sbFilterCAMLQuery.Append(@"<Eq><FieldRef Name='Connection_Type' /> <Value Type='Text'>2 - Published Document</Value></Eq></And>");
                                                    sbFilterCAMLQuery.Insert(0, "<And>");
                                                }
                                                break;
                                            case "2":
                                                {
                                                    sbFilterCAMLQuery.Append(@"<Eq><FieldRef Name='Connection_Type' /> <Value Type='Text'>3 - User Defined Document</Value></Eq></And>");
                                                    sbFilterCAMLQuery.Insert(0, "<And>");
                                                }
                                                break;
                                        }
                                    }
                                }
                            }
                            #endregion Page Type
                        }

                        //Signed Off
                        if ((!string.Equals(objPrintOptions.SignedOff, "both")) && (!string.IsNullOrEmpty(objPrintOptions.SignedOff)))
                        {
                            sbFilterCAMLQuery.Append(@"<Eq><FieldRef Name='Sign_Off_Status' /> <Value Type='Choice'>" + objPrintOptions.SignedOff + "</Value></Eq> </And>");
                            sbFilterCAMLQuery.Insert(0, "<And>");
                        }

                        //Empty Pages
                        if ((!string.Equals(objPrintOptions.EmptyPages, "both")) && (!string.IsNullOrEmpty(objPrintOptions.EmptyPages)))
                        {
                            sbFilterCAMLQuery.Append(@"<Eq><FieldRef Name='Empty' /> <Value Type='Choice'>" + objPrintOptions.EmptyPages + "</Value></Eq> </And>");
                            sbFilterCAMLQuery.Insert(0, "<And>");
                        }

                        if (objPrintOptions.PrintMyPages)
                        {
                            sbFilterCAMLQuery.Append(@"<Eq><FieldRef Name='Owner' /><Value Type='Text'>" + strCurrentUser + "</Value></Eq>");
                            sbFilterCAMLQuery.Append("</And>");
                            sbFilterCAMLQuery.Insert(0, "<And>");
                        }
                        //Open & Close <Where></Where>
                        sbFilterCAMLQuery.Append(@"</Where>");
                        sbFilterCAMLQuery.Insert(0, "<Where>");
                    }
                    else if (objPrintOptions.PrintMyPages && !objPrintOptions.IncludeFilter)
                    {
                        sbFilterCAMLQuery.Append(@"<Eq><FieldRef Name='Owner' /><Value Type='Text'>" + strCurrentUser + "</Value></Eq>");
                        //Open & Close <Where></Where>
                        sbFilterCAMLQuery.Append(@"</Where>");
                        sbFilterCAMLQuery.Insert(0, "<Where>");
                    }
                }
                // For PageOwner
                else if (objPrintOptions.PrintMyPages && objPrintOptions.IncludeFilter)
                {
                    sbFilterCAMLQuery.Append(@"<Eq><FieldRef Name='Owner' /><Value Type='Text'>" + strCurrentUser + "</Value></Eq>");
                    //Open & Close <Where></Where>
                    sbFilterCAMLQuery.Append(@"</Where>");
                    sbFilterCAMLQuery.Insert(0, "<Where>");
                }
            }
            #endregion CAML Query
            //Retrive only Page Id
            string strViewFields = "<FieldRef Name='ID' />";

            #endregion Building CAML Query using Print Options
            if (sbFilterCAMLQuery != null && sbFilterCAMLQuery.Length > 0)
            {
                strPageIdList = new List<string>(); //Declared Globally
                DataTable dtPageIds = objCommonBLL.ReadList(strParentSiteURL, CHAPTERPAGESMAPPINGLIST, sbFilterCAMLQuery.ToString(), strViewFields);
                if (dtPageIds != null && dtPageIds.Rows.Count > 0)
                {
                    foreach (DataRow drPageId in dtPageIds.Rows)
                    {
                        strPageIdList.Add(drPageId[0].ToString());
                    }
                }
            }

            ///End Gopinath code.

            switch (controlType)
            {
                case WELLBOOKVIEWERCONTROLBOOK:
                    {
                        #region BOOK PRINT
                        blnIsBookPrint = true;
                        if (trvWellBook != null)
                        {
                            if (trvWellBook.SelectedNode == null)
                            {
                                trvWellBook.Nodes[0].Selected = true;
                            }
                            if (trvWellBook.SelectedNode.Level == 0)
                            {
                                objBookInfo = objWellBookBLL.SetBookDetailDataObject(strParentSiteURL, trvWellBook.SelectedNode.Value, BOOKACTIONPRINT, false, objPrintOptions);
                                if (trvWellBook.CheckedNodes.Count > 0)
                                {
                                    foreach (RadTreeNode chapterNode in trvWellBook.SelectedNode.Nodes)
                                    {
                                        if (chapterNode.Checked)
                                        {
                                            objChapterInfo = CreateChapterInfo(chapterNode);
                                            if (objChapterInfo != null)
                                                arlChapterCollection.Add(objChapterInfo);
                                            if (objChapterInfo != null && objChapterInfo.PageInfo != null)
                                            {
                                                intNoOfPrintedPages += objChapterInfo.PageInfo.Count;
                                            }
                                        }
                                    }
                                    objBookInfo.Chapters = arlChapterCollection;
                                    objBookInfo.PageCount = intNoOfPrintedPages;
                                    if (objBookInfo.Chapters.Count == 0)
                                        objBookInfo = null;
                                    xmlWellBookDetails = objCommonBLL.CreateWellBookDetailXML(objBookInfo);
                                }
                                else
                                {
                                    this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "documentnotprinted", ALERTNOCHAPTERNODECHECKED, true);
                                }

                            }
                        }
                        #endregion BOOK PRINT
                        break;
                    }
                case WELLBOOKVIEWERCONTROLCHAPTER:
                    {
                        #region CHAPTER PRINT
                        blnIsChapterPrint = true;
                        if (trvWellBook != null)
                        {
                            objBookInfo = objWellBookBLL.SetBookDetailDataObject(strParentSiteURL, trvWellBook.SelectedNode.ParentNode.Value, BOOKACTIONPRINT, false, objPrintOptions);
                            if (trvWellBook.SelectedNode.Level == 1)
                            {
                                if (trvWellBook.SelectedNode.Checked)
                                {
                                    objChapterInfo = CreateChapterInfo(trvWellBook.SelectedNode);
                                    if (objChapterInfo != null)
                                        arlChapterCollection.Add(objChapterInfo);

                                    objBookInfo.Chapters = arlChapterCollection;
                                    if (objBookInfo.Chapters.Count == 0)
                                        objBookInfo = null;
                                    xmlWellBookDetails = objCommonBLL.CreateWellBookDetailXML(objBookInfo);
                                }
                                else
                                {
                                    this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "documentnotprinted", ALERTNOPAGENODECHECKED, true);
                                }
                            }
                        }
                        #endregion CHAPTER PRINT
                        break;
                    }
                case WELLBOOKVIEWERCONTROLPAGE:
                    {
                        #region PAGE PRINT
                        blnIsPagePrint = true;
                        string strPageID = string.Empty;
                        string strChapterID = string.Empty;
                        string strBookID = string.Empty;
                        if (trvWellBook != null)
                        {
                            if (trvWellBook.SelectedNode.Level == 2)
                            {
                                strBookID = trvWellBook.SelectedNode.ParentNode.ParentNode.Value;
                                strChapterID = trvWellBook.SelectedNode.ParentNode.Value;
                                strPageID = trvWellBook.SelectedNode.Value;
                            }
                        }
                        else if (string.Compare(mode, VIEW, true) == 0)
                        {
                            strPageID = HttpContext.Current.Request.QueryString[PAGEIDQUERYSTRING];
                            strChapterID = HttpContext.Current.Request.QueryString[CHAPTERIDQUERYSTRING];
                            DWBDataObjects.BookInfo objBookInfoSession = ((DWBDataObjects.BookInfo)HttpContext.Current.Session[SESSIONTREEVIEWDATAOBJECT]);
                            if (objBookInfoSession != null)
                            {
                                strBookID = objBookInfoSession.BookID;
                            }
                        }
                        objBookInfo = objWellBookBLL.SetBookDetailDataObject(strParentSiteURL, strBookID, BOOKACTIONPRINT, false, objPrintOptions);
                        objChapterInfo = objWellBookBLL.SetChapterDetails(strParentSiteURL, strChapterID, false);
                        if (objChapterInfo != null)
                        {
                            strPageIds = new StringBuilder();
                            strPageIds.Append(strPageID);
                            strPageIds.Append(strSplitter);
                            arlPageDetails = objWellBookBLL.SetSelectedPageInfo(strParentSiteURL, strPageIds.ToString(), objChapterInfo.ActualAssetValue, objChapterInfo.ColumnName);
                            if (arlPageDetails != null && arlPageDetails.Count > 0)
                            {
                                objChapterInfo.PageInfo = arlPageDetails;
                            }
                            arlChapterCollection.Add(objChapterInfo);
                        }
                        if (arlChapterCollection != null && arlChapterCollection.Count > 0)
                        {
                            objBookInfo.Chapters = arlChapterCollection;
                        }
                        xmlWellBookDetails = objCommonBLL.CreateWellBookDetailXML(objBookInfo);
                        #endregion PAGE PRINT
                        break;
                    }
                default:
                    break;
            }
            if (xmlWellBookDetails == null)
                {
                    return -1;
                }
            string strSiteURL = strParentSiteURL;
            SslRequiredWebPart objSslRequired = new SslRequiredWebPart();

            strSiteURL = objSslRequired.GetSslURL(strSiteURL);

            PDFServiceSPProxy objPDFService;
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                objPDFService = new PDFServiceSPProxy();
                objPDFService.PreAuthenticate = true;
                objPDFService.Credentials = new NetworkCredential(strWebServiceUserName, strWebServicePassword, strWebServiceDomain);
                PdfBLL objPdfBLL = new PdfBLL();

                if (xmlWellBookDetails != null)
                {
                    try
                    {
                        string strBookName = xmlWellBookDetails.DocumentElement.Attributes["BookName"].Value.ToString();
                        string strRequestID = Guid.NewGuid().ToString();
                        if (blnIsPagePrint)
                        {
                            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;
                        }
                        else if (blnIsChapterPrint)
                        {
                            UpdateDWBChapterPrintDetails(strCurrentUser, strRequestID, strBookName);
                            //strCurrentUser, strRequestID, e-MailID, document URL
                            //intPrintedDocID = objPDFService.GeneratePDFDocument(xmlWellBookDetails.DocumentElement, strParentSiteURL, strRequestID);
                            AsyncCallback asyncCall = new AsyncCallback(CallbackMethod);
                            objPDFService.Timeout = System.Threading.Timeout.Infinite;
                            objPDFService.BeginGeneratePDFDocument(xmlWellBookDetails.DocumentElement, strParentSiteURL, strRequestID, asyncCall, objPDFService);
                        }
                        else if (blnIsBookPrint)
                        {
                            UpdateDWBBookPrintDetails(strCurrentUser, strRequestID, strBookName, xmlWellBookDetails);
                        }
                    }
                    catch (SoapException)
                    {
                        throw;
                    }
                }
            });
            return 1;
        }
Пример #7
0
        /// <summary>
        /// Generates the TOC.
        /// </summary>
        /// <param name="docPDF">The doc PDF.</param>
        /// <param name="xmlPathDocumentCriteria">The XML path document criteria.</param>
        internal void GenerateTOC(Document docPDF, XPathDocument xmlPathDocumentCriteria, String context,Boolean isTOCApplicable, Boolean isStoryBoardApplicable, bool isPageTitleApplicable)
        {
            objpdfHelper = new PDFHelper();
            try
            {
                strBTOC = new StringBuilder();

                objpdfBLL = new PdfBLL();
                XPathNavigator objXPNavigator = xmlPathDocumentCriteria.CreateNavigator();
                // Set up namespace manager for XPath
                XmlNamespaceManager objXMLnameSpaces = new XmlNamespaceManager(objXPNavigator.NameTable);
                objXMLnameSpaces.AddNamespace("PDF", "http://www.shell.com/");

                if (isTOCApplicable)
                {
                    Int32 intPgCount = Convert.ToInt32(objpdfBLL.GetAttributeBookInfo(xmlPathDocumentCriteria, "PageCount"));
                    Int32 TOCPageCount = intPgCount / 63;
                    if (!(intPgCount % 63 == 0))
                        TOCPageCount++;
                    for (int pageCounter = 0; pageCounter < TOCPageCount; pageCounter++)
                    {
                        docPDF.Pages.AddNewPage(PageSize.A4, new Margins(40), PageOrientation.Portrait);

                    }
                    strBTOC.Append(strTOCBeginHTML);
                }
                XPathNodeIterator chapternodes = objXPNavigator.Select("/BookInfo/Chapter");
                while (chapternodes.MoveNext())//chapters
                {
                    if (isTOCApplicable)
                    {
                        strBTOC.AppendFormat(@"<tr><td colspan=""2"" >{0}</td><td ></td><td ></td></tr>",
                                chapternodes.Current.GetAttribute("ChapterTitle", objXMLnameSpaces.DefaultNamespace));
                    }
                    //Add page for Chapter Title if is Printable
                    if (Convert.ToBoolean(chapternodes.Current.GetAttribute("IsPrintable", objXMLnameSpaces.DefaultNamespace)))
                    {
                        objpdfHelper.AddChapterTitlePage(docPDF, chapternodes.Current.GetAttribute("ChapterTitle", objXMLnameSpaces.DefaultNamespace));
                    }
                    XPathNodeIterator pagenodes = chapternodes.Current.Select("PageInfo");
                    while (pagenodes.MoveNext())//pages in a chapter
                    {
                        if (isTOCApplicable)
                        {
                            //strBHyphen = new StringBuilder();
                            strPageTitle = pagenodes.Current.GetAttribute("PageTitle", objXMLnameSpaces.DefaultNamespace);
                            //for (int counter = 0; counter < (113 - strPageTitle.Length); counter++)
                            //{
                            //    strBHyphen.Append("-");
                            //}
                            strBTOC.AppendFormat(@"<tr>
                                        <td style=""width:5%""></td>
                                        <td style=""width:95%"" align=""right""><font style=""float:left"">{0}</font></td>
                                   </tr>",
                                                  strPageTitle);

                        }
                        objbkpage = new BookPage();
                        objbkpage.GeneratePDFPage(docPDF, pagenodes.Current, context, isPageTitleApplicable);
                        if (isStoryBoardApplicable)
                        {
                            objbkpage.GeneratePDFPageStoryBoard(docPDF, pagenodes.Current, context);
                        }
                    }
                    objpdfHelper.PrintLog(context, string.Format("Chapter {0} is created", chapternodes.Current.GetAttribute("ChapterTitle", objXMLnameSpaces.DefaultNamespace)), "WellBookTOC.GenerateTOC", "ChapterCreation");
                }
                if (isTOCApplicable)
                {
                    strBTOC.Append(strTOCEndHTML);
                    objpdfHelper.AddHTMLtoPDF(docPDF, Convert.ToString(strBTOC), context, true);
                }
            }
            catch (Exception ex)
            {
                objpdfHelper.PrintLog(context, ex.Message, "WellBookTOC.GenerateTOC", "Exception");
                objpdfHelper.PrintLog(context, ex.StackTrace, "WellBookTOC.GenerateTOC", "Exception");
                throw;
            }
        }
Пример #8
0
        /// <summary>
        /// Sets the basic attribute.
        /// </summary>
        /// <param name="xpatpageNode">The xpatpage node.</param>
        /// <returns>ArrayList</returns>
        private ArrayList SetBasicAttribute(string[] strarrPageDetails)
        {
            objAttribute = new Attributes();
            arlAttribute = new ArrayList();
            arrAttributeValue = new ArrayList();
            pdfBLL = new PdfBLL();

            switch (strarrPageDetails[4])
            {
                case "Well":
                    objAttribute.Name = "UWI";
                    break;
                case "Wellbore":
                    objAttribute.Name = "UWBI";
                    break;
                case "Field":
                    objAttribute.Name = "Field Name";
                    break;
            }
            arrAttributeValue.Add(SetValue(strarrPageDetails[2]));
            objAttribute.Value = arrAttributeValue;
            objAttribute.Operator = strarrPageDetails[1];
            arlAttribute.Add(objAttribute);
            return arlAttribute;
        }
Пример #9
0
        /// <summary>
        /// Adds the type1 to PDF doc.
        /// </summary>
        /// <param name="docPDF">The doc PDF.</param>
        /// <param name="xpatpageNode">The xpatpage node.</param>
        internal string AddType1toPDFDoc(string[] strarrPageDetails, string context)
        {
            strWr = new StringWriter();
            objFactory = new ServiceProvider();
            objreqinf = new RequestInfo();
            xmlDocSearchResult = new XmlDocument();
            pdfBLL = new PdfBLL();
            XmlTextReader xmlTextReader = null;
            AbstractController objMossController = null;
            objMossController = objFactory.GetServiceManager(MOSSSERVICE);
            objreqinf.Entity = SetEntity(strarrPageDetails);
            if (!strarrPageDetails[3].ToUpper().Equals("WELLHISTORY"))
            {
                objQueryServiceController = objFactory.GetServiceManager(Constant.REPORTSERVICE, context);
                xmlDocSearchResult = objQueryServiceController.GetSearchResults(objreqinf, -1, strarrPageDetails[3], null, 0);
            }
            else
            {
                objQueryServiceController = objFactory.GetServiceManager(Constant.EVENTSERVICE, context);
                xmlDocSearchResult = objQueryServiceController.GetSearchResults(objreqinf, -1, strarrPageDetails[3], null, 0);
            }
            switch (strarrPageDetails[3].ToUpper())
            {
                case "PREPRODRFT":
                    xmlTextReader = ((MOSSServiceManager)objMossController).GetXSLTemplate("PDFTabular Results", context);
                    break;
                case "WELLBOREHEADER":
                    xmlTextReader = ((MOSSServiceManager)objMossController).GetXSLTemplate("WellboreHeader Datasheet", context);
                    break;
                case "WELLHISTORY":
                    xmlTextReader = ((MOSSServiceManager)objMossController).GetXSLTemplate("WellHistory DataSheet", context);
                    break;
                case "WELLSUMMARY":
                    xmlTextReader = ((MOSSServiceManager)objMossController).GetXSLTemplate("WellSummary", context);
                    break;
            }
            strWr = pdfBLL.TransformSearchResultsToXSL(xmlDocSearchResult, xmlTextReader, string.Empty, string.Empty,
              string.Empty, strarrPageDetails[3], 100, "Report", 100, context);

            return Convert.ToString(strWr.GetStringBuilder());
        }
Пример #10
0
        /// <summary>
        /// Adds the book title.
        /// </summary>
        /// <param name="docPDF">The doc PDF.</param>
        /// <param name="strBooktitle">The STR booktitle.</param>
        internal void AddBookTitle(Document docPDF, XPathDocument xmlDocumentCriteria, Boolean IsTOCApplicable, string type)
        {
            strbookHeader = string.Empty;
            strbookHeader = "DIGITAL WELL BOOK _____________________________________________________";
            try
            {
                pdfBLL = new PdfBLL();
                strbookTitle = pdfBLL.GetAttributeBookInfo(xmlDocumentCriteria, "BookName");

                if (IsTOCApplicable)
                {
                    pdfPage = docPDF.Pages[0];
                }
                else
                {
                    docPDF.InsertPage(0, PageSize.A4, new Margins(), PageOrientation.Portrait);
                    pdfPage = docPDF.Pages[0];
                }

                #region Header for Book Title Page
                //Generate Text
                // Create a Bold .NET font of 10 points
                System.Drawing.Font fntVerdanaHeadaer = new System.Drawing.Font("Verdana", 15,
                            System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
                // Create the PDF fonts based on the .NET true type fonts
                PdfFont newfntVerdanaHeadaer = docPDF.AddFont(fntVerdanaHeadaer);

                // Add Title elements to the document
                TextElement PageTitleVerdanaHeadaer = new TextElement(3, 20, strbookHeader, newfntVerdanaHeadaer);
                PageTitleVerdanaHeadaer.TextAlign = HorizontalTextAlign.Left;
                pdfPage.AddElement(PageTitleVerdanaHeadaer);
                #endregion

                //Generate Text
                #region bOOK tITLE
                System.Drawing.Font ttfFontBold = new System.Drawing.Font("Verdana", 30,
                                System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
                // Create the PDF fonts based on the .NET true type fonts
                PdfFont newVerdanaFontBold = docPDF.AddFont(ttfFontBold);

                // Add Title elements to the document
                TextElement TypeTitle = new TextElement(3, 300, strbookTitle, newVerdanaFontBold);
                TypeTitle.TextAlign = HorizontalTextAlign.Center;
                AddElementResult addTitle = pdfPage.AddElement(TypeTitle);
                #endregion

                ///Generate Text for Book Owner
                #region bOOK oWNER

                System.Drawing.Font fntVerdanaBold = new System.Drawing.Font("Verdana", 20,
                            System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
                // Create the PDF fonts based on the .NET true type fonts
                PdfFont newfntVerdanaBold = docPDF.AddFont(fntVerdanaBold);
                //Add Book Owner to Page
                TextElement TypeVerdanaBold = new TextElement(3, addTitle.EndPageBounds.Bottom + 5,
                                    "Book Owner - " + pdfBLL.GetAttributeBookInfo(xmlDocumentCriteria, "BookOwner"),
                                                        newfntVerdanaBold);
                TypeVerdanaBold.TextAlign = HorizontalTextAlign.Center;
                AddElementResult addOwner = pdfPage.AddElement(TypeVerdanaBold);
                #endregion

                #region Published Date
                System.Drawing.Font ttfFont = new System.Drawing.Font("Verdana", 10,
                                System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
                // Create the PDF fonts based on the .NET true type fonts
                PdfFont newVerdanaFont = docPDF.AddFont(ttfFont);
                TextElement TypeVerdanaDate;
                if (type.Equals("pdf"))
                {
                    TypeVerdanaDate = new TextElement(3, addOwner.EndPageBounds.Bottom + 5, "Published date: " + DateTime.Now.ToString(DATEFORMAT), newVerdanaFont);
                }
                else
                {
                    TypeVerdanaDate = new TextElement(3, addOwner.EndPageBounds.Bottom + 5, "Date: " + DateTime.Now.ToString(DATEFORMAT), newVerdanaFont);
                }
                TypeVerdanaDate.TextAlign = HorizontalTextAlign.Center;
                pdfPage.AddElement(TypeVerdanaDate);
                #endregion
            }
            finally
            {
            }
        }
Пример #11
0
        /// <summary>
        /// Generates the PDF page.
        /// </summary>
        /// <param name="docPDF">The doc PDF.</param>
        /// <param name="xPathNavigator">The x path navigator.</param>
        internal void GeneratePDFPage(Document docPDF, XPathNavigator xpatpageNode,String strContext, bool isPageTitleApplicable)
        {
            objpdfHelper = new PDFHelper();
              try
              {
            strarrPageDetails = new string[5];
            strbHtml = new StringBuilder();
            strPageTitleHtml = new StringBuilder();
            strType1Html = string.Empty;
            objSPfile = null;
            objStream = new MemoryStream();
            XmlNamespaceManager objXMLnameSpaces = new XmlNamespaceManager(xpatpageNode.NameTable);
            objXMLnameSpaces.AddNamespace("PDF", "http://www.shell.com/");
            StrConnectType = xpatpageNode.GetAttribute("ConnectionType", objXMLnameSpaces.DefaultNamespace);

            ///Add First Page
            pdfBLL = new PdfBLL();

            strarrPageDetails[0] = xpatpageNode.GetAttribute("ActualColumnname", objXMLnameSpaces.DefaultNamespace);
            strarrPageDetails[1] = Constant.EQUALS;
            strarrPageDetails[2] = xpatpageNode.GetAttribute("AssetValue", objXMLnameSpaces.DefaultNamespace);
            strarrPageDetails[3] = xpatpageNode.GetAttribute("ReportName", objXMLnameSpaces.DefaultNamespace);
            strarrPageDetails[4] = xpatpageNode.GetAttribute("AssetType", objXMLnameSpaces.DefaultNamespace);
            IntPageId = Convert.ToInt32(xpatpageNode.GetAttribute("PageID", objXMLnameSpaces.DefaultNamespace));
            if (isPageTitleApplicable)
            {
            StrNarrative = pdfBLL.GetNarrative(IntPageId, strContext, Constant.LISTNARRATIVE);
            if (string.IsNullOrEmpty(StrNarrative))
                StrNarrative = "N/A";
            StrSignOffStatus = xpatpageNode.GetAttribute("SignOffStatus", objXMLnameSpaces.DefaultNamespace);
            switch (StrSignOffStatus)
            {
                case "Yes":
                    StrSignOffStatus = "Signed Off";
                    break;
                case "No":
                    StrSignOffStatus = "Not Signed Off";
                    break;
            }
            StrPageOwner = xpatpageNode.GetAttribute("PageOwner", objXMLnameSpaces.DefaultNamespace);
            StrPageTitle = xpatpageNode.GetAttribute("Title", objXMLnameSpaces.DefaultNamespace);
            xpatpageNode.MoveToParent();
            StrAssetValue = xpatpageNode.GetAttribute("AssetValue", objXMLnameSpaces.DefaultNamespace);
            StrPageTitle = StrPageTitle.Replace("$", StrAssetValue);
            #region PageTitleHtml
            strPageTitleHtml.Append(@"<table width=""90%"" align=""center"" style="" font-family:Verdana;font-size:42px;font-weight:bold;"" >
                                      <tr >
                                        <td align=""center"" width=""40%"" style=""padding-right: 8px; height: 600px;"">
                                          <b>");
            strPageTitleHtml.Append(StrPageTitle);
            strPageTitleHtml.Append(@" </b></td>
                                      </tr>
                                      </table>
                                    <table width=""70%"" align=""center"" style="" font-family:Verdana;font-size:20px;
                                        background-color:Black;border:solid 1px Black;"" cellpadding=""2"" cellspacing=""2"" >
                                      <tr style=""background-color:White;"">
                                        <td align=""right"" width=""40%"" style=""padding-right: 8px; height: 21px;"">
                                          <b>Page Owner</b></td>
                                        <td align=""left"" width=""60%"" style=""height: 21px"">
                                          ");
            strPageTitleHtml.Append(StrPageOwner);
            strPageTitleHtml.Append(@" </td>
                                      </tr>
                                      <tr style=""background-color:White;"">
                                        <td align=""right"" style=""padding-right: 8px;"">
                                          <b>Sign Off Status</b></td>
                                        <td align=""left"" >
                                          ");
            strPageTitleHtml.Append(StrSignOffStatus);
            strPageTitleHtml.Append(@"</td>
                                      </tr>
                                      <tr style=""height:100px;background-color:White;"">
                                        <td align=""right"" style=""padding-right: 8px;"" valign=""top"">
                                          <b>Narrative</b></td>
                                        <td align=""left"" valign=""top"">
                                          ");
            strPageTitleHtml.Append(StrNarrative);
            strPageTitleHtml.Append(@"</td>
                                      </tr>
                                  </table>");
            #endregion
            objpdfHelper.AddHTMLtoPDF(docPDF, Convert.ToString(strPageTitleHtml), strContext, false);
            }
            switch (StrConnectType)
            {
              case "1":
              try
              {
                  strType1Html = objpdfHelper.AddType1toPDFDoc(strarrPageDetails, strContext);
                  strbHtml.Append(Constant.HEAD);
                  strbHtml.Append(strType1Html);
                  strbHtml.Append(Constant.END);
                  HtmlToPdfElement htmlToPdfElement;
                  htmlToPdfElement = new HtmlToPdfElement(0, 0, -1, -1, Convert.ToString(strbHtml), HttpContext.Current.Request.Url.ToString());
                  htmlToPdfElement.FitWidth = true;
                  htmlToPdfElement.EmbedFonts = true;
                  htmlToPdfElement.LiveUrlsEnabled = true;
                  htmlToPdfElement.ScriptsEnabled = true;
                  htmlToPdfElement.ActiveXEnabled = true;
                  htmlToPdfElement.PdfBookmarkOptions.TagNames = null;
                  //Add a first page to the document. The next pages will inherit the settings from this page
                  PdfPage page = docPDF.Pages.AddNewPage(PageSize.A4, new Margins(10, 10, 0, 0), PageOrientation.Portrait);
                  page.AddElement(htmlToPdfElement);
              }
              catch (SoapException soapEx)
              {
                  objpdfHelper.AddWarningTitleToNewPDfPage(docPDF,soapEx.Message);
              }
              catch (WebException ex)
              {
                  objpdfHelper.AddWarningTitleToNewPDfPage(docPDF, ex.Message);
              }

            break;
              case "2":
            objSPfile = pdfBLL.DownloadFileFromDocumentLibrary(strContext, Constant.LISTPUBLISHEDDOCUMENTS,
                                                          Convert.ToString(IntPageId));
            objpdfHelper.AddFiletoPDFDoc(docPDF, objSPfile);
            break;
              case "3":
            objSPfile = pdfBLL.DownloadFileFromDocumentLibrary(strContext, Constant.LISTUSERDEFINEDDOCUMENTS,
                                                          Convert.ToString(IntPageId));
            objpdfHelper.AddFiletoPDFDoc(docPDF, objSPfile);
            break;
            }
              }
              catch (Exception ex)
              {
              objpdfHelper.PrintLog(strContext, ex.Message, "BookPage.GeneratePDFPage", "Exception");
              objpdfHelper.PrintLog(strContext, ex.StackTrace, "BookPage.GeneratePDFPage", "Exception");
            throw;
              }
              finally {
            objStream.Dispose();
              }
        }