Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AuthenticateUser();
            if (Request.Cookies["profileid"] != null && Request.Cookies["profileid"].Value != "")
            {
                intProfile = Int32.Parse(Request.Cookies["profileid"].Value);
            }
            if (Request.QueryString["applicationid"] != null && Request.QueryString["applicationid"] != "")
            {
                intApplication = Int32.Parse(Request.QueryString["applicationid"]);
            }
            if (Request.Cookies["application"] != null && Request.Cookies["application"].Value != "")
            {
                intApplication = Int32.Parse(Request.Cookies["application"].Value);
            }
            oDataPoint        = new DataPoint(intProfile, dsn);
            oUser             = new Users(intProfile, dsn);
            oServer           = new Servers(intProfile, dsn);
            oAsset            = new Asset(intProfile, dsnAsset);
            oForecast         = new Forecast(intProfile, dsn);
            oPlatform         = new Platforms(intProfile, dsn);
            oType             = new Types(intProfile, dsn);
            oModel            = new Models(intProfile, dsn);
            oModelsProperties = new ModelsProperties(intProfile, dsn);
            oIPAddresses      = new IPAddresses(intProfile, dsnIP, dsn);
            oFunction         = new Functions(intProfile, dsn, intEnvironment);
            oOperatingSystem  = new OperatingSystems(intProfile, dsn);
            oServicePack      = new ServicePacks(intProfile, dsn);
            oClass            = new Classes(intProfile, dsn);
            oEnvironment      = new Environments(intProfile, dsn);
            oResiliency       = new Resiliency(intProfile, dsn);
            if (oUser.IsAdmin(intProfile) == true || (oDataPoint.GetPagePermission(intApplication, "ASSET") == true || intDataPointAvailableAsset == 1))
            {
                panAllow.Visible = true;
                if (Request.QueryString["save"] != null)
                {
                    panSave.Visible = true;
                }
                if (Request.QueryString["error"] != null)
                {
                    panError.Visible = true;
                    lblError.Text    = "Name Already Exists";
                }
                Int32.TryParse(oFunction.decryptQueryString(Request.QueryString["id"]), out intID);
                if (Request.QueryString["close"] != null)
                {
                    Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "close", "<script type=\"text/javascript\">window.close();<" + "/" + "script>");
                }
                else if (intID > 0)
                {
                    DataSet ds = oDataPoint.GetAsset(intID);
                    if (ds.Tables[0].Rows.Count == 1)
                    {
                        // Load General Information
                        intAsset        = Int32.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                        lblAssetID.Text = "#" + intAsset.ToString();
                        string strSerial = ds.Tables[0].Rows[0]["serial"].ToString();
                        string strAsset  = ds.Tables[0].Rows[0]["asset"].ToString();

                        string strHeader = (strSerial.Length > 15 ? strSerial.Substring(0, 15) + "..." : strSerial);
                        lblHeader.Text    = "&quot;" + strHeader.ToUpper() + "&quot;";
                        Master.Page.Title = "DataPoint | Enclosure (" + strHeader + ")";
                        lblHeaderSub.Text = "Provides all the information about an enclosure...";
                        int intMenuTab = 0;
                        if (Request.QueryString["menu_tab"] != null && Request.QueryString["menu_tab"] != "")
                        {
                            intMenuTab = Int32.Parse(Request.QueryString["menu_tab"]);
                        }
                        Tab oTab = new Tab(hdnTab.ClientID, intMenuTab, "divMenu1", true, false);
                        oTab.AddTab("Asset Information", "");
                        oTab.AddTab("Location Information", "");
                        oTab.AddTab("Virtual Connect IPs", "");
                        oTab.AddTab("Resource Dependencies", "");
                        oTab.AddTab("Provisioning History", "");
                        oTab.AddTab("Blades", "");
                        //oTab.AddTab("Network Adapter Configuration", "");
                        strMenuTab1 = oTab.GetTabs();
                        if (oUser.IsAdmin(intProfile) == true || oDataPoint.GetFieldPermission(intProfile, "SERVER_ADMIN") == true)
                        {
                            panOldLocationInfo.Visible = true;
                        }

                        if (!IsPostBack)
                        {
                            //DataSet dsAssets = oServer.GetAsset(intAsset);
                            //foreach (DataRow drAsset in dsAssets.Tables[0].Rows)
                            //{
                            //    if (drAsset["latest"].ToString() == "1")
                            //    {
                            //        intAsset = Int32.Parse(drAsset["assetid"].ToString());
                            //        intAssetClass = Int32.Parse(drAsset["classid"].ToString());
                            //        intAssetEnv = Int32.Parse(drAsset["environmentid"].ToString());
                            //        break;
                            //    }
                            //}

                            // Asset Information
                            oDataPoint.LoadTextBox(txtPlatformSerial, intProfile, null, "", lblPlatformSerial, fldPlatformSerial, "ENCLOSURE_SERIAL", strSerial, "", false, true);
                            oDataPoint.LoadTextBox(txtPlatformAsset, intProfile, null, "", lblPlatformAsset, fldPlatformAsset, "ENCLOSURE_ASSET", strAsset, "", false, true);

                            int intAssetAttribute = Int32.Parse(oAsset.Get(intAsset, "asset_attribute"));
                            oDataPoint.LoadDropDown(ddlAssetAttribute, intProfile, null, "", lblAssetAttribute, fldAssetAttribute, "ASSET_ATTRIBUTE", "Name", "AttributeId", oAsset.getAssetAttributes(null, "", 1), intAssetAttribute, true, false, false);
                            oDataPoint.LoadTextBox(txtAssetAttributeComment, intProfile, null, "", lblAssetAttributeComment, fldAssetAttributeComment, "ASSET_ATTRIBUTE_COMMENT", oAsset.getAssetAttributesComments(intAsset), "", false, true);
                            ddlAssetAttribute.Attributes.Add("onclick", "return SetControlsForAssetAttributes()");

                            ddlPlatform.Attributes.Add("onchange", "PopulatePlatformTypes('" + ddlPlatform.ClientID + "','" + ddlPlatformType.ClientID + "','" + ddlPlatformModel.ClientID + "','" + ddlPlatformModelProperty.ClientID + "');ResetDropDownHidden('" + hdnModel.ClientID + "');");
                            ddlPlatformType.Attributes.Add("onchange", "PopulatePlatformModels('" + ddlPlatformType.ClientID + "','" + ddlPlatformModel.ClientID + "','" + ddlPlatformModelProperty.ClientID + "');ResetDropDownHidden('" + hdnModel.ClientID + "');");
                            ddlPlatformModel.Attributes.Add("onchange", "PopulatePlatformModelProperties('" + ddlPlatformModel.ClientID + "','" + ddlPlatformModelProperty.ClientID + "');ResetDropDownHidden('" + hdnModel.ClientID + "');");
                            ddlPlatformModelProperty.Attributes.Add("onchange", "UpdateDropDownHidden('" + ddlPlatformModelProperty.ClientID + "','" + hdnModel.ClientID + "');");
                            int intModel = Int32.Parse(oAsset.Get(intAsset, "modelid"));

                            hdnModel.Value = intModel.ToString();
                            int intModelParent = Int32.Parse(oModelsProperties.Get(intModel, "modelid"));
                            int intType        = oModel.GetType(intModelParent);
                            int intPlatform    = oType.GetPlatform(intType);
                            oDataPoint.LoadDropDown(ddlPlatform, intProfile, null, "", lblPlatform, fldPlatform, "ENCLOSURE_PLATFORM", "name", "platformid", oPlatform.Gets(1), intPlatform, false, false, true);
                            oDataPoint.LoadDropDown(ddlPlatformType, intProfile, null, "", lblPlatformType, fldPlatformType, "ENCLOSURE_TYPE", "name", "id", oType.Gets(intPlatform, 1), intType, false, false, true);
                            oDataPoint.LoadDropDown(ddlPlatformModel, intProfile, null, "", lblPlatformModel, fldPlatformModel, "ENCLOSURE_MODEL", "name", "id", oModel.Gets(intType, 1), intModelParent, false, false, true);
                            oDataPoint.LoadDropDown(ddlPlatformModelProperty, intProfile, null, "", lblPlatformModelProperty, fldPlatformModelProperty, "ENCLOSURE_MODEL_PROP", "name", "id", oModelsProperties.GetModels(0, intModelParent, 1), intModel, false, false, true);

                            // Get Asset
                            DataSet dsAsset = oAsset.GetEnclosure(intAsset);
                            if (dsAsset.Tables[0].Rows.Count > 0)
                            {
                                oDataPoint.LoadTextBox(txtName, intProfile, null, "", lblName, fldName, "ENCLOSURE_NAME", dsAsset.Tables[0].Rows[0]["name"].ToString(), "", false, false);
                                if (txtName.Text != "")
                                {
                                    lblHeader.Text += "&nbsp;&nbsp;&nbsp;[" + txtName.Text + "]";
                                }
                                lblStatus.Text = dsAsset.Tables[0].Rows[0]["statusname"].ToString();
                                int intClass = Int32.Parse(dsAsset.Tables[0].Rows[0]["classid"].ToString());
                                int intEnv   = Int32.Parse(dsAsset.Tables[0].Rows[0]["environmentid"].ToString());
                                hdnEnvironment.Value = intEnv.ToString();

                                oDataPoint.LoadDropDown(ddlPlatformClass, intProfile, null, "", lblPlatformClass, fldPlatformClass, "ENCLOSURE_CLASS", "name", "id", oClass.Gets(1), intClass, false, false, true);
                                oDataPoint.LoadDropDown(ddlPlatformEnvironment, intProfile, null, "", lblPlatformEnvironment, fldPlatformEnvironment, "ENCLOSURE_ENVIRONMENT", "name", "id", oClass.GetEnvironment(intClass, 0), intEnv, false, false, true);
                                oDataPoint.LoadTextBox(txtPlatformVLAN, intProfile, null, "", lblPlatformVLAN, fldPlatformVLAN, "ENCLOSURE_VLAN", dsAsset.Tables[0].Rows[0]["vlan"].ToString(), "", false, true);
                                if (dsAsset.Tables[0].Rows[0]["oa_ip"].ToString() != "")
                                {
                                    oDataPoint.LoadTextBox(txtPlatformOA, intProfile, btnOA, "https://" + dsAsset.Tables[0].Rows[0]["oa_ip"].ToString(), lblPlatformOA, fldPlatformOA, "ENCLOSURE_OA", dsAsset.Tables[0].Rows[0]["oa_ip"].ToString(), "", false, true);
                                }
                                else
                                {
                                    oDataPoint.LoadTextBox(txtPlatformOA, intProfile, null, "", lblPlatformOA, fldPlatformOA, "ENCLOSURE_OA", dsAsset.Tables[0].Rows[0]["oa_ip"].ToString(), "", false, true);
                                }
                                int intResiliency = 0;
                                Int32.TryParse(dsAsset.Tables[0].Rows[0]["resiliencyid"].ToString(), out intResiliency);
                                oDataPoint.LoadDropDown(ddlPlatformResiliency, intProfile, null, "", lblPlatformResiliency, fldPlatformResiliency, "ENCLOSURE_RESILIENCY", "name", "id", oResiliency.Gets(1), intResiliency, false, false, true);

                                lblOldlocation.Text = dsAsset.Tables[0].Rows[0]["OldLocation"].ToString();
                                lblOldRoom.Text     = dsAsset.Tables[0].Rows[0]["OldRoom"].ToString();
                                lblOldRack.Text     = dsAsset.Tables[0].Rows[0]["OldRack"].ToString();

                                txtLocation.Text     = dsAsset.Tables[0].Rows[0]["Location"].ToString();
                                txtRoom.Text         = dsAsset.Tables[0].Rows[0]["Room"].ToString();
                                txtZone.Text         = dsAsset.Tables[0].Rows[0]["Zone"].ToString();
                                txtRack.Text         = dsAsset.Tables[0].Rows[0]["Rack"].ToString();
                                txtRackPosition.Text = dsAsset.Tables[0].Rows[0]["Rackposition"].ToString();
                                oDataPoint.LoadTextBox(txtRackPosition, intProfile, null, "", lblRackPositionValue, fldLocation, "CHANGE_LOCATION", dsAsset.Tables[0].Rows[0]["rackposition"].ToString(), "", false, true);
                                hdnRackId.Value = dsAsset.Tables[0].Rows[0]["NewRackId"].ToString();

                                oDataPoint.LoadButton(btnSelectLocation, intProfile, fldLocation, "CHANGE_LOCATION",
                                                      "return LoadLocationRoomRack('" + "rack" + "','" + hdnRackId.ClientID + "', '" + txtLocation.ClientID + "','" + txtRoom.ClientID + "','" + txtZone.ClientID + "','" + txtRack.ClientID + "');");


                                //DR Counterpart
                                int    intDR = oAsset.GetDR(intAsset);
                                string strDR = oAsset.Get(intDR, "serial");
                                if (intDR > 0)
                                {
                                    oDataPoint.LoadTextBox(txtPlatformDRCounterPart, intProfile, btnPlatformDRCounterPart, "/datapoint/asset/datapoint_asset_search.aspx?t=serial&q=" + oFunction.encryptQueryString(strDR) + "&id=" + oFunction.encryptQueryString(intDR.ToString()), lblPlatformDRCounterPart, fldPlatformDRCounterPart, "BLADE_DR", strDR, "", true, false);
                                }
                                else
                                {
                                    oDataPoint.LoadTextBox(txtPlatformDRCounterPart, intProfile, null, "", lblPlatformDRCounterPart, fldPlatformDRCounterPart, "BLADE_DR", "", "", true, false);
                                }

                                ddlStatus.SelectedValue = dsAsset.Tables[0].Rows[0]["status"].ToString();
                                ddlStatus.Enabled       = (intAssetAttribute == (int)AssetAttribute.Ok);
                                panStatus.Visible       = (ddlStatus.Enabled == false);
                            }
                            else
                            {
                                Response.Redirect("/datapoint/asset/enclosure_deploy.aspx?t=serial&q=" + oFunction.encryptQueryString(strSerial) + "&id=" + oFunction.encryptQueryString(intAsset.ToString()) + "&r=0");
                            }

                            // Resource Dependencies
                            AssetOrder      oAssetOrder     = new AssetOrder(0, dsn, dsnAsset, intEnvironment);
                            Services        oService        = new Services(0, dsn);
                            ServiceRequests oServiceRequest = new ServiceRequests(0, dsn);
                            rptServiceRequests.DataSource = oAssetOrder.GetByAsset(intAsset, false);
                            rptServiceRequests.DataBind();
                            trServiceRequests.Visible = (rptServiceRequests.Items.Count == 0);
                            foreach (RepeaterItem ri in rptServiceRequests.Items)
                            {
                                Label lblServiceID = (Label)ri.FindControl("lblServiceID");
                                int   intService   = Int32.Parse(lblServiceID.Text);
                                Label lblDetails   = (Label)ri.FindControl("lblDetails");
                                Label lblProgress  = (Label)ri.FindControl("lblProgress");

                                if (lblProgress.Text == "")
                                {
                                    lblProgress.Text = "<i>Unavailable</i>";
                                }
                                else
                                {
                                    int     intResource  = Int32.Parse(lblProgress.Text);
                                    double  dblAllocated = 0.00;
                                    double  dblUsed      = 0.00;
                                    int     intStatus    = 0;
                                    bool    boolAssigned = false;
                                    DataSet dsResource   = oDataPoint.GetServiceRequestResource(intResource);
                                    if (dsResource.Tables[0].Rows.Count > 0)
                                    {
                                        Int32.TryParse(dsResource.Tables[0].Rows[0]["status"].ToString(), out intStatus);
                                    }
                                    foreach (DataRow drResource in dsResource.Tables[1].Rows)
                                    {
                                        boolAssigned  = true;
                                        dblAllocated += double.Parse(drResource["allocated"].ToString());
                                        dblUsed      += double.Parse(drResource["used"].ToString());
                                        intStatus     = Int32.Parse(drResource["status"].ToString());
                                    }
                                    if (intStatus == (int)ResourceRequestStatus.Closed)
                                    {
                                        lblProgress.Text = oServiceRequest.GetStatusBar(100.00, "100", "12", true);
                                    }
                                    else if (intStatus == (int)ResourceRequestStatus.Cancelled)
                                    {
                                        lblProgress.Text = "Cancelled";
                                    }
                                    else if (boolAssigned == false)
                                    {
                                        string  strManager = "";
                                        DataSet dsManager  = oService.GetUser(intService, 1); // Managers
                                        foreach (DataRow drManager in dsManager.Tables[0].Rows)
                                        {
                                            if (strManager != "")
                                            {
                                                strManager += "\\n";
                                            }
                                            int intManager = Int32.Parse(drManager["userid"].ToString());
                                            strManager += " - " + oUser.GetFullName(intManager) + " [" + oUser.GetName(intManager) + "]";
                                        }
                                        lblProgress.Text = "<a href=\"javascript:void(0);\" class=\"lookup\" onclick=\"alert('This request is pending assignment by the following...\\n\\n" + strManager + "');\">Pending Assignment</a>";
                                    }
                                    else if (dblAllocated > 0.00)
                                    {
                                        lblProgress.Text = oServiceRequest.GetStatusBar((dblUsed / dblAllocated) * 100.00, "100", "12", true);
                                    }
                                    else
                                    {
                                        lblProgress.Text = "<i>N / A</i>";
                                    }
                                    lblDetails.Text = "<a href=\"javascript:void(0);\" class=\"lookup\" onclick=\"OpenNewWindowMenu('/datapoint/service/resource.aspx?id=" + oFunction.encryptQueryString(intResource.ToString()) + "', '800', '600');\">" + lblDetails.Text + "</a>";
                                }
                            }

                            // Provioning History
                            rptHistory.DataSource = oAsset.GetProvisioningHistory(oDataPoint.AssetHistorySelect(intAsset));
                            rptHistory.DataBind();
                            lblHistory.Visible = (rptHistory.Items.Count == 0);
                            oDataPoint.LoadPanel(panProvisioning, intProfile, fldProvisioning, "ENCLOSURE_STATUS");

                            // Virtual Connects
                            rptVirtualConnect.DataSource = oAsset.GetEnclosureVCs(intAsset, 1);
                            rptVirtualConnect.DataBind();
                            lblVirtualConnect.Visible = (rptVirtualConnect.Items.Count == 0);
                            oDataPoint.LoadButton(btnVC, intProfile, fldVC, "ENCLOSURE_VC", "return OpenWindow('ASSET_DEPLOY_VCs','" + intAsset.ToString() + "');");

                            if (Request.QueryString["highlight"] != null && Request.QueryString["highlight"] != "")
                            {
                                intHighlight = Int32.Parse(Request.QueryString["highlight"]);
                            }
                            // Blades
                            rptBlades.DataSource = oAsset.GetEnclosureBlades(intAsset);
                            rptBlades.DataBind();
                            lblBlades.Visible = (rptBlades.Items.Count == 0);

                            // Redeploy
                            oDataPoint.LoadButton(btnRedeploy, intProfile, fldRedeploy, "ENCLOSURE_REDEPLOY");
                            if (rptBlades.Items.Count == 0)
                            {
                                btnRedeploy.Attributes.Add("onclick", "return confirm('Are you sure you want to redeploy this enclosure?') && confirm('WARNING! Redeploying an asset means that ALL the information regarding this asset will be erased.\\n\\nAre you sure you want to redeploy this enclosure?');");
                            }
                            else
                            {
                                btnRedeploy.Attributes.Add("onclick", "return confirm('Are you sure you want to redeploy this enclosure?\\n\\WARNING: The blades associated with this enclosure have not been redployed!\\nIt is STRONGLY recommended that you redeploy the blades first to avoid corrupting the asset database.\\n\\nAre you sure you want to continue?');");
                            }
                            oDataPoint.LoadButton(btnRedeployBlades, intProfile, fldRedeployBlades, "ENCLOSURE_REDEPLOY_BLADES");
                            if (rptBlades.Items.Count == 0)
                            {
                                btnRedeployBlades.Attributes.Add("onclick", "alert('All blades have already been redeployed');return false;;");
                            }
                            else
                            {
                                btnRedeployBlades.Attributes.Add("onclick", "return confirm('Are you sure you want to redeploy ALL the blades in this enclosure?') && confirm('WARNING! Redeploying an asset means that ALL the information regarding this asset will be erased.\\n\\nAre you sure you want to redeploy ALL the blades in this enclosure?');");
                            }
                        }
                    }
                    else
                    {
                        if (Request.QueryString["t"] != null && Request.QueryString["q"] != null)
                        {
                            Response.Redirect("/datapoint/asset/datapoint_asset_search.aspx?t=" + Request.QueryString["t"] + "&q=" + Request.QueryString["q"] + "&r=0");
                        }
                        else
                        {
                            Response.Redirect("/datapoint/asset/datapoint_asset_search.aspx");
                        }
                    }
                }
                else if (Request.QueryString["q"] != null && Request.QueryString["q"] != "")
                {
                    string  strQuery = oFunction.decryptQueryString(Request.QueryString["q"]);
                    DataSet ds       = oDataPoint.GetAssetName(strQuery, intID, 0, "", "", 0);
                    if (ds.Tables[0].Rows.Count == 1)
                    {
                        intAsset = Int32.Parse(ds.Tables[0].Rows[0]["assetid"].ToString());
                        Response.Redirect(Request.Path + "?t=" + Request.QueryString["t"] + "&q=" + Request.QueryString["q"] + "&id=" + oFunction.encryptQueryString(intAsset.ToString()));
                    }
                    else
                    {
                        Response.Redirect("/datapoint/asset/datapoint_asset_search.aspx?multiple=true&t=" + Request.QueryString["t"] + "&q=" + Request.QueryString["q"]);
                    }
                }
                else
                {
                    Response.Redirect("/datapoint/asset/datapoint_asset_search.aspx");
                }
                btnClose.Attributes.Add("onclick", "window.close();return false;");
                btnPrint.Attributes.Add("onclick", "window.print();return false;");
                btnSave.Attributes.Add("onclick", oDataPoint.LoadValidation());
                btnSaveClose.Attributes.Add("onclick", oDataPoint.LoadValidation());
                ddlPlatformClass.Attributes.Add("onchange", "PopulateEnvironments('" + ddlPlatformClass.ClientID + "','" + ddlPlatformEnvironment.ClientID + "',0);");
                ddlPlatformEnvironment.Attributes.Add("onchange", "UpdateDropDownHidden('" + ddlPlatformEnvironment.ClientID + "','" + hdnEnvironment.ClientID + "');");
                //ddlLocationState.Attributes.Add("onchange", "LoadLocationCity('" + ddlLocationCity.ClientID + "');LoadLocationAddress('" + ddlLocationAddress.ClientID + "');PopulateCitys('" + ddlLocationState.ClientID + "','" + ddlLocationCity.ClientID + "');ResetDropDownHidden('" + hdnAddress.ClientID + "');");
                //ddlLocationCity.Attributes.Add("onchange", "LoadLocationAddress('" + ddlLocationAddress.ClientID + "');PopulateAddresss('" + ddlLocationCity.ClientID + "','" + ddlLocationAddress.ClientID + "');ResetDropDownHidden('" + hdnAddress.ClientID + "');");
                //ddlLocationAddress.Attributes.Add("onchange", "UpdateDropDownHidden('" + ddlLocationAddress.ClientID + "','" + hdnAddress.ClientID + "');");
            }
            else
            {
                panDenied.Visible = true;
            }
        }
Example #2
0
        private void LoadRepeater(Repeater rptControl, string strViewRequest)
        {
            foreach (RepeaterItem ri in rptControl.Items)
            {
                Button btnCancel = (Button)ri.FindControl("btnCancel");
                if (btnCancel != null)
                {
                    btnCancel.Attributes.Add("onclick", "return confirm('NOTE: When you cancel a service in ClearView, the following actions will be taken...\\n\\n - Incomplete work will be stopped immediately\\n - Assigned technicians will be notified\\n\\nAre you sure you want to cancel this service?');");
                }
                LinkButton btnNumber = (LinkButton)ri.FindControl("btnNumber");
                int        intNumber = 0;
                if (btnNumber != null)
                {
                    if (btnNumber.Text != "")
                    {
                        intNumber = Int32.Parse(btnNumber.Text);
                    }
                }
                int    intService = 0;
                Button btnView    = (Button)ri.FindControl("btnView");
                intService = Int32.Parse(btnView.CommandArgument);

                Label lblDetails       = (Label)ri.FindControl("lblDetails");
                Label lblProgress      = (Label)ri.FindControl("lblProgress");
                Label lblRequestStatus = (Label)ri.FindControl("lblRequestStatus");
                if (lblRequestStatus.Text == "Submitted")
                {
                    if (btnNumber != null)
                    {
                        if (strViewRequest != "" && oService.Get(intService, "disable_customization") == "0")
                        {
                            if (intNumber > 0)
                            {
                                btnNumber.Attributes.Add("onclick", "return OpenWindow('PRINTER_FRIENDLY','?page=" + intViewRequest.ToString() + "&rid=" + intRequest.ToString() + "&formid=" + intService.ToString() + "&num=" + intNumber.ToString() + "&view=true', '800', '600');");
                            }
                            else
                            {
                                btnNumber.Enabled = false;
                            }
                        }
                        else
                        {
                            btnNumber.Enabled = false;
                        }
                    }

                    if (lblProgress.Text == "")
                    {
                        lblProgress.Text = "<i>Unavailable</i>";
                        if (btnNumber != null)
                        {
                            btnNumber.Enabled = false;
                        }
                    }
                    else
                    {
                        int     intResource  = Int32.Parse(lblProgress.Text);
                        double  dblAllocated = 0.00;
                        double  dblUsed      = 0.00;
                        bool    boolAssigned = false;
                        DataSet dsResource   = oDataPoint.GetServiceRequestResource(intResource);
                        foreach (DataRow drResource in dsResource.Tables[1].Rows)
                        {
                            if (drResource["deleted"].ToString() == "0")
                            {
                                boolAssigned  = true;
                                dblAllocated += double.Parse(drResource["allocated"].ToString());
                                dblUsed      += double.Parse(drResource["used"].ToString());
                            }
                        }
                        if (boolAssigned == false)
                        {
                            Label lblOnDemand = (Label)ri.FindControl("lblOnDemand");
                            if (lblOnDemand == null || lblOnDemand.Text == "0")
                            {
                                Label lblAutomate = (Label)ri.FindControl("lblAutomate");
                                if (lblAutomate == null || lblAutomate.Text == "0")
                                {
                                    string  strManager = "<tr><td colspan=\"3\"><img src=\"/images/spacer.gif\" border=\"0\" width=\"15\" height=\"1\"/></td></tr>";
                                    DataSet dsManager  = oService.GetUser(intService, 1); // Managers
                                    foreach (DataRow drManager in dsManager.Tables[0].Rows)
                                    {
                                        int intManager = Int32.Parse(drManager["userid"].ToString());
                                        strManager += "<tr><td><img src=\"/images/spacer.gif\" border=\"0\" width=\"15\" height=\"1\"/></td><td>-</td><td><a href=\"javascript:void(0);\" class=\"lookup\" onclick=\"OpenWindow('PROFILE','?userid=" + intManager.ToString() + "');\">" + oUser.GetFullName(intManager) + " [" + oUser.GetName(intManager) + "]</a></td></tr>";
                                    }
                                    lblProgress.Text = "Pending Assignment [<a href=\"javascript:void(0);\" class=\"lookup\" onclick=\"ShowHideDiv2('divAssign" + intResource.ToString() + "');\">View Service Managers</a>]<div id=\"divAssign" + intResource.ToString() + "\" style=\"display:none\"><table cellpadding=\"2\" cellspacing=\"2\" border=\"0\">" + strManager + "</table></div>";
                                }
                                else
                                {   //For automated
                                    lblProgress.Text  = oServiceRequest.GetStatusBar(100.00, "100", "12", true);
                                    btnView.Visible   = false;
                                    btnCancel.Visible = false;
                                }
                            }
                            else
                            {
                                DataSet dsSelected = oService.GetSelected(intRequest, intService, intNumber);
                                for (int ii = intNumber; ii > 0 && dsSelected.Tables[0].Rows.Count == 0; ii--)
                                {
                                    dsSelected = oService.GetSelected(intRequest, intService, ii - 1);
                                }
                                int intApproved = 0;
                                if (dsSelected.Tables[0].Rows.Count > 0)
                                {
                                    intApproved = Int32.Parse(dsSelected.Tables[0].Rows[0]["approved"].ToString());
                                }

                                if (intApproved > 0)
                                {
                                    Forecast         oForecast         = new Forecast(intProfile, dsn);
                                    ModelsProperties oModelsProperties = new ModelsProperties(intProfile, dsn);
                                    Types            oType             = new Types(intProfile, dsn);
                                    DataSet          dsService         = oForecast.GetAnswerService(intRequest);
                                    if (dsService.Tables[0].Rows.Count > 0)
                                    {
                                        int    intAnswer  = Int32.Parse(dsService.Tables[0].Rows[0]["id"].ToString());
                                        int    intModel   = Int32.Parse(dsService.Tables[0].Rows[0]["modelid"].ToString());
                                        int    intType    = oModelsProperties.GetType(intModel);
                                        string strExecute = oType.Get(intType, "forecast_execution_path");
                                        if (strExecute != "")
                                        {
                                            lblProgress.Text = "<a href=\"javascript:void(0);\" class=\"lookup\" title=\"Click here to execute this service\" onclick=\"OpenWindow('FORECAST_EXECUTE','" + strExecute + "?id=" + intAnswer.ToString() + "');\">Execute</a>";
                                        }
                                        else
                                        {
                                            lblProgress.Text = "<a href=\"javascript:void(0);\" class=\"lookup\" title=\"Click here to execute this service\" onclick=\"alert('Execution has not been configured for asset type " + oType.Get(intType, "name") + "');\">Execute</a>";
                                        }
                                    }
                                }
                                else
                                {
                                    lblProgress.Text = "<a title=\"Click here to execute this service\" disabled=\"disabled\">Execute</a>";
                                    if (intApproved < 0)
                                    {
                                        int    intDenied     = Int32.Parse(dsSelected.Tables[0].Rows[0]["approvedby"].ToString());
                                        string strApprovedOn = dsSelected.Tables[0].Rows[0]["approvedon"].ToString();
                                        string strReason     = dsSelected.Tables[0].Rows[0]["reason"].ToString();
                                        lblRequestStatus.Text = "<a href=\"javascript:void(0);\" onclick=\"alert('Denied By: " + oUser.GetFullName(intDenied) + "\\nDenied On: " + strApprovedOn + "\\nReason: " + strReason.Replace(Environment.NewLine, "\\n") + "');\">Request Denied</a>";
                                    }
                                    else
                                    {
                                        lblRequestStatus.Text = "Pending Approval";
                                    }
                                }
                            }
                        }
                        else if (dblAllocated > 0.00)
                        {
                            lblProgress.Text = oServiceRequest.GetStatusBar((dblUsed / dblAllocated) * 100.00, "100", "12", true);
                        }
                        else
                        {
                            lblProgress.Text = "<i>N / A</i>";
                        }
                        btnView.Attributes.Add("onclick", "return OpenNewWindowMenu('/datapoint/service/resource.aspx?id=" + oFunction.encryptQueryString(intResource.ToString()) + "', '800', '600');");
                        btnView.ToolTip = "ResourceID: " + intResource.ToString();
                        if (btnNumber != null)
                        {
                            lblDetails.Text = "<a href=\"javascript:void(0);\" class=\"lookup\" onclick=\"OpenWindow('SERVICES_DETAIL','?rid=" + intRequest.ToString() + "&sid=" + intService.ToString() + "');\" title=\"Click here to view the details of this service\">" + oService.Get(intService, "name") + "</a>";
                        }
                        else
                        {
                            lblDetails.Text = "<a href=\"javascript:void(0);\" class=\"lookup\" onclick=\"OpenWindow('SERVICES_DETAIL','?sid=" + intService.ToString() + "');\" title=\"Click here to view the details of this service\">" + oService.Get(intService, "name") + "</a>";
                        }
                    }
                }
                else
                {
                    btnView.Enabled = false;
                    if (btnCancel != null)
                    {
                        btnCancel.Enabled = false;
                    }
                    if (btnNumber != null)
                    {
                        if (strViewRequest != "" && oService.Get(intService, "disable_customization") == "0" && lblProgress.Text.ToUpper().Contains("AWAITING") == true)
                        {
                            if (intNumber > 0)
                            {
                                btnNumber.Attributes.Add("onclick", "return OpenNewWindowMenu('" + strViewRequest + "?rid=" + intRequest.ToString() + "&formid=" + intService.ToString() + "&num=" + intNumber.ToString() + "', '800', '600');");
                            }
                            else
                            {
                                btnNumber.Enabled = false;
                            }
                        }
                        else
                        {
                            btnNumber.Enabled = false;
                        }
                    }
                    lblProgress.Text = "---";
                }

                // Load Workflow Repeaters
                Repeater rptWorkflow = (Repeater)ri.FindControl("rptWorkflow");
                if (rptWorkflow != null)
                {
                    LoadRepeater(rptWorkflow, strViewRequest);
                }
            }
        }
Example #3
0
        protected void LoadSearch(int _search)
        {
            Search          oSearch          = new Search(intProfile, dsn);
            RequestItems    oRequestItem     = new RequestItems(intProfile, dsn);
            Services        oService         = new Services(intProfile, dsn);
            Applications    oApplication     = new Applications(intProfile, dsn);
            StatusLevels    oStatusLevel     = new StatusLevels();
            Users           oUser            = new Users(intProfile, dsn);
            Projects        oProject         = new Projects(intProfile, dsn);
            ResourceRequest oResourceRequest = new ResourceRequest(intProfile, dsn);
            ServiceRequests oServiceRequest  = new ServiceRequests(intProfile, dsn);
            DataSet         ds             = oSearch.GetProject(_search);
            int             intApplication = 0;

            if (Request.QueryString["applicationid"] != null && Request.QueryString["applicationid"] != "")
            {
                intApplication = Int32.Parse(Request.QueryString["applicationid"]);
            }
            if (Request.Cookies["application"] != null && Request.Cookies["application"].Value != "")
            {
                intApplication = Int32.Parse(Request.Cookies["application"].Value);
            }
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["userid"].ToString() == intProfile.ToString())
                {
                    string strType        = ds.Tables[0].Rows[0]["type"].ToString();
                    string strClause      = "cv_projects.deleted = 0 AND cv_projects.number NOT LIKE 'CV%' AND cv_projects.number NOT LIKE 'EPS%'";
                    string strOr1         = "";
                    string strOr2         = "";
                    string strSQL         = "SELECT DISTINCT '?pid=' + CAST(cv_projects.projectid AS varchar(10)) + '&sid=" + _search.ToString() + "' AS query, cv_projects.name, cv_projects.number, cv_projects.status, cv_projects.modified FROM cv_projects INNER JOIN cv_requests LEFT OUTER JOIN cv_service_requests ON cv_service_requests.requestid = cv_requests.requestid AND cv_service_requests.deleted = 0 LEFT OUTER JOIN cv_project_requests ON cv_project_requests.requestid = cv_requests.requestid AND cv_project_requests.deleted = 0 INNER JOIN cv_resource_requests INNER JOIN cv_request_items INNER JOIN cv_applications ON cv_request_items.applicationid = cv_applications.applicationid AND cv_applications.deleted = 0 ON cv_request_items.itemid = cv_resource_requests.itemid AND cv_request_items.deleted = 0 INNER JOIN cv_users ON cv_resource_requests.userid = cv_users.userid AND cv_users.deleted = 0 AND cv_users.enabled = 1 ON cv_requests.requestid = cv_resource_requests.requestid AND cv_resource_requests.deleted = 0 ON cv_requests.projectid = cv_projects.projectid AND cv_requests.deleted = 0 WHERE ";
                    string strApplication = " AND cv_request_items.applicationid = " + intApplication.ToString();
                    switch (strType)
                    {
                    case "O":
                        strApplication = "";
                        string strOName   = ds.Tables[0].Rows[0]["oname"].ToString().Trim();
                        string strONumber = ds.Tables[0].Rows[0]["onumber"].ToString().Trim();
                        if (strONumber != "")
                        {
                            strClause      += " AND cv_projects.number LIKE '%" + strONumber + "%'";
                            lblResults.Text = "Project Number LIKE &quot;" + strONumber + "&quot;";
                        }
                        else
                        {
                            strClause      += " AND cv_projects.name LIKE '%" + strOName + "%'";
                            lblResults.Text = "Project Name LIKE &quot;" + strOName + "&quot;";
                        }
                        string strOStatus = ds.Tables[0].Rows[0]["ostatus"].ToString();
                        if (strOStatus != "0")
                        {
                            strClause += " AND cv_projects.status = " + strOStatus;
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Status = &quot;" + oStatusLevel.Name(Int32.Parse(strOStatus)) + "&quot;";
                        }
                        string strOStart = ds.Tables[0].Rows[0]["ostart"].ToString();
                        if (strOStart != "")
                        {
                            strOStart  = DateTime.Parse(strOStart).ToShortDateString();
                            strClause += " AND cv_projects.modified > " + strOStart;
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Project Date > &quot;" + strOStart + "&quot;";
                        }
                        string strOEnd = ds.Tables[0].Rows[0]["oend"].ToString();
                        if (strOEnd != "")
                        {
                            strOEnd    = DateTime.Parse(strOEnd).ToShortDateString();
                            strClause += " AND cv_projects.modified < " + strOEnd;
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Project Date < &quot;" + strOEnd + "&quot;";
                        }
                        break;

                    case "P":
                        string strDepartment = ds.Tables[0].Rows[0]["department"].ToString();
                        if (strDepartment == "0")
                        {
                            strApplication   = "";
                            lblResults.Text += "Department = &quot;ALL&quot;";
                        }
                        else
                        {
                            strApplication   = " AND cv_request_items.applicationid = " + strDepartment;
                            lblResults.Text += "Department = &quot;" + oApplication.GetName(Int32.Parse(strDepartment)) + "&quot;";
                        }
                        string strDStatus = ds.Tables[0].Rows[0]["dstatus"].ToString();
                        if (strDStatus != "0")
                        {
                            strClause += " AND cv_resource_requests.status = " + strDStatus;
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Status = &quot;" + oStatusLevel.Name(Int32.Parse(strDStatus)) + "&quot;";
                        }
                        string strDStart = ds.Tables[0].Rows[0]["dstart"].ToString();
                        if (strDStart != "")
                        {
                            strDStart  = DateTime.Parse(strDStart).ToShortDateString();
                            strClause += " AND cv_requests.modified > " + strDStart;
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Request Date > &quot;" + strDStart + "&quot;";
                        }
                        string strDEnd = ds.Tables[0].Rows[0]["dend"].ToString();
                        if (strDEnd != "")
                        {
                            strDEnd    = DateTime.Parse(strDEnd).ToShortDateString();
                            strClause += " AND cv_requests.modified < " + strDEnd;
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Request Date < &quot;" + strDEnd + "&quot;";
                        }
                        break;

                    case "T":
                        string strTechnician = ds.Tables[0].Rows[0]["technician"].ToString();
                        if (strTechnician != "0")
                        {
                            strClause       += " AND cv_resource_requests.userid = " + strTechnician;
                            lblResults.Text += "Technician = &quot;" + oUser.GetFullName(Int32.Parse(strTechnician)) + "&quot;";
                        }
                        string strTStatus = ds.Tables[0].Rows[0]["tstatus"].ToString();
                        if (strTStatus != "0")
                        {
                            strClause += " AND cv_resource_requests.status = " + strTStatus;
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Status = &quot;" + oStatusLevel.Name(Int32.Parse(strTStatus)) + "&quot;";
                        }
                        string strTStart = ds.Tables[0].Rows[0]["tstart"].ToString();
                        if (strTStart != "")
                        {
                            strTStart  = DateTime.Parse(strTStart).ToShortDateString();
                            strClause += " AND cv_requests.modified > " + strTStart;
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Request Date > &quot;" + strTStart + "&quot;";
                        }
                        string strTEnd = ds.Tables[0].Rows[0]["tend"].ToString();
                        if (strTEnd != "")
                        {
                            strTEnd    = DateTime.Parse(strTEnd).ToShortDateString();
                            strClause += " AND cv_requests.modified < " + strTEnd;
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Request Date < &quot;" + strTEnd + "&quot;";
                        }
                        break;

                    case "L":
                        string strLead = ds.Tables[0].Rows[0]["lead"].ToString();
                        if (strLead != "0")
                        {
                            int intLead = Int32.Parse(strLead);
                            strClause       += " AND cv_users.manager = " + intLead.ToString();
                            lblResults.Text += "Team Lead = &quot;" + oUser.GetFullName(intLead) + "&quot;";
                        }
                        string strLStatus = ds.Tables[0].Rows[0]["lstatus"].ToString();
                        if (strLStatus != "0")
                        {
                            strClause += " AND cv_resource_requests.status = " + strLStatus;
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Status = &quot;" + oStatusLevel.Name(Int32.Parse(strLStatus)) + "&quot;";
                        }
                        string strLStart = ds.Tables[0].Rows[0]["lstart"].ToString();
                        if (strLStart != "")
                        {
                            strLStart  = DateTime.Parse(strLStart).ToShortDateString();
                            strClause += " AND cv_requests.modified > " + strLStart;
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Request Date < &quot;" + strLStart + "&quot;";
                        }
                        string strLEnd = ds.Tables[0].Rows[0]["lend"].ToString();
                        if (strLEnd != "")
                        {
                            strLEnd    = DateTime.Parse(strLEnd).ToShortDateString();
                            strClause += " AND cv_requests.modified < " + strLEnd;
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Request Date > &quot;" + strLEnd + "&quot;";
                        }
                        break;

                    case "G":
                        string strItem = ds.Tables[0].Rows[0]["itemid"].ToString();
                        if (strItem != "0")
                        {
                            strClause       += " AND cv_resource_requests.itemid = " + strItem;
                            lblResults.Text += "Activity Type = &quot;" + oRequestItem.GetItemName(Int32.Parse(strItem)) + "&quot;";
                        }
                        string strGStatus = ds.Tables[0].Rows[0]["gstatus"].ToString();
                        if (strGStatus != "0")
                        {
                            strClause += " AND cv_resource_requests.status = " + strGStatus;
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Status = &quot;" + oStatusLevel.Name(Int32.Parse(strGStatus)) + "&quot;";
                        }
                        string strGStart = ds.Tables[0].Rows[0]["gstart"].ToString();
                        if (strGStart != "")
                        {
                            strGStart  = DateTime.Parse(strGStart).ToShortDateString();
                            strClause += " AND cv_requests.modified > " + strGStart;
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Request Date < &quot;" + strGStart + "&quot;";
                        }
                        string strGEnd = ds.Tables[0].Rows[0]["gend"].ToString();
                        if (strGEnd != "")
                        {
                            strGEnd    = DateTime.Parse(strGEnd).ToShortDateString();
                            strClause += " AND cv_requests.modified < " + strGEnd;
                            if (lblResults.Text != "")
                            {
                                lblResults.Text += " AND ";
                            }
                            lblResults.Text += "Request Date > &quot;" + strGEnd + "&quot;";
                        }
                        break;

                    case "S":
                        break;
                    }
                    strClause = strClause + strApplication;
                    if (strOr1 != "" && strOr2 != "")
                    {
                        strClause = strClause + " AND " + strOr1 + " AND cv_project_requests.id IS NOT NULL OR " + strClause + " AND " + strOr1 + " AND cv_service_requests.id IS NOT NULL OR " + strClause + " AND " + strOr2 + " AND cv_project_requests.id IS NOT NULL OR " + strClause + " AND " + strOr2 + " AND cv_service_requests.id IS NOT NULL";
                    }
                    else
                    {
                        strClause = strClause + " AND cv_project_requests.id IS NOT NULL OR " + strClause + " AND cv_service_requests.id IS NOT NULL";
                    }
                    ds = SqlHelper.ExecuteDataset(dsn, CommandType.Text, strSQL + strClause);
                    DataView dv = ds.Tables[0].DefaultView;
                    if (Request.QueryString["sort"] != null)
                    {
                        dv.Sort = Request.QueryString["sort"];
                    }
                    rptView.DataSource = dv;
                    rptView.DataBind();
                    foreach (RepeaterItem ri in rptView.Items)
                    {
                        Label _progress = (Label)ri.FindControl("lblProgress");
                        Label _status   = (Label)ri.FindControl("lblStatus");
                        _status.Text = oStatusLevel.HTML(Int32.Parse(_status.Text));
                        Label _updated = (Label)ri.FindControl("lblUpdated");
                        Label _number  = (Label)ri.FindControl("lblNumber");
                        if (_number.Text == "")
                        {
                            _number.Text = "<i>TBD...</i>";
                        }
                        double dblUsed      = 0.00;
                        double dblAllocated = 0.00;
                        if (_progress.Text.Contains("?pid=") == true)
                        {
                            int intProject = 0;
                            if (Request.QueryString["sid"] != null && Request.QueryString["sid"] != "")
                            {
                                string strProgress = _progress.Text.Substring(0, _progress.Text.IndexOf("&"));
                                intProject = Int32.Parse(strProgress.Substring(5));
                            }
                            else
                            {
                                intProject = Int32.Parse(_progress.Text.Substring(5));
                            }
                            _updated.Text = oProject.GetLastUpdated(intProject);
                            DataSet dsAll = oResourceRequest.GetWorkflowProject(intProject);
                            foreach (DataRow drAll in dsAll.Tables[0].Rows)
                            {
                                int intResourceWorkflow = Int32.Parse(drAll["id"].ToString());
                                dblAllocated += double.Parse(oResourceRequest.GetWorkflow(intResourceWorkflow, "allocated"));
                                dblUsed      += oResourceRequest.GetWorkflowUsed(intResourceWorkflow);
                            }
                        }
                        else if (_progress.Text.Contains("?rid=") == true)
                        {
                            int     intRequest = Int32.Parse(_progress.Text.Substring(5));
                            DataSet dsAll      = oResourceRequest.GetWorkflowRequestAll(intRequest);
                            foreach (DataRow drAll in dsAll.Tables[0].Rows)
                            {
                                int intResourceWorkflow = Int32.Parse(drAll["id"].ToString());
                                dblAllocated += double.Parse(oResourceRequest.GetWorkflow(intResourceWorkflow, "allocated"));
                                dblUsed      += oResourceRequest.GetWorkflowUsed(intResourceWorkflow);
                            }
                        }
                        double dblProgress = 0.00;
                        if (dblAllocated > 0.00)
                        {
                            dblProgress = (dblUsed / dblAllocated) * 100.00;
                        }
                        _progress.Text = oServiceRequest.GetStatusBar(dblProgress, "100", "6", true);
                    }
                    lblNone.Visible = (rptView.Items.Count == 0);
                }
            }
        }
        private string GetSummary(int _requestid, int _serviceid, int _number)
        {
            Users           oUser           = new Users(intProfile, dsn);
            ServiceRequests oServiceRequest = new ServiceRequests(intProfile, dsn);
            RequestItems    oRequestItem    = new RequestItems(intProfile, dsn);
            Applications    oApplication    = new Applications(intProfile, dsn);
            StringBuilder   sbSummary       = new StringBuilder();
            DataSet         ds       = oResourceRequest.GetRequestService(_requestid, _serviceid, _number);
            int             intCount = 0;

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                intCount++;
                int           intResource  = Int32.Parse(dr["id"].ToString());
                double        dblAllocated = double.Parse(dr["allocated"].ToString());
                double        dblUsed      = oResourceRequest.GetWorkflowUsed(intResource);
                DataSet       dsStatus     = oResourceRequest.GetStatuss(intResource);
                string        strStatus    = "";
                StringBuilder sbStatuses   = new StringBuilder();
                bool          boolChange   = false;
                foreach (DataRow drStatus in dsStatus.Tables[0].Rows)
                {
                    double dblStatus = double.Parse(drStatus["status"].ToString());
                    strStatus = oResourceRequest.GetStatus(dblStatus, 30, 15);
                    if (boolChange == true)
                    {
                        sbStatuses.Append("<tr>");
                    }
                    else
                    {
                        sbStatuses.Append("<tr bgcolor=\"#F6F6F6\">");
                    }
                    sbStatuses.Append("<td nowrap valign=\"top\" align=\"center\">");
                    sbStatuses.Append(oResourceRequest.GetStatus(dblStatus, 30, 10));
                    sbStatuses.Append("</td>");
                    sbStatuses.Append("<td nowrap valign=\"top\" align=\"center\">");
                    sbStatuses.Append(DateTime.Parse(drStatus["modified"].ToString()).ToShortDateString());
                    sbStatuses.Append("</td>");
                    sbStatuses.Append("<td width=\"100%\" valign=\"top\">");
                    sbStatuses.Append(drStatus["comments"].ToString());
                    sbStatuses.Append("</td>");
                    sbStatuses.Append("</tr>");
                    boolChange = !boolChange;
                }
                if (sbStatuses.ToString() != "")
                {
                    sbStatuses.Insert(0, "<table width=\"100%\" cellpadding=\"3\" cellspacing=\"0\" border=\"0\" style=\"border:solid 1px #CCCCCC\"><tr bgcolor=\"#EEEEEE\"><td>&nbsp;</td><td><b><u>Date:</u></b></td><td><b><u>Comments:</u></b></td></tr>");
                    sbStatuses.Append("</table>");
                }
                double dblProgress = 0.00;
                if (dblAllocated > 0.00)
                {
                    dblProgress = (dblUsed / dblAllocated) * 100.00;
                }
                sbSummary.Append("<tr>");
                sbSummary.Append("<td><img src=\"/images/resource_people.gif\" border=\"0\" align=\"absmiddle\"></td>");
                int intUser = Int32.Parse(dr["userid"].ToString());
                sbSummary.Append("<td>");
                sbSummary.Append(intUser > 0 ? oUser.GetFullName(intUser) : "Pending Assignment");
                sbSummary.Append("</td>");
                sbSummary.Append("<td>");
                sbSummary.Append(oApplication.GetName(oRequestItem.GetItemApplication(Int32.Parse(dr["itemid"].ToString()))));
                sbSummary.Append("</td>");
                sbSummary.Append("<td nowrap align=\"center\">");
                sbSummary.Append(intUser > 0 ? strStatus : "---");
                sbSummary.Append("</td>");
                sbSummary.Append("<td nowrap width=\"100\">");
                sbSummary.Append(intUser > 0 ? oServiceRequest.GetStatusBar(dblProgress, "100", "14", true) : "---");
                sbSummary.Append("</td>");
                sbSummary.Append("<td width=\"1\" nowrap><a href=\"javascript:void(0);\" onclick=\"ShowHide('div");
                sbSummary.Append(intCount.ToString());
                sbSummary.Append("');\">[Details]</a></td>");
                sbSummary.Append("</tr>");
                sbSummary.Append("<tr>");
                sbSummary.Append("<td colspan=\"6\">");
                sbSummary.Append("<div id=\"div");
                sbSummary.Append(intCount.ToString());
                sbSummary.Append("\" style=\"display:none\">");
                sbSummary.Append(sbStatuses.ToString());
                sbSummary.Append("</div>");
                sbSummary.Append("</td>");
                sbSummary.Append("</tr>");
            }

            sbSummary.Insert(0, "<table width=\"100%\" cellpadding=\"3\" cellspacing=\"2\" border=\"0\"><tr><td></td><td><b><u>Technician:</u></b></td><td><b><u>Department:</u></b></td><td align=\"center\"><b><u>Status:</u></b></td><td><b><u>Progress:</u></b></td><td></td></tr>");
            sbSummary.Append("</table>");

            return(sbSummary.ToString());
        }
Example #5
0
        private string GetSummary(int _requestid, int _serviceid, int _number)
        {
            Users           oUser           = new Users(intProfile, dsn);
            ServiceRequests oServiceRequest = new ServiceRequests(intProfile, dsn);
            RequestItems    oRequestItem    = new RequestItems(intProfile, dsn);
            Applications    oApplication    = new Applications(intProfile, dsn);
            StatusLevels    oStatus         = new StatusLevels();
            StringBuilder   sbSummary       = new StringBuilder();
            DataSet         ds       = oResourceRequest.GetRequestService(_requestid, _serviceid, _number);
            int             intCount = 0;

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                intCount++;
                int    intResource  = Int32.Parse(dr["id"].ToString());
                int    intItem      = Int32.Parse(dr["itemid"].ToString());
                int    intNumber    = Int32.Parse(dr["number"].ToString());
                int    intStatus    = Int32.Parse(dr["status"].ToString());
                double dblAllocated = double.Parse(dr["allocated"].ToString());
                double dblProgress  = 0.00;
                if (intStatus == 3)
                {
                    dblProgress = 100.00;
                }
                else
                {
                    double dblUsed = oResourceRequest.GetWorkflowUsed(intResource);
                    if (dblAllocated > 0.00)
                    {
                        dblProgress = (dblUsed / dblAllocated) * 100.00;
                    }
                }
                string  strReason   = "Unavailable";
                int     intApproval = 0;
                DataSet dsReason    = oResourceRequest.GetApproval(_requestid, intItem, intNumber);
                if (dsReason.Tables[0].Rows.Count > 0)
                {
                    strReason = dsReason.Tables[0].Rows[0]["reason"].ToString().Trim();
                    if (strReason == "")
                    {
                        strReason = "<i>No additional information...</i>";
                    }
                    intApproval = Int32.Parse(dsReason.Tables[0].Rows[0]["approval"].ToString());
                }
                string strStatus  = oStatus.Name(intApproval);
                bool   boolResult = (intApproval == 1);
                sbSummary.Append("<tr>");
                sbSummary.Append("<td width=\"1\"><img src=\"/images/resource_people.gif\" border=\"0\" align=\"absmiddle\"></td>");
                int intUser = Int32.Parse(dr["userid"].ToString());
                sbSummary.Append("<td>");
                sbSummary.Append(intUser > 0 ? oUser.GetFullName(intUser) : "Pending Assignment");
                sbSummary.Append("</td>");
                sbSummary.Append("<td>");
                sbSummary.Append(oApplication.GetName(oRequestItem.GetItemApplication(Int32.Parse(dr["itemid"].ToString()))));
                sbSummary.Append("</td>");
                sbSummary.Append("<td nowrap align=\"center\">");
                sbSummary.Append(intUser > 0 ? strStatus : "---");
                sbSummary.Append("</td>");
                sbSummary.Append("<td nowrap width=\"100\">");
                sbSummary.Append(intUser > 0 ? oServiceRequest.GetStatusBar(dblProgress, "100", "14", true) : "---");
                sbSummary.Append("</td>");
                sbSummary.Append("<td width=\"1\" nowrap><a href=\"javascript:void(0);\" onclick=\"ShowHide('div");
                sbSummary.Append(intCount.ToString());
                sbSummary.Append("_1');\">[Details]</a>");
                sbSummary.Append(boolResult ? "&nbsp;<a href=\"javascript:void(0);\" onclick=\"ShowHide('div" + intCount.ToString() + "_2');\">[Result]</a>" : "");
                sbSummary.Append("</td>");
                sbSummary.Append("</tr>");
                sbSummary.Append("<tr>");
                sbSummary.Append("<td colspan=\"6\">");
                sbSummary.Append("<div id=\"div");
                sbSummary.Append(intCount.ToString());
                sbSummary.Append("_1\" style=\"display:none\">");
                sbSummary.Append(strReason);
                sbSummary.Append("</div>");

                if (boolResult == true)
                {
                    string  strResult = "";
                    DataSet dsResult  = oRequest.GetResult(_requestid, intItem, intNumber);
                    foreach (DataRow drResult in dsResult.Tables[0].Rows)
                    {
                        strResult += drResult["result"].ToString();
                    }
                    sbSummary.Append("<div id=\"div");
                    sbSummary.Append(intCount.ToString());
                    sbSummary.Append("_2\" style=\"display:none\">");
                    sbSummary.Append(strResult);
                    sbSummary.Append("</div>");
                }
                sbSummary.Append("</td>");
                sbSummary.Append("</tr>");
            }

            sbSummary.Insert(0, "<table width=\"100%\" cellpadding=\"3\" cellspacing=\"2\" border=\"0\"><tr><td></td><td><b><u>Technician:</u></b></td><td><b><u>Department:</u></b></td><td align=\"center\"><b><u>Status:</u></b></td><td><b><u>Progress:</u></b></td><td></td></tr>");
            sbSummary.Append("</table>");

            return(sbSummary.ToString());
        }
Example #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AuthenticateUser();
            if (Request.Cookies["profileid"] != null && Request.Cookies["profileid"].Value != "")
            {
                intProfile = Int32.Parse(Request.Cookies["profileid"].Value);
            }
            if (Request.QueryString["applicationid"] != null && Request.QueryString["applicationid"] != "")
            {
                intApplication = Int32.Parse(Request.QueryString["applicationid"]);
            }
            if (Request.Cookies["application"] != null && Request.Cookies["application"].Value != "")
            {
                intApplication = Int32.Parse(Request.Cookies["application"].Value);
            }
            oDataPoint        = new DataPoint(intProfile, dsn);
            oUser             = new Users(intProfile, dsn);
            oServer           = new Servers(intProfile, dsn);
            oAsset            = new Asset(intProfile, dsnAsset);
            oForecast         = new Forecast(intProfile, dsn);
            oPlatform         = new Platforms(intProfile, dsn);
            oType             = new Types(intProfile, dsn);
            oModel            = new Models(intProfile, dsn);
            oModelsProperties = new ModelsProperties(intProfile, dsn);
            oIPAddresses      = new IPAddresses(intProfile, dsnIP, dsn);
            oFunction         = new Functions(intProfile, dsn, intEnvironment);
            oOperatingSystem  = new OperatingSystems(intProfile, dsn);
            oServicePack      = new ServicePacks(intProfile, dsn);
            oClass            = new Classes(intProfile, dsn);
            oEnvironment      = new Environments(intProfile, dsn);
            oResiliency       = new Resiliency(intProfile, dsn);

            oSolaris    = new Solaris(intProfile, dsn);
            oStatusList = new StatusLevels(intProfile, dsn);
            if (oUser.IsAdmin(intProfile) == true || (oDataPoint.GetPagePermission(intApplication, "ASSET") == true || intDataPointAvailableAsset == 1))
            {
                panAllow.Visible = true;
                if (Request.QueryString["save"] != null)
                {
                    panSave.Visible = true;
                }
                if (Request.QueryString["error"] != null)
                {
                    panError.Visible = true;
                }
                if (Request.QueryString["close"] != null)
                {
                    Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "close", "<script type=\"text/javascript\">window.close();<" + "/" + "script>");
                }
                else if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
                {
                    string  strID = oFunction.decryptQueryString(Request.QueryString["id"]);
                    DataSet ds    = oDataPoint.GetAsset(Int32.Parse(strID));
                    if (ds.Tables[0].Rows.Count == 1)
                    {
                        // Load General Information
                        intAsset        = Int32.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                        lblAssetID.Text = "#" + intAsset.ToString();
                        string strSerial = ds.Tables[0].Rows[0]["serial"].ToString();
                        string strAsset  = ds.Tables[0].Rows[0]["asset"].ToString();

                        string strHeader = (strSerial.Length > 15 ? strSerial.Substring(0, 15) + "..." : strSerial);
                        lblHeader.Text    = "&quot;" + strHeader.ToUpper() + "&quot;";
                        Master.Page.Title = "DataPoint | Physical Deploy (" + strHeader + ")";
                        lblHeaderSub.Text = "Complete the following information to deploy a physical server...";
                        int intMenuTab = 0;
                        if (Request.QueryString["menu_tab"] != null && Request.QueryString["menu_tab"] != "")
                        {
                            intMenuTab = Int32.Parse(Request.QueryString["menu_tab"]);
                        }
                        Tab oTab = new Tab(hdnTab.ClientID, intMenuTab, "divMenu1", true, false);
                        oTab.AddTab("Asset Information", "");
                        oTab.AddTab("Location Information", "");
                        oTab.AddTab("World Wide Port Names", "");
                        oTab.AddTab("Resource Dependencies", "");
                        oTab.AddTab("Provisioning History", "");
                        strMenuTab1 = oTab.GetTabs();

                        if (oUser.IsAdmin(intProfile) == true || oDataPoint.GetFieldPermission(intProfile, "SERVER_ADMIN") == true)
                        {
                            panOldLocationInfo.Visible = true;
                        }

                        if (!IsPostBack)
                        {
                            LoadList();

                            // Asset Information
                            oDataPoint.LoadTextBox(txtPlatformSerial, intProfile, null, "", lblPlatformSerial, fldPlatformSerial, "PHYSICAL_SERIAL", strSerial, "", false, true);
                            oDataPoint.LoadTextBox(txtPlatformAsset, intProfile, null, "", lblPlatformAsset, fldPlatformAsset, "PHYSICAL_ASSET", strAsset, "", false, true);

                            int intAssetAttribute = Int32.Parse(oAsset.Get(intAsset, "asset_attribute"));
                            oDataPoint.LoadDropDown(ddlAssetAttribute, intProfile, null, "", lblAssetAttribute, fldAssetAttribute, "ASSET_ATTRIBUTE", "Name", "AttributeId", oAsset.getAssetAttributes(null, "", 1), intAssetAttribute, true, false, false);
                            oDataPoint.LoadTextBox(txtAssetAttributeComment, intProfile, null, "", lblAssetAttributeComment, fldAssetAttributeComment, "ASSET_ATTRIBUTE_COMMENT", oAsset.getAssetAttributesComments(intAsset), "", false, true);
                            ddlAssetAttribute.Attributes.Add("onclick", "return SetControlsForAssetAttributes()");

                            ddlPlatform.Attributes.Add("onchange", "PopulatePlatformTypes('" + ddlPlatform.ClientID + "','" + ddlPlatformType.ClientID + "','" + ddlPlatformModel.ClientID + "','" + ddlPlatformModelProperty.ClientID + "');ResetDropDownHidden('" + hdnModel.ClientID + "');");
                            ddlPlatformType.Attributes.Add("onchange", "PopulatePlatformModels('" + ddlPlatformType.ClientID + "','" + ddlPlatformModel.ClientID + "','" + ddlPlatformModelProperty.ClientID + "');ResetDropDownHidden('" + hdnModel.ClientID + "');");
                            ddlPlatformModel.Attributes.Add("onchange", "PopulatePlatformModelProperties('" + ddlPlatformModel.ClientID + "','" + ddlPlatformModelProperty.ClientID + "');ResetDropDownHidden('" + hdnModel.ClientID + "');");
                            ddlPlatformModelProperty.Attributes.Add("onchange", "UpdateDropDownHidden('" + ddlPlatformModelProperty.ClientID + "','" + hdnModel.ClientID + "');");
                            int intModel  = Int32.Parse(oAsset.Get(intAsset, "modelid"));
                            int intParent = Int32.Parse(oModelsProperties.Get(intModel, "modelid"));
                            if (oDataPoint.GetDeployModel(intProfile, intParent) == false && oUser.IsAdmin(intProfile) == false)
                            {
                                panAllow.Visible  = false;
                                panDenied.Visible = true;
                            }

                            hdnModel.Value = intModel.ToString();
                            int intModelParent = Int32.Parse(oModelsProperties.Get(intModel, "modelid"));
                            int intType        = oModel.GetType(intModelParent);
                            int intPlatform    = oType.GetPlatform(intType);
                            oDataPoint.LoadDropDown(ddlPlatform, intProfile, null, "", lblPlatform, fldPlatform, "PHYSICAL_PLATFORM", "name", "platformid", oPlatform.Gets(1), intPlatform, false, false, true);
                            oDataPoint.LoadDropDown(ddlPlatformType, intProfile, null, "", lblPlatformType, fldPlatformType, "PHYSICAL_TYPE", "name", "id", oType.Gets(intPlatform, 1), intType, false, false, true);
                            oDataPoint.LoadDropDown(ddlPlatformModel, intProfile, null, "", lblPlatformModel, fldPlatformModel, "PHYSICAL_MODEL", "name", "id", oModel.Gets(intType, 1), intModelParent, false, false, true);
                            oDataPoint.LoadDropDown(ddlPlatformModelProperty, intProfile, null, "", lblPlatformModelProperty, fldPlatformModelProperty, "PHYSICAL_MODEL_PROP", "name", "id", oModelsProperties.GetModels(0, intModelParent, 1), intModel, false, false, true);

                            // Get Asset
                            DataSet dsAsset = oAsset.GetServerOrBlade(intAsset);
                            if (dsAsset.Tables[0].Rows.Count > 0)
                            {
                                Response.Redirect("/datapoint/asset/physical.aspx?t=serial&q=" + oFunction.encryptQueryString(strSerial) + "&id=" + oFunction.encryptQueryString(intAsset.ToString()) + "&r=0");
                            }

                            oDataPoint.LoadDropDown(ddlPlatformClass, intProfile, null, "", lblPlatformClass, fldPlatformClass, "PHYSICAL_CLASS", "name", "id", oClass.Gets(1), 0, false, false, true);
                            oDataPoint.LoadDropDown(ddlPlatformEnvironment, intProfile, null, "", lblPlatformEnvironment, fldPlatformEnvironment, "PHYSICAL_ENVIRONMENT", "name", "id", oClass.GetEnvironment(0, 0), 0, false, false, true);
                            oDataPoint.LoadTextBox(txtPlatformILO, intProfile, null, "", lblPlatformILO, fldPlatformILO, "PHYSICAL_ILO", "", "", false, true);
                            oDataPoint.LoadTextBox(txtPlatformDummy, intProfile, null, "", lblPlatformDummy, fldPlatformDummy, "PHYSICAL_DUMMY", "", "", false, true);
                            oDataPoint.LoadTextBox(txtPlatformMAC, intProfile, null, "", lblPlatformMAC, fldPlatformMAC, "PHYSICAL_MAC", "", "", false, true);
                            oDataPoint.LoadTextBox(txtPlatformVLAN, intProfile, null, "", lblPlatformVLAN, fldPlatformVLAN, "PHYSICAL_VLAN", "", "", false, true);
                            oDataPoint.LoadDropDown(ddlPlatformBuildNetwork, intProfile, null, "", lblPlatformBuildNetwork, fldPlatformBuildNetwork, "PHYSICAL_BUILD_NETWORK", "name", "id", oSolaris.GetBuildNetworks(1), 0, false, false, false);
                            oDataPoint.LoadDropDown(ddlPlatformResiliency, intProfile, null, "", lblPlatformResiliency, fldPlatformResiliency, "PHYSICAL_RESILIENCY", "name", "id", oResiliency.Gets(1), 0, false, false, true);
                            oDataPoint.LoadDropDown(ddlPlatformOperatingSystemGroup, intProfile, null, "", lblPlatformOperatingSystemGroup, fldPlatformOperatingSystemGroup, "PHYSICAL_OS_GROUP", "name", "id", oOperatingSystem.GetGroups(1), 0, false, false, false);

                            if (dsAsset.Tables[0].Rows.Count > 0)
                            {
                                lblOldlocation.Text = dsAsset.Tables[0].Rows[0]["OldLocation"].ToString();
                                lblOldRoom.Text     = dsAsset.Tables[0].Rows[0]["OldRoom"].ToString();
                                lblOldRack.Text     = dsAsset.Tables[0].Rows[0]["OldRack"].ToString();

                                txtLocation.Text     = dsAsset.Tables[0].Rows[0]["Location"].ToString();
                                txtRoom.Text         = dsAsset.Tables[0].Rows[0]["Room"].ToString();
                                txtZone.Text         = dsAsset.Tables[0].Rows[0]["Zone"].ToString();
                                txtRack.Text         = dsAsset.Tables[0].Rows[0]["Rack"].ToString();
                                txtRackPosition.Text = dsAsset.Tables[0].Rows[0]["Rackposition"].ToString();
                                oDataPoint.LoadTextBox(txtRackPosition, intProfile, null, "", lblRackPositionValue, fldLocation, "CHANGE_LOCATION", dsAsset.Tables[0].Rows[0]["rackposition"].ToString(), "", false, true);
                                hdnRackId.Value = dsAsset.Tables[0].Rows[0]["RackId"].ToString();
                            }
                            oDataPoint.LoadButton(btnSelectLocation, intProfile, fldLocation, "CHANGE_LOCATION",
                                                  "return LoadLocationRoomRack('" + "rack" + "','" + hdnRackId.ClientID + "', '" + txtLocation.ClientID + "','" + txtRoom.ClientID + "','" + txtZone.ClientID + "','" + txtRack.ClientID + "');");

                            ddlPlatformStatus.SelectedValue = oAsset.GetStatus(intAsset, "status");

                            // Resource Dependencies
                            AssetOrder      oAssetOrder     = new AssetOrder(0, dsn, dsnAsset, intEnvironment);
                            Services        oService        = new Services(0, dsn);
                            ServiceRequests oServiceRequest = new ServiceRequests(0, dsn);
                            rptServiceRequests.DataSource = oAssetOrder.GetByAsset(intAsset, false);
                            rptServiceRequests.DataBind();
                            trServiceRequests.Visible = (rptServiceRequests.Items.Count == 0);
                            foreach (RepeaterItem ri in rptServiceRequests.Items)
                            {
                                Label lblServiceID = (Label)ri.FindControl("lblServiceID");
                                int   intService   = Int32.Parse(lblServiceID.Text);
                                Label lblDetails   = (Label)ri.FindControl("lblDetails");
                                Label lblProgress  = (Label)ri.FindControl("lblProgress");

                                if (lblProgress.Text == "")
                                {
                                    lblProgress.Text = "<i>Unavailable</i>";
                                }
                                else
                                {
                                    int     intResource  = Int32.Parse(lblProgress.Text);
                                    double  dblAllocated = 0.00;
                                    double  dblUsed      = 0.00;
                                    int     intStatus    = 0;
                                    bool    boolAssigned = false;
                                    DataSet dsResource   = oDataPoint.GetServiceRequestResource(intResource);
                                    if (dsResource.Tables[0].Rows.Count > 0)
                                    {
                                        Int32.TryParse(dsResource.Tables[0].Rows[0]["status"].ToString(), out intStatus);
                                    }
                                    foreach (DataRow drResource in dsResource.Tables[1].Rows)
                                    {
                                        boolAssigned  = true;
                                        dblAllocated += double.Parse(drResource["allocated"].ToString());
                                        dblUsed      += double.Parse(drResource["used"].ToString());
                                        intStatus     = Int32.Parse(drResource["status"].ToString());
                                    }
                                    if (intStatus == (int)ResourceRequestStatus.Closed)
                                    {
                                        lblProgress.Text = oServiceRequest.GetStatusBar(100.00, "100", "12", true);
                                    }
                                    else if (intStatus == (int)ResourceRequestStatus.Cancelled)
                                    {
                                        lblProgress.Text = "Cancelled";
                                    }
                                    else if (boolAssigned == false)
                                    {
                                        string  strManager = "";
                                        DataSet dsManager  = oService.GetUser(intService, 1); // Managers
                                        foreach (DataRow drManager in dsManager.Tables[0].Rows)
                                        {
                                            if (strManager != "")
                                            {
                                                strManager += "\\n";
                                            }
                                            int intManager = Int32.Parse(drManager["userid"].ToString());
                                            strManager += " - " + oUser.GetFullName(intManager) + " [" + oUser.GetName(intManager) + "]";
                                        }
                                        lblProgress.Text = "<a href=\"javascript:void(0);\" class=\"lookup\" onclick=\"alert('This request is pending assignment by the following...\\n\\n" + strManager + "');\">Pending Assignment</a>";
                                    }
                                    else if (dblAllocated > 0.00)
                                    {
                                        lblProgress.Text = oServiceRequest.GetStatusBar((dblUsed / dblAllocated) * 100.00, "100", "12", true);
                                    }
                                    else
                                    {
                                        lblProgress.Text = "<i>N / A</i>";
                                    }
                                    lblDetails.Text = "<a href=\"javascript:void(0);\" class=\"lookup\" onclick=\"OpenNewWindowMenu('/datapoint/service/resource.aspx?id=" + oFunction.encryptQueryString(intResource.ToString()) + "', '800', '600');\">" + lblDetails.Text + "</a>";
                                }
                            }

                            // Provioning History
                            rptHistory.DataSource = oAsset.GetProvisioningHistory(intAsset);
                            rptHistory.DataBind();
                            lblHistory.Visible = (rptHistory.Items.Count == 0);

                            // WWW
                            rptWWW.DataSource = oAsset.GetHBA(intAsset);
                            rptWWW.DataBind();
                            lblWWW.Visible = (rptWWW.Items.Count == 0);
                            oDataPoint.LoadButton(btnWWW, intProfile, fldWWW, "PHYSICAL_WWW", "return OpenWindow('ASSET_DEPLOY_HBAs','" + intAsset.ToString() + "');");
                        }
                    }
                    else
                    {
                        if (Request.QueryString["t"] != null && Request.QueryString["q"] != null)
                        {
                            Response.Redirect("/datapoint/asset/datapoint_asset_search.aspx?t=" + Request.QueryString["t"] + "&q=" + Request.QueryString["q"] + "&r=0");
                        }
                        else
                        {
                            Response.Redirect("/datapoint/asset/datapoint_asset_search.aspx");
                        }
                    }
                }
                else
                {
                    Response.Redirect("/datapoint/asset/datapoint_asset_search.aspx");
                }
                btnClose.Attributes.Add("onclick", "window.close();return false;");
                btnPrint.Attributes.Add("onclick", "window.print();return false;");
                btnDeploy.Attributes.Add("onclick", oDataPoint.LoadValidation());
                ddlPlatformClass.Attributes.Add("onchange", "PopulateEnvironments('" + ddlPlatformClass.ClientID + "','" + ddlPlatformEnvironment.ClientID + "',0);");
                ddlPlatformEnvironment.Attributes.Add("onchange", "UpdateDropDownHidden('" + ddlPlatformEnvironment.ClientID + "','" + hdnEnvironment.ClientID + "');");
            }
            else
            {
                panDenied.Visible = true;
            }
        }
Example #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AuthenticateUser();
            if (Request.Cookies["profileid"] != null && Request.Cookies["profileid"].Value != "")
            {
                intProfile = Int32.Parse(Request.Cookies["profileid"].Value);
            }
            if (Request.QueryString["applicationid"] != null && Request.QueryString["applicationid"] != "")
            {
                intApplication = Int32.Parse(Request.QueryString["applicationid"]);
            }
            if (Request.Cookies["application"] != null && Request.Cookies["application"].Value != "")
            {
                intApplication = Int32.Parse(Request.Cookies["application"].Value);
            }
            oDataPoint        = new DataPoint(intProfile, dsn);
            oUser             = new Users(intProfile, dsn);
            oServer           = new Servers(intProfile, dsn);
            oAsset            = new Asset(intProfile, dsnAsset);
            oForecast         = new Forecast(intProfile, dsn);
            oPlatform         = new Platforms(intProfile, dsn);
            oType             = new Types(intProfile, dsn);
            oModel            = new Models(intProfile, dsn);
            oModelsProperties = new ModelsProperties(intProfile, dsn);
            oIPAddresses      = new IPAddresses(intProfile, dsnIP, dsn);
            oFunction         = new Functions(intProfile, dsn, intEnvironment);
            oOperatingSystem  = new OperatingSystems(intProfile, dsn);
            oServicePack      = new ServicePacks(intProfile, dsn);
            oClass            = new Classes(intProfile, dsn);
            oEnvironment      = new Environments(intProfile, dsn);
            if (oUser.IsAdmin(intProfile) == true || (oDataPoint.GetPagePermission(intApplication, "ASSET") == true || intDataPointAvailableAsset == 1))
            {
                panAllow.Visible = true;
                if (Request.QueryString["save"] != null)
                {
                    panSave.Visible = true;
                }
                if (Request.QueryString["error"] != null)
                {
                    panError.Visible = true;
                    //      -100: More than one device name
                    //       -10: No device names
                    //        -5: Improper Name Format
                    //        -1: ServerID = 0
                    if (Request.QueryString["error"] == "-100")
                    {
                        lblError.Text = "More than one name";
                    }
                    else if (Request.QueryString["error"] == "-10")
                    {
                        lblError.Text = "User Cancelled Prompt";
                    }
                    else if (Request.QueryString["error"] == "-5")
                    {
                        lblError.Text = "Name is in Incorrect Format";
                    }
                    else if (Request.QueryString["error"] == "-1")
                    {
                        lblError.Text = "DeviceID = 0";
                    }
                    else
                    {
                        lblError.Text = "Generic Error";
                    }
                }
                Int32.TryParse(oFunction.decryptQueryString(Request.QueryString["id"]), out intID);
                if (Request.QueryString["close"] != null)
                {
                    Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "close", "<script type=\"text/javascript\">window.close();<" + "/" + "script>");
                }
                else if (intID > 0)
                {
                    DataSet ds = oDataPoint.GetAsset(intID);
                    if (ds.Tables[0].Rows.Count == 1)
                    {
                        // Load General Information
                        intAsset        = Int32.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                        lblAssetID.Text = "#" + intAsset.ToString();
                        string strSerial = ds.Tables[0].Rows[0]["serial"].ToString();
                        string strAsset  = ds.Tables[0].Rows[0]["asset"].ToString();

                        string strHeader = (strSerial.Length > 15 ? strSerial.Substring(0, 15) + "..." : strSerial);
                        lblHeader.Text    = "&quot;" + strHeader.ToUpper() + "&quot;";
                        Master.Page.Title = "DataPoint | VMware (" + strHeader + ")";
                        lblHeaderSub.Text = "Provides all the information about a VMware guest...";
                        int intMenuTab = 0;
                        if (Request.QueryString["menu_tab"] != null && Request.QueryString["menu_tab"] != "")
                        {
                            intMenuTab = Int32.Parse(Request.QueryString["menu_tab"]);
                        }
                        Tab oTab = new Tab(hdnTab.ClientID, intMenuTab, "divMenu1", true, false);
                        oTab.AddTab("Asset Information", "");
                        oTab.AddTab("Host Information", "");
                        oTab.AddTab("Resource Dependencies", "");
                        oTab.AddTab("Provisioning Information", "");
                        //oTab.AddTab("Network Adapter Configuration", "");
                        strMenuTab1 = oTab.GetTabs();

                        if (!IsPostBack)
                        {
                            //DataSet dsAssets = oServer.GetAsset(intAsset);
                            //foreach (DataRow drAsset in dsAssets.Tables[0].Rows)
                            //{
                            //    if (drAsset["latest"].ToString() == "1")
                            //    {
                            //        intAsset = Int32.Parse(drAsset["assetid"].ToString());
                            //        intAssetClass = Int32.Parse(drAsset["classid"].ToString());
                            //        intAssetEnv = Int32.Parse(drAsset["environmentid"].ToString());
                            //        break;
                            //    }
                            //}

                            // Asset Information
                            oDataPoint.LoadTextBox(txtPlatformSerial, intProfile, null, "", lblPlatformSerial, fldPlatformSerial, "VMWARE_SERIAL", strSerial, "", false, true);
                            oDataPoint.LoadTextBox(txtPlatformAsset, intProfile, null, "", lblPlatformAsset, fldPlatformAsset, "VMWARE_ASSET", strAsset, "", false, true);

                            int intAssetAttribute = 0;
                            Int32.TryParse(oAsset.Get(intAsset, "asset_attribute"), out intAssetAttribute);
                            oDataPoint.LoadDropDown(ddlAssetAttribute, intProfile, null, "", lblAssetAttribute, fldAssetAttribute, "ASSET_ATTRIBUTE", "Name", "AttributeId", oAsset.getAssetAttributes(null, "", 1), intAssetAttribute, true, false, false);
                            oDataPoint.LoadTextBox(txtAssetAttributeComment, intProfile, null, "", lblAssetAttributeComment, fldAssetAttributeComment, "ASSET_ATTRIBUTE_COMMENT", oAsset.getAssetAttributesComments(intAsset), "", false, true);
                            ddlAssetAttribute.Attributes.Add("onclick", "return SetControlsForAssetAttributes()");

                            ddlPlatform.Attributes.Add("onchange", "PopulatePlatformTypes('" + ddlPlatform.ClientID + "','" + ddlPlatformType.ClientID + "','" + ddlPlatformModel.ClientID + "','" + ddlPlatformModelProperty.ClientID + "');ResetDropDownHidden('" + hdnModel.ClientID + "');");
                            ddlPlatformType.Attributes.Add("onchange", "PopulatePlatformModels('" + ddlPlatformType.ClientID + "','" + ddlPlatformModel.ClientID + "','" + ddlPlatformModelProperty.ClientID + "');ResetDropDownHidden('" + hdnModel.ClientID + "');");
                            ddlPlatformModel.Attributes.Add("onchange", "PopulatePlatformModelProperties('" + ddlPlatformModel.ClientID + "','" + ddlPlatformModelProperty.ClientID + "');ResetDropDownHidden('" + hdnModel.ClientID + "');");
                            ddlPlatformModelProperty.Attributes.Add("onchange", "UpdateDropDownHidden('" + ddlPlatformModelProperty.ClientID + "','" + hdnModel.ClientID + "');");
                            int intModel = 0;
                            Int32.TryParse(oAsset.Get(intAsset, "modelid"), out intModel);

                            hdnModel.Value = intModel.ToString();
                            int intModelParent = 0;
                            Int32.TryParse(oModelsProperties.Get(intModel, "modelid"), out intModelParent);
                            int intType     = oModel.GetType(intModelParent);
                            int intPlatform = oType.GetPlatform(intType);
                            oDataPoint.LoadDropDown(ddlPlatform, intProfile, null, "", lblPlatform, fldPlatform, "VMWARE_PLATFORM", "name", "platformid", oPlatform.Gets(1), intPlatform, false, false, true);
                            oDataPoint.LoadDropDown(ddlPlatformType, intProfile, null, "", lblPlatformType, fldPlatformType, "VMWARE_TYPE", "name", "id", oType.Gets(intPlatform, 1), intType, false, false, true);
                            oDataPoint.LoadDropDown(ddlPlatformModel, intProfile, null, "", lblPlatformModel, fldPlatformModel, "VMWARE_MODEL", "name", "id", oModel.Gets(intType, 1), intModelParent, false, false, true);
                            oDataPoint.LoadDropDown(ddlPlatformModelProperty, intProfile, null, "", lblPlatformModelProperty, fldPlatformModelProperty, "VMWARE_MODEL_PROP", "name", "id", oModelsProperties.GetModels(0, intModelParent, 1), intModel, false, false, true);

                            // Get Asset
                            DataSet dsAsset = oAsset.GetGuest(intAsset);
                            if (dsAsset.Tables[0].Rows.Count > 0)
                            {
                                oDataPoint.LoadTextBoxDeviceName(txtName, btnName, null, true, hdnPNC, intProfile, btnNameLookup, "/datapoint/asset/datapoint_asset_search.aspx?t=name&q=" + oFunction.encryptQueryString(dsAsset.Tables[0].Rows[0]["name"].ToString()), lblName, fldName, "VMWARE_NAME", dsAsset.Tables[0].Rows[0]["name"].ToString(), "", false, false);
                                if (txtName.Text != "")
                                {
                                    lblHeader.Text += "&nbsp;&nbsp;&nbsp;[" + txtName.Text + "]";
                                }
                                lblStatus.Text = dsAsset.Tables[0].Rows[0]["statusname"].ToString();
                                int intClass = Int32.Parse(dsAsset.Tables[0].Rows[0]["classid"].ToString());
                                int intEnv   = Int32.Parse(dsAsset.Tables[0].Rows[0]["environmentid"].ToString());
                                hdnEnvironment.Value = intEnv.ToString();
                                oDataPoint.LoadDropDown(ddlPlatformClass, intProfile, null, "", lblPlatformClass, fldPlatformClass, "VMWARE_CLASS", "name", "id", oClass.Gets(1), intClass, false, false, true);
                                oDataPoint.LoadDropDown(ddlPlatformEnvironment, intProfile, null, "", lblPlatformEnvironment, fldPlatformEnvironment, "VMWARE_ENVIRONMENT", "name", "id", oClass.GetEnvironment(intClass, 0), intEnv, false, false, true);
                                ddlStatus.SelectedValue = dsAsset.Tables[0].Rows[0]["status"].ToString();
                                ddlStatus.Enabled       = (intAssetAttribute == (int)AssetAttribute.Ok);
                                panStatus.Visible       = (ddlStatus.Enabled == false);
                            }
                            else
                            {
                                Response.Redirect("/datapoint/asset/datapoint_asset_search.aspx");
                            }

                            // Get Original Detail
                            VMWare  oVMWare = new VMWare(intProfile, dsn);
                            DataSet dsGuest = oVMWare.GetGuest(dsAsset.Tables[0].Rows[0]["name"].ToString());
                            if (dsGuest.Tables[0].Rows.Count > 0)
                            {
                                panVMWare.Visible = true;
                                DataRow drGuest      = dsGuest.Tables[0].Rows[0];
                                int     intDatastore = Int32.Parse(drGuest["datastoreid"].ToString());
                                lblBuildDataStore.Text = oVMWare.GetDatastore(intDatastore, "name");
                                int intHost = Int32.Parse(drGuest["hostid"].ToString());
                                lblBuildHost.Text = oVMWare.GetHost(intHost, "name");
                                int intCluster = Int32.Parse(oVMWare.GetHost(intHost, "clusterid"));
                                lblBuildCluster.Text = oVMWare.GetCluster(intCluster, "name");
                                int intFolder = Int32.Parse(oVMWare.GetCluster(intCluster, "folderid"));
                                lblBuildFolder.Text = oVMWare.GetFolder(intFolder, "name");
                                int intDataCenter = Int32.Parse(oVMWare.GetFolder(intFolder, "datacenterid"));
                                lblBuildDataCenter.Text = oVMWare.GetDatacenter(intDataCenter, "name");
                                int intVirtualCenter = Int32.Parse(oVMWare.GetDatacenter(intDataCenter, "virtualcenterid"));
                                lblBuildVirtualCenter.Text = oVMWare.GetVirtualCenter(intVirtualCenter, "name");

                                // Get Host
                                if (Request.Cookies["host"] != null && Request.Cookies["host"].Value != "")
                                {
                                    string strHost = "";
                                    string strFind = txtName.Text;
                                    //strFind = "ohcleapp103d";
                                    DateTime datStart = DateTime.Parse(Request.Cookies["host"].Value);
                                    Response.Cookies["host"].Value = "";
                                    //VMWare oVMWare = new VMWare(intProfile, dsn);
                                    DataSet dsVirtualCenter = oVMWare.GetVirtualCenters(1);
                                    foreach (DataRow drVirtualCenter in dsVirtualCenter.Tables[0].Rows)
                                    {
                                        intVirtualCenter = Int32.Parse(drVirtualCenter["id"].ToString());
                                        string  strVirtualCenter    = drVirtualCenter["name"].ToString();
                                        string  strVirtualCenterURL = drVirtualCenter["url"].ToString();
                                        int     intVirtualCenterEnv = Int32.Parse(drVirtualCenter["environment"].ToString());
                                        DataSet dsDataCenter        = oVMWare.GetDatacenters(intVirtualCenter, 1);
                                        foreach (DataRow drDataCenter in dsDataCenter.Tables[0].Rows)
                                        {
                                            intDataCenter = Int32.Parse(drDataCenter["id"].ToString());
                                            string         strDataCenter = drDataCenter["name"].ToString();
                                            string         strConnect    = oVMWare.ConnectDEBUG(strVirtualCenterURL, intVirtualCenterEnv, strDataCenter);
                                            VimService     _service      = oVMWare.GetService();
                                            ServiceContent _sic          = oVMWare.GetSic();
                                            try
                                            {
                                                ManagedObjectReference oVM = oVMWare.GetVM(strFind);
                                                GuestInfo ginfo            = (GuestInfo)oVMWare.getObjectProperty(oVM, "guest");
                                                lblGuestName.Text  = ginfo.guestFullName;
                                                lblGuestState.Text = ginfo.guestState;
                                                GuestNicInfo[] nInfo = ginfo.net;
                                                foreach (GuestNicInfo nic in nInfo)
                                                {
                                                    string[] strIPAddresses = nic.ipAddress;
                                                    foreach (string strIPAddress in strIPAddresses)
                                                    {
                                                        if (lblIPAddress.Text != "")
                                                        {
                                                            lblIPAddress.Text += ", ";
                                                        }
                                                        lblIPAddress.Text += strIPAddress;
                                                    }
                                                    if (lblMACAddress.Text != "")
                                                    {
                                                        lblMACAddress.Text += ", ";
                                                    }
                                                    lblMACAddress.Text += nic.macAddress;
                                                    if (lblNetwork.Text != "")
                                                    {
                                                        lblNetwork.Text += ", ";
                                                    }
                                                    lblNetwork.Text += nic.network;
                                                }
                                                VirtualMachineConfigInfo    vminfo     = (VirtualMachineConfigInfo)oVMWare.getObjectProperty(oVM, "config");
                                                VirtualMachineSummary       oVMSummary = (VirtualMachineSummary)oVMWare.getObjectProperty(oVM, "summary");
                                                VirtualMachineConfigSummary oVMConfig  = oVMSummary.config;
                                                lblRAM.Text  = oVMConfig.memorySizeMB.ToString();
                                                lblCPUs.Text = oVMConfig.numCpu.ToString();
                                                lblPath.Text = oVMConfig.vmPathName;
                                                VirtualMachineRuntimeInfo oVMRuntime = oVMSummary.runtime;
                                                ManagedObjectReference    oVMHost    = oVMRuntime.host;
                                                strHost = (string)oVMWare.getObjectProperty(oVMHost, "name");
                                                if (strHost.IndexOf(".") > -1)
                                                {
                                                    strHost = strHost.Substring(0, strHost.IndexOf("."));
                                                }
                                                lblVirtualCenter.Text = strVirtualCenter;
                                                lblDataCenter.Text    = strDataCenter;
                                                break;
                                            }
                                            catch { }
                                            finally
                                            {
                                                if (_service != null)
                                                {
                                                    _service.Abort();
                                                    if (_service.Container != null)
                                                    {
                                                        _service.Container.Dispose();
                                                    }
                                                    try
                                                    {
                                                        _service.Logout(_sic.sessionManager);
                                                    }
                                                    catch { }
                                                    _service.Dispose();
                                                    _service = null;
                                                    _sic     = null;
                                                }
                                            }
                                        }
                                    }
                                    if (strHost != "")
                                    {
                                        oDataPoint.LoadTextBox(txtHostName, intProfile, btnHostName, "/datapoint/asset/server.aspx?t=name&q=" + oFunction.encryptQueryString(strHost), lblHostName, fldHostName, "VMWARE_HOST", strHost, "", false, false);
                                    }
                                    else
                                    {
                                        panHostNo.Visible = true;
                                    }
                                    TimeSpan oSpan = DateTime.Now.Subtract(datStart);
                                    btnHostQuery.Enabled = false;
                                    btnHostQuery.Text    = "Query Time: " + oSpan.TotalSeconds.ToString("0") + " seconds...";
                                }
                                else
                                {
                                    txtHostName.Visible   = false;
                                    lblHostName.Text      = "---";
                                    lblDataCenter.Text    = "---";
                                    lblVirtualCenter.Text = "---";
                                }
                                oDataPoint.LoadPanel(panHostQuery, intProfile, fldHostQuery, "VMWARE_HOST_QUERY");
                            }
                            else
                            {
                                Solaris oSolaris  = new Solaris(intProfile, dsn);
                                DataSet dsServers = oServer.GetAssetsAsset(intAsset);
                                foreach (DataRow drServer in dsServers.Tables[0].Rows)
                                {
                                    DataSet dsSVE = oSolaris.GetSVEGuest(Int32.Parse(drServer["serverid"].ToString()));
                                    if (dsSVE.Tables[0].Rows.Count > 0)
                                    {
                                        panSVE.Visible = true;
                                        int intCluster = Int32.Parse(dsSVE.Tables[0].Rows[0]["clusterid"].ToString());
                                        lblSVECluster.Text = oSolaris.GetSVECluster(intCluster, "name");
                                    }
                                }
                            }


                            // Resource Dependencies
                            AssetOrder      oAssetOrder     = new AssetOrder(0, dsn, dsnAsset, intEnvironment);
                            Services        oService        = new Services(0, dsn);
                            ServiceRequests oServiceRequest = new ServiceRequests(0, dsn);
                            rptServiceRequests.DataSource = oAssetOrder.GetByAsset(intAsset, false);
                            rptServiceRequests.DataBind();
                            trServiceRequests.Visible = (rptServiceRequests.Items.Count == 0);
                            foreach (RepeaterItem ri in rptServiceRequests.Items)
                            {
                                Label lblServiceID = (Label)ri.FindControl("lblServiceID");
                                int   intService   = Int32.Parse(lblServiceID.Text);
                                Label lblDetails   = (Label)ri.FindControl("lblDetails");
                                Label lblProgress  = (Label)ri.FindControl("lblProgress");

                                if (lblProgress.Text == "")
                                {
                                    lblProgress.Text = "<i>Unavailable</i>";
                                }
                                else
                                {
                                    int     intResource  = Int32.Parse(lblProgress.Text);
                                    double  dblAllocated = 0.00;
                                    double  dblUsed      = 0.00;
                                    int     intStatus    = 0;
                                    bool    boolAssigned = false;
                                    DataSet dsResource   = oDataPoint.GetServiceRequestResource(intResource);
                                    if (dsResource.Tables[0].Rows.Count > 0)
                                    {
                                        Int32.TryParse(dsResource.Tables[0].Rows[0]["status"].ToString(), out intStatus);
                                    }
                                    foreach (DataRow drResource in dsResource.Tables[1].Rows)
                                    {
                                        boolAssigned  = true;
                                        dblAllocated += double.Parse(drResource["allocated"].ToString());
                                        dblUsed      += double.Parse(drResource["used"].ToString());
                                        intStatus     = Int32.Parse(drResource["status"].ToString());
                                    }
                                    if (intStatus == (int)ResourceRequestStatus.Closed)
                                    {
                                        lblProgress.Text = oServiceRequest.GetStatusBar(100.00, "100", "12", true);
                                    }
                                    else if (intStatus == (int)ResourceRequestStatus.Cancelled)
                                    {
                                        lblProgress.Text = "Cancelled";
                                    }
                                    else if (boolAssigned == false)
                                    {
                                        string  strManager = "";
                                        DataSet dsManager  = oService.GetUser(intService, 1); // Managers
                                        foreach (DataRow drManager in dsManager.Tables[0].Rows)
                                        {
                                            if (strManager != "")
                                            {
                                                strManager += "\\n";
                                            }
                                            int intManager = Int32.Parse(drManager["userid"].ToString());
                                            strManager += " - " + oUser.GetFullName(intManager) + " [" + oUser.GetName(intManager) + "]";
                                        }
                                        lblProgress.Text = "<a href=\"javascript:void(0);\" class=\"lookup\" onclick=\"alert('This request is pending assignment by the following...\\n\\n" + strManager + "');\">Pending Assignment</a>";
                                    }
                                    else if (dblAllocated > 0.00)
                                    {
                                        lblProgress.Text = oServiceRequest.GetStatusBar((dblUsed / dblAllocated) * 100.00, "100", "12", true);
                                    }
                                    else
                                    {
                                        lblProgress.Text = "<i>N / A</i>";
                                    }
                                    lblDetails.Text = "<a href=\"javascript:void(0);\" class=\"lookup\" onclick=\"OpenNewWindowMenu('/datapoint/service/resource.aspx?id=" + oFunction.encryptQueryString(intResource.ToString()) + "', '800', '600');\">" + lblDetails.Text + "</a>";
                                }
                            }

                            // Provioning History
                            rptHistory.DataSource = oAsset.GetProvisioningHistory(oDataPoint.AssetHistorySelect(intAsset));
                            rptHistory.DataBind();
                            lblHistory.Visible = (rptHistory.Items.Count == 0);
                            oDataPoint.LoadPanel(panProvisioning, intProfile, fldProvisioning, "VMWARE_STATUS");
                        }
                    }
                    else
                    {
                        if (Request.QueryString["t"] != null && Request.QueryString["q"] != null)
                        {
                            Response.Redirect("/datapoint/asset/datapoint_asset_search.aspx?t=" + Request.QueryString["t"] + "&q=" + Request.QueryString["q"] + "&r=0");
                        }
                        else
                        {
                            Response.Redirect("/datapoint/asset/datapoint_asset_search.aspx");
                        }
                    }
                }
                else if (Request.QueryString["q"] != null && Request.QueryString["q"] != "")
                {
                    string  strQuery = oFunction.decryptQueryString(Request.QueryString["q"]);
                    DataSet ds       = oDataPoint.GetAssetName(strQuery, intID, 0, "", "", 0);
                    if (ds.Tables[0].Rows.Count == 1)
                    {
                        intID = Int32.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                        Response.Redirect(Request.Path + "?t=" + Request.QueryString["t"] + "&q=" + Request.QueryString["q"] + "&id=" + oFunction.encryptQueryString(intID.ToString()));
                    }
                    else
                    {
                        Response.Redirect("/datapoint/asset/datapoint_asset_search.aspx?multiple=true&t=" + Request.QueryString["t"] + "&q=" + Request.QueryString["q"]);
                    }
                }
                else
                {
                    Response.Redirect("/datapoint/asset/datapoint_asset_search.aspx");
                }
                btnClose.Attributes.Add("onclick", "window.close();return false;");
                btnPrint.Attributes.Add("onclick", "window.print();return false;");
                btnName.Attributes.Add("onclick", "return OpenWindow('DEVICE_NAME','?assetid=" + intAsset.ToString() + "');");
                btnSave.Attributes.Add("onclick", oDataPoint.LoadValidation("ProcessControlButton()"));
                btnSaveClose.Attributes.Add("onclick", oDataPoint.LoadValidation("ProcessControlButton()"));
                ddlPlatformClass.Attributes.Add("onchange", "PopulateEnvironments('" + ddlPlatformClass.ClientID + "','" + ddlPlatformEnvironment.ClientID + "',0);");
                ddlPlatformEnvironment.Attributes.Add("onchange", "UpdateDropDownHidden('" + ddlPlatformEnvironment.ClientID + "','" + hdnEnvironment.ClientID + "');");
                btnHostQuery.Attributes.Add("onclick", "ProcessButton(this,'Querying... please be patient...','225') && ProcessControlButton();");
            }
            else
            {
                panDenied.Visible = true;
            }
        }