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); oWorkstation = new Workstations(intProfile, dsn); 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); oDomain = new Domains(intProfile, dsn); oVirtualHDD = new VirtualHDD(intProfile, dsn); oVirtualRam = new VirtualRam(intProfile, dsn); oZeus = new Zeus(intProfile, dsnZeus); oLog = new Log(intProfile, dsn); oService = new Services(intProfile, dsn); oServiceRequest = new ServiceRequests(intProfile, dsn); oResourceRequest = new ResourceRequest(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 = """ + strHeader.ToUpper() + """; Master.Page.Title = "DataPoint | VMware Workstation (" + strHeader + ")"; lblHeaderSub.Text = "Provides all the information about a VMware Workstation..."; 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("Guest Information", ""); oTab.AddTab("Account Information", ""); oTab.AddTab("Resource Dependencies", ""); oTab.AddTab("Provisioning Information", ""); if (oUser.IsAdmin(intProfile) == true || oDataPoint.GetFieldPermission(intProfile, "SERVER_ADMIN") == true) { oTab.AddTab("Administration", ""); panAdministration.Visible = true; } strMenuTab1 = oTab.GetTabs(); if (!IsPostBack) { // Asset Information oDataPoint.LoadTextBox(txtPlatformSerial, intProfile, null, "", lblPlatformSerial, fldPlatformSerial, "WORKSTATION_VMWARE_SERIAL", strSerial, "", false, true); oDataPoint.LoadTextBox(txtPlatformAsset, intProfile, null, "", lblPlatformAsset, fldPlatformAsset, "WORKSTATION_VMWARE_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); string strExecute = oType.Get(intType, "forecast_execution_path"); if (strExecute != "") { DataSet dsVirtual = oWorkstation.GetVirtualAsset(intAsset); if (dsVirtual.Tables[0].Rows.Count > 0) { btnExecute.Attributes.Add("onclick", "return OpenWindow('FORECAST_EXECUTE','" + strExecute + "?id=" + dsVirtual.Tables[0].Rows[0]["answerid"].ToString() + "');"); } else { btnExecute.Enabled = false; } } else { btnExecute.Enabled = false; } int intPlatform = oType.GetPlatform(intType); oDataPoint.LoadDropDown(ddlPlatform, intProfile, null, "", lblPlatform, fldPlatform, "WORKSTATION_VMWARE_PLATFORM", "name", "platformid", oPlatform.Gets(1), intPlatform, false, false, true); oDataPoint.LoadDropDown(ddlPlatformType, intProfile, null, "", lblPlatformType, fldPlatformType, "WORKSTATION_VMWARE_TYPE", "name", "id", oType.Gets(intPlatform, 1), intType, false, false, true); oDataPoint.LoadDropDown(ddlPlatformModel, intProfile, null, "", lblPlatformModel, fldPlatformModel, "WORKSTATION_VMWARE_MODEL", "name", "id", oModel.Gets(intType, 1), intModelParent, false, false, true); oDataPoint.LoadDropDown(ddlPlatformModelProperty, intProfile, null, "", lblPlatformModelProperty, fldPlatformModelProperty, "WORKSTATION_VMWARE_MODEL_PROP", "name", "id", oModelsProperties.GetModels(0, intModelParent, 1), intModel, false, false, true); // Get Asset int intWorkstation = 0; DataSet dsAsset = oWorkstation.GetVirtualAsset(intAsset); if (dsAsset.Tables[0].Rows.Count > 0) { intWorkstation = Int32.Parse(dsAsset.Tables[0].Rows[0]["id"].ToString()); lblWorkstation.Text = intWorkstation.ToString(); txtStep.Text = dsAsset.Tables[0].Rows[0]["step"].ToString(); oDataPoint.LoadTextBoxDeviceName(txtName, btnName, null, true, hdnPNC, intProfile, null, "", lblName, fldName, "WORKSTATION_VMWARE_NAME", dsAsset.Tables[0].Rows[0]["name"].ToString(), "", false, false); if (txtName.Text != "") { lblHeader.Text += " [" + txtName.Text + "]"; } lblStatus.Text = dsAsset.Tables[0].Rows[0]["statusname"].ToString(); // Administrative Functions if (Request.QueryString["admin"] != null) { if (Request.QueryString["result"] != null) { strAdministration = "<tr><td>" + oFunction.decryptQueryString(Request.QueryString["result"]) + "</td></tr>"; } if (Request.QueryString["output"] != null) { DataSet dsOutput = oWorkstation.GetVirtualOutput(intWorkstation); foreach (DataRow drOutput in dsOutput.Tables[0].Rows) { strAdministration += "<tr><td><a href=\"javascript:void(0);\" onclick=\"ShowHideDiv2('div" + drOutput["id"].ToString() + "');\">" + drOutput["type"].ToString() + "</a></td></tr>"; strAdministration += "<tr id=\"div" + drOutput["id"].ToString() + "\" style=\"display:none\"><td>" + oFunction.FormatText(drOutput["output"].ToString()) + "</td></tr>"; } if (lblStatus.Text != "") { strAdministration += "<tr><td>" + oLog.GetEvents(oLog.GetEventsByName(txtName.Text.ToUpper(), (int)LoggingType.Error), intEnvironment) + "</td></tr>"; } } } 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, "WORKSTATION_VMWARE_CLASS", "name", "id", oClass.GetWorkstationVMwares(1), intClass, false, false, true); oDataPoint.LoadDropDown(ddlPlatformEnvironment, intProfile, null, "", lblPlatformEnvironment, fldPlatformEnvironment, "WORKSTATION_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); int intOS = Int32.Parse(dsAsset.Tables[0].Rows[0]["osid"].ToString()); bool boolXP = (oOperatingSystem.Get(intOS, "code") == "XP"); bool boolWin7 = (oOperatingSystem.Get(intOS, "code") == "7"); oDataPoint.LoadDropDown(ddlPlatformOS, intProfile, null, "", lblPlatformOS, fldPlatformOS, "WORKSTATION_VMWARE_OS", "name", "id", oOperatingSystem.Gets(1, 1), intOS, false, false, true); oDataPoint.LoadDropDown(ddlPlatformServicePack, intProfile, null, "", lblPlatformServicePack, fldPlatformServicePack, "WORKSTATION_VMWARE_SP", "name", "id", oOperatingSystem.GetServicePack(intOS), Int32.Parse(dsAsset.Tables[0].Rows[0]["spid"].ToString()), false, false, true); oDataPoint.LoadDropDown(ddlPlatformDomain, intProfile, null, "", lblPlatformDomain, fldPlatformDomain, "WORKSTATION_VMWARE_DOMAIN", "name", "id", oDomain.Gets(1), Int32.Parse(dsAsset.Tables[0].Rows[0]["domainid"].ToString()), false, false, true); oDataPoint.LoadDropDown(ddlPlatformHDD, intProfile, null, "", lblPlatformHDD, fldPlatformHDD, "WORKSTATION_VMWARE_HDD", "name", "id", oVirtualHDD.GetVMwares((boolXP ? 1 : 0), (boolWin7 ? 1 : 0), 1), Int32.Parse(dsAsset.Tables[0].Rows[0]["hddid"].ToString()), false, false, true); oDataPoint.LoadDropDown(ddlPlatformRam, intProfile, null, "", lblPlatformRam, fldPlatformRam, "WORKSTATION_VMWARE_RAM", "name", "id", oVirtualRam.GetVMwares((boolXP ? 1 : 0), (boolWin7 ? 1 : 0), 1), Int32.Parse(dsAsset.Tables[0].Rows[0]["ramid"].ToString()), false, false, true); } else { Response.Redirect("/datapoint/asset/datapoint_asset_search.aspx"); } // Get Host oDataPoint.LoadTextBox(txtHostName, intProfile, btnHostName, "/datapoint/asset/server.aspx?t=name&q=" + oFunction.encryptQueryString(dsAsset.Tables[0].Rows[0]["hostname"].ToString()), lblHostName, fldHostName, "WORKSTATION_VMWARE_HOST", dsAsset.Tables[0].Rows[0]["hostname"].ToString(), "", false, false); if (Request.Cookies["virtual_guest"] != null && Request.Cookies["virtual_guest"].Value != "") { string strHost = ""; string strFind = txtName.Text; //strFind = "ohcleapp103d"; DateTime datStart = DateTime.Parse(Request.Cookies["virtual_guest"].Value); Response.Cookies["virtual_guest"].Value = ""; VMWare oVMWare = new VMWare(intProfile, dsn); string strConnect = oVMWare.Connect(strFind); VimService _service = oVMWare.GetService(); ServiceContent _sic = oVMWare.GetSic(); try { ManagedObjectReference oVM = oVMWare.GetVM(strFind); ManagedObjectReference oParent = (ManagedObjectReference)oVMWare.getObjectProperty(oVM, "parent"); ManagedObjectReference oDataCenter = (ManagedObjectReference)oVMWare.getObjectProperty(oParent, "parent"); string strDataCenter = (string)oVMWare.getObjectProperty(oDataCenter, "name"); GuestInfo ginfo = (GuestInfo)oVMWare.getObjectProperty(oVM, "guest"); 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; } // HDD GuestDiskInfo[] oVMDisks = ginfo.disk; foreach (GuestDiskInfo oDisk in oVMDisks) { if (lblHDD.Text != "") { lblHDD.Text += "<br/>"; } double dblCapacity = double.Parse(oDisk.capacity.ToString()); dblCapacity = dblCapacity / 1024.00; dblCapacity = dblCapacity / 1024.00; dblCapacity = dblCapacity / 1024.00; double dblAvailable = double.Parse(oDisk.freeSpace.ToString()); dblAvailable = dblAvailable / 1024.00; dblAvailable = dblAvailable / 1024.00; dblAvailable = dblAvailable / 1024.00; lblHDD.Text += oDisk.diskPath + " " + dblCapacity.ToString("F") + " GB (" + dblAvailable.ToString("F") + " GB available)"; } // Status VirtualMachineSummary oVMSummary = (VirtualMachineSummary)oVMWare.getObjectProperty(oVM, "summary"); ManagedEntityStatus oVMStatus = oVMSummary.overallStatus; //lblOverallStatus.Text = (string)oVMStatus; lblOverallStatus.Text = Enum.GetName(typeof(ManagedEntityStatus), (ManagedEntityStatus)oVMStatus); // RAM & CPUs & Host VirtualMachineConfigSummary oVMConfig = oVMSummary.config; lblRAM.Text = oVMConfig.memorySizeMB.ToString(); lblCPUs.Text = oVMConfig.numCpu.ToString(); 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 = oVMWare.VirtualCenter(); lblDataCenter.Text = oVMWare.DataCenter(); } 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 != "") { panGuestYes.Visible = true; oDataPoint.LoadTextBox(txtHostName, intProfile, btnHostName, "/datapoint/asset/server.aspx?t=name&q=" + oFunction.encryptQueryString(strHost), lblHostName, fldHostName, "WORKSTATION_VMWARE_HOST", strHost, "", false, false); } else { panGuestNo.Visible = true; } TimeSpan oSpan = DateTime.Now.Subtract(datStart); btnGuestQuery.Enabled = false; btnGuestQuery.Text = "Query Time: " + oSpan.TotalSeconds.ToString("0") + " seconds..."; } oDataPoint.LoadPanel(panGuestQuery, intProfile, fldHostQuery, "WORKSTATION_VMWARE_HOST_QUERY"); // Account Information DataSet dsAccounts = oWorkstation.GetAccountsVMware(intWorkstation); rptAccounts.DataSource = dsAccounts; rptAccounts.DataBind(); lblNone.Visible = (rptAccounts.Items.Count == 0); // Resource Dependencies rptServiceRequests.DataSource = ds.Tables[1]; rptServiceRequests.DataBind(); trServiceRequests.Visible = (rptServiceRequests.Items.Count == 0); foreach (RepeaterItem ri in rptServiceRequests.Items) { Label lblRequestID = (Label)ri.FindControl("lblRequestID"); Label lblServiceID = (Label)ri.FindControl("lblServiceID"); Label lblNumber = (Label)ri.FindControl("lblNumber"); 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); //lblProgress.Text = oResourceRequest.GetStatus(Int32.Parse(lblRequestID.Text), Int32.Parse(lblServiceID.Text), Int32.Parse(lblNumber.Text), true, true, dsnServiceEditor, dsnAsset, intServiceDecommission); lblProgress.Text = oResourceRequest.GetStatus(null, null, Int32.Parse(lblRequestID.Text), Int32.Parse(lblServiceID.Text), null, Int32.Parse(lblNumber.Text), true, dsnServiceEditor)[0].status; /* * 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 = SqlHelper.ExecuteDataset(dsnAsset, CommandType.Text, oDataPoint.AssetHistorySelect(intAsset)); rptHistory.DataBind(); lblHistory.Visible = (rptHistory.Items.Count == 0); oDataPoint.LoadPanel(panProvisioning, intProfile, fldProvisioning, "WORKSTATION_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) { 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"); } 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 + "');"); btnGuestQuery.Attributes.Add("onclick", "ProcessButton(this,'Querying... please be patient...','225') && ProcessControlButton();"); btnOutput.Attributes.Add("onclick", "return ProcessButton(this) && ProcessControlButton();"); } else { panDenied.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { Int32.TryParse(Request.Cookies["profileid"].Value, out intProfile); oServer = new Servers(intProfile, dsn); oServerName = new ServerName(intProfile, dsn); oWorkstation = new Workstations(intProfile, dsn); oAsset = new Asset(intProfile, dsnAsset, dsn); Int32.TryParse(Request.QueryString["assetid"], out intAsset); bool boolMessage = false; if (Request.QueryString["changed"] != null) { boolMessage = true; Page.ClientScript.RegisterStartupScript(typeof(Page), "changed", "<script type=\"text/javascript\">alert('Device Name Changed Successfully!');RefreshOpeningWindow();window.close();<" + "/" + "script>"); } if (Request.QueryString["cleared"] != null) { boolMessage = true; Page.ClientScript.RegisterStartupScript(typeof(Page), "cleared", "<script type=\"text/javascript\">alert('Device Name Cleared Successfully!');RefreshOpeningWindow();window.close();<" + "/" + "script>"); } if (Request.QueryString["error"] != null) { boolMessage = true; Page.ClientScript.RegisterStartupScript(typeof(Page), "bad", "<script type=\"text/javascript\">alert('There was a problem changing the device name...\\n\\n" + Request.QueryString["error"] + "');<" + "/" + "script>"); } if (Int32.TryParse(oAsset.GetStatus(intAsset, "status"), out intStatus) == true) { if (!IsPostBack) { string strAdditional = ""; if (intAsset > 0 && Int32.TryParse(oAsset.GetStatus(intAsset, "status"), out intStatus) == true) { if (Request.QueryString["clear"] != null) { if (Request.QueryString["clear"] == "Clear") { radClear.SelectedValue = "Clear"; if (intStatus == (int)AssetStatus.InUse) { lblError.Text = "Can not clear the name of an asset while its Status is "In Use"."; } panClear.Visible = true; panID.Visible = true; } if (Request.QueryString["clear"] == "Change") { radClear.SelectedValue = "Change"; panChange.Visible = true; panID.Visible = true; } } DataSet dsWorkstations = oWorkstation.GetVirtualAsset(intAsset); if (dsWorkstations.Tables[0].Rows.Count == 1) { radClear.Items[0].Enabled = false; radClear.Items[0].Text += " - cannot clear device name for workstations"; ddlType.SelectedValue = "-1"; int intWorkstation = 0; int intName = 0; if (Int32.TryParse(dsWorkstations.Tables[0].Rows[0]["id"].ToString(), out intWorkstation) == true) { lblID.Text = intWorkstation.ToString(); if (Int32.TryParse(oWorkstation.GetVirtual(intWorkstation, "nameid"), out intName) == true) { lblNameID.Text = intName.ToString(); lblName.Text = oWorkstation.GetName(intName); lblNew.Text = lblName.Text; panWorkstation.Visible = true; DataSet dsWorkstation = oWorkstation.GetNameId(intName); if (dsWorkstation.Tables[0].Rows.Count == 1) { DataRow drWorkstation = dsWorkstation.Tables[0].Rows[0]; #region WORKSTATION NAMING // Environment ddlWorkstationEnvironment.Attributes.Add("onchange", "UpdateNamingDDL(this,'" + lblWorkstationEnvironment.ClientID + "','WORKSTATION');"); lblWorkstationEnvironment.Text = drWorkstation["environment"].ToString(); ddlWorkstationEnvironment.SelectedValue = lblWorkstationEnvironment.Text; // Code ddlWorkstationCode.Attributes.Add("onchange", "UpdateNamingDDL(this,'" + lblWorkstationCode.ClientID + "','WORKSTATION');"); lblWorkstationCode.Text = drWorkstation["code"].ToString(); ddlWorkstationCode.SelectedValue = lblWorkstationCode.Text; //Sequence txtWorkstationSequence.Attributes.Add("onblur", "UpdateNamingText(this,'" + lblWorkstationSequence.ClientID + "','WORKSTATION');"); lblWorkstationSequence.Text = drWorkstation["prefix1"].ToString() + drWorkstation["prefix2"].ToString() + drWorkstation["prefix3"].ToString() + drWorkstation["prefix4"].ToString() + drWorkstation["prefix5"].ToString() + drWorkstation["prefix6"].ToString(); txtWorkstationSequence.Text = lblWorkstationSequence.Text; panButtons.Visible = (Request.QueryString["clear"] != null); lblNew.Text = lblWorkstationEnvironment.Text + lblWorkstationCode.Text + lblWorkstationIdentifier.Text + lblWorkstationSequence.Text; strAdditional += "ValidateTextLength('" + txtWorkstationSequence.ClientID + "', 'Please enter a valid sequence\\n\\n - Must be exactly 6 characters in length', 6) && "; #endregion } } else { lblError.Text = "Invalid Workstation Name Record(" + oWorkstation.GetVirtual(intWorkstation, "nameid") + ")"; } } else { lblError.Text = "Invalid Workstation Record(" + dsWorkstations.Tables[0].Rows[0]["id"].ToString() + ")"; } } else { DataSet dsServers = oServer.GetAssetsAsset(intAsset); if (dsServers.Tables[0].Rows.Count == 1) { int intServer = 0; int intName = 0; if (Int32.TryParse(dsServers.Tables[0].Rows[0]["serverid"].ToString(), out intServer) == true) { lblID.Text = intServer.ToString(); if (Int32.TryParse(oServer.Get(intServer, "nameid"), out intName) == true) { lblNameID.Text = intName.ToString(); lblName.Text = oServer.GetName(intServer, true); if (oServer.Get(intServer, "pnc") == "1") { ddlType.SelectedValue = "1"; panPNC.Visible = true; DataSet dsPNC = oServerName.GetFactory(intName); if (dsPNC.Tables[0].Rows.Count == 1 || intName == 0) { //Operating System OperatingSystems oOperatingSystem = new OperatingSystems(intProfile, dsn); DataSet dsOS = oOperatingSystem.Gets(0, 1); DataView dvOS = dsOS.Tables[0].DefaultView; dvOS.RowFilter = "factory_code <> '' AND factory_code IS NOT NULL"; ddlPNCOS.DataTextField = "name"; ddlPNCOS.DataValueField = "factory_code"; ddlPNCOS.DataSource = dvOS; ddlPNCOS.DataBind(); ddlPNCOS.Attributes.Add("onchange", "UpdateNamingDDL(this,'" + lblPNCOS.ClientID + "','PNC');"); //Location Locations oLocation = new Locations(intProfile, dsn); DataSet dsLocation = oLocation.GetAddresss(1); DataView dvLocation = dsLocation.Tables[0].DefaultView; dvLocation.RowFilter = "factory_code <> 'X' AND factory_code <> '' AND factory_code IS NOT NULL"; ddlPNCLocation.DataTextField = "commonname"; ddlPNCLocation.DataValueField = "factory_code"; ddlPNCLocation.DataSource = dvLocation; ddlPNCLocation.DataBind(); ddlPNCLocation.Items.Add(new ListItem("Other", "X")); ddlPNCLocation.Attributes.Add("onchange", "UpdateNamingDDL(this,'" + lblPNCLocation.ClientID + "','PNC');"); //Mnemonic Variables oVariable = new Variables(intEnvironment); Mnemonic oMnemonic = new Mnemonic(intProfile, dsn); txtPNCMnemonic.Attributes.Add("onkeyup", "return AJAXTextBoxGet(this,'350','150','" + divPNCMnemonic.ClientID + "','" + lstPNCMnemonic.ClientID + "','" + hdnPNCMnemonic.ClientID + "','" + oVariable.URL() + "/frame/ajax/ajax_mnemonics.aspx',2);"); lstPNCMnemonic.Attributes.Add("ondblclick", "AJAXClickRow();"); hdnPNCMnemonic.Attributes.Add("onpropertychange", "UpdateNamingMnemonic('" + hdnPNCMnemonic.ClientID + "','" + txtPNCMnemonic.ClientID + "','" + lblPNCMnemonic.ClientID + "','PNC');"); //Environment Classes oClass = new Classes(intProfile, dsn); DataSet dsClass = oClass.Gets(1); DataView dvClass = dsClass.Tables[0].DefaultView; dvClass.RowFilter = "factory_code <> '' AND factory_code IS NOT NULL"; ddlPNCEnvironment.DataTextField = "name"; ddlPNCEnvironment.DataValueField = "factory_code"; ddlPNCEnvironment.DataSource = dvClass; ddlPNCEnvironment.DataBind(); ddlPNCEnvironment.Attributes.Add("onchange", "UpdateNamingDDL(this,'" + lblPNCEnvironment.ClientID + "','PNC');"); //Sequence txtPNCSequence.Attributes.Add("onblur", "UpdateNamingText(this,'" + lblPNCSequence.ClientID + "','PNC');"); //Function ddlPNCFunction.Attributes.Add("onchange", "UpdateNamingDDL(this,'" + lblPNCFunction.ClientID + "','PNC');"); //Specific ddlPNCSpecific.Attributes.Add("onchange", "UpdateNamingDDL(this,'" + lblPNCSpecific.ClientID + "','PNC');"); #region PNC NAMING if (intName > 0) { DataRow drPNC = dsPNC.Tables[0].Rows[0]; //Operating System lblPNCOS.Text = drPNC["os"].ToString(); ddlPNCOS.SelectedValue = lblPNCOS.Text; //Location lblPNCLocation.Text = drPNC["location"].ToString(); ddlPNCLocation.SelectedValue = lblPNCLocation.Text; //Mnemonic lblPNCMnemonic.Text = drPNC["mnemonic"].ToString(); DataSet dsMnemonic = oMnemonic.Get(lblPNCMnemonic.Text + " - "); int intMnemonic = Int32.Parse(dsMnemonic.Tables[0].Rows[0]["id"].ToString()); hdnPNCMnemonic.Value = intMnemonic.ToString(); txtPNCMnemonic.Text = lblPNCMnemonic.Text + " - " + oMnemonic.Get(intMnemonic, "name"); //Environment lblPNCEnvironment.Text = drPNC["environment"].ToString(); ddlPNCEnvironment.SelectedValue = lblPNCEnvironment.Text; //Sequence lblPNCSequence.Text = drPNC["name1"].ToString() + drPNC["name2"].ToString(); txtPNCSequence.Text = lblPNCSequence.Text; //Function lblPNCFunction.Text = drPNC["func"].ToString(); ddlPNCFunction.SelectedValue = lblPNCFunction.Text; //Specific lblPNCSpecific.Text = drPNC["specific"].ToString(); ddlPNCSpecific.SelectedValue = lblPNCSpecific.Text; } else { //Operating System ddlPNCOS.Items.Insert(0, new ListItem("-- SELECT --", "0")); strAdditional += "ValidateDropDown('" + ddlPNCOS.ClientID + "','Please select an Operating System') && "; //Location ddlPNCLocation.Items.Insert(0, new ListItem("-- SELECT --", "0")); strAdditional += "ValidateDropDown('" + ddlPNCLocation.ClientID + "','Please select a Location') && "; //Mnemonic strAdditional += "ValidateHidden0('" + hdnPNCMnemonic.ClientID + "','" + txtPNCMnemonic.ClientID + "','Please enter the mnemonic') && "; //Environment ddlPNCEnvironment.Items.Insert(0, new ListItem("-- SELECT --", "0")); strAdditional += "ValidateDropDown('" + ddlPNCEnvironment.ClientID + "','Please select an Environment') && "; //Sequence - Done down below //Function ddlPNCFunction.Items.Insert(0, new ListItem("-- SELECT --", "0")); strAdditional += "ValidateDropDown('" + ddlPNCFunction.ClientID + "','Please select a Function') && "; //Specific ddlPNCSpecific.Items.Insert(0, new ListItem("-- SELECT --", "0")); strAdditional += "ValidateDropDown('" + ddlPNCSpecific.ClientID + "','Please select an Option') && "; } panButtons.Visible = (Request.QueryString["clear"] != null); lblNew.Text = lblPNCOS.Text + lblPNCLocation.Text + lblPNCMnemonic.Text + lblPNCEnvironment.Text + lblPNCSequence.Text + lblPNCFunction.Text + lblPNCSpecific.Text; strAdditional += "ValidateTextLength('" + txtPNCSequence.ClientID + "', 'Please enter a valid sequence\\n\\n - Must be exactly 2 characters in length', 2) && "; #endregion } else { lblError.Text = "PNC Names (" + dsPNC.Tables[0].Rows.Count.ToString() + ")"; } } else { ddlType.SelectedValue = "0"; panNCB.Visible = true; DataSet dsNCB = oServerName.Get(intName); if (dsNCB.Tables[0].Rows.Count == 1 || intName == 0) { //State txtNCBState.Attributes.Add("onblur", "UpdateNamingText(this,'" + lblNCBState.ClientID + "','NCB');"); //City txtNCBCity.Attributes.Add("onblur", "UpdateNamingText(this,'" + lblNCBCity.ClientID + "','NCB');"); //Function DataSet dsFunction = oServerName.GetFunctions(); DataView dvFunction = dsFunction.Tables[0].DefaultView; dvFunction.RowFilter = "code <> '' AND code IS NOT NULL"; ddlNCBFunction.DataTextField = "name"; ddlNCBFunction.DataValueField = "code"; ddlNCBFunction.DataSource = dvFunction; ddlNCBFunction.DataBind(); ddlNCBFunction.Attributes.Add("onchange", "UpdateNamingDDL(this,'" + lblNCBFunction.ClientID + "','NCB');"); //SiteCode ddlNCBSiteCode.Attributes.Add("onchange", "UpdateNamingDDL(this,'" + lblNCBSiteCode.ClientID + "','NCB');"); //Sequence txtNCBSequence.Attributes.Add("onblur", "UpdateNamingText(this,'" + lblNCBSequence.ClientID + "','NCB');"); #region NCB NAMING if (intName > 0) { DataRow drNCB = dsNCB.Tables[0].Rows[0]; string strPrefix = drNCB["prefix1"].ToString(); string strPrefix1 = strPrefix.Substring(0, 2); string strPrefix2 = strPrefix.Substring(2, 3); //State lblNCBState.Text = strPrefix1; txtNCBState.Text = lblNCBState.Text; //City lblNCBCity.Text = strPrefix2; txtNCBCity.Text = lblNCBCity.Text; //Function lblNCBFunction.Text = drNCB["prefix2"].ToString(); ddlNCBFunction.SelectedValue = lblNCBFunction.Text; //SiteCode lblNCBSiteCode.Text = drNCB["sitecode"].ToString(); ddlNCBSiteCode.SelectedValue = lblNCBSiteCode.Text; //Sequence lblNCBSequence.Text = drNCB["name1"].ToString() + drNCB["name2"].ToString(); txtNCBSequence.Text = lblNCBSequence.Text; } else { //State - Done down below //City - Done down below //Function ddlNCBFunction.Items.Insert(0, new ListItem("-- SELECT --", "0")); strAdditional += "ValidateDropDown('" + ddlNCBFunction.ClientID + "','Please select a Function') && "; //SiteCode ddlNCBSiteCode.Items.Insert(0, new ListItem("-- SELECT --", "0")); strAdditional += "ValidateDropDown('" + ddlNCBSiteCode.ClientID + "','Please select a Site Code') && "; //Sequence - Done down below } panButtons.Visible = (Request.QueryString["clear"] != null); lblNew.Text = lblNCBState.Text + lblNCBCity.Text + lblNCBFunction.Text + lblNCBSiteCode.Text + lblNCBSequence.Text; strAdditional += "ValidateTextLength('" + txtNCBState.ClientID + "', 'Please enter a valid state\\n\\n - Must be exactly 2 characters in length', 2) && "; strAdditional += "ValidateTextLength('" + txtNCBCity.ClientID + "', 'Please enter a valid city\\n\\n - Must be exactly 3 characters in length', 3) && "; strAdditional += "ValidateTextLength('" + txtNCBSequence.ClientID + "', 'Please enter a valid sequence\\n\\n - Must be exactly 2 characters in length', 2) && "; #endregion } else { lblError.Text = "NCB Names (" + dsNCB.Tables[0].Rows.Count.ToString() + ")"; } } } else { lblError.Text = "Invalid Server Name Record(" + oServer.Get(intServer, "nameid") + ")"; } } else { lblError.Text = "Invalid Server Record(" + dsServers.Tables[0].Rows[0]["serverid"].ToString() + ")"; } } else { if (dsWorkstations.Tables[0].Rows.Count > 1) { lblError.Text = "Workstations (" + dsWorkstations.Tables[0].Rows.Count.ToString() + ")"; } else if (dsServers.Tables[0].Rows.Count > 1) { lblError.Text = "Servers (" + dsServers.Tables[0].Rows.Count.ToString() + ")"; } else { radClear.Items[1].Enabled = false; panButtons.Visible = (Request.QueryString["clear"] != null); //lblError.Text = "Asset Not Found"; } } } if (lblName.Text == "") { lblName.Text = "---"; } else { lblNew.CssClass = (lblNew.Text == lblName.Text ? "header" : "redheader"); } if (panChange.Visible == true) { btnSubmit.Attributes.Add("onclick", "return " + strAdditional + " IsOKtoChange() && confirm('WARNING: This will permanently change the device name and release the previous name for re-use (if applicable)!\\n\\nAre you sure you want to continue?') && ProcessButton(this,'Changing...','100');"); } if (panClear.Visible == true) { btnSubmit.Attributes.Add("onclick", "return confirm('WARNING: This will permanently clear the device name and release it for re-use (if applicable)!\\n\\nAre you sure you want to continue?') && ProcessButton(this,'Clearing...','100');"); } btnReset.Attributes.Add("onclick", "return IsOKtoReset(this);"); btnAlreadyChange.Attributes.Add("onclick", "return confirm('LAST CHANCE! This will permanently change the device name and release the previous name for re-use (if applicable)!\\n\\nAre you sure you want to continue?') && ProcessButton(this,'Changing...','100');"); } else { lblError.Text = "Either the asset or the status of the asset could not be identified"; } } } else { lblError.Text = "Either the asset or the status of the asset could not be identified"; } if (lblError.Text != "" && boolMessage == false) { panError.Visible = true; panClear.Visible = false; btnSubmit.Enabled = false; } }
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); oWorkstation = new Workstations(intProfile, dsn); 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); oDomain = new Domains(intProfile, dsn); oVirtualHDD = new VirtualHDD(intProfile, dsn); oVirtualRam = new VirtualRam(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 = """ + strHeader.ToUpper() + """; Master.Page.Title = "DataPoint | Virtual Workstation (" + strHeader + ")"; lblHeaderSub.Text = "Provides all the information about a Microsoft Virtual Workstation..."; 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("Account Information", ""); oTab.AddTab("Provisioning Information", ""); strMenuTab1 = oTab.GetTabs(); if (!IsPostBack) { // Asset Information oDataPoint.LoadTextBox(txtPlatformSerial, intProfile, null, "", lblPlatformSerial, fldPlatformSerial, "WORKSTATION_VIRTUAL_SERIAL", strSerial, "", false, true); oDataPoint.LoadTextBox(txtPlatformAsset, intProfile, null, "", lblPlatformAsset, fldPlatformAsset, "WORKSTATION_VIRTUAL_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, "WORKSTATION_VIRTUAL_PLATFORM", "name", "platformid", oPlatform.Gets(1), intPlatform, false, false, true); oDataPoint.LoadDropDown(ddlPlatformType, intProfile, null, "", lblPlatformType, fldPlatformType, "WORKSTATION_VIRTUAL_TYPE", "name", "id", oType.Gets(intPlatform, 1), intType, false, false, true); oDataPoint.LoadDropDown(ddlPlatformModel, intProfile, null, "", lblPlatformModel, fldPlatformModel, "WORKSTATION_VIRTUAL_MODEL", "name", "id", oModel.Gets(intType, 1), intModelParent, false, false, true); oDataPoint.LoadDropDown(ddlPlatformModelProperty, intProfile, null, "", lblPlatformModelProperty, fldPlatformModelProperty, "WORKSTATION_VIRTUAL_MODEL_PROP", "name", "id", oModelsProperties.GetModels(0, intModelParent, 1), intModel, false, false, true); // Get Asset DataSet dsAsset = oWorkstation.GetVirtualAsset(intAsset); if (dsAsset.Tables[0].Rows.Count > 0) { oDataPoint.LoadTextBoxDeviceName(txtName, btnName, null, true, hdnPNC, intProfile, null, "", lblName, fldName, "WORKSTATION_VIRTUAL_NAME", dsAsset.Tables[0].Rows[0]["name"].ToString(), "", false, false); if (txtName.Text != "") { lblHeader.Text += " [" + 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, "WORKSTATION_VIRTUAL_CLASS", "name", "id", oClass.Gets(1), intClass, false, false, true); oDataPoint.LoadDropDown(ddlPlatformEnvironment, intProfile, null, "", lblPlatformEnvironment, fldPlatformEnvironment, "WORKSTATION_VIRTUAL_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); int intOS = Int32.Parse(dsAsset.Tables[0].Rows[0]["osid"].ToString()); oDataPoint.LoadDropDown(ddlPlatformOS, intProfile, null, "", lblPlatformOS, fldPlatformOS, "WORKSTATION_VIRTUAL_OS", "name", "id", oOperatingSystem.Gets(1, 1), intOS, false, false, true); oDataPoint.LoadDropDown(ddlPlatformServicePack, intProfile, null, "", lblPlatformServicePack, fldPlatformServicePack, "WORKSTATION_VIRTUAL_SP", "name", "id", oOperatingSystem.GetServicePack(intOS), Int32.Parse(dsAsset.Tables[0].Rows[0]["spid"].ToString()), false, false, true); oDataPoint.LoadDropDown(ddlPlatformDomain, intProfile, null, "", lblPlatformDomain, fldPlatformDomain, "WORKSTATION_VIRTUAL_DOMAIN", "name", "id", oDomain.Gets(1), Int32.Parse(dsAsset.Tables[0].Rows[0]["domainid"].ToString()), false, false, true); oDataPoint.LoadDropDown(ddlPlatformHDD, intProfile, null, "", lblPlatformHDD, fldPlatformHDD, "WORKSTATION_VIRTUAL_HDD", "name", "id", oVirtualHDD.GetVirtuals(1), Int32.Parse(dsAsset.Tables[0].Rows[0]["hddid"].ToString()), false, false, true); oDataPoint.LoadDropDown(ddlPlatformRam, intProfile, null, "", lblPlatformRam, fldPlatformRam, "WORKSTATION_VIRTUAL_RAM", "name", "id", oVirtualRam.GetVirtuals(1), Int32.Parse(dsAsset.Tables[0].Rows[0]["ramid"].ToString()), false, false, true); lblCPUs.Text = "1"; } else { Response.Redirect("/datapoint/asset/datapoint_asset_search.aspx"); } // Get Host oDataPoint.LoadTextBox(txtHostName, intProfile, btnHostName, "/datapoint/asset/server.aspx?t=name&q=" + oFunction.encryptQueryString(dsAsset.Tables[0].Rows[0]["hostname"].ToString()), lblHostName, fldHostName, "WORKSTATION_VIRTUAL_HOST", dsAsset.Tables[0].Rows[0]["hostname"].ToString(), "", false, false); // Account Information DataSet dsAccounts = oWorkstation.GetAccountsVirtual(intAsset); rptAccounts.DataSource = dsAccounts; rptAccounts.DataBind(); lblNone.Visible = (rptAccounts.Items.Count == 0); // Provioning History rptHistory.DataSource = SqlHelper.ExecuteDataset(dsnAsset, CommandType.Text, oDataPoint.AssetHistorySelect(intAsset)); rptHistory.DataBind(); lblHistory.Visible = (rptHistory.Items.Count == 0); oDataPoint.LoadPanel(panProvisioning, intProfile, fldProvisioning, "WORKSTATION_VIRTUAL_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) { 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"); } 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 + "');"); } else { panDenied.Visible = true; } }