// ************************************************************************************ // ************************************************************************************ // The following rules apply to the project request approval workflow... // 1) New request // a) If expedited, send to Board // b) If not expedited, send to manager // 2) Manager Level // a) If approve, send to platform manager // b) If not approved, send message to user and stop workflow // 3) Platform Level // a) On first approval, send to board // b) If not approved by ALL, send message to user and stop workflow // 4) Board Level // a) On majority approval, send to director // b) If majority fails, send message to user and stop workflow // c) If tied, approve and send to director // 5) Director Level // a) If approve, approve the request, send message to user and send message to // TPM (working sponsor) to request resources. // b) If not approved, send message to user and stop workflow // ************************************************************************************ // ************************************************************************************ public void NewRequest(int _requestid, int _userid, bool _expedited, int _pageid, bool _director) { DeleteRequest(_requestid); string strBody = oProjectRequest.GetBody(_requestid, intEnvironment, true); Platforms oPlatform = new Platforms(user, dsn); if (_expedited == false) { // LOAD MANAGER DETAIL int intManager = Int32.Parse(oUser.Get(_userid, "manager")); if (intManager > 0) { LoadTable(_requestid, 1, _director); LoadTableDetail(_requestid, intManager, 0, 1); string strDefault = oUser.GetApplicationUrl(intManager, _pageid); if (strDefault == "") { oFunction.SendEmail(strEmailTitle, oUser.GetName(intManager) + ";", "", strEMailIdsBCC, strTitle, "<p><b>As the MANAGER (" + oUser.GetFullName(intManager) + ") this project request requires your approval...</b></p><p>" + strBody + "</p>", true, false); } else { oFunction.SendEmail(strEmailTitle, oUser.GetName(intManager) + ";", "", strEMailIdsBCC, strTitle, "<p><b>As the MANAGER (" + oUser.GetFullName(intManager) + ") this project request requires your approval...</b></p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(_pageid) + "?rid=" + _requestid.ToString() + "\" target=\"_blank\">Click here to view this project request.</a></p><p>" + strBody + "</p>", true, false); } oFunction.SendEmail(strEmailTitle, oUser.GetName(_userid), "", strEMailIdsBCC, strTitle, "<p><b>The following project request has been routed to your manager (" + oUser.GetFullName(intManager) + ") for approval.</b></p><p>" + oProjectRequest.GetBody(_requestid, intEnvironment, true) + "</p>", true, false); // LOAD PLATFORM DETAIL ds = oProjectRequest.GetPlatforms(_requestid); foreach (DataRow dr in ds.Tables[0].Rows) { int intUser = oPlatform.GetManager(Int32.Parse(dr["platformid"].ToString())); if (intUser > 0) { LoadTableDetail(_requestid, intUser, -10, 2); } } // LOAD BOARD DETAIL ds = oUser.GetBoard(); foreach (DataRow dr in ds.Tables[0].Rows) { LoadTableDetail(_requestid, Int32.Parse(dr["userid"].ToString()), -10, 3); } } else { bool boolPlatform = false; // LOAD AND SEND TO PLATFORM (no manager) ds = oProjectRequest.GetPlatforms(_requestid); foreach (DataRow dr in ds.Tables[0].Rows) { int intUser = oPlatform.GetManager(Int32.Parse(dr["platformid"].ToString())); if (intUser > 0) { boolPlatform = true; LoadTableDetail(_requestid, intUser, 0, 2); string strDefault = oUser.GetApplicationUrl(intUser, _pageid); if (strDefault == "") { oFunction.SendEmail(strEmailTitle, oUser.GetName(intUser) + ";", "", strEMailIdsBCC, strTitle, "<p><b>As the PLATFORM MANAGER (" + oUser.GetFullName(intUser) + ") this project request requires your approval...</b></p><p>" + strBody + "</p>", true, false); } else { oFunction.SendEmail(strEmailTitle, oUser.GetName(intUser) + ";", "", strEMailIdsBCC, strTitle, "<p><b>As the PLATFORM MANAGER (" + oUser.GetFullName(intUser) + ") this project request requires your approval...</b></p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(_pageid) + "?rid=" + _requestid.ToString() + "\" target=\"_blank\">Click here to view this project request.</a></p><p>" + strBody + "</p>", true, false); } } } if (boolPlatform == true) { LoadTable(_requestid, 2, _director); oFunction.SendEmail(strEmailTitle, oUser.GetName(_userid), "", strEMailIdsBCC, strTitle, "<p><b>The following project request has been routed to the PLATFORM MANAGER(S) for approval.</b></p><p>" + oProjectRequest.GetBody(_requestid, intEnvironment, true) + "</p>", true, false); // LOAD BOARD DETAIL ds = oUser.GetBoard(); foreach (DataRow dr in ds.Tables[0].Rows) { LoadTableDetail(_requestid, Int32.Parse(dr["userid"].ToString()), -10, 3); } } else { LoadTable(_requestid, 3, _director); // LOAD BOARD DETAIL ds = oUser.GetBoard(); foreach (DataRow dr in ds.Tables[0].Rows) { LoadTableDetail(_requestid, Int32.Parse(dr["userid"].ToString()), 0, 3); int intUser = Int32.Parse(dr["userid"].ToString()); string strDefault = oUser.GetApplicationUrl(intUser, _pageid); if (strDefault == "") { oFunction.SendEmail(strEmailTitle, oUser.GetName(intUser) + ";", "", strEMailIdsBCC, strTitle, "<p><b>As a BOARD MEMBER (" + oUser.GetFullName(intUser) + ") this project request requires your approval...</b></p><p>" + strBody + "</p>", true, false); } else { oFunction.SendEmail(strEmailTitle, oUser.GetName(intUser) + ";", "", strEMailIdsBCC, strTitle, "<p><b>As a BOARD MEMBER (" + oUser.GetFullName(intUser) + ") this project request requires your approval...</b></p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(_pageid) + "?rid=" + _requestid.ToString() + "\" target=\"_blank\">Click here to view this project request.</a></p><p>" + strBody + "</p>", true, false); } } } } } else { // LOAD MANAGER DETAIL LoadTable(_requestid, 3, _director); int intManager = Int32.Parse(oUser.Get(_userid, "manager")); LoadTableDetail(_requestid, intManager, -100, 1); // LOAD PLATFORM DETAIL ds = oProjectRequest.GetPlatforms(_requestid); foreach (DataRow dr in ds.Tables[0].Rows) { LoadTableDetail(_requestid, oPlatform.GetManager(Int32.Parse(dr["platformid"].ToString())), -100, 2); } // LOAD BOARD DETAIL ds = oUser.GetBoard(); foreach (DataRow dr in ds.Tables[0].Rows) { int intUser = Int32.Parse(dr["userid"].ToString()); LoadTableDetail(_requestid, intUser, 0, 3); string strDefault = oUser.GetApplicationUrl(intUser, _pageid); if (strDefault == "") { oFunction.SendEmail(strEmailTitle, oUser.GetName(intUser) + ";", "", strEMailIdsBCC, strTitle, "<p><b>As a BOARD MEMBER (" + oUser.GetFullName(intUser) + ") this project request requires your approval...</b></p><p>" + strBody + "</p>", true, false); } else { oFunction.SendEmail(strEmailTitle, oUser.GetName(intUser) + ";", "", strEMailIdsBCC, strTitle, "<p><b>As a BOARD MEMBER (" + oUser.GetFullName(intUser) + ") this project request requires your approval...</b></p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(_pageid) + "?rid=" + _requestid.ToString() + "\" target=\"_blank\">Click here to view this project request.</a></p><p>" + strBody + "</p>", true, false); } } oFunction.SendEmail(strEmailTitle, oUser.GetName(_userid), "", strEMailIdsBCC, strTitle, "<p><b>The following project request has been expedited for approval to the BOARD.</b></p><p>" + oProjectRequest.GetBody(_requestid, intEnvironment, true) + "</p>", true, false); } // LOAD DIRECTOR if (_director == true) { ds = oUser.GetDirector(); foreach (DataRow dr in ds.Tables[0].Rows) { LoadTableDetail(_requestid, Int32.Parse(dr["userid"].ToString()), -10, 4); } } }
public void NotifyTeamLead(int _itemid, int _rrid, int _assignpage, int _viewpage, int _environment, string _cc, string _se_dsn, string _dsn_asset, string _dsn_ip, int _userid_assigned) { RequestItems oRequestItem = new RequestItems(user, dsn); Users oUser = new Users(user, dsn); Applications oApplication = new Applications(user, dsn); Pages oPage = new Pages(user, dsn); Functions oFunction = new Functions(user, dsn, _environment); Variables oVariable = new Variables(_environment); Services oService = new Services(user, dsn); ResourceRequest oResourceRequest = new ResourceRequest(user, dsn); Log oLog = new Log(user, dsn); int intService = Int32.Parse(oResourceRequest.Get(_rrid, "serviceid")); string strService = oService.GetName(intService); if (intService == 0) { strService = oRequestItem.GetItemName(_itemid); } int intApp = oRequestItem.GetItemApplication(_itemid); int intRequest = Int32.Parse(oResourceRequest.Get(_rrid, "requestid")); int intNumber = Int32.Parse(oResourceRequest.Get(_rrid, "number")); Requests oRequest = new Requests(user, dsn); int intProject = oRequest.GetProjectNumber(intRequest); Projects oProject = new Projects(user, dsn); int intRequester = oRequest.GetUser(intRequest); string strSpacerRow = "<tr><td colspan=\"3\"><img src=\"" + oVariable.ImageURL() + "/images/spacer.gif\" border=\"0\" width=\"1\" height=\"7\" /></td></tr>"; string strEmail = oService.Get(intService, "email"); string strEMailIdsBCC = oFunction.GetGetEmailAlertsEmailIds("EMAILGRP_REQUEST_ASSIGNMENT"); string strCVT = "CVT" + intRequest.ToString() + "-" + intService.ToString() + "-" + intNumber.ToString(); int intUser = _userid_assigned; bool boolTech = false; if (intUser > 0) { boolTech = true; string strNotify = ""; //if (oProject.Get(intProject, "number").StartsWith("CV") == false) // strNotify = "<p><span style=\"color:#0000FF\"><b>PROJECT COORDINATOR:</b> Please allocate the hours listed above for each resource in Clarity.</span></p>"; // Add Workflow int intResourceWorkflow = oResourceRequest.AddWorkflow(_rrid, 0, oResourceRequest.Get(_rrid, "name"), intUser, Int32.Parse(oResourceRequest.Get(_rrid, "devices")), double.Parse(oResourceRequest.Get(_rrid, "allocated")), 2, 0); oLog.AddEvent(intRequest.ToString(), strCVT, "Request assigned to " + oUser.GetFullNameWithLanID(intUser) + " by the system", LoggingType.Debug); string strDefault = oUser.GetApplicationUrl(intUser, _viewpage); if (strDefault == "") { oFunction.SendEmail("Request Assignment: " + strService, oUser.GetName(intUser), _cc, strEMailIdsBCC, "Request Assignment: " + strService, "<p><b>The following request has been automatically assigned to you</b><p><p>" + oResourceRequest.GetWorkflowSummary(intResourceWorkflow, _environment, _se_dsn, _dsn_asset, _dsn_ip) + "</p>", true, false); } else { if (intProject > 0) { oFunction.SendEmail("Request Assignment: " + strService, oUser.GetName(intUser), _cc, strEMailIdsBCC, "Request Assignment: " + strService, "<p><b>The following request has been automatically assigned to you</b><p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(_viewpage) + "?pid=" + intProject.ToString() + "\" target=\"_blank\">Click here to review your new assignment.</a></p><p>" + oResourceRequest.GetWorkflowSummary(intResourceWorkflow, _environment, _se_dsn, _dsn_asset, _dsn_ip) + "</p>", true, false); } else { oFunction.SendEmail("Request Assignment: " + strService, oUser.GetName(intUser), _cc, strEMailIdsBCC, "Request Assignment: " + strService, "<p><b>The following request has been automatically assigned to you</b><p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/frame/resource_request.aspx?rrid=" + intResourceWorkflow.ToString() + "\" target=\"_blank\">Click here to review your new assignment.</a></p><p>" + oResourceRequest.GetWorkflowSummary(intResourceWorkflow, _environment, _se_dsn, _dsn_asset, _dsn_ip) + "</p>", true, false); } } string strActivity = "<tr><td><b>Resource:</b></td><td> </td><td>" + oUser.GetFullName(intUser) + "</td></tr>"; strActivity += strSpacerRow; strActivity += "<tr><td><b>Activity Type:</b></td><td> </td><td>" + oRequestItem.GetItemName(_itemid) + "</td></tr>"; strActivity = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"" + oVariable.DefaultFontStyle() + "\">" + strActivity + "</table>"; string strDeliverable = oApplication.Get(intApp, "deliverables_doc"); if (strDeliverable.Trim() != "") { strDeliverable = "<p><a href=\"" + oVariable.URL() + strDeliverable + "\">Click here to view the service deliverables</a></p>"; } if (oService.Get(intService, "notify_client") != "0") { oFunction.SendEmail("Request Assignment: " + strService, oUser.GetName(intRequester), _cc, strEMailIdsBCC, "Request Assignment: " + strService, "<p><b>A resource has been assigned to the following request...</b><p><p>" + oResourceRequest.GetWorkflowSummary(intResourceWorkflow, _environment, _se_dsn, _dsn_asset, _dsn_ip) + "</p><p>" + strActivity + "</p>" + strDeliverable + strNotify, true, false); } oProject.Update(intProject, 2); oResourceRequest.UpdateAccepted(_rrid, 1); oResourceRequest.UpdateAssignedBy(_rrid, -1000); } else { DataSet dsTechnicians = oService.GetUser(intService, 0); foreach (DataRow drTechnician in dsTechnicians.Tables[0].Rows) { boolTech = true; intUser = Int32.Parse(drTechnician["userid"].ToString()); string strNotify = ""; //if (oProject.Get(intProject, "number").StartsWith("CV") == false) // strNotify = "<p><span style=\"color:#0000FF\"><b>PROJECT COORDINATOR:</b> Please allocate the hours listed above for each resource in Clarity.</span></p>"; // Add Workflow int intResourceWorkflow = oResourceRequest.AddWorkflow(_rrid, 0, oResourceRequest.Get(_rrid, "name"), intUser, Int32.Parse(oResourceRequest.Get(_rrid, "devices")), double.Parse(oResourceRequest.Get(_rrid, "allocated")), 2, 1); oLog.AddEvent(intRequest.ToString(), strCVT, "Request assigned to " + oUser.GetFullNameWithLanID(intUser) + " from service techician configuration", LoggingType.Debug); // NOTIFY if (strEmail != "" && strEmail != "0") { string strDefault = oApplication.GetUrl(intApp, _viewpage); if (strDefault == "") { oFunction.SendEmail("Request Assignment: " + strService, strEmail, oUser.GetEmail(_cc, _environment), strEMailIdsBCC, "Request Assignment: " + strService, "<p><b>The following request has been automatically assigned to you</b></p><p>" + oResourceRequest.GetWorkflowSummary(intResourceWorkflow, _environment, _se_dsn, _dsn_asset, _dsn_ip) + "</p>", false, false); } else { if (intProject > 0) { oFunction.SendEmail("Request Assignment: " + strService, strEmail, oUser.GetEmail(_cc, _environment), strEMailIdsBCC, "Request Assignment: " + strService, "<p><b>The following request has been automatically assigned to you</b><p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(_viewpage) + "?pid=" + intProject.ToString() + "\" target=\"_blank\">Click here to review your new assignment.</a></p><p>" + oResourceRequest.GetWorkflowSummary(intResourceWorkflow, _environment, _se_dsn, _dsn_asset, _dsn_ip) + "</p>", false, false); } else { oFunction.SendEmail("Request Assignment: " + strService, strEmail, oUser.GetEmail(_cc, _environment), strEMailIdsBCC, "Request Assignment: " + strService, "<p><b>The following request has been automatically assigned to you</b><p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/frame/resource_request.aspx?rrid=" + intResourceWorkflow.ToString() + "\" target=\"_blank\">Click here to review your new assignment.</a></p><p>" + oResourceRequest.GetWorkflowSummary(intResourceWorkflow, _environment, _se_dsn, _dsn_asset, _dsn_ip) + "</p>", false, false); } } } else { string strDefault = oUser.GetApplicationUrl(intUser, _viewpage); if (strDefault == "") { oFunction.SendEmail("Request Assignment: " + strService, oUser.GetName(intUser), _cc, strEMailIdsBCC, "Request Assignment: " + strService, "<p><b>The following request has been automatically assigned to you</b><p><p>" + oResourceRequest.GetWorkflowSummary(intResourceWorkflow, _environment, _se_dsn, _dsn_asset, _dsn_ip) + "</p>", true, false); } else { if (intProject > 0) { oFunction.SendEmail("Request Assignment: " + strService, oUser.GetName(intUser), _cc, strEMailIdsBCC, "Request Assignment: " + strService, "<p><b>The following request has been automatically assigned to you</b><p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(_viewpage) + "?pid=" + intProject.ToString() + "\" target=\"_blank\">Click here to review your new assignment.</a></p><p>" + oResourceRequest.GetWorkflowSummary(intResourceWorkflow, _environment, _se_dsn, _dsn_asset, _dsn_ip) + "</p>", true, false); } else { oFunction.SendEmail("Request Assignment: " + strService, oUser.GetName(intUser), _cc, strEMailIdsBCC, "Request Assignment: " + strService, "<p><b>The following request has been automatically assigned to you</b><p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/frame/resource_request.aspx?rrid=" + intResourceWorkflow.ToString() + "\" target=\"_blank\">Click here to review your new assignment.</a></p><p>" + oResourceRequest.GetWorkflowSummary(intResourceWorkflow, _environment, _se_dsn, _dsn_asset, _dsn_ip) + "</p>", true, false); } } string strActivity = "<tr><td><b>Resource:</b></td><td> </td><td>" + oUser.GetFullName(intUser) + "</td></tr>"; strActivity += strSpacerRow; strActivity += "<tr><td><b>Activity Type:</b></td><td> </td><td>" + oRequestItem.GetItemName(_itemid) + "</td></tr>"; strActivity = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"" + oVariable.DefaultFontStyle() + "\">" + strActivity + "</table>"; string strDeliverable = oApplication.Get(intApp, "deliverables_doc"); if (strDeliverable.Trim() != "") { strDeliverable = "<p><a href=\"" + oVariable.URL() + strDeliverable + "\">Click here to view the service deliverables</a></p>"; } if (oService.Get(intService, "notify_client") != "0") { oFunction.SendEmail("Request Assignment: " + strService, oUser.GetName(intRequester), _cc, strEMailIdsBCC, "Request Assignment: " + strService, "<p><b>A resource has been assigned to the following request...</b><p><p>" + oResourceRequest.GetWorkflowSummary(intResourceWorkflow, _environment, _se_dsn, _dsn_asset, _dsn_ip) + "</p><p>" + strActivity + "</p>" + strDeliverable + strNotify, true, false); } } oProject.Update(intProject, 2); oResourceRequest.UpdateAccepted(_rrid, 1); oResourceRequest.UpdateAssignedBy(_rrid, -1000); } } if (boolTech == false) { oLog.AddEvent(intRequest.ToString(), strCVT, "Sending request to service manager(s) for assignment", LoggingType.Debug); // If no technicians assigned if (strEmail != "" && strEmail != "0") { // If group mailbox string strDefault = oApplication.GetUrl(intApp, _assignpage); oLog.AddEvent(intRequest.ToString(), strCVT, "Request sent to " + strEmail + " (group mailbox) for assignment", LoggingType.Debug); if (strDefault == "") { oFunction.SendEmail("Request Submitted: " + strService, strEmail, "", strEMailIdsBCC, "Request Submitted: " + strService, "<p><b>A resource from your department has been requested; you are required to assign a resource to this initiative.</b></p><p>" + oResourceRequest.GetSummary(_rrid, 0, _environment, _se_dsn, _dsn_asset, _dsn_ip) + "</p>", false, false); } else { oFunction.SendEmail("Request Submitted: " + strService, strEmail, "", strEMailIdsBCC, "Request Submitted: " + strService, "<p><b>A resource from your department has been requested; you are required to assign a resource to this initiative.</b></p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(_assignpage) + "?rrid=" + _rrid.ToString() + "\" target=\"_blank\">Click here to assign a resource.</a></p><p>" + oResourceRequest.GetSummary(_rrid, 0, _environment, _se_dsn, _dsn_asset, _dsn_ip) + "</p>", false, false); } } else { // If no group mailbox, notify team leads DataSet dsManagers = oService.GetUser(intService, 1); foreach (DataRow drManager in dsManagers.Tables[0].Rows) { intUser = Int32.Parse(drManager["userid"].ToString()); oLog.AddEvent(intRequest.ToString(), strCVT, "Request sent to " + oUser.GetFullNameWithLanID(intUser) + " for assignment", LoggingType.Debug); string strDefault = oUser.GetApplicationUrl(intUser, _assignpage); if (strDefault == "") { oFunction.SendEmail("Request Submitted: " + strService, oUser.GetName(intUser), "", strEMailIdsBCC, "Request Submitted: " + strService, "<p><b>A resource from your department has been requested; you are required to assign a resource to this initiative.</b></p><p>" + oResourceRequest.GetSummary(_rrid, 0, _environment, _se_dsn, _dsn_asset, _dsn_ip) + "</p>", true, false); } else { oFunction.SendEmail("Request Submitted: " + strService, oUser.GetName(intUser), "", strEMailIdsBCC, "Request Submitted: " + strService, "<p><b>A resource from your department has been requested; you are required to assign a resource to this initiative.</b></p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(_assignpage) + "?rrid=" + _rrid.ToString() + "\" target=\"_blank\">Click here to assign a resource.</a></p><p>" + oResourceRequest.GetSummary(_rrid, 0, _environment, _se_dsn, _dsn_asset, _dsn_ip) + "</p>", true, false); } } } } }
public void Deny(int _id, string _reason, int _request_pageid, bool _notify) { arParams = new SqlParameter[2]; arParams[0] = new SqlParameter("@id", _id); arParams[1] = new SqlParameter("@reason", _reason); SqlHelper.ExecuteNonQuery(dsn, CommandType.StoredProcedure, "pr_updateProjectPendingDeny", arParams); if (_notify == true) { DataSet ds = Get(_id); int intUser = Int32.Parse(ds.Tables[0].Rows[0]["userid"].ToString()); int intRequest = Int32.Parse(ds.Tables[0].Rows[0]["requestid"].ToString()); Variables oVariable = new Variables(intEnvironment); Functions oFunction = new Functions(user, dsn, intEnvironment); Users oUser = new Users(user, dsn); Pages oPage = new Pages(user, dsn); string strDefault = oUser.GetApplicationUrl(intUser, _request_pageid); string strEMailIdsBCC = oFunction.GetGetEmailAlertsEmailIds("EMAILGRP_PROJECT"); if (_reason != "") { _reason = "<p>The following comments were added:<br/>" + _reason + "</p>"; } if (strDefault != "") { oFunction.SendEmail("ClearView Project Approval", oUser.GetName(intUser), "", strEMailIdsBCC, "ClearView Project Approval", "<p><b>Your project has been DENIED.</b></p>" + _reason + "<p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(_request_pageid) + "?rid=" + intRequest.ToString() + "\" target=\"_blank\">Click here to continue.</a></p>", true, false); } } }
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); }