public Response Bleed(BleedRequest Request) { Response oResponse = new Response(); LogManager.WriteLog("VaultService: Bleed -- Entered", LogManager.enumLogLevel.Info); try { StringWriter outStream = new StringWriter(); XmlSerializer s = new XmlSerializer(typeof(BleedRequest)); s.Serialize(outStream, Request); LogManager.WriteLog("VaultService: Bleed Xml" + outStream.ToString(), LogManager.enumLogLevel.Info); outStream.Close(); if (Request.EventID == 0) { oResponse.ErrCode = 1; oResponse.ErrDesc = "Invalid EventID "; } //else if (Request.DeviceID == 0) //{ // oResponse.ErrCode = 1; // oResponse.ErrDesc = "Invalid DeviceID"; //} else if (Request.DeviceName.IsNullOrEmpty()) { oResponse.ErrCode = 2; oResponse.ErrDesc = "Invalid Device Name"; } else if (Request.TotalTransactionAmount < 0) { oResponse.ErrCode = 4; oResponse.ErrDesc = "Invalid Amount(Must be greater than 0)"; } else if (Request.CassetteDetails == null || Request.CassetteDetails.Count == 0) { oResponse.ErrCode = 5; oResponse.ErrDesc = "cassette details not found"; } foreach (Cassette cte in Request.CassetteDetails) { if (cte.CassetteName.IsNullOrEmpty()) { oResponse.ErrCode = 6; oResponse.ErrDesc = "Cassette name invalid."; break; } if (cte.Denom == 0) { oResponse.ErrCode = 5; oResponse.ErrDesc = "Cassette denom invalid."; break; } if (cte.Amount == 0) { oResponse.ErrCode = 5; oResponse.ErrDesc = "cassette amount invalid."; break; } } if (oResponse.ErrCode != 0) { LogManager.WriteLog("Bleed Response: " + oResponse.ToString(), LogManager.enumLogLevel.Debug); return oResponse; } SqlParameter[] sqlParameters = new SqlParameter[4]; sqlParameters[0] = new SqlParameter("@EventId", Request.EventID); sqlParameters[1] = new SqlParameter("@EventDescription", "BLEEDWEBREQUEST"); sqlParameters[2] = new SqlParameter("@XML", outStream.ToString()); sqlParameters[3] = new SqlParameter("@Device", Request.DeviceSerialNumber); int retval = int.Parse(SqlHelper.ExecuteScalar(GetConnectionString(), CommandType.StoredProcedure, "usp_Vault_UpdateGenericMessage", sqlParameters).ToString()); if (retval > 0) { LogManager.WriteLog("Bleed Updated Successfully Device:" + Request.DeviceName + " Amount: " + Request.TotalTransactionAmount, LogManager.enumLogLevel.Info); } else { if (retval == -701) { oResponse.ErrCode = 701; oResponse.ErrDesc = "Vault not enrolled/invalid serial number"; } else if (retval == -702) { oResponse.ErrCode = 702; oResponse.ErrDesc = "Feature not enabled"; } else { oResponse.ErrCode = -100; oResponse.ErrDesc = "Unable to process request"; } LogManager.WriteLog("Bleed Updated Failed Asset:" + Request.DeviceName + " Amount: " + Request.TotalTransactionAmount, LogManager.enumLogLevel.Info); } } catch (Exception ex) { LogManager.WriteLog("Error in updating Bleed Info", LogManager.enumLogLevel.Error); ExceptionManager.Publish(ex); oResponse.ErrCode = -100; oResponse.ErrDesc = "Error Occured"; } LogManager.WriteLog("Bleed Response: " + oResponse.ToString(), LogManager.enumLogLevel.Debug); return oResponse; }
public Response Bleed(BleedRequest Request) { Response oResponse = new Response(); LogManager.WriteLog("VaultService: Bleed -- Entered", LogManager.enumLogLevel.Info); try { StringWriter outStream = new StringWriter(); XmlSerializer s = new XmlSerializer(typeof(BleedRequest)); s.Serialize(outStream, Request); LogManager.WriteLog("VaultService: Bleed Xml" + outStream.ToString(), LogManager.enumLogLevel.Info); outStream.Close(); if (Request.EventID == 0) { oResponse.ErrCode = 1; oResponse.ErrDesc = "Invalid EventID "; } //else if (Request.DeviceID == 0) //{ // oResponse.ErrCode = 1; // oResponse.ErrDesc = "Invalid DeviceID"; //} else if (Request.DeviceName.IsNullOrEmpty()) { oResponse.ErrCode = 2; oResponse.ErrDesc = "Invalid Device Name"; } else if (Request.TotalTransactionAmount < 0) { oResponse.ErrCode = 4; oResponse.ErrDesc = "Invalid Amount(Must be greater than 0)"; } else if (Request.CassetteDetails == null || Request.CassetteDetails.Count == 0) { oResponse.ErrCode = 5; oResponse.ErrDesc = "cassette details not found"; } foreach (Cassette cte in Request.CassetteDetails) { if (cte.CassetteName.IsNullOrEmpty()) { oResponse.ErrCode = 6; oResponse.ErrDesc = "Cassette name invalid."; break; } if (cte.Denom == 0) { oResponse.ErrCode = 5; oResponse.ErrDesc = "Cassette denom invalid."; break; } if (cte.Amount == 0) { oResponse.ErrCode = 5; oResponse.ErrDesc = "cassette amount invalid."; break; } } if (oResponse.ErrCode != 0) { LogManager.WriteLog("Bleed Response: " + oResponse.ToString(), LogManager.enumLogLevel.Debug); return(oResponse); } SqlParameter[] sqlParameters = new SqlParameter[4]; sqlParameters[0] = new SqlParameter("@EventId", Request.EventID); sqlParameters[1] = new SqlParameter("@EventDescription", "BLEEDWEBREQUEST"); sqlParameters[2] = new SqlParameter("@XML", outStream.ToString()); sqlParameters[3] = new SqlParameter("@Device", Request.DeviceSerialNumber); int retval = int.Parse(SqlHelper.ExecuteScalar(GetConnectionString(), CommandType.StoredProcedure, "usp_Vault_UpdateGenericMessage", sqlParameters).ToString()); if (retval > 0) { LogManager.WriteLog("Bleed Updated Successfully Device:" + Request.DeviceName + " Amount: " + Request.TotalTransactionAmount, LogManager.enumLogLevel.Info); } else { if (retval == -701) { oResponse.ErrCode = 701; oResponse.ErrDesc = "Vault not enrolled/invalid serial number"; } else if (retval == -702) { oResponse.ErrCode = 702; oResponse.ErrDesc = "Feature not enabled"; } else { oResponse.ErrCode = -100; oResponse.ErrDesc = "Unable to process request"; } LogManager.WriteLog("Bleed Updated Failed Asset:" + Request.DeviceName + " Amount: " + Request.TotalTransactionAmount, LogManager.enumLogLevel.Info); } } catch (Exception ex) { LogManager.WriteLog("Error in updating Bleed Info", LogManager.enumLogLevel.Error); ExceptionManager.Publish(ex); oResponse.ErrCode = -100; oResponse.ErrDesc = "Error Occured"; } LogManager.WriteLog("Bleed Response: " + oResponse.ToString(), LogManager.enumLogLevel.Debug); return(oResponse); }