public List <TimeSpent> GetByTaskId(int id) { List <TimeSpent> result = new List <TimeSpent>(); FileStream fs = new FileStream(this.filepath, FileMode.OpenOrCreate); StreamReader sr = new StreamReader(fs); try { while (!sr.EndOfStream) { TimeSpent time = new TimeSpent(); time.TSId = Convert.ToInt32(sr.ReadLine()); time.TheAssi = Convert.ToInt32(sr.ReadLine()); time.TheTask = Convert.ToInt32(sr.ReadLine()); time.FinTime = Convert.ToDateTime(sr.ReadLine()); time.Hours = Convert.ToInt32(sr.ReadLine()); if (time.TheTask == id) { result.Add(time); //return time; } } } finally { sr.Close(); fs.Close(); } return(result); }
private int GetNextTSId() { int id = 1; FileStream fs = new FileStream(this.filepath, FileMode.OpenOrCreate); StreamReader sr = new StreamReader(fs); try { while (!sr.EndOfStream) { TimeSpent time = new TimeSpent(); time.TSId = Convert.ToInt32(sr.ReadLine()); time.TheAssi = Convert.ToInt32(sr.ReadLine()); time.TheTask = Convert.ToInt32(sr.ReadLine()); time.FinTime = Convert.ToDateTime(sr.ReadLine()); time.Hours = Convert.ToInt32(sr.ReadLine()); if (id <= time.TSId) { id = time.TSId + 1; } } return(id); } finally { sr.Close(); fs.Close(); } }
public List <TimeSpent> GetAll() { List <TimeSpent> result = new List <TimeSpent>(); FileStream fs = new FileStream(this.filepath, FileMode.OpenOrCreate); StreamReader sr = new StreamReader(fs); try { while (!sr.EndOfStream) { TimeSpent user = new TimeSpent(); user.TSId = Convert.ToInt32(sr.ReadLine()); user.TheAssi = Convert.ToInt32(sr.ReadLine()); user.TheTask = Convert.ToInt32(sr.ReadLine()); user.FinTime = Convert.ToDateTime(sr.ReadLine()); user.Hours = Convert.ToInt32(sr.ReadLine()); result.Add(user); } } finally { sr.Close(); fs.Close(); } return(result); }
public void SaveState() { using (FileStream fstream = File.Open(ScorePath, FileMode.Append)) { var Buff = new UnicodeEncoding().GetBytes($"Tiempo: {TimeSpent.ToString()} - Intentos {Attemps}\n"); fstream.Write(Buff, 0, Buff.Length); } }
public void Duration_should_return_0_if_start_or_end_is_null() { var subject = new TimeSpent(_clock.Object) { IsActive = false }; Assert.AreEqual(0, subject.Duration); }
public void ActiveDuration_should_be_0_if_start_is_null() { var subject = new TimeSpent(_clock.Object) { StartTime = null }; Assert.AreEqual(0, subject.ActiveDuration); }
public void ActiveDuration_should_return_seconds_when_start_and_end_dates_are_not_null() { var subject = new TimeSpent(_clock.Object) { StartTime = new DateTime(2017, 01, 01, 10, 00, 00), EndTime = new DateTime(2017, 01, 01, 10, 01, 00) }; Assert.AreEqual(60, subject.ActiveDuration); }
public void ActiveDuration_should_return_seconds_uses_current_time_when_enddate_is_null() { _clock.Setup(x => x.Now()).Returns(new DateTime(2017, 1, 1, 10, 00, 35)); var subject = new TimeSpent(_clock.Object) { StartTime = new DateTime(2017, 01, 01, 10, 00, 00), EndTime = null }; Assert.AreEqual(35, subject.ActiveDuration); }
private void tsMainNew_Click(object sender, EventArgs e) { TimeSpent item = new TimeSpent(); NewTime newTime = new NewTime(item); if (newTime.ShowDialog() == DialogResult.OK) { this.NewTime(item); SetDataSources(); } }
public void ActiveDurationInMinutes_should_return_minutes() { var subject = new TimeSpent(_clock.Object) { IsActive = false, StartTime = new DateTime(2017, 01, 01, 10, 00, 00), EndTime = new DateTime(2017, 01, 01, 10, 01, 00) }; Assert.AreEqual(1, subject.ActiveDurationInMinutes); }
public override string ToString() { return(Util.f("ec:{0} sc:{1} ssc:{2} sl:{3:.0} ts:{4:.0} la:{5:.0}", EventCount, SessionCount, SubSessionCount, SessionLenght.SecondsFormat(), TimeSpent.SecondsFormat(), LastActivity.SecondsFormat() )); }
public void DurationInMinutes_should_return_minutes_rounded_up_to_next_minute() { var subject = new TimeSpent(_clock.Object) { IsActive = false, StartTime = new DateTime(2017, 01, 01, 10, 00, 00), EndTime = new DateTime(2017, 01, 01, 10, 01, 01) }; Assert.AreEqual(2, subject.DurationInMinutes); }
public void Save(TimeSpent time) { if (time.TSId > 0) { // Edit(time); } else { Add(time); } }
public void Duration_should_return_seconds_for_inactive_TimeSpent() { var subject = new TimeSpent(_clock.Object) { IsActive = false, StartTime = new DateTime(2017, 01, 01, 10, 00, 00), EndTime = new DateTime(2017, 01, 01, 10, 01, 00) }; Assert.AreEqual(60, subject.Duration); }
public void DeleteTime(TimeSpent time) { using (var db = new Index.BloggingContext()) { var item = (from t in db.TimeSpent where t.TSId == time.TSId select t).First(); db.TimeSpent.Remove(item); db.SaveChanges(); } }
public void Delete(TimeSpent item) { using (var db = new BloggingContext()) { var time = (from t in db.TimeSpent where t.TSId == item.TSId select t).First(); db.TimeSpent.Remove(time); db.SaveChanges(); } }
public void New(TimeSpent item) { using (var db = new BloggingContext()) { var now = DateTime.Now; var time = new TimeSpent { TheAssi = item.TheAssi, TheTask = item.TheTask, FinTime = now, Hours = item.Hours }; db.TimeSpent.Add(time); db.SaveChanges(); } }
private void toolStripButton1_Click(object sender, EventArgs e) { TimeSpent item = new TimeSpent(); NewTime newTime = new NewTime(item); if (newTime.ShowDialog() == DialogResult.OK) { ListTimes create = new ListTimes(); create.NewTime(item); SetTimeSources(); } }
public void NewTime(TimeSpent time) { using (var db = new Index.BloggingContext()) { var now = DateTime.Now; var item = new TimeSpent { TheAssi = time.TheAssi, TheTask = time.TheTask, FinTime = now, Hours = time.Hours }; db.TimeSpent.Add(item); db.SaveChanges(); } }
public override string ToString() { return(Util.F("ec:{0} sc:{1} ssc:{2} sl:{3:.0} ts:{4:.0} la:{5:.0} adid:{6} isGdprForgotten:{7}", EventCount, SessionCount, SubSessionCount, SessionLength.SecondsFormat(), TimeSpent.SecondsFormat(), LastActivity.SecondsFormat(), Adid, IsGdprForgotten )); }
private void tsMainDelete_Click(object sender, EventArgs e) { Int32 selectedRowCount = dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected); if (selectedRowCount > 0) { DialogResult result = MessageBox.Show("Are you sure you want to delete this item", "Delete item", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { TimeSpent time = (TimeSpent)timeBindingSource.Current; this.DeleteTime(time); SetDataSources(); } } }
public override int GetHashCode() { var hashCode = -1245731201; hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(To); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(From); hashCode = hashCode * -1521134295 + StartTime.GetHashCode(); hashCode = hashCode * -1521134295 + EndTime.GetHashCode(); hashCode = hashCode * -1521134295 + TimeSpent.GetHashCode(); hashCode = hashCode * -1521134295 + Calories.GetHashCode(); hashCode = hashCode * -1521134295 + Cost.GetHashCode(); return(hashCode); }
public string[] ToStringArray(int digits) { return(new[] { AssemblyName, MethodName, AvgTime.ToString($"F{digits}", CultureInfo.InvariantCulture) /*.Replace(".", ",")*/, //slk . ; in csv , ! TicksNum.ToString(), MinTime.ToString($"F{digits}", CultureInfo.InvariantCulture) /*.Replace(".", ",")*/, //slk . ; in csv , ! MaxTime.ToString($"F{digits}", CultureInfo.InvariantCulture) /*.Replace(".", ",")*/, //slk . ; in csv , ! TimeSpent.ToString(), AvgKB.ToString(), AllocKB.ToString(), PatchOwners }); }
public void Delete(TimeSpent item) { string tempFilePath = "temp." + filepath; FileStream ifs = new FileStream(filepath, FileMode.OpenOrCreate); StreamReader sr = new StreamReader(ifs); FileStream ofs = new FileStream(tempFilePath, FileMode.OpenOrCreate); StreamWriter sw = new StreamWriter(ofs); try { while (!sr.EndOfStream) { TimeSpent time = new TimeSpent(); time.TSId = Convert.ToInt32(sr.ReadLine()); time.TheAssi = Convert.ToInt32(sr.ReadLine()); time.TheTask = Convert.ToInt32(sr.ReadLine()); time.FinTime = Convert.ToDateTime(sr.ReadLine()); time.Hours = Convert.ToInt32(sr.ReadLine()); if (time.TSId != item.TSId) { sw.WriteLine(time.TSId); sw.WriteLine(time.TheAssi); sw.WriteLine(time.TheTask); sw.WriteLine(time.FinTime); sw.WriteLine(time.Hours); } } } finally { sw.Close(); ofs.Close(); sr.Close(); ifs.Close(); } File.Delete(filepath); File.Move(tempFilePath, filepath); }
private void Add(TimeSpent item) { item.TSId = GetNextTSId(); FileStream fs = new FileStream(filepath, FileMode.Append); StreamWriter sw = new StreamWriter(fs); try { sw.WriteLine(item.TSId); sw.WriteLine(item.TheAssi); sw.WriteLine(item.TheTask); sw.WriteLine(item.FinTime); sw.WriteLine(item.Hours); } finally { sw.Close(); fs.Close(); } }
public static void UpdateHoursSpent(ModelsContext context, Score score) { var dbRecord = context.TimeSpents.FirstOrDefault(x => x.UserId == score.User.Id); if (dbRecord == null) { TimeSpent timeSpent = new TimeSpent { User = score.User, HoursSpent = score.Competition.Hours }; context.TimeSpents.Add(timeSpent); } else { dbRecord.HoursSpent += score.Competition.Hours; context.TimeSpents.Update(dbRecord); } context.SaveChanges(); }
public void DrawToForm(Form f) { var label = new Label(); var textBox = new TextBox(); var checkBox = new CheckBox(); label.Text = Description.ToString(); textBox.Text = TimeSpent.ToString(); label.Left = StartX; label.Top = StartY; StartX += 100;// Move position to right textBox.Left = StartX; textBox.Top = StartY; StartX += 150;// Move position to right checkBox.Left = StartX; checkBox.Top = StartY; StartX = 10; // Reset to start StartY += 50; // Move position to down f.Controls.Add(label); f.Controls.Add(textBox); f.Controls.Add(checkBox); }
public override int GetHashCode() { unchecked { int result = (comments != null ? comments.GetHashCode() : 0); result = (result * 397) ^ (versions != null ? versions.GetHashCode() : 0); result = (result * 397) ^ (fixVersions != null ? fixVersions.GetHashCode() : 0); result = (result * 397) ^ (SubtaskKeys.GetHashCode()); result = (result * 397) ^ (IssueLinks.GetHashCode()); result = (result * 397) ^ (components != null ? components.GetHashCode() : 0); result = (result * 397) ^ (attachments != null ? attachments.GetHashCode() : 0); result = (result * 397) ^ (Server != null ? Server.GUID.GetHashCode() : 0); result = (result * 397) ^ (IssueType != null ? IssueType.GetHashCode() : 0); result = (result * 397) ^ IssueTypeId; result = (result * 397) ^ (IssueTypeIconUrl != null ? IssueTypeIconUrl.GetHashCode() : 0); result = (result * 397) ^ (Description != null ? Description.GetHashCode() : 0); result = (result * 397) ^ Id; result = (result * 397) ^ (Key != null ? Key.GetHashCode() : 0); result = (result * 397) ^ (Summary != null ? Summary.GetHashCode() : 0); result = (result * 397) ^ (Status != null ? Status.GetHashCode() : 0); result = (result * 397) ^ (StatusIconUrl != null ? StatusIconUrl.GetHashCode() : 0); result = (result * 397) ^ (Priority != null ? Priority.GetHashCode() : 0); result = (result * 397) ^ (Resolution != null ? Resolution.GetHashCode() : 0); result = (result * 397) ^ (Reporter != null ? Reporter.GetHashCode() : 0); result = (result * 397) ^ (Assignee != null ? Assignee.GetHashCode() : 0); result = (result * 397) ^ CreationDate.GetHashCode(); result = (result * 397) ^ UpdateDate.GetHashCode(); result = (result * 397) ^ (ProjectKey != null ? ProjectKey.GetHashCode() : 0); result = (result * 397) ^ (Environment != null ? Environment.GetHashCode() : 0); result = (result * 397) ^ (OriginalEstimate != null ? OriginalEstimate.GetHashCode() : 0); result = (result * 397) ^ (RemainingEstimate != null ? RemainingEstimate.GetHashCode() : 0); result = (result * 397) ^ (TimeSpent != null ? TimeSpent.GetHashCode() : 0); result = (result * 397) ^ (ParentKey != null ? ParentKey.GetHashCode() : 0); result = (result * 397) ^ (PriorityIconUrl != null ? PriorityIconUrl.GetHashCode() : 0); result = (result * 397) ^ StatusId; result = (result * 397) ^ PriorityId; return(result); } }
public void Duration_should_be_0_for_active_TimeSpent() { var subject = new TimeSpent(_clock.Object); Assert.AreEqual(0, subject.Duration); }
public NewTime(TimeSpent time) { InitializeComponent(); this.item = time; SetDataSources(); }