public async Task <GlobalSearch> BuildAsync(string userId, string filter, FeedType type) { var search = new GlobalSearch(); search.SearchText = filter; ConcurrentBag <GlobalSearchItem> bag = new ConcurrentBag <GlobalSearchItem>(); filter = (filter ?? "").ToLower(); if (type == FeedType.Team) { AddRange(bag, GetTeams(userId, filter).ToList()); } if (type == FeedType.School) { AddRange(bag, GetSchools(userId, filter).ToList()); } if (type == FeedType.Sport) { AddRange(bag, GetSports(userId, filter).ToList()); } if (type == FeedType.ContentSource) { AddRange(bag, GetContentSources(userId, filter).ToList()); } if (type == FeedType.User) { AddRange(bag, GetUsers(userId, filter).ToList()); } search.Results = bag.ToList(); return(search); }
/*******************************************/ private static void Canvas_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { GH_Canvas canvas = sender as GH_Canvas; if (canvas == null) { return; } if (m_LastWire == null) { return; } FieldInfo targetField = typeof(GH_WireInteraction).GetField("m_target", BindingFlags.NonPublic | BindingFlags.Instance); if (targetField != null && targetField.GetValue(m_LastWire.Wire) != null) { m_LastWire = null; Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss") + "- Wire info cleared."); } else { GlobalSearch.Open(canvas.FindForm(), new SearchConfig { TypeConstraint = m_LastWire.SourceType, IsReturnType = m_LastWire.IsInput, Tags = m_LastWire.Tags }); } }
/*******************************************/ /**** Private Methods ****/ /*******************************************/ private static void Instances_CanvasCreated(GH_Canvas canvas) { GlobalSearch.Activate(canvas.FindForm()); canvas.MouseDown += Canvas_MouseDown; canvas.MouseUp += Canvas_MouseUp; canvas.KeyDown += Canvas_KeyDown; }
public HttpResponseMessage globalSearch(string searchText, string type) { try { GlobalSearch response = _business.globalSearch(searchText, type); return(Request.CreateResponse(HttpStatusCode.OK, response)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message.ToString())); } }
public GlobalSearch globalSearch(string searchText, string type) { try { if (string.IsNullOrWhiteSpace(searchText)) { searchText = ""; } GlobalSearch response = _repository.globalSearch(searchText, type); return(response); } catch (Exception) { throw; } }
/*******************************************/ /**** Public Methods ****/ /*******************************************/ public static void Activate() { GH.Instances.CanvasCreated += Instances_CanvasCreated; GlobalSearch.RemoveHandler(typeof(GlobalSearchMenu).FullName); GlobalSearch.ItemSelected += GlobalSearch_ItemSelected; // Update settings beased on config file in BHoM Settings folder UpdateSettingsFromFile(); // Watch for changes of the settings file string settingsFolder = Path.GetFullPath(Path.Combine(BH.Engine.Base.Query.BHoMFolder(), @"..\Settings")); m_Watcher = new FileSystemWatcher(settingsFolder, "Grasshopper.cfg"); m_Watcher.EnableRaisingEvents = true; m_Watcher.Changed += (sender, e) => UpdateSettingsFromFile(); m_Watcher.Created += (sender, e) => UpdateSettingsFromFile(); }
public async Task <GlobalSearch> BuildAsync(string userId, string filter) { var search = new GlobalSearch(); search.SearchText = filter; ConcurrentBag <GlobalSearchItem> bag = new ConcurrentBag <GlobalSearchItem>(); filter = (filter ?? "").ToLower(); var t1 = Task.Run(() => { AddRange(bag, GetTeams(userId, filter).ToList()); }); var t2 = Task.Run(() => { AddRange(bag, GetSchools(userId, filter).ToList()); }); var t3 = Task.Run(() => { AddRange(bag, GetSports(userId, filter).ToList()); }); var t4 = Task.Run(() => { AddRange(bag, GetContentSources(userId, filter).ToList()); }); var t5 = Task.Run(() => { AddRange(bag, GetUsers(userId, filter).ToList()); }); Task.WaitAll(t1, t2, t3, t4, t5); search.Results = bag.ToList(); if (string.IsNullOrEmpty(filter)) { search.Results = search.Results.OrderByDescending(m => m.Followers).Take(10).ToList(); } return(search); }
public ActionResult SearchResults(GlobalSearch model) { try { if (model.SearchString != null) { char[] charsToTrim = { ' ', '\t' }; model.SearchString = model.SearchString.Trim(charsToTrim); } if (model.SearchString == null) { model.SearchString = ""; } int userId = int.Parse(Session["UserID"].ToString()); if (model.SearchString != null) { DataSet ds = new DataSet(); string constr = ConfigurationManager.AppSettings["connstr"]; SqlConnection con = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); SqlParameter[] param = new SqlParameter[1]; cmd.Connection = con; cmd.CommandText = "SP_GlobalSearch"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@srchString", SqlDbType.VarChar).Value = model.SearchString; cmd.Parameters.Add("@UserID", SqlDbType.VarChar).Value = userId; SqlDataAdapter adap = new SqlDataAdapter(cmd); adap.Fill(ds); var searchlist = ds.Tables[0].AsEnumerable().Select(actRow => new SearchListItemModel { UserId = (int)actRow["UserId"], FirstName = actRow["FirstName"] + " " + actRow["LastName"], Role = actRow["RoleName"].ToString() == null ? string.Empty : actRow["RoleName"].ToString(), DesignationName = actRow["DesignationName"].ToString() == null ? string.Empty : actRow["DesignationName"].ToString(), Skills = actRow["Skills"].ToString() == null ? string.Empty : actRow["Skills"].ToString(), ProjectId = actRow["ProjectId"].ToString() == null ? string.Empty : actRow["ProjectId"].ToString(), ProjectName = actRow["ProjectName"].ToString() == null ? string.Empty : actRow["ProjectName"].ToString() }).ToList(); ViewBag.SearchString = model.SearchString; return(View(searchlist)); } else { return(View()); } } catch (Exception Ex) { string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName); throw Ex.GetBaseException(); } }