public void Initialize()
        {
            Db.ClearTables();
            Db.PopulateSignal();
            Db.PopulateSignalsWithApproaches();
            Db.PopulateApproachesWithDetectors();
            var signals = Db.Signals;

            foreach (var signal in signals)
            {
                foreach (var approach in signal.Approaches)
                {
                    Db.PopulateApproachSplitFailAggregationsWithRandomRecords(Convert.ToDateTime("1/1/2016"),
                                                                              Convert.ToDateTime("1/1/2018"), approach);
                }
            }
            ApproachSplitFailAggregationRepositoryFactory.SetApplicationEventRepository(
                new InMemoryApproachSplitFailAggregationRepository(Db));
            MOE.Common.Models.Repositories.SignalsRepositoryFactory.SetSignalsRepository(
                new InMemorySignalsRepository(Db));
            MetricTypeRepositoryFactory.SetMetricsRepository(new InMemoryMetricTypeRepository(Db));
            ApplicationEventRepositoryFactory.SetApplicationEventRepository(new InMemoryApplicationEventRepository(Db));
            Models.Repositories.DirectionTypeRepositoryFactory.SetDirectionsRepository(
                new InMemoryDirectionTypeRepository());
            SignalsRepository = SignalsRepositoryFactory.Create();
        }
Esempio n. 2
0
        public void Initialize()
        {
            Db.ClearTables();
            Db.PopulateSignal();
            Db.PopulateSignalsWithApproaches();
            Db.PopulateApproachesWithDetectors();
            var signals = Db.Signals;

            foreach (var signal in signals)
            {
                Db.PopulatePreemptAggregations(Convert.ToDateTime("1/1/2016"), Convert.ToDateTime("1/1/2018"), signal.SignalID, signal.VersionID);
            }

            ApproachRepositoryFactory.SetApproachRepository(new InMemoryApproachRepository(Db));
            PreemptAggregationDatasRepositoryFactory.SetArchivedMetricsRepository(
                new InMemoryPreemptAggregationDatasRepository(Db));
            MOE.Common.Models.Repositories.SignalsRepositoryFactory.SetSignalsRepository(
                new InMemorySignalsRepository(Db));
            MetricTypeRepositoryFactory.SetMetricsRepository(new InMemoryMetricTypeRepository(Db));
            ApplicationEventRepositoryFactory.SetApplicationEventRepository(new InMemoryApplicationEventRepository(Db));
            DetectorAggregationsRepositoryFactory.SetDetectorAggregationRepository(new InMemoryDetectorAggregationsRepository(Db));

            Models.Repositories.DirectionTypeRepositoryFactory.SetDirectionsRepository(
                new InMemoryDirectionTypeRepository());

            SignalsRepository = SignalsRepositoryFactory.Create();

            PreemptAggregationDatasRepositoryFactory.SetArchivedMetricsRepository(new InMemoryPreemptAggregationDatasRepository(Db));
        }
        public double GetTmcVolume(DateTime startDate, DateTime endDate, string signalId, int phase)
        {
            ISignalsRepository repository =
                SignalsRepositoryFactory.Create();
            var             signal         = repository.GetVersionOfSignalByDate(signalId, startDate);
            List <Detector> graphDetectors = signal.GetDetectorsForSignalByPhaseNumber(phase);

            List <int> tmcChannels = new List <int>();

            foreach (Detector gd in graphDetectors)
            {
                foreach (DetectionType dt in gd.DetectionTypes)
                {
                    if (dt.DetectionTypeID == 4)
                    {
                        tmcChannels.Add(gd.DetChannel);
                    }
                }
            }



            double count = (from cel in _db.Controller_Event_Log
                            where cel.Timestamp >= startDate &&
                            cel.Timestamp < endDate &&
                            cel.SignalID == signalId &&
                            tmcChannels.Contains(cel.EventParam) &&
                            cel.EventCode == 82
                            select cel).Count();

            return(count);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            IApplicationEventRepository errorRepository  = ApplicationEventRepositoryFactory.Create();
            SignalFtpOptions            signalFtpOptions = new SignalFtpOptions(
                Convert.ToInt32(ConfigurationManager.AppSettings["SNMPTimeout"]),
                Convert.ToInt32(ConfigurationManager.AppSettings["SNMPRetry"]),
                Convert.ToInt32(ConfigurationManager.AppSettings["SNMPPort"]),
                Convert.ToBoolean(ConfigurationManager.AppSettings["DeleteFilesAfterFTP"]),
                ConfigurationManager.AppSettings["LocalDirectory"],
                Convert.ToInt32(ConfigurationManager.AppSettings["FTPConnectionTimeoutInSeconds"]),
                Convert.ToInt32(ConfigurationManager.AppSettings["FTPReadTimeoutInSeconds"]),
                Convert.ToBoolean(ConfigurationManager.AppSettings["skipCurrentLog"]),
                Convert.ToBoolean(ConfigurationManager.AppSettings["RenameDuplicateFiles"]),
                Convert.ToInt32(ConfigurationManager.AppSettings["waitBetweenFileDownloadMilliseconds"])
                );
            int maxThreads = Convert.ToInt32(ConfigurationManager.AppSettings["MaxThreads"]);


            MOE.Common.Models.SPM db = new MOE.Common.Models.SPM();
            ISignalsRepository    signalsRepository = SignalsRepositoryFactory.Create(db);
            var signals = signalsRepository.GetLatestVersionOfAllSignalsForFtp();
            var options = new ParallelOptions {
                MaxDegreeOfParallelism = maxThreads
            };

            Parallel.ForEach(signals.AsEnumerable(), options, signal =>
                             //foreach (var signal in signals)
            {
                try
                {
                    MOE.Common.Business.SignalFtp signalFtp = new MOE.Common.Business.SignalFtp(signal, signalFtpOptions);

                    if (!Directory.Exists(signalFtpOptions.LocalDirectory + signal.SignalID))
                    {
                        Directory.CreateDirectory(signalFtpOptions.LocalDirectory + signal.SignalID);
                    }

                    //Get the records over FTP
                    if (CheckIfIPAddressIsValid(signal))
                    {
                        try
                        {
                            signalFtp.GetCurrentRecords();
                        }
                        catch (AggregateException ex)
                        {
                            Console.WriteLine("Error At Highest Level for signal " + ex.Message);
                            errorRepository.QuickAdd("FTPFromAllControllers", "Main", "Main Loop", MOE.Common.Models.ApplicationEvent.SeverityLevels.Medium, "Error At Highest Level for signal " + signal.SignalID);
                        }
                    }
                }
                catch (AggregateException ex)
                {
                    Console.WriteLine("Error At Highest Level for signal " + ex.Message);
                    errorRepository.QuickAdd("FTPFromAllControllers", "Main", "Main Loop", MOE.Common.Models.ApplicationEvent.SeverityLevels.Medium, "Error At Highest Level for signal " + signal.SignalID);
                }
            }
                             );
        }
Esempio n. 5
0
 public static void SetSignalsRepository(ISignalsRepository newRepository)
 {
     signalsRepository = newRepository;
 }
Esempio n. 6
0
        static void Main(string[] args)
        {
            IApplicationEventRepository errorRepository = ApplicationEventRepositoryFactory.Create();

            //while (true)
            //{
            try
            {
                SignalFtpOptions signalFtpOptions = new SignalFtpOptions(
                    Convert.ToInt32(ConfigurationManager.AppSettings["SNMPTimeout"]),
                    Convert.ToInt32(ConfigurationManager.AppSettings["SNMPRetry"]),
                    Convert.ToInt32(ConfigurationManager.AppSettings["SNMPPort"]),
                    Convert.ToBoolean(ConfigurationManager.AppSettings["DeleteFilesAfterFTP"]),
                    ConfigurationManager.AppSettings["LocalDirectory"],
                    Convert.ToInt32(ConfigurationManager.AppSettings["FTPConnectionTimeoutInSeconds"]),
                    Convert.ToInt32(ConfigurationManager.AppSettings["FTPReadTimeoutInSeconds"]),
                    Convert.ToBoolean(ConfigurationManager.AppSettings["skipCurrentLog"]),
                    Convert.ToBoolean(ConfigurationManager.AppSettings["RenameDuplicateFiles"]),
                    Convert.ToInt32(ConfigurationManager.AppSettings["waitBetweenFileDownloadMilliseconds"]),
                    Convert.ToInt32(ConfigurationManager.AppSettings["MaximumNumberOfFilesTransferAtOneTime"])
                    );
                int maxThreads           = Convert.ToInt32(ConfigurationManager.AppSettings["MaxThreads"]);
                int minutesToWait        = Convert.ToInt32(ConfigurationManager.AppSettings["MinutesToWait"]);
                MOE.Common.Models.SPM db = new MOE.Common.Models.SPM();
                ISignalsRepository    signalsRepository = SignalsRepositoryFactory.Create(db);
                var signals = signalsRepository.GetLatestVersionOfAllSignalsForFtp();
                //.Where(s =>s.SignalID =="7060");
                // EOS Signal at Bangerter and 3500 South
                var options = new ParallelOptions {
                    MaxDegreeOfParallelism = maxThreads
                };
                Parallel.ForEach(signals.AsEnumerable(), options, signal =>
                                 //foreach (var signal in signals)
                {
                    try
                    {
                        MOE.Common.Business.SignalFtp signalFtp =
                            new MOE.Common.Business.SignalFtp(signal, signalFtpOptions);
                        if (!Directory.Exists(signalFtpOptions.LocalDirectory + signal.SignalID))
                        {
                            Directory.CreateDirectory(signalFtpOptions.LocalDirectory + signal.SignalID);
                        }
                        if (CheckIfIPAddressIsValid(signal))
                        {
                            try
                            {
                                signalFtp.GetCurrentRecords();
                            }
                            catch (AggregateException ex)
                            {
                                Console.WriteLine("Error At Highest Level for signal " + ex.Message);
                                errorRepository.QuickAdd("FTPFromAllControllers", "Main", "Main Loop",
                                                         MOE.Common.Models.ApplicationEvent.SeverityLevels.Medium,
                                                         "Error At Highest Level for signal " + signal.SignalID);
                            }
                        }
                    }
                    catch (AggregateException ex)
                    {
                        Console.WriteLine("Error At Highest Level for signal " + ex.Message);
                        errorRepository.QuickAdd("FTPFromAllControllers", "Main", "Main Loop",
                                                 MOE.Common.Models.ApplicationEvent.SeverityLevels.Medium,
                                                 "Error At Highest Level for signal " + signal.SignalID);
                    }
                    //}
                });
                //string timeNow = DateTime.Now.ToString("t");
                //Console.WriteLine("At {0}, it is time to take a nap. Program will wait for {1} minutes.", timeNow, minutesToWait);
                //System.Threading.Thread.Sleep(minutesToWait * 60 * 1000);
            }
            catch (AggregateException ex)
            {
                Console.WriteLine("Error At Highest Level for Main (FTPfromAllControllers) " + ex.Message);
                errorRepository.QuickAdd("FTPFromAllControllers", "Main", "Main Loop",
                                         MOE.Common.Models.ApplicationEvent.SeverityLevels.Medium,
                                         "Error At Highest Level for Main (FTPfromAllControllers) at " + DateTime.Now.ToString("g"));
            }
            //}
        }
Esempio n. 7
0
        private static List <Business.Pin> GetPins()
        {
            ISignalsRepository repository = SignalsRepositoryFactory.Create();

            return(repository.GetPinInfo());
        }