Пример #1
0
        // GET: api/DOJSubmit
        public aggregate GetAggregate(int ID)
        {
            aggregate allAggregates = new aggregate();

            if (ID == 0)
            {
                Submissions submittedRec = entitiesdb.Submissions
                                           .Where(x => x.Status == "In Progress")
                                           .OrderByDescending(x => x.ID)
                                           .Select(x => x).FirstOrDefault();
                if (submittedRec != null)
                {
                    allAggregates.submissionID = submittedRec.ID;
                    ID = submittedRec.ID;
                }
            }


            if (ID != 0)
            {
                Submissions submission = entitiesdb.Submissions.Find(ID);
                allAggregates.submissionID = ID;
                if (submission != null)
                {
                    allAggregates.processedCount = Convert.ToInt32(submission.TotalProcessed);
                    allAggregates.succeededCount = Convert.ToInt32(submission.TotalSuccess);
                    allAggregates.fatalCount     = Convert.ToInt32(submission.TotalRejected);
                    allAggregates.failedCount    = Convert.ToInt32(submission.TotalWithErrors);
                    allAggregates.httpErrCount   = Convert.ToInt32(submission.TotalHTTPErrors);
                }
            }

            return(allAggregates);
        }
Пример #2
0
        public static async Task <Dictionary <string, aggregate> > Operations()
        {
            string[] datafile = await Reader(@"../../../../AggregateGDPPopulation/data/datafile.csv");

            string[] mapper = await Reader(@"../../../../AggregateGDPPopulation/data/cc-mapping.txt");

            //string[][] temp1 = await Task<string[]>.WhenAll(Reader(@"../../../../AggregateGDPPopulation/data/datafile.csv"), Reader(@"../../../../AggregateGDPPopulation/data/cc-mapping.txt"));
            //string[] datafile = temp1[0];
            //string[] mapper = temp1[1];
            string[]   header = (datafile[0].Replace("\"", "")).Split(',');
            string[][] map    = new string[mapper.Length - 1][];
            Console.WriteLine(mapper.Length);
            //Console.Write(map[0][0]);
            for (int i = 0; i < mapper.Length - 1; i++)
            {
                map[i] = mapper[i].Split(',');
                //Console.WriteLine("new item added - " + mapper[i]);
            }

            //Console.WriteLine(count);
            Dictionary <string, string> countryContinent = new Dictionary <string, string>();

            countryContinent = map.ToDictionary(sr => sr[0], sr => sr[1]);
            //foreach (string[] a in map)
            //{
            //   countryContinent.Add(a[0], a[1]);
            //}
            int cI                  = Array.IndexOf(header, "Country Name");
            int gdp2012Index        = Array.IndexOf(header, "GDP Billions (USD) 2012");
            int population2012Index = Array.IndexOf(header, "Population (Millions) 2012");
            Dictionary <string, aggregate> output = new Dictionary <string, aggregate>();

            for (int i = 1; i < datafile.Length; i++)
            {
                if (datafile[i].Length > 1)
                {
                    var       row        = datafile[i].Split(',');
                    string    country    = row[cI].Replace("\"", "");
                    double    population = Convert.ToDouble(row[population2012Index].Replace("\"", ""));
                    double    gdp        = Convert.ToDouble(row[gdp2012Index].Replace("\"", ""));
                    aggregate temp       = new aggregate();
                    if (country != "European Union")
                    {
                        if (output.ContainsKey(countryContinent[country]))
                        {
                            output[countryContinent[country]].GDP_2012        += gdp;
                            output[countryContinent[country]].POPULATION_2012 += population;
                        }
                        else
                        {
                            temp.GDP_2012        = gdp;
                            temp.POPULATION_2012 = population;
                            output.Add(countryContinent[country], temp);
                        }
                    }
                }
            }
            return(output);
        }
 DoAssertEvents(aggregate, action, stateAssertion, loadEventsOnly,
                expectedEvents
                .Select <(DomainAggregateEvent ev, Action <DomainAggregateEvent, DomainAggregateEvent> eventAssertion),