示例#1
0
        protected void Application_Start()
        {
            try
            {
                AreaRegistration.RegisterAllAreas();
                WebApiConfig.Register(GlobalConfiguration.Configuration);
                FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
                RouteConfig.RegisterRoutes(RouteTable.Routes);
                BundleConfig.RegisterBundles(BundleTable.Bundles);
                AuthConfig.RegisterAuth();

                RouteTable.Routes.MapRoute("Robots.txt", "robots.txt", new { controller = "Home", action = "Robots" });

                home = new HomeController();
                HomeController.SetDefaultDirectory();


                Database.SetInitializer(/*new DropCreateDatabaseIfModelChangesInitializer()*/ new CreateIfNoExistInitilizer());


                ExceptionUtility.Info("iniciando ArgetinaSismos..." + GlobalWebData.ToUniversalTime());


                ISourceRepository sourceRepository = new SourceRepository(new AplicationContextFactory());
                var appRepository = new EarthquakeRepository(new AplicationContextFactory());


                //--------------------------------------------------------------------------------------------------------


                /*for (int i = 100; i < 30000; i++) {
                 *
                 *  RegistrationDevice rd = new RegistrationDevice();
                 *  rd.Date = DateTime.Now;
                 *  rd.DeviceId = "359718776788248"+i;
                 *  rd.RegistrationId = i+"reEq5wZykVbsOq_oPL7ZRBjyZJ3XIMSuCCDtipam8dYI4Rko0an0nw1-SjX-bRDrVVcaXGj9Koau4RkPAKM5k5We4qG_Xi-I04VdQAhteqPMVAYC2Xf7HlFeT3NCBKPMf_jTvRRaKsZ0BcXqOHZsu7MnLU3NCw";
                 *  sourceRepository.DbContext.RegistrationDevices.Add(rd);
                 *  sourceRepository.Save();
                 *
                 * }*/


                //--------------------------------------------------------------------------------------------------------

                CollectorFactory collectorFactory = new CollectorFactory(sourceRepository);


                var inpresEarthquakeCollectorHtml = collectorFactory.GetInpresEarthquakeCollectorHtml();
                var eMSCEarthquakeCollectorXML    = collectorFactory.GetEMSCEarthquakeCollectorXML();
                var ssuchEarthquakeCollectorHtml  = collectorFactory.GetSSUCHEarthquakeCollectorHtml();

                IDictionary <string, EarthquakeCollector> collectors = new Dictionary <string, EarthquakeCollector>();
                collectors.Add("InpresEarthquakeCollectorHtml", inpresEarthquakeCollectorHtml);
                collectors.Add("EMSCEarthquakeCollectorXML", eMSCEarthquakeCollectorXML);
                collectors.Add("SSUCHEarthquakeCollectorHtml", ssuchEarthquakeCollectorHtml);

                earthquakeExpert = new EarthquakeExpert(collectors, new EarthquakeRepository(new AplicationContextFactory()),
                                                        new AplicationContextFactory(), new MylogRepository(new AplicationContextFactory()), new TwitterCollector());
                //--------------------------------------------------------------------------------------------

                Scheduler.Run("test", 1, RunScheduledTasks);
            }
            catch (Exception ex)
            {
                ExceptionUtility.Error(ex, this.GetType());
                var message = ExceptionUtility.GetExceptionData(ex, this.GetType());
            }
        }