-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #290 from DougSchmidt-AI/feature/PF-1365-NtdnrRepo…
…rtingTool PF-1365 - First working cut of ObservationReportExporter
- Loading branch information
Showing
8 changed files
with
379 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
319 changes: 260 additions & 59 deletions
319
Samples/DotNetSdk/ObservationReportExporter/Exporter.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
Samples/DotNetSdk/ObservationReportExporter/ExtraApis/TimeSeries/DeleteAttachmentById.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using ServiceStack; | ||
|
||
namespace ObservationReportExporter.ExtraApis.TimeSeries | ||
{ | ||
[Route("/attachments/{Id}", HttpMethods.Delete)] | ||
public class DeleteAttachmentById : IReturnVoid | ||
{ | ||
public string Id { get; set; } | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
Samples/DotNetSdk/ObservationReportExporter/FilenameGenerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace ObservationReportExporter | ||
{ | ||
public class FilenameGenerator | ||
{ | ||
public const string TemplatePattern = "Template"; | ||
public const string LocationPattern = "Location"; | ||
public const string TimePattern = "Time"; | ||
|
||
public const string DefaultAttachmentFilename = "{" + TemplatePattern + "}-{" + LocationPattern + "}.xlsx"; | ||
|
||
public static string GenerateAttachmentFilename(string attachmentFilename, string exportTemplateName, string locationIdentifier, DateTimeOffset exportTime) | ||
{ | ||
var patterns = new Dictionary<string, Func<string, string>>(StringComparer.InvariantCultureIgnoreCase) | ||
{ | ||
{ TemplatePattern, _ => exportTemplateName }, | ||
{ LocationPattern, _ => locationIdentifier }, | ||
{ TimePattern, format => exportTime.ToString(string.IsNullOrWhiteSpace(format) ? "yyyy-MM-dd" : format) } | ||
}; | ||
|
||
return PatternRegex.Replace(attachmentFilename, match => | ||
{ | ||
var pattern = match.Groups["pattern"].Value.Trim(); | ||
var format = match.Groups["format"].Value.Trim(); | ||
|
||
if (!patterns.TryGetValue(pattern, out var replacement)) | ||
throw new ExpectedException($"'{pattern}' is not a known attachment filename substitution pattern. Try one of {{{string.Join("}, {", patterns.Keys)}}}."); | ||
|
||
return replacement(format); | ||
}); | ||
} | ||
|
||
private static readonly Regex PatternRegex = new Regex(@"\{(?<pattern>[^:}]+)(:(?<format>[^}]+))?\}"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters