Example #1
0
 public static Dictionary <Project, double> LookingForProject(string Content, out HashSet <string> np)
 {
     np = NPExtractor.getNP(Content);
     string[] prefixes = { "find project about", "find project on", "find projects on", "find projects about" };
     if (prefixes.Any(prefix => Content.ToLower().StartsWith(prefix)))
     {
         char[] delimiterChars = { ' ', ',', '.', ':', '\t', '?' };
         var    array          = Content.ToLower().Split(delimiterChars);
         if (array.Length > 3)
         {
             for (int i = 3; i < array.Length; i++)
             {
                 if (array[i] != "and" && array[i] != "or" && array[i].Length > 0)
                 {
                     np.Add(array[i]);
                 }
             }
         }
     }
     if (np.Count > 0)
     {
         Dictionary <Project, double> project_list = QueryInterface.queryProject(np);
         return(project_list);
     }
     return(null);
 }
Example #2
0
 public ReClient(Transfering transfering, Evaluator evaluator, QueryInterface queryInterface)
 {
     Transfering = transfering;
     Evaluator   = evaluator;
     Transfering.ConnectionError += OnConnectionError;
     _queryInterface              = queryInterface;
 }
Example #3
0
        /// <summary>
        /// return null if no np is detected
        ///
        /// </summary>
        /// <param name="Content"></param>
        /// <returns></returns>
        public static Dictionary <Person, double> LookingForPerson(string Content, out HashSet <string> np)
        {
            //HashSet<string> np = NPExtractor.getNP(Content);
            np = new HashSet <string>();
            //if(Content.ToLower().StartsWith("who know"))
            //{
            //    Content = Content.Substring(9).TrimStart();
            //    char[] delimiterChars = { ',', '.', ':', '\t', '?' };
            //    var array = Content.ToLower().Split(delimiterChars);
            //    for(int i = 0; i < array.Length; i++)
            //    {
            //        if (array[i] != "and" && array[i] != "or" && array[i].Length > 0)
            //            np.Add(array[i]);
            //    }
            //}
            //else
            //    np = NPExtractor.getNP(Content);

            if (np.Count > 0)
            {
                Dictionary <Person, double> person_list = QueryInterface.queryUser(np);
                return(person_list);
            }
            return(null);
        }
Example #4
0
        internal static HashSet <Tuple <Person, string> > LookingForTeam(string input)
        {
            HashSet <string> np = NPExtractor.getNP(input);

            if (np.Count > 0)
            {
                return(QueryInterface.queryTeam(np));
            }
            return(null);
        }
Example #5
0
        public ResultType Dispatch <ResultType>(QueryInterface <ResultType> query)
        {
            Type type = typeof(QueryHandlerInterface <,>);

            Type[] typeArgs         = { query.GetType(), typeof(ResultType) };
            Type   queryHandlerType = type.MakeGenericType(typeArgs);

            dynamic    handler = _provider.GetService(queryHandlerType);
            ResultType result  = handler.Handle((dynamic)query);

            return(result);
        }
Example #6
0
        public OPipeServer(string pipeName, Evaluator evaluator = null)
        {
            _pipeName = pipeName;
            Evaluator = evaluator ?? new Evaluator();

            _queryInterface = new QueryInterface();
            _queryInterface.UpsertIndexedSymbols(new[] { "quote", "lambda", "if", "begin", "define", "set!", "call/cc", });
            _queryInterface.UpsertIndexedSymbols(Evaluator.DefaultEnviroment.Variables.Keys.ToArray());
            RegisterImplementation(_queryInterface);

            listerThread = new Thread(ListenerHandler);
            listerThread.IsBackground = true;
            listerThread.Start();
        }
Example #7
0
        public OTcpServer(int port, Evaluator evaluator = null)
        {
            Evaluator = evaluator ?? new Evaluator();

            _queryInterface = new QueryInterface();
            _queryInterface.UpsertIndexedSymbols(new [] { "quote", "lambda", "if", "begin", "define", "set!", "call/cc", });
            _queryInterface.UpsertIndexedSymbols(Evaluator.DefaultEnviroment.Variables.Keys.ToArray());
            RegisterImplementation(_queryInterface);

            _listener = new TcpListener(IPAddress.Any, port);
            _listener.Start();

            Evaluator.DefaultEnviroment.Define("get-context-tcp-client", new Func <dynamic>(() => ContexTcpClient));

            listerThread = new Thread(ListenerHandler);
            listerThread.IsBackground = true;
            listerThread.Start(_listener);
        }
Example #8
0
        public void getResults_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //Get data for the selected suite
                var selectedItem = (TreeViewItem)TvMtm.SelectedItem;

                _suiteid = int.Parse(selectedItem.Tag.ToString());
                try
                {
                    Mouse.OverrideCursor = Cursors.Wait;
                    _rawdata             = DataGetter.GetResultSummaryList(_suiteid, selectedItem.Header.ToString());
                }
                catch (Exception exp)
                {
                    MessageBox.Show(
                        "We are not able to get data from VSTF.Please check if you are able to connect using Visual studio.Please send us the below error details if you are able to connect." +
                        Environment.NewLine + exp.Message, "OOPS!", MessageBoxButton.OK, MessageBoxImage.Warning);

                    return;
                }
                finally
                {
                    Mouse.OverrideCursor = null;
                }
                //Add Filters
                var filters = new List <Filter>();

                var moduleinclusion  = ChkModuleInclusion.IsChecked != null && ChkModuleInclusion.IsChecked.Value;
                var modulefilter     = Txtmodulefilter.Text;
                var testerinclusion  = ChkTesterInclusion.IsChecked != null && ChkTesterInclusion.IsChecked.Value;
                var testerfilter     = Txttesterfilter.Text;
                var automationstatus = CmbAutomationStaus.SelectedItem.ToString();
                if (!string.IsNullOrEmpty(TxtTitlefilter.Text))
                {
                    var titleFilter = new Filter();
                    if (ChkTitleInclusion.IsChecked != null && ChkTitleInclusion.IsChecked.Value)
                    {
                        titleFilter.Op = "Contains";
                    }
                    else
                    {
                        titleFilter.Op = "Not Contains";
                    }
                    titleFilter.Name  = "Title";
                    titleFilter.Value = TxtTitlefilter.Text;
                    filters.Add(titleFilter);
                }
                if (!CmbPriority.SelectedValue.ToString().Equals("All", StringComparison.InvariantCultureIgnoreCase))
                {
                    var titleFilter = new Filter {
                        Name = "Priority", Value = CmbPriority.SelectedValue.ToString()
                    };

                    filters.Add(titleFilter);
                }
                if (!CmbOutcome.SelectedValue.ToString().Equals("All", StringComparison.InvariantCultureIgnoreCase))
                {
                    var titleFilter = new Filter {
                        Name = "Outcome", Value = CmbOutcome.SelectedValue.ToString()
                    };

                    filters.Add(titleFilter);
                }

                _queryResult = QueryInterface.Generate(_rawdata, modulefilter, moduleinclusion, testerfilter,
                                                       testerinclusion, automationstatus, filters);
                ResultDataGrid.ItemsSource = _queryResult;

                MessageBox.Show("All done. Found " + _queryResult.Count + " Cases");
            }
            catch (Exception exp)
            {
                MessageBox.Show(
                    "It seems something has gone wrong. Please send us the below information so that we can resolve the issue." +
                    Environment.NewLine + exp.Message, "OOPS!", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            finally
            {
                Mouse.OverrideCursor = null;
            }
        }
Example #9
0
        public async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> argument)
        {
            var message = await argument;
            //await context.PostAsync("You said: " + message.Text);
            string input = message.Text;
            //Activity reply;
            string displayString = "";

            channel = message.ChannelId;
            uid     = message.From.Id;
            if (!RegisterCheck)
            {
                RegisterCheck = true;
                user          = DB_Operation.queryUserInfo(channel, uid);
                if (user != null)
                {
                    IsRegister = true;
                }
            }
            if (input.ToLower() == "register")
            {
                var userForm = new FormDialog <FormUserInfo>(new FormUserInfo(), FormUserInfo.BuildForm, FormOptions.PromptInStart);
                context.Call <FormUserInfo>(userForm, UserFormComplete);
            }

            else
            {
                INTENT           userIntent;
                HashSet <string> keywords = LUIS.getNP(input, out userIntent);


                //if (Reaction.isLookingForPerson(input))
                if (userIntent == INTENT.FindUser)
                {
                    await context.PostAsync("Let me check...");

                    //HashSet<string> keywords;
                    //Dictionary<Person, double> user_list = Reaction.LookingForPerson(input, out keywords);
                    if (keywords.Count == 0)
                    {
                        displayString += "Sorry, I can not understand your query. Do you meant to find a user with specific skill? You can try to ask me: \"Who knows *skill1, skill2, ...*\".";
                    }

                    else
                    {
                        Dictionary <Person, double> user_list = QueryInterface.queryUser(keywords);
                        if (user_list.Count == 0)
                        {
                            displayString += "Sorry, I could not find any appropriate user for your query \"" + input + "\"";
                        }
                        else
                        {
                            displayString += "I find serveral users who might help you with";
                            foreach (var keyword in keywords)
                            {
                                displayString += " " + keyword;
                            }
                            displayString += ":";
                            foreach (Person p in user_list.Keys)
                            {
                                displayString += "\n";
                                displayString += string.Format("* [{1}]({0})", p.homepageurl, p.userLogin);
                            }
                        }
                    }
                }

                //else if (Reaction.isLookingForProject(input))
                else if (userIntent == INTENT.FindProject)
                {
                    await context.PostAsync("Let me check...");

                    //HashSet<string> keywords;
                    //Dictionary<Project, double> project_list = Reaction.LookingForProject(input,out keywords);
                    if (keywords.Count == 0)
                    {
                        displayString += "Sorry, I can not understand your query. Do you meant to find a project on specific techs? You can try to ask me: \"Find project about *tech1, tech2, ...*\".";
                    }
                    else
                    {
                        Dictionary <Project, double> project_list = QueryInterface.queryProject(keywords);

                        if (project_list.Count == 0)
                        {
                            displayString += "Sorry, I could not find any appropriate project for your query \"." + input + "\"";
                        }
                        else
                        {
                            displayString += "I find serveral projects about";
                            foreach (var keyword in keywords)
                            {
                                displayString += " " + keyword;
                            }
                            displayString += ":";
                            foreach (Project p in project_list.Keys)
                            {
                                displayString += "\n";
                                displayString += string.Format("* [{1}]({0})", p.projectUrl, p.projectName);
                            }
                        }
                    }
                }
                //else if (Reaction.isLookingForTeam(input))
                else if (userIntent == INTENT.FindTeam)
                {
                    await context.PostAsync("Let me check...");

                    //HashSet<Tuple<Person, string>> records = Reaction.LookingForTeam(input);
                    if (keywords.Count == 0)
                    {
                        displayString += "Sorry, I can not understand your query. Do you meant to find a team of users to cover specific skills? You can try to ask me: \"Find a team covers skill of *skill1, skill2, ...*\".";
                    }
                    else
                    {
                        HashSet <Tuple <Person, string> > records = QueryInterface.queryTeam(keywords);
                        if (records.Count == 0)
                        {
                            displayString += "Sorry, I could not find any team according to your requirement \"." + input + "\"";
                        }
                        else
                        {
                            displayString += "I find a team consists of following users according to your requirement:\n\n";
                            displayString += "**People**\t\t**Skills**";
                            foreach (Tuple <Person, string> t in records)
                            {
                                displayString += "\n\n";
                                displayString += string.Format("* [{2}]({0})\t\t{1}", t.Item1.userLogin, t.Item2, t.Item1.homepageurl);
                            }
                        }
                    }
                }
                else
                {
                    displayString  = "I'm a bot to help you find people or project with specific technological skills on GitHub easily. [More Channel](http://collabotframework.azurewebsites.net)";
                    displayString += "\n\n You can start with: \n";
                    displayString += "* \"Who knows *skill1, skill2, ...*\"\n";
                    displayString += "* \"Find project about *tech1, tech2, ...*\"\n";
                    displayString += "* \"Find a team covers skills of *skill1, skill2, ...*\"";
                    displayString += "\n\n Say *register* to let me serve you better!";
                    //int length = (activity.Text ?? string.Empty).Length;
                    //Activity reply = activity.CreateReply($"You sent {activity.Text} which was {length} characters <br/> Test new line");
                }
                await context.PostAsync(displayString);

                System.Diagnostics.Trace.TraceInformation("Reply: [markdown]{0}", displayString);
                context.Wait(MessageReceivedAsync);
            }
        }