예제 #1
0
        protected override void OnPause()
        {
            base.OnPause ();

            CheckBox cbDateIndicate = FindViewById<CheckBox>(Resource.Id.cbDateIndicate);
            CheckBox cbDataUpdate = FindViewById<CheckBox>(Resource.Id.cbDataUpdate);

            // Konfiguration speichern
            AppConfig appConfig = new AppConfig();
            appConfig.DateIndicate = cbDateIndicate.Checked;
            appConfig.DataAutomaticUpdate = cbDataUpdate.Checked;

            Config config = new Config(this);
            config.SetAppConfig(appConfig);
            config.SetWSConfig(settingsFeedListAdapter.GetFeedConfig);
        }
예제 #2
0
        public AppConfig GetAppConfig()
        {
            Logging.Log(this, Logging.LoggingTypeDebug, "GetAppConfig()");

            AppConfig ret = new AppConfig();
            string sqlCommand = "SELECT AppIsConfigured, DateIndicate, DataAutomaticUpdate FROM config Limit 1;";

            try
            {
                using(SqliteConnection conn = GetConnection())
                {
                    using(DbCommand c = conn.CreateCommand())
                    {
                        using (SqliteCommand sqlCmd = new SqliteCommand(sqlCommand, conn))
                        {
                            conn.Open();

                            using (DbDataReader reader = sqlCmd.ExecuteReader())
                            {
                                // Es gibt nur eine letzte Version
                                reader.Read();

                                if (reader.HasRows)
                                {
                                    ret.AppIsConfigured = reader.GetBoolean(0);
                                    ret.DateIndicate = reader.GetBoolean(1);
                                    ret.DataAutomaticUpdate = reader.GetBoolean(2);
                                }
                            }

                            conn.Close();
                        }
                    }
                }
            }
            catch(SqliteException ex)
            {
                Logging.Log(this, Logging.LoggingTypeError, ".GetAppConfig()", ex);
            }

            return ret;
        }
        public override void ViewWillDisappear(bool animated)
        {
            base.ViewWillDisappear (animated);

            dsEinstellungenList.SaveData();

            AppConfig appConfig = new AppConfig()
            {
                AppIsConfigured = true,
                DataAutomaticUpdate = swAutoDownload.On,
                DateIndicate = false
            };

            new Config(this).SetAppConfig(appConfig);

            if (NavigationController.TopViewController.GetType() == typeof(NewsListViewController))
            {
                ((NewsListViewController)NavigationController.TopViewController).UpDateFeeds();
            }
        }
예제 #4
0
        public void SetAppConfig(AppConfig config)
        {
            if (config == null)
                return;

            try
            {
                using(SqliteConnection conn = GetConnection())
                {
                    using(DbCommand c = conn.CreateCommand())
                    {
                        using (SqliteCommand sqlCmd = new SqliteCommand("UPDATE config SET AppIsConfigured=1, DateIndicate = @DateIndicate, DataAutomaticUpdate = @DataAutomaticUpdate;", conn))
                        {
                            sqlCmd.Parameters.AddWithValue("@DateIndicate", config.DateIndicate);
                            sqlCmd.Parameters.AddWithValue("@DataAutomaticUpdate", config.DataAutomaticUpdate);

                            conn.Open();
                            sqlCmd.ExecuteNonQuery();
                            conn.Close();
                        }
                    }
                }
            }
            catch(SqliteException ex)
            {
                Logging.Log(this, Logging.LoggingTypeError, ".SetAppConfig()", ex);
            }
        }
예제 #5
0
        public AppConfig GetAppConfig()
        {
            AppConfig ret = new AppConfig();
            string sqlCommand = "SELECT AppIsConfigured, DateIndicate, DataAutomaticUpdate FROM config Limit 1;";

            #if MONODROID
            if ((int)Android.OS.Build.VERSION.SdkInt < 77)
            {
                /*
                 * http://pastebin.com/tNPmzXND
                 * http://www.c-sharpcorner.com/UploadFile/88b6e5/sqlitedatabase-connectivity/
                 *
                try
                {
                    DBHelper dbHelper = new DBHelper((Android.Content.Context)context);
                    Android.Database.Sqlite.SQLiteDatabase sqlDB = dbHelper.ReadableDatabase;

                    Cursor reader = sqlDB.RawQuery(sqlCommand, null);
                    while(result.moveToNext())
                    {
                        ret.AppIsConfigured = reader.GetBoolean(0);
                        ret.DateIndicate = reader.GetBoolean(1);
                        ret.DataAutomaticUpdate = reader.GetBoolean(2);
                    }

                    dbHelper.Close();
                }
                catch(Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(this.GetType() + ".GetAppConfig() - ex: " + ex.ToString());
                }

                return ret;
                */
            }
            #endif

            try
            {
                using(SqliteConnection conn = GetConnection())
                {
                    using(DbCommand c = conn.CreateCommand())
                    {
                        using (SqliteCommand sqlCmd = new SqliteCommand(sqlCommand, conn))
                        {
                            conn.Open();

                            using (DbDataReader reader = sqlCmd.ExecuteReader())
                            {
                                // Es gibt nur eine letzte Version
                                reader.Read();

                                if (reader.HasRows)
                                {
                                    ret.AppIsConfigured = reader.GetBoolean(0);
                                    ret.DateIndicate = reader.GetBoolean(1);
                                    ret.DataAutomaticUpdate = reader.GetBoolean(2);
                                }
                            }

                            conn.Close();
                        }
                    }
                }
            }
            catch(SqliteException ex)
            {
                System.Diagnostics.Debug.WriteLine(this.GetType() + ".GetAppConfig() - ex: " + ex.ToString());
            }

            return ret;
        }
예제 #6
0
        public void SetAppConfig(AppConfig config)
        {
            if (config == null)
                return;

            try
            {
                using(SqliteConnection conn = GetConnection())
                {
                    using(DbCommand c = conn.CreateCommand())
                    {
                        using (SqliteCommand sqlCmd = new SqliteCommand("UPDATE config SET AppIsConfigured=1, DateIndicate = @DateIndicate, DataAutomaticUpdate = @DataAutomaticUpdate;", conn))
                        {
                            sqlCmd.Parameters.AddWithValue("@DateIndicate", config.DateIndicate);
                            sqlCmd.Parameters.AddWithValue("@DataAutomaticUpdate", config.DataAutomaticUpdate);

                            conn.Open();
                            sqlCmd.ExecuteNonQuery();
                            conn.Close();
                        }
                    }
                }
            }
            catch(SqliteException ex)
            {
                System.Diagnostics.Debug.WriteLine(this.GetType() + ".SetAppConfig() - ex: " + ex.ToString());
            }
        }