protected void btnApprove_Click(Object Sender, EventArgs e) { if (Request.QueryString["rrid"] != null) { // Approved; Send to team lead for assignment int intResource = Int32.Parse(Request.QueryString["rrid"]); int intRequest = Int32.Parse(oResourceRequest.Get(intResource, "requestid")); int intService = Int32.Parse(oResourceRequest.Get(intResource, "serviceid")); int intNumber = Int32.Parse(oResourceRequest.Get(intResource, "number")); string strCVT = "CVT" + intRequest.ToString() + "-" + intService.ToString() + "-" + intNumber.ToString(); int ApprovalID = 0; DataSet dsApproval = oResourceRequest.GetApprovals(intRequest, intService, intNumber); foreach (DataRow drApproval in dsApproval.Tables[0].Rows) { if (Int32.Parse(drApproval["userid"].ToString()) == intProfile) { if (String.IsNullOrEmpty(drApproval["approved"].ToString()) == false || String.IsNullOrEmpty(drApproval["denied"].ToString()) == false) { ApprovalID = Int32.Parse(drApproval["id"].ToString()); break; } } } if (ApprovalID == 0) { oLog.AddEvent(intRequest.ToString(), strCVT, "Not already approved for user " + oUser.GetName(intProfile), LoggingType.Debug); oResourceRequest.UpdateStatusOverall(intResource, 2); if (oResourceRequest.Get(intResource, "platform_approval") == "0") { // Platform Approve oResourceRequest.ApprovePlatform(intResource, 1); SendEmail(intRequest, true, "PLATFORM", txtReason.Text); oLog.AddEvent(intRequest.ToString(), strCVT, "User " + oUser.GetName(intProfile) + " approved PLATFORM", LoggingType.Debug); } else if (oService.GetSelected(intRequest, intService, intNumber, "approved") == "0") { // Service Manager Approve oService.UpdateSelectedApprove(intRequest, intService, intNumber, 1, intProfile, DateTime.Now, ""); SendEmail(intRequest, true, "SERVICE MANAGER", txtReason.Text); oLog.AddEvent(intRequest.ToString(), strCVT, "User " + oUser.GetName(intProfile) + " approved SERVICE MANAGER", LoggingType.Debug); } else { oResourceRequest.UpdateApproval(intRequest, intService, intNumber, intProfile, txtReason.Text, DateTime.Now.ToString(), ""); SendEmail(intRequest, true, "3RD PARTY APPROVER", txtReason.Text); oLog.AddEvent(intRequest.ToString(), strCVT, "User " + oUser.GetName(intProfile) + " approved 3RD PARTY APPROVER", LoggingType.Debug); } int intItem = Int32.Parse(oResourceRequest.Get(intResource, "itemid")); if (oServiceRequest.NotifyApproval(intResource, intResourceRequestApprove, intEnvironment, "", dsnServiceEditor) == false) { oServiceRequest.NotifyTeamLead(intItem, intResource, intAssignPage, intViewPage, intEnvironment, "", dsnServiceEditor, dsnAsset, dsnIP, 0); } } else { oLog.AddEvent(intRequest.ToString(), strCVT, "Already approved for user " + oUser.GetName(intProfile), LoggingType.Debug); } } if (Request.QueryString["srid"] != null) { // Approved; Permit submission int intServiceSelectedID = Int32.Parse(Request.QueryString["srid"]); DataSet dsServiceSelected = oService.GetSelectedById(intServiceSelectedID); DataRow drServiceSelected = dsServiceSelected.Tables[0].Rows[0]; int intRequest = Int32.Parse(drServiceSelected["requestid"].ToString()); int intService = Int32.Parse(drServiceSelected["serviceid"].ToString()); int intItem = oService.GetItemId(intService); int intNumber = Int32.Parse(drServiceSelected["number"].ToString()); string strCVT = "CVT" + intRequest.ToString() + "-" + intService.ToString() + "-" + intNumber.ToString(); oService.UpdateSelectedApprove(intRequest, intService, intNumber, 1, intProfile, DateTime.Now, ""); SendEmail(intRequest, true, "SERVICE MANAGER", txtReason.Text); oLog.AddEvent(intRequest.ToString(), strCVT, "User " + oUser.GetName(intProfile) + " approved SERVICE MANAGER", LoggingType.Debug); // Kick off any automated processing... Workstations oWorkstation = new Workstations(intProfile, dsn); oWorkstation.ExecuteVMware(intRequest); } if (Request.QueryString["rid"] != null) { // Manager Approve int intRequest = Int32.Parse(Request.QueryString["rid"]); oServiceRequest.UpdateApproval(intRequest, 1); oResourceRequest.UpdateStatusRequest(intRequest, 2); SendEmail(intRequest, true, "MANAGER", txtReason.Text); DataSet dsForm = oRequestItem.GetForms(intRequest); foreach (DataRow drForm in dsForm.Tables[0].Rows) { int intService = 0; Int32.TryParse(drForm["serviceid"].ToString(), out intService); int intNumber = 0; Int32.TryParse(drForm["number"].ToString(), out intNumber); if (intService > 0 && intNumber > 0) { if (oServiceRequest.NotifyApproval(intRequest, intService, intNumber, intResourceRequestApprove, intEnvironment, "", dsnServiceEditor) == false) { // Send to Team Lead for assignment ds = oResourceRequest.GetUnAssigned(intRequest, 0); foreach (DataRow dr in ds.Tables[0].Rows) { int intItem = Int32.Parse(dr["itemid"].ToString()); oServiceRequest.NotifyTeamLead(intItem, Int32.Parse(dr["id"].ToString()), intAssignPage, intViewPage, intEnvironment, "", dsnServiceEditor, dsnAsset, dsnIP, 0); } } } } } Response.Redirect(oPage.GetFullLink(intPage) + "?action=finish"); }
protected void Page_Load(object sender, EventArgs e) { RequestItems oRequestItem = new RequestItems(intProfile, dsn); RequestFields oRequestField = new RequestFields(intProfile, dsn); ServiceRequests oServiceRequest = new ServiceRequests(intProfile, dsn); Services oService = new Services(intProfile, dsn); Log oLog = new Log(intProfile, dsn); Users oUser = new Users(intProfile, dsn); Functions oFunction = new Functions(intProfile, dsn, intEnvironment); Pages oPage = new Pages(intProfile, dsn); Requests oRequest = new Requests(intProfile, dsn); Variables oVariable = new Variables(intEnvironment); 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")) { string strResult = oService.GetName(intService) + " Completed"; string strError = oService.GetName(intService) + " Error"; // ********* BEGIN PROCESSING ************** string strCVT = "CVT" + intRequest.ToString() + "-" + intService.ToString() + "-" + intNumber.ToString(); Forecast oForecast = new Forecast(intProfile, dsn); ModelsProperties oModelsProperties = new ModelsProperties(intProfile, dsn); Types oType = new Types(intProfile, dsn); DataSet dsService = oForecast.GetAnswerService(intRequest); if (dsService.Tables[0].Rows.Count > 0) { int intAnswer = Int32.Parse(dsService.Tables[0].Rows[0]["id"].ToString()); int intModel = Int32.Parse(dsService.Tables[0].Rows[0]["modelid"].ToString()); int intType = oModelsProperties.GetType(intModel); string strExecute = oType.Get(intType, "forecast_execution_path"); DataSet dsSelected = oService.GetSelected(intRequest, intService, intNumber); if (oServiceRequest.NotifyApproval(intRequest, intService, intNumber, intResourceRequestApprove, intEnvironment, "", dsnServiceEditor) == false) { oLog.AddEvent(intRequest.ToString(), strCVT, "Service request has been fully approved", LoggingType.Debug); Workstations oWorkstation = new Workstations(intProfile, dsn); oWorkstation.ExecuteVMware(intRequest); oLog.AddEvent(intRequest.ToString(), strCVT, "Service request ExecuteVMware has completed.", LoggingType.Debug); } else { oLog.AddEvent(intRequest.ToString(), strCVT, "Service request has been sent for approval", LoggingType.Debug); } //if (strExecute != "") // btnStart.Attributes.Add("onclick", "return OpenWindow('FORECAST_EXECUTE','" + strExecute + "?id=" + intAnswer.ToString() + "');"); //else // btnStart.Attributes.Add("onclick", "alert('Execution has not been configured for asset type " + oType.Get(intType, "name") + "');return false;"); strDone += "<table border=\"0\"><tr><td><img src=\"/images/bigCheck.gif\" border=\"0\" align=\"absmiddle\"/></td><td class=\"biggerbold\">" + oService.GetName(intService) + " Submitted</td></tr></table>"; } // ******** END PROCESSING ************** oRequestItem.UpdateFormDone(intRequest, intItem, intNumber, 1); } } } }