/// <summary> /// Metodo encargado para extraer informacion de los surtidores calculados en el controlador, /// tratarlo en el controller y mandarlo para realizar un json final. /// </summary> /// <param name="host"></param> /// <param name="posId"></param> /// <param name="maquina"></param> /// <returns></returns> public IList <FuellingPointData> GetFuellingPoinsDataDOMS(string host, string posId, string maquina) { try { _DOMSSemaphore.Wait(); Logger.Log("Entrada", new { host, posId, maquina }); var ret = new List <FuellingPointData>(); // BLOQUE CRITICO _connectToDOMS(host, posId, maquina); Logger.Log("Llamada Forecourt.EventsDisabled"); Forecourt.EventsDisabled = false; FuellingPointCollection fpCollection = GetFuellingPointCollection(); Logger.Log("Llamada IFCConfig.FuellingPoints con exito.", fpCollection); GradeCollection gcGrade = GetGradeCollection(); Logger.Log("Llamada IFCConfig.Grades con exito", gcGrade); // MX- Se coloca la Interfaz de la invocacion del Fuelling para el Objeto. foreach (FuellingPoint fuellingPoint in fpCollection) { FuellingPointTotals fptPunto = fuellingPoint.Totals[FpTotalTypes.GT_FUELLING_POINT_TOTAL]; GradeTotalCollection gradeTotals = GetGradeTotalCollection(fptPunto); Logger.Log("Llamada GradeTotals con exito.", gradeTotals); foreach (GradeTotal gradeTotal in gradeTotals) { ret.Add(new FuellingPointData { FuellingPointID = fuellingPoint.Id, GrandVolTotal = Convert.ToDecimal(fptPunto.GrandVolTotal), GrandMoneyTotal = Convert.ToDecimal(fptPunto.GrandMoneyTotal), GradeID = gradeTotal.GradeId, GradeTotal = gcGrade.Item[gradeTotal.GradeId].Text, GradeVolTotal = Convert.ToDecimal(gradeTotal.GradeVolTotal) }); } } Logger.Log("Salida", ret); return(ret); } catch (Exception e) { Logger.LogException(e); throw; } finally { _performDisconnect(); _DOMSSemaphore.Release(); } }
/// <summary> /// Obtiene los FuellingPointCollection desde IFC. /// Se debe llamar desde un bloque critico. /// Realizara una serie de intentos para obtener la lectura, si no lo consigue fallará /// </summary> /// <returns></returns> private FuellingPointCollection GetFuellingPointCollection() { for (int i = 0; i < Configuration.MaxAttemptsToReadFuellingPoints; i++) { Logger.Log($"Intento {i + 1} de lectura FuellingPointCollection"); FuellingPointCollection ret = IFCConfig.FuellingPoints; if (ret.Count > 0) { return(ret); } Logger.Log($"Intento {i + 1} de lectura FuellingPointCollection con resultado vacio. Paramos hilo {Configuration.SleepingMillisecondsBetweenAttempsToReadFuellingPoints} ms"); System.Threading.Thread.CurrentThread.Join(Configuration.SleepingMillisecondsBetweenAttempsToReadFuellingPoints); } throw new InvalidOperationException($"No se ha recuperado FuellingPointCollection tras {Configuration.MaxAttemptsToReadFuellingPoints} intentos"); }