コード例 #1
0
        public void callback(SparqlResultSet results, Object u)
        {
            try
            {
                List <Event>  events = new List <Event>();
                IMessengerApi api    = RestClientBuilder.GetMessengerApi();
                //System.Console.WriteLine("Query Callback");

                if (results.Count > 0 && u is CallbackData)
                {
                    CallbackData user = (CallbackData)u;
                    //System.Console.WriteLine("Found Results");
                    foreach (SparqlResult res in results)
                    {
                        try
                        {
                            Event e = ResultParser.GetEvent(res);
                            events.Add(e);
                            //System.Console.WriteLine("Datum: " + e.startDate);
                            //System.Console.WriteLine("Dend: " + e.endDate);
                        } catch (Exception ex)
                        {
                            System.Console.WriteLine(ex);
                        }
                    }
                    rm.SendTextMessage(user.Id, DataConstants.GetMessage("Found", user.Language));
                    //System.Console.WriteLine(JsonConvert.SerializeObject(CarouselFactory.makeCarousel(user.Id, events, user.Language)));
                    String result = api.SendMessageToUser(CarouselFactory.makeCarousel(user.Id, events, user.Language)).Result;
                }
                else if (u is CallbackData)
                {
                    CallbackData user = (CallbackData)u;
                    rm.SendNoEventFound(user.Id, user.Language);
                    rm.SendConfirmation(user.Id, user.Language);
                }
                else if (u is VDS.RDF.AsyncError)
                {
                    VDS.RDF.AsyncError error = (VDS.RDF.AsyncError)u;
                    CallbackData       user  = (CallbackData)error.State;
                    string             hmess = DataConstants.GetMessage("Error", user.Language);
                    rm.SendTextMessage(user.Id, hmess);
                }
                // System.Console.WriteLine("End of query method");
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex);
            }
        }
コード例 #2
0
 public ReplyManager()
 {
     api  = RestClientBuilder.GetMessengerApi();
     lang = "GENTS";  //default Gentse chatbot
 }
コード例 #3
0
 public App()
 {
     _messenger    = new PMessenger();
     _messengerApi = RestClient.For <IMessengerApi>("http://localhost:54545/api");
 }