Exemplo n.º 1
0
        static void Main(string[] args)
        {
            // Load settings
            _configReader = new ConfigReader(SettingsPath);
            BaseConfig.Sources = _configReader.GetAllInstancesOf("ConnectionString");

            // Register sync events
            _sync = new SyncManager();
            _sync.OnSyncComplete += Sync_OnSyncComplete;
            _sync.OnSyncFailure += Sync_OnSyncFailure;
            _sync.OnUpdateStatus += Sync_OnUpdateStatus;
            _sync.OnSyncStart += Sync_OnSyncStart;
            _sync.OnCleanUp += Sync_OnCleanUp;

            if (WasLastRun_Local())
            {
                BaseConfig.IsLocal = false;
                Sync();
            }

            var main = new MainView();
            main.Show();

            SaveRun_Status();
            if (BaseConfig.IsLocal)
            {
                BaseConfig.IsLocal = false;
                Sync();
            }

            //Console.ReadKey();
        }
 public void TestMediaMailerNumberOfRecipients()
 {
     var configReader = new ConfigReader();
      IMailMan mailMan = new MailMan2( configReader );
      IDetectLogFiles logFileDetector = new MediaLogDetector();
      var sut = new MediaMailerJob( mailMan, logFileDetector, configReader );
      var result = mailMan.RecipientCount();
      Assert.AreEqual( actual:result, expected:2 );
 }
 public void TestMediaMailerJob()
 {
     var configReader = new ConfigReader();
      IMailMan mailMan = new MailMan2( configReader );
      IDetectLogFiles logFileDetector = new MediaLogDetector();
      var sut = new MediaMailerJob(mailMan, logFileDetector, configReader);
      sut.DoJob();
      Assert.IsTrue(sut.LogsMailed > 0);
 }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var configReader = new ConfigReader(@"C:\repoSettings.xml");
            BaseConfig.Sources = configReader.GetAllInstancesOf("ConnectionString");

            SyncManager sync = new SyncManager();

            // Bind to all sync events
            sync.OnSyncComplete += Sync_OnSyncComplete;
            sync.OnSyncFailure += Sync_OnSyncFailure;
            sync.OnUpdateStatus += Sync_OnUpdateStatus;
            sync.OnSyncStart += Sync_OnSyncStart;
            sync.OnCleanUp += Sync_OnCleanUp;

            // SYNC!
            sync.SyncAllTables();
        }
Exemplo n.º 5
0
 public void TestInitialize()
 {
     sut = SystemUnderTest();
 }
Exemplo n.º 6
0
        public void Go(BackgroundWorker backgroundWorker1, DoWorkEventArgs e)
        {
            try
             {
            MyWorker = backgroundWorker1;
            var configReader = new ConfigReader();

            MyJobs = new List<Job>();

            MyJobs.Add( new DropBoxCopyTflToVesuviusJob( TimeKeeper ) ); //  get any new TFL data from dropbox
            MyJobs.Add( new MediaJob() );  //  regular always
            MyJobs.Add( new LogMailerJob(new MailMan2( configReader ), new LogFileDetector(), configReader ) );  //  once daily
            MyJobs.Add( new MediaMailerJob( new MailMan2( configReader ), new MediaLogDetector(), configReader ) );  //  once daily

            #region Looking back on the games just played

            MyJobs.Add( new AssignRolesJob( TimeKeeper ) );  //  sets the ROLE on players based on actual stats
            MyJobs.Add( new YahooXmlJob( TimeKeeper ) );
            MyJobs.Add( new PerformanceReportJob( TimeKeeper ) );
            MyJobs.Add( new FantasyReportJob( TimeKeeper ) );
            MyJobs.Add( new DepthChartJob( TimeKeeper ) );
            MyJobs.Add( new StatGridJob( TimeKeeper ) );
            MyJobs.Add( new PlayOffTeamsJob( TimeKeeper ) );
            MyJobs.Add( new UpdateActualsJob( TimeKeeper ) );
            MyJobs.Add( new UpdateTeamActualsJob( TimeKeeper ) );

            #endregion

            #region  Looking forward to the upcoming games

            MyJobs.Add( new GameProjectionsJob( TimeKeeper ) ); //  once in pre season then once a week regular - always
            MyJobs.Add( new GeneratePlayerProjectionsJob( TimeKeeper ) );
            MyJobs.Add( new GameProjectionReportsJob( TimeKeeper ) );
            MyJobs.Add( new RookiesJob( TimeKeeper ) );
            MyJobs.Add( new OutputProjectionsJob( Historian ) );  //  needs game projections
            MyJobs.Add( new FantasyProjectionJob( TimeKeeper ) );
            MyJobs.Add( new HotListsJob( TimeKeeper ) );
            MyJobs.Add( new UnitReportsJob( Historian ) );
            MyJobs.Add( new TeamCardsJob( TimeKeeper ) );
            MyJobs.Add( new OldRosterGridJob( TimeKeeper ) );
            MyJobs.Add( new DefensiveReportsJob( TimeKeeper ) );
            MyJobs.Add( new SuggestedLineupsJob( TimeKeeper ) );
            MyJobs.Add( new PickupChartJob( TimeKeeper ) );
            MyJobs.Add( new PreviousPickupChartJob( TimeKeeper, Historian ) );
            MyJobs.Add( new StartersJob( TimeKeeper ) );

            #endregion

            #region Regular Always jobs
            MyJobs.Add( new RunReportJob( TimeKeeper ) );
            MyJobs.Add( new LogCleanupJob() );
            MyJobs.Add( new TflDataBackupJob() );
            MyJobs.Add( new MediaListsPublishJob() );
            #endregion

            #region Pre Season Jobs -- Long running so last in the job order
            MyJobs.Add( new PlayerCsvJob( TimeKeeper ) );
            MyJobs.Add( new BalanceReportJob( TimeKeeper ) ); //  once off - pre season
            MyJobs.Add( new FreeAgentMarketJob( TimeKeeper ) ); //  regular - pre season
            MyJobs.Add( new StrengthOfScheduleJob( TimeKeeper ) ); //  once off - pre season
            MyJobs.Add( new PlayerReportsJob( TimeKeeper ) );
            #endregion

            MyJobs.Add( new DropboxCopyToReginaJob( TimeKeeper,
              "d:\\shares\\public\\dropbox\\gridstat\\{0}",
              "\\\\Regina\\web\\medialists\\dropbox\\gridstat\\{0}"
              ) );

            MyJobs.Add( new DropboxCopyToReginaJob( TimeKeeper,
              "d:\\shares\\public\\dropbox\\gridstat\\tfl-out",
              "\\\\Regina\\web\\medialists\\dropbox\\gridstat\\tfl-out"
              ) );

            if (Passes == 0)
               ReportProgress(
                  string.Format("{0} - {1} jobs defined -Starting...",
                                 Version, MyJobs.Count), ButlerConstants.ReportInTextArea);

            while (true)
            {
               Passes++;

               Logger.Info( "-------------------------------------------------------------------------------------" );
               foreach ( var job in MyJobs )
               {
                  string whyNot;
                  if (job.IsTimeTodo(out whyNot))
                  {
                     ReportProgress(
                        string.Format("Doing job {0}", job.Name), ButlerConstants.ReportInTextArea);
                     var outcome = job.Execute();
                     ReportProgress(outcome, ButlerConstants.ReportInTextArea);
                  }
                  else
                     ReportProgress(
                        string.Format("Job skipped {0} - {1}", job.Name, whyNot),
                        ButlerConstants.ReportInTextArea);
               }
               Logger.Info( "=====================================================================================" );

               ReportProgress(string.Format(
                  "Pass Number {0} done - next pass ({1}) {2:HH:mm}",
                  Passes, Pollinterval, DateTime.Now.AddMinutes(Pollinterval)));
               Thread.Sleep(Pollinterval * 60 * 1000); //  <pollInterval> hours

               if (!MyWorker.CancellationPending) continue;

               e.Cancel = true;
               break;
            }
             }
             catch (Exception ex)
             {
            if (Logger == null) Logger = LogManager.GetCurrentClassLogger();
            Logger.Error(ex.Message);
            Logger.Error(ex.StackTrace);
            throw;
             }
        }