private void LoadSecurity() { ModelsProperties oModelsProperties = new ModelsProperties(intProfile, dsn); Servers oServer = new Servers(intProfile, dsn); OnDemand oOnDemand = new OnDemand(0, dsn); int intAnswer = 0; int intModel = 0; DataSet dsSecurity = oOnDemandTasks.GetServerOther(intRequest, intService, intNumber); if (dsSecurity.Tables[0].Rows.Count > 0) { intAnswer = Int32.Parse(dsSecurity.Tables[0].Rows[0]["answerid"].ToString()); intModel = Int32.Parse(dsSecurity.Tables[0].Rows[0]["modelid"].ToString()); } //intAnswer = 2681; //intModel = 395; int intStep = (oModelsProperties.IsTypeVMware(intModel) ? 6 : 4); if (intAnswer > 0) { panSecurity.Visible = true; string strRequestResult = ""; // PRE (creation of groups) DataSet dsServers = oServer.GetAnswer(intAnswer); foreach (DataRow drServer in dsServers.Tables[0].Rows) { strRequestResult += "<tr>"; int intServer = Int32.Parse(drServer["id"].ToString()); strRequestResult += "<td valign=\"top\"><b>" + oServer.GetName(intServer, true) + ":</b></td>"; DataSet dsStep = oOnDemand.GetStepDoneServer(intServer, intStep); if (dsStep.Tables[0].Rows.Count > 0) { strRequestResult += "<td valign=\"top\">" + dsStep.Tables[0].Rows[0]["result"].ToString() + "</td>"; } strRequestResult += "</tr>"; } if (strRequestResult != "") { strRequestResult = "<table cellpadding=\"3\" cellspacing=\"2\" border=\"0\">" + strRequestResult + "</table>"; } lblSecurityPre.Text = strRequestResult; // POST (account generation and ties to groups) strRequestResult = ""; int intRequestAD = oForecast.GetRequestID(intAnswer, true); DataSet dsRequestResult = oRequest.GetResult(intRequestAD); foreach (DataRow drRequestResult in dsRequestResult.Tables[0].Rows) { strRequestResult += drRequestResult["result"].ToString(); } lblSecurityPost.Text = strRequestResult; } }
private void CheckResults(string strQuery) { DataSet ds = oServer.Get(strQuery, false); if (ds.Tables[0].Rows.Count == 1) { panSearch.Visible = true; lblServer.Text = strQuery.ToUpper(); int intAnswer = 0; int intProject = 0; if (ds.Tables[0].Rows[0]["answerid"].ToString() != "") { intAnswer = Int32.Parse(ds.Tables[0].Rows[0]["answerid"].ToString()); } if (ds.Tables[0].Rows[0]["projectid"].ToString() != "") { intProject = Int32.Parse(ds.Tables[0].Rows[0]["projectid"].ToString()); } if (intProject > 0 && intAnswer > 0) { ModelsProperties oModelsProperties = new ModelsProperties(intProfile, dsn); Types oType = new Types(intProfile, dsn); int intServer = Int32.Parse(ds.Tables[0].Rows[0]["id"].ToString()); int intModel = Int32.Parse(ds.Tables[0].Rows[0]["modelid"].ToString()); strResults += "<tr><td nowrap>Server Name Generation:</td><td width=\"100%\">Generated via On-Demand Server Auto-Provisioning</td></tr>"; strResults += "<tr><td nowrap>Project ID:</td><td width=\"100%\">" + intProject.ToString() + "</td></tr>"; strResults += "<tr><td nowrap>Project Name:</td><td width=\"100%\">" + ds.Tables[0].Rows[0]["name"].ToString() + "</td></tr>"; strResults += "<tr><td nowrap>Project Number:</td><td width=\"100%\">" + ds.Tables[0].Rows[0]["number"].ToString() + "</td></tr>"; int intLead = 0; if (ds.Tables[0].Rows[0]["lead"].ToString() != "") { intLead = Int32.Parse(ds.Tables[0].Rows[0]["lead"].ToString()); } strResults += "<tr><td nowrap>Project Lead:</td><td width=\"100%\">" + oUser.GetFullName(intLead) + " (" + oUser.GetName(intLead) + ")</td></tr>"; int intEngineer = 0; if (ds.Tables[0].Rows[0]["engineer"].ToString() != "") { intEngineer = Int32.Parse(ds.Tables[0].Rows[0]["engineer"].ToString()); } strResults += "<tr><td nowrap>Integration Engineer:</td><td width=\"100%\">" + oUser.GetFullName(intEngineer) + " (" + oUser.GetName(intEngineer) + ")</td></tr>"; strResults += "<tr><td nowrap>Implementor:</td><td width=\"100%\">" + GetImplementor(intProject, intAnswer) + "</td></tr>"; int intBackup = Int32.Parse(oForecast.GetAnswer(intAnswer, "backup")); DataSet dsBackup = oOnDemandTasks.GetServerBackup(intAnswer); if (dsBackup.Tables[0].Rows.Count > 0) { int intRequestB = Int32.Parse(dsBackup.Tables[0].Rows[0]["requestid"].ToString()); int intItemB = Int32.Parse(dsBackup.Tables[0].Rows[0]["itemid"].ToString()); int intNumberB = Int32.Parse(dsBackup.Tables[0].Rows[0]["number"].ToString()); DataSet dsResourceB = oResourceRequest.Get(intRequestB, intItemB, intNumberB); if (dsResourceB.Tables[0].Rows.Count > 0) { strResults += "<tr><td nowrap>Backup:</td>"; string strUsersB = ""; foreach (DataRow drResourceB in dsResourceB.Tables[0].Rows) { int intUserB = Int32.Parse(drResourceB["userid"].ToString()); if (strUsersB != "") { strUsersB += ", "; } strUsersB += oUser.GetFullName(intUserB) + " (" + (dsBackup.Tables[0].Rows[0]["chk1"].ToString() == "1" ? "Complete" : "Incomplete") + ")"; } strResults += "<td width=\"100%\">" + strUsersB + "</td></tr>"; } else { strResults += "<tr><td nowrap>Backup:</td><td width=\"100%\">Pending Assignment</td></tr>"; } } else { strResults += "<tr><td nowrap>Backup:</td><td width=\"100%\">Not Submitted (" + (intBackup == 1 ? "Client <b>DID</b> Request a Backup" : "Client <b>DID NOT</b> Request a Backup") + ")</td></tr>"; } if (oModelsProperties.IsTypeVMware(intModel) == false) { int intStorage = Int32.Parse(oForecast.GetAnswer(intAnswer, "storage")); DataSet dsStorageT = oOnDemandTasks.GetServerStorage(intAnswer, 0); if (dsStorageT.Tables[0].Rows.Count > 0) { int intRequestST = Int32.Parse(dsStorageT.Tables[0].Rows[0]["requestid"].ToString()); int intItemST = Int32.Parse(dsStorageT.Tables[0].Rows[0]["itemid"].ToString()); int intNumberST = Int32.Parse(dsStorageT.Tables[0].Rows[0]["number"].ToString()); DataSet dsResourceST = oResourceRequest.Get(intRequestST, intItemST, intNumberST); if (dsResourceST.Tables[0].Rows.Count > 0) { strResults += "<tr><td nowrap>Storage (TEST):</td>"; string strUsersST = ""; foreach (DataRow drResourceST in dsResourceST.Tables[0].Rows) { int intUserST = Int32.Parse(drResourceST["userid"].ToString()); if (strUsersST != "") { strUsersST += ", "; } strUsersST += oUser.GetFullName(intUserST) + " (" + (dsStorageT.Tables[0].Rows[0]["chk1"].ToString() == "1" ? "Complete" : "Incomplete") + ")"; } strResults += "<td width=\"100%\">" + strUsersST + "</td></tr>"; } else { strResults += "<tr><td nowrap>Storage (TEST):</td><td width=\"100%\">Pending Assignment</td></tr>"; } } else { strResults += "<tr><td nowrap>Storage (TEST):</td><td width=\"100%\">Not Submitted (" + (intStorage == 1 ? "Client <b>DID</b> Request TEST Storage" : "Client <b>DID NOT</b> Request TEST Storage") + ")</td></tr>"; } DataSet dsStorageP = oOnDemandTasks.GetServerStorage(intAnswer, 1); if (dsStorageP.Tables[0].Rows.Count > 0) { int intRequestSP = Int32.Parse(dsStorageP.Tables[0].Rows[0]["requestid"].ToString()); int intItemSP = Int32.Parse(dsStorageP.Tables[0].Rows[0]["itemid"].ToString()); int intNumberSP = Int32.Parse(dsStorageP.Tables[0].Rows[0]["number"].ToString()); DataSet dsResourceSP = oResourceRequest.Get(intRequestSP, intItemSP, intNumberSP); if (dsResourceSP.Tables[0].Rows.Count > 0) { strResults += "<tr><td nowrap>Storage (PROD):</td>"; string strUsersSP = ""; foreach (DataRow drResourceSP in dsResourceSP.Tables[0].Rows) { int intUserSP = Int32.Parse(drResourceSP["userid"].ToString()); if (strUsersSP != "") { strUsersSP += ", "; } strUsersSP += oUser.GetFullName(intUserSP) + " (" + (dsStorageP.Tables[0].Rows[0]["chk1"].ToString() == "1" ? "Complete" : "Incomplete") + ")"; } strResults += "<td width=\"100%\">" + strUsersSP + "</td></tr>"; } else { strResults += "<tr><td nowrap>Storage (PROD):</td><td width=\"100%\">Pending Assignment</td></tr>"; } } else { strResults += "<tr><td nowrap>Storage (PROD):</td><td width=\"100%\">Not Submitted (" + (intStorage == 1 ? "Client <b>DID</b> Request PROD Storage" : "Client <b>DID NOT</b> Request PROD Storage") + ")</td></tr>"; } } else { strResults += "<tr><td nowrap>Storage (TEST):</td><td width=\"100%\">VMware Does Not Require Storage Configuration</td></tr>"; strResults += "<tr><td nowrap>Storage (PROD):</td><td width=\"100%\">VMware Does Not Require Storage Configuration</td></tr>"; } strResults += "<tr><td nowrap>Model:</td><td width=\"100%\">" + oModelsProperties.Get(intModel, "name") + "</td></tr>"; strResults += "<tr><td nowrap>NickName:</td><td width=\"100%\">" + oForecast.GetAnswer(intAnswer, "name") + "</td></tr>"; strResults += "<tr><td nowrap>Current State:</td><td width=\"100%\">" + (ds.Tables[0].Rows[0]["step"].ToString() == "0" ? "Awaiting Execution" : (ds.Tables[0].Rows[0]["step"].ToString() == "999" ? "Completed Build" : "Building...")) + "</td></tr>"; strResults += "<tr><td nowrap colspan=\"2\"><img src=\"/images/icons/pdf.gif\" border=\"0\" align=\"absmiddle\"/> <a href=\"/frame/ondemand/pdf_tsm.aspx?id=" + intAnswer.ToString() + "\">Click here to view the TSM Registration Form</a></td></tr>"; strResults += "<tr><td nowrap colspan=\"2\"><img src=\"/images/icons/pdf.gif\" border=\"0\" align=\"absmiddle\"/> <a href=\"/frame/ondemand/pdf_san.aspx?id=" + intAnswer.ToString() + "\">Click here to view the SAN Registration Form (TEST)</a></td></tr>"; strResults += "<tr><td nowrap colspan=\"2\"><img src=\"/images/icons/pdf.gif\" border=\"0\" align=\"absmiddle\"/> <a href=\"/frame/ondemand/pdf_san.aspx?id=" + intAnswer.ToString() + "&prod=true\">Click here to view the SAN Registration Form (PROD)</a></td></tr>"; strResults += "<tr><td nowrap colspan=\"2\"><img src=\"/images/icons/html.gif\" border=\"0\" align=\"absmiddle\"/> <a href=\"/frame/ondemand/pdf_sc.aspx?id=" + intServer.ToString() + "\">Click here to view the Service Center Request</a></td></tr>"; strResults += "<tr><td nowrap colspan=\"2\"><img src=\"/images/icons/pdf.gif\" border=\"0\" align=\"absmiddle\"/> <a href=\"/frame/ondemand/pdf_birth.aspx?id=" + intAnswer.ToString() + "\">Click here to view the Birth Certificate</a></td></tr>"; strResults += "<tr><td nowrap colspan=\"2\"><img src=\"/images/file.gif\" border=\"0\" align=\"absmiddle\"/> <a href=\"javascript:void(0);\" onclick=\"OpenWindow('FORECAST_EQUIPMENT','?id=" + intAnswer.ToString() + "');\">Click here to view the design</a></td></tr>"; strResults += "<tr><td nowrap colspan=\"2\"><img src=\"/images/file.gif\" border=\"0\" align=\"absmiddle\"/> <a href=\"" + oPage.GetFullLink(intDesignBuilder) + "?id=" + oForecast.GetAnswer(intAnswer, "forecastid") + "&highlight=" + intAnswer.ToString() + "\" target=\"_blank\">Click here to view the OVERALL design</a></td></tr>"; int intType = oModelsProperties.GetType(intModel); string strExecute = oType.Get(intType, "forecast_execution_path"); if (strExecute != "") { strResults += "<tr><td nowrap colspan=\"2\"><img src=\"/images/user.gif\" border=\"0\" align=\"absmiddle\"/> <a href=\"javascript:void(0);\" onclick=\"OpenWindow('NEW_WINDOW','" + strExecute + "?id=" + intAnswer.ToString() + "&sid=2&view=true');\">Click here to view the application configuration</a></td></tr>"; if (oForecast.IsOSDistributed(intAnswer) == true) { if (oForecast.IsHACluster(intAnswer) == true) { strResults += "<tr><td nowrap colspan=\"2\"><img src=\"/images/config.gif\" border=\"0\" align=\"absmiddle\"/> <a href=\"javascript:void(0);\" onclick=\"OpenWindow('NEW_WINDOW','" + strExecute + "?id=" + intAnswer.ToString() + "&sid=3&view=true');\">Click here to view the device configuration</a></td></tr>"; } else { strResults += "<tr><td nowrap colspan=\"2\"><img src=\"/images/config.gif\" border=\"0\" align=\"absmiddle\"/> <a href=\"javascript:void(0);\" onclick=\"OpenWindow('NEW_WINDOW','" + strExecute + "?id=" + intAnswer.ToString() + "&sid=3&view=true');\">Click here to view the device configuration</a></td></tr>"; } strResults += "<tr><td nowrap colspan=\"2\"><img src=\"/images/calendar.gif\" border=\"0\" align=\"absmiddle\"/> <a href=\"javascript:void(0);\" onclick=\"OpenWindow('NEW_WINDOW','" + strExecute + "?id=" + intAnswer.ToString() + "&sid=4&view=true');\">Click here to view the production go live date</a></td></tr>"; } else { if (oForecast.IsHACluster(intAnswer) == true) { strResults += "<tr><td nowrap colspan=\"2\"><img src=\"/images/config.gif\" border=\"0\" align=\"absmiddle\"/> <a href=\"javascript:void(0);\" onclick=\"OpenWindow('NEW_WINDOW','" + strExecute + "?id=" + intAnswer.ToString() + "&sid=3&view=true');\">Click here to view the device configuration</a></td></tr>"; } else { strResults += "<tr><td nowrap colspan=\"2\"><img src=\"/images/config.gif\" border=\"0\" align=\"absmiddle\"/> <a href=\"javascript:void(0);\" onclick=\"OpenWindow('NEW_WINDOW','" + strExecute + "?id=" + intAnswer.ToString() + "&sid=3&view=true');\">Click here to view the device configuration</a></td></tr>"; } strResults += "<tr><td nowrap colspan=\"2\"><img src=\"/images/calendar.gif\" border=\"0\" align=\"absmiddle\"/> <a href=\"javascript:void(0);\" onclick=\"OpenWindow('NEW_WINDOW','" + strExecute + "?id=" + intAnswer.ToString() + "&sid=4&view=true');\">Click here to view the production go live date</a></td></tr>"; } strResults += "<tr><td nowrap colspan=\"2\"><img src=\"/images/check.gif\" border=\"0\" align=\"absmiddle\"/> <a href=\"javascript:void(0);\" onclick=\"OpenWindow('FORECAST_EXECUTE','" + strExecute + "?id=" + intAnswer.ToString() + "');\">Click here to view the execution</a></td></tr>"; } strResults += "<tr><td nowrap colspan=\"2\" class=\"header\"><b>Asset History:</b></td></tr>"; string strAssets = ""; DataSet dsAssets = oServer.GetAssets(intServer); foreach (DataRow drAsset in dsAssets.Tables[0].Rows) { strAssets += "<tr><td>" + drAsset["serial"].ToString() + "</td><td>" + drAsset["asset"].ToString() + "</td><td>" + drAsset["model"].ToString() + "</td><td>" + drAsset["class"].ToString() + "</td><td>" + drAsset["environment"].ToString() + "</td><td>" + drAsset["datestamp"].ToString() + "</td></tr>"; } if (strAssets == "") { strAssets += "<tr><td colspan=\"6\"><img src=\"/images/alert.gif\" border=\"0\" align=\"absmiddle\"/> There are no assets</td></tr>"; } strAssets = "<tr class=\"bold\"><td>Serial</td><td>Asset</td><td>Model</td><td>Class</td><td>Environment</td><td>DateStamp</td></tr>" + strAssets; strAssets = "<table cellpadding=\"3\" cellspacing=\"2\" border=\"0\">" + strAssets + "</table>"; strResults += "<tr><td nowrap colspan=\"2\">" + strAssets + "</td></tr>"; } else { strResults += "<tr><td nowrap>Server Name Generation:</td><td width=\"100%\">Generated via Custom Functions, Server Names</td></tr>"; int intUser = Int32.Parse(ds.Tables[0].Rows[0]["servernameuserid"].ToString()); strResults += "<tr><td nowrap>Implementor:</td><td width=\"100%\">" + oUser.GetFullName(intUser) + " (" + oUser.GetName(intUser) + ")</td></tr>"; strResults += "<tr><td nowrap>Description:</td><td width=\"100%\">" + ds.Tables[0].Rows[0]["description"].ToString() + "</td></tr>"; } } else { panMultiple.Visible = true; foreach (DataRow dr in ds.Tables[0].Rows) { strMultiple += "<tr onmouseover=\"CellRowOver(this);\" onmouseout=\"CellRowOut(this);\" onclick=\"window.navigate('" + oPage.GetFullLink(intPage) + "?name=" + oFunctions.encryptQueryString(dr["servername"].ToString()) + "');\">"; int intAnswer = 0; int intProject = 0; if (dr["answerid"].ToString() != "") { intAnswer = Int32.Parse(dr["answerid"].ToString()); } if (dr["projectid"].ToString() != "") { intProject = Int32.Parse(dr["projectid"].ToString()); } strMultiple += "<td>" + dr["servername"].ToString() + "</td>"; if (intAnswer == 0 && intProject == 0) { int intImplementor = Int32.Parse(dr["servernameuserid"].ToString()); strMultiple += "<td>" + oUser.GetFullName(intImplementor) + " (" + oUser.GetName(intImplementor) + ")" + "</td>"; strMultiple += "<td>Custom Function</td>"; } else if (intAnswer > 0 && intProject > 0) { strMultiple += "<td>" + GetImplementor(intProject, intAnswer) + "</td>"; strMultiple += "<td>Design Builder Execution</td>"; } else { strMultiple += "<td>*** ERROR ***</td>"; strMultiple += "<td>???</td>"; } strMultiple += "<td>" + dr["name"].ToString() + "</td>"; strMultiple += "<td>" + dr["number"].ToString() + "</td>"; strMultiple += "</tr>"; } } }
protected void Page_Load(object sender, EventArgs e) { intProfile = Int32.Parse(Request.Cookies["profileid"].Value); RequestItems oRequestItem = new RequestItems(intProfile, dsn); RequestFields oRequestField = new RequestFields(intProfile, dsn); ServiceRequests oServiceRequest = new ServiceRequests(intProfile, dsn); Services oService = new Services(intProfile, dsn); oFunction = new Functions(intProfile, dsn, intEnvironment); oUser = new Users(intProfile, dsn); oRequest = new Requests(intProfile, dsn); int intRequest = Int32.Parse(Request.QueryString["rid"]); string strStatus = oServiceRequest.Get(intRequest, "checkout"); DataSet dsItems = oRequestItem.GetForms(intRequest); int intItem = 0; int intService = 0; int intNumber = 0; if (dsItems.Tables[0].Rows.Count > 0) { bool boolBreak = false; foreach (DataRow drItem in dsItems.Tables[0].Rows) { if (boolBreak == true) { break; } if (drItem["done"].ToString() == "0") { intItem = Int32.Parse(drItem["itemid"].ToString()); intService = Int32.Parse(drItem["serviceid"].ToString()); intNumber = Int32.Parse(drItem["number"].ToString()); boolBreak = true; } if (intItem > 0 && (strStatus == "1" || strStatus == "2")) { bool boolSuccess = true; //string strResult = oService.GetName(intService) + " Completed"; string strResult = ""; string strError = oService.GetName(intService) + " Error"; // ********* BEGIN PROCESSING ************** Servers oServer = new Servers(intProfile, dsn); OnDemand oOnDemand = new OnDemand(intProfile, dsn); Audit oAudit = new Audit(intProfile, dsn); ServerName oServerName = new ServerName(intProfile, dsn); ModelsProperties oModelsProperties = new ModelsProperties(intProfile, dsn); Asset oAsset = new Asset(intProfile, dsnAsset, dsn); DataSet dsRebuild = oServer.GetRebuild(intRequest, intService, intNumber); bool found = false; foreach (DataRow drRebuild in dsRebuild.Tables[0].Rows) { found = true; int intServer = Int32.Parse(drRebuild["serverid"].ToString()); string strName = oServer.GetName(intServer, true); int intModel = 0; int intRebuildStep = 0; // Load General Information int intAsset = 0; DataSet dsAssets = oServer.GetAssets(intServer); foreach (DataRow drAsset in dsAssets.Tables[0].Rows) { if (drAsset["latest"].ToString() == "1") { intAsset = Int32.Parse(drAsset["assetid"].ToString()); break; } } if (intAsset > 0) { // Asset Information intModel = Int32.Parse(oAsset.Get(intAsset, "modelid")); } if (oModelsProperties.IsTypeVMware(intModel) == false) { intRebuildStep = 6; } else { intRebuildStep = 7; } oServer.UpdateStep(intServer, intRebuildStep); // Redo step...delete current step and update the other step oOnDemand.UpdateStepDoneServerRedo(intServer, intRebuildStep); oServer.DeleteSwitchports(intServer); // Reconfigure switchports oServer.UpdateRebuilding(intServer, 1); // Delete Audits oAudit.DeleteServer(intServer, 0); oAudit.DeleteServer(intServer, 1); // Set installs back DataSet dsInstalls = oServerName.GetComponentDetailSelected(intServer, 0); foreach (DataRow drInstall in dsInstalls.Tables[0].Rows) { oServerName.UpdateComponentDetailSelected(intServer, Int32.Parse(drInstall["detailid"].ToString()), -2); } int intStepSkipStart = 0; int intStepSkipGoto = 0; oServer.UpdateStepSkip(intServer, intStepSkipStart, intStepSkipGoto); strResult += "<p>The server " + strName + " was successfully queued for rebuild</p>"; strError = ""; break; } if (found == false) { strError = "<p>There was a problem configuring the server for rebuild ~ Request not found.</p>"; } if (strResult == "") { boolSuccess = false; } // ******** END PROCESSING ************** if (oService.Get(intService, "automate") == "1" && boolSuccess == true) { strDone += "<table border=\"0\"><tr><td valign=\"top\"><img src=\"/images/ico_check.gif\" border=\"0\" align=\"absmiddle\"/></td><td valign=\"top\" class=\"biggerbold\">" + strResult + "</td></tr></table>"; } else { if (boolSuccess == false) { strDone += "<table border=\"0\"><tr><td valign=\"top\"><img src=\"/images/ico_error.gif\" border=\"0\" align=\"absmiddle\"/></td><td valign=\"top\" class=\"biggerbold\">" + strError + "</td></tr></table>"; } else { strDone += "<table border=\"0\"><tr><td valign=\"top\"><img src=\"/images/ico_check.gif\" border=\"0\" align=\"absmiddle\"/></td><td valign=\"top\" class=\"biggerbold\">" + oService.GetName(intService) + " Submitted</td></tr></table>"; } } oRequestItem.UpdateFormDone(intRequest, intItem, intNumber, 1, 1); } } } }
protected void Page_Load(object sender, EventArgs e) { intProfile = Int32.Parse(Request.Cookies["profileid"].Value); RequestItems oRequestItem = new RequestItems(intProfile, dsn); RequestFields oRequestField = new RequestFields(intProfile, dsn); ServiceRequests oServiceRequest = new ServiceRequests(intProfile, dsn); Services oService = new Services(intProfile, dsn); oFunction = new Functions(intProfile, dsn, intEnvironment); oUser = new Users(intProfile, dsn); oRequest = new Requests(intProfile, dsn); int intRequest = Int32.Parse(Request.QueryString["rid"]); string strStatus = oServiceRequest.Get(intRequest, "checkout"); DataSet dsItems = oRequestItem.GetForms(intRequest); int intItem = 0; int intService = 0; int intNumber = 0; if (dsItems.Tables[0].Rows.Count > 0) { bool boolBreak = false; foreach (DataRow drItem in dsItems.Tables[0].Rows) { if (boolBreak == true) { break; } if (drItem["done"].ToString() == "0") { intItem = Int32.Parse(drItem["itemid"].ToString()); intService = Int32.Parse(drItem["serviceid"].ToString()); intNumber = Int32.Parse(drItem["number"].ToString()); boolBreak = true; } if (intItem > 0 && (strStatus == "1" || strStatus == "2")) { bool boolSuccess = true; string strResult = oService.GetName(intService) + " Completed"; string strError = oService.GetName(intService) + " Error"; // ********* BEGIN PROCESSING ************** bool boolIsServerVMWare = false; bool boolIsNotManual = false; int intServer = 0; int intModel = 0; Customized oCustomized = new Customized(intProfile, dsn); DataSet dsDecomServer = oCustomized.GetDecommissionServer(intRequest, intItem, intNumber); if (dsDecomServer.Tables[0].Rows.Count > 0) { intServer = Int32.Parse(dsDecomServer.Tables[0].Rows[0]["serverid"].ToString()); DateTime datPower = DateTime.Parse(dsDecomServer.Tables[0].Rows[0]["poweroff"].ToString()); string strPowerNew = dsDecomServer.Tables[0].Rows[0]["poweroff_new"].ToString(); string strName = dsDecomServer.Tables[0].Rows[0]["servername"].ToString(); Asset oAsset = new Asset(intProfile, dsnAsset); Servers oServers = new Servers(intProfile, dsn); DataSet dsAssets = oServers.GetAssets(intServer); if (intServer > 0) { DataSet dsServer = oServers.Get(intServer); ModelsProperties oModelsProperties = new ModelsProperties(intProfile, dsn); if (dsServer.Tables[0].Rows[0]["modelid"] != DBNull.Value) { intModel = Int32.Parse(dsServer.Tables[0].Rows[0]["modelid"].ToString()); } if (intModel > 0 && oModelsProperties.IsTypeVMware(intModel) == true) { boolIsServerVMWare = true; } boolIsNotManual = true; } // VMWARE if (boolIsNotManual == true) { bool boolUnique = true; foreach (DataRow drAsset in dsAssets.Tables[0].Rows) { if (drAsset["latest"].ToString() == "1" || drAsset["dr"].ToString() == "1") { int intAsset = Int32.Parse(drAsset["assetid"].ToString()); boolUnique = oAsset.AddDecommission(intRequest, intItem, intNumber, intAsset, intProfile, dsDecomServer.Tables[0].Rows[0]["reason"].ToString(), datPower, strName + (drAsset["dr"].ToString() == "1" ? "-DR" : ""), (drAsset["dr"].ToString() == "1" ? 1 : 0), strPowerNew); if (boolUnique == false) { break; } } } if (boolUnique == true || strPowerNew != "") { oAsset.UpdateDecommission(intRequest, intItem, intNumber, 1); strResult += "<p>The server " + strName + " was successfully queued for decommission on " + (strPowerNew != "" ? strPowerNew : datPower.ToShortDateString()) + "</p>"; strError = ""; } else { strError = "<p>The server " + strName + " has already been queued for decommission</p>"; } //Send service center notification //"Assignment: Complete and Close" # region "Send Service Center Notification" ResourceRequest oResourceRequest = new ResourceRequest(intProfile, dsn); DataSet dsRR = oResourceRequest.GetResourceRequest(intRequest, intItem, intNumber); int intRRId = 0; if (dsRR.Tables[0].Rows.Count > 0) { intRRId = Int32.Parse(dsRR.Tables[0].Rows[0]["id"].ToString()); } //int intServerDecommServiceID = Int32.Parse(ConfigurationManager.AppSettings["SERVICEID_SERVER_DECOMMISSION"]); //if (intService == intServerDecommServiceID) //{ // SendServiceCenterNotification(intRequest, intItem, intService, intNumber, 0); //} #endregion } else { // MANUAL (non-automated) double dblHours = 0.00; int intDevices = 1; Field oField = new Field(intProfile, dsn); strResult += "<p>The server decommission request was submitted for " + strName + ".</p>"; strError = ""; string strTable = oField.GetTableName2(intService); if (strTable != "") { DataSet ds = oField.GetTableServiceRequest(strTable, intRequest.ToString(), intItem.ToString(), intNumber.ToString()); if (ds.Tables[0].Columns.Contains("hours") == true) { foreach (DataRow dr in ds.Tables[0].Rows) { dblHours += double.Parse(dr["hours"].ToString()); } } if (ds.Tables[0].Columns.Contains("devices") == true) { foreach (DataRow dr in ds.Tables[0].Rows) { intDevices += Int32.Parse(dr["devices"].ToString()); } } } if (oService.Get(intService, "quantity_is_device") == "1") { DataSet dsTemp = oService.GetSelected(intRequest, intService); if (dsTemp.Tables[0].Rows.Count > 0) { intDevices = Int32.Parse(dsTemp.Tables[0].Rows[0]["quantity"].ToString()); } } int intResource = oServiceRequest.AddRequest(intRequest, intItem, intService, intDevices, dblHours, 2, intNumber, dsnServiceEditor); if (oServiceRequest.NotifyApproval(intResource, intResourceRequestApprove, intEnvironment, "", dsnServiceEditor) == false) { oServiceRequest.NotifyTeamLead(intItem, intResource, intAssignPage, intViewPage, intEnvironment, "", dsnServiceEditor, dsnAsset, dsnIP, 0); } oRequest.AddResult(intRequest, intItem, intNumber, "Server Decommission", strError, strResult, intEnvironment, (oService.Get(intService, "notify_client") == "1"), oUser.GetName(intProfile)); } } else { strResult = ""; dsDecomServer = oCustomized.GetDecommissionServerDeleted(intRequest, intItem, intNumber); string strName = ""; if (dsDecomServer.Tables[0].Rows.Count > 0) { strName = dsDecomServer.Tables[0].Rows[0]["servername"].ToString(); } if (strName == "") { strError = "<p>One or more of the servers you attempted to decommission have already been queued for decommission</p>"; } else { strError = "<p>The server " + strName + " has already been queued for decommission</p>"; } oRequestItem.DeleteForms(intRequest, intService, intNumber); } if (strResult == "") { boolSuccess = false; } // ******** END PROCESSING ************** if (oService.Get(intService, "automate") == "1" && boolSuccess == true) { strDone += "<table border=\"0\"><tr><td valign=\"top\"><img src=\"/images/ico_check.gif\" border=\"0\" align=\"absmiddle\"/></td><td valign=\"top\" class=\"biggerbold\">" + strResult + "</td></tr></table>"; } else { if (boolSuccess == false) { strDone += "<table border=\"0\"><tr><td valign=\"top\"><img src=\"/images/ico_error.gif\" border=\"0\" align=\"absmiddle\"/></td><td valign=\"top\" class=\"biggerbold\">" + strError + "</td></tr></table>"; } else { strDone += "<table border=\"0\"><tr><td valign=\"top\"><img src=\"/images/ico_check.gif\" border=\"0\" align=\"absmiddle\"/></td><td valign=\"top\" class=\"biggerbold\">" + oService.GetName(intService) + " Submitted</td></tr></table>"; } } oRequestItem.UpdateFormDone(intRequest, intItem, intNumber, 1, (boolIsNotManual?1:0)); } } }
protected void Page_Load(object sender, EventArgs e) { intProfile = Int32.Parse(Request.Cookies["profileid"].Value); RequestItems oRequestItem = new RequestItems(intProfile, dsn); RequestFields oRequestField = new RequestFields(intProfile, dsn); ServiceRequests oServiceRequest = new ServiceRequests(intProfile, dsn); Services oService = new Services(intProfile, dsn); int intRequest = Int32.Parse(Request.QueryString["rid"]); string strStatus = oServiceRequest.Get(intRequest, "checkout"); DataSet dsItems = oRequestItem.GetForms(intRequest); int intItem = 0; int intService = 0; int intNumber = 0; if (dsItems.Tables[0].Rows.Count > 0) { bool boolBreak = false; foreach (DataRow drItem in dsItems.Tables[0].Rows) { if (boolBreak == true) { break; } if (drItem["done"].ToString() == "0") { intItem = Int32.Parse(drItem["itemid"].ToString()); intService = Int32.Parse(drItem["serviceid"].ToString()); intNumber = Int32.Parse(drItem["number"].ToString()); boolBreak = true; } if (intItem > 0 && (strStatus == "1" || strStatus == "2")) { bool boolSuccess = true; string strResult = oService.GetName(intService) + " Completed"; string strError = oService.GetName(intService) + " Error"; // ********* BEGIN PROCESSING ************** Requests oRequest = new Requests(intProfile, dsn); Users oUser = new Users(intProfile, dsn); Workstations oWorkstation = new Workstations(intProfile, dsn); Workstations oRemote = new Workstations(intProfile, dsnRemote); Asset oAsset = new Asset(intProfile, dsnAsset); Domains oDomain = new Domains(intProfile, dsn); ModelsProperties oModelsProperties = new ModelsProperties(intProfile, dsn); DataSet ds = oWorkstation.GetVirtualDecommissions(intRequest, intItem, intNumber); strResult = ""; foreach (DataRow dr in ds.Tables[0].Rows) { int intID = Int32.Parse(dr["id"].ToString()); int intName = Int32.Parse(dr["nameid"].ToString()); string strName = oWorkstation.GetName(intName); int intAsset = Int32.Parse(dr["assetid"].ToString()); int intModel = Int32.Parse(dr["modelid"].ToString()); if (oModelsProperties.IsTypeVMware(intModel) == true) { // VMware Workstation bool boolUnique = oAsset.AddDecommission(intRequest, intItem, intNumber, intAsset, intProfile, "", DateTime.Now, strName, 0, ""); if (boolUnique == true) { oAsset.UpdateDecommission(intRequest, intItem, intNumber, 1); VMWare oVMWare = new VMWare(intProfile, dsn); DataSet dsGuest = oVMWare.GetGuest(strName); string strCluster = "???"; if (dsGuest.Tables[0].Rows.Count > 0 && dsGuest.Tables[0].Rows[0]["hostid"].ToString() != "") { int intHost = Int32.Parse(dsGuest.Tables[0].Rows[0]["hostid"].ToString()); int intCluster = Int32.Parse(oVMWare.GetHost(intHost, "clusterid")); strCluster = oVMWare.GetCluster(intCluster, "name"); } strResult += "<p>The VMware workstation " + strName + " is queued to be decommissioned from the cluster " + strCluster + ".</p>"; } else { strResult += "<p>The VMware workstation " + strName + " is ALREADY queued to be decommissioned</p>"; } } else { // Microsoft Virtual Workstation int intHost = Int32.Parse(dr["virtualhostid"].ToString()); int intOS = Int32.Parse(dr["osid"].ToString()); string strHost = oAsset.GetServerOrBlade(intHost, "name"); string strVirtualDir = ""; DataSet dsOS = oAsset.GetVirtualHostOs(intHost); foreach (DataRow drOS in dsOS.Tables[0].Rows) { if (Int32.Parse(drOS["osid"].ToString()) == intOS) { strVirtualDir = drOS["virtualdir"].ToString(); break; } } int intDomain = Int32.Parse(dr["domainid"].ToString()); int intEnv = Int32.Parse(oDomain.Get(intDomain, "environment")); oRemote.AddRemoteVirtualDecom(intEnv, strHost, strVirtualDir, strName); // Clean up database oWorkstation.DeleteVirtual(intID); oWorkstation.UpdateName(intName, 1); oAsset.DeleteGuest(intAsset); oAsset.AddStatus(intAsset, "", (int)AssetStatus.Decommissioned, intProfile, DateTime.Now); strResult += "<p>The virtual workstation " + strName + " was successfully decommissioned from the host " + strHost + ".</p>"; } strError = ""; } oRequest.AddResult(intRequest, intItem, intNumber, "Virtual Workstation Decommission", strError, strResult, intEnvironment, (oService.Get(intService, "notify_client") == "1"), oUser.GetName(intProfile)); if (strResult == "") { boolSuccess = false; } // ******** END PROCESSING ************** if (oService.Get(intService, "automate") == "1" && boolSuccess == true) { strDone += "<table border=\"0\"><tr><td valign=\"top\"><img src=\"/images/ico_check.gif\" border=\"0\" align=\"absmiddle\"/></td><td valign=\"top\" class=\"biggerbold\">" + strResult + "</td></tr></table>"; } else { if (boolSuccess == false) { strDone += "<table border=\"0\"><tr><td valign=\"top\"><img src=\"/images/ico_error.gif\" border=\"0\" align=\"absmiddle\"/></td><td valign=\"top\" class=\"biggerbold\">" + strError + "</td></tr></table>"; } else { strDone += "<table border=\"0\"><tr><td valign=\"top\"><img src=\"/images/ico_check.gif\" border=\"0\" align=\"absmiddle\"/></td><td valign=\"top\" class=\"biggerbold\">" + oService.GetName(intService) + " Submitted</td></tr></table>"; } } oRequestItem.UpdateFormDone(intRequest, intItem, intNumber, 1, 1); } } } }