Exemple #1
0
        public CollectorTest()
        {
            Collector = new Collector();
            string oxfordEntriesRoute = ConfigurationManager.AppSettings["OxfordApi.Entries"];

            this.Parameters = ParameterGenerator.GenerateParameters("hello", oxfordEntriesRoute);
        }
Exemple #2
0
        public override void Process(Impulse impulse)
        {
            Impulse result = null;

            if (impulse is Data)
            {
                //TODO: new to chew up the data before i decide what to do with it.
                //  i will only check for a definition if that is what the query requests.
                Data       query      = impulse as Data;
                Parameters parameters = ParameterGenerator.GenerateParameters(query.Content, "/api/v1/entries/en/");
                Definition definition = Collector.GatherData <Definition>(parameters).Result as Definition;

                if (definition != null)
                {
                    result = Map.DefinitionToWord(definition);

                    if (result != null)
                    {
                        result.Outcome = Outcome.Success;
                        result.Signal  = SignalType.Response;
                    }
                    else
                    {
                        Trace.WriteLine($"{Resources.Constants.Trace.Date};{this.ToString()};{SignalType.None};{Outcome.Failure}");
                    }
                }
                else
                {
                    result = new Data
                    {
                        Content = "",
                        Outcome = Outcome.Failure,
                        Signal  = SignalType.Response,
                    };
                }

                if (result != null)
                {
                    Transmitter.SendSignal(result);
                    Trace.WriteLine(string.Format("{0};{1};{2}", Resources.Constants.Trace.Date, this.ToString(), result.Signal));
                }
            }
        }