public static ReportingUnit BuildReportingUnit(string type, string value)
        {
            ReportingUnit rr = new ReportingUnit();

            rr.Name = value;
            if (type == "congressional")
            {
                rr.Type = ReportingUnitType.congressional;
            }
            if (type == "county")
            {
                rr.Type = ReportingUnitType.county;
            }
            if (type == "precinct")
            {
                rr.Type = ReportingUnitType.precinct;
            }
            if (type == "state-house")
            {
                rr.Type = ReportingUnitType.statehouse;
            }
            if (type == "state-senate")
            {
                rr.Type = ReportingUnitType.statesenate;
            }
            if (type == "split-precinct")
            {
                rr.Type = ReportingUnitType.splitprecinct;
            }

            return(rr);
        }
Exemple #2
0
        public List <ReportingUnit> GetReportingUnit(string language)
        {
            List <ReportingUnit> theList = new List <ReportingUnit>();
            ReportingUnit        theData = null;

            try
            {
                ReportingUnitDS.ReportingUnitsDataTable theTable = theAdapter.GetReportingUnits(language);

                if (theTable != null && theTable.Rows.Count > 0)
                {
                    foreach (ReportingUnitDS.ReportingUnitsRow theRow in theTable.Rows)
                    {
                        theData = FillRecord(theRow);
                        theList.Add(theData);
                    }
                }
            }
            catch (Exception exc)
            {
                log.Error("Ocurrió un error al obtener la lista de ReportingUnits de la Base de Datos", exc);
                throw exc;
            }

            return(theList);
        }
Exemple #3
0
        public ReportingUnit GetReportingUnitByID(string reportingUnitID, string language)
        {
            if (string.IsNullOrEmpty(reportingUnitID))
            {
                throw new ArgumentException("El ID no puede ser <= 0.");
            }

            if (string.IsNullOrEmpty(language))
            {
                language = Artexacta.App.Utilities.LanguageUtilities.GetLanguageFromContext();
            }

            ReportingUnit theData = null;

            try
            {
                ReportingUnitDS.ReportingUnitsDataTable theTable = theAdapter.GetReportingUnitById(reportingUnitID, language);

                if (theTable != null && theTable.Rows.Count > 0)
                {
                    ReportingUnitDS.ReportingUnitsRow theRow = theTable[0];
                    theData = FillRecord(theRow);
                }
            }
            catch (Exception exc)
            {
                log.Error("Error en GetReportingUnitByID para reportingUnitID: " + reportingUnitID + " y language: " + language, exc);
                throw exc;
            }

            return(theData);
        }
Exemple #4
0
        private static ReportingUnit FillRecord(ReportingUnitDS.ReportingUnitsRow row)
        {
            ReportingUnit theNewRecord = new ReportingUnit(
                row.reportingUnitID,
                row.name);

            return(theNewRecord);
        }
Exemple #5
0
        private void GivenReportingUnits()
        {
            var brazil      = new Countries(this.session).CountryByIsoCode["br"];
            var southAfrica = new Countries(this.session).CountryByIsoCode["sa"];

            var gwg = new BusinessUnits(this.session).GWG;
            var git = new BusinessUnits(this.session).GIT;

            this.Guarulhos =
                new ReportingUnitBuilder(this.session).WithExternalPrimaryKey(31)
                .WithAbbreviation("GRU")
                .WithName("Guarulhos")
                .WithCountry(brazil)
                .WithBusinessUnit(gwg)
                .WithPerson(this.Person1)
                .Build();
            this.JohannesburgIT =
                new ReportingUnitBuilder(this.session).WithExternalPrimaryKey(64)
                .WithAbbreviation("JOH")
                .WithName("Johannesburg -IT")
                .WithCountry(southAfrica)
                .WithBusinessUnit(git)
                .WithPerson(this.Person1)
                .Build();

            //Child reporting units.
            this.GuarulhosPassCar =
                new ReportingUnitBuilder(this.session).WithExternalPrimaryKey(54)
                .WithAbbreviation("GRP")
                .WithName("Guarulhos Pass Car")
                .WithCountry(brazil)
                .WithParent(this.Guarulhos)
                .WithBusinessUnit(gwg)
                .WithPerson(this.Person1)
                .Build();
            this.GuarulhosTruck =
                new ReportingUnitBuilder(this.session).WithExternalPrimaryKey(55)
                .WithAbbreviation("GRT")
                .WithName("Guarulhos Truck")
                .WithCountry(brazil)
                .WithParent(this.Guarulhos)
                .WithBusinessUnit(gwg)
                .WithPerson(this.Person1)
                .Build();
        }