Esempio n. 1
0
        public CoverageProcessorTest()
        {
            this._stubFileHelper      = Substitute.For <IFileHelper>();
            this._stubReportParser    = Substitute.For <IReportParser>();
            this._stubCoverageUpdater = Substitute.For <ICoverageUpdater>();
            this._stubNotifyer        = Substitute.For <INotifyer>();
            this._stubEmailNotifyer   = Substitute.For <INotifyer>();
            this._stubCoverageLogger  = Substitute.For <ICoverageLogger>();

            this._stubServiceProvider = Substitute.For <IServiceProvider>();
            this._stubServiceProvider.GetService <IFileHelper>().Returns(this._stubFileHelper);
            this._stubServiceProvider.GetService <IReportParser>().Returns(this._stubReportParser);
            this._stubServiceProvider.GetService <ICoverageUpdater>().Returns(this._stubCoverageUpdater);
            //this._stubServiceProvider.GetService<INotifyer>().Returns(this._stubNotifyer);
            //this._stubServiceProvider.GetService<INotifyer>().Returns(this._stubEmailNotifyer);
            //this._stubServiceProvider.GetService<INotifyer>().Returns(new SlackNotifyer(this._stubServiceProvider));
            //this._stubServiceProvider.GetService<INotifyer>().Returns(new EmailNotifyer(this._stubServiceProvider));
            this._stubServiceProvider.GetService <IEnumerable <INotifyer> >().Returns(new List <INotifyer> {
                this._stubNotifyer, this._stubEmailNotifyer
            });
            this._stubServiceProvider.GetService <ICoverageLogger>().Returns(this._stubCoverageLogger);

            //this._stubServiceProvider.GetServices<INotifyer>();
            //this._stubServiceProvider.GetServices<INotifyer>().Returns(new List<INotifyer> { this._stubNotifyer, this._stubEmailNotifyer });
        }
Esempio n. 2
0
 public CoverageProcessor(IServiceProvider serviceProvider)
 {
     this._serviceProvider = serviceProvider;
     this._fileHelper      = serviceProvider.GetRequiredService <IFileHelper>();
     this._reportParser    = serviceProvider.GetRequiredService <IReportParser>();
     this._coverageUpdater = serviceProvider.GetRequiredService <ICoverageUpdater>();
     this._coverageLogger  = serviceProvider.GetRequiredService <ICoverageLogger>();
 }
Esempio n. 3
0
 public FileEmailMessageProcessor(IReportParser <T> reportParser,
                                  IReportPersistor <T> reportPersistor,
                                  ILogger log)
 {
     _reportParser    = reportParser;
     _reportPersistor = reportPersistor;
     _log             = log;
 }
Esempio n. 4
0
 public MailboxFetcher(ILogger <MailboxFetcher> logger,
                       IServiceProvider serviceProvider,
                       IReportParser reportParser)
 {
     _logger = logger;
     _logger.LogInformation("Constructed MailboxFetcher");
     _serviceProvider = serviceProvider;
     _reportParser    = reportParser;
 }
Esempio n. 5
0
 public DeviceReader(IDeviceEndpoint endpoint, IReportParser <T> reportParser)
 {
     Endpoint     = endpoint;
     Parser       = reportParser;
     workerThread = new Thread(Main)
     {
         Name         = "OpenTabletDriver Device Reader",
         IsBackground = true,
         Priority     = ThreadPriority.AboveNormal
     };
 }
 public DeviceReader(HidDevice device, IReportParser <T> reportParser)
 {
     Device       = device;
     Parser       = reportParser;
     WorkerThread = new Thread(Main)
     {
         Name         = "OpenTabletDriver Device Reader",
         IsBackground = true,
         Priority     = ThreadPriority.BelowNormal,
     };
 }
Esempio n. 7
0
        public void Generate(Report report, Order order)
        {
            IReportParser reportParser = report switch
            {
                Report.Invoice => new InvoiceReportParser(),
                Report.CuttingList => new CuttingListReportParser(),
                Report.Painting => new PaintingReportParser(),
                _ => throw new InvalidEnumArgumentException()
            };

            _output.WriteLine(reportParser.ToStringReport(order));
        }
    }
Esempio n. 8
0
        public AmazonReportService(AmazonReportType reportType,
                                   long companyId,
                                   AmazonApi api,
                                   ILogService log,
                                   ITime time,
                                   IDbFactory dbFactory,
                                   ISyncInformer syncInfo,
                                   IStyleManager styleManager,
                                   INotificationService notificationService,
                                   IStyleHistoryService styleHistoryService,
                                   IItemHistoryService itemHistoryService,
                                   ISystemActionService actionService,
                                   IReportParser parser,
                                   string path = "")
        {
            _log       = log;
            _time      = time;
            _dbFactory = dbFactory;

            _api = api;

            _reportInfo = new AmazonReportInfo();
            _reportInfo.ReportRequestId = String.Empty;

            _path          = path;
            _companyId     = companyId;
            _syncInfo      = syncInfo;
            _reportType    = reportType;
            _parser        = parser;
            _actionService = actionService;

            var parseContext = new ParseContext()
            {
                Log                 = log,
                Time                = time,
                DbFactory           = dbFactory,
                ActionService       = actionService,
                StyleManager        = styleManager,
                NotificationService = notificationService,
                StyleHistoryService = styleHistoryService,
                ItemHistoryService  = itemHistoryService,
                SyncInformer        = syncInfo,
                CompanyId           = companyId
            };

            _parser.Init(parseContext);

            _log.Info(string.Format("Path: {0}", path));
        }
Esempio n. 9
0
        public DeviceReader(HidDevice device, IReportParser <T> reportParser)
        {
            Device       = device;
            Parser       = reportParser;
            WorkerThread = new Thread(Main)
            {
                Name         = "OpenTabletDriver Device Reader",
                IsBackground = true,
                Priority     = ThreadPriority.AboveNormal,
            };

            try
            {
                ReportStream = Device.Open();
                WorkerThread.Start();
            }
            catch
            {
                throw new IOException("Failed to open stream");
            }
        }
Esempio n. 10
0
 public SimianToolExecutor(IReportParser reportParser)
 {
     _reportParser = reportParser;
 }
Esempio n. 11
0
 public TicsToolExecutor(IReportParser reportParser)
 {
     _reportParser = reportParser;
 }
Esempio n. 12
0
 public static Maybe <IReportNode[]> List(this Maybe <TextParser> p, ReadOnlySpan <char> separator, IReportParser itemParser)
 => p?List(p.Value, separator, itemParser) : p.Convert <IReportNode[]>();
 public ReportOutput(IReportParser reportParser, IReportPrinter reportPrinter)
 {
     _reportParser  = reportParser;
     _reportPrinter = reportPrinter;
 }
Esempio n. 14
0
 public static Maybe <IReportNode> Try(this Maybe <TextParser> parser, IReportParser reportParser)
 => Try(parser, reportParser.Parse);
Esempio n. 15
0
 public static Maybe <IReportNode[]> List(this TextParser p, ReadOnlySpan <char> separator, IReportParser itemParser)
 => List(p, separator, x => itemParser.Parse(x));
Esempio n. 16
0
 public UnitCanStudyParser(IReportParser skillParser)
 {
     this.skillParser = skillParser;
 }
Esempio n. 17
0
        static void Run(Options options)
        {
            options.Print(Console.Out);

            string inputFolder = Path.GetFullPath(options.InputFolder);

            if (!Directory.Exists(inputFolder))
            {
                Console.WriteLine("Input file folder {0} does not exist.", inputFolder);
                return;
            }

            DataDictionary dataDictionary = new DataDictionary();

            if (!string.IsNullOrEmpty(options.DataDictionaryFile))
            {
                dataDictionary.Load(options.DataDictionaryFile);
            }

            DataDictionary newDataDictionary = new DataDictionary(dataDictionary);

            IReportParser parser = ReportParserFactory.Create(options.FinanceReportFileType, dataDictionary, Console.Error);

            List <FinanceReport> reports = new List <FinanceReport>();

            foreach (var file in Directory.EnumerateFiles(inputFolder))
            {
                string code = Path.GetFileNameWithoutExtension(file);

                if (string.IsNullOrWhiteSpace(code))
                {
                    Console.WriteLine("The file name {0} is not expected", file);
                }

                FinanceReport report = parser.ParseReport(code, file);

                if (report == null)
                {
                    Console.WriteLine("Parse report file {0} failed.", file);
                }
                else
                {
                    Console.WriteLine("Parse report for {0}:{1} succeeded.", report.CompanyCode, report.CompanyName);

                    AddReportMetadataToDataDictionary(report, newDataDictionary);

                    reports.Add(report);
                }
            }

            // normalize each report according to data dictionary
            foreach (var report in reports)
            {
                report.Normalize(newDataDictionary);
            }

            // expand and merge tables in reports
            ExpandAndMergeTables(reports);

            // create revenue table for last 12 months
            CreateRevenueTableForLast12Months(reports);

            // output reports
            OutputReports(reports, options.OutputFolder);

            // save new data dictionary if necessary.
            if (!string.IsNullOrEmpty(options.GenerateDataDictionaryFile))
            {
                newDataDictionary.Save(options.GenerateDataDictionaryFile);
            }

            Console.WriteLine("Done.");
        }
Esempio n. 18
0
 public UnitSkillsParser(IReportParser skillParser)
 {
     this.skillParser = skillParser;
 }
 public EmailMessageInfoProcessor(IReportParser <TDomain> parser,
                                  ILogger log)
 {
     _parser = parser;
     _log    = log;
 }
Esempio n. 20
0
 public static Maybe <IReportNode> ParseMaybe(this IReportParser parser, Maybe <TextParser> p)
 => p?parser.Parse(p.Value) : p.Convert <IReportNode>();