private void ResumeAction() { GotoState(InitState.NotRunningLogged); // Save state to database var entities = new DialogTimeEntities(); using (entities) { var q = from x in entities.StartStops where x.TimeIntervall.EndsWith("p") && x.PersId == _user.PersId select x; if (q.Any()) { if (q.Count() > 1) { // TODO: Szenario behandeln // I'm resuming, but there are many pending activities return; } var first = q.First(); first.TimeIntervall = first.TimeIntervall.Substring(0, first.TimeIntervall.Length - 1) + string.Format(",{0:00}:{1:00}-", DateTime.Now.Hour, DateTime.Now.Minute); entities.SaveChanges(); _intervalls = new Helpers.Intervalls(first.TimeIntervall); GotoState(InitState.Running); } } }
private void PauseAction() { GotoState(InitState.Paused); var entities = new DialogTimeEntities(); using (entities) { var q = from x in entities.StartStops where x.TimeIntervall.EndsWith("-") && x.PersId == _user.PersId select x; if (q.Any()) { if (q.Count() > 1) { // TODO: Szenario behandeln // I'm pausing, but there are many pending activities return; } var first = q.First(); first.TimeIntervall += string.Format("{0:00}:{1:00}p", DateTime.Now.Hour, DateTime.Now.Minute); entities.SaveChanges(); _intervalls = new Helpers.Intervalls(first.TimeIntervall); _timer_Elapsed(this, null); GotoState(InitState.Paused); } } }
private void BaseStartAction(DateTime time) { if (!PassValidation()) { FeedbackText = "Bitte, alle nötige Daten eingeben"; return; } var entities = new DialogTimeEntities(); using (entities) { var entry = new StartStop(); entry.PersId = _username; entry.ProjektId = _selectedProjekt.Value; entry.TimeIntervall = string.Format("{0:00}:{1:00}-", time.Hour, time.Minute); entry.LohnkategorieKuerzel = _selectedLohnkategorie; entry.TarifkategorieId = _selectedTarifkategorie; entry.Text = Text; entry.Datum = time; entities.StartStops.Add(entry); entities.SaveChanges(); _intervalls = new Helpers.Intervalls(entry.TimeIntervall); GotoState(InitState.Running); } }
private void BaseStopAction(DateTime time) { GotoState(InitState.NotRunningLogged); var entities = new DialogTimeEntities(); using (entities) { var q = from x in entities.StartStops where (x.TimeIntervall.EndsWith("-") || x.TimeIntervall.EndsWith("p")) && x.PersId == _user.PersId select x; if (q.Any()) { if (q.Count() > 1) { // TODO: Szenario behandeln // I'm stopping, but there are many pending activities return; } var first = q.First(); if (first.TimeIntervall.EndsWith("p")) { first.TimeIntervall = first.TimeIntervall.Substring(0, first.TimeIntervall.Length - 1); } else { first.TimeIntervall += string.Format("{0:00}:{1:00}", time.Hour, time.Minute); } var ii = new Intervalls(first.TimeIntervall); var jj = new Intervalls(); var q2 = from x in entities.RapportEintraeges where x.PersId == _user.PersId && x.Datum == time select x; foreach (var e in q2) { jj.AddRange(new Intervalls(e.TimeIntervall)); } ii.CutWith(jj); RapportEintraege eintrag = new RapportEintraege() { Id = Guid.NewGuid(), AnsatzExtern = 0, AnsatzIntern = 0, ArbeitsRapportNr = 0, Aufwand = Math.Round(ii.EllapsedAsDouble, 1), Datum = time, ErfDatum = DateTime.Now, ErfName = _user.PersId, LohnkategorieKuerzel = first.LohnkategorieKuerzel, LohnKatKontierung = "", MandantId = Guid.Parse("331A58AF-C3F6-42BE-BF55-0AE0C5F26C87"), MutDatum = DateTime.Now, MutName = _user.PersId, PersId = _user.PersId, ProjektId = first.ProjektId, TarifkategorieId = first.TarifkategorieId, Text = first.Text, TimeIntervall = ii.ToString(), Verrechnet = 0, Zuschlag = 0 }; entities.RapportEintraeges.Add(eintrag); entities.SaveChanges(); _intervalls = new Helpers.Intervalls(first.TimeIntervall); _timer_Elapsed(this, null); GotoState(InitState.NotRunningLogged); } } }