Ejemplo n.º 1
0
 public BookRepository()
 {
     Books = SearchUtility.GetBooks().AsQueryable();
 }
Ejemplo n.º 2
0
        public IActionResult ReserveBook(int libraryID)
        {
            ReserveBookViewModel viewModel = this.vmFactory.GetReserveBookViewModel(SearchUtility.GetBookByLibraryID(libraryID));

            return(View(viewModel));
        }
Ejemplo n.º 3
0
        private bool OnFilter(object obj, string[] search = null)
        {
            if (obj is IItem item)
            {
                // skip items without names
                if (string.IsNullOrEmpty(item.Name))
                {
                    return(false);
                }

                if (this.mode == Mode.Items && (obj is Prop || item.Key == 0))
                {
                    return(false);
                }

                if (this.mode == Mode.Special && (obj is Prop || item.Key != 0))
                {
                    return(false);
                }

                if (this.mode == Mode.Props && !(obj is Prop))
                {
                    return(false);
                }

                if (this.slot == ItemSlots.MainHand || this.slot == ItemSlots.OffHand)
                {
                    if (!item.IsWeapon)
                    {
                        return(false);
                    }
                }
                else
                {
                    if (!item.FitsInSlot(this.slot))
                    {
                        return(false);
                    }
                }

                if (!this.HasClass(this.ClassFilter, item.EquipableClasses))
                {
                    return(false);
                }

                bool matches = false;

                matches |= SearchUtility.Matches(item.Name, search);
                matches |= SearchUtility.Matches(item.ModelSet.ToString(), search);
                matches |= SearchUtility.Matches(item.ModelBase.ToString(), search);
                matches |= SearchUtility.Matches(item.ModelVariant.ToString(), search);

                if (item.HasSubModel)
                {
                    matches |= SearchUtility.Matches(item.SubModelSet.ToString(), search);
                    matches |= SearchUtility.Matches(item.SubModelBase.ToString(), search);
                    matches |= SearchUtility.Matches(item.SubModelVariant.ToString(), search);
                }

                matches |= SearchUtility.Matches(item.Key.ToString(), search);

                return(matches);
            }

            return(false);
        }
Ejemplo n.º 4
0
 public static string SearchResultLabel(LooseAssemblyName looseAssemblyName, string query)
 {
     return(SearchUtility.HighlightQuery(looseAssemblyName.name, query));
 }
        public async Task <SearchResponseVM> GetDocumentsAsync(SearchRequestVM searchRequestVM, ClientContext clientContext)
        {
            var searchObject = searchRequestVM.SearchObject;

            // Encode all fields which are coming from js
            SearchUtility.EncodeSearchDetails(searchObject.Filters, false);
            // Encode Search Term
            searchObject.SearchTerm = (searchObject.SearchTerm != null) ?
                                      WebUtility.HtmlEncode(searchObject.SearchTerm).Replace(ServiceConstants.ENCODED_DOUBLE_QUOTES, ServiceConstants.DOUBLE_QUOTE) : string.Empty;

            var searchResultsVM = await docRepository.GetDocumentsAsync(searchRequestVM, clientContext);

            if (searchResultsVM.TotalRows > 0)
            {
                dynamic documentDataList = new List <dynamic>();
                IEnumerable <IDictionary <string, object> > searchResults = searchResultsVM.SearchResults;
                foreach (var searchResult in searchResults)
                {
                    dynamic documentData = new ExpandoObject();
                    foreach (var key in searchResult.Keys)
                    {
                        documentData.Checker = false;
                        ServiceUtility.AddProperty(documentData, "Checker", false);
                        if (key.ToString().ToLower() == searchSettings.ManagedPropertyDocumentClientName.ToString().ToLower())
                        {
                            ServiceUtility.AddProperty(documentData,
                                                       configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentClient").Key,
                                                       searchResult[key].ToString());
                        }

                        if (key.ToString().ToLower() == searchSettings.ManagedPropertyFileName.ToString().ToLower())
                        {
                            if (searchResult[key] != null && (searchResult[key].ToString() != string.Empty))
                            {
                                string fileNameWithOutExt = System.IO.Path.GetFileNameWithoutExtension(searchResult[key].ToString());
                                ServiceUtility.AddProperty(documentData,
                                                           configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentName").Key,
                                                           fileNameWithOutExt);
                            }
                        }

                        if (key.ToString().ToLower() == searchSettings.ManagedPropertyDocumentClientId.ToString().ToLower())
                        {
                            ServiceUtility.AddProperty(documentData,
                                                       configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentClientId").Key,
                                                       searchResult[key].ToString());
                        }
                        if (key.ToString().ToLower() == searchSettings.ManagedPropertySiteName.ToString().ToLower())
                        {
                            ServiceUtility.AddProperty(documentData,
                                                       configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentClientUrl").Key,
                                                       searchResult[key].ToString());
                        }
                        if (key.ToString().ToLower() == searchSettings.ManagedPropertyDocumentVersion.ToString().ToLower())
                        {
                            ServiceUtility.AddProperty(documentData,
                                                       configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentVersion").Key,
                                                       searchResult[key].ToString());
                        }
                        if (key.ToString().ToLower() == searchSettings.ManagedPropertyDocumentMatterName.ToString().ToLower())
                        {
                            if (searchResult[key].ToString() != string.Empty)
                            {
                                ServiceUtility.AddProperty(documentData,
                                                           configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentMatterName").Key,
                                                           searchResult[key].ToString());
                            }
                            else
                            {
                                ServiceUtility.AddProperty(documentData,
                                                           configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentMatterName").Key,
                                                           searchResult["Title"].ToString());
                            }
                        }
                        if (key.ToString().ToLower() == searchSettings.ManagedPropertyDocumentMatterId.ToString().ToLower())
                        {
                            ServiceUtility.AddProperty(documentData,
                                                       configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentMatterId").Key,
                                                       searchResult[key].ToString());
                        }
                        if (key.ToString().ToLower() == searchSettings.ManagedPropertyDocumentCheckOutUser.ToString().ToLower())
                        {
                            ServiceUtility.AddProperty(documentData,
                                                       configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentCheckoutUser").Key,
                                                       searchResult[key].ToString());
                        }
                        //-------------------------
                        if (key.ToString().ToLower() == searchSettings.ManagedPropertyCreated.ToString().ToLower())
                        {
                            if (searchResult[key] != null && (searchResult[key].ToString() != string.Empty))
                            {
                                ServiceUtility.AddProperty(documentData,
                                                           configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentCreatedDate").Key,
                                                           searchResult[key].ToString());
                            }
                        }
                        if (key.ToString().ToLower() == searchSettings.ManagedPropertyFileExtension.ToString().ToLower())
                        {
                            ServiceUtility.AddProperty(documentData,
                                                       configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentExtension").Key,
                                                       searchResult[key].ToString());
                            if (searchResult[key].ToString().ToLower() == "csv")
                            {
                                ServiceUtility.AddProperty(documentData,
                                                           configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentIconUrl").Key,
                                                           $"{generalSettings.SiteURL}/_layouts/15/images/generaldocument.png");
                            }
                            else if (searchResult[key].ToString().ToLower() != "pdf")
                            {
                                ServiceUtility.AddProperty(documentData,
                                                           configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentIconUrl").Key,
                                                           $"{generalSettings.SiteURL}/_layouts/15/images/ic{searchResult[key].ToString().ToLower()}.gif");
                            }
                            else
                            {
                                ServiceUtility.AddProperty(documentData,
                                                           configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentIconUrl").Key,
                                                           $"{generalSettings.SiteURL}/_layouts/15/images/ic{searchResult[key].ToString().ToLower()}.png");
                            }
                        }

                        if (key.ToString().ToLower() == searchSettings.ManagedPropertyPath.ToString().ToLower())
                        {
                            ServiceUtility.AddProperty(documentData,
                                                       configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentOWAUrl").Key,
                                                       searchResult[key].ToString());
                            ServiceUtility.AddProperty(documentData,
                                                       configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentUrl").Key,
                                                       searchResult[key].ToString());
                        }
                        if (key.ToString().ToLower() == "serverredirectedurl")
                        {
                            if (searchResult[key] != null)
                            {
                                ServiceUtility.AddProperty(documentData,
                                                           configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentOWAUrl").Key,
                                                           searchResult[key].ToString());
                                ServiceUtility.AddProperty(documentData,
                                                           configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentUrl").Key,
                                                           searchResult[key].ToString());
                            }
                        }
                        if (key.ToString().ToLower() == searchSettings.ManagedPropertyLastModifiedTime.ToString().ToLower())
                        {
                            ServiceUtility.AddProperty(documentData,
                                                       configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentModifiedDate").Key,
                                                       searchResult[key].ToString());
                        }

                        if (key.ToString().ToLower() == searchSettings.ManagedPropertyAuthor.ToString().ToLower())
                        {
                            ServiceUtility.AddProperty(documentData,
                                                       configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentOwner").Key,
                                                       searchResult[key].ToString());
                        }
                        if (key.ToString().ToLower() == searchSettings.ManagedPropertyDocumentId.ToLower())
                        {
                            if (searchResult[key] != null)
                            {
                                ServiceUtility.AddProperty(documentData,
                                                           configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("docId").Key,
                                                           searchResult[key].ToString());
                            }
                        }

                        if (key.ToString().ToLower() == searchSettings.ManagedPropertyPracticeGroup.ToString().ToLower())
                        {
                            ServiceUtility.AddProperty(documentData,
                                                       configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentPracticeGroup").Key,
                                                       searchResult[key].ToString());
                        }

                        if (key.ToString().ToLower() == "parentlink")
                        {
                            ServiceUtility.AddProperty(documentData,
                                                       configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentParentUrl").Key,
                                                       searchResult[key].ToString());
                            string documentUrl = searchResult[key].ToString().Substring(0, searchResult[key].ToString().LastIndexOf("/"));
                            string siteUrl     = searchResult["SiteName"].ToString();
                            string matterGuid  = searchResult[key].ToString().ToLower().Replace(siteUrl, "").Split('/')[1];
                            string matterUrl   = $"{siteUrl}/sitepages/{matterGuid}.aspx";
                            ServiceUtility.AddProperty(documentData,
                                                       configuration.GetSection("Search").GetSection("SearchColumnsUIPickerForDocument").GetSection("documentMatterUrl").Key,
                                                       matterUrl);
                        }
                        ServiceUtility.AddProperty(documentData, "PinType", "Pin");
                        ServiceUtility.AddProperty(documentData, "DocGuid", Guid.NewGuid().ToString());
                    }
                    documentDataList.Add(documentData);
                }
                searchResultsVM.DocumentDataList = documentDataList;
                searchResultsVM.SearchResults    = null;
                if (searchRequestVM.SearchObject.IsUnique && searchResultsVM.DocumentDataList != null && !string.IsNullOrWhiteSpace(searchRequestVM.SearchObject.UniqueColumnName))
                {
                    searchResultsVM.DocumentDataList = GetUniqueResults(searchRequestVM, searchResultsVM);
                }
                return(searchResultsVM);
            }
            else
            {
                return(searchResultsVM);
            }
        }
Ejemplo n.º 6
0
        public IHttpActionResult GetSearchContents(string search)
        {
            SearchUtility _searchUtility = new SearchUtility();

            return(Ok(_searchUtility.GetBlogAndPostList(search)));
        }
        private void GameObjectRowContentGUI(Rect rowPosition, Rect contentPosition, GameObjectItem item, RowGUIArgs args)
        {
            var openPrefabButtonPosition = new Rect
                                           (
                rowPosition.xMax - HierarchyStyles.openPrefabButton.fixedWidth - HierarchyStyles.openPrefabButton.margin.right,
                rowPosition.y,
                HierarchyStyles.openPrefabButton.fixedWidth,
                HierarchyStyles.openPrefabButton.fixedHeight
                                           );

            if (item.canOpenPrefab)
            {
                if (GUI.Button(openPrefabButtonPosition, GUIContent.none, HierarchyStyles.openPrefabButton))
                {
                    GameObjectOperations.OpenPrefab(item.gameObject);
                    parentWindow?.Close();
                    GUIUtility.ExitGUI();
                    return;
                }
            }

            contentPosition.xMax = openPrefabButtonPosition.xMin;

            var iconPosition = new Rect
                               (
                contentPosition.x,
                contentPosition.y,
                IconSize.Small,
                IconSize.Small
                               );

            if (PeekPlugin.Configuration.enablePreviewIcons && PreviewUtility.TryGetPreview(item.gameObject, out var preview) && preview != null)
            {
                GUI.DrawTexture(iconPosition, preview);
            }
            else if (item.icon != null)
            {
                GUI.DrawTexture(iconPosition, item.icon);
            }

            if (item.overlay != null)
            {
                GUI.DrawTexture(iconPosition, item.overlay);
            }

            var labelPosition = contentPosition;

            labelPosition.xMin += iconPosition.width;
            labelPosition.xMin += 2;

            var label = item.displayName;

            if (hasSearch)
            {
                label = SearchUtility.HighlightQuery(label, searchString);
            }

            if (e.type == EventType.Repaint)
            {
                item.style.Draw(labelPosition, label, false, false, args.selected, args.focused);
            }

            var target = item.gameObject;

            if (target == null)
            {
                return;
            }

            Object[] targets;

            if (args.selected)
            {
                targets = GetSelection().Where(i => FindItem(i, rootItem) is GameObjectItem).Select(i => FindGameObjectItem(i).gameObject).ToArray();
            }
            else
            {
                targets = new[] { target.gameObject };
            }

            TreeViewToolbars.Draw(false, toolbarControlProvider, target, targets, args.selected, args.label, contentPosition, rowPosition, HasFocus());
        }
        private void SceneItemRowContentGUI(Rect rowPosition, Rect contentPosition, SceneItem item, RowGUIArgs args)
        {
            contentPosition.yMin++;

            // Lots of messy code to display the row like Unity does,
            // because we don't have access to the same DrawItemBackground
            // override as they do
            var isHovered  = rowPosition.Contains(e.mousePosition);
            var isSelected = args.selected;

            var backgroundColor = GUI.backgroundColor;

            if (isHovered && !isSelected)
            {
                GUI.backgroundColor = ColorUtility.Gray(0.75f);
            }

            using (LudiqGUI.color.Override(new Color(1, 1, 1, 0.9f)))
            {
                GUI.Label(rowPosition, GUIContent.none, HierarchyStyles.sceneHeader);
            }

            GUI.backgroundColor = backgroundColor;

            if (isSelected)
            {
                var selectionHighlightPosition = rowPosition;
                selectionHighlightPosition.height--;
                EditorGUI.DrawRect(selectionHighlightPosition, ColorPalette.unitySelectionHighlight);
            }

            var iconPosition = new Rect
                               (
                contentPosition.x,
                contentPosition.y,
                IconSize.Small,
                IconSize.Small
                               );

            if (item.icon != null)
            {
                GUI.DrawTexture(iconPosition, item.icon);
            }

            contentPosition.xMin += iconPosition.width;
            contentPosition.xMin += 2;

            var label = item.displayName;

            if (hasSearch)
            {
                label = SearchUtility.HighlightQuery(label, searchString);
            }

            var style = item.style;

            if (SceneManager.GetActiveScene() == item.scene)
            {
                style = style.BoldedStyle(true);
            }

            if (e.type == EventType.Repaint)
            {
                style.Draw(contentPosition, label, false, false, args.selected, args.focused);
            }
        }
 protected override bool DoesItemMatchSearch(TreeViewItem item, string search)
 {
     return(SearchUtility.Matches(search, item.displayName));
 }
        protected override TreeViewItem BuildRoot()
        {
            var root = new TreeViewItem(-1, -1, "Root");

            root.children = new List <TreeViewItem>();

            if (targets != null && targets.Length == 1)
            {
                var target = targets[0];

                if (target == null)
                {
                    parentWindow.Close();

                    return(root);
                }

                // Build the minimal transform hierarchy
                var parents = new List <GameObject>();

                var currentParent = target;

                while (currentParent != null)
                {
                    parents.Add(currentParent);
                    currentParent = currentParent.transform.parent.AsUnityNull()?.gameObject;
                }

                parents.Reverse();

                var rootTransform = parents[0];
                var scene         = rootTransform.gameObject.scene;
                var sceneItem     = new SceneItem(scene);
                root.AddChild(sceneItem);
                Item currentParentItem = sceneItem;

                foreach (var parent in parents)
                {
                    var parentItem = new GameObjectItem(parent);
                    currentParentItem.AddChild(parentItem);
                    currentParentItem = parentItem;
                }

                AddChildrenRecursive((GameObjectItem)currentParentItem);

                // AddSiblings((GameObjectItem)currentParentItem);
            }
            else
            {
                var prefabStage = PrefabStageUtility.GetCurrentPrefabStage();

                if (prefabStage != null)
                {
                    // Build the prefab stage hierarchy

                    var prefabRoot     = prefabStage.prefabContentsRoot;
                    var prefabRootItem = new GameObjectItem(prefabRoot);

                    var stageItem = new PrefabStageItem(prefabStage);
                    AddChildrenRecursive(prefabRootItem);
                    stageItem.AddChild(prefabRootItem);
                    root.AddChild(stageItem);
                }
                else
                {
                    // Build the full scene hierarchy

                    for (var i = 0; i < SceneManager.sceneCount; i++)
                    {
                        var scene = SceneManager.GetSceneAt(i);

                        if (!scene.IsValid())
                        {
                            continue;
                        }

                        var sceneItem = new SceneItem(scene);

                        if (scene.isLoaded)
                        {
                            foreach (var sceneRootGameObject in scene.GetRootGameObjects())
                            {
                                var sceneRootGameObjectItem = new GameObjectItem(sceneRootGameObject);

                                AddChildrenRecursive(sceneRootGameObjectItem);

                                sceneItem.AddChild(sceneRootGameObjectItem);
                            }
                        }

                        root.AddChild(sceneItem);
                    }
                }
            }

            // Override with search if needed
            if (hasSearch)
            {
                var searchRoot    = new TreeViewItem(-1, -1, "Results");
                var searchResults = new List <TreeViewItem>();

                var treeViewItemStack = new Stack <TreeViewItem>();
                treeViewItemStack.Push(root);

                while (treeViewItemStack.Count > 0)
                {
                    var treeViewItem = treeViewItemStack.Pop();

                    if (treeViewItem.children != null)
                    {
                        foreach (var child in treeViewItem.children)
                        {
                            if (child != null)
                            {
                                if (DoesItemMatchSearch(child, searchString))
                                {
                                    searchResults.Add(child);
                                }

                                treeViewItemStack.Push(child);
                            }
                        }
                    }
                }

                foreach (var searchResult in searchResults)
                {
                    searchResult.children = null;
                }

                searchResults.Sort((x, y) => SearchUtility.Relevance(searchString, x.displayName).CompareTo(SearchUtility.Relevance(searchString, y.displayName)));
                searchRoot.children = searchResults;
                root = searchRoot;
            }

            SetupDepthsFromParentsAndChildren(root);

            hoveredItem = null;

            return(root);
        }
 public MovieRepository()
 {
     Movies = SearchUtility.GetMovies().AsQueryable();
 }
 public static void Reset()
 {
     SearchResults = SearchUtility.GetBooks().AsQueryable().OrderBy(book => book.Title);
 }
 public IActionResult RemoveBookResult(int libraryID)
 {
     InventoryManager.RemoveBook(SearchUtility.GetBookByLibraryID(libraryID));
     return(View());
 }