Esempio n. 1
0
 /// <summary>
 /// Initializes the user preference.
 /// </summary>
 protected void InitializeUserPreference()
 {
     CommonUtility objCommonUtility = new CommonUtility();
     AbstractController objMossController = null;
     ServiceProvider objFactory = new ServiceProvider();
     string strCurrSiteUrl = SPContext.Current.Site.Url.ToString();
     try
     {
         objUserPreferences = new UserPreferences();
         string strUserId = objCommonUtility.GetUserName();
         objMossController = objFactory.GetServiceManager("MossService");
         //get the user prefrences.
         objUserPreferences = ((MOSSServiceManager)objMossController).GetUserPreferencesValue(strUserId, strCurrSiteUrl);
         CommonUtility.SetSessionVariable(Page, enumSessionVariable.UserPreferences.ToString(), objUserPreferences);
     }
     catch (Exception ex)
     {
         CommonUtility.HandleException(HttpContext.Current.Request.Url.ToString(), ex);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Transforms the EP catalog XML to result table.
        /// </summary>
        /// <param name="responseXml">The response XML.</param>
        /// <param name="textReader">The text reader.</param>
        /// <param name="currentPageNumber">The current 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>
        protected void TransformEPCatalogXmlToResultTable(XmlDocument responseXml, XmlTextReader textReader,
                                              string currentPageNumber, string sortByColumn, string sortOrder,
                                              string searchType)
        {
            XslCompiledTransform xslTransform = null;
            XmlDocument objXmlDocForXSL = null;
            XsltArgumentList xsltArgsList = null;
            DateTimeConvertor objDateTimeConvertor = null;
            object objSessionUserPreference = null;
            int intRecordCount = 0;
            Pagination objPagination = null;
            string strSortXPATH = string.Empty;

            if(responseXml != null && textReader != null)
            {
                xslTransform = new XslCompiledTransform();
                objXmlDocForXSL = new XmlDocument();
                //Inititlize the XSL
                objXmlDocForXSL.Load(textReader);
                xslTransform.Load(objXmlDocForXSL);
                xsltArgsList = new XsltArgumentList();
                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);
                }
                //setting record count
                intRecordCount = GetRecordCountFromResult(responseXml, searchType);

                /// the below condition validates the sortOrder parameter value.
                if(string.IsNullOrEmpty(sortOrder))
                {
                    sortOrder = SORTDEFAULTORDER;
                }
                if(string.IsNullOrEmpty(sortByColumn))
                    sortByColumn = string.Empty;
                strSortXPATH = GetSortXPath(sortByColumn);
                /// Add the required parameters to the XsltArgumentList object
                /// passing parameters to XSL
                ///creating Pagination related parameter
                objPagination = new Pagination(Convert.ToInt32(currentPageNumber), intRecordCount, intRecordsPerPage, false);
                CreatePaginationXslParameter(ref xsltArgsList, objPagination);
                objDateTimeConvertor = new DateTimeConvertor();
                xsltArgsList.AddExtensionObject("urn:DATE", objDateTimeConvertor);
                xsltArgsList.AddParam("SortXPath", string.Empty, strSortXPATH);
                xsltArgsList.AddParam(SORTCOLUMN, string.Empty, sortByColumn);
                xsltArgsList.AddParam(SORTORDER, string.Empty, sortOrder);
                xsltArgsList.AddParam(SEARCHTYPEPARAMETER, string.Empty, searchType.ToLowerInvariant());
                StringBuilder builder = new StringBuilder();
                StringWriter stringWriter = new StringWriter(builder);
                xslTransform.Transform(responseXml, xsltArgsList, stringWriter);
                strResultTable = stringWriter.GetStringBuilder();
            }
            else
            {
                throw new Exception("Invalid Arguments");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Transforms the EP catalog 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="sortColumn">The sort column.</param>
        /// <param name="sortOrder">The sort order.</param>
        /// <param name="maxRecords">The max records.</param>
        /// <param name="windowTitle">The window title.</param>
        /// <param name="searchType">Type of the search.</param>
        protected void TransformEPCatalogResultsToXSL(XmlDocument document, XmlTextReader textReader, string pageNumber, string sortColumn, string sortOrder, int maxRecords, string windowTitle, string searchType)
        {
            XslTransform xslTransform = null;
            XmlDocument objXmlDocForXSL = null;
            XsltArgumentList xsltArgsList = null;
            XmlNodeList objXmlNodeList = null;
            XPathDocument objXPathDocument = null;
            DateTimeConvertor objDateTimeConvertor = null;
            int intPageNumber = 0;
            int intRecordCount = 0;
            double dblCurrentPage = 0D;
            string strSortXPATH = string.Empty;
            string strRequestID = string.Empty;
            object objSessionUserPreference = null;
            MemoryStream objMemoryStream = null;

            try
            {
                if(document != null && textReader != null)
                {
                    xslTransform = new XslTransform();
                    objXmlDocForXSL = new XmlDocument();
                    xsltArgsList = new XsltArgumentList();
                    objPreferences = new UserPreferences();

                    objSessionUserPreference = CommonUtility.GetSessionVariable(Page, enumSessionVariable.UserPreferences.ToString());
                    if(objSessionUserPreference != null)
                    {
                        objPreferences = (UserPreferences)objSessionUserPreference;
                        intRecordsPerPage = Convert.ToInt16(objPreferences.RecordsPerPage);
                    }

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

                    /// Inititlize the XSL
                    objXmlDocForXSL.Load(textReader);
                    xslTransform.Load(objXmlDocForXSL);

                    /// Get the Total Record Count
                    objXmlNodeList = document.SelectNodes(EPXPATH);
                    if(objXmlNodeList != null)
                    {
                        foreach(XmlNode xmlNode in objXmlNodeList)
                        {
                            intRecordCount = Convert.ToInt32(xmlNode.SelectSingleNode("Count").InnerXml.ToString());
                        }
                    }
                    if(pageNumber.Length > 0)
                    {
                        intPageNumber = Convert.ToInt32(pageNumber);
                        /// the below condition validates the pageNumber parameter value.
                        dblCurrentPage = Double.Parse(pageNumber);
                    }
                    /// Added for cashing
                    /// Get the Response ID
                    strRequestID = (document.SelectSingleNode("ResultSet/requestid") != null ? document.SelectSingleNode("ResultSet/requestid").InnerText : string.Empty);

                    if(sortColumn == null)
                        sortColumn = string.Empty;
                    strSortXPATH = GetSortXPath(sortColumn);

                    /// Add the required parameters to the XsltArgumentList object
                    objDateTimeConvertor = new DateTimeConvertor();
                    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, HttpContext.Current.Request.Url.AbsolutePath + "?");
                    xsltArgsList.AddParam(CURRENTPAGE, string.Empty, dblCurrentPage + 1);
                    xsltArgsList.AddParam(MAXPAGES, string.Empty, 5);
                    xsltArgsList.AddParam("searchType", string.Empty, searchType);
                    xsltArgsList.AddParam(SORTCOLUMN, string.Empty, sortColumn);
                    xsltArgsList.AddParam(SORTORDER, string.Empty, sortOrder);
                    xsltArgsList.AddParam(WINDOWTITLE, string.Empty, windowTitle);
                    xsltArgsList.AddParam("SortXPath", string.Empty, strSortXPATH);
                    xsltArgsList.AddParam(MAXRECORDS, string.Empty, maxRecords);
                    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.Dispose();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the default user preferences stored in the Sharepoint List. 
        /// if the user has not set any Preferences explicitly, the default preferences will be taken from the 
        /// Sharepoint list with the default values
        /// </summary>
        /// <param name="userID">The user ID.</param>
        /// <returns>UserPerferences object</returns>
        internal UserPreferences GetDefaultUserPreferences(string userID)
        {
            SPListItemCollection prefListItemColl = null;
            SPListItemCollection userDefLinksColl = null;
            UserPreferences objPreferences = null;
            string strSiteLocation = string.Empty;
            try
            {
                strSiteLocation = SPContext.Current.Site.Url.ToString();
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPSite site = new SPSite(strSiteLocation))
                    {
                        using (SPWeb web = site.OpenWeb())
                        {
                            objSPQuery.Query = "<Where><Eq><FieldRef Name=\"UserID\" /><Value Type=\"Text\">" + userID
                                             + "</Value></Eq></Where>";
                            prefListItemColl = web.Lists[USERPREFERENCESLIST].GetItems(objSPQuery);

                            if (prefListItemColl != null && prefListItemColl.Count != 0)
                            {
                                objPreferences = new UserPreferences();

                                if (prefListItemColl[0]["Default_x0020_Asset"] != null)
                                    objPreferences.Asset = prefListItemColl[0]["Default_x0020_Asset"].ToString();

                                if (prefListItemColl[0]["Default_x0020_Basin"] != null)
                                    objPreferences.Basin = prefListItemColl[0]["Default_x0020_Basin"].ToString();
                                if (prefListItemColl[0]["Default_x0020_Country"] != null)
                                    objPreferences.Country = prefListItemColl[0]["Default_x0020_Country"].ToString();
                                if (prefListItemColl[0]["Title"] != null)
                                    objPreferences.Display = prefListItemColl[0]["Title"].ToString();
                                //objPreferences.Field = prefListItemColl[0]["Default_x0020_Field"].ToString();
                                if (prefListItemColl[0]["Records_x0020_Per_x0020_Page"] != null)
                                    objPreferences.RecordsPerPage = prefListItemColl[0]["Records_x0020_Per_x0020_Page"].ToString();
                                if (prefListItemColl[0]["Depth_x0020_Units"] != null)
                                    objPreferences.DepthUnits = prefListItemColl[0]["Depth_x0020_Units"].ToString();
                                //Dream 3.0 code
                                //Start
                                if (prefListItemColl[0]["Pressure_x0020_Units"] != null)
                                    objPreferences.PressureUnits = prefListItemColl[0]["Pressure_x0020_Units"].ToString();
                                if (prefListItemColl[0]["Temperature_x0020_Units"] != null)
                                    objPreferences.TemperatureUnits = prefListItemColl[0]["Temperature_x0020_Units"].ToString();
                                //End

                                objSPQuery.Query = "<Where><Eq><FieldRef Name=\"UserID\" /><Value Type=\"Text\">" + userID
                                                 + "</Value></Eq></Where>";
                                userDefLinksColl = web.Lists[USERDEFINEDLINKSLIST].GetItems(objSPQuery);
                                URL objURL = new URL();
                                ArrayList arlUserDefLinks = new ArrayList();
                                for (int index = 0; index < userDefLinksColl.Count; index++)
                                {
                                    objURL.URLTitle = userDefLinksColl[0]["Title"].ToString();
                                    objURL.URLValue = userDefLinksColl[0]["URL"].ToString();
                                    //objURL.Tooltip = userDefLinksColl[0]["Tooltip"].ToString();
                                    arlUserDefLinks.Add(objURL);
                                }
                                objPreferences.URL = arlUserDefLinks;
                            }
                        }
                    }
                });
            }
            catch (Exception)
            {
                throw;
            }
            return objPreferences;
        }
Esempio n. 5
0
 /// <summary>
 /// Gets the userpreferences from session.
 /// </summary>
 /// <returns></returns>
 public UserPreferences GetUserPreferencesFromSession(Page page, string userID, string parentSiteURL)
 {
     UserPreferences objPreferences = new UserPreferences();
     object objSessionUserPreference = null;
     try
     {
         objSessionUserPreference = CommonUtility.GetSessionVariable(page, enumSessionVariable.UserPreferences.ToString());
         //validates the user preferences session variable.
         if(objSessionUserPreference != null)
         {
             objPreferences = (UserPreferences)objSessionUserPreference;
         }
         else
         {
             objPreferences = GetUserPreferencesValue(userID, parentSiteURL);
         }
     }
     catch(Exception)
     {
         throw;
     }
     return objPreferences;
 }
Esempio n. 6
0
 /// <summary>
 /// Updates the user preferences.
 /// </summary>
 /// <param name="strUserID">user ID.</param>
 /// <param name="objPreferences">user preferences object.</param>
 /// <param name="strAction">action.</param>
 /// <param name="strStorageURL">storage URL.</param>
 /// <returns></returns>
 public bool UpdateUserPreferences(string userID, UserPreferences objPreferences, string action)
 {
     bool blnIsUpdated = false;
     UserPreferenceHandler objPreferencesHandler = null;
     try
     {
         objPreferencesHandler = new UserPreferenceHandler();
         //updates the user preferences and sets the Flag.
         blnIsUpdated = objPreferencesHandler.UpdateUserPreferences(userID, objPreferences, action);
     }
     catch(Exception)
     {
         throw;
     }
     return blnIsUpdated;
 }
Esempio n. 7
0
        /// <summary>
        /// Sets the user preference.
        /// </summary>
        private void SetUserPreference()
        {
            object objSessionUserPreference = null;
            objUserPreferences = new UserPreferences();

            objSessionUserPreference = CommonUtility.GetSessionVariable(Page, enumSessionVariable.UserPreferences.ToString());
            //sets the user preferences object from session.
            if (objSessionUserPreference == null)
            {
                InitializeUserPreference();
                objSessionUserPreference = CommonUtility.GetSessionVariable(Page, enumSessionVariable.UserPreferences.ToString());
                objUserPreferences = (UserPreferences)objSessionUserPreference;
            }
            else
            {
                objUserPreferences = (UserPreferences)objSessionUserPreference;
            }
        }
Esempio n. 8
0
        /// <summary>
        /// set the skip record count, request id and maxfetch record
        /// </summary>
        /// <returns></returns>
        private SkipInfo SetSkipInfo(bool isFetchAll, int maxRecords)
        {
            int intMaxRecordPage = 0;
            /// Get the value from Userpreferences
            objSkipInfo = new SkipInfo();
            objPreferences = new UserPreferences();
            objPreferences = (UserPreferences)CommonUtility.GetSessionVariable(Page, enumSessionVariable.UserPreferences.ToString());
            if(objPreferences != null)
                intMaxRecordPage = Convert.ToInt32(objPreferences.RecordsPerPage);

            if(string.Equals(SearchType.ToString().ToLowerInvariant(), TIMEDEPTHDETAIL) || string.Equals(SearchType.ToString().ToLowerInvariant(), DIRECTIONALSURVEYDETAIL))
            {
                objSkipInfo.MaxFetch = maxRecords.ToString();
                objSkipInfo.SkipRecord = "0";
            }
            else
            {
                if(strCurrPageNumber.Length > 0)
                    objSkipInfo.SkipRecord = Convert.ToString(Convert.ToInt32(strCurrPageNumber) * intMaxRecordPage);
                else
                    objSkipInfo.SkipRecord = "0";
                if(isFetchAll)
                {
                    objSkipInfo.MaxFetch = maxRecords.ToString();
                }
                else
                    objSkipInfo.MaxFetch = objPreferences.RecordsPerPage;
            }
            return objSkipInfo;
        }
Esempio n. 9
0
 /// <summary>
 /// Initializes the user preference.
 /// </summary>
 private void InitializeUserPreference()
 {
     objUserPreferences = new UserPreferences();
     string strUserId = objUtility.GetUserName();
     //get the user preferences.
     objUserPreferences = ((MOSSServiceManager)objController).GetUserPreferencesValue(strUserId, SPContext.Current.Site.Url.ToString());
     CommonUtility.SetSessionVariable(Page, enumSessionVariable.UserPreferences.ToString(), objUserPreferences);
 }
Esempio n. 10
0
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            //Dream 4.0 Ajax change starts
            //Fix for the UpdatePanel postback behaviour.
            EnsurePanelFix();
            RenderBusyBox();
            //Dream 4.0 Ajax change ends
            ServiceProvider objFactory = new ServiceProvider();
            objController = objFactory.GetServiceManager("MossService");
            strParentSiteURL = SPContext.Current.Site.Url.ToString();
            //Initializing Variables
            DataTable objListData = null;
            String strCAMLQuery = string.Empty;
            try
            {
                CreateUpdatePanel();
                CommonUtility.SetSessionVariable(Page, enumSessionVariable.IsDisplayContextSearch.ToString(), false);
                if(!UserValidation.ValidateUser())
                {
                    this.Context.Response.Redirect(ACCESSDENIEDPAGE, false);
                }

                if(UserValidation.IsSiteUnderMaintenance())
                {
                    /// Redirect to static page which should display the maintenance message
                    this.Context.Response.Redirect(SUSPENDACCESSPAGE, false);
                }
                //Initialize or get user preference values
                InitializeUserPreference();
                object objUserSessionPreferences = CommonUtility.GetSessionVariable(Page, enumSessionVariable.UserPreferences.ToString());
                if(objUserSessionPreferences != null)
                {
                    objUserPreferences = (UserPreferences)objUserSessionPreferences;
                }
                //Populating Country Drop Down
                strCAMLQuery = "<OrderBy><FieldRef Name=\"Title\" /></OrderBy><Where><Eq><FieldRef Name=\"Active\" /><Value Type=\"Choice\">Yes</Value></Eq></Where>";
                RenderQuickSearchCountry(objUserPreferences, strParentSiteURL, COUNTRYLIST, strCAMLQuery);
                //Populating Asset Drop Down
                strCAMLQuery = "<Where><Eq><FieldRef Name=\"IsActiveReportService\" /><Value Type=\"Boolean\">1</Value></Eq></Where>";
                RenderQuickSearchAsset(objUserPreferences, strParentSiteURL, ASSETTYPELIST, strCAMLQuery);
                //Creating Column Drop Down
                CreateQuickSearchColumnDDL();
                //Populating Column Drop Down
                PopulateQuickSearchColumnDDL();
                //Render Text Criteria Text Box
                RenderQuickSearchCriteriaField();
                RenderQuickSearchGoButton();
                this.Controls.Add(updtPanelLeftNaV);
                RenderLeftNav();
            }
            catch(Exception ex)
            {
                CommonUtility.HandleException(HttpContext.Current.Request.Url.ToString(), ex);
            }
            finally
            {
                if(objListData != null)
                    objListData.Dispose();
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Renders the quick search country.
        /// </summary>
        /// <param name="preferencesSetByUser">The preferences set by user.</param>
        /// <param name="parentSiteURL">The parent site URL.</param>
        /// <param name="listName">Name of the list.</param>
        /// <param name="camlQuery">The caml query.</param>
        private void RenderQuickSearchCountry(UserPreferences preferencesSetByUser, string parentSiteURL, string listName, string camlQuery)
        {
            DataTable objListData = null;
            DataRow objListRow;
            String strCountryName = string.Empty;
            String strCountryDesc = string.Empty;
            String strCompareCountry = string.Empty;
            String strQueryAsset = string.Empty;

            try
            {
                cboQuickCountry.ID = "cboQuickCountry";
                cboQuickCountry.CssClass = "dropdownAdvSrch";
                cboQuickCountry.Width = Unit.Pixel(140);
                cboQuickCountry.Items.Add(ANYCOUNTRYTEXT);
                cboQuickCountry.Items[0].Value = ANYCOUNTRYVALUE;

                if(Page.Request.QueryString[ASSETQUERYSTRING] != null)
                {
                    strQueryAsset = Page.Request.QueryString[ASSETQUERYSTRING].Trim();
                }
                /// Reads the values from Country Sharepoint List.
                objListData = ((MOSSServiceManager)objController).ReadList(parentSiteURL, listName, camlQuery);
                if(objListData != null && objListData.Rows.Count > 0)
                {
                    /// Loop through the values in Country List and finds the index of country user preference in List.
                    for(int intIndex = 0; intIndex < objListData.Rows.Count; intIndex++)
                    {
                        objListRow = objListData.Rows[intIndex];
                        strCountryName = objListRow["Title"].ToString();
                        strCountryDesc = objListRow["Country_x0020_Code"].ToString();
                        if(preferencesSetByUser.Country != null)
                        {
                            if(Page.Request.QueryString[COUNTRYQUERYSTRING] != null)
                            {
                                if(string.Compare(strQueryAsset, PARSITEMVAL, true) == 0)
                                    strCompareCountry = strCountryName;
                                else
                                    strCompareCountry = strCountryDesc;

                                if(string.Equals(strCompareCountry.Trim(), Page.Request.QueryString[COUNTRYQUERYSTRING].Trim()))
                                {
                                    intCountryIndex = intIndex + 1;
                                }
                            }
                            else if(string.Equals(strCountryDesc.Trim(), preferencesSetByUser.Country.Trim()))
                            {
                                intCountryIndex = intIndex + 1;
                            }
                        }
                        else if(Page.Request.QueryString[COUNTRYQUERYSTRING] != null)
                        {
                            if(string.Compare(strQueryAsset, PARSITEMVAL, true) == 0)
                                strCompareCountry = strCountryName;
                            else
                                strCompareCountry = strCountryDesc;

                            if(string.Equals(strCompareCountry.Trim(), Page.Request.QueryString[COUNTRYQUERYSTRING].Trim()))
                            {
                                intCountryIndex = intIndex + 1;
                            }
                        }
                        cboQuickCountry.Items.Add(strCountryName);
                        cboQuickCountry.Items[intIndex + 1].Value = strCountryDesc;
                    }
                }
                objListData.Clear();
                /// set the country default value from user preference.
                cboQuickCountry.SelectedIndex = intCountryIndex;
            }
            finally
            {
                if(objListData != null)
                    objListData.Dispose();
            }
        }
Esempio n. 12
0
        //DREAM4.0 Changes replaced Listbox control type to List control
        /// <summary>
        /// Loads the country basin data.
        /// </summary>
        /// <param name="strListName">Name of the STR list.</param>
        /// <param name="strEntityName">Name of the STR entity.</param>
        /// <param name="lstControl">The LST control.</param>
        protected void LoadCountryBasinData(string listName, string entityName, ListControl listBoxControl)
        {
            try
            {
                DataRow dtRow;

                objUserPreferences = new UserPreferences();
                int intControlIndex = -1;
                string strEntityName = string.Empty;
                string strColumnName = string.Empty;
                string strPreferredCountryBasin = string.Empty;
                string strCamlQuery = "<OrderBy><FieldRef Name=\"Title\"/></OrderBy><Where><Eq>" + "<FieldRef Name=\"Active\" /><Value Type=\"Choice\">Yes</Value></Eq></Where>";

                string strUserId = objUtility.GetUserName();
                objUserPreferences = ((MOSSServiceManager)objMossController).GetUserPreferencesFromSession(Page, strUserId, objUtility.GetParentSiteUrl(strCurrSiteUrl));

                dtListValues.Reset();
                dtListValues = ((MOSSServiceManager)objMossController).ReadList(strCurrSiteUrl, listName, strCamlQuery);
                listBoxControl.Items.Clear();

                if(string.Equals(entityName, BASINLIST))
                {
                    if(objUserPreferences.Basin.Length > 0)
                        strPreferredCountryBasin = objUserPreferences.Basin.ToLower();
                    strColumnName = "Title";
                }
                else if(string.Equals(entityName, COUNTRYLIST))
                {
                    if(objUserPreferences.Country.Length > 0)
                        strPreferredCountryBasin = objUserPreferences.Country.ToLower();
                    strColumnName = "Country_x0020_Code";
                }

                if(dtListValues != null)
                {
                    for(int intIndex = 0; intIndex < dtListValues.Rows.Count; intIndex++)
                    {
                        dtRow = dtListValues.Rows[intIndex];
                        if((dtRow["Title"] != null) && (!string.IsNullOrEmpty(dtRow["Title"].ToString())))
                        {
                            strEntityName = dtRow[strColumnName].ToString();

                            if(string.Equals(strEntityName.ToLower(), strPreferredCountryBasin))
                            {
                                intControlIndex = intIndex;
                            }
                            listBoxControl.Items.Add(dtRow["Title"].ToString());
                            if(string.Compare(entityName, COUNTRYLIST, true) == 0)
                            {
                                listBoxControl.Items[intIndex].Value = Convert.ToString(dtRow["Country_x0020_Code"]);
                            }
                        }
                    }
                }
                //DREAM4.0 code added for adv search country dropdown
                if(string.Equals(entityName, BASINLIST))
                {
                    listBoxControl.SelectedIndex = intControlIndex;
                }
                else if(string.Equals(entityName, COUNTRYLIST) && intControlIndex != -1)
                {
                    listBoxControl.SelectedIndex = intControlIndex;
                }
            }
            catch(Exception ex)
            {
                CommonUtility.HandleException(strCurrSiteUrl, ex);
            }
            finally
            {
                if(dtListValues != null)
                    dtListValues.Dispose();
            }
        }
Esempio n. 13
0
 /// <summary>
 /// Sets the user preferences.
 /// </summary>
 protected void SetUserPreferences()
 {
     objUserPreferences = new UserPreferences();
     string strUserId = objUtility.GetUserName();
     objUserPreferences = ((MOSSServiceManager)objMossController).GetUserPreferencesFromSession(Page, strUserId, objUtility.GetParentSiteUrl(strCurrSiteUrl));
 }
Esempio n. 14
0
 /// <summary>
 /// Sets the user preference.
 /// </summary>
 private void SetUserPreference()
 {
     object objBeforeSessionUserPreference = null;
     object objSessionUserPreference = null;
     /// Validates the user preferences session value.
     objBeforeSessionUserPreference = CommonUtility.GetSessionVariable(Page, enumSessionVariable.UserPreferences.ToString());
     if (objBeforeSessionUserPreference == null)
     {
         InitializeUserPreference();
         objSessionUserPreference = CommonUtility.GetSessionVariable(Page, enumSessionVariable.UserPreferences.ToString());
         objUserPreferences = (UserPreferences)objSessionUserPreference;
     }
     else
     {
         objUserPreferences = (UserPreferences)objBeforeSessionUserPreference;
     }
     if (objUserPreferences != null)
     {
         if (strDisplayType.Length == 0)
             strDisplayType = objUserPreferences.Display;
     }
 }
Esempio n. 15
0
 /// <summary>
 /// Initializes the user preference.
 /// </summary>
 private void InitializeUserPreference()
 {
     try
     {
         string strUserId = objCommonUtility.GetUserName();
         /// Reads the user preferences.
         objUserPreferences = ((MOSSServiceManager)objMossController).GetUserPreferencesValue(strUserId, strCurrSiteUrl);
         CommonUtility.SetSessionVariable(Page, enumSessionVariable.UserPreferences.ToString(), objUserPreferences);
     }
     catch (Exception ex)
     {
         CommonUtility.HandleException(HttpContext.Current.Request.Url.ToString(), ex);
     }
 }
Esempio n. 16
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();
                }
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Transforms the XML to result table.
        /// </summary>
        /// <param name="responseXml">The response XML.</param>
        /// <param name="textReader">The text reader.</param>
        /// <param name="currentPageNumber">The current 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="activeDiv">The active div.</param>
        protected void TransformXmlToResultTable(XmlDocument responseXml, XmlTextReader textReader,
                                              string currentPageNumber, string sortByColumn, string sortOrder,
                                              string searchType, string activeDiv)
        {
            XslCompiledTransform xslTransform = null;
            XmlDocument objXmlDocForXSL = null;
            XsltArgumentList xsltArgsList = null;
            DateTimeConvertor objDateTimeConvertor = null;
            object objSessionUserPreference = null;
            int intRecordCount = 0;
            Pagination objPagination = null;

            if(responseXml != null && textReader != null)
            {
                xslTransform = new XslCompiledTransform();
                objXmlDocForXSL = new XmlDocument();
                //Inititlize the XSL
                objXmlDocForXSL.Load(textReader);
                xslTransform.Load(objXmlDocForXSL);
                xsltArgsList = new XsltArgumentList();
                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);
                }
                //setting record count
                intRecordCount = GetRecordCountFromResult(responseXml, searchType);

                /// the below condition validates the sortOrder parameter value.
                if(string.IsNullOrEmpty(sortOrder))
                {
                    sortOrder = SORTDEFAULTORDER;
                }
                if(string.IsNullOrEmpty(sortByColumn))
                    sortByColumn = string.Empty;

                /// Add the required parameters to the XsltArgumentList object
                /// passing parameters to XSL
                ///creating Pagination related parameter
                objPagination = new Pagination(Convert.ToInt32(currentPageNumber), intRecordCount, intRecordsPerPage, blnSkipCountEnabled);

                CreatePaginationXslParameter(ref xsltArgsList, objPagination);
                GetDataQualityRange(ref xsltArgsList);
                objDateTimeConvertor = new DateTimeConvertor();
                xsltArgsList.AddExtensionObject("urn:DATE", objDateTimeConvertor);
                xsltArgsList.AddParam(ACTIVEDIV, string.Empty, activeDiv);
                xsltArgsList.AddParam(SORTCOLUMN, string.Empty, sortByColumn);
                xsltArgsList.AddParam(SORTORDER, string.Empty, sortOrder);
                xsltArgsList.AddParam(SEARCHTYPEPARAMETER, string.Empty, searchType.ToLowerInvariant());
                xsltArgsList.AddParam(USERPREFERENCELABEL, string.Empty, strDepthUnit.ToLowerInvariant());
                xsltArgsList.AddParam(FORMULAVALUETITLE, string.Empty, PIVALUE);
                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);
                xsltArgsList.AddParam(REORDERDIVHTML, string.Empty, strReorderDivHTML);
                if(hidRowSelectedCheckBoxes != null)
                    xsltArgsList.AddParam(PARAMROWSELECTEDCHECKBOXES, string.Empty, hidRowSelectedCheckBoxes.Value);
                if(hidColSelectedCheckBoxes != null)
                    xsltArgsList.AddParam(PARAMCOLSELECTEDCHECKBOXES, string.Empty, hidColSelectedCheckBoxes.Value);
                xsltArgsList.AddParam(ASSETCOLNAME, string.Empty, GetAssetNameCol(hidAssetName.Value));
                StringBuilder builder = new StringBuilder();
                StringWriter stringWriter = new StringWriter(builder);
                xslTransform.Transform(responseXml, xsltArgsList, stringWriter);
                strResultTable = stringWriter.GetStringBuilder();
            }
            else
            {
                throw new Exception("Invalid Arguments");
            }
        }
Esempio n. 18
0
 /// <summary>
 /// Renders the quick search asset.
 /// </summary>
 /// <param name="preferencesSetByUser">The preferences set by user.</param>
 /// <param name="parentSiteURL">The parent site URL.</param>
 /// <param name="listName">Name of the list.</param>
 /// <param name="camlQuery">The caml query.</param>
 private void RenderQuickSearchAsset(UserPreferences preferencesSetByUser, string parentSiteURL, string listName, string camlQuery)
 {
     DataTable objListData = null;
     DataRow objListRow;
     string strAssetName = string.Empty;
     try
     {
         cboQuickAsset.ID = "cboQuickAsset";
         cboQuickAsset.CssClass = "dropdownAdvSrch";
         cboQuickAsset.Width = Unit.Pixel(140);
         cboQuickAsset.AutoPostBack = true;
         cboQuickAsset.SelectedIndexChanged += cboQuickAsset_SelectedIndexChanged;
         cboQuickAsset.Attributes.Add("onchange", "javascript:QuickSearchOnChange();");
         /// Reads the values from Asset Sharepoint List.
         objListData = ((MOSSServiceManager)objController).ReadList(parentSiteURL, listName, camlQuery);
         if(objListData != null && objListData.Rows.Count > 0)
         {
             /// Loop through the values in Asset List.
             for(int intIndex = 0; intIndex < objListData.Rows.Count; intIndex++)
             {
                 objListRow = objListData.Rows[intIndex];
                 strAssetName = objListRow["Title"].ToString();
                 if(preferencesSetByUser.Asset.Length > 0)
                 {
                     if(Page.Request.QueryString[ASSETQUERYSTRING] != null)
                     {
                         if(string.Equals(strAssetName.Trim(), Page.Request.QueryString[ASSETQUERYSTRING].Trim()))
                         {
                             intAssetIndex = intIndex;
                         }
                     }
                     else if(string.Equals(strAssetName.Trim(), preferencesSetByUser.Asset.Trim()))
                     {
                         intAssetIndex = intIndex;
                     }
                 }
                 else if(Page.Request.QueryString[ASSETQUERYSTRING] != null)
                 {
                     if(string.Equals(strAssetName.Trim(), Page.Request.QueryString[ASSETQUERYSTRING].Trim()))
                     {
                         intAssetIndex = intIndex;
                     }
                 }
                 cboQuickAsset.Items.Add(strAssetName);
             }
         }
         objListData.Clear();
         /// this will set the default value for the asset type from user preferences.
         cboQuickAsset.SelectedIndex = intAssetIndex;
     }
     finally
     {
         if(objListData != null)
             objListData.Dispose();
     }
 }
Esempio n. 19
0
 /// <summary>
 /// Initializes the user preference.
 /// </summary>
 protected void InitializeUserPreference()
 {
     string strUserId = objCommonUtility.GetUserName();
     //get the user prefrences.
     objUserPreferences = ((MOSSServiceManager)objMossController).GetUserPreferencesValue(strUserId, strCurrSiteUrl);
     CommonUtility.SetSessionVariable(Page, enumSessionVariable.UserPreferences.ToString(), objUserPreferences);
 }
Esempio n. 20
0
        /// <summary>
        /// Handles the Click event of the cmdSubmit 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 cmdSubmit_Click(object sender, EventArgs e)
        {
            string strAction = string.Empty;
            try
            {
                string strUserId = objUtility.GetUserName();
                objUserPreferences = ((MOSSServiceManager)objMossController).GetUserPreferences(strUserId);
                if(objUserPreferences == null)
                {
                    objUserPreferences = new UserPreferences();
                    strAction = CREATE;
                }
                else
                {
                    strAction = UPDATE;
                }

                bool blnIsSaved = false;
                objUserPreferences.Display = cboDisplay.SelectedItem.Value;
                objUserPreferences.DepthUnits = cboDepthUnits.SelectedItem.Value;
                objUserPreferences.Country = cboCountry.SelectedItem.Value;
                objUserPreferences.Asset = cboAsset.SelectedItem.Value;
                objUserPreferences.RecordsPerPage = cboRecordsPerPage.SelectedItem.Value;
                objUserPreferences.Basin = cboBasin.SelectedItem.Value;
                //Dream 3.0 code
                //Start
                objUserPreferences.PressureUnits = cboPressureUnits.SelectedItem.Value;
                objUserPreferences.TemperatureUnits = cboTemperatureUnits.SelectedItem.Value;
                //End
                URL objURL = null;
                ArrayList arlURL = new ArrayList();
                objURL = new URL();
                objURL.URLTitle = txtLinkTitle1.Text.Trim();
                objURL.URLValue = txtLinkUrl1.Text.Trim();
                arlURL.Add(objURL);

                objURL = new URL();
                objURL.URLTitle = txtLinkTitle2.Text.Trim();
                objURL.URLValue = txtLinkUrl2.Text.Trim();
                arlURL.Add(objURL);

                objURL = new URL();
                objURL.URLTitle = txtLinkTitle3.Text.Trim();
                objURL.URLValue = txtLinkUrl3.Text.Trim();
                arlURL.Add(objURL);

                objURL = new URL();
                objURL.URLTitle = txtLinkTitle4.Text.Trim();
                objURL.URLValue = txtLinkUrl4.Text.Trim();
                arlURL.Add(objURL);

                objUserPreferences.URL = arlURL;
                blnIsSaved = ((MOSSServiceManager)objMossController).UpdateUserPreferences(strUserId, objUserPreferences, strAction);
                if(blnIsSaved)
                {
                    CommonUtility.SetSessionVariable(Page, enumSessionVariable.UserPreferences.ToString(), objUserPreferences);
                    Page.Response.Redirect("/_layouts/Dream/ConfirmUserPreferences.aspx?saved=1", false);
                }
                else
                {
                    Page.Response.Redirect("/_layouts/Dream/ConfirmUserPreferences.aspx?saved=0", false);
                }
            }
            catch(WebException webEx)
            {
                ShowLableMessage(webEx.Message);
            }
            catch(Exception ex)
            {
                CommonUtility.HandleException(strCurrSiteUrl, ex);
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Handles the Load event of the Page 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 Page_Load(object sender, EventArgs e)
        {
            strCurrSiteURL = HttpContext.Current.Request.Url.ToString();
            objUserPreferences = new UserPreferences();
            string strDepthUnit = string.Empty;
            string strUser = string.Empty;
            try
            {
                lblException.Text = string.Empty;
                cmdSearch.Attributes.Add(REDIRECTATTRIBUTE, REDIRECTATTRIBUTEVALUE);
                cmdReset.Attributes.Add(REDIRECTATTRIBUTE, REDIRECTATTRIBUTEVALUE);
                if (!Page.IsPostBack)
                {
                    //Sets the Logs Check refresh session variable.
                    CommonUtility.SetSessionVariable(Page, CHECKREFRESH, DateTime.Now.ToString());
                    object objSessionUserPreference = CommonUtility.GetSessionVariable(Page, enumSessionVariable.UserPreferences.ToString());
                    if (objSessionUserPreference != null)
                        objUserPreferences = (UserPreferences)objSessionUserPreference;
                    strDepthUnit = objUserPreferences.DepthUnits;
                    base.SearchType = LOGSFIELDSEARCHTYPE;
                    LoadControls(chbShared, cboSavedSearch);
                    if (Request.QueryString["savesearchname"] != null)
                    {
                        if (Request.QueryString["operation"] != null)
                        {
                            if (string.Equals(Request.QueryString["operation"].ToString(), "modify"))
                            {
                                cmdSaveSearch.Value = "Modify Search";
                                txtSaveSearch.Text = Request.QueryString["savesearchname"].ToString();
                                txtSaveSearch.Enabled = false;
                            }
                        }
                    }
                    BindTooltipTextToControls();

                    if (Request.QueryString[SAVESEARCHNAMEQUERYSTRING] != null)
                    {
                        if (Request.QueryString["manage"] != null)
                        {
                            if (string.Equals(Request.QueryString["manage"].ToString(), "true"))
                                strUser = GetUserName();
                            else
                                strUser = "******";
                        }
                        XmlDocument xmldoc = new XmlDocument();
                        //loads the saved search XML Document of administrator
                        xmldoc = ((MOSSServiceManager)objMossController).GetDocLibXMLFile(SearchType, strUser);
                        SetFeetMetre(xmldoc, cboSavedSearch.SelectedItem.Text.ToString());
                    }

                    if (rdoDepthUnitsMetres.Checked != true && rdoDepthUnitsFeet.Checked != true)
                    {
                        if (string.Equals(strDepthUnit, METRES))
                        {
                            rdoDepthUnitsMetres.Checked = true;
                        }
                        else if (string.Equals(strDepthUnit, FEET))
                        {
                            rdoDepthUnitsFeet.Checked = true;
                        }
                    }
                }
            }
            catch (WebException webEx)
            {
                ShowLableMessage(webEx.Message);
            }
            catch (Exception ex)
            {
                CommonUtility.HandleException(strCurrSiteURL, ex);
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Handles the Load event of the Page 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 Page_Load(object sender, EventArgs e)
        {
            try
            {
                AbstractController objMossController = null;
                UserPreferences objUserPreferences = new UserPreferences();
                ////Some time user enter the values in between the textbox like row1 textbox and row 5 textbox, before populate the value to table, clean up the textbox value.
                drpWellbore.Attributes.Add("onChange", "javascript:ClearAllRows(this)");

                #region if Wellbore dropdown value changed, need to populate Depthrefece value country value to Dropdown and Label control

                CommonUtility objCommonUtility = new CommonUtility();
                ServiceProvider objFactory = new ServiceProvider();
                objReportController = objFactory.GetServiceManager(ServiceName.ToString());
                objMossController = objFactory.GetServiceManager(MOSSSERVICE);

                string strUserId = objCommonUtility.GetUserName();
                //reads the user preferences.
                objUserPreferences = ((MOSSServiceManager)objMossController).GetUserPreferencesValue(strUserId, strCurrSiteUrl);
                CommonUtility.SetSessionVariable(Page, enumSessionVariable.UserPreferences.ToString(), objUserPreferences);

                object objSessionUserPreference = CommonUtility.GetSessionVariable(Page, enumSessionVariable.UserPreferences.ToString());
                if (objSessionUserPreference != null)
                    objUserPreferences = (UserPreferences)objSessionUserPreference;
                strDepthUnit = objUserPreferences.DepthUnits;

                if (rdoDepthUnitsFeet.Checked != true && rdoDepthUnitsMetres.Checked != true)
                {
                    if (string.Equals(strDepthUnit, METRES))
                    {
                        rdoDepthUnitsMetres.Checked = true;
                    }
                    else if (string.Equals(strDepthUnit, FEET))
                    {
                        rdoDepthUnitsFeet.Checked = true;
                    }
                }

                if (rdoDepthUnitsFeet.Checked)
                {
                    strFeetMetre = "(ft)";
                }
                if (rdoDepthUnitsMetres.Checked)
                {
                    strFeetMetre = "(m)";
                }

                //Used to display the selected value to drpdepthReference Dropdown.
                FillDepthrefSelectedValue();

                if((objUtility.GetPostBackControl(this.Page) != null) && (string.Equals(objUtility.GetPostBackControl(this.Page).ID, "drpWellbore")))
                {
                    try
                    {
                        rdoDepthUnitsFeet.Checked = true;
                        objRequestInfo = SetDataObject(Default);
                        xmlDocSearchResultAHTVD = objReportController.GetSearchResults(objRequestInfo, intMaxRecord, strAHTVCALCULATOR, null, intSortOrder);
                        FillCountryDetails(xmlDocSearchResultAHTVD);
                        Session["xmlDocSearchResultAHTVD"] = null;
                        Session["xmlDocSearchResultAHTVD"] = xmlDocSearchResultAHTVD.OuterXml;
                        objRequestInfo = null;

                        objRequestInfo = SetDataObject(Default);
                        xmlDocSearchResultDepthRef = objReportController.GetSearchResults(objRequestInfo, intMaxRecord, strMECHANICALDATADEPTHREF, null, intSortOrder);
                        Session["xmlDocSearchResultDepthRef"] = null;
                        Session["xmlDocSearchResultDepthRef"] = xmlDocSearchResultDepthRef.OuterXml;
                        FilldrpDepthReference(xmlDocSearchResultDepthRef);
                        FillDepthrefSelectedValue();
                    }
                    catch
                    {
                        pnlTable.Visible = false;
                        pnlTableErrorMessage.Visible = true;
                        lblTableErrorMessage.Visible = true;
                    }
                }

                #endregion

                int intCount = tblConvertRows.Rows.Count - 2;
                // Thease session variables are used to display the values into First row first col, last row first column of the HTML tables in non-editable mode.
                if (Session["TopDepth"] != null && Session["BottomDepth"] != null)
                {
                    //Assign always Topdepth values into First textbox, and Bottom values into last text box, thease values are coming webservice.
                    TextBox txtAHDepth0 = (TextBox)tblConvertRows.Rows[0].Cells[0].FindControl("txtAHDepth0");
                    txtAHDepth0.Text = Convert.ToDouble(Session["TopDepth"].ToString()).ToString(("#0.00"));

                    TextBox txtAHDepthMax = (TextBox)tblConvertRows.Rows[intCount].Cells[0].FindControl("txtAHDepth" + intCount);
                    txtAHDepthMax.Text = Convert.ToDouble(Session["BottomDepth"].ToString()).ToString(("#0.00"));

                    TextBox lblAHDepth0 = (TextBox)tblConvertRows.Rows[0].Cells[1].FindControl("lblAHDepth0");

                    Decimal decTxtAHDepth0 = Convert.ToDecimal(txtAHDepth0.Text.ToString());
                    Decimal decTxtAHDepthMax = Convert.ToDecimal(txtAHDepthMax.Text.ToString());
                    Decimal decHndDrpValue = Convert.ToDecimal(Session["hidDrpDepthRefValue"].ToString());
                    //*added by Dev
                    decHndDrpValue = ConvertFeetMetre(decHndDrpValue, hidDepthRefDefaultUnit.Value);

                    // used to display with 2 digit, eg : 52.00
                    //Bydefault need to display calculated values to 1 rows 2 columns and last row 2 columns.
                    // (0.00 - Depth Reference (DF,BF,etc...)
                    lblAHDepth0.Text = Convert.ToString(Math.Round(Convert.ToDecimal(Convert.ToDouble(decTxtAHDepth0) - Convert.ToDouble(decHndDrpValue)), 2).ToString("#0.00")).ToString();
                    TextBox lblAHDepthMax = (TextBox)tblConvertRows.Rows[intCount].Cells[1].FindControl("lblAHDepth" + intCount);
                    lblAHDepthMax.Text = Convert.ToString(Math.Round(Convert.ToDecimal(Convert.ToDouble(decTxtAHDepthMax) - Convert.ToDouble(decHndDrpValue)), 2).ToString("#0.00")).ToString();

                }
            }
            catch (SoapException soapEx)
            {
                if (!string.Equals(soapEx.Message, SOAPEXCEPTIONMESSAGE))
                {
                    CommonUtility.HandleException(strCurrSiteUrl, soapEx, 1);
                }
                RenderExceptionMessage(soapEx.Message);
            }
            catch (WebException webEx)
            {
                CommonUtility.HandleException(HttpContext.Current.Request.Url.ToString(), webEx, 1);
                RenderExceptionMessage(webEx.Message);
            }
            catch (Exception ex)
            {
                CommonUtility.HandleException(HttpContext.Current.Request.Url.ToString(), ex);
            }
            finally
            {
                objUtility.CloseBusyBox(this.Page);
            }
        }
Esempio n. 23
0
 /// <summary>
 /// Gets the user preferences.
 /// </summary>
 /// <param name="strUserID">Current logged in User ID.</param>
 /// <param name="strSiteLocation">Site location.</param>
 /// <returns>UserPerferences object</returns>
 public UserPreferences GetUserPreferences(string userID)
 {
     UserPreferenceHandler objUserPreferenceHandler = null;
     UserPreferences objPreferences = null;
     try
     {
         objPreferences = new UserPreferences();
         objUserPreferenceHandler = new UserPreferenceHandler();
         //reads the user preferences.
         objPreferences = objUserPreferenceHandler.GetUserPreferences(userID);
     }
     catch(Exception)
     {
         throw;
     }
     return objPreferences;
 }
Esempio n. 24
0
 /// <summary>
 /// Gets the user selected unit.
 /// </summary>
 /// <returns></returns>
 private string GetUserSelectedUnitForChart()
 {
     string strUnit = string.Empty;
     UserPreferences objUserPreferences = new UserPreferences();
     objMossController = objFactory.GetServiceManager("MossService");
     string strUserId = objCommonUtility.GetUserName();
     //get the user prefrences.
     objUserPreferences = ((MOSSServiceManager)objMossController).GetUserPreferencesValue(strUserId, strCurrSiteUrl);
     if(!string.IsNullOrEmpty(strUnit = objCommonUtility.GetFormControlValue(FEETMETERRADIOBUTTONID)))
     {
         if (strUnit.ToLower().Equals("feet"))
         {
             strUnit = "feet";
         }
         else
         {
             strUnit = "metres";
         }
     }
     else if (objUserPreferences != null)
     {
         strUnit = objUserPreferences.DepthUnits.ToLowerInvariant();
     }
     return strUnit;
 }
Esempio n. 25
0
        /// <summary>
        /// Gets the userpreferences value.
        /// </summary>
        /// <returns></returns>
        public UserPreferences GetUserPreferencesValue(string userID, string parentSiteURL)
        {
            Common objCommon = null;
            UserPreferences objPreferences = null;
            UserPreferenceHandler objUserPreferenceHandler = null;
            DataTable objDefaultPreferences = null;
            try
            {
                objCommon = new Common();
                objPreferences = new UserPreferences();
                objUserPreferenceHandler = new UserPreferenceHandler();

                objPreferences = objUserPreferenceHandler.GetUserPreferences(userID);
                if(objPreferences != null)
                {
                    return objPreferences;
                }
                else
                {
                    //Read 'Default Preferences' list and set to the object
                    objDefaultPreferences = new DataTable();
                    objPreferences = new UserPreferences();
                    objDefaultPreferences = objCommon.ReadList(parentSiteURL, DEFAULTPREFERENCESLIST);
                    foreach(DataRow objDataRow in objDefaultPreferences.Rows)
                    {
                        if(string.Equals(objDataRow["Title"].ToString(), "Display"))
                        {
                            objPreferences.Display = objDataRow["Default_x0020_Value"].ToString();
                        }
                        else if(string.Equals(objDataRow["Title"].ToString(), "DepthUnits"))
                        {
                            objPreferences.DepthUnits = objDataRow["Default_x0020_Value"].ToString();
                        }
                        else if(string.Equals(objDataRow["Title"].ToString(), "RecordsPerPage"))
                        {
                            objPreferences.RecordsPerPage = objDataRow["Default_x0020_Value"].ToString();
                        }
                    }
                    return objPreferences;
                }
            }
            catch(Exception)
            {
                throw;
            }
            finally
            {
                if(objDefaultPreferences != null)
                    objDefaultPreferences.Dispose();
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Updates the user preferences when the user changes his preferences data.
        /// </summary>
        /// <param name="userID">The user ID.</param>
        /// <param name="preferencesSetByUser">The preferences set by user.</param>
        /// <param name="action">The action.</param>
        /// <returns>
        /// boolean returns whether update is success
        /// </returns>        
        internal bool UpdateUserPreferences(string userID, UserPreferences preferencesSetByUser, string action)
        {
            #region Method Variables
            bool blnIsSuccess = false;
            SPList preferencesList, userDefLinksList;
            SPQuery query;
            SPListItemCollection preferencesItemsColl = null;
            SPListItemCollection userDefLinksColl = null;
            SPListItem preferencesItem;
            #endregion

            try
            {
                string strStorageURL = SPContext.Current.Site.Url;
                // using(SPSite newSite = new SPSite(strStorageURL))
                SPSecurity.RunWithElevatedPrivileges(delegate()
                 {
                     using (SPSite site = new SPSite(strStorageURL))
                     {
                         using(SPWeb web = site.OpenWeb())
                         {
                             preferencesList = web.Lists[USERPREFERENCESLIST];
                             userDefLinksList = web.Lists[USERDEFINEDLINKSLIST];

                             //if user has not selected anything, blank value needs to be updated in the
                             //list instead "---Select---"
                             if (string.Compare(preferencesSetByUser.Asset, SELECT, true) == 0)
                                 preferencesSetByUser.Asset = " ";

                             if (string.Compare(preferencesSetByUser.Basin, SELECT, true) == 0)
                                 preferencesSetByUser.Basin = " ";

                             if (string.Compare(preferencesSetByUser.Country, SELECT, true) == 0)
                                 preferencesSetByUser.Country = " ";

                             if (string.Compare(preferencesSetByUser.Field, SELECT, true) == 0)
                                 preferencesSetByUser.Field = " ";

                             if (action == UPDATE)
                             {
                                 web.AllowUnsafeUpdates = true;
                                 query = new SPQuery();
                                 query.Query = "<Where><Eq><FieldRef Name=\"UserID\" /><Value Type=\"Text\">" + userID + "</Value></Eq></Where>";

                                 //update items in UserPreferences List
                                 preferencesItemsColl = preferencesList.GetItems(query);
                                 preferencesItem = preferencesItemsColl[0];
                                 preferencesItem["Default_x0020_Asset"] = preferencesSetByUser.Asset;
                                 preferencesItem["Default_x0020_Basin"] = preferencesSetByUser.Basin;
                                 preferencesItem["Default_x0020_Country"] = preferencesSetByUser.Country;
                                 preferencesItem["Depth_x0020_Units"] = preferencesSetByUser.DepthUnits;
                                 //preferencesItem["Map_x0020_Display"] = preferencesSetByUser.MapDisplay;
                                 preferencesItem["Title"] = preferencesSetByUser.Display;
                                 //preferencesItem["Default_x0020_Field"] = preferencesSetByUser.Field;
                                 preferencesItem["Records_x0020_Per_x0020_Page"] = preferencesSetByUser.RecordsPerPage;
                                 //Dream 3.0 code
                                 //Start
                                 preferencesItem["Pressure_x0020_Units"] = preferencesSetByUser.PressureUnits;
                                 preferencesItem["Temperature_x0020_Units"] = preferencesSetByUser.TemperatureUnits;
                                 //End
                                 preferencesItem.Update();

                                 //update items in UserDefinedLinks list
                                 userDefLinksColl = userDefLinksList.GetItems(query);
                                 DeleteLinkItems(userDefLinksColl);  //Delete all existing links; and add new
                                 AddUserDefinedLinks(preferencesSetByUser.URL, userDefLinksList, userID);  //add new item to UserDefinedLinks list
                                 web.AllowUnsafeUpdates = false;
                                 blnIsSuccess = true;
                             }
                             else if (action == CREATE)
                             {
                                 web.AllowUnsafeUpdates = true;

                                 //add new item to UserPreferences list
                                 preferencesItem = preferencesList.Items.Add();
                                 preferencesItem["Default_x0020_Asset"] = preferencesSetByUser.Asset;
                                 preferencesItem["Default_x0020_Basin"] = preferencesSetByUser.Basin;
                                 preferencesItem["Default_x0020_Country"] = preferencesSetByUser.Country;
                                 preferencesItem["Depth_x0020_Units"] = preferencesSetByUser.DepthUnits;
                                 //preferencesItem["Map_x0020_Display"] = preferencesSetByUser.MapDisplay;
                                 preferencesItem["Title"] = preferencesSetByUser.Display;
                                 //preferencesItem["Default_x0020_Field"] = preferencesSetByUser.Field;
                                 preferencesItem["Records_x0020_Per_x0020_Page"] = preferencesSetByUser.RecordsPerPage;
                                 preferencesItem["UserID"] = userID;
                                 //Dream 3.0 code
                                 //Start
                                 preferencesItem["Pressure_x0020_Units"] = preferencesSetByUser.PressureUnits;
                                 preferencesItem["Temperature_x0020_Units"] = preferencesSetByUser.TemperatureUnits;
                                 //End
                                 preferencesItem.Update();

                                 AddUserDefinedLinks(preferencesSetByUser.URL, userDefLinksList, userID);  //add new item to UserDefinedLinks list
                                 web.AllowUnsafeUpdates = false;
                                 blnIsSuccess = true;
                             }
                         }
                     }
                 });
            }
            catch (Exception)
            {
                throw;
            }
            return blnIsSuccess;
        }