public async Task ReadGDriveFile() { string fileId = "0BxmMOBL2mKJ9YjJ6WDhReXcxQVE"; byte[] startFileResults = new byte[256]; await ExcelAnalyzer.GetGoogleDriveFileAsync(fileId, OAUTH_TOKEN, async s => { Assert.IsTrue(s.Read(startFileResults, 0, 256) > 0); }); }
public AnalysisController(IHostingEnvironment env, /*IAnalysisRepository repository,*/ /*ExcelAnalyzer excelAnalyzer,*/ ILogger <AnalysisController> logger) { _env = env; _logger = logger; //_repository = repository; // skipping the dependency injection because it seems to be broken in the Google Cloud _logger?.LogInformation("Starting AnalysisController"); _repository = AnalysisRepositoryFactory.CreateRepository(GetDbContextOptions()); //_excelAnalyzer = excelAnalyzer; _excelAnalyzer = new ExcelAnalyzer(_repository); }
public async Task <IActionResult> Start(string id) { if (string.IsNullOrWhiteSpace(id)) { throw new ArgumentNullException("id"); } string oauthToken = OAuthToken; if (string.IsNullOrWhiteSpace(oauthToken)) { _logger.LogWarning($"Analysis requested but no OAuth token was provided. File id was { id }"); throw new SecurityException("No OAuth token provided in request"); } int analysisId; try { _logger.LogInformation($"Adding Google File to database for starting anaylsis: { id }"); _logger.LogInformation($"Using connection string: { _repository.ConnectionString }"); analysisId = await _repository.StartAnalysisAsync(id); } catch (Exception err) { // TODO: create proper EventIds for logging _logger?.LogError(0, err, "Unable to save new analysis to database"); throw err; } // start analyzing immediately on new thread ThreadPool.QueueUserWorkItem(async s => { _logger.LogInformation("Starting analysis for Google file { id }"); // Can't use Dependency Injection because our calling thread will // dispose the objects var excelAnalyzer = new ExcelAnalyzer( AnalysisRepositoryFactory.CreateRepository(GetDbContextOptions())); await excelAnalyzer.AnalyzeAsync(analysisId, id, oauthToken); }); return(Ok()); }
public async Task AnalyzeExcelSheetAsync() { MappingConfig.RegisterMaps(); // open test excel file string excelFile = Path.Combine( Directory.GetCurrentDirectory(), "TestBook1.xlsx"); using (var stream = new FileStream(path: excelFile, mode: FileMode.Open)) { var context = new AnalysisContext(); var repo = new AnalysisRepository(context); var analyzer = new ExcelAnalyzer(repo); await analyzer.AnalyzeAsync(1, "1", stream); } }
public Report GenerateReport(Patient pat, string path) { Report report = new Report(); //Use ExcelAnalyzer object to get the values. ExcelAnalyzer doc = new ExcelAnalyzer(); //Open Excel file doc.excel_init(path); #region ExcelPull string LStrideNumber = doc.excel_getValue("B5"); if (LStrideNumber != "") { report.LStrideNumber = Math.Round(Convert.ToDouble(LStrideNumber), 2); } else { report.LStrideNumber = 0; } string LStancePercent = doc.excel_getValue("B6"); if (LStancePercent != "") { report.LStancePercent = Math.Round(Convert.ToDouble(LStancePercent), 3) * 100; } else { report.LStancePercent = 0; } string LSwingPercent = doc.excel_getValue("B7"); if (LSwingPercent != "") { report.LSwingPercent = Math.Round(Convert.ToDouble(LSwingPercent), 3) * 100; } else { report.LSwingPercent = 0; } string LSingleLimbStancePercent = doc.excel_getValue("B8"); if (LSingleLimbStancePercent != "") { report.LSingleLimbStancePercent = Math.Round(Convert.ToDouble(LSingleLimbStancePercent), 3) * 100; } else { report.LSingleLimbStancePercent = 0; } string RStrideNumber = doc.excel_getValue("B11"); if (RStrideNumber != "") { report.RStrideNumber = Math.Round(Convert.ToDouble(RStrideNumber), 2); } else { report.RStrideNumber = 0; } string RStancePercent = doc.excel_getValue("B12"); if (RStancePercent != "") { report.RStancePercent = Math.Round(Convert.ToDouble(RStancePercent), 3) * 100; } else { report.RStancePercent = 0; } string RSwingPercent = doc.excel_getValue("B13"); if (RSwingPercent != "") { report.RSwingPercent = Math.Round(Convert.ToDouble(RSwingPercent), 3) * 100; } else { report.RSwingPercent = 0; } string RSingleLimbStancePercent = doc.excel_getValue("B14"); if (RSingleLimbStancePercent != "") { report.RSingleLimbStancePercent = Math.Round(Convert.ToDouble(RSingleLimbStancePercent), 3) * 100; } else { report.RSingleLimbStancePercent = 0; } string AverageGaitSpeed = doc.excel_getValue("B15"); if (AverageGaitSpeed != "") { report.AverageGaitSpeed = Math.Round(Convert.ToDouble(AverageGaitSpeed), 3) * 100; } else { report.AverageGaitSpeed = 0; } string LeftStrideLength = doc.excel_getValue("B15"); if (LeftStrideLength != "") { report.LeftStrideLength = Math.Round(Convert.ToDouble(LeftStrideLength), 2); } else { report.LeftStrideLength = 0; } string RightStrideLength = doc.excel_getValue("B15"); if (RightStrideLength != "") { report.RightStrideLength = Math.Round(Convert.ToDouble(RightStrideLength), 2); } else { report.RightStrideLength = 0; } string Candence = doc.excel_getValue("B15"); if (Candence != "") { report.Candence = Math.Round(Convert.ToDouble(Candence), 2); } else { report.Candence = 0; } #endregion //Close Excel doc.excel_close(); return(report); }