Пример #1
0
        private void CheckDownloadResult(object state)
        {
            //PrepareTestSpec();

            if (Core.Globals.GetFileNameResult == GetFileNameResultType.Success)
            {
                // Success
                if (Core.Globals.DownloadMasterDBResult == DownloadDBResultType.Success)
                {
                    var appPreferences = new AppPreferences(this.ApplicationContext);
                    appPreferences.SaveMasterDBDownloaded(true);

                    if (Core.Globals.DownloadAuditDBResult == DownloadDBResultType.Success)
                    {
                        appPreferences.SaveAuditDBDownloaded(true);

                        TransitionToMain();
                    }
                    else if (Core.Globals.DownloadAuditDBResult == DownloadDBResultType.NotFoundError || Core.Globals.DownloadAuditDBResult == DownloadDBResultType.BadRequestError)
                    {
                        RunOnUiThread(() =>
                        {
                            DownloadProcessingLayout.Visibility = ViewStates.Gone;
                            DownloadErrorAuditLayout.Visibility = ViewStates.Visible;
                        });
                    }
                }
                else if (Core.Globals.DownloadMasterDBResult == DownloadDBResultType.NotFoundError || Core.Globals.DownloadMasterDBResult == DownloadDBResultType.BadRequestError)
                {
                    RunOnUiThread(() =>
                    {
                        DownloadProcessingLayout.Visibility  = ViewStates.Gone;
                        DownloadErrorMasterLayout.Visibility = ViewStates.Visible;
                    });
                }
            }
            else
            {
                // Error
                RunOnUiThread(() =>
                {
                    DownloadProcessingLayout.Visibility    = ViewStates.Gone;
                    DownloadErrorFilenameLayout.Visibility = ViewStates.Visible;
                });
            }
        }
Пример #2
0
        private void ListItemClicked(int position)
        {
            Android.Support.V4.App.Fragment fragment = null;
            switch (position)
            {
            case 0:
                this.Title = "Dashboard";
                fragment   = new DashboardFragment();
                break;

            case 1:
                this.Title = "Outlet List";
                fragment   = new OutletListFragment();
                break;

            case 2:
                this.Title = "Unit of Measurement";
                fragment   = new UOMFragment();
                break;

            case 3:
                this.Title = "Synchronization";
                fragment   = new SyncFragment();
                break;

            case 4:
                this.Title = "About";
                fragment   = new AboutFragment();
                break;

            case 5:
                Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(this);
                builder.SetTitle("Confirm");
                builder.SetMessage("Are you sure you want to log out?");
                builder.SetPositiveButton("NO", (sender, e) =>
                {
                });
                builder.SetNegativeButton("YES", (sender, e) =>
                {
                    var appPreferences = new AppPreferences(this.ApplicationContext);
                    appPreferences.SaveUsername("");
                    appPreferences.SavePassword("");
                    appPreferences.SaveMasterDBDownloaded(false);
                    appPreferences.SaveAuditDBDownloaded(false);

                    string masterDBPath = new FileUtil().GetMasterDBPath();
                    if (File.Exists(masterDBPath))
                    {
                        File.Delete(masterDBPath);
                    }

                    string auditDBPath = new FileUtil().GetAuditDBPath();
                    if (File.Exists(auditDBPath))
                    {
                        File.Delete(auditDBPath);
                    }

                    string auditDBBlankPath = new FileUtil().GetAuditDBBlankPath();
                    if (File.Exists(auditDBBlankPath))
                    {
                        File.Delete(auditDBBlankPath);
                    }

                    string tempZipFile = new FileUtil().GetTempZipFileName();
                    if (File.Exists(tempZipFile))
                    {
                        File.Delete(tempZipFile);
                    }

                    string tempDirectoryPath = new FileUtil().GetTempDirectoryPath();
                    string auditZipPath      = System.IO.Path.Combine(tempDirectoryPath, Core.Globals.LoginUsername + ".zip");
                    if (File.Exists(auditZipPath))
                    {
                        File.Delete(auditZipPath);
                    }

                    FileUtil.ClearCache();
                    FileUtil.DeleteCache(this.ApplicationContext);

                    GlobalsAndroid.masterDB = null;

                    GC.Collect();
                    GC.WaitForPendingFinalizers();

                    Finish();
                });
                builder.Show();
                return;
            }

            if (!IsFinishing)
            {
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment)
                .CommitAllowingStateLoss();
            }
        }