public bool NotifyApproval(int _requestid, int intService, int intNumber, int _resourcerequestapprove, int _environment, string _cc, string _dsn_service_editor) { bool boolNotify = false; RequestItems oRequestItem = new RequestItems(user, dsn); ResourceRequest oResourceRequest = new ResourceRequest(user, dsn); Applications oApplication = new Applications(user, dsn); Users oUser = new Users(user, dsn); Functions oFunction = new Functions(user, dsn, _environment); Requests oRequest = new Requests(user, dsn); Pages oPage = new Pages(user, dsn); Variables oVariable = new Variables(_environment); Platforms oPlatform = new Platforms(user, dsn); Services oService = new Services(user, dsn); Log oLog = new Log(user, dsn); string strEMailIdsBCC = oFunction.GetGetEmailAlertsEmailIds("EMAILGRP_REQUEST_STATUS"); int intPlatform = 0; int intManager = 0; int intApp = 0; int intItem = oService.GetItemId(intService); int RRID = 0; DataSet dsResource = oResourceRequest.GetAllService(_requestid, intService, intNumber); if (dsResource.Tables[0].Rows.Count > 0) { Int32.TryParse(dsResource.Tables[0].Rows[0]["RRID"].ToString(), out RRID); } string strCVT = "CVT" + _requestid.ToString() + "-" + intService.ToString() + "-" + intNumber.ToString(); if (intItem > 0) { intApp = oRequestItem.GetItemApplication(intItem); intPlatform = Int32.Parse(oApplication.Get(intApp, "platform_approve")); } if (intService > 0) { Int32.TryParse(oService.Get(intService, "manager_approval"), out intManager); } DataSet dsSelected = oService.GetSelected(_requestid, intService, intNumber); int intSelectedID = 0; int intApproved = 0; if (dsSelected.Tables[0].Rows.Count > 0) { Int32.TryParse(dsSelected.Tables[0].Rows[0]["approved"].ToString(), out intApproved); Int32.TryParse(dsSelected.Tables[0].Rows[0]["id"].ToString(), out intSelectedID); } else { intApproved = 1; // since not the first one submitted, automatically approve from a service owner perspective. } // First, check for the requestor's manager Approval if (intManager == 1 && Get(_requestid, "manager_approval") == "0") { // Send to Manager for approval intPlatform = 0; boolNotify = true; int intUser = oUser.GetManager(oRequest.GetUser(_requestid), true); oLog.AddEvent(_requestid.ToString(), strCVT, "Sending to manager for approval - " + oUser.GetFullNameWithLanID(intUser), LoggingType.Debug); if (intUser == 0) { intPlatform = 1; } else { string strDefault = oUser.GetApplicationUrl(intUser, _resourcerequestapprove); if (strDefault == "") { oFunction.SendEmail("Request #CVT" + _requestid.ToString() + " APPROVAL", oUser.GetName(intUser), _cc, strEMailIdsBCC, "Request #CVT" + _requestid.ToString() + " APPROVAL", "<p><b>A service request requires your approval; you are required to approve or deny this request.</b></p>", true, false); } else { oFunction.SendEmail("Request #CVT" + _requestid.ToString() + " APPROVAL", oUser.GetName(intUser), _cc, strEMailIdsBCC, "Request #CVT" + _requestid.ToString() + " APPROVAL", "<p><b>A service request requires your approval; you are required to approve or deny this request.</b></p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(_resourcerequestapprove) + "?rid=" + _requestid.ToString() + "&approve=true\" target=\"_blank\">Click here to review this request.</a></p>", true, false); } } } else { // Next, check the service approval DataSet dsApprovers = oService.GetUser(intService, -10); //int intApproval = ((oService.Get(intService, "approval") == "1" && dsApprovers.Tables[0].Rows.Count > 0) ? 0 : 1); int intApproval = ((oService.Get(intService, "approval") == "1" && dsApprovers.Tables[0].Rows.Count > 0) ? 1 : 0); if (intApproval == 1 && intApproved == 0) { // Send to Approvers for approval boolNotify = true; // Send to Approvers for approval foreach (DataRow drApprover in dsApprovers.Tables[0].Rows) { int intUser = Int32.Parse(drApprover["userid"].ToString()); oLog.AddEvent(_requestid.ToString(), strCVT, "Sending to service approver for approval - " + oUser.GetFullNameWithLanID(intUser), LoggingType.Debug); string strDefault = oUser.GetApplicationUrl(intUser, _resourcerequestapprove); if (strDefault == "") { oFunction.SendEmail("Service Request APPROVAL", oUser.GetName(intUser), _cc, strEMailIdsBCC, "Service Request APPROVAL", "<p><b>A service request requires your approval; you are required to approve or deny this request.</b></p>", true, false); } else { oFunction.SendEmail("Service Request APPROVAL", oUser.GetName(intUser), _cc, strEMailIdsBCC, "Service Request APPROVAL", "<p><b>A service request requires your approval; you are required to approve or deny this request.</b></p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(_resourcerequestapprove) + "?srid=" + intSelectedID.ToString() + "\" target=\"_blank\">Click here to review this request.</a></p>", true, false); } } } else { // Update that the service is approved. if (intSelectedID > 0 && intApproved != 1) { oService.UpdateSelectedApprove(_requestid, intService, intNumber, 1, -999, DateTime.Now, "System Approval"); } // Commenting since no current way of knowing if request has been approved by the platform //if (intPlatform == 1) //{ // // Send to Platform for approval // if (intItem > 0) // { // int intUser = oPlatform.GetManager(Int32.Parse(oRequestItem.GetItem(intItem, "platformid"))); // if (intUser > 0) // { // string strDefault = oUser.GetApplicationUrl(intUser, _resourcerequestapprove); // if (strDefault == "") // oFunction.SendEmail("Request APPROVAL", oUser.GetName(intUser), "", strEMailIdsBCC, "Request APPROVAL", "<p><b>A service request requires your approval; you are required to approve or deny this request.</b></p>", true, false); // else // oFunction.SendEmail("Request APPROVAL", oUser.GetName(intUser), "", strEMailIdsBCC, "Request APPROVAL", "<p><b>A service request requires your approval; you are required to approve or deny this request.</b></p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(_resourcerequestapprove) + "?rrid=" + _resourcerequestid.ToString() + "\" target=\"_blank\">Click here to review this request.</a></p>", true, false); // } // } //} // Notify 3rd part approvers DataSet dsAlready = oResourceRequest.GetApprovals(_requestid, intService, intNumber); ServiceEditor oServiceEditor = new ServiceEditor(user, _dsn_service_editor); DataSet dsApprovalFields = oServiceEditor.GetApprovals(intService); DataSet dsServiceEditor = oServiceEditor.GetRequestFirstData2(_requestid, intService, intNumber, 0, dsn); foreach (DataRow drApprovalField in dsApprovalFields.Tables[0].Rows) { if (dsServiceEditor.Tables[0].Rows.Count > 0) { int intApprover = 0; if (Int32.TryParse(dsServiceEditor.Tables[0].Rows[0][drApprovalField["dbfield"].ToString()].ToString(), out intApprover) == true && intApprover > 0) { // Check to see if already sent bool boolAlready = false; foreach (DataRow drAlready in dsAlready.Tables[0].Rows) { if (intApprover == Int32.Parse(drAlready["userid"].ToString())) { boolAlready = true; break; } } if (boolAlready == false) { boolNotify = true; oResourceRequest.AddApproval(_requestid, intService, intNumber, intApprover); oLog.AddEvent(_requestid.ToString(), strCVT, "Sending to 3rd party approver for approval - " + oUser.GetFullNameWithLanID(intApprover), LoggingType.Debug); string strDefault = oUser.GetApplicationUrl(intApprover, _resourcerequestapprove); if (strDefault == "") { oFunction.SendEmail("Request #CVT" + _requestid.ToString() + "-" + intService.ToString() + "-" + intNumber.ToString() + " APPROVAL", oUser.GetName(intApprover), "", strEMailIdsBCC, "Request #CVT" + _requestid.ToString() + "-" + intService.ToString() + "-" + intNumber.ToString() + " APPROVAL", "<p><b>A service request requires your approval; you are required to approve or deny this request.</b></p>", true, false); } else { oFunction.SendEmail("Request #CVT" + _requestid.ToString() + "-" + intService.ToString() + "-" + intNumber.ToString() + " APPROVAL", oUser.GetName(intApprover), "", strEMailIdsBCC, "Request #CVT" + _requestid.ToString() + "-" + intService.ToString() + "-" + intNumber.ToString() + " APPROVAL", "<p><b>A service request requires your approval; you are required to approve or deny this request.</b></p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(_resourcerequestapprove) + "?rrid=" + RRID.ToString() + "\" target=\"_blank\">Click here to review this request.</a></p>", true, false); } } else { // No new people to notify, check to see all approvals are finished. foreach (DataRow drAlready in dsAlready.Tables[0].Rows) { if (drAlready["approved"].ToString() == "" && drAlready["denied"].ToString() == "") { boolNotify = true; break; } } oLog.AddEvent(_requestid.ToString(), strCVT, "Notify = " + boolNotify.ToString(), LoggingType.Debug); } } } } } } //if (intApproval) return(boolNotify); }