Ejemplo n.º 1
0
        /// <summary>
        /// Page_s the init.
        /// </summary>
        protected void Page_Init()
        {
            #region  Page_init
            try
            {
                pnlSoapError.Visible = false;
                lblErrorMessage.Visible = false;
                pnlConverterContent.Visible = true;
                btn_goBack.Visible = false;
                pnlTable.Visible = true;
                pnlTableErrorMessage.Visible = false;
                lblTableErrorMessage.Visible = false;
                objUtility = new CommonUtility();

                objUtility.RenderBusyBox(this.Page);

                if (HttpContext.Current.Request.Form["hidSelectedRows"] != null)
                {
                    //This session values is assigned into AHDTVDPopup.ascx / TVDepthPopup.ascx
                    Session.Remove("DepthValues");
                    Session.Remove("tblConvertsRowsCount");
                    Session.Remove("xmlDocSearchResultWellBore");
                    Session.Remove("TopDepth");
                    Session.Remove("BottomDepth");
                    Session.Remove("xmlDocSearchResultAHTVD");
                    Session.Remove("xmlDocSearchResultDepthRef");
                    Session.Remove("hidDrpDepthRefValue");
                }

                tblConvertRows.EnableViewState = true;
                //**added of dev
                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;
                    }
                }
                //**end

                //Used to set the tab index for AH and TV textbox only.
                if (hdnTabIndex != null)
                {
                    if (string.IsNullOrEmpty(hdnTabIndex.Value.ToString()))
                    {
                        hdnTabIndex.Value = "1";
                    }
                }

                if (Session["tblConvertsRowsCount"] == null)
                {
                    GenerateRows(intMinRowLength, intMaxRowlength, strtblWithHeaderRow);
                }
                else
                {
                    GenerateRows(intMinRowLength, intMaxRowlength, strtblWithHeaderRow);
                    GenerateRows(intMaxRowlength, Convert.ToInt32(Session["tblConvertsRowsCount"].ToString()), strtblWithOutHeaderRow);
                }

                objReportController = objFactory.GetServiceManager(ServiceName.ToString());

                //Fill Wellbore name into Wellbore Dropdown

                #region populate wellbore name
                if (Session["xmlDocSearchResultWellBore"] == null)
                {
                    objRequestInfo = SetDataObject(strUWBI);
                    xmlDocSearchResultWellBore = objReportController.GetSearchResults(objRequestInfo, intMaxRecord, strWELLBORE, SORTCOLUMN, intSortOrder);
                    FilldrpWellboreName(xmlDocSearchResultWellBore);
                    Session["xmlDocSearchResultWellBore"] = xmlDocSearchResultWellBore.OuterXml;
                    objRequestInfo = null;
                }
                else
                {
                    XmlDocument xmlResponse = new XmlDocument();
                    xmlResponse.LoadXml((string)Session["xmlDocSearchResultWellBore"]);
                    FilldrpWellboreName(xmlResponse);
                    objRequestInfo = null;
                }
                #endregion

                //Fill Wellbore depth reference when Wellbore name is selected.

                #region Populate Wellbore Depth Reference.

                if (Session["xmlDocSearchResultDepthRef"] == null)
                {
                    objRequestInfo = SetDataObject(Default);
                    xmlDocSearchResultDepthRef = objReportController.GetSearchResults(objRequestInfo, intMaxRecord, strMECHANICALDATADEPTHREF, null, intSortOrder);
                    hidDepthRefDefaultUnit.Value = GetMeasurementUnit(xmlDocSearchResultDepthRef.SelectNodes("response/report/record[1]/attribute[@name='depth_reference_elevation']")[0]);
                    FilldrpDepthReference(xmlDocSearchResultDepthRef);
                    Session["xmlDocSearchResultDepthRef"] = xmlDocSearchResultDepthRef.OuterXml;
                    objRequestInfo = null;
                }
                else
                {
                    XmlDocument xmlResponse = new XmlDocument();
                    xmlResponse.LoadXml((string)Session["xmlDocSearchResultDepthRef"]);
                    hidDepthRefDefaultUnit.Value = GetMeasurementUnit(xmlResponse.SelectNodes("response/report/record[1]/attribute[@name='depth_reference_elevation']")[0]);
                    FilldrpDepthReference(xmlResponse);
                }
                #endregion

                #region Display Country Details.
                if (Session["xmlDocSearchResultAHTVD"] == null)
                {
                    objRequestInfo = SetDataObject(Default);
                    xmlDocSearchResultAHTVD = objReportController.GetSearchResults(objRequestInfo, intMaxRecord, strAHTVCALCULATOR, null, intSortOrder);
                    FillCountryDetails(xmlDocSearchResultAHTVD);
                    Session["xmlDocSearchResultAHTVD"] = xmlDocSearchResultAHTVD.OuterXml;
                    objRequestInfo = null;
                }
                else
                {
                    XmlDocument xmlResponse = new XmlDocument();
                    xmlResponse.LoadXml((string)Session["xmlDocSearchResultAHTVD"]);
                    FillCountryDetails(xmlResponse);
                }
                #endregion

                inttblCount = tblConvertRows.Rows.Count;

                //Populate Top & Bottom Depths value from Popup Window

                # region Top & Bottom Depths values to Table
                if (Session["DepthValues"] != null)
                {
                    strDepthValues = Session["DepthValues"].ToString();
                    arrDepthval = strDepthValues.Split('|');
                    dblTopDepth = Convert.ToDouble(arrDepthval[0].ToString());
                    dblBottomDepth = Convert.ToDouble(arrDepthval[1].ToString());
                    intDepthInterval = Convert.ToInt32(arrDepthval[2].ToString());
                    strDepthname = arrDepthval[3].ToString();
                    //used to find the no of rows to be create in the HTML table.
                    int index = Convert.ToInt32(Math.Ceiling(Math.Round(((dblBottomDepth - dblTopDepth) / intDepthInterval), 2)));

                    index = index + 3;
                    if (index < inttblCount)
                    {
                        //if index count is <=10, then no need to create extra rows, by default 10 rows will be there.
                        FillDepthValues(dblTopDepth, dblBottomDepth, intDepthInterval, index, strDepthname, drpDepthReference.SelectedItem.Value);
                    }
                    else
                    {
                        // if index count is >=10, then need to add new rows into HTML table.
                        GenerateRows(intMaxRowlength, index, strtblWithOutHeaderRow);
                        FillDepthValues(dblTopDepth, dblBottomDepth, intDepthInterval, index, strDepthname, drpDepthReference.SelectedItem.Value);

                    }
                }
                #endregion

                SetCSSforEditableAHTVdepth();

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

            }
            #endregion
        }