private void UpdateRegInfo(RegInfoFB info) { string jsonString1 = JsonHelper.ParseObjectToJSON <RegInfoFB>(info); string url = string.Format("registrations-data/{0}-{1}", _clientInfo.SchoolId, _clientInfo.SessionString); FirebaseHelper.PatchData(jsonString1, url); }
public async void update(long device_id, [FromQuery] string account_id, [FromBody] UpdateScheduledMessageRequest request) { using (var dbContext = new PulseDbContext()) { var(account, message) = await GetScheduledMessage(dbContext, device_id, account_id); if (message == null) { return; } message.To = request.To; message.Data = request.Data; message.MimeType = request.MimeType; message.Timestamp = request.Timestamp; message.Title = request.Title; message.Repeat = request.Repeat; await FirebaseHelper.SendMessage(account, "updated_scheduled_message", new { id = message.DeviceId, to = message.To, data = message.Data, mimeType = message.MimeType, timestamp = message.Timestamp, title = message.Title, repeat = message.Repeat }); await dbContext.SaveChangesAsync(); } }
async void CrearMapa() { Loading2(true); var pueblo = await FirebaseHelper.ObtenerPueblo(Ruta.IdPueblo); if (string.IsNullOrEmpty(pueblo.Nombre)) { UserDialogs.Instance.Alert("Advertencia", Constantes.TitlePuebloRequired + " A continuación guarde el nombre antes de empezar a crear contenido.", "OK"); return; } Geocoder geoCoder = new Geocoder(); string address = pueblo.Nombre + ", Andalucía, Spain"; IEnumerable <Position> approximateLocations = await geoCoder.GetPositionsForAddressAsync(address); Position position = approximateLocations.FirstOrDefault(); MapSpan mapSpan = MapSpan.FromCenterAndRadius(position, Distance.FromKilometers(0.5)); Map = new Map(mapSpan) { WidthRequest = -1, HeightRequest = 300, HasScrollEnabled = true, HasZoomEnabled = true, IsShowingUser = true }; PonerRuta(); PonerPins(); stackMapa.Children.Add(Map); Loading2(false); }
/* METHODS */ private async void SignUp() { // If the fields are empty if (string.IsNullOrEmpty(Email) || string.IsNullOrEmpty(Password) || string.IsNullOrEmpty(FirstName) || string.IsNullOrEmpty(LastName)) { await App.Current.MainPage.DisplayAlert("Empty Values", "Please make sure to fill in all the spaces", "OK"); } else { var user = await FirebaseHelper.AddUser(FirstName, LastName, Email, Password); if (user) { await App.Current.MainPage.DisplayAlert("SignUp Success", "", "Ok"); //Navigate to MainPage Application.Current.MainPage = new MainPage(); // Make this asynchronous Email = string.Empty; Password = string.Empty; FirstName = string.Empty; LastName = string.Empty; } else { await App.Current.MainPage.DisplayAlert("Error", "We ran into an error whiles signing up, please check your network", "OK"); } } }
private async void Login() { if (string.IsNullOrEmpty(Email) || string.IsNullOrEmpty(Password)) { await App.Current.MainPage.DisplayAlert("Hata", "Lütfen Email ve Parola Giriniz!", "OK"); } else { var user = await FirebaseHelper.GetUser(Email); if (user != null) { if (Email == user.Email && Password == user.Password) { UserSettings.UserName = Email; UserSettings.Password = Password; await App.Current.MainPage.Navigation.PushAsync(new MyTabbedPage(Email)); } else { await App.Current.MainPage.DisplayAlert("Giriş Başarısız", "Girdiğiniz Email ve Parola Doğru Değil!", "OK"); } } else { await App.Current.MainPage.DisplayAlert("Giriş Başarısız", "Kullanıcı Bulunamadı", "OK"); } } }
private async void OKButton_Clicked(object sender, EventArgs e) { await FirebaseHelper.UpdateQuantity(EditNumberEntry.Text, selectedItem.ItemName, EditDatePicker.Date.ToString("MM/dd")); EditNumberFrame.IsVisible = false; EditNumberEntry.IsVisible = false; EditDateFrame.IsVisible = false; OKButton.IsEnabled = false; OKButton.IsVisible = false; CancelButton.IsVisible = false; CancelButton.IsEnabled = false; AddButton.IsEnabled = true; AddButton.IsVisible = true; OKAimButton.IsVisible = false; CancelAimButton.IsVisible = false; AnimButton.IsVisible = true; AnimButton.IsEnabled = true; OKAimButton.IsVisible = false; CancelAimButton.IsVisible = false; AddButton.IsVisible = true; ToggleEditAnimState(true, true); AnimButton.PlayFrameSegment(45, 125); CartAnimButton.PlayFrameSegment(50, 160); // use frame 160 if item is added to shopping cart CartAnimComplete = true; EditAnimButton.PlayFrameSegment(14, 48); EditAnimComplete = true; AnimButton.PlayFrameSegment(0, 25); CurrentFrame = 25; selectedItem = null; await(BindingContext as PantryView).RefreshPantry(); }
private async void Button_Clicked_AdminLogin(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(entryLogin.Text) || String.IsNullOrWhiteSpace(entryPassword.Text)) { await DisplayAlert("Fail!", "You left empty fields", "OK"); await Navigation.PushAsync(new AdminPanelLogin()); } else { FirebaseHelper firebaseHelper = new FirebaseHelper(); var result = await firebaseHelper.FindAdminByLoginAndPassword(entryLogin.Text, entryPassword.Text); if (result != null) { await Navigation.PushAsync(new AdminPanel()); } else { await DisplayAlert("Fail!", "Wrong login or password", "OK"); await Navigation.PushAsync(new AdminPanelLogin()); } } }
public async void add([FromBody] AddBlacklistRequest request) { using (var dbContext = new PulseDbContext()) { var account = await dbContext.Accounts .Include(a => a.Devices) .Include(a => a.Blacklists) .Where(a => a.AccountId == request.AccountId) .FirstOrDefaultAsync(); if (account == null) { return; } foreach (var blacklist in request.Blacklists) { dbContext.Blacklists.Add(blacklist); account.Blacklists.Add(blacklist); await FirebaseHelper.SendMessage(account, "added_blacklist", new { id = blacklist.DeviceId, phone_number = blacklist.PhoneNumber, phrase = blacklist.Phrase }); } await dbContext.SaveChangesAsync(); } }
public async void remove(long device_id, [FromQuery] string account_id) { using (var dbContext = new PulseDbContext()) { var account = await dbContext.Accounts .Include(a => a.Blacklists) .Where(a => a.AccountId == account_id) .FirstOrDefaultAsync(); if (account == null) { return; } var blacklist = account.Blacklists.Where(c => c.DeviceId == device_id).FirstOrDefault(); if (blacklist == null) { return; } await FirebaseHelper.SendMessage(account, "removed_blacklist", new { id = device_id }); dbContext.Blacklists.Add(blacklist); account.Blacklists.Add(blacklist); await dbContext.SaveChangesAsync(); } }
void SubstractUserPoint(string userID, double point) { Debug.Log("Mengajukan transaksi point."); double result = FO.userPoint - point; if (result < 0) { Debug.Log("Transaksi gagal. Jumlah point anda tidak mencukupi."); ModalPanelManager.instance.Choice( "", "point Anda tidak mencukupi", false, "", "", null, null, false ); tukarButton.interactable = true; return; } Debug.Log("Melakukan update point kedalam database."); FirebaseHelper.AddUserPoint(FO.userId, -pointToExchange, () => { FO.userPoint = result; Debug.Log("Transaksi berhasil."); OnTransactionSucceedEvent(); }); }
public void OpenExchangeWindow(double pointPrice, string reward) { // Get or update point from db async FirebaseHelper.GetUserPoint(FO.userId, (userPoint) => { FO.userPoint = userPoint; pointToExchange = pointPrice; if (FO.userPoint < pointPrice) { ModalPanelManager.instance.Choice( "", "Point Anda tidak mencukupi untuk mendapatkan reward ini. Kumpulkan point dengan menemukan lokasi-lokasi tertentu di AR Map!. Pergi ke AR Map sekarang?", true, "Ya", "Tidak", () => { UnityEngine.SceneManagement.SceneManager.LoadScene("armap"); }, () => { ModalPanelManager.instance.ClosePanel(); }, false ); return; } gameObject.SetActive(true); tukarButton.interactable = true; messageDisplay.text = string.Format( "Anda dapat menukarkan {0} point milik Anda untuk mendapatkan reward {1}. \nTunjukan layar ini ke merchant untuk mendapatkan reward!", FO.userPoint, reward ); }); }
public async void add([FromBody] AddFolderRequest request) { using (var dbContext = new PulseDbContext()) { var account = await dbContext.Accounts .Include(a => a.Devices) .Include(a => a.Folders) .Where(a => a.AccountId == request.AccountId) .FirstOrDefaultAsync(); if (account == null) { return; } foreach (var folder in request.Folders) { dbContext.Folders.Add(folder); account.Folders.Add(folder); await FirebaseHelper.SendMessage(account, "added_folder", folder); } await dbContext.SaveChangesAsync(); } }
public async void update(long device_id, [FromQuery] string account_id, [FromBody] UpdateDraftRequest request) { using (var dbContext = new PulseDbContext()) { var(account, draft) = await GetDraft(dbContext, device_id, account_id); if (draft == null) { return; } draft.Data = request.Data; draft.MimeType = request.MimeType; await FirebaseHelper.SendMessage(account, "replaced_drafts", new { id = draft.DeviceId, conversation_id = draft.DeviceConversationId, data = draft.Data, mime_type = draft.MimeType }); await dbContext.SaveChangesAsync(); } }
public async void add([FromBody] AddDraftRequest request) { using (var dbContext = new PulseDbContext()) { var account = await dbContext.Accounts .Include(a => a.Drafts) .Where(a => a.AccountId == request.AccountId) .FirstOrDefaultAsync(); if (account == null) { return; } foreach (var draft in request.Drafts) { dbContext.Drafts.Add(draft); account.Drafts.Add(draft); await FirebaseHelper.SendMessage(account, "added_draft", new { id = draft.DeviceId, conversation_id = draft.DeviceConversationId, data = draft.Data, mime_type = draft.MimeType }); } await dbContext.SaveChangesAsync(); } }
public async void add([FromBody] AddContactRequest request) { using (var dbContext = new PulseDbContext()) { var account = await dbContext.Accounts .Include(a => a.Contacts) .Where(a => a.AccountId == request.AccountId) .FirstOrDefaultAsync(); if (account == null) { return; } foreach (var contact in request.Contacts) { dbContext.Contacts.Add(contact); account.Contacts.Add(contact); await FirebaseHelper.SendMessage(account, "added_contact", new { phone_number = contact.PhoneNumber, name = contact.Name, type = contact.ContactType, color = contact.Color, color_dark = contact.ColorDark, color_light = contact.ColorLight, color_accent = contact.ColorAccent }); } await dbContext.SaveChangesAsync(); } }
/// <summary> /// loads center book asynchronusly /// </summary> public void LoadCentreBook() { System.TimeSpan span = System.DateTime.Now - inTime; FirebaseHelper.LogInShelfSection(inTime.ToString(), span.TotalSeconds); //SceneManager.LoadScene("Books/Decodable/CatTale/Common/Scenes/Scene01"); StartCoroutine(LoadYourAsyncScene()); }
public async void update([FromQuery] string phone_number, [FromQuery] long device_id, [FromQuery] string account_id, [FromBody] UpdateContactRequest request) { using (var dbContext = new PulseDbContext()) { var(account, contact) = await GetContact(dbContext, device_id, account_id); if (contact == null) { return; } contact.PhoneNumber = request.PhoneNumber; contact.Name = request.Name; await FirebaseHelper.SendMessage(account, "updated_contact", new { device_id = device_id, phone_number = contact.PhoneNumber, name = contact.Name, type = contact.ContactType, color = contact.Color, color_dark = contact.ColorDark, color_light = contact.ColorLight, color_accent = contact.ColorAccent }); await dbContext.SaveChangesAsync(); } }
/// <summary> /// Application developers can override this method to provide behavior when the back button is pressed. /// </summary> /// <returns> /// To be added. /// </returns> protected override bool OnBackButtonPressed() { try { FirebaseHelper firebaseHelper = new FirebaseHelper(); //// Adds notes to the firebase NotesData notes = new NotesData() { Title = txtTitle.Text, Notes = txtNotes.Text, ColorNote = this.noteColor, LabelData = new List <string>() }; this.firebaseHelper.AddNote(notes); //// If it is successfull displays mesaage this.DisplayAlert("Success", "Notes added successfully", "ok"); base.OnBackButtonPressed(); } catch (Exception e) { Console.WriteLine(e.Message); } return(false); }
//slide handler void slideValueChangedHandler(SLIDE_NAME slideName) { Debug.Log("slideValueChangedHandler :: " + slideName.ToString()); if (slideName == SLIDE_NAME.SLIDE_NAME_SPEAKING_SPEED) { TemporarilyStatus.getInstance().speaking_speed = slideSpeakingSpeed.value; FirebaseHelper.getInstance().updateSettingSpeakingSpeed(TemporarilyStatus.getInstance().speaking_speed); } else if (slideName == SLIDE_NAME.SLIDE_NAME_TOTAL_PER_DAY) { TemporarilyStatus.getInstance().total_card_a_day = Mathf.RoundToInt(slideTotalPerDay.value); totalPerDayValue.text = TemporarilyStatus.getInstance().total_card_a_day.ToString(); FirebaseHelper.getInstance().updateSettingTotalPerDay(TemporarilyStatus.getInstance().total_card_a_day); } else if (slideName == SLIDE_NAME.SLIDE_NAME_WAITING_TIME) { TemporarilyStatus.getInstance().time_to_show_answer = Mathf.RoundToInt(slideWaitingTime.value); waitingTimevalue.text = TemporarilyStatus.getInstance().time_to_show_answer.ToString(); FirebaseHelper.getInstance().updateSettingTimeShowAnswer(TemporarilyStatus.getInstance().time_to_show_answer); } else if (slideName == SLIDE_NAME.SLIDE_NAME_WORD_PER_DAY) { TemporarilyStatus.getInstance().new_card_a_day = Mathf.RoundToInt(slideWordPerDay.value); wordPerDayValue.text = TemporarilyStatus.getInstance().new_card_a_day.ToString(); FirebaseHelper.getInstance().updateSettingWordPerDay(TemporarilyStatus.getInstance().new_card_a_day); } }
public async void cleanup([FromQuery] string account_id, [FromQuery] long timestamp) { using (var dbContext = new PulseDbContext()) { var account = await dbContext.Accounts .Include(a => a.Messages) .Where(a => a.AccountId == account_id) .FirstOrDefaultAsync(); if (account == null) { return; } var messages = account.Messages.Where(m => m.Timestamp < timestamp).ToList(); foreach (var message in messages) { dbContext.Messages.Remove(message); account.Messages.Remove(message); } await FirebaseHelper.SendMessage(account, "cleanup_messages", new { timestamp }); await dbContext.SaveChangesAsync(); } }
private static void SaveSessionOnFireBase(string schoolCode, DateTime sessionStartTime, DateTime sessionEndTime) { try { string machineName = MacAddressHelper.GetMacAddress();// Environment.MachineName; SessionInfoFB info = new SessionInfoFB(); //info.machineName = Environment.MachineName; info.sessionstarttime = sessionStartTime; info.sessionendtime = sessionEndTime; string jsonString = JsonHelper.ParseObjectToJSON <SessionInfoFB>(info); string url = string.Format("clientanalytic-data/{0}/{1}/sessions/", schoolCode, machineName); //string url = string.Format("clientanalytic-data/{0}/session", schoolCode); FirebaseHelper.PostData(jsonString, url); } catch (Exception e) { if (e.Message.Contains("A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond")) { throw e; } else { Console.Out.WriteLine("-----------------"); Console.Out.WriteLine(e.Message); } } }
public async void update(long device_id, [FromQuery] string account_id, [FromBody] UpdateMessageRequest request) { using (var dbContext = new PulseDbContext()) { var(account, message) = await GetMessage(dbContext, device_id, account_id); if (message == null) { return; } message.MessageType = request.Type; message.Read = request.Read; message.Seen = request.Seen; message.Timestamp = request.Timestamp; await FirebaseHelper.SendMessage(account, "updated_message", new { id = message.DeviceId, type = message.MessageType, message.Read, message.Seen, timestamp = message.Timestamp }); await dbContext.SaveChangesAsync(); } }
private async void SignUp() { SignUpPage signUpPage = new SignUpPage(); if (string.IsNullOrEmpty(Email) || string.IsNullOrEmpty(Password)) { await App.Current.MainPage.DisplayAlert("Hata", "Lütfen Email ve Parola Giriniz!", "OK"); } var emailPattern = "^([\\w\\.\\-]+)@([\\w\\-]+)((\\.(\\w){2,3})+)$"; if (!String.IsNullOrWhiteSpace(email) && !(Regex.IsMatch(Email, emailPattern))) { await App.Current.MainPage.DisplayAlert("Hata", "Geçersiz Email", "OK"); } else { var user = await FirebaseHelper.AddUser(Email, Password); if (user) { await App.Current.MainPage.DisplayAlert("Başarılı", "Kayıt Başarılı", "Ok"); await App.Current.MainPage.Navigation.PushAsync(new LoginPage()); } else { await App.Current.MainPage.DisplayAlert("Hata", "Kayıt Başarısız!", "OK"); } } }
private async void Button_Clicked_Login(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(entryLogin.Text) || String.IsNullOrWhiteSpace(entryPassword.Text)) { await DisplayAlert("Fail!", "You left empty fields", "OK"); CurrentUserID = 0; //just for case... await Navigation.PushAsync(new Login()); } else { FirebaseHelper firebaseHelper = new FirebaseHelper(); var result = await firebaseHelper.FindUserByLoginAndPassword(entryLogin.Text, entryPassword.Text); if (result != null) { CurrentUserID = result.ID; var reault = await firebasehelper.GetUser(CurrentUserID); login = reault.Username; await Navigation.PushAsync(new GameMenu()); } else { await DisplayAlert("Fail!", "Wrong login or password", "OK"); CurrentUserID = 0; //just for case... await Navigation.PushAsync(new Login()); } } }
public async void add([FromBody] AddScheduledMessageRequest request) { using (var dbContext = new PulseDbContext()) { var account = await dbContext.Accounts .Include(a => a.ScheduledMessages) .Where(a => a.AccountId == request.AccountId) .FirstOrDefaultAsync(); if (account == null) { return; } foreach (var message in request.ScheduledMessages) { dbContext.ScheduledMessages.Add(message); account.ScheduledMessages.Add(message); await FirebaseHelper.SendMessage(account, "added_scheduled_message", new { id = message.DeviceId, to = message.To, data = message.Data, mimeType = message.MimeType, timestamp = message.Timestamp, title = message.Title, repeat = message.Repeat }); } await dbContext.SaveChangesAsync(); } }
IEnumerator DownloadImage(string url) { Debug.Log("Downloading User Avatar"); Debug.Log(url); using (UnityWebRequest www = UnityWebRequest.Get(url)) { www.Send(); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { while (!www.downloadHandler.isDone) { Debug.Log(www.downloadProgress.ToString()); yield return(null); } string datePatt = @"yyyyMMddHHmmssfff"; string file_name = DateTime.UtcNow.ToString(datePatt, CultureInfo.InvariantCulture) + ".jpg"; string savePath = $"{FirebaseHelper.LocalCacheImagePath}{file_name}"; Directory.CreateDirectory(Directory.GetParent(savePath).ToString()); System.IO.File.WriteAllBytes(savePath, www.downloadHandler.data); fb_avatar_name = file_name; while (!File.Exists(savePath)) { Debug.Log("Saving Avatar to local"); } FirebaseHelper.UploadFile(savePath, file_name, "images"); Debug.Log("Download complete!"); } } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddResponseCompression(); services.AddControllers(); FirebaseHelper.Init(Environment.GetEnvironmentVariable("FIREBASE_SERVER_KEY")); }
private async void SwipeItem_Invoked(object sender, EventArgs e) { item toDelete = ((SwipeItem)sender).BindingContext as item; await FirebaseHelper.DeleteItem(toDelete); await(BindingContext as ItemView).RefreshItems(); }
private async void UpdateChatFromFirebase() { try { chatlistdetail = await FirebaseHelper.GetChatForUserID(CurrentUserId, recieverUserId : RecieverUserID); //var _sortedlist = chatlistdetail.OrderBy(x => x.TimeStamp).ToList(); //chatlistdetail = _sortedlist; if (chatlistdetail.Count > ChatDetailList.Count) { updatechatlistdetail = chatlistdetail.Skip(ChatDetailList.Count).ToList(); try { foreach (var item in updatechatlistdetail) { ChatDetailList.Add(item); } } catch (Exception ex) { } MessagingCenter.Send("", "ScrollToEnd"); } } catch (Exception ex) { } }
private static RegInfoFB GetRegInfoFromFirebase(string schoolCode, string sessionYear) { string url = string.Format("registrations-data/{0}-{1}", schoolCode, sessionYear); string jsonString = FirebaseHelper.GetData(url); return(JsonHelper.ParseJsonToObject <RegInfoFB>(jsonString) as RegInfoFB); }