static void ExecuteApp() { IFileWriteService fileWriteServices = new FileWriteService(); IHendler <ImportFileCommand> importFileHendler = new ImportFileHendler(fileWriteServices); IFileReadService fileReadService = new FileReadService(); do { Count++; Console.Clear(); Console.WriteLine($"Processamento iniciado: {Count}"); Console.WriteLine(new ImportFileApp(importFileHendler, fileReadService, Configuration).ImportFile()); Console.WriteLine("Processamento finalizado."); Console.WriteLine("Deseja encerrar o Aplicativo? (s/n): "); string readLine; bool sucess = LineReader.TryReadLine(out readLine, int.Parse(Configuration["TimingToExecute"])); if (sucess) { if (readLine.ToLower().Equals("s")) { Exit = true; } } } while (!Exit); Process.GetCurrentProcess().Kill(); }
public void ExecuteAppTest() { IFileWriteService fileWriteServices = new FileWriteService(); IHendler <ImportFileCommand> importFileHendler = new ImportFileHendler(fileWriteServices); IFileReadService fileReadService = new FileReadService(); string retorno = new ImportFileApp(importFileHendler, fileReadService, Configuration).ImportFile(); }
public HomeController() { this.readPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/SDLC.mpp"); this.taskService = new GanttTaskService(); this.dependencyService = new GanttDependencyService(); this.resourceService = new GanttResourceService(); this.assignmentService = new GanttAssignmentService(); this.fileWriteService = new FileWriteService(); }
public void Write_Html_File() { //init var xsltStr = "Html string"; var fileName = "test.html"; //Setup var mockRepository = new Mock <IFileWriteRepository>(); mockRepository.Setup(m => m.WriteHtmlFile(xsltStr, fileName)).Returns(true); var fileWriteService = new FileWriteService(mockRepository.Object); //act var status = fileWriteService.WriteHtmlFile(xsltStr, fileName); //assert Assert.AreEqual(status, true); }
public void Write_Html_File() { //init var xsltStr = "Html string"; var fileName = "test.html"; //Setup var mockRepository = new Mock <IFileWriteRepository>(); mockRepository.Setup(m => m.WriteHtmlFile(xsltStr, _airTicketsSettings.OutputHtmlPath, fileName)).Returns(Task.FromResult(true)); var fileWriteService = new FileWriteService(mockRepository.Object, _airTicketsSettings); //act var status = fileWriteService.WriteHtmlFile(xsltStr, fileName); //assert Assert.True(status.Result); }
private void TaskBody() { this.GetDatas(this._selectedElement); var parsingSettings = this._mainForm.ParsingSettings; var newFormat = ""; var total = this._selectedElement.TotalCount.HasValue && this._selectedElement.TotalCount.Value > 0 ? this._selectedElement.TotalCount.Value : this._drawInPage; var stopTakeDrawCurrent = parsingSettings.AddToCurrent ? this._lastDrawCurrent : total; IFileWriteService fileWriteService = new FileWriteService(parsingSettings, this._selectedElement, this._cancellationTokenSource.Token, this._mainForm.UpdateProgres, this._mainForm.AppTextListBox, stopTakeDrawCurrent, this._lastDrawAll, this._loggerFactory.ErrorLogged); fileWriteService.InitialOldData(); var page = 1; var setData = true; this._startDraw = this._lastDrawCurrent + 1; try { var iteration = 0; var maximum = total; var loaded = 0; while (((parsingSettings.AddToAll ? true : (parsingSettings.AddToCurrent ? (this._startDraw > this._lastDrawCurrent || total > 0) : total > 0)))) { if (this._loadedPage == -1) { this._loadedPage = 1; newFormat = string.Format(this._appSettings.Format, this._selectedElement.PathName, 1); } else { newFormat = string.Format(this._appSettings.ContinueFormat, this._selectedElement.PathName, 1, this._startDraw); } total = total - this._drawInPage >= this._drawInPage ? total - this._drawInPage : 0; if (this._cancellationTokenSource.IsCancellationRequested) { return; } var json = this._htmlService.GetStringContent(newFormat); if (this._cancellationTokenSource.IsCancellationRequested) { return; } var postResulModel = this._jsonService.JsonConvertDeserializeObject <PostResulModel>(json); if (this._cancellationTokenSource.IsCancellationRequested) { return; } var stolotoParseResults = this._htmlParser.ParseHtml(postResulModel.Data, parsingSettings.ParsingExtraNumbers); if (this._cancellationTokenSource.IsCancellationRequested) { return; } if (iteration == 0) { maximum = parsingSettings.AddToCurrent ? stolotoParseResults.Max(val => val.Draw) - this._lastDrawCurrent : maximum; } loaded += stolotoParseResults.Count; this._mainForm.SetLoadingProgress(loaded, maximum > loaded ? maximum : loaded); fileWriteService.AppendResults(stolotoParseResults); if (setData) { setData = false; this._mainForm.UpdateDatas((new FilesData() { LastDrawCurrent = stolotoParseResults.Where(val => val.Numbers.Count > 0).Max(val => val.Draw) })); } this._selectedButton.ToolTip = new LotaryToolTip() { Status = postResulModel.Status, Page = page }; var breakIteration = (parsingSettings.AddToCurrent ? stolotoParseResults.Any(val => val.Draw <= this._lastDrawCurrent) : total == 0) && (parsingSettings.AddToAll ? stolotoParseResults.Any(val => val.Draw <= this._lastDrawAll) : true); if (postResulModel.Stop || breakIteration) { break; } this._startDraw = stolotoParseResults.Min(val => val.Draw) - 1; page++; this._loadedPage++; iteration++; } } catch (Exception ex) { this._loggerFactory.ErrorLogged(ex); } fileWriteService.Finalize(); this._loadedPage = -1; this._startDraw = -1; this._mainForm.SetLoaded(); }