Пример #1
0
        /// <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();
            }
        }
Пример #2
0
        /// <summary>
        /// Obtiene los GradeCollection 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 GradeTotalCollection GetGradeTotalCollection(FuellingPointTotals fptPunto)
        {
            for (int i = 0; i < Configuration.MaxAttemptsToReadGradeTotals; i++)
            {
                Logger.Log($"Intento {i + 1} de lectura GradeTotals");
                GradeTotalCollection ret = fptPunto.GradeTotals;
                if (ret.Count > 0)
                {
                    return(ret);
                }
                Logger.Log($"Intento {i + 1} de lectura GradeTotals con resultado vacio. Paramos hilo {Configuration.SleepingMillisecondsBetweenAttempsToReadGradeTotals} ms");

                System.Threading.Thread.CurrentThread.Join(Configuration.SleepingMillisecondsBetweenAttempsToReadGradeTotals);
            }
            throw new InvalidOperationException($"No se ha recuperado GradeTotals tras {Configuration.MaxAttemptsToReadGradeTotals} intentos");
        }