Beispiel #1
0
        /// <summary>
        /// Transforms the search results to XSL.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="textReader">The text reader.</param>
        /// <param name="pageNumber">The page number.</param>
        /// <param name="sortByColumn">The sort by column.</param>
        /// <param name="sortOrder">The sort order.</param>
        /// <param name="searchType">Type of the search.</param>
        /// <param name="maxRecords">The max records.</param>
        /// <param name="windowTitle">The window title.</param>
        /// <param name="recordCount">The record count.</param>
        /// <param name="activeDiv">The active div.</param>
        protected void TransformSearchResultsToXSL(XmlDocument document, XmlTextReader textReader,
                                                string pageNumber, string sortByColumn, string sortOrder,
                                                string searchType, int maxRecords, string windowTitle, int recordCount, string activeDiv)
        {
            XslTransform xslTransform = null;
            XmlDocument objXmlDocForXSL = null;
            XsltArgumentList xsltArgsList = null;
            XmlNodeList objXmlNodeList = null;
            XPathDocument objXPathDocument = null;
            MemoryStream objMemoryStream = null;
            DateTimeConvertor objDateTimeConvertor = null;

            ServiceProvider objFactory = new ServiceProvider();
            //calls the appropriate factory class from the controller layer.
            objMossController = objFactory.GetServiceManager(MOSSSERVICE);

            int intPageNumber = 0;

            int intRecordCount = 0;
            double dblCurrentPage = 0D;
            string strSortOrder = SORTDEFAULTORDER;
            string strRequestID = string.Empty;
            object objSessionUserPreference = null;

            try
            {
                if(document != null && textReader != null)
                {
                    /// Inititlize the system and custom objects
                    objCommonUtility = new CommonUtility();
                    xslTransform = new XslTransform();
                    objXmlDocForXSL = new XmlDocument();
                    xsltArgsList = new XsltArgumentList();
                    objPreferences = new UserPreferences();
                    objMemoryStream = new MemoryStream();
                    document.Save(objMemoryStream);
                    objMemoryStream.Position = 0;
                    objXPathDocument = new XPathDocument(objMemoryStream);

                    /// Inititlize the XSL
                    objXmlDocForXSL.Load(textReader);
                    xslTransform.Load(objXmlDocForXSL);
                    /// the below condition validates the pageNumber parameter value.
                    if(pageNumber.Length > 0)
                    {
                        intPageNumber = Convert.ToInt32(pageNumber);
                    }
                    /// the below condition validates the sortOrder parameter value.
                    if(sortOrder.Length > 0)
                    {
                        strSortOrder = sortOrder;
                    }
                    objSessionUserPreference = CommonUtility.GetSessionVariable(Page, enumSessionVariable.UserPreferences.ToString());
                    /// get count of records per page from User's Preference if set
                    if(objSessionUserPreference != null)
                    {
                        /// read the User Preferences from the session.
                        objPreferences = (UserPreferences)objSessionUserPreference;
                        if(string.IsNullOrEmpty(strDepthUnit))
                        {
                            strDepthUnit = objPreferences.DepthUnits;
                        }
                        intRecordsPerPage = Convert.ToInt16(objPreferences.RecordsPerPage);
                    }
                    /// Get the Total Record Count
                    objXmlNodeList = document.SelectNodes(XPATH);
                    if(objXmlNodeList != null)
                    {
                        foreach(XmlNode xmlNode in objXmlNodeList)
                        {
                            intRecordCount = Convert.ToInt32(xmlNode.SelectSingleNode("recordcount").InnerXml.ToString());
                            intDetailRecordCount = intRecordCount;
                        }
                    }
                    /// the below condition validates the pageNumber parameter value.
                    if(pageNumber.Length > 0)
                    {
                        dblCurrentPage = Double.Parse(pageNumber);
                        intRecordCount = recordCount; //Added for cashing
                    }
                    /// Added for cashing
                    /// Get the Response ID
                    objXmlNodeList = document.SelectNodes("response");
                    if(objXmlNodeList != null)
                    {
                        foreach(XmlNode xmlNode in objXmlNodeList)
                        {
                            if(xmlNode.Attributes["requestid"] != null)
                            {
                                strRequestID = xmlNode.Attributes["requestid"].Value.ToString();
                            }
                        }
                    }
                    if(sortByColumn == null)
                        sortByColumn = string.Empty;
                    int intColumnsToLock = GetNumberofRecordsToLock(document, RESULTRECORDLOCKXPATH);
                    /// Add the required parameters to the XsltArgumentList object
                    GetDataQualityRange(ref xsltArgsList);

                    objDateTimeConvertor = new DateTimeConvertor();
                    #region DREAM 4.0 - Paging functionality in My Team, My Team Assets and Team Management
                    /// Multi Team Owner Implementation
                    /// Changed By: Yasotha
                    /// Date : 24-Jan-2010
                    /// Modified Lines: 435-438
                    #endregion
                    /// passing parameters to XSL
                    xsltArgsList.AddExtensionObject("urn:DATE", objDateTimeConvertor);
                    xsltArgsList.AddParam(RECORDSPERPAGE, string.Empty, intRecordsPerPage);
                    xsltArgsList.AddParam(PAGENUMBER, string.Empty, intPageNumber);
                    xsltArgsList.AddParam(ACTIVEDIV, string.Empty, activeDiv);
                    xsltArgsList.AddParam(RECORDCOUNT, string.Empty, intRecordCount);
                    xsltArgsList.AddParam(CURRENTPAGENAME, string.Empty, objCommonUtility.GetCurrentPageName(true));
                    xsltArgsList.AddParam(CURRENTPAGE, string.Empty, dblCurrentPage + 1);
                    xsltArgsList.AddParam(MAXPAGES, string.Empty, MAXPAGEVALUE);
                    xsltArgsList.AddParam(SORTCOLUMN, string.Empty, sortByColumn);
                    xsltArgsList.AddParam(SORTORDER, string.Empty, strSortOrder);
                    xsltArgsList.AddParam(COLUMNSTOLOCK, string.Empty, intColumnsToLock);
                    xsltArgsList.AddParam(SEARCHTYPEPARAMETER, string.Empty, searchType);
                    xsltArgsList.AddParam(USERPREFERENCELABEL, string.Empty, strDepthUnit.ToLower());
                    xsltArgsList.AddParam(FORMULAVALUETITLE, string.Empty, PIVALUE);
                    xsltArgsList.AddParam(MAXRECORDS, string.Empty, maxRecords);
                    /// DREAM 3.0 code
                    /// start
                    xsltArgsList.AddParam(COLUMNNAMES, string.Empty, strColNames);
                    xsltArgsList.AddParam(COLUMNDISPLAYSTATUS, string.Empty, strColDisplayStatus);
                    xsltArgsList.AddParam(PRESSUREUNIT, string.Empty, strPressureUnit.ToLowerInvariant());
                    xsltArgsList.AddParam(TEMPERATUREUNIT, string.Empty, strTemperatureUnit);//.ToLowerInvariant());
                    xsltArgsList.AddParam(REORDERDIVHTML, string.Empty, strReorderDivHTML);
                    /// end
                    if(!windowTitle.Equals("My Team Assets"))
                    {
                        xsltArgsList.AddParam(WINDOWTITLE, string.Empty, windowTitle);
                    }
                    else
                    {
                        xsltArgsList.AddParam(WINDOWTITLE, string.Empty, string.Empty);
                    }
                    xsltArgsList.AddParam(REQUESTID, string.Empty, strRequestID);
                    StringBuilder builder = new StringBuilder();
                    StringWriter stringWriter = new StringWriter(builder);
                    xslTransform.Transform(objXPathDocument, xsltArgsList, stringWriter);
                    strResultTable = stringWriter.GetStringBuilder();
                }
                else
                {
                    throw new Exception("Invalid Arguments");
                }
            }
            finally
            {
                if(objMemoryStream != null)
                {
                    objMemoryStream.Close();
                    objMemoryStream.Dispose();
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Transforms the form search results to XSL.
        /// </summary>
        /// <param name="document">The XML document.</param>
        /// <param name="textReader">The XML text reader.</param>
        /// <param name="pageNumber">The page number.</param>
        /// <param name="sortByColumn">The sortby column.</param>
        /// <param name="sortOrder">The sortorder.</param>
        /// <param name="searchType">Type of the search.</param>
        public StringWriter TransformSearchResultsToXSL(XmlDocument document, XmlTextReader textReader,
                                                string pageNumber, string sortByColumn, string sortOrder,
                                                string searchType, int maxRecords, string windowTitle, int recordCount, string context)
        {
            //XslCompiledTransform xslTransform = null;
            XslTransform xslTransform = null;
            XmlDocument objXmlDocForXSL = null;
            XsltArgumentList xsltArgsList = null;
            XmlNodeList objXmlNodeList = null;
            XPathDocument objXPathDocument = null;
            MemoryStream objMemoryStream = null;
            DateTimeConvertor objDateTimeConvertor = null;

            ServiceProvider objFactory = new ServiceProvider();
            objMOSSController = objFactory.GetServiceManager(MOSSSERVICE);
            strwr = new StringWriter();
            int intPageNumber = 0;

            int intRecordCount = 0;
            double dblCurrentPage = 0D;
            string strSortOrder = SORTDEFAULTORDER;
            //string strDepthUnit = string.Empty;
            string strDepthUnit = "metres";
            string strRequestID = string.Empty;

            try
            {
                if (document != null && textReader != null)
                {
                    //Inititlize the system and custom objects
                    objCommonUtility = new CommonUtility();
                    xslTransform = new XslTransform();
                    objXmlDocForXSL = new XmlDocument();
                    xsltArgsList = new XsltArgumentList();

                    objMemoryStream = new MemoryStream();
                    document.Save(objMemoryStream);
                    objMemoryStream.Position = 0;
                    objXPathDocument = new XPathDocument(objMemoryStream);

                    //Inititlize the XSL
                    objXmlDocForXSL.Load(textReader);
                    xslTransform.Load(objXmlDocForXSL);
                    //the below condition validates the pageNumber parameter value.
                    if (pageNumber.Length > 0)
                    {
                        intPageNumber = Convert.ToInt32(pageNumber);
                    }
                    //the below condition validates the sortOrder parameter value.
                    if (sortOrder.Length > 0)
                    {
                        strSortOrder = sortOrder;
                    }

                    //Get the Total Record Count
                    objXmlNodeList = document.SelectNodes(XPATH);
                    if (objXmlNodeList != null)
                    {
                        foreach (XmlNode xmlNode in objXmlNodeList)
                        {
                            intRecordCount = Convert.ToInt32(xmlNode.SelectSingleNode("recordcount").InnerXml.ToString());
                        }
                    }
                    //the below condition validates the pageNumber parameter value.
                    if (pageNumber.Length > 0)
                    {
                        dblCurrentPage = Double.Parse(pageNumber);
                        intRecordCount = recordCount; //Added for cashing
                    }
                    //Added for cashing
                    //Get the Response ID
                    objXmlNodeList = document.SelectNodes("response");
                    if (objXmlNodeList != null)
                    {
                        foreach (XmlNode xmlNode in objXmlNodeList)
                        {
                            strRequestID = xmlNode.Attributes["requestid"].Value.ToString();
                        }
                    }
                    if (sortByColumn == null)
                        sortByColumn = string.Empty;
                    int intColumnsToLock = GetNumberofRecordsToLock(document, RESULTRECORDLOCKXPATH);
                    //Add the required parameters to the XsltArgumentList object
                    GetDataQualityRange(ref xsltArgsList, context);

                    objDateTimeConvertor = new DateTimeConvertor();
                    //xsltArgsList.AddExtensionObject(EXTENSIONOBJECT, objDateTimeConvertor);
                    //xsltArgsList.AddParam(RECORDSPERPAGE, string.Empty, intRecordsPerPage);
                    //xsltArgsList.AddParam(PAGENUMBER, string.Empty, intPageNumber);
                    //xsltArgsList.AddParam(RECORDCOUNT, string.Empty, intRecordCount);
                    //xsltArgsList.AddParam(CURRENTPAGENAME, string.Empty, objCommonUtility.GetCurrentPageName(true));
                    //xsltArgsList.AddParam(CURRENTPAGE, string.Empty, dblCurrentPage + 1);
                    //xsltArgsList.AddParam(MAXPAGES, string.Empty, MAXPAGEVALUE);
                    //xsltArgsList.AddParam(SORTCOLUMN, string.Empty, sortByColumn);
                    //xsltArgsList.AddParam(SORTORDER, string.Empty, strSortOrder);
                    //xsltArgsList.AddParam(COLUMNSTOLOCK, string.Empty, intColumnsToLock);
                    //xsltArgsList.AddParam(SEARCHTYPEPARAMETER, string.Empty, searchType);
                    //xsltArgsList.AddParam(USERPREFERENCELABEL, string.Empty, strDepthUnit.ToLower());
                    //xsltArgsList.AddParam(FORMULAVALUETITLE, string.Empty, PIVALUE);
                    //xsltArgsList.AddParam(MAXRECORDS, string.Empty, maxRecords);
                    //xsltArgsList.AddParam(WINDOWTITLE, string.Empty, windowTitle);
                    //xsltArgsList.AddParam(REQUESTID, string.Empty, strRequestID);
                    //xsltArgsList.AddParam(ISSORTAPPLICABLE, string.Empty, FALSE);

                    xsltArgsList.AddExtensionObject("urn:DATE", objDateTimeConvertor);
                    xsltArgsList.AddParam(RECORDSPERPAGE, string.Empty, intRecordsPerPage);
                    xsltArgsList.AddParam(PAGENUMBER, string.Empty, intPageNumber);
                    xsltArgsList.AddParam(RECORDCOUNT, string.Empty, intRecordCount);
                    xsltArgsList.AddParam(CURRENTPAGENAME, string.Empty, objCommonUtility.GetCurrentPageName(true));
                    xsltArgsList.AddParam(CURRENTPAGE, string.Empty, dblCurrentPage + 1);
                    xsltArgsList.AddParam(MAXPAGES, string.Empty, MAXPAGEVALUE);
                    xsltArgsList.AddParam(SORTCOLUMN, string.Empty, sortByColumn);
                    xsltArgsList.AddParam(SORTORDER, string.Empty, strSortOrder);
                    xsltArgsList.AddParam(COLUMNSTOLOCK, string.Empty, intColumnsToLock);
                    xsltArgsList.AddParam(SEARCHTYPEPARAMETER, string.Empty, searchType);
                    xsltArgsList.AddParam(USERPREFERENCELABEL, string.Empty, strDepthUnit.ToLower());
                    xsltArgsList.AddParam(FORMULAVALUETITLE, string.Empty, PIVALUE);
                    xsltArgsList.AddParam(MAXRECORDS, string.Empty, maxRecords);
                    xsltArgsList.AddParam(WINDOWTITLE, string.Empty, windowTitle);
                    xsltArgsList.AddParam(REQUESTID, string.Empty, strRequestID);

                    xslTransform.Transform(objXPathDocument, xsltArgsList, strwr);
                }
                else
                {
                    throw new Exception("Invalid Arguments");
                }
                return strwr;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (objMemoryStream != null)
                {
                    objMemoryStream.Close();
                    objMemoryStream.Dispose();
                }
            }
        }