Example #1
0
        private void GenerateLogSummaryForCurrentLogCommand_Execute(LogViewModel logToGenerate)
        {
            if (logToGenerate == null)
            return;

              this.MessengerInstance.Send<GenerateTimeSummaryMessage>(new GenerateTimeSummaryMessage(logToGenerate));
        }
 public GenerateTimeSummaryMessage(LogViewModel log)
 {
     this.Log = log;
 }
Example #3
0
 internal void GoToLogForToday()
 {
     this.CurrentLog = LogViewModel.LoadByDate(this.LastKnownDate, this.Settings);
 }
Example #4
0
 private void HandleLoadLogMessage(LoadLogMessage message)
 {
     this.CurrentLog = LogViewModel.LoadByFileName(message.LogToLoad.FileName, message.LogToLoad.Date, this.Settings);
     this.MessengerInstance.Send <GenerateTimeSummaryMessage>(new GenerateTimeSummaryMessage(this.CurrentLog));
 }
Example #5
0
        public static LogViewModel LoadByFileName(string filename, DateTime date, SettingsViewModel settings)
        {
            if (File.Exists(filename))
              {
            var log = new LogViewModel(date, settings);

            using (var reader = new StreamReader(filename))
            {
              string currentLine;
              while ((currentLine = reader.ReadLine()) != null)
              {
            Match m = Regex.Match(currentLine, @"^\[(.*) - (.*) : (.*)\]\w*(.*)");
            if (m.Success)
            {
              try
              {
                var startDate = DateTime.Parse(m.Groups[1].Value);
                var endDate = DateTime.Parse(m.Groups[2].Value);
                var type = (TimeEntryTypes)Enum.Parse(typeof(TimeEntryTypes), m.Groups[3].Value);
                var label = m.Groups[4].Value.Trim();

                log.TimeEntries.Add(new TimeEntryViewModel() { StartTime = startDate, EndTime = endDate, Label = label, Type = type });
              }
              catch
              {

              }
            }
              }

            }

            return log;
              }
              else
              {
            var log = new LogViewModel(date, settings);
            log.TimeEntries.Add(new TimeEntryViewModel() { Type = TimeEntryTypes.StartOfWorkday, StartTime = new DateTime(), EndTime = settings.WorkdayStart, Label = "Start the day" });

            return log;
              }
        }