Exemplo n.º 1
0
        public void run()
        {
            while (!Complete)
            {
                var item = workQueue.dequeueItem();

                if (!ReferenceEquals(null, item))
                {
                    Constituency constituency = item.ProcessData();
                    if (!ReferenceEquals(null, constituency))
                    {
                        lock (constitlist)
                        {
                            constitlist.constituencyList.Add(constituency);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Consumer:{0} has rejected Work Item:{1}", id, item.recordConfig.ToString());
                    }
                    Thread.Sleep(duration);
                    progMan.ItemsLeft--;
                }
            }
            ThreadsRunning--;
        }
        public Constituency ReadDataFromFile(RecordConfig configRecord)
        {
            if (!File.Exists(configRecord.file))
            {
                return(null);
            }

            XDocument xmlDoc           = XDocument.Load(configRecord.file);
            var       constituencyName = (from c in xmlDoc.Descendants("Constituency")
                                          select c.Attribute("name").Value).First();

            Constituency constit = new Constituency(constituencyName);

            constit.ReportPartyWin = new Report("OverallWinner");
            constit.ReportPartyWin.TotalVotesDataMeasure = SelectDataMeasuresConstituency(xmlDoc, constit.ConstituencyName);

            return(constit);
        }
Exemplo n.º 3
0
 public Work(RecordConfig recordconfig, IFileReader IOHandler)
 {
     constituency      = null;
     this.recordConfig = recordconfig;
     this.IOHandler    = IOHandler;
 }