public void Reload()
        {
            var progress = new ProgressDialog(Activity);

            progress.SetTitle(Resource.String.please_wait);
            progress.SetMessage(GetString(Resource.String.loading));
            progress.Indeterminate = true;
            progress.Show();

            Task.Factory.StartNew(async() => {
                var db   = ion.database;
                var jobs = new Dictionary <JobRow, List <SessionRow> >();

                // Add the "Default" job that sessions are assigned to
                jobs.Add(new JobRow()
                {
                    _id     = 0,
                    jobName = GetString(Resource.String.report_session_unassigned),
                }, new List <SessionRow>());

                foreach (var job in await db.QueryForAllAsync <JobRow>())
                {
                    jobs[job] = new List <SessionRow>();
                }

                foreach (var job in jobs.Keys)
                {
                    var sessions = jobs[job];
                    sessions.AddRange(db.Table <SessionRow>().Where(x => x.frn_JID == job._id).AsEnumerable());
                }

                var records = new List <RecordAdapter.IRecord>();

                foreach (var job in jobs.Keys)
                {
                    records.Add(new ReportJobHeaderRecord(job, jobs[job]));
                    foreach (var session in jobs[job])
                    {
                        records.Add(await ReportSessionRecord.NewAsync(ion, session));
                    }
                }

                return(records);
            }).ContinueWith((arg) => {
                progress.Dismiss();

                if (arg.Result.IsFaulted)
                {
                    Error(GetString(Resource.String.report_error_unknown), arg.Exception);
                }
                else
                {
                    adapter.Set(arg.Result.Result);
                }
                InvalidateDelete();
                SyncCheckedSessions();
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Beispiel #2
0
 public void OnCheckChanged(ReportSessionRecord record)
 {
     if (record.isChecked)
     {
         activity.checkedSessions.Add(record.data._id);
     }
     else
     {
         activity.checkedSessions.Remove(record.data._id);
     }
     InvalidateDelete();
 }
Beispiel #3
0
        private async Task <List <ReportSessionRecord> > LoadAllSessionsAsync()
        {
            var ret = new List <ReportSessionRecord>();

            var rows = ion.database.Table <SessionRow>().AsEnumerable();

            foreach (var row in rows)
            {
                try {
                    var record = await ReportSessionRecord.NewAsync(ion, row);

                    ret.Add(record);
                } catch (Exception e) {
                    Log.E(this, "Failed to load row: " + row, e);
                }
            }

            return(ret);
        }
Beispiel #4
0
 public void OnDeleteClicked(ReportSessionRecord record)
 {
     RequestDeleteSessions(new SessionRow[] { record.data });
 }