public void DenyRequest(int _requestid, int _approval, string _by) { Projects oProject = new Projects(user, dsn); int intProject = oRequest.GetProjectNumber(_requestid); int intWorking = Int32.Parse(oProject.Get(intProject, "working")); int intExecutive = Int32.Parse(oProject.Get(intProject, "executive")); oProject.Update(intProject, _approval); string strStatus = "ERROR"; switch (_approval) { case -1: strStatus = "DENIED"; break; case 10: strStatus = "SHELVED"; break; } int intRequester = oRequest.GetUser(_requestid); string _external = GetComments(_requestid); if (_external.Trim() == "") { oFunction.SendEmail(strEmailTitle, oUser.GetName(intRequester), oUser.GetName(intWorking) + ";" + oUser.GetName(intExecutive) + ";", strEMailIdsBCC, strTitle, "<p><b>The following project request has been " + strStatus + " by " + _by + ".</b></p><p>" + oProjectRequest.GetBody(_requestid, intEnvironment, true) + "</p>", true, false); } else { oFunction.SendEmail(strEmailTitle, oUser.GetName(intRequester), oUser.GetName(intWorking) + ";" + oUser.GetName(intExecutive) + ";", strEMailIdsBCC, strTitle, "<p><b>The following project request has been " + strStatus + " by " + _by + ".</b></p><p>" + oProjectRequest.GetBody(_requestid, intEnvironment, true) + "</p><p>The following comments were added to this request:<br/>" + _external + "<p>", true, false); } }
public string GetErrorBody(int _requestid, int _serviceid, int _number) { DataSet ds = GetError(_requestid, _serviceid, _number); Users oUser = new Users(0, dsn); Requests oRequest = new Requests(0, dsn); Servers oServer = new Servers(0, dsn); StringBuilder sbDetails = new StringBuilder(); if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; int intUser = oRequest.GetUser(_requestid); int intAudit = Int32.Parse(ds.Tables[0].Rows[0]["auditid"].ToString()); DataSet dsAudit = GetServer(intAudit); if (dsAudit.Tables[0].Rows.Count > 0) { int intServer = Int32.Parse(dsAudit.Tables[0].Rows[0]["serverid"].ToString()); sbDetails.Append("<tr><td colspan=\"5\"><b>SERVER: " + oServer.GetName(intServer, true) + "</b></td></tr>"); sbDetails.Append("<tr><td colspan=\"5\"><b>SCRIPT: " + dsAudit.Tables[0].Rows[0]["name"].ToString() + "</b></td></tr>"); sbDetails.Append("<tr>"); sbDetails.Append("<td> </td>"); sbDetails.Append("<td><b>Status</b></td>"); sbDetails.Append("<td><b>Code</b></td>"); sbDetails.Append("<td><b>Result</b></td>"); sbDetails.Append("<td><b>Date</b></td>"); sbDetails.Append("</tr>"); try { DataSet dsAuditResult = GetServerDetailsRemote(intAudit); foreach (DataRow drAuditResult in dsAuditResult.Tables[0].Rows) { sbDetails.Append("<tr>"); sbDetails.Append("<td></td>"); try { int intAuditStatus = Int32.Parse(drAuditResult["status"].ToString()); AuditStatus oAuditStatus = (AuditStatus)intAuditStatus; sbDetails.Append("<td valign=\"top\" nowrap>" + oAuditStatus.ToString() + "</td>"); } catch { sbDetails.Append("<td valign=\"top\" nowrap>Unknown Status (" + drAuditResult["status"].ToString() + ")</td>"); } sbDetails.Append("<td valign=\"top\" nowrap>" + drAuditResult["code"].ToString() + "</td>"); sbDetails.Append("<td valign=\"top\" width=\"100%\">" + drAuditResult["result"].ToString() + "</td>"); sbDetails.Append("<td valign=\"top\" nowrap>" + drAuditResult["created"].ToString() + "</td>"); sbDetails.Append("</tr>"); } } catch { } } } return(sbDetails.ToString()); }
public string GetBody(int _requestid, int _itemid, int _number, int _serviceid, int _rrid, int _rr_workflowid, string _se_dsn, int _environment, string _dsn_asset, string _dsn_ip) { string strView = ""; Applications oApplication = new Applications(user, dsn); RequestItems oRequestItem = new RequestItems(user, dsn); ResourceRequest oResourceRequest = new ResourceRequest(user, dsn); Users oUser = new Users(user, dsn); Services oService = new Services(user, dsn); Variables oVariable = new Variables(_environment); Functions oFunction = new Functions(0, dsn, _environment); Requests oRequest = new Requests(user, dsn); Projects oProject = new Projects(user, dsn); ServiceRequests oServiceRequest = new ServiceRequests(user, dsn); ServiceEditor oServiceEditor = new ServiceEditor(user, _se_dsn); Servers oServer = new Servers(user, dsn); Workstations oWorkstation = new Workstations(user, dsn); AssetOrder oAssetOrder = new AssetOrder(user, dsn, _dsn_asset, _environment); AssetSharedEnvOrder oAssetSharedEnvOrder = new AssetSharedEnvOrder(user, dsn, _dsn_asset, _environment); PNCTasks oPNCTask = new PNCTasks(user, dsn); TSM oTSM = new TSM(user, dsn); StatusLevels oStatusLevel = new StatusLevels(); DataSet dsRR = oResourceRequest.GetRequestService(_requestid, _serviceid, _number); if (dsRR.Tables[0].Rows.Count > 0) { if (_rrid == 0) { Int32.TryParse(dsRR.Tables[0].Rows[0]["parent"].ToString(), out _rrid); } if (_rr_workflowid == 0) { Int32.TryParse(dsRR.Tables[0].Rows[0]["id"].ToString(), out _rr_workflowid); } } // Workflow string strWorkflowName = ""; int intProject = oRequest.GetProjectNumber(_requestid); if (intProject > 0) { strView += "<tr><td valign=\"top\"><b>Project Name:</b></td>"; strView += "<td colspan=\"40\">" + oProject.Get(intProject, "name") + "</td></tr>"; strView += "<tr><td valign=\"top\"><b>Project Number:</b></td>"; strView += "<td>" + "<a href=\"" + oRequest.GetDataPointLink(_requestid, _environment) + "\" target=\"_blank\">" + oProject.Get(intProject, "number") + "</a></td></tr>"; } else { string strTaskName = "N/A"; if (_rr_workflowid > 0) { strTaskName = oResourceRequest.GetWorkflow(_rr_workflowid, "name").Trim(); } if ((strTaskName == "" || strTaskName == "N/A") && _rrid > 0) { strTaskName = oResourceRequest.Get(_rrid, "name").Trim(); } if ((strTaskName == "" || strTaskName == "N/A") && _requestid > 0) { strTaskName = oServiceRequest.Get(_requestid, "name").Trim(); } strView += "<tr><td valign=\"top\"><b>Task Name:</b></td>"; strView += "<td colspan=\"40\">" + strTaskName + "</td></tr>"; } strView += "<tr><td valign=\"top\"><b>Task Number:</b></td>"; strView += "<td>" + "<a href=\"javascript:void(0);\" class=\"lookup\" onclick=\"OpenNewWindowMenu('/datapoint/service/resource.aspx?id=" + oFunction.encryptQueryString(_rrid.ToString()) + "', '800', '600');\">CVT" + _requestid.ToString() + "-" + _serviceid.ToString() + "-" + _number.ToString() + "</a></td></tr>"; //strWorkflowName += "<td>" + "<a href=\"javascript:void(0);\" class=\"lookup\" onclick=\"OpenNewWindowMenu('" + oRequest.GetDataPointLink(_requestid, _environment) + "', '800', '600');\">CVT" + _requestid.ToString() + "</a></td>"; string strWorkflowRequested = ""; string strWorkflowCreated = ""; string strWorkflowService = ""; string strWorkflowDepartment = ""; string strWorkflowResources = ""; string strWorkflowStatus = ""; string strWorkflowComments = ""; int intStatus = 0; // Requested strWorkflowRequested += "<td valign=\"top\"><b>Requested By:</b></td>"; int intRequestor = oRequest.GetUser(_requestid); int intRequestorManager = 0; Int32.TryParse(oUser.Get(intRequestor, "manager"), out intRequestorManager); Int32.TryParse(oResourceRequest.Get(_rrid, "status"), out intStatus); strWorkflowRequested += "<td>" + oUser.GetFullName(intRequestor) + " (" + oUser.GetName(intRequestor) + ")" + "</td>"; strWorkflowCreated += "<td valign=\"top\"><b>Created On:</b></td>"; if (_rrid > 0) { strWorkflowCreated += "<td>" + DateTime.Parse(oResourceRequest.Get(_rrid, "created")).ToLongDateString() + "</td>"; } else { strWorkflowCreated += "<td>" + DateTime.Parse(oRequest.Get(_requestid, "created")).ToLongDateString() + "</td>"; } // Service strWorkflowService += "<td valign=\"top\"><b>Service:</b></td>"; if (_serviceid == 0) { strWorkflowService += "<td>" + oRequestItem.GetItem(_itemid, "service_title") + "</td>"; } else { strWorkflowService += "<td>" + oService.GetName(_serviceid) + "</td>"; } // Department strWorkflowDepartment += "<td valign=\"top\"><b>Department:</b></td>"; strWorkflowDepartment += "<td>" + oApplication.Get(oRequestItem.GetItemApplication(_itemid), "service_title") + "</td>"; // Resources string strApprovers = ""; DataSet dsApprovals = oResourceRequest.GetApprovals(_requestid, _serviceid, _number); foreach (DataRow drApprover in dsApprovals.Tables[0].Rows) { int intApprover = Int32.Parse(drApprover["userid"].ToString()); if (drApprover["approved"].ToString() == "" && drApprover["denied"].ToString() == "") { if (strApprovers != "") { strApprovers += "\\n"; } strApprovers += oUser.GetFullName(intApprover) + " (" + oUser.GetName(intApprover) + ")"; } } bool boolAutomated = (oService.Get(_serviceid, "automate") == "1"); if (boolAutomated == false) { DataSet dsReqForm = oRequestItem.GetForm(_requestid, _serviceid, _itemid, _number); if (dsReqForm.Tables[0].Rows.Count > 0) { boolAutomated = (dsReqForm.Tables[0].Rows[0]["automated"].ToString() == "1" ? true : false); } } strWorkflowResources += "<td valign=\"top\"><b>Assigned:</b></td>"; strWorkflowStatus += "<td><b>Status:</b></td>"; if (boolAutomated == true) { strWorkflowResources += "<td valign=\"top\">---</td>"; intStatus = (int)ResourceRequestStatus.NotAvailable; // Set to N/A since it is automated... strWorkflowStatus += "<td>" + oStatusLevel.HTML(intStatus) + "</td>"; } else { List <WorkflowStatus> RR = oResourceRequest.GetStatus(null, _rrid, null, null, null, null, false, _se_dsn); if (RR.Count > 0) { StringBuilder strUsers = new StringBuilder(); foreach (string strUser in RR[0].users) { if (String.IsNullOrEmpty(strUser) == false) { strUsers.Append(strUser); strUsers.AppendLine("<br/>"); } } strWorkflowResources += "<td valign=\"top\">" + strUsers.ToString() + "</td>"; strWorkflowStatus += "<td>" + RR[0].status + "</td>"; if (String.IsNullOrEmpty(RR[0].comments) == false) { strWorkflowComments += "<td valign=\"top\"><b>Comments:</b></td>"; strWorkflowComments += "<td valign=\"top\">" + oFunction.FormatText(RR[0].comments) + "</td>"; } } else { strWorkflowResources += "<td valign=\"top\"> N / A </td>"; strWorkflowStatus += "<td> N / A </td>"; } } strView += "<tr>" + strWorkflowRequested + "</tr><tr>" + strWorkflowCreated + "</tr><tr>" + strWorkflowService + "</tr><tr>" + strWorkflowDepartment + "</tr>" + "<tr>" + strWorkflowStatus + "</tr>" + (strWorkflowResources == "" ? "" : "<tr>" + strWorkflowResources + "</tr>") + (strWorkflowComments == "" ? "" : "<tr>" + strWorkflowComments + "</tr>"); if (strView == "") { strView = "Information Unavailable"; } else { strView = "<table cellpadding=\"3\" cellspacing=\"2\" border=\"0\" style=\"" + oVariable.DefaultFontStyle() + "\">" + strView + "</table>"; StringBuilder sbViewRequest = new StringBuilder(); Customized oCustomized = new Customized(user, dsn); DNS oDNS = new DNS(user, dsn); OnDemandTasks oOnDemandTask = new OnDemandTasks(user, dsn); Reports oReport = new Reports(user, dsn); Audit oAudit = new Audit(user, dsn); Enhancements oEnhancement = new Enhancements(user, dsn); ServerDecommission oServerDecommission = new ServerDecommission(0, dsn); Storage oStorage = new Storage(0, dsn); string strCatch = "1"; try { sbViewRequest.Append(oServiceEditor.GetRequestBody(_requestid, _serviceid, _number, dsn)); if (sbViewRequest.ToString() == "") { strCatch = "2"; sbViewRequest.Append(oCustomized.GetPNCDNSConflictBody(_requestid, _itemid, _number)); } if (sbViewRequest.ToString() == "") { strCatch = "3"; sbViewRequest.Append(oCustomized.GetStorage3rdBody(_requestid, _itemid, _number, _environment)); } if (sbViewRequest.ToString() == "") { strCatch = "4"; sbViewRequest.Append(oOnDemandTask.GetServerOther(_requestid, _serviceid, _number, _environment, _dsn_asset, _dsn_ip)); } if (sbViewRequest.ToString() == "") { strCatch = "5"; sbViewRequest.Append(GetBody(oReport.GetOrderReport(_requestid, _itemid, _number), _serviceid)); } if (sbViewRequest.ToString() == "") { strCatch = "6"; sbViewRequest.Append(oServerDecommission.GetBody(_requestid, _number, _dsn_asset, _environment)); } if (sbViewRequest.ToString() == "") { strCatch = "7"; sbViewRequest.Append(oCustomized.GetDecommissionServerBody(_requestid, _itemid, _number, _dsn_asset)); } if (sbViewRequest.ToString() == "") { strCatch = "7.1"; sbViewRequest.Append(oWorkstation.GetApprovalSummary(_requestid)); } if (sbViewRequest.ToString() == "") { strCatch = "8"; int intEnhancementID = oCustomized.GetEnhancementID(_requestid); if (intEnhancementID > 0) { sbViewRequest.Append("<tr><td>"); sbViewRequest.Append(oCustomized.GetEnhancementBody(intEnhancementID, _environment, false)); sbViewRequest.Append("</td></tr>"); } } if (sbViewRequest.ToString() == "") { strCatch = "9"; int intIssueID = oCustomized.GetIssueID(_requestid); if (intIssueID > 0) { sbViewRequest.Append("<tr><td>"); sbViewRequest.Append(oCustomized.GetIssueBody(intIssueID, _environment, false)); sbViewRequest.Append("</td></tr>"); } } if (sbViewRequest.ToString() == "") { strCatch = "10"; sbViewRequest.Append(GetBody(oCustomized.GetIIS(_requestid, _itemid, _number), _serviceid)); } if (sbViewRequest.ToString() == "") { strCatch = "11"; sbViewRequest.Append(GetBody(oCustomized.GetRemediation(_requestid, _itemid, _number), _serviceid)); } if (sbViewRequest.ToString() == "") { strCatch = "12"; sbViewRequest.Append(GetBody(oCustomized.GetServerArchive(_requestid, _itemid, _number), _serviceid)); } if (sbViewRequest.ToString() == "") { strCatch = "13"; sbViewRequest.Append(GetBody(oCustomized.GetServerRetrieve(_requestid, _itemid, _number), _serviceid)); } if (sbViewRequest.ToString() == "") { strCatch = "14"; sbViewRequest.Append(GetBody(oCustomized.GetTPM(_requestid, _itemid, _number), _serviceid)); } if (sbViewRequest.ToString() == "") { strCatch = "15"; sbViewRequest.Append(GetBody(oCustomized.GetWorkstation(_requestid, _itemid, _number), _serviceid)); } if (sbViewRequest.ToString() == "") { strCatch = "16"; sbViewRequest.Append(GetBody(oCustomized.GetThirdTierDistributed(_requestid, _itemid, _number), _serviceid)); } if (sbViewRequest.ToString() == "") { strCatch = "17"; sbViewRequest.Append(GetBody(oCustomized.GetGeneric(_requestid, _itemid, _number), _serviceid)); } if (sbViewRequest.ToString() == "") { strCatch = "18"; sbViewRequest.Append(oDNS.GetDNSBody(_requestid, _itemid, _number, false, _environment)); } if (sbViewRequest.ToString() == "") { strCatch = "19"; sbViewRequest.Append(oAudit.GetErrorBody(_requestid, _serviceid, _number)); } if (sbViewRequest.ToString() == "")//Server Error Provisioning Support { strCatch = "20"; sbViewRequest.Append(oServer.GetErrorDetailsBody(_requestid, _itemid, _number, _environment)); } if (sbViewRequest.ToString() == "") //Workstation Error Provisioning Support { strCatch = "21"; sbViewRequest.Append(oWorkstation.GetVirtualErrorDetailsBody(_requestid, _number, _environment)); } if (sbViewRequest.ToString() == "") //Asset Procurement { strCatch = "22"; sbViewRequest.Append(oAssetOrder.GetOrderBody(_requestid, _itemid, _number)); } if (sbViewRequest.ToString() == "") //Shared Environement - IM { strCatch = "23"; sbViewRequest.Append(oAssetSharedEnvOrder.GetOrderBody(_requestid, _itemid, _number)); } if (sbViewRequest.ToString() == "") //Backup { strCatch = "24"; sbViewRequest.Append(oTSM.GetBody(_requestid, _itemid, _number, _dsn_asset, _dsn_ip)); } if (sbViewRequest.ToString() == "") // New Enhancement { strCatch = "25"; sbViewRequest.Append(oEnhancement.GetBodyRequest(_requestid, _environment)); } if (sbViewRequest.ToString() == "") // New Enhancement { strCatch = "26"; sbViewRequest.Append(oStorage.GetBody(_requestid, _itemid, _number, _dsn_asset, _dsn_ip, _environment, false)); } if (sbViewRequest.ToString() == "") { //strViewRequest = "Information Unavailable"; sbViewRequest.Append(" "); } else { if (sbViewRequest.ToString().Trim().StartsWith("<table") == false) { sbViewRequest.Insert(0, "<table cellpadding=\"3\" cellspacing=\"2\" border=\"0\" style=\"" + oVariable.DefaultFontStyle() + "\">"); sbViewRequest.Append("</table>"); } } } catch { sbViewRequest = new StringBuilder(" ** WARNING: Information Unavailable (# " + strCatch + ") ** "); } sbViewRequest.Insert(0, "<table cellpadding=\"3\" cellspacing=\"2\" border=\"0\" style=\"" + oVariable.DefaultFontStyle() + "\"><tr><td>"); sbViewRequest.Append("</td></tr></table>"); strView += "<br/>" + sbViewRequest.ToString(); } return(strView); }
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 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); }