Skip to content

Commit

Permalink
[AB#43] User can specify export interval minutes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shuai Zhang committed Dec 20, 2019
1 parent d3c11e7 commit 5e0c220
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 49 deletions.
48 changes: 24 additions & 24 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-format": {
"version": "3.1.37601",
"commands": [
"dotnet-format"
]
},
"fantomas-tool": {
"version": "3.1.0",
"commands": [
"fantomas"
]
},
"dotnet-ef": {
"version": "3.1.0",
"commands": [
"dotnet-ef"
]
}
}
}
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-format": {
"version": "3.1.37601",
"commands": [
"dotnet-format"
]
},
"fantomas-tool": {
"version": "3.1.0",
"commands": [
"fantomas"
]
},
"dotnet-ef": {
"version": "3.1.0",
"commands": [
"dotnet-ef"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,13 @@ namespace GeothermalResearchInstitute.Wpf.ViewModels
"Performance", "CA1822", Justification = "ViewModel.")]
public class DeviceMetricHistoryExportViewModel : BindableBase
{
private static readonly TimeSpan[] CandidateExportTimeSpans = new TimeSpan[]
{
TimeSpan.FromSeconds(10),
};

private readonly ILogger<DeviceMetricHistoryExportViewModel> logger;
private readonly IOptions<CoreOptions> coreOptions;
private readonly DeviceService.DeviceServiceClient client;
private ViewModelContext viewModelContext;
private DateTime startDateTime = DateTime.Now.Subtract(TimeSpan.FromDays(1));
private DateTime endDateTime = DateTime.Now;
private TimeSpan selectedTimeSpan = CandidateExportTimeSpans[0];
private int intervalMinutes = 10;

public DeviceMetricHistoryExportViewModel(
ILogger<DeviceMetricHistoryExportViewModel> logger,
Expand All @@ -51,8 +46,6 @@ public DeviceMetricHistoryExportViewModel(
this.ExportCommand = new DelegateCommand(this.ExecuteExport, this.CanExport);
}

public ICollection<TimeSpan> ExportTimeSpans => CandidateExportTimeSpans;

public ViewModelContext ViewModelContext
{
get => this.viewModelContext;
Expand All @@ -79,10 +72,10 @@ public DateTime EndDateTime
}
}

public TimeSpan SelectedTimeSpan
public int IntervalMinutes
{
get => this.selectedTimeSpan;
set => this.SetProperty(ref this.selectedTimeSpan, value);
get => this.intervalMinutes;
set => this.SetProperty(ref this.intervalMinutes, value);
}

public DelegateCommand ExportCommand { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,22 @@
Grid.Column="0"
VerticalAlignment="Center"
Content="时间间隔:" />
<ComboBox
Grid.Row="2"
Grid.Column="1"
VerticalAlignment="Center"
ItemsSource="{Binding ExportTimeSpans}"
SelectedItem="{Binding SelectedTimeSpan}">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=TotalSeconds, StringFormat={}{0:# 秒}}" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Grid Grid.Row="2" Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox
Grid.Column="0"
Height="20"
VerticalAlignment="Center"
Text="{Binding IntervalMinutes}" />
<TextBlock
Grid.Column="1"
Padding="5,0"
VerticalAlignment="Center"
Text="分钟" />
</Grid>
</Grid>
</DockPanel>
</Grid>
Expand Down
28 changes: 28 additions & 0 deletions dev-support/bin/format.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
param(
[Switch] $ChangedOnly
)

$ErrorActionPreference = "Stop"

$EnlistmentRoot = [System.IO.Path]::GetDirectoryName([System.IO.Path]::GetDirectoryName($PSScriptRoot))
$DosToUnixExec = Join-Path $EnlistmentRoot "dev-support/bin/dos2unix.exe"

Push-Location $EnlistmentRoot

if ($ChangedOnly) {
git status -s `
| ForEach-Object { & $DosToUnixExec ($_.Trim() -split "\s+")[1] }
} else {
# Get-ChildItem $EnlistmentRoot `
# -Recurse `
# -Exclude (Join-Path $EnlistmentRoot "third_party"), (Join-Path $EnlistmentRoot "output") `
# -Include "*.adoc", `
# "*.ini", "*.json", "*.yml", `
# "*.html", "*.xaml", `
# "*.cs", "*.fs", "*.proto", `
# "*.props", "*.*proj", "*.sln" `
# | ForEach-Object { & $DosToUnixExec $_.FullName }
}
dotnet.exe format

Pop-Location

0 comments on commit 5e0c220

Please sign in to comment.