/// <inheritdoc /> /// <summary> /// Gets the and store GPS data. /// </summary> /// <param name="activityId">The activity identifier.</param> /// <param name="fileFormat">File format.</param> /// <param name="fileName">Name of the file.</param> /// <returns>Task result</returns> public async Task GetAndStoreGpsData(long activityId, ActivityFileTypeEnum fileFormat, string fileName) { this.logger.LogInformation($"Downloading of GPS data in {fileFormat.ToString()} format started."); using (var data = await this.client.DownloadActivityFile(activityId, fileFormat)) { //data.Position = 0; await this.storage.StoreData(fileName, data); } this.logger.LogInformation($"Downloading of GPS data in {fileFormat.ToString()} format done."); }
/// <inheritdoc /> /// <summary> /// Downloads the activity file. /// </summary> /// <param name="activityId">The activity identifier.</param> /// <param name="fileFormat">The file format.</param> /// <returns> /// Stream /// </returns> public async Task <Stream> DownloadActivityFile(long activityId, ActivityFileTypeEnum fileFormat) { var url = fileFormat == DefaultFile ? string.Format(UrlActivityDownloadDefaultFile, activityId) : string.Format(UrlActivityDownloadFile, fileFormat.ToString().ToLower(), activityId); Stream streamCopy = new MemoryStream(); using (var res = await this.httpClient.GetAsync(url)) { await(await res.Content.ReadAsStreamAsync()).CopyToAsync(streamCopy); return(streamCopy); } }
/// <inheritdoc /> /// <summary> /// Creates the name of the GPS file map. /// </summary> /// <param name="exportFormat">The export format.</param> /// <returns>GPS file name</returns> public string CreateGpsFileMapName(ActivityFileTypeEnum exportFormat) => $"{GpsDataFile}.{(exportFormat == ActivityFileTypeEnum.Fit ? "zip" : exportFormat.ToString().ToLower())}";