Ejemplo n.º 1
0
        private void buildGradeDropdown()
        {
            int  selectedSeriesID = ControlUtility.GetDropdownValue(this.dropdownSeries);
            bool isEmpty          = selectedSeriesID == -1;

            GradeCollection gradeList = LookupWrapper.GetAllGrades(false);

            ControlUtility.BindRadComboBoxControl(this.dropdownHighestAdvertisedGrade, gradeList, null, "GradeName", "GradeID", "[-- Select High Grade --]");

            // remove other from list
            if (gradeList.Count > 0 && gradeList.Contains("Other"))
            {
                gradeList.RemoveAt(gradeList.Count - 1);
            }

            GradeCollection lowGradeList = new GradeCollection();

            lowGradeList.AddRange(gradeList);

            // remove highest grade from list and bind as Low Grade List
            if (lowGradeList.Count > 0)
            {
                lowGradeList.RemoveAt(lowGradeList.Count - 1);
            }

            ControlUtility.BindRadComboBoxControl(this.dropdownLowestAdvertisedGrade, lowGradeList, null, "GradeName", "GradeID", "[-- Select Low Grade --]");

            // position descriptions
            buildPositionDescriptionList();

            // build JNP Template list
            buildJNPTemplateList();
        }
Ejemplo n.º 2
0
        public void GivenAStudenHasGradesThenTheCalculatorShouldCalculateAverageCorrectly()
        {
            var student1 = new Student()
            {
                Naam = "Bozo"
            };

            var student2 = new Student()
            {
                Naam = "Victor"
            };

            float expectedAverageStudent1 = (5f + 10f) / 2;
            float expectedAverageStudent2 = (8f + 5f) / 2;

            var gradeCollection = new GradeCollection();

            gradeCollection.AddGrade(CreateGrade(student1, 5f));
            gradeCollection.AddGrade(CreateGrade(student1, 10f));
            gradeCollection.AddGrade(CreateGrade(student2, 8f));
            gradeCollection.AddGrade(CreateGrade(student2, 5f));

            var actualAverageStudent1 = AverageCalculator.CalculateMeanAverage(gradeCollection.GetGradesForStudent(student1));
            var actualAverageStudent2 = AverageCalculator.CalculateMeanAverage(gradeCollection.GetGradesForStudent(student2));

            Assert.AreEqual(expectedAverageStudent1, actualAverageStudent1, 0.001f);
            Assert.AreEqual(expectedAverageStudent2, actualAverageStudent2, 0.002f);
        }
Ejemplo n.º 3
0
        public void GivenTheSameGradeIsAddedTwiceToCollectionThenCollectionThrowsArgumentException()
        {
            GradeCollection collection = new GradeCollection();
            var             grade      = CreateGrade();

            collection.AddGrade(grade);
            collection.AddGrade(grade);
        }
Ejemplo n.º 4
0
        public void GivenAddGradeCollectionHasGrade()
        {
            var gradeCollection = new GradeCollection();
            var grade           = CreateGrade();

            Assert.AreEqual(0, gradeCollection.Count);
            gradeCollection.AddGrade(grade);
            Assert.AreEqual(1, gradeCollection.Count);
        }
Ejemplo n.º 5
0
        public void GivenClearCollectionThenGradeCollectionIsEmpty()
        {
            var grade           = CreateGrade();
            var gradeCollection = new GradeCollection();

            Assert.AreEqual(0, gradeCollection.Count);
            gradeCollection.AddGrade(grade);
            Assert.AreEqual(1, gradeCollection.Count);
            gradeCollection.Clear();
            Assert.AreEqual(0, gradeCollection.Count);
        }
Ejemplo n.º 6
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();
            }
        }
Ejemplo n.º 7
0
        private void bindFPLAndCurrentGrade()
        {
            GradeCollection gradeList = LookupWrapper.GetAllGrades(false);
            //3580:Add New WFP: FPL and Current Grade Drop down - remove 100 from the option
            Grade othergrade = new Grade();

            othergrade.GradeID = 100;
            gradeList.Remove(othergrade);
            ControlUtility.BindRadComboBoxControl(this.dropDownFPLGrades, gradeList, null, "GradeID", "GradeID", "<<-- Select FPL -->>");
            ControlUtility.BindRadComboBoxControl(this.dropDownCurrentGrades, gradeList, null, "GradeID", "GradeID", "<<-- Select Current Grade -->>");
        }
Ejemplo n.º 8
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 GradeCollection GetGradeCollection()
        {
            for (int i = 0; i < Configuration.MaxAttemptsToReadGrades; i++)
            {
                Logger.Log($"Intento {i + 1} de lectura GradeCollection");
                GradeCollection ret = IFCConfig.Grades;
                if (ret.Count > 0)
                {
                    return(ret);
                }
                Logger.Log($"Intento {i + 1} de lectura GradeCollection con resultado vacio. Paramos hilo {Configuration.SleepingMillisecondsBetweenAttempsToReadGrades} ms");

                System.Threading.Thread.CurrentThread.Join(Configuration.SleepingMillisecondsBetweenAttempsToReadGrades);
            }
            throw new InvalidOperationException($"No se ha recuperado GradeCollection tras {Configuration.MaxAttemptsToReadGrades} intentos");
        }
Ejemplo n.º 9
0
        internal static GradeCollection GetCollection(DataTable dataItems)
        {
            GradeCollection listCollection = new GradeCollection();
            Grade           current        = null;

            if (dataItems != null)
            {
                for (int i = 0; i < dataItems.Rows.Count; i++)
                {
                    current = new Grade(dataItems.Rows[i]);
                    listCollection.Add(current);
                }
            }
            else
            {
                throw new Exception("You cannot create a Grade collection from a null data table.");
            }

            return(listCollection);
        }
Ejemplo n.º 10
0
        public GradeCollection GetGrades()
        {
            GradeCollection childDataCollection = null;

            if (base.ValidateKeyField(this._seriesID))
            {
                try
                {
                    DataTable dt = ExecuteDataTable("spr_GetGradesByseriesID", this._seriesID);

                    // fill collection list
                    childDataCollection = Grade.GetCollection(dt);
                }
                catch (Exception ex)
                {
                    HandleException(ex);
                }
            }

            return(childDataCollection);
        }
Ejemplo n.º 11
0
        public void GivenANullIsAddedToCollectionThenCollectionThrowsArgumentNullException()
        {
            GradeCollection collection = new GradeCollection();

            collection.AddGrade(null);
        }