Пример #1
0
        public async void ImportFrom_GoogleDocs()
        {
            var excelImport = RestApiApplication.CreateContainer().Resolve<Repository.Import.ExcelImport>();

            var downloader = new GoogleDriveDownloader();

            var documentId = Environment.GetEnvironmentVariable("BBR_GoogleDocId", EnvironmentVariableTarget.User);
 
            if(string.IsNullOrEmpty(documentId))
                Assert.Fail("Cannot import if documentId is not set in environment variable");

            var content = await downloader.LastNedSpreadsheetFraGoogleDrive(documentId);
            excelImport.LesInn(content);
        }
Пример #2
0
        public async Task<HttpResponseMessage> ConvertMapToExcel(string documentId)
        {
            var downloader = new GoogleDriveDownloader();

            var content = await downloader.LastNedMapFraGoogleDrive(documentId);
           
            var poster = _kmlToExcelPoster.LesInn(content);
            _excelWriter.SkrivPoster(poster);
            var bytes = _excelWriter.GetAsByteArray();

            var result = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StreamContent(new MemoryStream(bytes))
            };
            result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.ms-excel");
            result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") {FileName = "kml_poster.xlsx"};

            return result;
        }
Пример #3
0
        public async Task<IHttpActionResult> ConfigureFromGoogleMap(string documentId)
        {
            var downloader = new GoogleDriveDownloader();

            var content = await downloader.LastNedMapFraGoogleDrive(documentId);

            var poster = _kmlToExcelPoster.LesInn(content);

            var matchId = _matchProvider.GetMatchId();

            MatchImport.ExcelMatch excelMatch;
            using (var context = _dataContextFactory.Create())
            {
                var match = context.Matcher.SingleOrDefault(x => x.MatchId == matchId);
                excelMatch = MatchImport.ExcelMatch.FromMatch(match);
                excelMatch.DefaultPoengFordeling = "100,90,80,70,60"; // TODO: Lagre default fra import
            }
            
            _excelWriter.SkrivTilExcel(excelMatch, null, poster);
            var bytes = _excelWriter.GetAsByteArray();
            _excelImport.LesInn(bytes);

            ClearCaching();

            return Ok();
        }
Пример #4
0
        public async Task<IHttpActionResult> ConfigureFromGoogleDrive(string documentId)
        {
            var downloader = new GoogleDriveDownloader();

            var content = await downloader.LastNedSpreadsheetFraGoogleDrive(documentId);
            _excelImport.LesInn(content);

            ClearCaching();

            return Ok();
        }