示例#1
0
        /// <summary>
        /// Execution Logic
        /// </summary>
        protected override void Execute(CodeActivityContext context)
        {
            try
            {
                MembersCount.Set(context, 0);
                MembersNames.Set(context, new Collection <string>()
                {
                });

                string host     = "https://api.meetup.com/2/rsvps?event_id={0}&sign=true&key={1}";
                string url      = string.Format(host, EventID.Get(context), ApiKey.Get(context));
                string response = string.Empty;

                HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;

                if (null == request)
                {
                    throw new ApplicationException("HttpWebRequest failed");
                }
                using (StreamReader sr = new StreamReader(request.GetResponse().GetResponseStream()))
                {
                    response = sr.ReadToEnd();
                }

                RawResponse.Set(context, response);

                Collection <string> names = new Collection <string>()
                {
                };

                JObject o = JObject.Parse(response);
                JArray  a = (JArray)o["results"];

                foreach (JToken item in a)
                {
                    names.Add(item["member"]["name"].ToString());
                }

                MembersCount.Set(context, a.Count);
                MembersNames.Set(context, names);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// Execution Logic
        /// </summary>
        /// <param name="context"></param>
        protected override void Execute(CodeActivityContext context)
        {
            MembersCount.Set(context, 0);
            MembersNames.Set(context, new Collection <String>()
            {
            });

            string host     = "https://api.meetup.com/2/members?order=name&sign=true&group_urlname={0}&key={1}";
            string url      = String.Format(host, GroupUrlName.Get(context), ApiKey.Get(context));
            string response = String.Empty;

            HttpWebRequest request = HttpWebRequest.Create(url) as HttpWebRequest;

            if (null == request)
            {
                throw new ApplicationException("HttpWebRequest failed");
            }
            using (StreamReader sr = new StreamReader(request.GetResponse().GetResponseStream()))
            {
                response = sr.ReadToEnd();
            }

            RawResponse.Set(context, response);

            var names = new Collection <String>()
            {
            };

            JObject o = JObject.Parse(response);
            JArray  a = (JArray)o["results"];

            foreach (var item in a)
            {
                names.Add(item["name"].ToString());
            }

            MembersCount.Set(context, a.Count);
            MembersNames.Set(context, names);
        }