示例#1
0
        public static void Init()
        {
            AppConfigurationModel configModel = null;
            AppConfig             dbRow       = null;

            try
            {
                using (var con = DependencyService.Get <IDatabase>().GetConnection(ConnectionType.AppConfig))
                {
                    dbRow = con.Table <AppConfig>().FirstOrDefault(each => true);

                    if (TryToUpdateCurrentConfigInDb(out configModel, con, dbRow))
                    {
                    }
                    else
                    {
                        configModel = JsonConvert
                                      .DeserializeObject <AppConfigurationModel>(dbRow.ApplicationConfiguration);
                    }
                    CurrentLanguage = dbRow.ConfigInt;
                    SetConfigurations(configModel);
                }
            }
            catch (Exception e)
            {
                //wtf
                var mes = e.Message;
            }
        }
示例#2
0
        public static void ChangeConfiguration(int id)
        {
            if (!Busy)
            {
                Busy = true;
                Utility.ShowIndicator = true;
                if (id != CurrentLanguage)
                {
                    AppConfigurationModel buffer = default(AppConfigurationModel);
                    bool success = false;

                    using (var con = DependencyService.Get <IDatabase>().GetConnection(ConnectionType.AppConfig))
                    {
                        success = TryToUpdateCurrentConfigInDb(out buffer, con, new AppConfig {
                            ConfigInt = id
                        });
                    }
                    if (success)
                    {
                        CurrentLanguage = id;
                        SetConfigurations(buffer);
                        SetColors();
                    }
                    else
                    {
                        (Application.Current.MainPage as MainPage).DisplayAlert("HomeM8", "İnternet bağlantınızda sorun olabilir", "Tamam");
                    }
                }
                Busy = false;
                Utility.ShowIndicator = false;
            }
        }
示例#3
0
        static bool TryToUpdateCurrentConfigInDb(out AppConfigurationModel bufferConfigModel, SQLiteConnection con, AppConfig dbRow)
        {
            AppConfigResponseModel buffer = null;

            Task.Run(() => buffer = JsonConvert.DeserializeObject <AppConfigResponseModel>(Helper
                                                                                           .httpGetAsync($"{Utility.BaseURL}/api/app/GetAppConfiguration?id={dbRow.ConfigInt}").Result)).Wait();

            if (buffer.responseVal == 0)
            {
                con.Table <AppConfig>().Delete(each => true);

                con.Insert(new AppConfig()
                {
                    ConfigInt = dbRow.ConfigInt, ApplicationConfiguration = buffer.languageJsonString
                });

                bufferConfigModel = JsonConvert.DeserializeObject <AppConfigurationModel>(buffer.languageJsonString);
                return(true);
            }
            else
            {
                bufferConfigModel = null;
                return(false);
            }
        }
示例#4
0
 static void SetConfigurations(AppConfigurationModel configModel)
 {
     Instance.DecidePageContent         = configModel.DecidePageContent;
     Instance.AppColorConfiguration     = configModel.AppColorConfiguration;
     Instance.ForgotPasswordPageContent = configModel.ForgotPasswordPageContent;
     Instance.LoginPageContent          = configModel.LoginPageContent;
     Instance.RegisterPageContent       = configModel.RegisterPageContent;
     Instance.HomePageContent           = configModel.HomePageContent;
     Instance.ApplicationContent        = configModel.ApplicationContent;
     Instance.AccountPageContent        = configModel.AccountPageContent;
 }
示例#5
0
 public void ChangeConfiguration(int id)
 {
     AppConfigurationModel.ChangeConfiguration(id);
 }
示例#6
0
 public App()
 {
     InitializeComponent();
     AppConfigurationModel.SetColors();
     MainPage = new MainPage();
 }