|
@@ -1,10 +1,13 @@
|
|
|
using System;
|
|
|
+using System.Collections.Generic;
|
|
|
using System.ComponentModel;
|
|
|
using System.Diagnostics;
|
|
|
using System.Globalization;
|
|
|
using System.IO;
|
|
|
+using System.Text.RegularExpressions;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
+using System.Windows.Input;
|
|
|
using GCHR.Control;
|
|
|
using GCHR.Control.Tasks;
|
|
|
using GCHR.Model;
|
|
@@ -16,6 +19,8 @@ namespace GCHR
|
|
|
{
|
|
|
private TaskManager _aufgabenListe;
|
|
|
|
|
|
+ private List<string> _historie;
|
|
|
+
|
|
|
//private readonly List<Periode> _periodenListe = new List<Periode>();
|
|
|
|
|
|
private bool ImportdatenSichern
|
|
@@ -46,67 +51,44 @@ namespace GCHR
|
|
|
private void WindowLoaded(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
var config = Konfiguration.CreateInstance(Constants.ConfigDatei);
|
|
|
- Logger.Info(DateTime.Now + " GCHR gestartet.");
|
|
|
-
|
|
|
- /*
|
|
|
- var von = new Periode((DateTime.Today.Year - 1).ToString(CultureInfo.InvariantCulture) + "01");
|
|
|
- var bis =
|
|
|
- new Periode(DateTime.Today.Year +
|
|
|
- DateTime.Today.Month.ToString(CultureInfo.InvariantCulture).PadLeft(2, '0'));
|
|
|
-
|
|
|
- while (!von.ToString().Equals(bis.ToString()))
|
|
|
- {
|
|
|
- _periodenListe.Add(von);
|
|
|
- von = von.Nachfolger;
|
|
|
- }
|
|
|
- */
|
|
|
-
|
|
|
-
|
|
|
+ Historie();
|
|
|
AktuellenMonatEinstellen();
|
|
|
Kopfzeile.Content = config.Haendler + " - " + config.HaendlernummerBmCode + " - " + config.Mandantenname;
|
|
|
-
|
|
|
- /*
|
|
|
- LvPerioden.ItemsSource = _periodenListe;
|
|
|
- LvPerioden.SelectedIndex = _periodenListe.Count - 1;
|
|
|
- LvPerioden.ScrollIntoView(_periodenListe[_periodenListe.Count - 1]);
|
|
|
- LvPerioden.Focus();
|
|
|
- */
|
|
|
}
|
|
|
|
|
|
private void AktuellenMonatEinstellen()
|
|
|
{
|
|
|
Jahrbox.Items.Clear();
|
|
|
- for (var i = 2010; i <= DateTime.Today.Year; i++)
|
|
|
+ for (var i = 2012; i <= DateTime.Today.Year; i++)
|
|
|
{
|
|
|
Jahrbox.Items.Add(i);
|
|
|
}
|
|
|
|
|
|
- var aktPeriode = aktuellenMonatBestimmen();
|
|
|
+ var aktPeriode = AktuellenMonatBestimmen();
|
|
|
|
|
|
Monatsbox.SelectedIndex = Int32.Parse(aktPeriode.Monat) - 1;
|
|
|
Jahrbox.SelectedValue = Int32.Parse(aktPeriode.Jahr);
|
|
|
}
|
|
|
|
|
|
- private Periode aktuellenMonatBestimmen()
|
|
|
+ private void Historie()
|
|
|
{
|
|
|
- var neuerMonat =
|
|
|
- new Periode(DateTime.Today.Year +
|
|
|
- DateTime.Today.Month.ToString(CultureInfo.InvariantCulture).PadLeft(2, '0'));
|
|
|
- var monateZurueck = DateTime.Today.Month;
|
|
|
- if (monateZurueck <= 2)
|
|
|
- {
|
|
|
- monateZurueck += 12;
|
|
|
- }
|
|
|
+ _historie = Logger.Historie();
|
|
|
+ _historie.Reverse();
|
|
|
+ LvPerioden.ItemsSource = _historie;
|
|
|
+ }
|
|
|
|
|
|
- for (var i = 0; i < monateZurueck; i++)
|
|
|
- {
|
|
|
- neuerMonat = neuerMonat.Vorgaenger;
|
|
|
- if (!File.Exists(neuerMonat.Vorgaenger.BalanceDatei)) continue;
|
|
|
- var aelterAlsFuenfTage =
|
|
|
- File.GetLastWriteTime(neuerMonat.Vorgaenger.BalanceDatei).AddDays(5).CompareTo(DateTime.Now) <= 0;
|
|
|
- return (aelterAlsFuenfTage) ? neuerMonat : neuerMonat.Vorgaenger;
|
|
|
- }
|
|
|
- return neuerMonat.Nachfolger;
|
|
|
+ private Periode AktuellenMonatBestimmen()
|
|
|
+ {
|
|
|
+ var vormonat = new Periode(DateTime.Today.Year, DateTime.Today.Month).Vorgaenger;
|
|
|
+ if (_historie.Count == 0) return vormonat;
|
|
|
+
|
|
|
+ var match = Regex.Match(_historie[0], @"(\d{2})/(\d{4})$");
|
|
|
+ if (!match.Success) return vormonat;
|
|
|
+
|
|
|
+ var aktMonat = new Periode(match.Groups[2].Value + match.Groups[1].Value);
|
|
|
+ var letzteFuenfTage = File.GetLastWriteTime(aktMonat.BalanceDatei).AddDays(5).CompareTo(DateTime.Now) >= 0;
|
|
|
+ if (!File.Exists(aktMonat.BalanceDatei) || letzteFuenfTage) return aktMonat;
|
|
|
+ return aktMonat.Nachfolger;
|
|
|
}
|
|
|
|
|
|
private void BtnStartenClick(object sender, RoutedEventArgs e)
|
|
@@ -175,6 +157,10 @@ namespace GCHR
|
|
|
{
|
|
|
BtnStarten.IsEnabled = true;
|
|
|
BtnProtokoll.Visibility = Visibility.Visible;
|
|
|
+ Historie();
|
|
|
+ Logger.Progress(DateTime.Now + " Prozess beendet.");
|
|
|
+ Logger.Progress("------------------------------------");
|
|
|
+ Logger.Progress("");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -213,7 +199,19 @@ namespace GCHR
|
|
|
{
|
|
|
var dateiInfo = new FileInfo(Logger.ExportLog);
|
|
|
if (dateiInfo.Directory == null) return;
|
|
|
- var psi = new ProcessStartInfo("explorer.exe", dateiInfo.Directory.ToString())
|
|
|
+ ProzessStarten("explorer.exe", dateiInfo.Directory.ToString());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void LvPeriodenDoubleClick(object sender, MouseButtonEventArgs e)
|
|
|
+ {
|
|
|
+ var match = Regex.Match(_historie[LvPerioden.SelectedIndex], @"(\d{2})/(\d{4})$");
|
|
|
+ var log = new Periode(match.Groups[2].Value + match.Groups[1].Value).LogDatei;
|
|
|
+ ProzessStarten("notepad.exe", log);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void ProzessStarten(string programm, string parameter)
|
|
|
+ {
|
|
|
+ var psi = new ProcessStartInfo(programm, parameter)
|
|
|
{
|
|
|
RedirectStandardOutput = true,
|
|
|
WindowStyle = ProcessWindowStyle.Normal,
|