Skip to content

Commit

Permalink
New version 1.0.3
Browse files Browse the repository at this point in the history
  Fix: Änderungen wurden nicht mehr direkt gespeichert. Erst beim Beenden des Programms.
  Update: Import Dialog überarbeitet.
  • Loading branch information
punker76 committed Dec 12, 2016
1 parent 25acf2f commit 7bd2bb3
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 79 deletions.
Binary file modified .paket/paket.exe
Binary file not shown.
6 changes: 3 additions & 3 deletions MONI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("1.0.2.0")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyProduct("moni 1.0.2.0")]
[assembly: AssemblyVersion("1.0.3.0")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyProduct("moni 1.0.3.0")]
8 changes: 2 additions & 6 deletions MONI/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Windows.Input;
using System.Windows.Threading;
using GongSolutions.Wpf.DragDrop;
using MahApps.Metro.Controls.Dialogs;
using MONI.Data;
using MONI.Util;
using NLog;
Expand Down Expand Up @@ -42,7 +43,6 @@ public class MainViewModel : ViewModelBase, IDropTarget
private ICommand previousMonthCommand;
private ICommand previousWeekCommand;
private Visibility projectHitListVisibility;
private bool showPasswordDialog;
private WorkMonth workMonth;
private WorkWeek workWeek;
private WorkYear workYear;
Expand Down Expand Up @@ -260,11 +260,7 @@ private MoniSettings MonlistSettings

public string CurrentMonthMonlistImportFile { get; private set; }

public bool ShowPasswordDialog
{
get { return this.showPasswordDialog; }
set { this.Set(ref this.showPasswordDialog, value); }
}
public LoginDialogData MonlistImportLoginData { get; internal set; }

public void DragOver(IDropInfo dropInfo)
{
Expand Down
57 changes: 0 additions & 57 deletions MONI/Views/MainView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1107,62 +1107,5 @@
</ListBox>
</Grid>

<!-- get user password -->
<Grid Visibility="{Binding ElementName=mv, Path=ViewModel.ShowPasswordDialog, Converter={StaticResource false2CollapsedConverter}}">
<Border Background="SkyBlue"
Opacity="0.7" />
<TextBlock FontSize="80"
FontWeight="Bold"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="#2CB4EB"
Margin="0 0 300 200">
passwort bitte
</TextBlock>
<Border Background="White"
Width="400"
Height="150">
<Grid VerticalAlignment="Center"
Margin="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Foreground="White" Background="Red" FontWeight="Bold" TextWrapping="Wrap">
Hierduch wird der gesamte, aktuell angezeigte Monat in MonList ersetzt. Alle Daten in MonList werden hierdurch überschrieben!
</TextBlock>
<Label Grid.Column="0"
Grid.Row="2">
Passwort
</Label>
<PasswordBox Grid.Column="1"
Grid.Row="2"
Margin="2"
x:Name="passwordBox" />

<Button Grid.Column="0"
Grid.Row="3"
Margin="0,0,2,0"
Click="PasswordCancel_OnClick">
Abbrechen
</Button>
<Button Grid.Column="1"
Grid.Row="3"
Margin="2,0,0,0"
Click="PasswordOK_OnClick"
IsDefault="True">
OK
</Button>
</Grid>
</Border>
</Grid>

</Grid>
</Controls:MetroWindow>
55 changes: 42 additions & 13 deletions MONI/Views/MainView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using MONI.Util;
using MONI.ViewModels;
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
using Newtonsoft.Json;
using NLog;

Expand Down Expand Up @@ -301,10 +302,45 @@ private void EditPreferencesSave_OnClick(object sender, RoutedEventArgs e)
this.CheckForMonlist();
}

private void ToMonlist_Button_Click(object sender, RoutedEventArgs e)
private async void ToMonlist_Button_Click(object sender, RoutedEventArgs e)
{
this.ViewModel.ShowPasswordDialog = true;
this.passwordBox.Focus();
var message = "Hierduch wird der gesamte, aktuell angezeigte Monat in MonList ersetzt. Alle Daten in MonList werden hierdurch überschrieben!";
if (this.ViewModel.MonlistImportLoginData != null)
{
var settings = new MetroDialogSettings()
{
AffirmativeButtonText = "Importieren",
NegativeButtonText = "Abbrechen",
};
MessageDialogResult result = await this.ShowMessageAsync("Monlist Daten-Import", message, MessageDialogStyle.AffirmativeAndNegative, settings);
if (result == MessageDialogResult.Affirmative)
{
this.UploadToMonlist(this.ViewModel.MonlistImportLoginData.Password);
}
}
else
{
var settings = new LoginDialogSettings
{
ShouldHideUsername = !string.IsNullOrWhiteSpace(this.ViewModel.Settings.MainSettings.MonlistEmployeeNumber),
EnablePasswordPreview = true,
AffirmativeButtonText = "Importieren",
NegativeButtonText = "Abbrechen",
NegativeButtonVisibility = Visibility.Visible
};
LoginDialogData result = await this.ShowLoginAsync("Monlist Daten-Import", message + "\n\nPasswort", settings);
if (result != null && !string.IsNullOrWhiteSpace(result.Password))
{
// user pressed ok
if (!settings.ShouldHideUsername)
{
this.ViewModel.Settings.MainSettings.MonlistEmployeeNumber = result.Username;
}
this.ViewModel.MonlistImportLoginData = result;

this.UploadToMonlist(result.Password);
}
}
}

private void WorkDayTextBox_OnGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
Expand Down Expand Up @@ -347,30 +383,23 @@ private void WorkDayTextBox_OnKeyDown(object sender, KeyEventArgs e)
}
}

private void PasswordCancel_OnClick(object sender, RoutedEventArgs e)
{
this.ViewModel.ShowPasswordDialog = false;
}

private void PasswordOK_OnClick(object sender, RoutedEventArgs e)
private void UploadToMonlist(string password)
{
this.ViewModel.ShowPasswordDialog = false;
var password = this.passwordBox.Password;
string user = this.ViewModel.Settings.MainSettings.MonlistEmployeeNumber;
if (!string.IsNullOrWhiteSpace(password))
{
// decide if you want to use monapi
if (!this.ViewModel.Settings.MainSettings.UseMonApi)
{
var currentMonthMonlistImportFile = this.ViewModel.CurrentMonthMonlistImportFile;
string user = this.ViewModel.Settings.MainSettings.MonlistEmployeeNumber;
string pw = password;
var args = string.Format("--user=\"{0}\" --pw=\"{1}\" --monat=\"{2}\" --jahr=\"{3}\" --file=\"{4}\"", user, pw, this.ViewModel.WorkMonth.Month, this.ViewModel.WorkMonth.Year, currentMonthMonlistImportFile);
Process.Start(this.ViewModel.Settings.MainSettings.MonlistExecutablePath, args);
}
else
{
int usernumberAsInt;
if (int.TryParse(this.ViewModel.Settings.MainSettings.MonlistEmployeeNumber, out usernumberAsInt))
if (int.TryParse(user.Trim('0'), out usernumberAsInt))
{
var me = new MonapiJSONExporter(usernumberAsInt);
var jsonData = me.Export(this.ViewModel.WorkMonth);
Expand Down
8 changes: 8 additions & 0 deletions moni_updates.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,12 @@
],
"DownLoadURL": "https://github.com/dotob/moni/releases/download/1.0.2/MONI.exe"
},
{
"Version": "1.0.3",
"Changes": [
"Fix: Änderungen wurden nicht mehr direkt gespeichert. Erst beim Beenden des Programms.",
"Update: Import Dialog überarbeitet.",
],
"DownLoadURL": "https://github.com/dotob/moni/releases/download/1.0.3/MONI.exe"
},
]

0 comments on commit 7bd2bb3

Please sign in to comment.