Ejemplo n.º 1
0
        void RefreshContent()
        {
            llSyncItems.RemoveAllViews();
            queue = (List <SyncQueue>)SyncQueueManager.GetSyncQueue(selectedDate);
            foreach (var q in queue)
            {
                View view = LayoutInflater.Inflate(Resource.Layout.SyncFragmentItem, null);

                RelativeLayout rl = view.FindViewById <RelativeLayout> (Resource.Id.sfiRelativeLayout);
                ImageView      iv = view.FindViewById <ImageView> (Resource.Id.sfiStatusImage);

                TextView type = view.FindViewById <TextView> (Resource.Id.sfiTypeInfoText);
                TextView loc  = view.FindViewById <TextView> (Resource.Id.sfiLocationText);

                try {
                    if (q.isSync)
                    {
                        rl.SetBackgroundColor(Android.Graphics.Color.LightGreen);
                        iv.SetImageResource(Resource.Drawable.ic_check_circle_white_36dp);
                        type.SetTextAppearance(this, Resource.Style.text_success);
                        loc.SetTextAppearance(this, Resource.Style.text_success_small);
                    }
                    else
                    {
                        rl.SetBackgroundColor(Android.Graphics.Color.LightPink);
                        iv.SetImageResource(Resource.Drawable.ic_highlight_off_white_36dp);
                        type.SetTextAppearance(this, Resource.Style.text_danger);
                        loc.SetTextAppearance(this, Resource.Style.text_danger_small);
                    }

                    Attendance att   = null;
                    Pharmacy   pharm = null;
                    switch (q.type)
                    {
                    case SyncQueueType.sqtAttendance:
                        att       = AttendanceManager.GetAttendance(q.itemID);
                        pharm     = PharmacyManager.GetPharmacy(att.pharmacy);
                        type.Text = string.Format(@"Тип: Посещение аптеки {0} за дату {1}", pharm.fullName, att.date.ToString(@"d"));
                        loc.Text  = string.Format(@"Размещение: {0}", q.fileLocation);
                        break;

                    case SyncQueueType.sqtAttendanceResult:
                        AttendanceResult attRes = AttendanceResultManager.GetAttendanceResult(q.itemID);
                        att       = AttendanceManager.GetAttendance(attRes.attendance);
                        pharm     = PharmacyManager.GetPharmacy(att.pharmacy);
                        type.Text = string.Format(@"Тип: Значение по препарату в посещение аптеки {0} за дату {1}", pharm.fullName, att.date.ToString(@"d"));
                        loc.Text  = string.Format(@"Размещение: {0}", q.fileLocation);
                        break;

                    case SyncQueueType.sqtAttendanceGPSPoint:
                        AttendanceGPSPoint attGPS = AttendanceGPSPointManager.GetAttendanceGPSPoint(q.itemID);
                        att       = AttendanceManager.GetAttendance(attGPS.attendance);
                        pharm     = PharmacyManager.GetPharmacy(att.pharmacy);
                        type.Text = string.Format(@"Тип: GPS значение в посещение аптеки {0} за дату {1} - lat:{2}, lon:{3}", pharm.fullName, att.date.ToString(@"d"), attGPS.latitude, attGPS.longitude);
                        loc.Text  = string.Format(@"Размещение: {0}", q.fileLocation);
                        break;

                    case SyncQueueType.sqtAttendancePhoto:
                        AttendancePhoto attPho = AttendancePhotoManager.GetAttendancePhoto(q.itemID);
                        type.Text = string.Format(@"Фото: {0}", attPho.photoPath);
                        loc.Text  = q.fileLocation;
                        break;

                    default:
                        type.Text = @"Неизвестный тип файла";
                        type.SetTextColor(Android.Graphics.Color.DarkRed);
                        break;
                    }
                } catch (Exception ex) {
                    type.Text = @"Error:";
                    loc.Text  = ex.Message;
                }

                llSyncItems.AddView(view);
            }
        }