public IEnumerable<SocialDataItem> GetData()
        {
            /*
             */
            var token = SocialDataSource.Token;
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Add("x-authorization", token);
            var task = client.GetAsync(host + route);
            task.Wait();

            var readTask = task.Result.Content.ReadAsStringAsync();
            readTask.Wait();
            var result = readTask.Result;
            dynamic obj = JsonConvert.DeserializeObject(result);
            var temp = (JArray)obj.posts;
            var items = new List<SocialDataItem>();

            foreach (var i in temp)
            {
                dynamic d = i;
                string id = d.id;
                string title = d.title;
                string text = d.content;
                var sdi = new SocialDataItem(id, title, title, null, text, text, null);
                items.Add(sdi);
            }
            return items;
        }
Example #2
0
        public IEnumerable<SocialDataItem> GetData()
        {
            var client = new HttpClient();
            var token = SocialDataSource.Token;
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Add("x-authorization", token);
            //#F48024
            var task = client.GetAsync(host + examsRoute);
            task.Wait();

            var readTask = task.Result.Content.ReadAsStringAsync();
            readTask.Wait();
            var result = readTask.Result;
            dynamic obj = JsonConvert.DeserializeObject(result);

            var items = new List<SocialDataItem>();
            foreach(var item in obj.activityStream.items)
            {
                var sdi = new SocialDataItem(
                    item.target.referenceId.ToString(),item.target.title.ToString(),item.actor.title.ToString(),null,item.target.title.ToString(),item.target.title.ToString(),null);
                items.Add(sdi);
            }

            return items;
        }
Example #3
0
        public IEnumerable<SocialDataItem> GetData()
        {
            /*
             * {
            "upcomingEvents": [{
            "category": "due",
            "id": 25,
            "titleHeading": "SitePen Demo",
            "title": "Questions Relative to Research Topic Assignment pp",
            "type": "UNKNOWN",
            "when": {
            "time": "2012-11-20T00:00:00Z"
            },
            "links": [{
            "href": "https://m-api.ecollege.com/courses/6747098",
            "rel": "https://m-api.ecollege.com/rel/course"
            }]
            }]
            }
             */
            var token = SocialDataSource.Token;
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Add("x-authorization", token);
            //#F48024
            var task = client.GetAsync(host + route);
            task.Wait();

            var readTask = task.Result.Content.ReadAsStringAsync();
            readTask.Wait();
            var result = readTask.Result;
            dynamic obj = JsonConvert.DeserializeObject(result);

            var temp = (JArray)obj.upcomingEvents;
            var items = new List<SocialDataItem>();

            foreach (var i in temp)
            {
                dynamic d = i;
                string id = d.id;
                string title = d.titleHeading + " : " + d.title;
                string text = d.when.time;
                //text = RipHtmlOut(text);
                var sdi = new SocialDataItem(id, title, title, null, text, text, null);
                //sdi.Read = read;
                items.Add(sdi);
            }
            return items;
        }
        public IEnumerable<SocialDataItem> GetAnnouncements()
        {
            var token = SocialDataSource.Token;
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Add("x-authorization", token);
            //#F48024
            var task = client.GetAsync(host + annoucementsRoute);
            task.Wait();

            var readTask = task.Result.Content.ReadAsStringAsync();
            readTask.Wait();
            var result = readTask.Result;
            dynamic obj = JsonConvert.DeserializeObject(result);
            var temp = (JArray)obj.userannouncements;
            var items = new List<SocialDataItem>();

            //      "userannouncements": [{
            //"id": "11072162-23124301",
            //"readStatus": {
            //    "markedAsRead": false
            //},

            foreach (var i in temp)
            {

                dynamic d = i;
                string id = d.id;
                string title = d.announcement.subject;
                string text = d.announcement.text;
                bool read = d.readStatus.markedAsRead;
                text = RipHtmlOut(text);
                var sdi = new SocialDataItem(id, title, title, null, text, text, null);
                sdi.Read = read;
                items.Add(sdi);
            }
            return items;
        }