Ejemplo n.º 1
0
 public static FindPrintManager Create(XElement xe = null, NamedValues<ZValue> parameters = null, int version = 0)
 {
     FindPrintManagerCreator createFindPrintManager = new FindPrintManagerCreator();
     createFindPrintManager.Init(xe);
     if (version != 0)
         createFindPrintManager.Version = version;
     createFindPrintManager.SetParameters(parameters);
     return createFindPrintManager.Create();
 }
Ejemplo n.º 2
0
        // 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;
                pb.TraceLevel.Level = (int)_traceLevel;
            }

            //_downloadAutomateManager.Start();

            return(_downloadAutomateManager);
        }
Ejemplo n.º 3
0
 public static FindPrintManager CreateFindPrintManager(string parameters = null, int version = 0)
 {
     // parameters : version = 6, dailyPrintManager = true, gapDayBefore = 5, gapDayAfter = 2
     FindPrintManagerCreator createFindPrintManager = new FindPrintManagerCreator();
     if (version != 0)
         createFindPrintManager.Version = version;
     NamedValues<ZValue> parameters2 = ParseParameters(parameters);
     //NamedValues.TraceValues(parameters2);
     createFindPrintManager.Init(GetDownloadAutomateManagerConfig(GetTestValue(parameters2)));
     createFindPrintManager.SetParameters(parameters2);
     //Trace.WriteLine("DailyPrintManager {0}", createFindPrintManager.DailyPrintManager);
     return createFindPrintManager.Create();
 }
Ejemplo n.º 4
0
        public static FindPrintManager CreateFindPrintManager(string parameters = null, int version = 0)
        {
            // parameters : version = 6, dailyPrintManager = true, gapDayBefore = 5, gapDayAfter = 2
            FindPrintManagerCreator createFindPrintManager = new FindPrintManagerCreator();

            if (version != 0)
            {
                createFindPrintManager.Version = version;
            }
            NamedValues <ZValue> parameters2 = ParseParameters(parameters);

            //NamedValues.TraceValues(parameters2);
            createFindPrintManager.Init(GetDownloadAutomateManagerConfig(GetTestValue(parameters2)));
            createFindPrintManager.SetParameters(parameters2);
            //Trace.WriteLine("DailyPrintManager {0}", createFindPrintManager.DailyPrintManager);
            return(createFindPrintManager.Create());
        }
Ejemplo n.º 5
0
        public static void RenameDailyPrintFiles(string sourceDirectory, string destinationDirectory, string logFile, bool simulate = true, string parameters = null)
        {
            // parameters : (FindPrintManager) int version, bool dailyPrintManager, int gapDayBefore, int gapDayAfter
            //NamedValues<ZValue> parameters2 = NamedValues.ParseValues(parameters);
            NamedValues <ZValue> parameters2 = ParseParameters(parameters);
            XElement             xe          = GetDownloadAutomateManagerConfig(GetTestValue(parameters2));
            int version = xe.zXPathValue("Version").zTryParseAs(6);
            FindPrintManager findPrintManager = FindPrintManagerCreator.Create(xe, parameters2, version);
            //PrintFileManager_v2.GetDailyPrintFiles(sourceDirectory).zRenameDailyPrintFiles(findPrintManager, destinationDirectory, simulate: simulate).zSave(logFile);

            string lastDirectory = null;

            PrintFileManager_v2.GetDailyPrintFiles(sourceDirectory).zGetRenameDailyPrintFilesInfos(findPrintManager)
            .Select(renamePrintFile =>
            {
                if (!simulate)
                {
                    string directory = zPath.GetDirectoryName(renamePrintFile.SourceFile);
                    if (directory != lastDirectory)
                    {
                        // remove empty directories
                        if (lastDirectory != null)
                        {
                            //zdir.DeleteEmptyDirectory(lastDirectory, deleteOnlySubdirectory: false);
                            zdir.DeleteEmptyDirectory(lastDirectory, recurse: true);
                        }
                        lastDirectory = directory;
                    }
                    if (renamePrintFile.RenameFile)
                    {
                        renamePrintFile.DestinationFile = PrintFileManager_v2.RenamePrintFile(renamePrintFile.SourceFile, zPath.Combine(destinationDirectory, renamePrintFile.File));
                    }
                }
                return(renamePrintFile);
            }).zSave(logFile);
            // remove empty directories
            if (!simulate && lastDirectory != null)
            {
                //zdir.DeleteEmptyDirectory(lastDirectory, deleteOnlySubdirectory: false);
                zdir.DeleteEmptyDirectory(lastDirectory, recurse: true);
            }
        }