Пример #1
0
        protected void Page_Load()
        {
            Int32.TryParse(Request.QueryString["id"], out intAsset);
            if (intAsset > 0)
            {
                int   intModelProperty = 0;
                Asset oAsset           = new Asset(0, dsnAsset, dsn);
                if (Int32.TryParse(oAsset.Get(intAsset, "modelid"), out intModelProperty) == true)
                {
                    ModelsProperties oModelsProperties = new ModelsProperties(0, dsn);
                    if (oModelsProperties.IsDell(intModelProperty) == true)
                    {
                        int intDellConfig = 0;
                        Int32.TryParse(oModelsProperties.Get(intModelProperty, "dellconfigid"), out intDellConfig);
                        Dells   oDell  = new Dells(0, dsn);
                        DataSet dsDell = oDell.Get(intDellConfig);
                        if (dsDell.Tables[0].Rows.Count == 1)
                        {
                            DataRow drDell = dsDell.Tables[0].Rows[0];
                            strUser = drDell["username"].ToString();
                            strPass = drDell["password"].ToString();
                            strILO  = oAsset.GetServerOrBlade(intAsset, "ilo");

                            Functions oFunction = new Functions(0, dsn, intEnvironment);
                            Variables oVariable = new Variables(intEnvironment);

                            if (Request.QueryString["showimage"] != null)
                            {
                                Response.Redirect("/ondemand/ondemand_dell_image.aspx?showimage=https://" + strILO + Request.QueryString["showimage"]);
                            }
                            else if (Request.QueryString["bypass"] != null)
                            {
                                if (strUser == "" || strPass == "")
                                {
                                    strUser = oVariable.ADUser() + "@" + oVariable.FullyQualified();
                                    strPass = oFunction.AddPassword(50);
                                }
                            }
                        }
                    }
                }
            }
        }
        private void LoadAssetInformation()
        {
            DataSet dsProcurementReq = oAssetOrder.Get(Int32.Parse(hdnOrderId.Value));

            if (dsProcurementReq.Tables[0].Rows.Count > 0)
            {
                DataRow drProcurementReq = dsProcurementReq.Tables[0].Rows[0];
                int     intLocation      = 0;
                Int32.TryParse(drProcurementReq["LocationId"].ToString(), out intLocation);
                string strLocationCommonName = (intLocation > 0 ? oLocation.GetAddress(intLocation, "commonname") : "");
                if (strLocationCommonName == "")
                {
                    lblIntendedLocation.Text = "Intended Location : " + drProcurementReq["Location"].ToString();
                }
                else
                {
                    lblIntendedLocation.Text = "Intended Location : " + strLocationCommonName;
                }

                lblIntendedRoom.Text         = "Intended Room : " + drProcurementReq["Room"].ToString();
                lblIntendedZone.Text         = "Intended Zone : " + drProcurementReq["Zone"].ToString();
                lblIntendedRack.Text         = "Intended Rack : " + drProcurementReq["Rack"].ToString();
                lblIntendedRackPosition.Text = "Intended Rack Position : " + (drProcurementReq["RackPos"].ToString() == "" ? "N / A" : drProcurementReq["RackPos"].ToString());

                lblIntendedResiliency.Text  = "Intended Resiliency : " + (drProcurementReq["Resiliency"].ToString() == "" ? "N / A" : drProcurementReq["Resiliency"].ToString());
                lblIntendedClass.Text       = "Intended Class : " + drProcurementReq["Class"].ToString();
                lblIntendedEnvironment.Text = "Intended Environment : " + drProcurementReq["Environment"].ToString();

                lblIntendedEnclosure.Text = "Intended Enclosure : " + (drProcurementReq["Enclosure"].ToString() == "" ? "N / A" : drProcurementReq["Enclosure"].ToString());
                lblIntendedSlot.Text      = "Intended Enclosure Slot : " + (drProcurementReq["Enclosure"].ToString() == "" ? "N / A" : drProcurementReq["EnclosureSlot"].ToString());

                lblIntendedOperatingSystemGroup.Text = "Intended Operating System Group : " + (drProcurementReq["OperatingSystemGroup"].ToString() == "" ? "Not Specified" : drProcurementReq["OperatingSystemGroup"].ToString());
            }


            DataSet dsAsset = oAsset.GetAssetsAll(Int32.Parse(hdnAssetId.Value));

            if (dsAsset.Tables[0].Rows.Count == 1)
            {
                DataRow drAsset = dsAsset.Tables[0].Rows[0];
                intAsset        = Int32.Parse(drAsset["AssetId"].ToString());
                lblAssetID.Text = "#" + intAsset.ToString();

                string strSerial = drAsset["AssetSerial"].ToString();
                string strAsset  = drAsset["AssetTag"].ToString();
                string strHeader = (strSerial.Length > 15 ? strSerial.Substring(0, 15) + "..." : strSerial);

                lblHeader.Text    = """ + strHeader.ToUpper() + """;
                Master.Page.Title = "Asset Staging and Configuration (" + strHeader + ")";
                lblHeaderSub.Text = "Stage and Configure a asset...";

                int intModel    = Int32.Parse(drAsset["AssetModelId"].ToString());
                int intLocation = 0;
                Int32.TryParse(drAsset["LocationId"].ToString(), out intLocation);
                panSwitches.Visible        = (oModelsProperties.IsConfigureSwitches(intModel) && oLocation.IsOffsite(intLocation) == false);
                panSwitchesPending.Visible = false;
                int  intModelParent = Int32.Parse(oModelsProperties.Get(intModel, "modelid"));
                bool IsDell         = oModelsProperties.IsDell(intModel);
                txtAssetSerial.Text      = drAsset["AssetSerial"].ToString();
                txtAssetTag.Text         = drAsset["AssetTag"].ToString();
                txtModel.Text            = oModel.Get(intModelParent, "name");
                txtModelProperty.Text    = drAsset["ModelName"].ToString();
                hdnModelPropertyId.Value = drAsset["AssetModelId"].ToString();
                hdnAssetCategoryId.Value = drAsset["AssetCategoryId"].ToString();



                SetControlsForAssetCategory(IsDell);

                if (hdnAssetCategoryId.Value == "4") //Rack
                {
                    txtDeviceName.Text = drAsset["Rack"].ToString();
                }
                else
                {
                    txtDeviceName.Text = drAsset["AssetName"].ToString();
                }



                ddlClass.SelectedValue = (drAsset["ClassId"].ToString() != "" ? drAsset["ClassId"].ToString() : "0");
                if (drAsset["ClassId"].ToString() != "")
                {
                    ddlEnvironment.DataTextField  = "name";
                    ddlEnvironment.DataValueField = "id";
                    ddlEnvironment.DataSource     = oClass.GetEnvironment(Int32.Parse(drAsset["ClassId"].ToString()), 0);
                    ddlEnvironment.DataBind();
                    ddlEnvironment.Items.Insert(0, new ListItem("-- SELECT --", "0"));
                }

                hdnEnvironment.Value         = (drAsset["EnvironmentId"].ToString() != "" ? drAsset["EnvironmentId"].ToString() : "0");
                ddlEnvironment.SelectedValue = (drAsset["EnvironmentId"].ToString() != "" ? drAsset["EnvironmentId"].ToString() : "0");

                //hdnLocation.Value = (drAsset["LocationId"].ToString() != "" ? drAsset["LocationId"].ToString() : "0");
                hdnZoneId.Value      = (drAsset["ZoneId"].ToString() != "" ? drAsset["ZoneId"].ToString() : "0");
                hdnRackId.Value      = (drAsset["RackId"].ToString() != "" ? drAsset["RackId"].ToString() : "0");
                txtRackPosition.Text = (drAsset["RackPosition"].ToString() != "" ? drAsset["RackPosition"].ToString() : "0");

                populateLocations();

                ddlEnclosure.SelectedValue = (drAsset["EnclosureId"].ToString() != "" ? drAsset["EnclosureId"].ToString() : "0");
                txtSlot.Text                          = (drAsset["Slot"].ToString() != "" ? drAsset["Slot"].ToString() : "0");
                chkSpare.Checked                      = (drAsset["Spare"].ToString() == "1" ? true : false);
                txtILO.Text                           = drAsset["ILO"].ToString();
                txtDummyName.Text                     = drAsset["DummyName"].ToString();
                txtVLAN.Text                          = (drAsset["vLAN"].ToString() != ""? drAsset["vLAN"].ToString():"0");
                ddlBuildNetwork.SelectedValue         = (drAsset["BuildNetworkId"].ToString() != "" ? drAsset["BuildNetworkId"].ToString() : "0");
                txtOAIP.Text                          = (drAsset["OAIP"].ToString() != "" ? drAsset["OAIP"].ToString() : "");
                ddlResiliency.SelectedValue           = (drAsset["resiliencyid"].ToString() != "" ? drAsset["resiliencyid"].ToString() : "0");
                ddlOperatingSystemGroup.SelectedValue = (drAsset["operatingsystemgroupid"].ToString() != "" ? drAsset["operatingsystemgroupid"].ToString() : "0");



                switch (hdnAssetCategoryId.Value)
                {
                case "1":      //Physical Server
                    if (IsDell == false)
                    {
                        LoadWorldWidePortNames(intAsset);
                    }
                    break;

                case "2":     //Blade
                    if (IsDell == false)
                    {
                        LoadWorldWidePortNames(intAsset);
                    }
                    break;

                case "3":     //Enclosure
                    break;

                case "4":     //Rack

                    break;

                default:
                    break;
                }

                if (!IsPostBack && panSwitches.Visible == true)
                {
                    int intRackID = 0;
                    if (Int32.TryParse(drAsset["rackid"].ToString(), out intRackID) == true)
                    {
                        lblSwitchRack.Text    = drAsset["rack"].ToString();
                        lblSwitchRack.ToolTip = drAsset["rackid"].ToString();
                        DataSet dsSwitches = oAsset.GetSwitchsByRack(intRackID, 1);
                        LoadSwitch(ddlNetwork1, dsSwitches, ddlNetwork1Blade, txtNetwork1FexID, ddlNetwork1Port, txtNetwork1Interface, lblNetwork1Interface, hdnNetwork1Blade, hdnNetwork1Port, SwitchPortType.Network, 1, intAsset);
                        LoadSwitch(ddlNetwork2, dsSwitches, ddlNetwork2Blade, txtNetwork2FexID, ddlNetwork2Port, txtNetwork2Interface, lblNetwork2Interface, hdnNetwork2Blade, hdnNetwork2Port, SwitchPortType.Network, 2, intAsset);
                        LoadSwitch(ddlBackup, dsSwitches, ddlBackupBlade, txtBackupFexID, ddlBackupPort, txtBackupInterface, lblBackupInterface, hdnBackupBlade, hdnBackupPort, SwitchPortType.Backup, 1, intAsset);
                        LoadSwitch(ddlRemote, dsSwitches, ddlRemoteBlade, txtRemoteFexID, ddlRemotePort, txtRemoteInterface, lblRemoteInterface, hdnRemoteBlade, hdnRemotePort, SwitchPortType.Remote, 1, intAsset);
                        LoadSwitch(ddlCluster1, dsSwitches, ddlCluster1Blade, txtCluster1FexID, ddlCluster1Port, txtCluster1Interface, lblCluster1Interface, hdnCluster1Blade, hdnCluster1Port, SwitchPortType.Cluster, 1, intAsset);
                        LoadSwitch(ddlCluster2, dsSwitches, ddlCluster2Blade, txtCluster2FexID, ddlCluster2Port, txtCluster2Interface, lblCluster2Interface, hdnCluster2Blade, hdnCluster2Port, SwitchPortType.Cluster, 2, intAsset);
                        LoadSwitch(ddlStorage1, dsSwitches, ddlStorage1Blade, null, ddlStorage1Port, txtStorage1Interface, null, hdnStorage1Blade, hdnStorage1Port, SwitchPortType.Storage, 1, intAsset);
                        LoadSwitch(ddlStorage2, dsSwitches, ddlStorage2Blade, null, ddlStorage2Port, txtStorage2Interface, null, hdnStorage2Blade, hdnStorage2Port, SwitchPortType.Storage, 2, intAsset);
                    }
                    else
                    {
                        panSwitches.Visible        = false;
                        panSwitchesPending.Visible = (oModelsProperties.IsConfigureSwitches(intModel) && oLocation.IsOffsite(intLocation) == false);
                        btnSaveAndClose.Enabled    = false;
                    }
                }
            }
        }