Esempio n. 1
0
        private async Task AddItem(Record pItem, ConcurrentDictionary <string, GeoZone> pDicToComplete, int pDataId)
        {
            GeoZone   oGeoZone;
            CoVidData oCoviData;

            if (!pDicToComplete.ContainsKey(pItem.geoId))
            {
                oGeoZone            = new GeoZone();
                oGeoZone.geoID      = pItem.geoId;
                oGeoZone.code       = pItem.countryterritoryCode;
                oGeoZone.dataList   = new ConcurrentBag <CoVidData>();
                oGeoZone.name       = pItem.countriesAndTerritories;
                oGeoZone.population = pItem.popData2019;

                pDicToComplete.GetOrAdd(pItem.geoId, oGeoZone);
            }

            oCoviData = new CoVidData();

            oCoviData.cases = pItem.cases;
            oCoviData.date  = new CovidDate(
                ulong.Parse(pDataId.ToString()),
                pItem.dateRep,
                UtilsConstants.StringConstants.RIGHT_BAR, UtilsConstants.DateConstants.API_DATE_FORMAT);
            oCoviData.deaths = pItem.deaths;
            pDicToComplete[pItem.geoId].dataList.Add(oCoviData);
        }
Esempio n. 2
0
        private void SetCovidDataQuery(CoVidData pCovidData, GeoZone pGeoZone, Query oQuery)
        {
            StringBuilder oStringBuilder = new StringBuilder();

            this.AddCovidDataInsertStatementToStringBuilder(oStringBuilder, pCovidData, pGeoZone, oQuery);
            oQuery.query = oQuery.query.Replace(
                UtilsConstants.QueryConstants.REPLACE_QUERY_CONSTANT, oStringBuilder.ToString());
        }
Esempio n. 3
0
        public bool InsertCovidData(CoVidData pCovidData, GeoZone pGeoZone)
        {
            Query oQuery;

            this.SetQuery(_INSERT_DATES_QUERY_PATH, out oQuery);
            oQuery.query = oQuery.query.Replace(UtilsConstants.QueryConstants.COUNTRY_NAME, pGeoZone.name);
            this.SetCovidDataQuery(pCovidData, pGeoZone, oQuery);

            return(oConnectionPostgreSql.ExecuteCommand(oQuery.query));
        }
Esempio n. 4
0
        public override bool InsertCovidData(CoVidData pCovidData, GeoZone pGeoZone)
        {
            ConnectionPostgreSql oConnection;

            this.SetConnection(out oConnection);

            _oPostgreSqlInsert = PostgreSqlInsert.GetInstance(oConnection);

            _oPostgreSqlInsert.InsertCovidData(pCovidData, pGeoZone);

            return(true);
        }
Esempio n. 5
0
 private void AddCovidDataInsertStatementToStringBuilder(
     StringBuilder oStringBuilder,
     CoVidData oCovidData,
     GeoZone pGeoZone,
     Query oQuery)
 {
     oStringBuilder.Append(
         oQuery.valuesFormat.Replace(
             UtilsConstants.QueryConstants.ZERO_STRING,
             string.Join(
                 string.Empty,
                 UtilsConstants.StringConstants.REPLACE_SINGLEQUOTE_CONSTANT,
                 oCovidData.id.ToString(),
                 UtilsConstants.StringConstants.REPLACE_SINGLEQUOTE_CONSTANT)));
     oStringBuilder.Replace(
         UtilsConstants.QueryConstants.ONE_STRING,
         string.Join(
             string.Empty,
             UtilsConstants.StringConstants.REPLACE_SINGLEQUOTE_CONSTANT,
             Utils.UtilsJSON.GetInstance().Serialize(oCovidData),
             UtilsConstants.StringConstants.REPLACE_SINGLEQUOTE_CONSTANT));
 }
Esempio n. 6
0
 public abstract bool InsertCovidData(CoVidData pCovidData, GeoZone pGeoZone);