コード例 #1
0
        protected void btnGo_Click(Object Sender, EventArgs e)
        {
            int intAnswer = 0;

            if (radEnvironment.SelectedItem.Value == "TEST")
            {
                intAnswer = intHostTest;
            }
            if (radEnvironment.SelectedItem.Value == "PROD")
            {
                intAnswer = intHostProd;
            }
            if (intAnswer > 0)
            {
                string strName  = txtName.Text.ToUpper();
                string strName1 = strName.Substring(0, 5);
                strName = strName.Substring(5);
                string strName2 = strName.Substring(0, 3);
                strName = strName.Substring(3);
                string strName3 = strName.Substring(0, 2);
                strName = strName.Substring(2);
                string strName4 = strName.Substring(0, 1);
                strName = strName.Substring(1);
                int     intName = 0;
                DataSet dsNames = SqlHelper.ExecuteDataset(dsn, CommandType.Text, "SELECT * FROM cv_servernames WHERE prefix1 = '" + strName1 + "' AND prefix2 = '" + strName2 + "' AND sitecode = '" + strName3 + "' AND name1 = '" + strName4 + "' AND name2 = '" + strName + "' AND deleted = 0");
                if (dsNames.Tables[0].Rows.Count > 0)
                {
                    intName = Int32.Parse(dsNames.Tables[0].Rows[0]["id"].ToString());
                }
                else
                {
                    ServerName oServerName = new ServerName(0, dsn);
                    intName = oServerName.Add(0, strName1, strName2, strName3, strName4, strName, 0, txtSerial.Text, 0);
                }
                Forecast oForecast  = new Forecast(0, dsn);
                int      intClass   = Int32.Parse(oForecast.GetAnswer(intAnswer, "classid"));
                int      intEnv     = Int32.Parse(oForecast.GetAnswer(intAnswer, "environmentid"));
                int      intAddress = Int32.Parse(oForecast.GetAnswer(intAnswer, "addressid"));
                int      intNumber  = (int)SqlHelper.ExecuteScalar(dsn, CommandType.Text, "SELECT MAX(number) FROM cv_servers WHERE answerid = " + intAnswer.ToString());
                intNumber = intNumber + 1;
                DataSet dsServers    = SqlHelper.ExecuteDataset(dsn, CommandType.Text, "SELECT * FROM cv_servers WHERE answerid = " + intAnswer.ToString());
                DataRow drServer     = dsServers.Tables[0].Rows[0];
                int     intOldServer = Int32.Parse(drServer["id"].ToString());
                SqlHelper.ExecuteNonQuery(dsn, CommandType.Text, "INSERT INTO cv_servers VALUES(" + drServer["requestid"] + "," + drServer["answerid"] + "," + drServer["modelid"] + "," + drServer["csmconfigid"] + "," + drServer["clusterid"] + "," + intNumber.ToString() + "," + drServer["osid"] + "," + drServer["spid"] + "," + drServer["templateid"] + "," + drServer["domainid"] + "," + drServer["test_domainid"] + "," + drServer["infrastructure"] + "," + drServer["dr"] + "," + drServer["dr_exist"] + ",'" + drServer["dr_name"] + "'," + drServer["dr_consistency"] + "," + drServer["dr_consistencyid"] + "," + drServer["configured"] + "," + drServer["local_storage"] + "," + drServer["accounts"] + "," + drServer["fdrive"] + ",0,0," + intName.ToString() + ",'" + drServer["dhcp"] + "',0,999,0,0,null,null,null,0,getdate(),getdate(),0)");
                int   intServer = (int)SqlHelper.ExecuteScalar(dsn, CommandType.Text, "SELECT TOP 1 id FROM cv_servers WHERE answerid = " + intAnswer.ToString() + " ORDER BY created DESC");
                Asset oAsset    = new Asset(0, dsnAsset);
                int   intAsset  = oAsset.Add("", Int32.Parse(Request.Form[hdnParent.UniqueID]), txtSerial.Text.ToUpper(), txtAsset.Text.ToUpper(), (int)AssetStatus.Arrived, intProfile, DateTime.Now, 0, 1);
                oAsset.AddServer(intAsset, (int)AssetStatus.Available, intProfile, DateTime.Now, intClass, intEnv, intAddress, GetRoom(txtRoom.Text), GetRack(txtRack.Text), txtRackPos.Text, txtILO.Text, txtSerial.Text.ToUpper(), txtMAC.Text, Int32.Parse(txtVlan.Text), 0);
                oAsset.AddStatus(intAsset, txtName.Text.ToUpper(), (int)AssetStatus.InUse, intProfile, DateTime.Now);
                Servers oServer = new Servers(0, dsn);
                oServer.AddAsset(intServer, intAsset, intClass, intEnv, 0, 0);
                lblDone.Text = "<img src='/images/bigcheck.gif' border='0' align='absmiddle'/> <b>Finished!</b> ClearView added the host";
            }
            else
            {
                lblDone.Text = "<img src='/images/bigerror.gif' border='0' align='absmiddle'/> <b>Error!</b> Select a Type!";
            }
        }
コード例 #2
0
ファイル: servername.ascx.cs プロジェクト: radtek/ClearView
        protected void btnSubmit_Click(Object Sender, EventArgs e)
        {
            int    intID            = -100;
            string strError         = "";
            string strPrefixError   = "";
            bool   boolNCB          = (Request.QueryString["type"] == "NCB");
            bool   boolPNC          = (Request.QueryString["type"] == "PNC");
            string strFieldCode     = "";
            string strFieldSpecific = "";

            if (boolNCB == true)
            {
                strFieldCode = "code";
            }
            else if (boolPNC == true)
            {
                strFieldCode     = "factory_code";
                strFieldSpecific = "factory_code_specific";
            }

            string strComponentCode     = "";
            string strComponentSpecific = "";

            if (Request.Form["hdnComponents"] != null)
            {
                string strComponents = Request.Form["hdnComponents"];
                if (strComponents != "")
                {
                    while (strComponents != "")
                    {
                        int intDetail = Int32.Parse(strComponents.Substring(0, strComponents.IndexOf("&")));
                        if (intDetail > 0)
                        {
                            int intComponent = 0;
                            if (Int32.TryParse(oServerName.GetComponentDetail(intDetail, "componentid"), out intComponent) == true)
                            {
                                string strCode = oServerName.GetComponent(intComponent, strFieldCode);
                                if (strPrefixError != "")
                                {
                                    strPrefixError += "\\n";
                                }
                                strPrefixError += " - " + oServerName.GetComponent(intComponent, "name");
                                if (strCode.Trim() != "")
                                {
                                    if (strFieldSpecific != "")
                                    {
                                        strComponentSpecific = oServerName.GetComponent(intComponent, strFieldSpecific).Trim();
                                    }
                                    strComponentCode = strCode.Trim();
                                    break;
                                }
                            }
                        }
                        strComponents = strComponents.Substring(strComponents.IndexOf("&") + 1);
                    }
                }
            }
            if (ddlApplication.SelectedIndex > 0)
            {
                strPrefixError = " - " + ddlApplication.SelectedItem.Text;
            }
            int intServerType = 0;

            if (ddlApplication.SelectedIndex > 0)
            {
                intServerType = Int32.Parse(ddlApplication.SelectedItem.Value);
            }
            string strPrefix = "";

            if (intServerType > 0)
            {
                if (strFieldCode != "")
                {
                    strPrefix = oServerName.GetApplication(intServerType, strFieldCode).Trim();
                }
                if (strFieldSpecific != "")
                {
                    strComponentSpecific = oServerName.GetApplication(intServerType, strFieldSpecific).Trim();
                }
            }
            else
            {
                strPrefix = strComponentCode;
            }
            strPrefix = strPrefix.ToUpper().Trim();
            if (strPrefix == "")
            {
                strError = "The following component(s) or server type have not been configured for server naming...\\n\\n" + strPrefixError;
            }
            else
            {
                int intOS = Int32.Parse(ddlOS.SelectedItem.Value);
                if (boolNCB == true)
                {
                    if (oOperatingSystems.IsMidrange(intOS) == true)
                    {
                        strPrefix = "X" + strPrefix.Substring(0, 2);
                    }
                    switch (ddlCluster.SelectedItem.Value)
                    {
                    case "1":
                        // NSQ = Node of a Cluster
                        if (strPrefix.StartsWith("X") == true)
                        {
                            strPrefix = "XN" + strPrefix[1].ToString();
                        }
                        else
                        {
                            strPrefix = "N" + strPrefix.Substring(0, 2);
                        }
                        break;

                    case "2":
                        // CLU = Cluster Name
                        strPrefix = "CLU";
                        break;

                    case "3":
                        // CSQ = Cluster Instance Name
                        if (strPrefix.StartsWith("X") == true)
                        {
                            strPrefix = "XC" + strPrefix[1].ToString();
                        }
                        else
                        {
                            strPrefix = "C" + strPrefix.Substring(0, 2);
                        }
                        break;
                    }
                    intID = oServerName.Add(Int32.Parse(ddlClass.SelectedItem.Value), Int32.Parse(ddlEnvironment.SelectedItem.Value), Int32.Parse(Request.Form[hdnParent.UniqueID]), strPrefix, intProfile, txtName.Text, 1, dsnServiceEditor);
                }
                else if (boolPNC == true)
                {
                    string strOS = oOperatingSystems.Get(intOS, "factory_code");
                    if (strOS == "")
                    {
                        strError = "The selected OPERATING SYSTEM has not been configured for server naming...";
                    }
                    else
                    {
                        int    intAddress  = Int32.Parse(Request.QueryString["aid"]);
                        string strLocation = oLocation.GetAddress(intAddress, "factory_code");
                        if (strOS == "")
                        {
                            strError = "The selected LOCATION has not been configured for server naming...";
                        }
                        else
                        {
                            int    intMnemonic = Int32.Parse(Request.Form[hdnMnemonic.UniqueID]);
                            string strMnemonic = oMnemonic.Get(intMnemonic, "factory_code");
                            if (strOS == "")
                            {
                                strError = "The selected MNEMONIC has not been configured for server naming...";
                            }
                            else
                            {
                                int    intClass       = Int32.Parse(Request.QueryString["cid"]);
                                int    intEnv         = Int32.Parse(Request.QueryString["eid"]);
                                string strEnvironment = oClass.Get(intClass, "factory_code");
                                if (strOS == "")
                                {
                                    strError = "The selected CLASS has not been configured for server naming...";
                                }
                                else
                                {
                                    // Get Server Function
                                    string strFunction = strComponentCode;
                                    if (strOS == "")
                                    {
                                        strError = "The selected FUNCTION has not been configured for server naming...";
                                    }
                                    else
                                    {
                                        // Get Specifics
                                        string strSpecific = strComponentSpecific;
                                        switch (ddlCluster.SelectedItem.Value)
                                        {
                                        case "1":
                                            // NSQ = Node of a Cluster
                                            strSpecific = "Z";
                                            break;

                                        case "2":
                                            // CLU = Cluster Name
                                            strSpecific = "";
                                            break;

                                        case "3":
                                            // CSQ = Cluster Instance Name
                                            strSpecific = "";
                                            break;
                                        }
                                        intID = oServerName.AddFactory(strOS, strLocation, strMnemonic, strEnvironment, intClass, intEnv, strFunction, strSpecific, intProfile, txtName.Text, dsnServiceEditor);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            Redirect(intID, strError);
        }
コード例 #3
0
        protected void MakeChange(bool _override)
        {
            // Check to see if new name already exists
            int    intNameID  = Int32.Parse(lblNameID.Text);
            int    intID      = Int32.Parse(lblID.Text);
            bool   boolExists = false;
            string strName    = Request.Form[hdnName.UniqueID];
            string strError   = "";

            switch (ddlType.SelectedValue)
            {
            case "-1":
                // Workstation
                DataSet dsWorkstation = oWorkstation.GetName(strName);
                if (dsWorkstation.Tables[0].Rows.Count > 0 && dsWorkstation.Tables[0].Rows[0]["available"].ToString() == "0" && _override == false)
                {
                    boolExists = true;
                }
                else
                {
                    // Does not exist or is otherwise available for use - update
                    boolExists = false;
                    // Set old name to available
                    oWorkstation.UpdateName(intNameID, 1);
                    if (dsWorkstation.Tables[0].Rows.Count > 0)
                    {
                        // If name already exists (available is marked or _override = true) then use that
                        intNameID = Int32.Parse(dsWorkstation.Tables[0].Rows[0]["id"].ToString());
                    }
                    else
                    {
                        // Create the name
                        string strSequence = txtWorkstationSequence.Text;
                        intNameID = oWorkstation.AddName(ddlWorkstationEnvironment.SelectedItem.Value, ddlWorkstationCode.SelectedItem.Value, lblWorkstationIdentifier.Text, strSequence.Substring(0, 1), strSequence.Substring(1, 1), strSequence.Substring(2, 1), strSequence.Substring(3, 1), strSequence.Substring(4, 1), strSequence.Substring(5, 1), 0);
                    }
                    // Set new name to unavailable
                    oWorkstation.UpdateName(intNameID, 0);
                    // Update workstation record
                    oWorkstation.UpdateVirtualName(intID, intNameID);
                }
                break;

            case "0":
                // Server (National City)
                int     intNameNCB = oServerName.GetName(strName);
                DataSet dsNCB      = oServerName.Get(intNameNCB);
                if (dsNCB.Tables[0].Rows.Count > 0 && dsNCB.Tables[0].Rows[0]["available"].ToString() == "0" && _override == false)
                {
                    boolExists = true;
                }
                else
                {
                    // Does not exist or is otherwise available for use - update
                    boolExists = false;
                    // Set old name to available
                    oServerName.Update(intNameID, 1);
                    if (dsNCB.Tables[0].Rows.Count > 0)
                    {
                        // If name already exists (available is marked or _override = true) then use that
                        intNameID = intNameNCB;
                    }
                    else
                    {
                        // Create the name
                        string strSequence = txtNCBSequence.Text;
                        intNameID = oServerName.Add(0, txtNCBState.Text + txtNCBCity.Text, ddlNCBFunction.SelectedItem.Value, ddlNCBSiteCode.SelectedItem.Value, strSequence.Substring(0, 1), strSequence.Substring(1, 1), intProfile, "CHANGE", 0);
                    }
                    // Set new name to unavailable
                    oServerName.Update(intNameID, 0);
                    // Update server record
                    oServer.UpdateServerNamed(intID, intNameID);
                }
                break;

            case "1":
                // Server (PNC Financial Services)
                int     intNamePNC = oServerName.GetNameFactory(strName);
                DataSet dsPNC      = oServerName.GetFactory(intNamePNC);
                if (dsPNC.Tables[0].Rows.Count > 0 && dsPNC.Tables[0].Rows[0]["available"].ToString() == "0" && _override == false)
                {
                    boolExists = true;
                }
                else
                {
                    // Does not exist or is otherwise available for use - update
                    boolExists = false;
                    // Set old name to available
                    oServerName.UpdateFactory(intNameID, 1);
                    if (dsPNC.Tables[0].Rows.Count > 0)
                    {
                        // If name already exists (available is marked or _override = true) then use that
                        intNameID = intNamePNC;
                    }
                    else
                    {
                        // Create the name
                        string strSequence = txtPNCSequence.Text;
                        intNameID = oServerName.AddFactory(ddlPNCOS.SelectedItem.Value, ddlPNCLocation.SelectedItem.Value, Request.Form["hdnPNCMnemonic"], ddlPNCEnvironment.SelectedItem.Value, strSequence.Substring(0, 1), strSequence.Substring(1, 1), ddlPNCFunction.SelectedItem.Value, ddlPNCSpecific.SelectedItem.Value, intProfile, "CHANGE", 0);
                    }
                    // Set new name to unavailable
                    oServerName.UpdateFactory(intNameID, 0);
                    // Update server record
                    oServer.UpdateServerNamed(intID, intNameID);
                }
                break;
            }

            if (boolExists == true)
            {
                panExists.Visible  = true;
                lblAlready.Text    = strName;
                panChange.Visible  = false;
                panButtons.Visible = false;
                btnAlreadyCancel.Focus();
            }
            else
            {
                if (strError == "")
                {
                    // Update asset
                    oAsset.AddStatus(intAsset, strName, intStatus, intProfile, DateTime.Now);
                    // Redirect
                    Response.Redirect(Request.Path + "?assetid=" + intAsset.ToString() + "&clear=" + radClear.SelectedItem.Value + "&changed=true");
                }
                else
                {
                    // Build Error Message
                    Response.Redirect(Request.Path + "?assetid=" + intAsset.ToString() + "&clear=" + radClear.SelectedItem.Value + "&error=" + strError);
                }
            }
        }
コード例 #4
0
        protected void CreateClusterAndAddHostsToServer()
        {
            ServerName oServerName        = new ServerName(0, dsn);
            Servers    oServer            = new Servers(0, dsn);
            Cluster    oCluster           = new Cluster(0, dsn);
            int        intClass           = Int32.Parse(ddlClass.SelectedValue);
            int        intEnv             = Int32.Parse(ddlEnvironment.SelectedValue);
            int        intAddress         = Int32.Parse(hdnLocation.Value);
            int        intRequestId       = Int32.Parse(hdnRequestId.Value);
            int        intVMWareClusterId = 0;
            int        intClusterID       = 0;
            int        intSelectedCount   = 0;
            int        intSelectedDRCount = 0;

            DataSet dsAssets = oAsset.GetAssetsByOrder(Int32.Parse(hdnOrderId.Value));

            intSelectedCount   = dsAssets.Tables[0].Rows.Count;
            intSelectedDRCount = dsAssets.Tables[0].Rows.Count;

            intModel = Int32.Parse(ddlModel.SelectedValue);
            if (intOrderType == (int)AssetSharedEnvOrderType.AddCluster)//for Cluster -Add record in Cluster Table
            {
                string strPrefix          = "XCV";
                string strDatastoreNotify = "xassa3x";
                int    intServerName      = oServerName.Add(intClass, intEnv, intAddress, strPrefix, intProfile, "VMWARE_CLUSTER_IM", 1, dsnServiceEditor);
                string strClusterName     = oServerName.GetName(intServerName, 0);
                intVMWareClusterId = oVMWare.AddCluster(intParent, intModel, strClusterName, 0, 0,
                                                        10000, "", strDatastoreNotify, 1, 500, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 100, 2, 100, 500, 100,
                                                        10, 10, 10, 1, 1, 1);
                foreach (ListItem lstOS in chkFunctionVMWARE.Items)
                {
                    if (lstOS.Selected)
                    {
                        oVMWare.AddClusterOS(intVMWareClusterId, Int32.Parse(lstOS.Value));
                    }
                }
                intClusterID = oCluster.Add(intRequestId, strClusterName, intSelectedCount, intSelectedDRCount, 0);
            }
            else if (intOrderType == (int)AssetSharedEnvOrderType.AddHost)
            {
                intVMWareClusterId = Int32.Parse(hdnParentId.Value);
            }

            //For Cluster OR Host -Add Server Assets Table
            if (intOrderType == (int)AssetSharedEnvOrderType.AddCluster ||
                intOrderType == (int)AssetSharedEnvOrderType.AddHost)
            {
                int    intNumber     = 0;
                int    intDomain     = 0;
                int    intOS         = 0;
                int    intSP         = 0;
                string strNodePrefix = "XNV";
                foreach (DataRow drAsset in dsAssets.Tables[0].Rows)
                {
                    //Mark the Asset to Instock
                    //oAsset.UpdateStatus(Int32.Parse(hdnAssetId.Value), "", (int)AssetStatus.InStock, intProfile, DateTime.Now);
                    intNumber++;
                    int intserverId = oServer.Add(intRequestId, 0, intModel, 0, intClusterID, intNumber, intOS, intSP, 0, intDomain, 0, 1, 0, (intSelectedDRCount > 0 ? 1 : 0), 0, "", 0, 0, 1, 1, 1, 1, 0, (oClass.Get(intClass, "pnc") == "1" ? 1 : 0), intVMWareClusterId, 0);
                    int intAsset    = Int32.Parse(drAsset["id"].ToString());
                    oServer.AddAsset(intserverId, intAsset, intClass, intEnvironment, 0, 0);
                    //oServer.UpdateStep(intserverId, 1);
                    oAsset.Update(intAsset, (int)AssetAttribute.Reserve);
                    //string strHostName = "";
                    //oAsset.AddStatus(intAsset, strHostName, (int)AssetStatus.Reserved, intProfile, DateTime.Now);
                    //Based on the asset selection create name for hosts
                    //intServerName = oServerName.Add(intClass, intEnv, intAddress, strNodePrefix, intProfile, oAsset.Get(intAsset, "serial"), 1);
                    //string strHostName = oServerName.GetName(intServerName, 0);
                    //
                }
                //Set the server step to one
                DataSet dsServer = oServer.GetRequests(intRequestId, 1);
                foreach (DataRow dr in dsServer.Tables[0].Rows)
                {
                    oServer.UpdateStep(Int32.Parse(dr["id"].ToString()), 1);
                }
            }
            ////if (Int32.Parse(rblASEOrderType.SelectedValue) == (int)AssetSharedEnvOrderType.AddHost)//for Host -Add record in Host Table
            ////{
            ////    intVMWareClusterId = 123456789;
            ////    int intNumber = 0;
            ////    int intDomain = 0;  // josh
            ////    int intOS = 0;  // josh
            ////    int intSP = 0;  // josh
            ////    string strPrefix = "XNV";
            ////    int intSelectedDRCount = 0;
            ////    foreach (DataListItem dlItem in dlAssetsSelection.Items)
            ////    {
            ////        HiddenField hdnAssetId = (HiddenField)dlItem.FindControl("hdnAssetId");
            ////        CheckBox chkSelectAsset = (CheckBox)dlItem.FindControl("chkSelectAsset");
            ////        if (chkSelectAsset.Checked == true)
            ////        {
            ////            //Mark the Asset to Instock
            ////            //oAsset.UpdateStatus(Int32.Parse(hdnAssetId.Value), "", (int)AssetStatus.InStock, intProfile, DateTime.Now);
            ////            intNumber++;
            ////            int intserverId = oServer.Add(intRequestId, 0, intModel, 0, 0, intNumber, intOS, intSP, 0, intDomain, 0, 1, 0, (intSelectedDRCount > 0 ? 1 : 0), 0, "", 0, 0, 1, 1, 1, 1, 0, (oClass.Get(intClass, "pnc") == "1" ? 1 : 0), intVMWareClusterId, 0);
            ////            int intAsset = Int32.Parse(hdnAssetId.Value);
            ////            oServer.AddAsset(intserverId, intAsset, intClass, intEnvironment, 0, 0);
            ////            //Based on the asset selection create name for hosts
            ////            //intServerName = oServerName.Add(intClass, intEnv, intAddress, strPrefix, intProfile, oAsset.Get(intAsset, "serial"), 1);
            ////            //string strHostName = oServerName.GetName(intServerName, 0);
            ////            //oAsset.AddStatus(intAsset, strHostName, (int)AssetStatus.InUse, intProfile, DateTime.Now);


            ////        }
            ////    }
            ////}
        }