private void CreateDatabaseOrModifyDatabase(List <VehicleDetails> vehicleList) { DeleteDatabase(FuelDB.Singleton.DBPath); FuelDB.Singleton.CreateTable <VehicleDetails>(); FuelDB.Singleton.CreateTable <BillDetails>(); //FuelDB.Singleton.CreateDatabase<Fuel>(); var details = vehicleList?.First(); vehicleList.RemoveAt(0); var billDetails = new BillDetails { AvailableLiters = details.VID, BillCurrentNumber = details.DriverID_PK, BillPrefix = details.RegNo, DeviceStatus = details.DriverName }; AppPreferences.SaveString(this, Utilities.DEVICESTATUS, billDetails.DeviceStatus); AppPreferences.SaveBool(this, Utilities.IsDownloaded, true); FuelDB.Singleton.InsertValues(vehicleList); btnDownloadData.Clickable = false; FuelDB.Singleton.InsertBillDetails(billDetails); }
private void GetThisWeekPrize(string guest_token) { try { this.Loading(true); var api = new ApiAsnycTask(this.Context, GetString(Resource.String.api_url) + "lotto/GetThisWeekPrize", guest_token); var json = api.Execute().Get().ToString(); var _result = JsonConvert.DeserializeObject <ApiResult <NextWeekPrize> >(json); if (_result != null) { var app_cache = new AppPreferences(this.Context); app_cache.NextWeekSequenceNo = _result.result.SequenceNo; last_week_seqno = _result.result.SequenceNo - 1; if (_result.success == true) { week_prize = _result.result; InitNextWeekPrize(rootView, _result.result); } else { AppDialog.SNG.Alert(this.Context, _result.message); } } this.Loading(false); } catch (Java.Lang.Exception ex) { Log.Error(this.GetType().Name, ex.Message); } }
private void TransitionViewController(object state) { var appPreferences = new AppPreferences(this.ApplicationContext); string Username = appPreferences.GetUsername(); if (Username == "") { // No User Remembered appPreferences.SaveLoginSkipped(false); TransitionToSignIn(); } else { // User exists. appPreferences.SaveLoginSkipped(true); bool MasterDBDownloaded = appPreferences.GetMasterDBDownloaded(); if (MasterDBDownloaded) { // Master DB Downloaded TransitionToMain(); } else { // Master DB Not Found TransitionToDownload(); } } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewModel = new BuildingsViewModel(); Context mContext = Android.App.Application.Context; AppPreferences ap = new AppPreferences(mContext); facilityId = Convert.ToInt32(ap.GetFacilityId()); View view = inflater.Inflate(Resource.Layout.fragment_facility_building, container, false); recyclerView = view.FindViewById <RecyclerView>(Resource.Id.buildingRecyclerView); addButton = view.FindViewById <FloatingActionButton>(Resource.Id.addnewBuilding_button); recyclerView.HasFixedSize = true; recyclerView.SetAdapter(adapter = new BrowseBuildingsAdapter(Activity, ViewModel)); refresher = view.FindViewById <SwipeRefreshLayout>(Resource.Id.buildingRefresher); refresher.SetColorSchemeColors(Resource.Color.accent); progress = view.FindViewById <ProgressBar>(Resource.Id.buildingprogressbar_loading); progress.Visibility = ViewStates.Gone; addButton.Click += AddButton_Click; addButton.SetBackgroundColor(Android.Graphics.Color.Tan); return(view); }
private void LeaveMember(string user_token) { try { this.Loading(true); var api = new ApiAsnycTask(this.Context, GetString(Resource.String.api_url) + "user/LeaveMember", user_token); api.Execute(); api.SendFinish += (s, e) => { var _result = JsonConvert.DeserializeObject <ApiResult <string> >(e.Json); if (_result != null) { if (_result.success == true) { var app_cache = new AppPreferences(this.Context); app_cache.UserTokenKey = ""; Refresh?.Invoke(this, new RefreshEventArgs(true)); } else { AppDialog.SNG.Alert(this.Context, _result.message); } } this.Loading(false); }; } catch (Java.Lang.Exception ex) { Log.Error(this.GetType().Name, ex.Message); } }
private void ListenerClick(object sender, System.EventArgs e) { var app_cache = new AppPreferences(this.Context); var _token = app_cache.UserTokenKey; var _login_id = app_cache.UserLoginId; var _view = (ImageView)sender; switch (_view.Id) { case Resource.Id.iv_pre: user_curr_seqno--; if (user_curr_seqno < user_first_seqno) { user_curr_seqno = user_first_seqno; } break; case Resource.Id.iv_post: user_curr_seqno++; if (user_curr_seqno > user_last_seqno) { user_curr_seqno = user_last_seqno; } break; } GetUserChoicesWithBuffer(_token, _login_id); NavigationToggle(this.rootView); }
private void InitData(View view) { var app_cache = new AppPreferences(this.Context); var _token = app_cache.UserTokenKey; var _login_id = app_cache.UserLoginId; var _user_info = user_infos .Where(u => u.login_id == _login_id) .SingleOrDefault(); if (_user_info == null) { this.GetCount(_token, _user_info); this.GetUserInfo(_token, _login_id); } else { var _interval = Convert.ToInt32(Resource.String.push_read_interval_minute); if (_user_info.last_push_count_read.AddMinutes(_interval) < DateTime.Now) { this.GetCount(_token, _user_info); } DisplayView(_user_info); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); apre = new AppPreferences(this); var m_context = apre.getContextKey(); if (!string.IsNullOrEmpty(m_context)) { StartActivity(typeof(OrderListActivity)); } else { SetContentView(Resource.Layout.Main); userNametext = FindViewById <EditText>(Resource.Id.txtuserName); passwordtext = FindViewById <EditText>(Resource.Id.txtpass); Button btnLogin = FindViewById <Button>(Resource.Id.btnLogin); btnLogin.Click += new System.EventHandler(btnLogin_Click); TextView txtdangky = FindViewById <TextView>(Resource.Id.txtdangky); txtdangky.Click += (object sender, System.EventArgs e) => { Intent viewIntent = new Intent(Intent.ActionView, Android.Net.Uri.Parse("https://Bizkasa.com/")); StartActivity(viewIntent); }; } // Set our view from the "main" layout resource // SetContentView (Resource.Layout.Main); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); ap = new AppPreferences(this); SetContentView(Resource.Layout.activity_list); _toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(_toolbar); _rv = FindViewById <RecyclerView>(Resource.Id.rv); _rv.HasFixedSize = true; _rvLayoutManager = new LinearLayoutManager(this); _rv.SetLayoutManager(_rvLayoutManager); _listItems = new List <ListItem>(); var listaJson = ap.GetString("listaPesquisa", ""); var listaPesquisas = JsonConvert.DeserializeObject <List <Pesquisa> >(listaJson); foreach (var item in listaPesquisas) { _listItem = new ListItem(); _listItem.Title = item.Descricao; _listItem.PageType = typeof(POPActivity); _listItems.Add(_listItem); } _adapter = new CustomAdapter(_listItems, this.Resources); _adapter.ItemClick += OnItemClick; _rv.SetAdapter(_adapter); }
public Servico() { InitializeComponent(); app = new AppPreferences(Forms.Context); CarregarLocaisManutencao(); }
private void InitEvent() { main_tab_layout.TabSelected += (sender, e) => { TabColorToggle(prev_tab_position, false); //Log.Debug(this.GetType().Name, $"InitEvent ({prev_tab_position}) => ({e.Tab.Position})"); prev_tab_position = e.Tab.Position; if (this.mainPagerAdapter.IsAnonymous(e.Tab.Position) == false) { var app_cache = new AppPreferences(this.ApplicationContext); var _token = app_cache.UserTokenKey; if (AppCommon.SNG.CheckExpired(this.ApplicationContext, _token) == true) { AppCommon.SNG.JumpLoginActivity(this.ApplicationContext); return; } } main_view_pager.CurrentItem = e.Tab.Position; var _fragment = (IPagerFragment)this.mainPagerAdapter.GetItem(e.Tab.Position); _fragment.Initialize(); TabColorToggle(e.Tab.Position, true); }; }
private void GetPrizeBySeqNoWithBuffer(string guest_token, int sequence_no) { if (winner_list.Count <= 0) { var app_cache = new AppPreferences(this.Context); var _cache_winner = app_cache.WinnerHistory; if (_cache_winner != null) { winner_list = _cache_winner; } } var _winner = winner_list .Where(w => w.sequenceNo == sequence_no) .SingleOrDefault(); if (_winner == null) { GetPrizeBySeqNo(guest_token, sequence_no); } else { InitWinnerBySeqNo(rootView, _winner); } }
private async void GetDetails() { WebService.IPADDRESS = AppPreferences.GetString(this, Utilities.IPAddress); //WebService.IPADDRESS = "49.207.180.49"; //did = "FED11"; did = AppPreferences.GetString(this, Utilities.DEVICEID); //siteId = "2"; siteId = AppPreferences.GetString(this, Utilities.SITEID); try { //var result = await WebService.Singleton.PostDataToWebService(Utilities.GET_VEHICLE_DETAILS, did, siteId, Utilities.GET_VEHICLE_RESULT); //vehiclDetailList = JsonConvert.DeserializeObject<List<VehicleDetails>>(result); var itemType = await WebService.Singleton.PostDataToWebService(Utilities.GET_ITEM_DETAILS, did, siteId, Utilities.GET_ITEM_RESULT); itemDetails = JsonConvert.DeserializeObject <List <ItemDetails> >(itemType); itemList = itemDetails.Select(x => x.MaterialName).ToList(); //itemList.Insert(0, "Select"); //itemTypeSpinner.Adapter = new BasicAdapter(this, itemDetails.Select(x => x.MaterialName).ToArray()); ShowLoader(false); } catch (Exception ex) { RunOnUiThread(() => { Toast.MakeText(this, "No Data to load..", ToastLength.Short).Show(); ShowLoader(false); }); Console.WriteLine(ex.Message); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.config); var txtIpAddress = FindViewById <EditText>(Resource.Id.txtIP); var txtDeviceID = FindViewById <EditText>(Resource.Id.txtDeviceId); var txtSiteID = FindViewById <EditText>(Resource.Id.txtSiteId); FindViewById <Button>(Resource.Id.btnConfig).Click += (s, e) => { if (txtIpAddress.Text.Equals(string.Empty) || txtDeviceID.Text.Equals(string.Empty) || txtSiteID.Text.Equals(string.Empty)) { Toast.MakeText(this, "Enter all fields..", ToastLength.Short).Show(); return; } Toast.MakeText(this, "Success", ToastLength.Short).Show(); AppPreferences.SaveString(this, Utilities.IPAddress, txtIpAddress.Text.Replace(" ", "")); AppPreferences.SaveString(this, Utilities.DEVICEID, txtDeviceID.Text.Replace(" ", "")); AppPreferences.SaveString(this, Utilities.SITEID, txtSiteID.Text.Replace(" ", "")); StartActivity(typeof(LogInActivity)); }; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewModel = new FacilitiesViewModel(); ap = new AppPreferences(Application.Context); this.SqlLiteManager = new SqlLiteManager(); userId = Convert.ToInt32(ap.GetUserId()); View view = inflater.Inflate(Resource.Layout.fragment_facility, container, false); recyclerView = view.FindViewById <RecyclerView>(Resource.Id.facilityRecyclerView); searchedTxt = view.FindViewById <EditText>(Resource.Id.searchedTxt); searchedTxt.TextChanged += Search_Facilities; recyclerView.HasFixedSize = true; recyclerView.SetAdapter(adapter = new BrowseFacilitiesAdapter(Activity, ViewModel, userId)); refresher = view.FindViewById <SwipeRefreshLayout>(Resource.Id.refresher); refresher.SetColorSchemeColors(Resource.Color.accent); progress = view.FindViewById <ProgressBar>(Resource.Id.progressbar_loading); progress.Visibility = ViewStates.Gone; return(view); }
private async void GetImages(AppPreferences ap) { if (!String.IsNullOrEmpty(imageNames[0])) { Bitmap bit = ap.SetImageBitmap(ap.CreateDirectoryForPictures() + "/" + imageNames[0]); if (bit != null) { pictureHolder.SetImageBitmap(bit); } else if (bit == null && !String.IsNullOrEmpty(imageNames[0])) { PictureViewModel pictureViewModel = new PictureViewModel(); Models.Picture picture = await pictureViewModel.ExecuteGetPictureCommand(imageNames[0]); if (picture != null) { var _bit = ap.StringToBitMap(picture.File); if (_bit != null) { ap.SaveImage(_bit, imageNames[0]); } pictureHolder.SetImageBitmap(_bit); } } } }
public void CreateDatabaseOrModifyDatabase(List <VehicleDetails> vehicleList) { DeleteDatabase(FuelDB.Singleton.DBPath); FuelDB.Singleton.CreateTable <VehicleDetails>(); FuelDB.Singleton.CreateTable <BillDetails>(); var details = vehicleList?.First(); vehicleList.RemoveAt(0); var billDetails = new BillDetails { AvailableLiters = details.VID, BillCurrentNumber = details.DriverID_PK, BillPrefix = details.RegNo, DeviceStatus = details.DriverName }; AppPreferences.SaveString(this, Utilities.DEVICESTATUS, billDetails.DeviceStatus); AppPreferences.SaveBool(this, Utilities.IsDownloaded, true); FuelDB.Singleton.InsertValues(vehicleList); btnDownloadData.Clickable = false; FuelDB.Singleton.InsertBillDetails(billDetails); RunOnUiThread(() => { loader.Visibility = Android.Views.ViewStates.Gone; mainHolder.Alpha = 1f; Window.ClearFlags(Android.Views.WindowManagerFlags.NotTouchable); Toast.MakeText(this, "success..", ToastLength.Short).Show(); btnDownloadData.Clickable = false; AppPreferences.SaveBool(this, Utilities.IsDownloaded, true); }); ExceptionLog.LogDetails(this, "Database created successfully"); }
protected override void OnResume() { base.OnResume(); if (this.mainPagerAdapter.IsAnonymous(prev_tab_position) == false) { var app_cache = new AppPreferences(this.ApplicationContext); var _token = app_cache.UserTokenKey; if (AppCommon.SNG.CheckExpired(this.ApplicationContext, _token) == false) { var _fragment = (IPagerFragment)this.mainPagerAdapter.GetItem(prev_tab_position); _fragment.Initialize(); } else { prev_tab_position = 0; } } var tab = main_tab_layout.GetTabAt(prev_tab_position); tab.Select(); main_view_pager.CurrentItem = prev_tab_position; }
private async void SaveFacility() { if (appPreferences.IsOnline(Application.Context)) { facility.SettlementType = settlementtype.SelectedItem.ToString(); facility.Zoning = zoning.SelectedItem.ToString(); MessageDialog messageDialog = new MessageDialog(); messageDialog.ShowLoading(); bool isUpdated = await viewModel.ExecuteUpdateFacilityCommand(facility); messageDialog.HideLoading(); if (isUpdated) { messageDialog.SendToast("Facility Information is saved successful."); var intent = new Intent(this, typeof(FacilityDetailActivity)); Context mContext = Android.App.Application.Context; AppPreferences ap = new AppPreferences(mContext); ap.SaveFacilityId(facility.Id.ToString()); intent.PutExtra("data", Newtonsoft.Json.JsonConvert.SerializeObject(facility)); this.StartActivity(intent); Finish(); } else { messageDialog.SendToast("Error occurred: Unable to save Facility Information."); } } }
/// <summary> /// Sends an HTTP request to the DRM DeviceCore service with the given /// data. /// </summary> /// <param name="method">HTTP method.</param> /// <param name="data">Data to send.</param> private void SendDRMRequest(string method, string data) { string user = AppPreferences.GetDRMUsername(); string pwd = AppPreferences.GetDRMPassword(); if (string.IsNullOrEmpty(user) || string.IsNullOrEmpty(pwd)) { throw new Exception("User and password not configured."); } // Create url to the Remote Manager server for a given web service request. Uri url = new Uri(string.Format("{0}/ws/DeviceCore", AppPreferences.GetDRMServer())); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = method; CredentialCache credCache = new CredentialCache(); credCache.Add(url, "Basic", new NetworkCredential(user, pwd)); request.Credentials = credCache; request.ContentType = "text/xml"; request.Accept = "text/xml"; StreamWriter writer = new StreamWriter(request.GetRequestStream()); writer.Write(data); writer.Close(); // Get response. WebResponse serverResponse = request.GetResponse(); serverResponse.Close(); }
protected override void OnExit(ExitEventArgs e) { try { AppPreferences.Save(App.AppName); } catch (Exception ex) { Console.WriteLine(ex); Console.WriteLine(ex.StackTrace); } try { RecycleBin.Instance.DeleteContent(); } catch (Exception ex) { Console.WriteLine(ex); Console.WriteLine(ex.StackTrace); } try { BatchAction.DeleteUndoFiles(); } catch (Exception ex) { Console.WriteLine(ex); Console.WriteLine(ex.StackTrace); } base.OnExit(e); }
public async Task <bool> UpdatePreferencesAsync(AppPreferences appPreferences, Guid userId) { try { var user = await GetByIdAsync(userId); if (user.AppPreferences.Language != appPreferences.Language) { user.AppPreferences.Language = appPreferences.Language; } if (user.AppPreferences.Theme != appPreferences.Theme) { user.AppPreferences.Theme = appPreferences.Theme; } await _userRepository.SaveChangesAsync(); return(true); } catch (Exception e) { Console.WriteLine(e); return(false); } }
private async void SignIn_Click(object sender, EventArgs e) { if (!ValidateForm()) { return; } MessageDialog messageDialog = new MessageDialog(); AppPreferences ap = new AppPreferences(Application.Context); messageDialog.ShowLoading(); EncryptionHelper encryptionHelper = new EncryptionHelper(); message.Text = ""; var user = new User() { Username = username.Text, Password = password.Text, }; //if (ap.IsOnline(Application.Context)) //{ user = await ViewModel.ExecuteLoginCommand(user); // this.SqlLiteManager.CreateDatabase(); //await this.SqlLiteManager.InsertUpdateUser(this.SqlLiteManager.MapUserToLocalUser(user)); //} //else { // var locaUser = await SqlLiteManager.GetUser(this.SqlLiteManager.MapUserToLocalUser(user)); // if (locaUser != null) // user = SqlLiteManager.MapLocalUserToUser(locaUser); // else { // user = new User() // { // RespondMessage = "Invaild username or password.", // }; // } //} if (user.RespondMessage != null) { message.Text = user.RespondMessage; } else { var newIntent = new Intent(this, typeof(MainActivity)); newIntent.AddFlags(ActivityFlags.ClearTop); newIntent.AddFlags(ActivityFlags.SingleTop); ap.SaveUserId(user.Id.ToString()); StartActivity(newIntent); Finish(); } messageDialog.HideLoading(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var data = Intent.GetStringExtra("data"); appPreferences = new AppPreferences(Application.Context); var item = Newtonsoft.Json.JsonConvert.DeserializeObject <Facility>(data); viewModel = new FacilityDetailViewModel(item); Bundle mybundle = new Bundle(); mybundle.PutString("data", Newtonsoft.Json.JsonConvert.SerializeObject(item)); adapter = new TabsAdapter(this, SupportFragmentManager, mybundle); pager = FindViewById <ViewPager>(Resource.Id.viewpager); var tabs = FindViewById <TabLayout>(Resource.Id.tabs); pager.Adapter = adapter; tabs.SetupWithViewPager(pager); pager.OffscreenPageLimit = 3; Toolbar.MenuItemClick += (sender, e) => { var itemTitle = e.Item.TitleFormatted; switch (itemTitle.ToString()) { case "Log Out": var intent = new Intent(this, typeof(LoginActivity)); appPreferences.SaveUserId("0"); StartActivity(intent); break; case "Submit": FacilityInformationFragment fragment = (FacilityInformationFragment)SupportFragmentManager.Fragments[1]; if (fragment != null) { fragment.SubmitFacility(); } break; case "Add": var buildingIntent = new Intent(this, typeof(AddBuildingActivity));; StartActivity(buildingIntent); break; } }; pager.PageSelected += (sender, args) => { var fragment = adapter.InstantiateItem(pager, args.Position) as IFragmentVisible; fragment?.BecameVisible(); }; SupportActionBar.Title = item.Name; SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); }
/// <summary> /// Method called when the 'OK' button is clicked. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">Event args.</param> private void OkClicked(object sender, EventArgs e) { // Save the DRM username and password in the preferences. AppPreferences.SetDRMUsername(usernameEntry.Text); AppPreferences.SetDRMPassword(passwordEntry.Text); AppPreferences.SetDRMServer(serverPicker.SelectedIndex == 0 ? SERVER_PRODUCTION : SERVER_TEST); ClosePopup(); }
public async Task <IActionResult> UpdatePreferences([FromBody] AppPreferences appPreferences) { var user = await _userManager.GetUserAsync(User); await _userService.UpdatePreferencesAsync(appPreferences, user.Id); return(Ok()); }
public Limpeza() { InitializeComponent(); app = new AppPreferences(Forms.Context); CarregarDados(); }
public void ApplyAppPreferences(AppPreferences preferences) { base.ExecuteMethod("ApplyAppPreferences", delegate() { this.AppPreferences = preferences; this.CacheHost.PersistentDataSet(false, CACHE_FILENAME_APP_PREFS, preferences); }); }
private void PushCountryData(int position) { var preferences = new AppPreferences(this._view.Context); preferences.SaveAccessKey(PreferenceField.PREFERENCE_COUNTNTRY_DATA, _countryArray[position]); this.FragmentManager.PopBackStack(); }
private void SaveAppSettings() { AppSettings.ShowWalkTroutPage = false; var appPref = new AppPreferences(); appPref.StoreShowWalkThroughPageValue(AppSettings.ShowWalkTroutPage); }