コード例 #1
0
ファイル: UIHelper.cs プロジェクト: vijaymca/Dotnet
        /// <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;
        }
コード例 #2
0
ファイル: UIHelper.cs プロジェクト: vijaymca/Dotnet
 /// <summary>
 /// Callbacks the method.
 /// </summary>
 /// <param name="asyncResult">The async result.</param>
 private void CallbackMethod(IAsyncResult asyncResult)
 {
     WellBookBLL objBookBLL = null;
     try
     {
         string strResults = string.Empty;
         // Create an instance of the WebService
         objPDFService = (PDFServiceSPProxy)asyncResult.AsyncState;
         strResults = objPDFService.EndGeneratePDFDocument(asyncResult);
         objBookBLL = new WellBookBLL();
         //strDocumentURL = objBookBLL.GetPrintDocumentURL(strResults, strParentSiteURL, strAddress, contextForEmails, "DWB Chapter Print Details");
         objBookBLL.SendEmailToUserOnPrint(strResults, strParentSiteURL, strAddress, contextForEmails);
     }
     catch (SoapException)
     {
         throw;
     }
 }
コード例 #3
0
ファイル: DWBTypeIReports.cs プロジェクト: vijaymca/Dotnet
        /// <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;
        }