Пример #1
0
        static void Main(string[] args)
        {
            if (Properties.Settings.Default.forceNonParallel)
            {
                options = new ParallelOptions {
                    MaxDegreeOfParallelism = -1
                };
            }
            else
            {
                if (Properties.Settings.Default.MaxThreads < 2)
                {
                    options = new ParallelOptions {
                        MaxDegreeOfParallelism = 1
                    };
                }
                else
                {
                    options = new ParallelOptions {
                        MaxDegreeOfParallelism = Properties.Settings.Default.MaxThreads
                    };
                }
            }

            List <MOE.Common.Models.Signal> signalsDT;

            MOE.Common.Models.SPM db = new MOE.Common.Models.SPM();
            using (db)
            {
                signalsDT = (from s in db.Signals
                             where s.ControllerTypeID == 4
                             select s).ToList();
            }



            Parallel.ForEach(signalsDT, options, row =>
                             //foreach (var row in signalsDT )
            {
                if (TestIPAddress(row))
                {
                    string signalId = row.SignalID;

                    Console.WriteLine("Starting signal" + signalId);

                    MOE.Common.Business.MaxTimeHDLogClient client = new MOE.Common.Business.MaxTimeHDLogClient();

                    XmlDocument xml = client.GetSince(row.IPAddress, GetMostRecentRecordTime(signalId));

                    SaveToDB(xml, signalId);

                    Console.WriteLine("Finished signal" + signalId);
                }
            }
                             );
        }
Пример #2
0
        static void Main(string[] args)
        {
            if (Properties.Settings.Default.forceNonParallel)
            {
                options = new ParallelOptions {
                    MaxDegreeOfParallelism = -1
                };
            }
            else
            {
                if (Properties.Settings.Default.MaxThreads < 2)
                {
                    options = new ParallelOptions {
                        MaxDegreeOfParallelism = 1
                    };
                }
                else
                {
                    options = new ParallelOptions {
                        MaxDegreeOfParallelism = Properties.Settings.Default.MaxThreads
                    };
                }
            }

            MOE.Common.Models.Repositories.ISignalsRepository sr =
                MOE.Common.Models.Repositories.SignalsRepositoryFactory.Create();

            List <MOE.Common.Models.Signal> signalsDT = sr.GetLatestVerionOfAllSignalsByControllerType(4);



            Parallel.ForEach(signalsDT, options, row =>
                             //foreach (var row in signalsDT )
            {
                if (TestIPAddress(row))
                {
                    string signalId = row.SignalID;

                    Console.WriteLine("Starting signal" + signalId);

                    MOE.Common.Business.MaxTimeHDLogClient client = new MOE.Common.Business.MaxTimeHDLogClient();

                    XmlDocument xml = client.GetSince(row.IPAddress, GetMostRecentRecordTime(signalId));

                    SaveToDB(xml, signalId);

                    Console.WriteLine("Finished signal" + signalId);
                }
            }
                             );
        }