Ejemplo n.º 1
0
        // should only be triggered from an CameraCategorySelectionView:OnCategoryLoad call!!!
        public async void OnEventsLoadRequest(object sender, EventArgs args)
        {
            string jsonQuery = "";
            string result    = await GlobalSingletonHelpers.requestFromServerAsync(HttpMethod.Get, "event", jsonQuery);

            if (!result.Equals("fail"))
            {
                IList <EventJSON> evts = JsonConvert.DeserializeObject <IList <EventJSON> >(result);
                if (evts != null)
                {
                    lock (openCategorys) {
                        foreach (EventJSON evt in evts)
                        {
                            AddEvent(evt);
                        }
                    }
                }
            }
            else
            {
                Debug.WriteLine("DHB:CameraCategorySelectionView:OnEventsLoadRequest event apicall failed!");
                // build a test panel...
                //CameraEventTitleElement cete = new CameraEventTitleElement { eventName = "Dummy Example", accessKey = "mace rule", eventId = 111, };
                //openCategorys.Add(cete);
            }
        }
Ejemplo n.º 2
0
        public async void OnCreateEvent(object Sender, EventArgs args)
        {
            await createEvent.FadeTo(0, 175);

            await createEvent.FadeTo(1, 175);

            CreateEventJSON create = new CreateEventJSON {
                categories     = buildCategoryNames(),
                eventName      = newEventName.Text,
                gamesExcluded  = buildGamesExcluded(),
                numPlayers     = this.numPlayers,
                startTime      = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm"),
                uploadDuration = (int)this.uploadDuration,
                votingDuration = (int)this.votingDuration,
            };
            string jsonQuery = JsonConvert.SerializeObject(create);
            string result    = await GlobalSingletonHelpers.requestFromServerAsync(HttpMethod.Post, "newevent", jsonQuery);

            if (result.Equals("fail"))
            {
                createEvent.Text = "Tap to retry create";
            }
            else
            {
                CreateEventResponseJSON cerj = JsonConvert.DeserializeObject <CreateEventResponseJSON>(result);
                //MasterPage mp = ((MasterPage)Application.Current.MainPage);
                //mp.thePages.judgingPage.fireLoadChallenge();
                //cameraPage.latestPassphrase = cerj.accessKey;
                cameraPage.AddEvent(cerj);
                cameraPage.switchToSelectView();
            }
        }
Ejemplo n.º 3
0
        // why doesn't badges code handle this?
        public virtual async void TokenReceived(object sender, EventArgs e)
        {
            //coreProfile.usernameLabel.Text = GlobalStatusSingleton.username;
            string jsonQuery = "";
            string result    = "fail";

            while (result.Equals("fail"))
            {
                result = await GlobalSingletonHelpers.requestFromServerAsync(HttpMethod.Get, BADGES, jsonQuery);

                if (result.Equals("fail"))
                {
                    await Task.Delay(10000);
                }
            }
            if (!result.Equals("fail"))
            {
                BadgesResponseJSON badges = JsonConvert.DeserializeObject <BadgesResponseJSON>(result);
                if (badges != null)
                {
                    coreProfile.SetBadgesData(badges);
                    badgesPage.SetBadgesData(badges);
                }
            }
            else
            {
                Debug.WriteLine("DHB:CameraCategorySelectionView:OnEventsLoadRequest event apicall failed!");
            }
        }
Ejemplo n.º 4
0
        protected static async Task <string> requestApiCallAsync()
        {
            Debug.WriteLine("DHB:EventsHistory_Profile:requestApiCallAsync start");
            string result = "fail";

            //result = await GlobalSingletonHelpers.requestFromServerAsync(HttpMethod.Get, "events/prev/10000", "");
            result = await GlobalSingletonHelpers.requestFromServerAsync(HttpMethod.Get, "events/next/0", "");

            //result = await GlobalSingletonHelpers.requestFromServerAsync(HttpMethod.Get, "events/next", "");
            //result = await GlobalSingletonHelpers.requestFromServerAsync(HttpMethod.Get, "events/next/0/100", "");
            return(result);
        }
Ejemplo n.º 5
0
        private static async void saveDataOnExitAsync(ZoomPage saveData)
        {
            await Task.Delay(500);

            Debug.WriteLine("DHB:ZoomPage:saveDataOnExitAsync this should print second");
            PhotoUpdateJSON pJSON = new PhotoUpdateJSON();

            pJSON.flag = saveData.flaggedImg.IsVisible;
            pJSON.like = saveData.likedImg.IsVisible;
            //pJSON.tags = saveData.tagEntry.Text;   @todo parse and set tags.
            string jsonQuery = JsonConvert.SerializeObject(pJSON);

            if (jsonQuery != null)
            {
                string apiCall = "update/photo/" + saveData.pid;
                string result  = await GlobalSingletonHelpers.requestFromServerAsync(HttpMethod.Put, apiCall, jsonQuery);
            }
        }
Ejemplo n.º 6
0
        private async Task <string> photoUpdate(long pid)
        {
            string          result = "";
            PhotoUpdateJSON pJSON  = new PhotoUpdateJSON();

            //pJSON.flag = saveData.flaggedImg.IsVisible;
            //pJSON.like = saveData.likedImg.IsVisible;
            //pJSON.tags = saveData.tagEntry.Text;   @todo parse and set tags.
            string[] splitters     = { " ", "," };
            string[] tagsAsStrings = tagsEntry.Text.Split(splitters, StringSplitOptions.RemoveEmptyEntries);
            pJSON.tags = new List <string>(tagsAsStrings);
            string jsonQuery = JsonConvert.SerializeObject(pJSON);

            if (jsonQuery != null)
            {
                string apiCall = "update/photo/" + pid;
                result = await GlobalSingletonHelpers.requestFromServerAsync(HttpMethod.Put, apiCall, jsonQuery);
            }
            return(result);
        }
Ejemplo n.º 7
0
        public async void OnJoinClicked(object sender, EventArgs args)
        {
            await joinPassphrase.FadeTo(0, 175);

            await joinImageEnd.FadeTo(0, 175);

            await joinPassphrase.FadeTo(1, 175);

            await joinImageEnd.FadeTo(1, 175);

            if ((joinPassphrase.Text != null) && (!joinPassphrase.Text.Equals("")))
            {
                string query  = "joinevent?accesskey=" + joinPassphrase.Text;
                string result = await GlobalSingletonHelpers.requestFromServerAsync(HttpMethod.Post, query, "");

                if (result.Equals("fail"))
                {
                }
                else
                {
                    /*
                     * IList<CategoryJSON> newCategories = JsonHelper.DeserializeToList<CategoryJSON>(result);
                     * foreach (CategoryJSON newCat in newCategories) {
                     *  CameraClosedCategoryElement coce = new CameraClosedCategoryElement(newCat);
                     *
                     *  // This does an object memory check rather than an equivalence check.
                     *  // should be a way to make this work, but brute force it for now.
                     *  //if (!openCategorys.Contains<CameraOpenCategoryElement>(coce)) {
                     *  if (!hasCategory(coce)) {
                     *      openCategorys.Add(coce);
                     *  }
                     * }
                     */
                    EventJSON newEvent = JsonConvert.DeserializeObject <EventJSON>(result);
                    //AddEvent(newEvent);
                    cameraPage.AddEvent(newEvent);  // calls this.addevent, but also the profile page's.
                }
            }
        }