public ResponseService Check(List <Field> Fields) { List <Field> Respuesta = new List <Field>(); ResponseService R_Service = new ResponseService(); Class_TN TN = new Class_TN(); bool Datos = false; foreach (var item in Fields) { if ((item.Name == "ID_Product") && (item.Value.ToString() != "")) { Datos = true; } } return(TN.TN_Query(Fields, Datos, Url, User, Password)); //TN Consulta if (!IsConfigured) { throw new Exception(); } return(new ResponseService()); }
public ResponseService Request(List <Field> Fields) { List <Field> Respuesta = new List <Field>(); ResponseService R_Service = new ResponseService(); Class_TN TN = new Class_TN(); string service = "getReloadClass"; string response = "ReloadResponse"; bool Datos = false; foreach (var item in Fields) { if ((item.Name == "ID_Product") && (item.Value.ToString() != "")) { service = "getReloadData"; response = "DataResponse"; Datos = true; } } string[] credentials = new string[] { Url, User, Password }; var task = Task.Run(() => { return(TN.Send_Request(service, credentials, Fields)); }); try { var success = task.Wait(50000); if (!success) { return(TN.TN_Query(Fields, Datos, Url, User, Password)); } else { R_Service.XML = TN.Response_Xml(task.Result, service + "Result", response); Respuesta = TN.Response_Fields(R_Service.XML); R_Service.Fields = Fields.Union(Respuesta).ToList(); foreach (var item in Respuesta) { if (item.Name == "Response_ResponseCode") { R_Service.ResponseCode = Convert.ToInt32(item.Value); } if (item.Name == "Response_AutoNo") { R_Service.AuthorizeCode = Convert.ToInt32(item.Value); } } } } catch (AggregateException ex) { throw ex.InnerException; } if (R_Service.ResponseCode == 6 || R_Service.ResponseCode == 71) { //RealizaConsulta return(TN.TN_Query(Fields, Datos, Url, User, Password)); } else if (R_Service.ResponseCode == 0) { R_Service.Success = true; } return(R_Service); if (!IsConfigured) { throw new Exception(); } return(new ResponseService()); }