/// Saves the user preferences.
        public Boolean SaveUserPreferences(LoginModel loginModel)
        {
            Boolean lReturnValue = false;

            if (loginModel == null)
            {
                return(lReturnValue);
            }

            if ((loginModel.UserName == null) || (loginModel.Password == null))
            {
                return(lReturnValue);
            }

            Dictionary <String, Object> lDictionary = new Dictionary <String, Object>();

            lDictionary.Add(Defines.KeyUserName, loginModel.UserName);
            lDictionary.Add(Defines.KeyPassword, loginModel.Password);
            lDictionary.Add(Defines.KeyShouldRemember, loginModel.ShouldRemember);
            lDictionary.Add(Defines.KeyLoginCookies, loginModel.Cookies);

            String lValue = JsonConvert.SerializeObject(lDictionary);

            SQLiteRowData lSQLiteRowData = new SQLiteRowData(Defines.KeyUserPreferences, lValue);
            int           tempValue      = SaveItem(lSQLiteRowData).Result;

            if (tempValue > 0)
            {
                lReturnValue = true;
            }

            return(lReturnValue);
        }
 /// <summary>
 /// Deletes the item async.
 /// </summary>
 /// <returns>The item async.</returns>
 /// <param name="item">Item.</param>
 public Task <int> DeleteItemAsync(SQLiteRowData item)
 {
     lock (lockObject)
     {
         return(sqliteConnection.DeleteAsync(item));
     }
 }
        /// Gets the user preferences.
        public LoginModel GetUserPreferences()
        {
            LoginModel lLoginModel = null;

            Task <SQLiteRowData> tempSQLiteRowData = GetItemForKey(Defines.KeyUserPreferences);

            SQLiteRowData lSQLiteRowData = null;

            if (tempSQLiteRowData.Result != null)
            {
                lSQLiteRowData = tempSQLiteRowData.Result;
            }

            if (lSQLiteRowData != null)
            {
                String lValue = lSQLiteRowData.Value;
                Dictionary <String, Object> lDictionary = JsonConvert.DeserializeObject <Dictionary <String, Object> >(lValue);
                if (lDictionary != null)
                {
                    lLoginModel                = new LoginModel();
                    lLoginModel.UserName       = (String)lDictionary[Defines.KeyUserName];
                    lLoginModel.Password       = (String)lDictionary[Defines.KeyPassword];
                    lLoginModel.ShouldRemember = (Boolean)lDictionary[Defines.KeyShouldRemember];
                    lLoginModel.Cookies        = (String)lDictionary[Defines.KeyLoginCookies];
                }
            }
            return(lLoginModel);
        }
Example #4
0
 public static void saveTimePeriod(string selectedTimePeriod)
 {
     if (selectedTimePeriod != null)
     {
         SQLite.SQLiteRowData data = new SQLite.SQLiteRowData();
         data = new SQLiteRowData("SelectedSettingTimePeriod", selectedTimePeriod);
         SQLiteManager.SharedInstance().SaveItem(data);
     }
 }
Example #5
0
 public static void saveDefaultView(string selectedDefaultView)
 {
     if (selectedDefaultView != null)
     {
         SQLite.SQLiteRowData data = new SQLite.SQLiteRowData();
         data = new SQLiteRowData("SelectedSettingDefaultView", selectedDefaultView);
         SQLiteManager.SharedInstance().SaveItem(data);
     }
 }
Example #6
0
        /// <summary>
        /// Gets the environment value.
        /// </summary>
        /// <returns>The environment value.</returns>
        public static string getEnvironmentValue()
        {
            string        environmentValue = "QA";
            SQLiteRowData checkForQAEnvironmentActivated = SQLiteManager.SharedInstance().GetItemForKey("EnvironmentValue").Result;

            if (checkForQAEnvironmentActivated != null)
            {
                environmentValue = checkForQAEnvironmentActivated.Value;
            }

            return(environmentValue);
        }
        /// Deletes the user preferences.
        public Boolean DeleteUserPreferences()
        {
            Boolean lReturnValue = false;

            SQLiteRowData lSQLiteRowData = new SQLiteRowData(Defines.KeyUserPreferences, "");
            int           tempValue      = DeleteItemAsync(lSQLiteRowData).Result;

            if (tempValue > 0)
            {
                lReturnValue = true;
            }
            return(lReturnValue);
        }
        public void ConnectionWasSuccessFullWithResult(object result, string RequestID)
        {
            try
            {
                IsBusy = false;
                if (RequestID == Defines.LoginRequestServerHit)
                {
                    Dictionary <String, Object> lDictionary = (Dictionary <String, Object>)result;
                    String     lConnectionResponseMessage   = (String)lDictionary[Defines.KeyConnectionResponseMessage];
                    String     lLoginCookies = (String)lDictionary[Defines.KeyLoginCookies];
                    LoginModel lLoginModel   = new LoginModel();
                    lLoginModel.UserName       = UserName;
                    lLoginModel.Password       = Password;
                    lLoginModel.Cookies        = lLoginCookies;
                    lLoginModel.ShouldRemember = ShouldRememberMe;
                    var qaActivated = Utilities.getEnvironmentValue();
                    Console.Out.WriteLine("Login Screen Success: \r {0}", lConnectionResponseMessage);

                    SQLiteRowData dataTime = new SQLiteRowData();
                    SQLiteRowData dataView = new SQLiteRowData();

                    dataTime = Utilities.getTimePeriod();
                    dataView = Utilities.getDefaultView();

                    Utilities.deleteAllDataFromSQlite();
                    Utilities.saveEnvironment(qaActivated);
                    if (dataTime != null)
                    {
                        Utilities.saveTimePeriod(dataTime.Value);
                    }
                    if (dataView != null)
                    {
                        Utilities.saveDefaultView(dataView.Value);
                    }
                    SQLiteManager.SharedInstance().SaveUserPreferences(lLoginModel);
                    Navigation.PushAsync(new DealerSearchPage(false));
                }
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine("Login Screen Success Exception: \r {0}", ex.Message);
                DisplayAlert("Login Alert", "Could not Login. Please try again!!", "OK");
            }
        }
 /// <summary>
 /// Saves the item.
 /// </summary>
 /// <returns>The item.</returns>
 /// <param name="item">Item.</param>
 public Task <int> SaveItem(SQLiteRowData item)
 {
     /* if (item.ID != 0)
      * {
      *   return sqliteConnection.UpdateAsync(item);
      * }
      * else
      * {
      *   return sqliteConnection.InsertAsync(item);
      * } */
     lock (lockObject)
     {
         SQLiteRowData lRowData = GetItemForKey(item.Key).Result;
         if ((lRowData != null) && (lRowData.Key.ToLower().Equals(item.Key.ToLower())))
         {
             item.ID = lRowData.ID;
             return(sqliteConnection.UpdateAsync(item));
         }
         else
         {
             return(sqliteConnection.InsertAsync(item));
         }
     }
 }
Example #10
0
 public static void saveEnvironment(string enviromentValue)
 {
     SQLite.SQLiteRowData data = new SQLite.SQLiteRowData();
     data = new SQLiteRowData("EnvironmentValue", enviromentValue);
     SQLiteManager.SharedInstance().SaveItem(data);
 }