示例#1
0
        public List <County> GetCounties()
        {
            List <County> fin = new List <County>();
            County        tmpCounty;
            int           active, deaths;

            foreach (DateTime theDate in TimeLine["cases"].Keys)
            {
                active = TimeLine["cases"][theDate];
                deaths = TimeLine["deaths"].ContainsKey(theDate) ? TimeLine["deaths"][theDate] : -1;
                // tmpCounty = new County(this.Province, this.County, theDate, active, deaths);
                // fin.Add(tmpCounty);

                // // tmpCounty = new County();
                // // tmpCounty.Province_State = this.Province;
                // // tmpCounty.Name = this.County;
                // // tmpCounty.Active = active;
                // // tmpCounty.Deaths = deaths;

                fin.Add(new County(Program.FixTheCase(this.Province), Program.FixTheCase(this.County), theDate, active, deaths));
            }
            /* Pretty sure this'll never happen, but handle deaths with no corresponding active entry */
            foreach (DateTime theDate in TimeLine["deaths"].Keys)
            {
                /* Filter out recs we've already handled. */
                if (fin.Where(x => x.Last_Update.Date == theDate.Date).Count() > 0)
                {
                    continue;
                }
                active    = -1; //If this had a matching active entry it would've hit that continue.
                deaths    = TimeLine["deaths"][theDate];
                tmpCounty = new County(this.Province, this.County, theDate, active, deaths);

                // tmpCounty = new County();
                // tmpCounty.Province_State = this.Province;
                // tmpCounty.Name = this.County;
                // tmpCounty.Active = active;
                // tmpCounty.Deaths = deaths;

                fin.Add(tmpCounty);
            }
            return(fin);
        }
示例#2
0
        public Record(County guy)
        {
            double tmpDubs;

            this.FIPS           = guy.FIPS;
            this.Country        = string.IsNullOrEmpty(guy.Country_Region) ? "" : guy.Country_Region;
            this.Province_State = string.IsNullOrEmpty(guy.Province_State) ? "" : guy.Province_State;
            this.County         = string.IsNullOrEmpty(guy.Name) ? "" : guy.Name;
            this.Last_Update    = guy.Last_Update;
            this.Confirmed      = guy.Confirmed;
            this.Deaths         = guy.Deaths;
            this.Recovered      = guy.Recovered;
            this.Active         = guy.Active;
            this.Combined_Key   = guy.Combined_Key;

            if (double.TryParse(guy.Lat, out tmpDubs))
            {
                this.Lat = tmpDubs;
            }
            else
            {
                this.Lat = null;
            }
            if (double.TryParse(guy.Long, out tmpDubs))
            {
                this.Long = tmpDubs;
            }
            else
            {
                this.Long = null;
            }
            if (double.TryParse(guy.Incidence_Rate, out tmpDubs))
            {
                this.Incidence_Rate = tmpDubs;
            }
            else
            {
                this.Incidence_Rate = null;
            }
        }