Ejemplo n.º 1
0
 public MainWindow(
     Func <string, Task <Timetable> > loadTimetableFunc,
     Func <TrainNumber> windowFactory,
     EntriesCollection entries,
     IApplicationStateService appStateService)
 {
     Entries = entries;
     InitializeComponent();
     _loadTimetable   = loadTimetableFunc;
     _windowFactory   = windowFactory;
     _appStateService = appStateService;
 }
Ejemplo n.º 2
0
        private void InsertEntry(LogEntry entry)
        {
            try
            {
                EntriesCollection.Insert(0, entry);

                var count = EntriesCollection.Count;
                if (count > BufferSize)
                {
                    EntriesCollection.RemoveAt(count - 1);
                }
            }
            catch { }
        }
Ejemplo n.º 3
0
        static BenchmarkService()
        {
            var entries = Enumerable.Range(1, 8).Select(i => new Entry
            {
                Attributes = new Attributes
                {
                    Created       = BaseDateTime.AddDays(i).ToTimestamp(),
                    Enabled       = true,
                    Expires       = BaseDateTime.AddDays(i).AddYears(1).ToTimestamp(),
                    NotBefore     = BaseDateTime.ToTimestamp(),
                    RecoveryLevel = "Purgeable",
                    Updated       = BaseDateTime.AddSeconds(i).ToTimestamp(),
                },
                ContentType = "application/xml",
                Id          = "https://benchmarktest.id/item/value" + i,
                Tags        = { "test", "perf", "json" },
            }).ToList();

            _entries = new EntriesCollection();
            _entries.Entries.AddRange(entries);
        }
Ejemplo n.º 4
0
        public void BtnDeleteSelectedEntry()
        {
            //Check if found
            if (EntriesCollection.Where(x => x.ID == SelectedEntry.ID).Count() == 0)
            {
                return;
            }

            //Find the entryrow
            EntryRow entryRow = EntriesCollection.FirstOrDefault(x => x.ID == SelectedEntry.ID);

            //Delete from datagrid
            EntriesCollection.Remove(entryRow);
            NotifyOfPropertyChange(() => EntriesCollection);

            VismaEntry vismaEntry;

            //Delete vismaentry from database and its timesheetentry if it was the last vismaentry.
            using (var ctx = new DatabaseDir.Database())
            {
                //Find the object in th database and delete
                vismaEntry = ctx.VismaEntries.Where(v => v.Id == SelectedEntry.ID).First();
                ctx.VismaEntries.Remove(vismaEntry);
                ctx.SaveChanges();
            }

            //Check and delete timesheetEntry if it no longer contains any vismaEntries
            using (var ctx = new DatabaseDir.Database())
            {
                //Search for other vismaentries with the same timesheet id
                List <VismaEntry> list = new List <VismaEntry>(ctx.VismaEntries.Where(x => x.TimesheetEntryID == vismaEntry.TimesheetEntryID));
                if (list.Count() == 0)
                {
                    TimesheetEntry timesheetEntry = ctx.TimesheetEntries.FirstOrDefault(x => x.Id == vismaEntry.TimesheetEntryID);
                    //If none, then delete
                    ctx.TimesheetEntries.Remove(timesheetEntry);
                    ctx.SaveChanges();
                }
            }
        }
Ejemplo n.º 5
0
 public override Task <Empty> JsonInput(EntriesCollection request, ServerCallContext context)
 {
     return(Task.FromResult(new Empty()));
 }