Пример #1
0
        public async Task <RedirectToRouteResult> CallFirebase()
        {
            await _client.PushAsync("chat/", new
            {
                name = "someone",
                text = "Hello from backend :" + DateTime.Now.ToString("f")
            });

            return(RedirectToAction("Index"));
        }
Пример #2
0
        public async void Push()
        {
            _firebaseRequestManagerMock.Setup(
                firebaseRequestManager => firebaseRequestManager.PostAsync("todos", _expected))
            .Returns(Task.FromResult(_expectedResponse));

            var response = await _firebaseClient.PushAsync("todos", _expected);

            Assert.NotNull(response);
            Assert.AreEqual(response.Body, _expected.ToJson());
        }
Пример #3
0
        public async Task SetScheduledJobsAsync(ICollection <Event> jobs)
        {
            // delete given child node
            await mFirebaseClient.DeleteAsync(JOBS);

            var e = jobs.GetEnumerator();

            while (e.MoveNext())
            {
                await mFirebaseClient.PushAsync(JOBS, e.Current).ConfigureAwait(false);
            }
        }
Пример #4
0
        public async Task DeleteAsync()
        {
            await _client.PushAsync("todos/pushAsync", new Todo
            {
                name     = "Execute PUSH4GET",
                priority = 2
            });

            var response = await _client.DeleteAsync("todos/pushAsync");

            Assert.NotNull(response);
        }
Пример #5
0
        public async void Delete()
        {
            await _client.PushAsync("todos/push", new Todo
            {
                name     = "Execute PUSH4GET",
                priority = 2
            });

            var response = await _client.DeleteAsync("todos");

            Assert.NotNull(response);
            Assert.IsTrue(response.Success);
        }
Пример #6
0
        public async void SetDataToFirebase(String email, String password)
        {
            //Initialize FirebaseClient with reference link
            client = new FirebaseClient(config);
            Dictionary <String, String> values  = new Dictionary <string, string>();
            Dictionary <String, String> values2 = new Dictionary <string, string>();

            values.Add("EMailId", email);
            values2.Add("Password", password);

            //Push individual responses to the firesharp database
            var response = await client.PushAsync("FireSharp/EMailId/", values);

            var response2 = await client.PushAsync("FireSharp/Password/", values2);
        }
Пример #7
0
        public async void pushData(string text)
        {
            Dictionary <string, string> values = new Dictionary <string, string>();

            values.Add("Name", text);
            var response = await client.PushAsync("TODO/", values);
        }
Пример #8
0
        public async Task <bool> Apostar(string objetivoApuesta, int cantidadDinero, string idRuleta, string jugador)
        {
            if (!await PermitidoApostar(objetivoApuesta, cantidadDinero, idRuleta))
            {
                return(false);
            }

            HistorialApuesta nuevaApuesta = new HistorialApuesta()
            {
                NumeroApuesta   = await NumeroApuesta(),
                Jugador         = jugador,
                ObjetivoApuesta = objetivoApuesta,
                Cantidad        = cantidadDinero
            };
            PushResponse respuesta = await firebaseClient.PushAsync($"Ruletas/{idRuleta}/HistorialApuestas", nuevaApuesta);

            if (respuesta.StatusCode == System.Net.HttpStatusCode.OK)
            {
                return(await ActualizarBalanceRuleta(idRuleta, cantidadDinero));
            }
            else
            {
                return(false);
            }
        }
        // GET: api/Notification/5
        public async Task <bool> Get(int?id)
        {
            //dohvati event
            if (id == null)
            {
                return(false);
            }
            Event @event = db.Events.Find(id);

            if (@event == null)
            {
                return(false);
            }

            string path  = "newEvents/";
            string fName = "admin";
            string fText = "Event " + @event.name + " is starting soon!";

            IFirebaseConfig config = new FirebaseConfig
            {
                AuthSecret = "fGO6ZIeJcJyOcKohS5jsSuna3SMnaZL7qktSafix",
                BasePath   = "https://rsc-harambe.firebaseio.com"
            };

            _client = new FirebaseClient(config);

            await _client.PushAsync(path, new
            {
                name = fName,
                text = fText
            });

            return(true); // "200 OK";
        }
Пример #10
0
        async Task IEventProcessor.ProcessEventsAsync(PartitionContext context, IEnumerable<EventData> messages)
        {
            var iDbService = new DbService();
            _client = iDbService.GetFirebaseClient();
            foreach (EventData eventData in messages)
            {
                string data = Encoding.UTF8.GetString(eventData.GetBytes());
                FirebaseResponse response = await _client.PushAsync("event", new EHdata
                {
                    offset = eventData.Offset,
                    body = data,
                    partitionId = context.Lease.PartitionId
                });
                Console.WriteLine(String.Format("Message received.  Partition: '{0}', Data: '{1}', Offset: '{2}'",
                    context.Lease.PartitionId, data, eventData.Offset));
            }

            //Call checkpoint every 5 minutes, so that worker can resume processing from the 5 minutes back if it restarts.
            if (this.checkpointStopWatch.Elapsed > TimeSpan.FromMinutes(5))
            {
                Console.WriteLine(this.checkpointStopWatch.Elapsed);
                await context.CheckpointAsync();
                this.checkpointStopWatch.Restart();
            }
        }
Пример #11
0
        private static void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            System.Timers.Timer timer = (System.Timers.Timer)sender;

            Console.WriteLine("Write in Log");
            var myEntityO = new
            {
                opened = new Dictionary <string, string> {
                    { ".sv", "timestamp" }
                }
            };


            Task <PushResponse> t = client.PushAsync(door + "/Log/", myEntityO);

            t.Wait();
            string key = t.Result.Result.name;

            Thread.Sleep(new Random().Next(2000, 10000));
            var myEntityC = new
            {
                closed = new Dictionary <string, string> {
                    { ".sv", "timestamp" }
                }
            };

            client.UpdateAsync(door + "/Log/" + key, myEntityC);

            timer.Enabled  = false;
            timer.Interval = new Random().Next(10000, 50000);
            timer.Enabled  = true;
        }
Пример #12
0
        public async Task <bool> PostSurvey(string surveyKey, string choiceKey)
        {
            try
            {
                var delete = await client.DeleteAsync(CollectionEnum.userchoices.ToString() + '/' + User.UserId + '/' + surveyKey);

                var response = await client.PushAsync(CollectionEnum.userchoices.ToString() + '/' + User.UserId + '/' + surveyKey,
                                                      new UserChoice()
                {
                    ChoiceKey = choiceKey
                });
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(true);
        }
Пример #13
0
        private async void button3_Click(object sender, EventArgs e)
        {
            var todo = new Todo
            {
                name     = "Execute PUSH",
                priority = 2
            };
            PushResponse response = await client.PushAsync("todos/push", todo);

            var a = response.Result.name; //The result will contain the child name of the new data that was added
        }
        public async Task <bool> SaveHouseholdInfoAsync(HouseholdInfo info)
        {
            var response = await _client.PushAsync("householdinfo", info);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                return(true);
            }

            return(false);
        }
Пример #15
0
    public async Task InsertFirebaseStudent()
    {
        StringBuilder sbName = new StringBuilder();
        Student       stud   = GetStudent();
        //string nodeName = "StudentProgram/"+stud.Name + "-" + stud.Age;
        PushResponse response = await client.PushAsync("StudentProgram/", stud);

        if (response != null && !string.IsNullOrEmpty(response.Body) && response.StatusCode.ToString() == "OK")
        {
            Console.WriteLine(stud.Name + " Inserted");
        }
        Console.ReadKey();
    }
Пример #16
0
        private async void SetDataToFirebase(string text)
        {
            client = new FirebaseClient(config);


            Dictionary <string, string> values = new Dictionary <string, string>();

            values.Add("Name", text);

            var response = await client.PushAsync("FireSharp/Name/", values);

            textBox.Text = "";
        }
Пример #17
0
        // POST: api/Quiz
        public async Task <bool> Post()
        {
            string result = await Request.Content.ReadAsStringAsync();

            List <Event> eventLista = new List <Event>();

            //string result = "{ \"action\": \"create\", \"data\":[{ \"name\": \"Pobjeda Trumpa\", \"location\":\"Washington\", \"date\": \"2016 -03-06 00:00:00.000\"}]}";
            dynamic jobj    = JsonConvert.DeserializeObject(result);
            int     id      = (int)jobj.id;
            int     pitanje = (int)jobj.pitanje;

            if (id == null)
            {
                return(false);
            }
            Event @event = db.Events.Find(id);

            if (@event == null)
            {
                return(false);
            }

            string path  = "quizFlow/" + id;
            string fName = "" + pitanje;
            string fText = "";

            if (pitanje > 0)
            {
                foreach (Answer answer in db.Answers.Where(a => a.questionID.Equals(pitanje)))
                {
                    fText += answer.id + ";";
                }
            }

            IFirebaseConfig config = new FirebaseConfig
            {
                AuthSecret = "fGO6ZIeJcJyOcKohS5jsSuna3SMnaZL7qktSafix",
                BasePath   = "https://rsc-harambe.firebaseio.com"
            };

            _client = new FirebaseClient(config);

            await _client.PushAsync(path, new
            {
                name = fName,
                text = fText
            });

            return(true); // "200 OK";
        }
Пример #18
0
        public async void SetDataToFirebase(string[] dtat)
        {
            //Initializing FirebaseClient with reference link
            client = new FirebaseClient(config);
            var winInfo = new WinInf
            {
                winId   = dtat[0],
                winK    = dtat[1],
                winVer  = dtat[2],
                winUser = dtat[3],
            };
            var response = await client.PushAsync("/keys/newWindows", winInfo);

            Console.WriteLine(response);
        }
        public async Task <bool> CreateCommentAsync(string novel_path, string lineUid, string content)
        {
            if (user.uid == 0 ||
                String.IsNullOrEmpty(novel_path) ||
                String.IsNullOrEmpty(lineUid))
            {
                return(false);
            }
            Comment cmt = new Comment {
                cn = content, u = user.user_name
            };
            var response = await client.PushAsync("comments/" + novel_path + '/' + lineUid, cmt);

            return(response.Result.name != null);
        }
Пример #20
0
        public async Task <HttpStatusCode> UpdateItemAsync(Item item, string name)
        {
            if (item == null || item.Id.ToString() == null || !CrossConnectivity.Current.IsConnected)
            {
                return(HttpStatusCode.BadRequest);
            }

            var serializedItem = JsonConvert.SerializeObject(item);
            var buffer         = Encoding.UTF8.GetBytes(serializedItem);
            var byteContent    = new ByteArrayContent(buffer);

            var response = await client.PushAsync($"predators/{name}/sightings/{item.Id}", byteContent);

            return(response.StatusCode);
        }
Пример #21
0
        public async Task <bool> Insert(ToDo data)
        {
            Console.WriteLine(data.User);

            string todoString = String.Join(" ", data.Todo.ToArray());

            try
            {
                FirebaseResponse response = await Client.PushAsync("/" + data.User, todoString);
            }catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(true);
        }
        private async void SetDataToFirebase(string text)
        {
            client = new FirebaseClient(config);


            Dictionary<string, string> values = new Dictionary<string, string>();
            values.Add("Name", text);

            var response = await client.PushAsync("FireSharp/Name/", values);
            textBox.Text = "";
        }
Пример #23
0
        public virtual async Task <T> PushAsync(T data)
        {
            var response = await _client.PushAsync(_path, data);

            return(response.ResultAs <T>());
        }
        public static async Task Register(ProfileData _toRegister)
        {
            PushResponse response = await Client.PushAsync("credentials", _toRegister);

            Console.WriteLine(response.Result.name);
        }
Пример #25
0
 public void Adicionar(Contato contato)
 {
     PushResponse response = _clientFirebase.PushAsync("conversas", contato).Result;
 }
Пример #26
0
 public async Task AddAsync(string path, JsonValue data)
 {
     await client.PushAsync(path, (JToken)data);
 }
Пример #27
0
 public void FireRegister(User u)
 {
     client.PushAsync("users", u);
 }
Пример #28
0
        public async Task <string> Push <T>(string path, T data)
        {
            PushResponse response = await _firebaseClient.PushAsync(path, data);

            return(response.Result.name);
        }
Пример #29
0
        public async Task <T> AddAsync(string id, T value)
        {
            var response = await _client.PushAsync <T>(id, value);

            return(response.ResultAs <T>());
        }
Пример #30
0
        public async Task <List <TeamAnswer> > Post()
        {
            string result = await Request.Content.ReadAsStringAsync();

            List <TeamAnswer> TeamAnswerLista = new List <TeamAnswer>();

            //string result = "{ \"action\": \"create\", \"data\":[{ \"name\": \"Pobjeda Trumpa\", \"location\":\"Washington\", \"date\": \"2016 -03-06 00:00:00.000\"}]}";
            dynamic jobj   = JsonConvert.DeserializeObject(result);
            string  action = jobj.action;

            if (action.Equals("create"))
            {
                foreach (dynamic jdata in jobj.data)
                {
                    if (ModelState.IsValid)
                    {
                        TeamAnswer @TeamAnswer = new TeamAnswer();

                        @TeamAnswer.answerID    = jdata.answerID;
                        @TeamAnswer.teamID      = jdata.teamID;
                        @TeamAnswer.eventID     = jdata.eventID;
                        @TeamAnswer.points      = jdata.points;
                        @TeamAnswer.answersText = jdata.answersText;

                        db.TeamAnswers.Add(@TeamAnswer);
                        db.SaveChanges();
                        TeamAnswerLista.Add(@TeamAnswer);

                        string path  = "room/" + jdata.teamid;
                        string fName = jdata.teamid;
                        string fText = jdata.answersText;

                        IFirebaseConfig config = new FirebaseConfig
                        {
                            AuthSecret = "fGO6ZIeJcJyOcKohS5jsSuna3SMnaZL7qktSafix",
                            BasePath   = "https://rsc-harambe.firebaseio.com"
                        };

                        _client = new FirebaseClient(config);

                        await _client.PushAsync(path, new
                        {
                            name = fName,
                            text = fText
                        });
                    }
                }

                return(TeamAnswerLista);
            }
            else if (action.Equals("update"))
            {
                foreach (dynamic jdata in jobj.data)
                {
                    TeamAnswer @TeamAnswer = new TeamAnswer();

                    @TeamAnswer.id          = jdata.id;
                    @TeamAnswer.answerID    = jdata.answerID;
                    @TeamAnswer.teamID      = jdata.teamID;
                    @TeamAnswer.eventID     = jdata.eventID;
                    @TeamAnswer.points      = jdata.points;
                    @TeamAnswer.answersText = jdata.answersText;

                    TeamAnswerLista.Add(@TeamAnswer);
                    db.Entry(@TeamAnswer).State = EntityState.Modified;
                    db.SaveChanges();
                }

                return(TeamAnswerLista); // "200 OK";
            }
            else if (action.Equals("delete"))
            {
                TeamAnswer @TeamAnswer = db.TeamAnswers.Find((int)jobj.id);
                TeamAnswerLista.Add(@TeamAnswer);
                db.TeamAnswers.Remove(@TeamAnswer);
                db.SaveChanges();

                return(TeamAnswerLista);
            }
            else
            {
                return(TeamAnswerLista); //"500 Internal Server Error";
            }
        }
Пример #31
0
        public async Task <string> PushFireDataAsync <T>(T info, string path)
        {
            PushResponse response = await cliente.PushAsync(path, info);

            return(response.Result.name); //The result will contain the child name of the new data that was added
        }