public static List<LogEntry> ReadAll(SupportedPeriod period) { using (BadgeDataContext db = new BadgeDataContext(BadgeDataContext.ConnectionString)) { return (from entry in db.Entries where entry.Time.Date >= period.From.Date && entry.Time.Date <= period.To.Date orderby entry.Time select entry).ToList(); } }
public static void Log(LogEntry[] logEntry) { using (BadgeDataContext db = new BadgeDataContext(BadgeDataContext.ConnectionString)) { foreach (var entry in logEntry) { db.Entries.InsertOnSubmit(entry); } db.SubmitChanges(); } }
public static LogEntry Read(decimal id) { var item = default(LogEntry); using (BadgeDataContext db = new BadgeDataContext(BadgeDataContext.ConnectionString)) { item = db.Entries.FirstOrDefault(entry => entry.Id == id); } return item; }
public static EntryType GetLastType() { var last = default(LogEntry); using (BadgeDataContext db = new BadgeDataContext(BadgeDataContext.ConnectionString)) { last = (from entry in db.Entries orderby entry.Time descending select entry).FirstOrDefault(); } return last != null ? last.EntryTypeEnum : EntryType.Out; }
private void LogEntryButton_Tap(object sender, GestureEventArgs e) { using (BadgeDataContext db = new BadgeDataContext(BadgeDataContext.ConnectionString)) { LogEntry entries = new LogEntry { Id = db.Entries.Count() + 1, EntryTypeEnum = LogEntry.GetLastType() == EntryType.In ? EntryType.Out : EntryType.In, Time = DateTime.Now, }; db.Entries.InsertOnSubmit(entries); db.SubmitChanges(); MessageBox.Show(string.Format("Azione {0} alle {1}", entries.EntryTypeEnum, entries.Time.ToString()), "Info", MessageBoxButton.OK); } }
public static EntryType GetLastType() { var last = default(LogEntry); using (BadgeDataContext db = new BadgeDataContext(BadgeDataContext.ConnectionString)) { // last = db.Entries.Last(); foreach (var entry in db.Entries) { last = entry; } } if (last == null) return EntryType.Out; return last.EntryTypeEnum; }
public static List<ReportLog> ReadAll(SupportedPeriod period) { var list = new List<ReportLog>(); using (BadgeDataContext db = new BadgeDataContext(BadgeDataContext.ConnectionString)) { var entrylistIn = (from entry in db.Entries where entry.EntryTypeEnum == Model.EntryType.In && entry.Time >= period.From && entry.Time <= period.To orderby entry.Time select entry); var entrylistOut = (from entry in db.Entries where entry.EntryTypeEnum == Model.EntryType.Out && entry.Time >= period.From && entry.Time <= period.To orderby entry.Time select entry); foreach (var item in entrylistIn) { list.Add(new ReportLog(item, entrylistOut.FirstOrDefault(log => log.Time > item.Time))); } } return list; }
public static List<LogEntry> ReadAll() { var list = default(List<LogEntry>); using (BadgeDataContext db = new BadgeDataContext(BadgeDataContext.ConnectionString)) { list = db.Entries.ToList(); } return list; }
private static int CountEntries() { using (BadgeDataContext db = new BadgeDataContext(BadgeDataContext.ConnectionString)) { return db.Entries.Count(); } }
public static List<LogEntry> ReadAll() { using (BadgeDataContext db = new BadgeDataContext(BadgeDataContext.ConnectionString)) { return db.Entries.ToList(); } }
public static LogEntry Read(decimal id) { using (BadgeDataContext db = new BadgeDataContext(BadgeDataContext.ConnectionString)) { return db.Entries.FirstOrDefault(entry => entry.Id == id); } }
// Code to execute when the application is launching (eg, from Start) // This code will not execute when the application is reactivated private void Application_Launching(object sender, LaunchingEventArgs e) { using (BadgeDataContext db = new BadgeDataContext(BadgeDataContext.ConnectionString)) { if (!db.DatabaseExists()) { db.CreateDatabase(); db.SubmitChanges(); } } }
public static List<ReportLog> ReadAll() { var list = default(List<ReportLog>); using (BadgeDataContext db = new BadgeDataContext(BadgeDataContext.ConnectionString)) { var entrylist = db.Entries.ToList(); if (entrylist.Count == 2) { list.Add(new ReportLog(entrylist[0], entrylist[1])); } } return list; }