Exemple #1
0
        //private static XmlConfig _config = new XmlConfig("pt_config.xml");

        public static void Main(string[] args)
        {
            try
            {
                //Trace.CurrentTrace.SetLogFile(null, LogOptions.LogToConsole);
                Trace.CurrentTrace.SetViewer(Console.Out.Write);
                //string log = _config.Get("Log").zRootPath(zapp.GetEntryAssemblyDirectory());
                //if (log != null)
                //{
                //    //Trace.WriteLine("log to \"{0}\"", log);
                //    //Trace.AddTraceFile(log, LogOptions.IndexedFile);
                //    Trace.CurrentTrace.AddTraceFile(log);
                //}
                Trace.CurrentTrace.SetWriter(WriteToFile.Create(_config.Get("Log").zRootPath(zapp.GetEntryAssemblyDirectory()), _config.Get("Log/@option").zTextDeserialize(FileOption.None)));
                string path = _config.Get("PrintConfig");
                if (path != null)
                {
                    //Trace.WriteLine("load print config \"{0}\"", path);
                    _printConfig = new XmlConfig(path);
                }
                pt(args);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
                Trace.WriteLine(ex.StackTrace);
            }
        }
Exemple #2
0
        //static int Main(string[] args)
        static void Main()
        {
            try
            {
                XmlConfig config = new XmlConfig();
                FormatInfo.SetInvariantCulture();
                Application.CurrentCulture = FormatInfo.CurrentFormat.CurrentCulture;
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                RemoteRunSource remoteRunSource = new RemoteRunSource();
                remoteRunSource.RunsourceDllFilename = config.GetExplicit("RunsourceDllFilename");
                remoteRunSource.RunsourceClassName   = config.GetExplicit("RunsourceClassName");
                remoteRunSource.TraceClassName       = config.GetExplicit("TraceClassName");
                // ATTENTION si CreateRunSourceDomain = true runsource.launch.exe ne peut pas mettre à jour runsource.runsource.exe
                remoteRunSource.CreateRunSourceDomain = config.Get("CreateRunSourceDomain").zTryParseAs <bool>(false);
                IRunSource runSource = remoteRunSource.GetRunSource();
                runSource.AllowMultipleExecution = config.Get("AllowMultipleExecution").zTryParseAs(false);
                // ATTENTION Trace exists in both 'runsource.runsource.exe' and 'runsource.dll'
                // donc il faut utiliser RemoteRunSource.GetTrace()
                ITrace trace = remoteRunSource.GetTrace();
                trace.SetWriter(config.Get("Log"), config.Get("Log/@option").zTextDeserialize(FileOption.None));

                // ATTENTION appeler DeleteGeneratedAssemblies() après SetRunSourceConfig()
                //RunSourceForm form = new RunSourceForm(runSource, trace, config, GetRunSourceRestartParameters());
                RunSourceForm_v3 form = new RunSourceForm_v3(runSource, trace, config, GetRunSourceRestartParameters());

                form.SetRestartRunsource += FormSetRestartRunsource;
                Application.Run(form);
                SetRunSourceRestartParameters();
            }
            catch (Exception ex)
            {
                zerrf.ErrorMessageBox(ex);
            }
        }
Exemple #3
0
        static void Main()
        {
            try
            {
                object runSourceRestartParameters = null;
                while (true)
                {
                    __config = new XmlConfig(__configFile);
                    TraceManager.Current.AddTrace(Trace.Current);
                    //TraceManager.Current.SetWriter(__config.Get("Log").zRootPath(zapp.GetAppDirectory()), __config.Get("Log/@option").zTextDeserialize(FileOption.None));
                    TraceManager.Current.SetWriter(WriteToFile.Create(__config.Get("Log").zRootPath(zapp.GetAppDirectory()), __config.Get("Log/@option").zTextDeserialize(FileOption.None)));
                    //__traceUpdate = __config.Get("UpdateRunSource/TraceUpdate").zTryParseAs(false);
                    zUpdateFiles.Trace = __config.Get("UpdateRunSource/TraceUpdate").zTryParseAs(false);

                    UpdateRunSourceFiles();
                    Run(runSourceRestartParameters);
                    // attention récupérer RunSourceRestartParameters avant UpdateRunSourceFiles(), UpdateRunSourceFiles() fait AppDomain.Unload()
                    runSourceRestartParameters = __domain.GetData(__domainRestartParametersName);
                    if (runSourceRestartParameters == null)
                    {
                        break;
                    }
                    //__domain.DomainUnload += domain_DomainUnload;
                    //Trace.WriteLine("__domain.IsFinalizingForUnload() : {0}", __domain.IsFinalizingForUnload());
                    //Trace.WriteLine("AppDomain.Unload(__domain)");
                    AppDomain.Unload(__domain);
                    __domain = null;
                    //Trace.WriteLine("__domain.IsFinalizingForUnload() : {0}", __domain.IsFinalizingForUnload());
                }
            }
            catch (Exception ex)
            {
                zerrf.ErrorMessageBox(ex);
            }
        }
Exemple #4
0
        private void InitCradleOfRomeWatcher()
        {
            XmlConfig config = XmlConfig.CurrentConfig;

            gCradleWatcher = new PB_Library.CradleOfRomeWatcher();
            gCradleWatcher.CradleProgram = config.Get("CradleOfRomeWatcher/Program");
            if (gCradleWatcher.CradleProgram == null)
            {
                return;
            }
            gCradleWatcher.CradleFileDirectory        = config.GetExplicit("CradleOfRomeWatcher/FileDirectory");
            gCradleWatcher.CradleFileSaveDirectory    = config.Get("CradleOfRomeWatcher/FileSaveDirectory");
            gCradleWatcher.CradleFileArchiveDirectory = config.Get("CradleOfRomeWatcher/FileArchiveDirectory");
            //gCradleWatcher.Notify += new PB_Library.NotifyDelegate(Trace);
            gCradleWatcher.Notify += new PB_Library.NotifyDelegate(TraceMessage);
            //gCradleWatcher.CraddleFilesSaved += new CraddleFilesSavedDelegate(CraddleFilesSaved);
            gCradleWatcher.BlitzLevelType = PB_Library.CradleOfRomeBlitzLevelType.Hard;
            if (config.Get("CradleOfRomeWatcher/StartWatcher").zTryParseAs(false))
            {
                gCradleWatcher.Start();
            }

            Trace.WriteLine("CradleOfRomeWatcher/Program : \"{0}\"", gCradleWatcher.CradleProgram);
            Trace.WriteLine("CradleOfRomeWatcher/FileDirectory : \"{0}\"", gCradleWatcher.CradleFileDirectory);
            Trace.WriteLine("CradleOfRomeWatcher/FileSaveDirectory : \"{0}\"", gCradleWatcher.CradleFileSaveDirectory);
            Trace.WriteLine("CradleOfRomeWatcher/FileArchiveDirectory : \"{0}\"", gCradleWatcher.CradleFileArchiveDirectory);
            Trace.WriteLine("CradleOfRomeWatcher/StartWatcher : {0}", gCradleWatcher.IsStarted());
        }
Exemple #5
0
        private void InitTitle()
        {
            string title = _config.Get("RunsourceTitle");

            if (title != null)
            {
                _title = title;
            }
        }
Exemple #6
0
        static void Main()
        {
            try
            {
                // load runsource.runsource.config.xml (config of runsource.runsource.exe)
                XmlConfig config = new XmlConfig();
                FormatInfo.SetInvariantCulture();
                Application.CurrentCulture = FormatInfo.CurrentFormat.CurrentCulture;
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                RemoteRunSource remoteRunSource = new RemoteRunSource();
                remoteRunSource.RunsourceDllFilename  = config.GetExplicit("RunsourceDllFilename");
                remoteRunSource.RunsourceClassName    = config.GetExplicit("RunsourceClassName");
                remoteRunSource.TraceManagerClassName = config.GetExplicit("TraceManagerClassName");
                remoteRunSource.TraceClassName        = config.GetExplicit("TraceClassName");
                // ATTENTION si CreateRunSourceDomain = true runsource.launch.exe ne peut pas mettre à jour runsource.runsource.exe
                remoteRunSource.CreateRunSourceDomain = config.Get("CreateRunSourceDomain").zTryParseAs <bool>(false);
                IRunSource runSource = remoteRunSource.GetRunSource();
                //remoteRunSource.LoadRunsourceCommand();
                //runSource.AllowMultipleExecution = config.Get("AllowMultipleExecution").zTryParseAs(false);
                ///////////////////////// donc il faut utiliser RemoteRunSource.GetTrace()
                //ITrace trace = remoteRunSource.GetTrace();
                //trace.SetWriter(config.Get("Log"), config.Get("Log/@option").zTextDeserialize(FileOption.None));

                // ATTENTION Trace exists in both 'runsource.runsource.exe' and 'runsource.dll'
                // both Trace are connected to TraceManager and can be used
                string     logFile       = config.Get("Log");
                FileOption logFileOption = config.Get("Log/@option").zTextDeserialize(FileOption.None);
                TraceManager.Current.AddTrace(Trace.Current);
                //TraceManager.Current.SetWriter(logFile, logFileOption);
                TraceManager.Current.SetWriter(WriteToFile.Create(logFile, logFileOption));

                ITraceManager remoteTraceManager = remoteRunSource.GetTraceManager();
                remoteTraceManager.AddTrace(remoteRunSource.GetTrace());
                //remoteTraceManager.SetWriter(logFile, logFileOption);
                remoteTraceManager.SetWriter(WriteToFile.Create(logFile, logFileOption));

                // ATTENTION appeler DeleteGeneratedAssemblies() après SetRunSourceConfig()
                //RunSourceForm form = new RunSourceForm(runSource, trace, config, GetRunSourceRestartParameters());
                //RunSourceForm_v3 form = new RunSourceForm_v3(runSource, trace, config, GetRunSourceRestartParameters());
                //RunSourceFormExe form = new RunSourceFormExe(runSource, trace, config, GetRunSourceRestartParameters());
                RunSourceFormExe form = new RunSourceFormExe(runSource, config, remoteRunSource, GetRunSourceRestartParameters());
                RunSourceFormExe.Current = form;

                form.SetRestartRunsource += FormSetRestartRunsource;
                Application.Run(form);

                TraceManager.Current.RemoveTrace(Trace.Current);
                TraceManager.Current.RemoveTrace(remoteRunSource.GetTrace());
                SetRunSourceRestartParameters();
            }
            catch (Exception ex)
            {
                zerrf.ErrorMessageBox(ex);
            }
        }
Exemple #7
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);
 }
Exemple #8
0
        public Backup()
        {
            gTaskName  = "Backup";
            gTaskTrace = Trace.CurrentTrace;
            gConfig    = new XmlConfig();
            //string sPath = gConfig.Get("Backup/Log");
            //if (sPath != null)
            //    gTaskTrace.SetLogFile(sPath, LogOptions.IndexedFile);
            gTaskTrace.SetWriter(gConfig.Get("Backup/Log"), gConfig.Get("Backup/Log/@option").zTextDeserialize(FileOption.None));

            gTaskProgress       = new Progress();
            gTaskProgressDetail = new Progress();
        }
Exemple #9
0
        //public static void Test_Mail_01()
        //{
        //    System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
        //    message.To.Add("*****@*****.**");
        //    message.Subject = "test";
        //    message.From = new System.Net.Mail.MailAddress("*****@*****.**");
        //    message.Body = "test";
        //    System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("yoursmtphost");
        //    smtp.Send(message);
        //}

        //public static void Test_Mail_02()
        //{
        //    // obsolete
        //    System.Web.Mail.MailMessage message = new System.Web.Mail.MailMessage();
        //    message.From = "from e-mail";
        //    message.To = "to e-mail";
        //    message.Subject = "Message Subject";
        //    message.Body = "Message Body";
        //    System.Web.Mail.SmtpMail.SmtpServer = "SMTP Server Address";
        //    System.Web.Mail.SmtpMail.Send(message);

        //    System.Web.Mail.SmtpMail.SmtpServer = "SMTP Host Address";
        //    System.Web.Mail.SmtpMail.Send("from", "To", "Subject", "MessageText");
        //}

        public static void Test_Mail_01()
        {
            //var fromAddress = new MailAddress("*****@*****.**", "Pierre Beuzart");
            //var toAddress = new MailAddress("*****@*****.**", "To Name");
            //var fromAddress = new MailAddress(localConfig.Get("Gmail/Mail"));
            //var toAddress = new MailAddress("*****@*****.**");
            //string subject = "test";
            //string body = "test";
            //using (var message = new MailMessage(fromAddress, toAddress)
            //{
            //    Subject = subject,
            //    Body = body
            //})
            //{
            //    GetSmtpClient().Send(message);
            //}

            XmlConfig   localConfig = GetLocalConfig();
            MailMessage message     = new MailMessage(new MailAddress(localConfig.Get("DownloadAutomateManager/Gmail/Mail")), new MailAddress("*****@*****.**"))
            {
                Subject = "test",
                Body    = "test"
            };

            GetSmtpClient().Send(message);
        }
Exemple #10
0
        static void UpdateRunSourceFiles()
        {
            string appDir = zapp.GetAppDirectory();
            //string dir = __config.Get("UpdateRunSource/UpdateDirectory", __defaultUpdateDirectory).zRootPath(appDir);
            //string dir = __config.Get("UpdateRunSource/UpdateDirectory").zRootPath(appDir);
            string dir = __config.Get("RunsourceUpdateDirectory").zRootPath(appDir);

            //UpdateFiles(dir, appDir);
            zUpdateFiles.UpdateFiles(dir, appDir);
            //if (zDirectory.Exists(dir))
            //{
            //    foreach (string file in zDirectory.EnumerateFiles(dir))
            //    {
            //        //Trace.WriteLine("copy file \"{0}\" to directory \"{1}\"", file, appDir);
            //        try
            //        {
            //            zfile.CopyFileToDirectory(file, appDir, options: CopyFileOptions.OverwriteReadOnly | CopyFileOptions.CopyOnlyIfNewer);
            //        }
            //        catch (Exception exception)
            //        {
            //            Trace.WriteLine("error copying file \"{0}\" to directory \"{1}\"", file, appDir);
            //            Trace.WriteLine(exception.Message);
            //        }
            //    }
            //}
        }
Exemple #11
0
        public static void InitAlways()
        {
            XmlConfig.CurrentConfig = new XmlConfig(RunSource.CurrentRunSource.GetFilePath("BlogDemoor.config.xml"));
            XmlConfig config = XmlConfig.CurrentConfig;

            Trace.CurrentTrace.SetWriter(config.Get("Log").zRootPath(zapp.GetAppDirectory()), config.Get("Log/@option").zTextDeserialize(FileOption.None));

            HttpManager.CurrentHttpManager.ExportDirectory = config.Get("HttpExportDirectory").zRootPath(zapp.GetEntryAssemblyDirectory());

            MongoLog.CurrentMongoLog.SetLogFile(config.Get("MongoLog").zRootPath(zapp.GetEntryAssemblyDirectory()), config.Get("MongoLog/@option").zTextDeserialize(FileOption.None));
            string mongoCache = config.Get("MongoCache").zRootPath(zapp.GetEntryAssemblyDirectory());

            if (mongoCache != null)
            {
                MongoCursorCache.CacheFile = mongoCache;
            }
        }
Exemple #12
0
        public static SmtpClient GetSmtpClient()
        {
            XmlConfig localConfig = GetLocalConfig();
            string    mail        = localConfig.Get("DownloadAutomateManager/Gmail/Mail");
            string    password    = localConfig.Get("DownloadAutomateManager/Gmail/Password");
            string    smtpHost    = localConfig.Get("DownloadAutomateManager/Gmail/SmtpHost");
            int       smtpPort    = localConfig.Get("DownloadAutomateManager/Gmail/SmtpPort").zTryParseAs <int>(587);

            return(new SmtpClient
            {
                Host = smtpHost,
                Port = smtpPort,
                EnableSsl = true,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials = new System.Net.NetworkCredential(new MailAddress(mail).Address, password)
            });
        }
Exemple #13
0
        //private static string GetScanZone(QuestionsParameters parameters, string imageFile)
        //{
        //    // format: "top:left:height:width,...", example "zone=0:0:100:100,50:50:50:50"
        //    if (parameters.PageColumn == 1)
        //        return null;
        //    else if (parameters.PageColumn == 2)
        //    {
        //        int width;
        //        int height;
        //        zimg.GetImageWidthHeight(imageFile, out width, out height);
        //        string zone;
        //        switch (parameters.PageRotate)
        //        {
        //            case PageRotate.NoRotate:
        //            case PageRotate.Rotate180:
        //                int width2 = width / 2;
        //                zone = $"0:0:{width2}:{height},{width2}:0:{width - width2}:{height}";
        //                break;
        //            case PageRotate.Rotate90:
        //            case PageRotate.Rotate270:
        //                int height2 = height / 2;
        //                zone = $"0:0:{width}:{height2},0:{height2}:{width}:{height - height2}";
        //                break;
        //            default:
        //                throw new PBException($"unknow page rotation {parameters.PageRotate}");
        //        }
        //        return zone;
        //    }
        //    else
        //        throw new PBException($"can't create scan zone for {parameters.PageColumn} columns");
        //}

        //private OcrRequest CreateOcrRequest()
        //{
        //    return new OcrRequest { Language = "french,english", OutputFormat = "txt" };
        //}

        //private OcrWebService CreateOcrWebService()
        //{
        //    XmlConfig config = XmlConfig.CurrentConfig;
        //    XmlConfig ocrWebServiceConfig = config.GetConfig("OcrWebServiceConfig");
        //    OcrWebService ocrWebService = new OcrWebService(ocrWebServiceConfig.GetExplicit("UserName"), ocrWebServiceConfig.GetExplicit("LicenseCode"), _timeout);
        //    //ocrWebService.UserName = ocrWebServiceConfig.GetExplicit("UserName");
        //    //ocrWebService.LicenseCode = ocrWebServiceConfig.GetExplicit("LicenseCode");
        //    string cacheDirectory = config.Get("OcrWebServiceCacheDirectory");
        //    if (cacheDirectory != null)
        //    {
        //        UrlCache urlCache = new UrlCache(cacheDirectory);
        //        urlCache.UrlFileNameType = UrlFileNameType.Host | UrlFileNameType.Path;
        //        if (config.Get("OcrWebServiceCacheDirectory/@option")?.ToLower() == "indexedfile")
        //            urlCache.IndexedFile = true;
        //        ocrWebService.HttpManager.SetCacheManager(urlCache);
        //    }
        //    return ocrWebService;
        //}

        private ScanManager CreateScanManager()
        {
            XmlConfig config = XmlConfig.CurrentConfig;
            XmlConfig ocrWebServiceConfig = config.GetConfig("OcrWebServiceConfig");
            UrlCache  urlCache            = null;
            string    cacheDirectory      = config.Get("OcrWebServiceCacheDirectory");

            if (cacheDirectory != null)
            {
                urlCache = new UrlCache(cacheDirectory);
                urlCache.UrlFileNameType = UrlFileNameType.Host | UrlFileNameType.Path;
                if (config.Get("OcrWebServiceCacheDirectory/@option")?.ToLower() == "indexedfile")
                {
                    urlCache.IndexedFile = true;
                }
            }
            ScanManager scanManager = new ScanManager(ocrWebServiceConfig.GetExplicit("UserName"), ocrWebServiceConfig.GetExplicit("LicenseCode"), urlCache);

            scanManager.Language     = "french,english";
            scanManager.OutputFormat = "txt";
            return(scanManager);
        }
Exemple #14
0
        public void StartAssemblyResolve()
        {
            XmlConfig config = GetRunSourceConfig();

            if (config != null)
            {
                AssemblyResolve.TraceAssemblyResolve = config.Get("TraceAssemblyResolve").zTryParseAs(false);
                //AssemblyResolve.TraceAssemblyLoad = config.Get("TraceAssemblyLoad").zTryParseAs(false);
                //AssemblyResolve.UpdateAssembly = config.Get("UpdateAssembly").zTryParseAs(false); ;
                //AssemblyResolve.UpdateSubDirectory = config.Get("UpdateAssemblySubDirectory", AssemblyResolve.UpdateSubDirectory); ;
                //AssemblyResolve.TraceUpdateAssembly = config.Get("TraceUpdateAssembly").zTryParseAs(false);
            }
            AssemblyResolve.Start();
        }
Exemple #15
0
        public static void InitAlways()
        {
            XmlConfig.CurrentConfig = new XmlConfig(RunSourceCommand.GetFilePath("hts.config.xml"));
            XmlConfig config = XmlConfig.CurrentConfig;

            string logFile = config.Get("Log").zRootPath(zapp.GetAppDirectory());

            //Trace.WriteLine($"set log file \"{logFile}\"");
            //RunSourceCommand.SetWriter(logFile, config.Get("Log/@option").zTextDeserialize(FileOption.None));
            //RunSourceCommand.TraceSetWriter(WriteToFile.Create(logFile, config.Get("Log/@option").zTextDeserialize(FileOption.None)));
            RunSourceCommand.TraceManager.SetWriter(WriteToFile.Create(logFile, config.Get("Log/@option").zTextDeserialize(FileOption.None)));

            AppData.DataDirectory = config.GetExplicit("DataDir");
            //string httpExportDirectory = config.Get("HttpExportDirectory").zRootPath(zapp.GetEntryAssemblyDirectory());
            //if (httpExportDirectory != null)
            //{
            //    //Trace.WriteLine($"http export directory \"{httpExportDirectory}\"");
            //    HttpRun.HttpManager.UrlCache = new UrlCache(httpExportDirectory);
            //    HttpRun.HttpManager.UrlCache.UrlFileNameType = UrlFileNameType.Host | UrlFileNameType.Path | UrlFileNameType.Ext | UrlFileNameType.Query;
            //    HttpRun.HttpManager.UrlCache.IndexedFile = true;
            //    HttpRun.HttpManager.UrlCache.SaveRequest = true;
            //}
            HttpRun.HttpManager.UrlCache = UrlCache.CreateIndexedCache(config.Get("HttpExportDirectory").zRootPath(zapp.GetEntryAssemblyDirectory()));
            MongoLog.CurrentMongoLog.SetLogFile(config.Get("MongoLog").zRootPath(zapp.GetEntryAssemblyDirectory()), config.Get("MongoLog/@option").zTextDeserialize(FileOption.None));
            string mongoCache = config.Get("MongoCache").zRootPath(zapp.GetEntryAssemblyDirectory());

            if (mongoCache != null)
            {
                MongoCursorCache.CacheFile = mongoCache;
            }
            //TraceMongoCommand.ResultToGrid = true;
            //DefaultMongoSerialization.SetDefaultMongoSerializationOptions();
            //DefaultMongoSerialization.RegisterDefaultMongoSerializer();
            //HtmlRun.SetResult = dt => RunSource.CurrentRunSource.SetResult(dt);

            //pb.Web.Html.HtmlToXmlManager.Current.ExportXml = true;
        }
Exemple #16
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;
        }
Exemple #17
0
        //static int Main(string[] args)
        static void Main()
        {
            try
            {
                Trace.CurrentTrace.SetLogFile("log.txt", LogOptions.None);

                XmlConfig config = new XmlConfig();
                FormatInfo.SetInvariantCulture();
                Application.CurrentCulture = FormatInfo.CurrentFormat.CurrentCulture;
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                RemoteRunSource remoteRunSource = new RemoteRunSource();
                remoteRunSource.RunsourceDllFilename = config.GetExplicit("RunsourceDllFilename");
                remoteRunSource.RunsourceClassName   = config.GetExplicit("RunsourceClassName");
                //remoteRunSource.CreateRunSourceDomain = config.Get("CreateRunSourceDomain").zTryParseAs<bool>(true);
                // attention si CreateRunSourceDomain = true runsource.launch.exe ne peut pas mettre à jour runsource.runsourced32.exe
                remoteRunSource.CreateRunSourceDomain = config.Get("CreateRunSourceDomain").zTryParseAs <bool>(false);
                RunSourceForm form = new RunSourceForm(remoteRunSource.GetRunSource(), config, GetRunSourceRestartParameters());

                //form.UpdateRunsourceFiles += FormUpdateRunsourceFiles;
                form.SetRestartRunsource += FormSetRestartRunsource;
                Application.Run(form);
                //if (_projectFiles != null)
                SetRunSourceUpdateAndRestartParameters();

                //if (_updateProgram)
                //{
                //    _updateProgram = false;
                //    return 1;
                //}
                //else
                //    return 0;
            }
            catch (Exception ex)
            {
                zerrf.ErrorMessageBox(ex);
                //return 0;
            }
        }
Exemple #18
0
        public static void InitAlways()
        {
            XmlConfig.CurrentConfig = new XmlConfig(RunSourceCommand.GetFilePath("download.config.xml"));
            XmlConfig config = XmlConfig.CurrentConfig;

            //RunSourceCommand.SetWriter(config.Get("Log").zRootPath(zapp.GetAppDirectory()), config.Get("Log/@option").zTextDeserialize(FileOption.None));
            //RunSourceCommand.TraceSetWriter(WriteToFile.Create(config.Get("Log").zRootPath(zapp.GetAppDirectory()), config.Get("Log/@option").zTextDeserialize(FileOption.None)));
            RunSourceCommand.TraceManager.SetWriter(WriteToFile.Create(config.Get("Log").zRootPath(zapp.GetAppDirectory()), config.Get("Log/@option").zTextDeserialize(FileOption.None)));

            string dataDir = config.GetExplicit("DataDir");

            AppData.DataDirectory = dataDir;

            //HttpManager.CurrentHttpManager.ExportDirectory = config.Get("HttpExportDirectory").zRootPath(zapp.GetEntryAssemblyDirectory());
            HttpRun.HttpManager.UrlCache = UrlCache.CreateIndexedCache(config.Get("HttpExportDirectory").zRootPath(zapp.GetEntryAssemblyDirectory()));

            MongoLog.CurrentMongoLog.SetLogFile(config.Get("MongoLog").zRootPath(zapp.GetEntryAssemblyDirectory()), config.Get("MongoLog/@option").zTextDeserialize(FileOption.None));
            string mongoCache = config.Get("MongoCache").zRootPath(zapp.GetEntryAssemblyDirectory());

            if (mongoCache != null)
            {
                MongoCursorCache.CacheFile = mongoCache;
            }

            // export data of PrintTextValuesManager
            bool exportData = config.Get("TextInfos/ExportData").zParseAs <bool>();

            if (exportData)
            {
                string exportDataFile = config.Get("TextInfos/ExportDataFile");
                if (exportDataFile != null)
                {
                    DownloadPrint.PrintTextValuesManager.SetExportDataFile(exportDataFile);
                }
            }
        }
Exemple #19
0
        public static void Test_Md5_02()
        {
            XmlConfig localConfig = new XmlConfig(XmlConfig.CurrentConfig.GetExplicit("LocalConfig"));

            Test_Md5_01(localConfig.Get("DownloadAutomateManager/Ebookdz/Password"));
        }
Exemple #20
0
 private MailSender CreateMailSender()
 {
     return(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)));
 }
        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);
        }
Exemple #22
0
        static void Main()
        {
            try
            {
                XmlConfig config = new XmlConfig();

                //Trace.CurrentTrace.SetLogFile("log.txt", LogOptions.None);
                //string path = config.Get("Log").zSetRootDirectory();
                //if (path != null)
                //    _runSource.Trace.SetLogFile(path, LogOptions.IndexedFile);
                //Trace.WriteLine(config.Get("Log").zSetRootDirectory());
                //LogOptions logOptions = config.Get("Log/@LogOptions").zTextDeserialize(LogOptions.None);
                //Trace.WriteLine(logOptions.ToString());
                //Trace.CurrentTrace.SetLogFile(config.Get("Log").zSetRootDirectory(), config.Get("Log/@LogOptions").zTextDeserialize(LogOptions.None));
                //Trace.WriteLine(Trace.CurrentTrace.GetLogFile());

                FormatInfo.SetInvariantCulture();
                Application.CurrentCulture = FormatInfo.CurrentFormat.CurrentCulture;
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                RemoteRunSource remoteRunSource = new RemoteRunSource();
                remoteRunSource.RunsourceDllFilename = config.GetExplicit("RunsourceDllFilename");
                remoteRunSource.RunsourceClassName   = config.GetExplicit("RunsourceClassName");
                remoteRunSource.TraceClassName       = config.GetExplicit("TraceClassName");
                //remoteRunSource.CreateRunSourceDomain = config.Get("CreateRunSourceDomain").zTryParseAs<bool>(true);
                // ATTENTION si CreateRunSourceDomain = true runsource.launch.exe ne peut pas mettre à jour runsource.runsource.exe
                remoteRunSource.CreateRunSourceDomain = config.Get("CreateRunSourceDomain").zTryParseAs <bool>(false);
                IRunSource runSource = remoteRunSource.GetRunSource();
                runSource.AllowMultipleExecution = config.Get("AllowMultipleExecution").zTryParseAs(false);
                // ATTENTION Trace exists in both 'runsource.runsource.exe' and 'runsource.dll'
                // donc il faut utiliser RemoteRunSource.GetTrace()
                ITrace trace = remoteRunSource.GetTrace();
                //trace.SetLogFile(config.Get("Log").zRootPath(zapp.GetAppDirectory()), config.Get("Log/@LogOptions").zTextDeserialize(LogOptions.None));
                // .zRootPath(zapp.GetAppDirectory())
                trace.SetWriter(config.Get("Log"), config.Get("Log/@option").zTextDeserialize(FileOption.None));

                //runSource.GenerateAndExecuteManager.GenerateAssemblyDirectory = config.Get("GenerateAssemblyDirectory", "run").zRootPath(zapp.GetAppDirectory());
                // ATTENTION appeler DeleteGeneratedAssemblies() après SetRunSourceConfig()
                //runSource.DeleteGeneratedAssemblies();
                //RunSourceForm_v1 form = new RunSourceForm_v1(runSource, trace, config, GetRunSourceRestartParameters());
                RunSourceForm form = new RunSourceForm(runSource, trace, config, GetRunSourceRestartParameters());

                //form.UpdateRunsourceFiles += FormUpdateRunsourceFiles;
                form.SetRestartRunsource += FormSetRestartRunsource;
                Application.Run(form);
                //if (_projectFiles != null)
                SetRunSourceRestartParameters();
                //SetRunSourceUpdateParameters();

                //if (_updateProgram)
                //{
                //    _updateProgram = false;
                //    return 1;
                //}
                //else
                //    return 0;
                //Application.Exit();
            }
            catch (Exception ex)
            {
                zerrf.ErrorMessageBox(ex);
                //return 0;
            }
        }