Beispiel #1
0
 public static MailSender GetMailSender()
 {
     if (_mailSender == null)
     {
         XmlConfig localConfig = GetLocalConfig();
         _mailSender = new MailSender(localConfig.Get("DownloadAutomateManager/Gmail/Mail"), localConfig.Get("DownloadAutomateManager/Gmail/Password"),
             localConfig.Get("DownloadAutomateManager/Gmail/SmtpHost"), localConfig.Get("DownloadAutomateManager/Gmail/SmtpPort").zTryParseAs<int>(587));
     }
     return _mailSender;
 }
        // int gapDayBefore = 0, int gapDayAfter = 0, int? traceLevel = null
        //public static DownloadAutomateManager_v2 Create(int version = 3, bool dailyPrintManager = false, bool useTestManager = false, bool test = false)
        //{
        //    CreateDownloadAutomateManager create = new CreateDownloadAutomateManager();
        //    create._version = version;
        //    create._dailyPrintManager = dailyPrintManager;
        //    //create._gapDayBefore = gapDayBefore;
        //    //create._gapDayAfter = gapDayAfter;
        //    create._useTestManager = useTestManager;
        //    //create._traceLevel = traceLevel;
        //    create._test = test;
        //    return create._Create();
        //}

        public DownloadAutomateManager Create()
        {
            // from DownloadAutomate_f.CreateDownloadAutomate_v2()

            // le 01/11/2014 désactive version 1 et version 2
            // version 1 : utilise l'ancien FindPrintManager, l'ancienne liste de print dans print_list1.xml, l'ancien pattern de date FindPrints/Dates/Date avec l'ancien FindDateManager
            // version 2 : version 1 + le nouveau FindPrintManager_new avec le nouveau PrintTitleManager, la nouvelle liste de print dans print_list2.xml,
            // version 3 : version 2 + le nouveau pattern de date FindPrints/Dates/DateNew avec le nouveau FindDateManager_new
            // version 4 (not used) : version 3 + découpe le titre avec "du" ou "-" (PrintTitleManager)
            // version 5 : version 3 +  new find date
            // version 6 : version 5 +  printTitleManager version 2 + findPrintManager version 2

            if (_version < 3 || _version > 6)
                throw new PBException("bad version {0}", _version);

            Trace.WriteLine("create download automate : version {0} useTestManager {1} traceLevel {2}", _version, _useTestManager, _traceLevel.zToStringOrNull());

            //if (!_test)
            //    _xeConfig = XmlConfig.CurrentConfig.GetElement("DownloadAutomateManager");
            //else
            //    _xeConfig = XmlConfig.CurrentConfig.GetElement("DownloadAutomateManager_Test");

            _mongoDownloadAutomateManager = CreateMongoDownloadAutomateManager();

            //_findPrintManager = CreateFindPrintManager();
            _findPrintManager = FindPrintManagerCreator.Create(_xeConfig, _parameters, _version);

            _downloadManager = CreateDownloadManager();
            _mailSender = CreateMailSender();
            _mailMessage = CreateMailMessage();

            _downloadAutomateManager = _CreateDownloadAutomateManager();

            //InitServers();
            //CreateServerManagers();

            _downloadAutomateManager.Init(_xeConfig);
            _downloadAutomateManager.SetParameters(_parameters);

            TraceResult();

            //if (!ControlDownloadManagerClient())
            //    throw new PBException("error DownloadManagerClient is not working");

            if (_traceLevel != null)
                Trace.CurrentTrace.TraceLevel = (int)_traceLevel;

            //_downloadAutomateManager.Start();

            return _downloadAutomateManager;
        }