private void ProcessSnowResponse(SnowTicket snowTicket, Requester requester, int daysLeft, int emailNotification, int NoAprrovalCancelRequired) { bool notification = false; if (snowTicket != null) { //update database status if (!string.IsNullOrEmpty(snowTicket.change_status)) { if (snowTicket.change_status.ToLower() == "approved") { string subject = Utility.GetEmailSubjects(8, DateTime.UtcNow, snowTicket.change_request_id); string deploymentEventSescription = Utility.GetDeploymentEventSescriptions(4, snowTicket.change_request_id); if (Utility.UpdateSnowStatus(snowTicket.change_status, snowTicket.change_request_id, requester.snowId, 0, deploymentEventSescription,requester.RequesterId)) { Utility.SendEmail(requester.RequesterEmail, subject, Utility.GetEmailBodyApproved(snowTicket.change_request_id), requester.RequesterDisplayName); } } else if (snowTicket.change_status.ToLower() == "rejected") { CancelTicketAndRespondToUser(requester.RequesterId, snowTicket.change_request_id, Utility.VAL_APPROVER_REJECTED, snowTicket.start_date, requester); } else { if (daysLeft <= 0 && NoAprrovalCancelRequired <=1) { CancelTicketAndRespondToUser(requester.RequesterId, snowTicket.change_request_id, "", snowTicket.start_date, requester, false, snowTicket.Approvals); } else { string deploymentEventSescription = string.Empty; notification = GetNotification(daysLeft, emailNotification); if (notification) { string subject = Utility.GetEmailSubjects(9, DateTime.Now, snowTicket.change_request_id); deploymentEventSescription = Utility.GetDeploymentEventSescriptions(5,snowTicket.change_request_id); Utility.SendEmail(requester.RequesterEmail, subject, Utility.GetEmailBodyApprovalPending(snowTicket.change_request_id, snowTicket.start_date, daysLeft.ToString(), snowTicket.Approvals), requester.RequesterDisplayName); } Utility.UpdateSnowStatus(snowTicket.change_status, snowTicket.change_request_id, requester.snowId, (notification) ? daysLeft : 0, deploymentEventSescription,requester.RequesterId); } } } } }
/// <summary> /// /// </summary> /// <param name="response"></param> /// <returns></returns> private SnowTicket ParseWebResponse(WebResponse response) { SnowTicket result = new SnowTicket(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(response.GetResponseStream()); XmlNodeList Responses = xmlDoc.GetElementsByTagName(Utility.TAG_RESPONSE_PAYLOAD); if (Responses.Count > 1) { foreach (XmlNode xmlNode in Responses[1].ChildNodes) { SetObjectProperty(xmlNode.Name, xmlNode.InnerText, result); } result.IsSuccess = true; result.HostName = GetServersListFromSnow(xmlDoc); if (result.HostName != null && result.HostName.Count() > 0) { result.HostIds = GetServerIds(result.HostName); } } else if (Responses.Count > 0) { foreach (XmlNode xmlNode in Responses[0].ChildNodes) { SetObjectProperty(xmlNode.Name, xmlNode.InnerText, result); } result.IsSuccess = true; result.HostName = GetServersListFromSnow(xmlDoc); if (result.HostName != null && result.HostName.Count() > 0) { result.HostIds = GetServerIds(result.HostName); } //if (result.response_type == Utility.REQUEST_TYPE_TICKET_GET) //{ result.Approvals = GetApprovals(xmlDoc); //} } else { result.IsSuccess = false; XmlNodeList faults = xmlDoc.GetElementsByTagName("SOAP-ENV:Fault"); if (faults != null && faults.Count > 0) { foreach (XmlNode xmlNode in faults[0].ChildNodes) { if (xmlNode.Name == "faultcode") { result.Error_Code = xmlNode.InnerText; result.faultcode = xmlNode.InnerText; } else { result.Error_Message = xmlNode.InnerText; result.faultstring = xmlNode.InnerText; } } } } return result; }