示例#1
0
        public async Task HandleXAPIAsync()
        {
            if (lastFeedbackSent.verb.Contains("Good"))
            {
            }
            else
            {
                XAPIStuff.XAPIActor           actor    = new XAPIStuff.XAPIActor("id_" + lastFeedbackSent.applicationName, "application", lastFeedbackSent.applicationName);
                XAPIStuff.XAPIVerb            verb     = new XAPIStuff.XAPIVerb("id", lastFeedbackSent.verb);
                XAPIStuff.XAPIObject          myObject = new XAPIStuff.XAPIObject("student", "id_student");
                TimeSpan                      ts       = new TimeSpan(DateTime.Now.Subtract(lastFeedbackSent.frameStamp).Ticks);
                XAPIStuff.XAPIDurationContext duration = new XAPIStuff.XAPIDurationContext(ts);
                XAPIStuff.XAPIContext         context  = new XAPIStuff.XAPIContext(duration);

                XAPIStuff.XAPIStatement myStatement = new XAPIStuff.XAPIStatement(actor, verb, myObject, context);

                string xapiString = JsonConvert.SerializeObject(myStatement, Newtonsoft.Json.Formatting.Indented);


                try
                {
                    foreach (LAApplication myLA in myLAApps)
                    {
                        string         url      = myLA.Path + xapiString;
                        HttpWebRequest request  = (HttpWebRequest)WebRequest.Create(url);
                        WebResponse    response = await request.GetResponseAsync();

                        Stream       resStream = response.GetResponseStream();
                        StreamReader sr99      = new StreamReader(resStream);
                        string       aa        = await sr99.ReadToEndAsync();
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    Console.WriteLine("error trying to post to server");
                }
            }
        }
示例#2
0
        public async void HandleFeedback(string feedback)
        {
            foreach (FeedbackApp fapp in myFeedbacks)
            {
                fapp.SendUDP(feedback);
            }
            try
            {
                FeedbackObject feed = JsonConvert.DeserializeObject <FeedbackObject>(feedback);

                if (feed.verb.Equals(lastFeedbackSent.verb))
                {
                }
                else if (feed.verb.Contains("Good"))
                {
                    XAPIStuff.XAPIActor           actor    = new XAPIStuff.XAPIActor("id_" + lastFeedbackSent.applicationName, "application", lastFeedbackSent.applicationName);
                    XAPIStuff.XAPIVerb            verb     = new XAPIStuff.XAPIVerb("id", lastFeedbackSent.verb);
                    XAPIStuff.XAPIObject          myObject = new XAPIStuff.XAPIObject("student", "id_student");
                    XAPIStuff.XAPIDurationContext duration = new XAPIStuff.XAPIDurationContext(feed.frameStamp.Subtract(lastFeedbackSent.frameStamp));
                    XAPIStuff.XAPIContext         context  = new XAPIStuff.XAPIContext(duration);

                    XAPIStuff.XAPIStatement myStatement = new XAPIStuff.XAPIStatement(actor, verb, myObject, context);

                    string xapiString = JsonConvert.SerializeObject(myStatement, Newtonsoft.Json.Formatting.Indented);

                    try
                    {
                        foreach (LAApplication myLA in myLAApps)
                        {
                            string         url      = myLA.Path + xapiString;
                            HttpWebRequest request  = (HttpWebRequest)WebRequest.Create(url);
                            WebResponse    response = await request.GetResponseAsync();

                            Stream       resStream = response.GetResponseStream();
                            StreamReader sr99      = new StreamReader(resStream);
                            string       aa        = await sr99.ReadToEndAsync();
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        Console.WriteLine("error trying to post to server");
                    }
                    lastFeedbackSent = feed;
                }
                else
                {
                    lastFeedbackSent = feed;
                }
            }
            catch
            {
            }

            Dispatcher.Invoke(() =>
            {
                try
                {
                    myRecordingInterface.LabelFeedback.Content = feedback;
                }
                catch
                {
                }
            });
        }