Ejemplo n.º 1
0
        private void LoadConfig()
        {
            if (File.Exists("config.json"))
            {
                _cfg = JsonConvert.DeserializeObject <ConfigATP>(File.ReadAllText("config.json"));
            }
            else
            {
                _cfg = new ConfigATP();
            }
            //此处已完成接口启动
            if (_t != null)
            {
                _t._q = this._q;
                _t.StartFollow(_cfg.FloConfig);
            }
            //foreach (var file in _cfg.StrategyFiles)
            //20170307:读取指定目录策略文件
            Directory.CreateDirectory("./strategies");
            var files = new DirectoryInfo("./strategies").GetFiles("*.dll", SearchOption.AllDirectories).ToList();

            files.Add(new FileInfo("./at_strategy.dll")); //测试用
            foreach (var file in files)
            {
                //if (File.Exists(file))
                LoadStrategyFile(file.FullName);
            }
            //本执行文件中的策略
            LoadStrategyFile(Application.ExecutablePath);
        }
Ejemplo n.º 2
0
        async Task<IFormFileCollection> IFileService.UppFiles(IFormFileCollection file,
            List<FileDetail> fileDetailList,
            IHostingEnvironment _appEnvironment)
        {
            var filePath = _appEnvironment.WebRootPath + "/Files/";
            var filesNames = new DirectoryInfo(filePath)
                .EnumerateFiles()
                ?.Select(f => f.Name)
                .ToList();

            IFormFileCollection uploadedFiles = file;
            foreach (var uploaded in uploadedFiles)
            {
                if (uploaded != null)
                {
                    string fileName = CreateName(filesNames, uploaded);

                    using (var fileStream = new FileStream(filePath + fileName, FileMode.Create))
                    {
                        await uploaded.CopyToAsync(fileStream);
                    }

                    fileDetailList.Add(new FileDetail
                    {
                        Name = uploaded.FileName,
                        Path = "/Files/" + fileName
                    });

                    filesNames.Add(fileName);
                }
            }

            return uploadedFiles;
        }
Ejemplo n.º 3
0
        public void test_barcode_reader()
        {
            var files1 = new DirectoryInfo(@"C:\spain\BBVA\BBVA examples 18 digit").GetFiles();
            var files2 = new DirectoryInfo(@"C:\spain\Thales Examples\Thales Examples").GetFiles();
            var files3 = new DirectoryInfo(@"C:\spain\Verifone Examples\Verifone Examples").GetFiles();
            var files4 = new DirectoryInfo(@"C:\spain\Verifone Examples - TOPOS\Verifone Examples - TOPOS").GetFiles();

            var files = files1.Add(files2).Add(files3).Add(files4);

            StateSaver.Default.Path = "asd";
            StateSaver.Default.Load();
            List <BarcodeConfig> barcodeLayouts = StateSaver.Default.Get <List <BarcodeConfig> >(Strings.LIST_OF_BARCODECONFIGS);

            foreach (var fileName in files)
            {
                Debug.WriteLine(fileName);

                Bitmap bmp        = (Bitmap)Bitmap.FromFile(fileName.FullName);
                Bitmap bmpBarcode = null;
                {
                    var time = Stopwatch.StartNew();

                    System.Drawing.Rectangle rect = System.Drawing.Rectangle.Empty;
                    string barcode = null;
                    bool   result  = CommonTools.ParseVoucherImage(ref bmp, ref bmpBarcode, out rect, ref barcode);
                    Assert.IsTrue(result);

                    BarcodeData data = null;

                    foreach (var cfg in barcodeLayouts)
                    {
                        if (cfg.ParseBarcode(barcode, ref data))
                        {
                            break;
                        }
                    }

                    if (data == null)
                    {
                        Debug.WriteLine("Wrong barcode " + barcode);
                    }

                    Debug.WriteLine(time.Elapsed);
                }

                Debug.WriteLine("===================================");
            }
        }
        /// <summary>
        /// Boot process, before the <see cref="StartUp"/> method is called
        /// </summary>
        /// <param name="args">The arguments.</param>
        /// <param name="_logger">The logger.</param>
        protected void startUpProcess(String[] args, ILogBuilder _logger)
        {
            logger = _logger;
            if (args == null)
            {
                args = new string[] { }
            }
            ;
            commandLineArguments.AddRange(args);

            AppDomain.CurrentDomain.UnhandledException += ReactTo_UnhandledException;
            AppDomain.CurrentDomain.ProcessExit        += CurrentDomain_ProcessExit;

            String appDirectory = AppDomain.CurrentDomain.BaseDirectory; //Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().GetName().CodeBase);

            Environment.CurrentDirectory = appDirectory;

            state = new aceApplicationState();

            setAboutInformation();

            folder = new DirectoryInfo(appDirectory);

            // creating folders subsystem
            folder_cache     = folder.Add(aceApplicationInfo.FOLDERNAME_CACHE, "Cache", "Repository of [" + name + "] application general cache");
            folder_reports   = folder.Add(aceApplicationInfo.FOLDERNAME_REPORTS, "Reporting output", "Repository with reports generated by [" + name + "] application");
            folder_resources = folder.Add(aceApplicationInfo.FOLDERNAME_RESOURCES, "Resources", "Repository with resources used by [" + name + "] application");
            folder_config    = folder.Add(aceApplicationInfo.FOLDERNAME_CONFIG, "Configuration", "Application [" + name + "] configuration files");
            folder_plugins   = folder.Add(aceApplicationInfo.FOLDERNAME_PLUGINS, "Plug-ins", "Directory with 3rd party plug-ins for application [" + name + "]. Use subdirectories to organize plug-ins into groups.");
            folder_projects  = folder.Add(aceApplicationInfo.FOLDERNAME_PROJECTS, "Projects", "Directory with 3rd party plug-ins for application [" + name + "]. Use subdirectories to organize plug-ins into groups.");
            folder_logs      = folder.Add(aceApplicationInfo.FOLDERNAME_LOGS, "Logs", "Diagnostic data for [" + name + "] application.");

            if (logger == null)
            {
                logger = aceLog.loger;
            }

            aceCommons.crashReportPath = folder_logs.path;

            imbSCI.Core.screenOutputControl.logToConsoleControl = aceLog.consoleControl;

            // loading settings -----------------------------------------------------------------------\

            settings = new aceApplicationSettings();
            settings.Load(folder_config);

            deploySettings();

            // ----------------------------------------------------------------------------------------/

            // setting up the culture
            Console.OutputEncoding = Encoding.UTF8;
            state.culture          = CultureInfo.CreateSpecificCulture(settings.Culture);
            Thread.CurrentThread.CurrentCulture   = state.culture;
            Thread.CurrentThread.CurrentUICulture = state.culture;

            // setup the cache system
            if (settings.CachePathOverride.isNullOrEmpty())
            {
                cacheSystem.defaultCacheDirectoryPath = folder_cache.path;
            }
            else
            {
                cacheSystem.defaultCacheDirectoryPath = settings.CachePathOverride;
            }

            // loading plug-ins
            plugins = new pluginManager(folder_plugins);
            if (settings.LoadPluginsOnStartUp)
            {
                plugins.loadPlugins(aceLog.loger, folder_plugins);
            }

            // <------------ calling "loaded" event
            callEventApplicationLoaded();
        }