void RefreshView() { Count = 0; Count += MainDatabase.CountItemsToSync <Attendance>(); Count += MainDatabase.CountItemsToSync <CompetitorData>(); Count += MainDatabase.CountItemsToSync <ContractData>(); Count += MainDatabase.CountItemsToSync <CoterieData>(); Count += MainDatabase.CountItemsToSync <DistributionData>(); Count += MainDatabase.CountItemsToSync <Pharmacy>(); Count += MainDatabase.CountItemsToSync <Employee>(); Count += MainDatabase.CountItemsToSync <ExcludeRouteItem>(); Count += MainDatabase.CountItemsToSync <GPSData>(); Count += MainDatabase.CountItemsToSync <Hospital>(); Count += MainDatabase.CountItemsToSync <HospitalData>(); Count += MainDatabase.CountItemsToSync <Entities.Message>(); Count += MainDatabase.CountItemsToSync <MessageData>(); //var photoDatas = MainDatabase.GetItemsToSync<PhotoData>(); Count += MainDatabase.CountItemsToSync <PresentationData>(); Count += MainDatabase.CountItemsToSync <PromotionData>(); Count += MainDatabase.CountItemsToSync <ResumeData>(); Count += MainDatabase.CountItemsToSync <RouteItem>(); var toSyncCount = FindViewById <TextView>(Resource.Id.saSyncEntitiesCount); toSyncCount.Text = string.Format("Необходимо синхронизировать {0} объектов", Count); var toUpdateCount = FindViewById <TextView>(Resource.Id.saUpdateEntitiesCount); toUpdateCount.Text = string.Format("Необходимо обновить {0} объектов", 0); var photoCount = FindViewById <TextView>(Resource.Id.saSyncPhotosCount); photoCount.Text = string.Format("Необходимо выгрузить {0} фото", MainDatabase.CountItemsToSync <PhotoData>()); CancelSource = new CancellationTokenSource(); CancelToken = CancelSource.Token; CheckMaterialFiles(); CSForLibraryFiles = new CancellationTokenSource(); CTForLibraryFiles = CSForLibraryFiles.Token; CheckLibraryFiles(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RequestWindowFeature(WindowFeatures.NoTitle); Window.AddFlags(WindowManagerFlags.KeepScreenOn); // Create your application here SetContentView(Resource.Layout.Profile); FindViewById <Button>(Resource.Id.paCloseB).Click += (sender, e) => { Finish(); }; FindViewById <Button>(Resource.Id.paExitAppB).Click += (sender, e) => { int count = 0; count += MainDatabase.CountItemsToSync <Attendance>(); count += MainDatabase.CountItemsToSync <CompetitorData>(); count += MainDatabase.CountItemsToSync <ContractData>(); count += MainDatabase.CountItemsToSync <CoterieData>(); count += MainDatabase.CountItemsToSync <DistributionData>(); count += MainDatabase.CountItemsToSync <Pharmacy>(); count += MainDatabase.CountItemsToSync <Employee>(); count += MainDatabase.CountItemsToSync <GPSData>(); count += MainDatabase.CountItemsToSync <Hospital>(); count += MainDatabase.CountItemsToSync <HospitalData>(); //var monthFinanceDatas = MainDatabase.GetItemsToSync<FinanceDataByMonth>(); //var quarterFinanceDatas = MainDatabase.GetItemsToSync<FinanceDataByQuarter>(); //var monthSaleDatas = MainDatabase.GetItemsToSync<SaleDataByMonth>(); //var quarterSaleDatas = MainDatabase.GetItemsToSync<SaleDataByQuarter>(); count += MainDatabase.CountItemsToSync <MessageData>(); count += MainDatabase.CountItemsToSync <PresentationData>(); count += MainDatabase.CountItemsToSync <PromotionData>(); count += MainDatabase.CountItemsToSync <ResumeData>(); count += MainDatabase.CountItemsToSync <RouteItem>(); count += MainDatabase.CountItemsToSync <RouteItem>(); count += MainDatabase.CountItemsToSync <PhotoData>(); if (count > 0) { new AlertDialog.Builder(this) .SetTitle(Resource.String.warning_caption) .SetMessage("Перед выходом необходимо синхронизировать все данные!!!") .SetCancelable(true) .SetPositiveButton("OK", (caller, arguments) => { if (caller is Dialog) { (caller as Dialog).Dismiss(); } }) .Show(); } else { GetSharedPreferences(MainActivity.C_MAIN_PREFS, FileCreationMode.Private) .Edit() .PutString(SigninDialog.C_USERNAME, string.Empty) .Commit(); MainDatabase.Dispose(); Finish(); } }; Content = FindViewById <LinearLayout>(Resource.Id.paAttendanceByWeekLL); Table = FindViewById <ListView>(Resource.Id.paAttendanceByWeekTable); int weeksCount = 14; Dates = new DateTimeOffset[weeksCount]; var header = (LinearLayout)LayoutInflater.Inflate(Resource.Layout.AttendanceByWeekTableHeader, Table, false); (header.GetChildAt(0) as TextView).Text = @"Недели"; for (int w = 0; w < weeksCount; w++) { Dates[w] = DateTimeOffset.UtcNow.AddDays(-7 * (weeksCount - 1 - w)); var hView = header.GetChildAt(w + 1); if (hView is TextView) { (hView as TextView).Text = Helper.GetIso8601WeekOfYear(Dates[w].UtcDateTime.Date).ToString(); } } Content.AddView(header, 1); var shared = GetSharedPreferences(MainActivity.C_MAIN_PREFS, FileCreationMode.Private); FindViewById <TextView>(Resource.Id.paUsernameTV).Text = shared.GetString(SigninDialog.C_USERNAME, string.Empty); var agentUUID = shared.GetString(SigninDialog.C_AGENT_UUID, string.Empty); try { var agent = MainDatabase.GetItem <Agent>(agentUUID); FindViewById <TextView>(Resource.Id.paShortNameTV).Text = agent.shortName; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } SearchSwitcher = FindViewById <ViewSwitcher>(Resource.Id.paSearchVS); SearchSwitcher.SetInAnimation(this, Android.Resource.Animation.SlideInLeft); SearchSwitcher.SetOutAnimation(this, Android.Resource.Animation.SlideOutRight); SearchImage = FindViewById <ImageView>(Resource.Id.paSearchIV); SearchImage.Click += (sender, e) => { if (CurrentFocus != null) { var imm = (InputMethodManager)GetSystemService(InputMethodService); imm.HideSoftInputFromWindow(CurrentFocus.WindowToken, HideSoftInputFlags.None); } SearchSwitcher.ShowNext(); }; SearchEditor = FindViewById <EditText>(Resource.Id.paSearchET); SearchEditor.AfterTextChanged += (sender, e) => { var text = e.Editable.ToString(); (Table.Adapter as AttendanceByWeekAdapter).SetSearchText(text); }; }