Example #1
0
        public async Task <string> GetHashNodeKey(HashGroup group, string key, params int[] status)
        {
            long intKey;

            try
            {
                intKey = Convert.ToInt64(key);
            }
            catch
            {
                intKey = key.ToInt();
            }

            intKey = intKey % group.Count;

            var node = await _hashNodeStore.QueryFirstByGreaterCode(group.ID, intKey, status);

            if (node == null)
            {
                node = await _hashNodeStore.QueryByMinCode(group.ID, status);
            }

            if (node == null)
            {
                var fragment = new TextFragment()
                {
                    Code = TextCodes.NotFoundHashNodeByGroup,
                    DefaultFormatting = "没有找到名称为{0}的哈希组的任何节点",
                    ReplaceParameters = new List <object>()
                    {
                        group.Name
                    }
                };

                throw new UtilityException((int)Errors.NotFoundHashNodeByGroup, fragment);
            }

            return(node.RealNode.NodeKey);
        }
Example #2
0
 public async Task <HashNode> GetMinCode(HashGroup group, params int[] status)
 {
     return(await _hashNodeStore.QueryByMinCode(group.ID, status));
 }