Exemplo n.º 1
0
 public static void SetCurrentEvent(Event evnt)
 {
     CurrentEvent = evnt;
 }
Exemplo n.º 2
0
        public void GetEventInfo(string eventCode)
        {
            string json = ParamsToJSON ("event_code", eventCode ?? string.Empty);
            SayHiRestClient syrc = new SayHiRestClient (SayHiRestClient.HTTPPOSTMETHOD, CreateEndpointURL (GetEventInfoPath),
                                                       json);
            syrc.OnRestCallCompleted += (RestResult obj) =>
            {
                Event ret = null;

                if (!obj.IsSuccess)
                {
                    ret = new Event (obj.IsSuccess, obj.Result);
                }
                else
                {
                    try
                    {
                        ret = new Event (true);

                        using (JsonTextReader jtr = new JsonTextReader(new StringReader(obj.Result)))
                        {

                            while (jtr.Read())
                            {
                                if (JsonKeyMatches (jtr, JsonToken.PropertyName, "address"))
                                {
                                    ret.Address = jtr.ReadAsString ();
                                }
                                else
                                if (JsonKeyMatches (jtr, JsonToken.PropertyName, "date"))
                                {
                                    ret.Date = jtr.ReadAsString ();
                                }
                                else
                                if (JsonKeyMatches (jtr, JsonToken.PropertyName, "end_time"))
                                {
                                    ret.EndTime = jtr.ReadAsString ();
                                }
                                else
                                if (JsonKeyMatches (jtr, JsonToken.PropertyName, "event_code"))
                                {
                                    ret.Code = jtr.ReadAsString ();
                                }
                                else
                                if (JsonKeyMatches (jtr, JsonToken.PropertyName, "name"))
                                {
                                    ret.Name = jtr.ReadAsString ();
                                }
                                else
                                if (JsonKeyMatches (jtr, JsonToken.PropertyName, "start_time"))
                                {
                                    ret.StartTime = jtr.ReadAsString ();
                                }
                                else
                                if (JsonKeyMatches (jtr, JsonToken.PropertyName, "summary"))
                                {
                                    ret.Summary = jtr.ReadAsString ();
                                }
                                else
                                if (JsonKeyMatches (jtr, JsonToken.PropertyName, "venue"))
                                {
                                    ret.Venue = jtr.ReadAsString ();
                                }
                                else
                                if (JsonKeyMatches (jtr, JsonToken.PropertyName, "organizer"))
                                {
                                    ret.Organizer = jtr.ReadAsString ();
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        ret = new Event (false, GenerateParseErrorMessage (e));
                    }
                }

                SafeRaiseEvent (OnGetEventInfoCompleted, ret);

            };
            syrc.SendRestRequest ();
        }