Ejemplo n.º 1
0
        //public static PrintTitleManager CreatePrintTitleManager(int version = 3, int gapDayBefore = 0, int gapDayAfter = 0)
        public PrintTitleManager Create()
        {
            // version 2 : utilise le nouveau PrintTitleManager, l'ancien pattern de date FindPrints/Dates/Date avec l'ancien FindDateManager
            // 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

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

            //_printList1Config = XmlConfig.CurrentConfig.GetConfig("PrintList1Config");

            FindDateManager findDateManager = CreateFindDateManager();

            PrintTitleManager printTitleManager = new PrintTitleManager();

            printTitleManager.FindDateManager   = findDateManager;
            printTitleManager.FindNumberManager = new FindNumberManager(_printList1Config.GetElements("FindPrints/Numbers/Number"), compileRegex: true);
            printTitleManager.FindSpecial       = new RegexValuesList(_printList1Config.GetElements("FindPrints/Specials/Special"), compileRegex: true);
            printTitleManager.PrintDirectory    = _printList1Config.GetExplicit("FindPrints/UnknowPrintDirectory");
            printTitleManager.SplitTitle        = _splitTitle;
            //if (_version == 4)
            //    printTitleManager.SplitTitle = true;
            //else
            //    printTitleManager.SplitTitle = false;
            if (_version == 6)
            {
                printTitleManager.Version = 2;
            }
            return(printTitleManager);
        }
Ejemplo n.º 2
0
        public static RegexValuesList CreateAnkiRegexValuesList()
        {
            string          configFile      = @"c:\pib\drive\google\dev\.net\Apps\tools\anki\anki.config.xml";
            XmlConfig       config          = new XmlConfig(configFile);
            RegexValuesList regexValuesList = new RegexValuesList(config.GetElements("QuestionInfos/QuestionInfo"), compileRegex: true);

            //regexValuesList.Add(config.GetElements("ResponseInfos/ResponseInfo"), compileRegex: true);
            return(regexValuesList);
        }
Ejemplo n.º 3
0
        private FindPrintManager _CreateFindPrintManager()
        {
            FindPrintManager findPrintManager = new FindPrintManager();
            findPrintManager.TrySplitTitle = _trySplitTitle;
            findPrintManager.PrintTitleManager = _printTitleManager;
            findPrintManager.FindPrintList = new RegexValuesList(_printList2Config.GetElements("FindPrints/Prints/Print"), compileRegex: true);
            if (_dailyPrintManager)
            {
                findPrintManager.FindPrintList.Add(_printList2Config.GetElements("FindPrints/Prints/ShortPrint"), compileRegex: true);
                findPrintManager.FindDayManager = _findDayManager;
                findPrintManager.UseFindDay = true;
                findPrintManager.SetGapDayBefore(_gapDayBefore);
                findPrintManager.SetGapDayAfter(_gapDayAfter);
            }
            findPrintManager.PrintManager = _printManager;
            findPrintManager.PostTypeDirectories = _postTypeDirectories;
            findPrintManager.DefaultPrintDirectory = _printList1Config.Get("FindPrints/DefaultPrintDirectory");
            findPrintManager.UnknowPrintDirectory = _printList1Config.Get("FindPrints/UnknowPrintDirectory");

            //if (_version >= 6)
            //    findPrintManager.Version = 2;

            return findPrintManager;
        }
Ejemplo n.º 4
0
        public static bool CompileProjects(string projectsFile, Win32ResourceCompiler win32ResourceCompiler, ResourceCompiler resourceCompiler = null, string runsourceSourceDirectory = null, Action <IProjectCompiler> onCompiled = null)
        {
            Chrono chrono = new Chrono();

            chrono.Start();
            int nbProject = 0;

            try
            {
                if (!zFile.Exists(projectsFile))
                {
                    throw new PBException("projects file dont exists \"{0}\"", projectsFile);
                }
                XmlConfig projects          = new XmlConfig(projectsFile);
                string    projectsDirectory = zPath.GetDirectoryName(projectsFile);
                //string updateDir = _config.GetExplicit("UpdateRunSource/UpdateDirectory").zRootPath(zapp.GetEntryAssemblyDirectory());

                string updateDirectory = projects.Get("UpdateDirectory");

                foreach (XElement project in projects.GetElements("Project"))
                {
                    string projectFile = project.zExplicitAttribValue("value").zRootPath(projectsDirectory);
                    Trace.WriteLine("Compile project \"{0}\"", projectFile);

                    ProjectCompiler compiler = ProjectCompiler.Create(projectFile, win32ResourceCompiler, resourceCompiler);
                    compiler.RunsourceSourceDirectory = runsourceSourceDirectory;
                    compiler.Compile();
                    compiler.TraceMessages();

                    //if (onCompiled != null)
                    //    onCompiled(compiler);
                    onCompiled?.Invoke(compiler);
                    if (!compiler.Success)
                    {
                        return(false);
                    }
                    string copyOutput = project.zAttribValue("copyOutput").zRootPath(zapp.GetEntryAssemblyDirectory());
                    if (copyOutput != null)
                    {
                        //Trace.WriteLine("  copy result files to directory \"{0}\"", copyOutput);
                        compiler.CopyResultFilesToDirectory(copyOutput);
                    }
                    if (project.zAttribValue("copyToUpdateDirectory").zTryParseAs(false))
                    {
                        if (updateDirectory == null)
                        {
                            throw new PBException("update directory is not defined");
                        }
                        //Trace.WriteLine("  copy result files to directory \"{0}\"", updateDirectory);
                        compiler.CopyResultFilesToDirectory(updateDirectory);
                    }
                    nbProject++;
                }
            }
            catch (ProjectCompilerException ex)
            {
                Error.WriteMessage(ErrorOptions.TraceError, ex.Message);
            }
            finally
            {
                chrono.Stop();
                Trace.WriteLine("{0} project(s) compiled", nbProject);
                Trace.WriteLine("Process completed {0}", chrono.TotalTimeString);
            }
            return(true);
        }
Ejemplo n.º 5
0
 public PrintManager CreatePrintManager()
 {
     return new PrintManager(_printConfig.GetElements("Print/Prints/Print"));
 }
Ejemplo n.º 6
0
 public FindDayManager CreateFindDayManager()
 {
     return new FindDayManager(_printList1Config.GetElements("FindPrints/Dates/ShortDay"), compileRegex: true);
 }
Ejemplo n.º 7
0
        public List <string> Zip()
        {
            int nbZip = 0;
            IEnumerable <XElement> zips = gConfig.GetElements("Backup/Zip");

            foreach (XElement xeZip in zips)
            {
                nbZip += xeZip.zXPathValues("Source/SourceDirectory").Count();
                nbZip += xeZip.zXPathValues("Source/SourceFile").Count();
            }


            List <string> zipFiles = new List <string>();
            int           iZip     = 0;

            foreach (XElement xeZip in zips)
            {
                if (gAbortTask)
                {
                    break;
                }
                CompressionLevel compressionLevel = GetCompressionLevel(xeZip.zXPathValue("CompressionLevel"));
                string           sZipDir          = xeZip.zXPathValue("ZipDirectory");
                foreach (string sourceDir in xeZip.zXPathValues("Source/SourceDirectory"))
                {
                    if (gAbortTask)
                    {
                        break;
                    }
                    gTaskProgress.SetProgressText("Zip " + sourceDir);
                    gTaskProgress.SetProgress(++iZip, nbZip);

                    if (!zDirectory.Exists(sourceDir))
                    {
                        //cTrace.Trace("Zip          : directory does'nt exist {0}", sourceDir);
                        gTaskTrace.WriteLine("Zip          : directory does'nt exist {0}", sourceDir);
                        continue;
                    }
                    DateTime t3 = DateTime.Now;
                    using (ZipFile zip = new ZipFile())
                    {
                        zip.SaveProgress += new EventHandler <SaveProgressEventArgs>(ZipSaveProgress);
                        //zip.CompressionLevel = CompressionLevel.BestSpeed;
                        zip.CompressionLevel = compressionLevel;
                        zip.AddDirectory(sourceDir, "");
                        string sPath = zpath.PathSetDirectory(zPath.GetFileNameWithoutExtension(sourceDir) + ".zip", sZipDir);
                        string sDir  = zPath.GetDirectoryName(sPath);
                        if (!zDirectory.Exists(sDir))
                        {
                            zDirectory.CreateDirectory(sDir);
                        }
                        zip.Save(sPath);
                        if (gAbortTask)
                        {
                            break;
                        }
                        zipFiles.Add(sPath);
                        int nbFiles = zip.zNbFile();
                        //int nbDir = zip.zNbDirectory();
                        long     compressedSize   = zip.zCompressedSize();
                        long     uncompressedSize = zip.zUncompressedSize();
                        double   ratio            = zip.zCompressionRatio();
                        TimeSpan t4 = DateTime.Now.Subtract(t3);
                        gTaskTrace.WriteLine("Zip          : {0,-40} - ratio {1,4:0.0} - nb files {2,5} - size {3,8} / {4,8} - {5:00}:{6:00}:{7:00}", sourceDir, ratio, nbFiles, GetSizeString(compressedSize), GetSizeString(uncompressedSize), t4.Hours, t4.Minutes, t4.Seconds);
                    }
                }

                foreach (string sourceFile in xeZip.zXPathValues("Source/SourceFile"))
                {
                    if (gAbortTask)
                    {
                        break;
                    }
                    gTaskProgress.SetProgressText("Zip " + sourceFile);
                    gTaskProgress.SetProgress(++iZip, nbZip);

                    if (!zFile.Exists(sourceFile))
                    {
                        //cTrace.Trace("Zip          : file does'nt exist {0}", sourceFile);
                        gTaskTrace.WriteLine("Zip          : file does'nt exist {0}", sourceFile);
                        continue;
                    }
                    DateTime t3 = DateTime.Now;
                    using (ZipFile zip = new ZipFile())
                    {
                        zip.SaveProgress += new EventHandler <SaveProgressEventArgs>(ZipSaveProgress);
                        //zip.CompressionLevel = CompressionLevel.BestSpeed;
                        zip.CompressionLevel = compressionLevel;
                        zip.AddFile(sourceFile, "");
                        string sPath = zpath.PathSetDirectory(zPath.GetFileNameWithoutExtension(sourceFile) + ".zip", sZipDir);
                        string sDir  = zPath.GetDirectoryName(sPath);
                        if (!zDirectory.Exists(sDir))
                        {
                            zDirectory.CreateDirectory(sDir);
                        }
                        zip.Save(sPath);
                        if (gAbortTask)
                        {
                            break;
                        }
                        zipFiles.Add(sPath);
                        int nbFiles = zip.zNbFile();
                        //int nbDir = zip.zNbDirectory();
                        long     compressedSize   = zip.zCompressedSize();
                        long     uncompressedSize = zip.zUncompressedSize();
                        double   ratio            = zip.zCompressionRatio();
                        TimeSpan t4 = DateTime.Now.Subtract(t3);
                        gTaskTrace.WriteLine("Zip          : {0,-40} - ratio {1,4:0.0} - nb files {2,5} - size {3,8} / {4,8} - {5:00}:{6:00}:{7:00}", sourceFile, ratio, nbFiles, GetSizeString(compressedSize), GetSizeString(uncompressedSize), t4.Hours, t4.Minutes, t4.Seconds);
                    }
                }
            }
            return(zipFiles);
        }