예제 #1
0
 public IEnumerable <Tags> GetTags(TagSort sort)
 {
     return(sort switch
     {
         TagSort.Count => Context.FullTags.OrderByDescending(t => t.ArticleTag.Count).ThenBy(t => t.TagName),
         _ => Context.FullTags.OrderBy(t => t.TagName)
     });
예제 #2
0
        /// <summary>
        /// Sorts the InternalItemList based on the specified tag sort.
        /// </summary>
        /// <param name="tagSort">The tag sort.</param>
        internal void Sort(TagSort tagSort)
        {
            InternalItemComparer internalItemComparer = new InternalItemComparer(tagSort.IsTag, tagSort.TagName, new List <SortOrder>(1)
            {
                tagSort.SortOrder
            });

            itemList.Sort(internalItemComparer);
        }
 /// <summary>
 /// Sorts according to the specified tag sort.
 /// </summary>
 /// <param name="tagSort">The tag sort.</param>
 internal void Sort(TagSort tagSort)
 {
     InternalItemList.Sort(tagSort);
 }
예제 #4
0
파일: TagMethods.cs 프로젝트: svick/stacky
 public virtual IPagedList<Tag> GetTags(TagSort sortBy = TagSort.Popular, SortDirection sortDirection = SortDirection.Descending, int? page = null, int? pageSize = null)
 {
     return GetTags("tags", null, sortBy.ToString().ToLower(), GetSortDirection(sortDirection), page, pageSize);
 }
예제 #5
0
        /// <summary>
        /// Processes the specified intersection query.
        /// </summary>
        /// <param name="intersectionQuery">The intersection query.</param>
        /// <param name="messageContext">The message context.</param>
        /// <param name="storeContext">The store context.</param>
        /// <returns>IntersectionQueryResult</returns>
        internal static IntersectionQueryResult Process(IntersectionQuery intersectionQuery,
                                                        MessageContext messageContext,
                                                        IndexStoreContext storeContext)
        {
            //Fetch each index (assume all indexes are local) and perform intersection and return the results
            IntersectionQueryResult          intersectionQueryResult;
            List <IndexDataItem>             resultItemList            = null;
            Dictionary <byte[], IndexHeader> indexIdIndexHeaderMapping = new Dictionary <byte[], IndexHeader>(new ByteArrayEqualityComparer());
            List <string>    localIdentityTagNames = null;
            bool             isTagPrimarySort      = false;
            string           sortFieldName         = null;
            List <SortOrder> sortOrderList         = null;
            StringBuilder    exceptionInfo         = new StringBuilder();

            try
            {
                if (intersectionQuery.IndexIdList.Count > 0)
                {
                    IndexTypeMapping indexTypeMapping =
                        storeContext.StorageConfiguration.CacheIndexV3StorageConfig.IndexTypeMappingCollection[messageContext.TypeId];
                    ValidateQuery(indexTypeMapping, intersectionQuery);

                    #region Set sort vars

                    Index targetIndexInfo = indexTypeMapping.IndexCollection[intersectionQuery.TargetIndexName];
                    localIdentityTagNames = indexTypeMapping.IndexCollection[intersectionQuery.TargetIndexName].LocalIdentityTagList;
                    bool    sortFieldPartOfLocalId = IsSortFieldPartOfLocalId(localIdentityTagNames, targetIndexInfo.PrimarySortInfo);
                    TagSort itemIdTagSort          = new TagSort("ItemId", false, new SortOrder(DataType.Int32, SortBy.ASC));

                    if (!sortFieldPartOfLocalId)
                    {
                        //Set sort vars
                        isTagPrimarySort = itemIdTagSort.IsTag;
                        sortFieldName    = itemIdTagSort.TagName;
                        sortOrderList    = new List <SortOrder>(1)
                        {
                            itemIdTagSort.SortOrder
                        };
                    }
                    else
                    {
                        isTagPrimarySort = targetIndexInfo.PrimarySortInfo.IsTag;
                        sortFieldName    = targetIndexInfo.PrimarySortInfo.FieldName;
                        sortOrderList    = targetIndexInfo.PrimarySortInfo.SortOrderList;
                    }

                    #endregion

                    #region Fetch CacheIndexInternal and Intersect

                    CacheIndexInternal      targetIndex;
                    CacheIndexInternal      resultCacheIndexInternal = null;
                    IntersectionQueryParams indexIdParam;
                    byte[] indexId;
                    byte[] metadata;
                    MetadataPropertyCollection metadataPropertyCollection;

                    for (int i = 0; i < intersectionQuery.IndexIdList.Count; i++)
                    {
                        #region Extract index and apply criteria

                        indexId      = intersectionQuery.IndexIdList[i];
                        indexIdParam = intersectionQuery.GetIntersectionQueryParamForIndexId(indexId);
                        // Note: This should be changed later and just extracted once if it is also requested in GetIndexHeader
                        metadata = null;
                        metadataPropertyCollection = null;
                        if (indexTypeMapping.MetadataStoredSeperately)
                        {
                            IndexServerUtils.GetMetadataStoredSeperately(indexTypeMapping,
                                                                         messageContext.TypeId,
                                                                         messageContext.PrimaryId,
                                                                         indexId,
                                                                         storeContext,
                                                                         out metadata,
                                                                         out metadataPropertyCollection);
                        }

                        targetIndex = IndexServerUtils.GetCacheIndexInternal(storeContext,
                                                                             messageContext.TypeId,
                                                                             (intersectionQuery.PrimaryIdList != null && i < intersectionQuery.PrimaryIdList.Count) ?
                                                                             intersectionQuery.PrimaryIdList[i] :
                                                                             IndexCacheUtils.GeneratePrimaryId(indexId),
                                                                             indexId,
                                                                             targetIndexInfo.ExtendedIdSuffix,
                                                                             intersectionQuery.TargetIndexName,
                                                                             indexIdParam.Count,
                                                                             indexIdParam.Filter,
                                                                             true,
                                                                             indexIdParam.IndexCondition,
                                                                             false,
                                                                             false,
                                                                             targetIndexInfo.PrimarySortInfo,
                                                                             targetIndexInfo.LocalIdentityTagList,
                                                                             targetIndexInfo.StringHashCodeDictionary,
                                                                             null,
                                                                             targetIndexInfo.IsMetadataPropertyCollection,
                                                                             metadataPropertyCollection,
                                                                             intersectionQuery.DomainSpecificProcessingType,
                                                                             storeContext.DomainSpecificConfig,
                                                                             null,
                                                                             null,
                                                                             false);

                        #endregion

                        if (targetIndex != null)
                        {
                            if (targetIndex.Count <= 0)
                            {
                                // No items in one of the indexes. Stop Interestion !!
                                resultCacheIndexInternal = null;
                                break;
                            }

                            PerformanceCounters.Instance.SetCounterValue(
                                PerformanceCounterEnum.NumOfItemsInIndexPerIntersectionQuery,
                                messageContext.TypeId,
                                targetIndex.OutDeserializationContext.TotalCount);

                            PerformanceCounters.Instance.SetCounterValue(
                                PerformanceCounterEnum.NumOfItemsReadPerIntersectionQuery,
                                messageContext.TypeId,
                                targetIndex.OutDeserializationContext.ReadItemCount);

                            if (!sortFieldPartOfLocalId)
                            {
                                //Need to sort indexes by item id
                                targetIndex.Sort(itemIdTagSort);
                            }

                            #region Intersection

                            if (resultCacheIndexInternal == null)
                            {
                                // No need to perform intersection for first index
                                resultCacheIndexInternal = targetIndex;
                            }
                            else
                            {
                                IntersectionAlgo.Intersect(isTagPrimarySort,
                                                           sortFieldName,
                                                           localIdentityTagNames,
                                                           sortOrderList,
                                                           resultCacheIndexInternal.InternalItemList,
                                                           targetIndex.InternalItemList,
                                                           intersectionQuery.MaxResultItems,
                                                           i == intersectionQuery.IndexIdList.Count - 1 ? intersectionQuery.IsSingleClusterQuery : false);

                                if (resultCacheIndexInternal == null || resultCacheIndexInternal.Count < 1)
                                {
                                    // Unable to fetch one of the indexes. Stop Interestion !!
                                    resultCacheIndexInternal  = null;
                                    indexIdIndexHeaderMapping = null;
                                    break;
                                }
                            }

                            #endregion
                        }
                        else
                        {
                            // Unable to fetch one of the indexes. Stop Interestion !!
                            resultCacheIndexInternal  = null;
                            indexIdIndexHeaderMapping = null;
                            break;
                        }

                        #region Get MetaData

                        if (intersectionQuery.GetIndexHeader)
                        {
                            if (!indexIdIndexHeaderMapping.ContainsKey(indexId))
                            {
                                indexIdIndexHeaderMapping.Add(indexId,
                                                              IndexServerUtils.GetIndexHeader(targetIndex, indexTypeMapping, messageContext.TypeId, IndexCacheUtils.GeneratePrimaryId(indexId), storeContext));
                            }
                        }

                        #endregion
                    }
                    if (resultCacheIndexInternal != null && resultCacheIndexInternal.Count > 0)
                    {
                        resultItemList = CacheIndexInternalAdapter.GetIndexDataItemList(resultCacheIndexInternal, 1, int.MaxValue);
                    }

                    #endregion

                    #region Get data

                    if (!intersectionQuery.ExcludeData && resultItemList != null && resultItemList.Count > 0)
                    {
                        DataTierUtil.GetData(resultItemList,
                                             storeContext,
                                             messageContext,
                                             indexTypeMapping.FullDataIdFieldList,
                                             intersectionQuery.FullDataIdInfo);
                    }

                    #endregion
                }

                intersectionQueryResult = new IntersectionQueryResult(resultItemList,
                                                                      indexIdIndexHeaderMapping,
                                                                      localIdentityTagNames,
                                                                      isTagPrimarySort,
                                                                      sortFieldName,
                                                                      sortOrderList,
                                                                      exceptionInfo.ToString());

                // update performance counter
                PerformanceCounters.Instance.SetCounterValue(
                    PerformanceCounterEnum.IndexLookupAvgPerIntersectionQuery,
                    messageContext.TypeId,
                    intersectionQuery.IndexIdList.Count);
            }
            catch (Exception ex)
            {
                exceptionInfo.Append(" | " + ex.Message);
                intersectionQueryResult = new IntersectionQueryResult(null, null, null, false, null, null, exceptionInfo.ToString());
                LoggingUtil.Log.ErrorFormat("TypeId {0} -- Error processing IntersectionQuery : {1}", messageContext.TypeId, ex);
            }
            return(intersectionQueryResult);
        }
예제 #6
0
 private void Tag_StateChange(object sender, EventArgs e)
 {
     TagSort?.Invoke(sender, EventArgs.Empty);
 }
예제 #7
0
        public static void LoadSettings(bool applyThemeAswell = false)
        {
            // Declare Registry
            var keyApp = Registry.CurrentUser.CreateSubKey("Software\\Xeraxic\\Assembly\\ApplicationSettings\\");
            // Create a JSON Seralizer
            var jss = new JavaScriptSerializer();

            if (keyApp != null)
            {
                applicationAccent = (Accents)keyApp.GetValue("accent", 0);
                applicationEasterEggs = Convert.ToBoolean(keyApp.GetValue("easterEggs", true));
                applicationUpdateOnStartup = Convert.ToBoolean(keyApp.GetValue("CheckUpdatesOnStartup", true));
                if (applyThemeAswell)
                    ApplyAccent();

                applicationRecents = jss.Deserialize<List<RecentFileEntry>>(keyApp.GetValue("RecentFiles", "").ToString());
                applicationXBDMSidebarLocation = (Home.XBDMSidebarLocations)keyApp.GetValue("XBDMSidebarLocation", 0);
                applicationSizeWidth = Convert.ToSingle(keyApp.GetValue("SizeWidth", 1100));
                applicationSizeHeight = Convert.ToSingle(keyApp.GetValue("SizeHeight", 600));
                applicationSizeMaximize = Convert.ToBoolean(keyApp.GetValue("SizeMaxamize", false));

                XDKNameIP = keyApp.GetValue("XDKNameIP", "192.168.1.0").ToString();
                if (xbdm != null)
                {
                    xbdm.UpdateDeviceIdent(XDKNameIP);
                    //try { xbdm.Connect(); } catch { }
                }
                XDKAutoSave = Convert.ToBoolean(keyApp.GetValue("XDKAutoSave", true));
                XDKScreenshotPath = keyApp.GetValue("XDKScreenshotPath", VariousFunctions.GetApplicationLocation() + @"Saved Images\").ToString();
                XDKResizeImages = Convert.ToBoolean(keyApp.GetValue("XDKScreenshotResize", true));
                XDKResizeScreenshotHeight = Convert.ToInt16(keyApp.GetValue("XDKScreenshotHeight", 1080));
                XDKResizeScreenshotWidth = Convert.ToInt16(keyApp.GetValue("XDKScreenshotWidth", 1920));
                XDKScreenshotGammaCorrect = Convert.ToBoolean(keyApp.GetValue("XDKScreenGammaCorrect", true));
                XDKScreenshotGammaModifier = Convert.ToDouble(keyApp.GetValue("XDKScreenModifier", 0.5));
                XDKScreenshotFreeze = Convert.ToBoolean(keyApp.GetValue("XDKScreenFreeze", false));

                startpageShowOnLoad = Convert.ToBoolean(keyApp.GetValue("ShowStartPageOnLoad", true));
                startpageHideOnLaunch = Convert.ToBoolean(keyApp.GetValue("HideStartPageOnLaunch", false));
                startpageShowRecentsMap = Convert.ToBoolean(keyApp.GetValue("ShowRecentsMap", true));
                startpageShowRecentsBLF = Convert.ToBoolean(keyApp.GetValue("ShowRecentsBLF", true));
                startpageShowRecentsMapInfo = Convert.ToBoolean(keyApp.GetValue("ShowRecentsMapInfo", true));

                halomapTagSort = (TagSort)keyApp.GetValue("TagSorting", 0);
                halomapShowEmptyClasses = Convert.ToBoolean(keyApp.GetValue("ShowEmptyClasses", false));
                halomapLastSelectedMetaEditor = (LastMetaEditorType)keyApp.GetValue("LastSelectedMetaEditor", 0);
                halomapMapInfoDockSide = (MapInfoDockSide)keyApp.GetValue("MapInfoDockSide", 0);

                pluginsShowInvisibles = Convert.ToBoolean(keyApp.GetValue("ShowInvisibles", false));
                pluginsShowComments = Convert.ToBoolean(keyApp.GetValue("ShowComments", true));

                defaultMAP = Convert.ToBoolean(keyApp.GetValue("DefaultMAPEditor", true));
                defaultBLF = Convert.ToBoolean(keyApp.GetValue("DefaultBLFEditor", false));
                defaultMIF = Convert.ToBoolean(keyApp.GetValue("DefaultMIFEditor", false));
                defaultAMP = Convert.ToBoolean(keyApp.GetValue("DefaultAMPEditor", true));
            }

            OnSettingsChanged();
        }
예제 #8
0
 public virtual IPagedList <Tag> GetTags(TagSort sortBy = TagSort.Popular, SortDirection sortDirection = SortDirection.Descending, int?page = null, int?pageSize = null)
 {
     return(GetTags("tags", null, sortBy.ToString().ToLower(), GetSortDirection(sortDirection), page, pageSize));
 }
예제 #9
0
파일: TagMethods.cs 프로젝트: lfoust/stacky
 public virtual void GetTags(Action <IPagedList <Tag> > onSuccess, Action <ApiException> onError, TagSort sortBy = TagSort.Popular, SortDirection sortDirection = SortDirection.Descending, int?page = null, int?pageSize = null)
 {
     GetTags(onSuccess, onError, "tags", null, sortBy.ToString().ToLower(), GetSortDirection(sortDirection), page, pageSize);
 }
예제 #10
0
파일: TagMethods.cs 프로젝트: svick/stacky
 public virtual void GetTags(Action<IPagedList<Tag>> onSuccess, Action<ApiException> onError = null, TagSort sortBy = TagSort.Popular, SortDirection sortDirection = SortDirection.Descending, int? page = null, int? pageSize = null)
 {
     GetTags(onSuccess, onError, "tags", null, sortBy.ToString().ToLower(), GetSortDirection(sortDirection), page, pageSize);
 }