コード例 #1
0
 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();
     }
 }
コード例 #2
0
        public static void Log(LogEntry[] logEntry)
        {
            using (BadgeDataContext db = new BadgeDataContext(BadgeDataContext.ConnectionString)) {
                foreach (var entry in logEntry) {
                    db.Entries.InsertOnSubmit(entry);
                }
                db.SubmitChanges();

            }
        }
コード例 #3
0
ファイル: LogEntry.cs プロジェクト: dineshkummarc/Badge
        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;
        }
コード例 #4
0
        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;
        }
コード例 #5
0
ファイル: Badge.xaml.cs プロジェクト: dineshkummarc/Badge
        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);
            }
        }
コード例 #6
0
ファイル: LogEntry.cs プロジェクト: dineshkummarc/Badge
        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;
        }
コード例 #7
0
        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;
        }
コード例 #8
0
ファイル: LogEntry.cs プロジェクト: dineshkummarc/Badge
        public static List<LogEntry> ReadAll()
        {
            var list = default(List<LogEntry>);

            using (BadgeDataContext db = new BadgeDataContext(BadgeDataContext.ConnectionString))
            {
                list = db.Entries.ToList();

            }

            return list;
        }
コード例 #9
0
 private static int CountEntries()
 {
     using (BadgeDataContext db = new BadgeDataContext(BadgeDataContext.ConnectionString)) {
         return db.Entries.Count();
     }
 }
コード例 #10
0
 public static List<LogEntry> ReadAll()
 {
     using (BadgeDataContext db = new BadgeDataContext(BadgeDataContext.ConnectionString)) {
         return db.Entries.ToList();
     }
 }
コード例 #11
0
 public static LogEntry Read(decimal id)
 {
     using (BadgeDataContext db = new BadgeDataContext(BadgeDataContext.ConnectionString)) {
         return db.Entries.FirstOrDefault(entry => entry.Id == id);
     }
 }
コード例 #12
0
ファイル: App.xaml.cs プロジェクト: johnatandante/Badge
        // 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();
                }

            }
        }
コード例 #13
0
ファイル: ReportLog.cs プロジェクト: dineshkummarc/Badge
        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;
        }