public IFirebaseConfig conec() { IFirebaseConfig config = new FireSharp.Config.FirebaseConfig { AuthSecret = "4OUpc4rGJTetaxG8IBiE3uoXdSVNuBeRdJoo8Uju", BasePath = "https://fir-app-cf755.firebaseio.com/" }; return(config); }
public BarusFirebaseDatabase() { roomDatas = new Dictionary <int, string>(); timer = new Timer(2000); timer.Elapsed += Timer_Elapsed; var config = new FireSharp.Config.FirebaseConfig { AuthSecret = "9dZg3lsWe9BYGfbAcOXt5Y2Ll7fkVHVZhmj5TGPc", BasePath = "https://matnodes-demo.firebaseio.com" }; client = new FirebaseClient(config); ListenStream(); RefleshDatas(); timer.Start(); }
/** * Checks authentication through firebase-auth from stepup then configures client using firesharp */ public async Task <bool> login(String email, String password) { try { var authProvider = new FirebaseAuthProvider(new FirebaseConfig(Authentication.fbAuth)); var auth = await authProvider.SignInWithEmailAndPasswordAsync(email, password); IFirebaseConfig config = new FireSharp.Config.FirebaseConfig { AuthSecret = auth.FirebaseToken, BasePath = Authentication.basePath }; firebase = new FirebaseClient(config); } catch { return(false); } return(true); }
private void ActivityTimer_Tick(object sender, EventArgs e) { activityTimer.Stop(); try { lastCheckedTimeLabel.Text = "Last Ran Tick: " + DateTime.Now; if (lastChecked.Date != DateTime.Today) { lastCheckedDatabaseLabel.Text = "Last Checked Database: " + DateTime.Now; lastChecked = DateTime.Today; FireSharp.Config.FirebaseConfig c = new FireSharp.Config.FirebaseConfig(); c.AuthSecret = "NI7XHYpZL97crh1Hfh7biXC3C4FQvJIRzi8ZetcX"; c.BasePath = "https://spoileralert-394.firebaseio.com"; FireSharp.FirebaseClient f = new FireSharp.FirebaseClient(c); FireSharp.Response.FirebaseResponse r = f.Get("/"); dynamic database = JsonConvert.DeserializeObject(r.Body); foreach (var user in database) { List <String> expiredItems = new List <string>(); var id = user.Name; var u = user.First; var settings = u["settings"]; int threshold = settings["threshold"]; String emailAddress = settings["email"]; bool wantNotifications = settings["notifications"]; var l = u["fridge"]; if (l == null) { continue; } foreach (var item in l) { var name = item.Name; var arr = item.Value; int quantity = (int)arr.First.Value; int daysTil = (int)arr.Last.Value; int updateData = daysTil - 1; int[] newVal = new int[2] { quantity, updateData }; if (updateData <= threshold) { expiredItems.Add(name); } // ---- Update the database ----- // String path = String.Format("/{0}/fridge/{1}", id, name); f.Set(path, newVal); } // ---- Email User with any expired items if (wantNotifications && (expiredItems.Count > 0)) { String body = "Hello there!\nThe following items from your fridge expire in "; body = body + threshold; body = body + " days: \n"; foreach (var s in expiredItems) { body = body + s; body = body + "\n"; } body = body + "\nStay Fresh!\nSpoilerAlert"; String subject = "A Message From Your Fridge"; MailMessage mail = new MailMessage("SpoilerAlert <*****@*****.**>", emailAddress); SmtpClient client = new SmtpClient("smtp.gmail.com"); client.Port = 587; client.EnableSsl = true; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Credentials = new System.Net.NetworkCredential("youremail", "yourpassword"); mail.Subject = subject; mail.Body = body; client.Send(mail); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { activityTimer.Start(); } }