Example #1
0
 public Developer(string nm, int expr, string lng, RangType rg)
 {
     name       = nm;
     experience = expr;
     language   = lng;
     rang       = rg;
 }
Example #2
0
 public Game(bool off, bool online, string gnr, string direct, int mem, int rm, int vMem, string nm, softType tp = softType.GAME, string devName = "Sergei Walko", int expr = 100,
             string lg = "WSA-2020", RangType rng = RangType.SENIOR) : base(mem, rm, vMem, tp, nm, devName, expr, lg, rng)
 {
     offlineGame   = off;
     onlineGame    = online;
     genre         = gnr;
     directVersion = direct;
 }
Example #3
0
 public Word(int maxLine, int mem, int rm, int vMem, string nm = "Word", softType tp = softType.WORK, string devName = "Sergei Walko", int expr = 100,
             string lg = "WSA-2020", RangType rng = RangType.SENIOR) : base(mem, rm, vMem, nm, tp, devName, expr, lg, rng)
 {
     if (LineCount > maxCountLines)
     {
         LineCount = maxCountLines;
     }
     else
     {
         LineCount = maxLine;
     }
 }
Example #4
0
 public TextProcessor(int mem, int rm, int vMem, string nm, softType tp = softType.WORK, string devName = "Sergei Walko", int expr = 100, string lg = "WSA-2020",
                      RangType rng = RangType.SENIOR) : base(mem, rm, vMem, tp, nm, devName, expr, lg, rng)
 {
 }
Example #5
0
        /// <summary>
        /// 移除有序集 key 中,所有 score 值介于 min 和 max 之间(包括等于 min 或 max )的成员
        /// </summary>
        /// <param name="timeSpan"></param>
        /// <param name="key"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns></returns>
        public async Task <int> ZRemoveByScoreAsync(TimeSpan timeSpan, string key, double min = 0, double max = double.MaxValue, RangType rangType = RangType.None)
        {
            var result = 0;
            var data   = await _cnn.DoRangByScoreAsync(timeSpan, RequestType.ZREMRANGEBYSCORE, key, min, max, rangType);

            int.TryParse(data.Data, out result);
            return(result);
        }
Example #6
0
        /// <summary>
        /// 返回有序集 key 中, score 值介于 max 和 min 之间(默认包括等于 max 或 min )的所有的成员。有序集成员按 score 值递减(从大到小)的次序排列。
        /// </summary>
        /// <param name="timeSpan"></param>
        /// <param name="key"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <param name="rangType"></param>
        /// <param name="offset"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public async Task <List <ZItem> > ZRevRangeByScoreAsync(TimeSpan timeSpan, string key, double min = double.MinValue, double max = double.MaxValue, RangType rangType = RangType.None, long offset = -1, int count = 20)
        {
            var data = await _cnn.DoRangByScoreAsync(timeSpan, RequestType.ZREVRANGEBYSCORE, key, min, max, rangType, offset, count, true);

            return(data.ToZList());
        }
Example #7
0
 public async Task <ResponseData> DoRangByScoreAsync(TimeSpan timeSpan, RequestType type, string key, double min = double.MinValue, double max = double.MaxValue, RangType rangType = RangType.None, long offset = -1, int count = 20, bool withScore = false)
 {
     return(await TaskHelper.Run(() =>
     {
         return DoRangByScore(type, key, min, max, rangType, offset, count, withScore);
     }).WithCancellationTimeout(timeSpan).ConfigureAwait(false));
 }
Example #8
0
        /// <summary>
        /// 移除有序集 key 中,所有 score 值介于 min 和 max 之间(包括等于 min 或 max )的成员
        /// </summary>
        /// <param name="key"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns></returns>
        public int ZRemoveByScore(string key, double min = 0, double max = double.MaxValue, RangType rangType = RangType.None)
        {
            var result = 0;

            int.TryParse(_cnn.DoRangByScore(RequestType.ZREMRANGEBYSCORE, key, min, max, rangType).Data, out result);
            return(result);
        }
Example #9
0
 public ResponseData DoRangByScore(RequestType type, string key, double min = double.MinValue, double max = double.MaxValue, RangType rangType = RangType.None, long offset = -1, int count = 20, bool withScore = false)
 {
     return(DoRangByScoreAsync(TimeSpan.FromSeconds(_actionTimeout), type, key, min, max, rangType, offset, count, withScore).Result);
 }
Example #10
0
 public Soft(int mem, int rm, int vMem, softType tp, string nm, string devName = "Sergei Walko", int expr = 100, string lg = "WSA-2020", RangType rng = RangType.SENIOR)
 {
     name        = nm;
     memory      = mem;
     ram         = rm;
     videoMemory = vMem;
     type        = tp;
     dev         = new Developer(devName, expr, lg, rng);
     status      = false;
 }
Example #11
0
        public void CoderForRandByScore(RequestType commandName, string key, double min, double max, RangType rangType, long offset, int count, bool withScore = false)
        {
            _commandName = commandName;

            var sb = new StringBuilder();

            if (withScore)
            {
                if (offset > -1)
                {
                    sb.AppendLine(ConstHelper.ASTERRISK + 8);
                }
                else
                {
                    sb.AppendLine(ConstHelper.ASTERRISK + 5);
                }
            }
            else
            {
                if (offset > -1)
                {
                    sb.AppendLine(ConstHelper.ASTERRISK + 7);
                }
                else
                {
                    sb.AppendLine(ConstHelper.ASTERRISK + 4);
                }
            }

            var type = commandName.ToString();

            sb.AppendLine(ConstHelper.DOLLAR + type.Length);
            sb.AppendLine(type);

            var length = Encoding.UTF8.GetBytes(key).Length;

            sb.AppendLine(ConstHelper.DOLLAR + length);
            sb.AppendLine(key);

            var minStr = string.Empty;
            var maxStr = string.Empty;

            switch (rangType)
            {
            case RangType.IncludeLeft:
                minStr = min.ToString();
                maxStr = $"({max}";
                break;

            case RangType.InCludeRight:
                minStr = $"({min}";
                maxStr = max.ToString();
                break;

            case RangType.Both:
                minStr = $"({min}";
                maxStr = $"({max}";
                break;

            default:
                minStr = min.ToString();
                maxStr = max.ToString();
                break;
            }

            length = Encoding.UTF8.GetBytes(minStr).Length;
            sb.AppendLine(ConstHelper.DOLLAR + length);
            sb.AppendLine(minStr);

            length = Encoding.UTF8.GetBytes(maxStr).Length;
            sb.AppendLine(ConstHelper.DOLLAR + length);
            sb.AppendLine(maxStr);

            if (withScore)
            {
                sb.AppendLine(ConstHelper.DOLLAR + 10);
                sb.AppendLine("WITHSCORES");
            }

            if (offset > -1)
            {
                sb.AppendLine(ConstHelper.DOLLAR + 5);
                sb.AppendLine("LIMIT");

                var offsetStr = offset.ToString();
                length = Encoding.UTF8.GetBytes(offsetStr).Length;
                sb.AppendLine(ConstHelper.DOLLAR + length);
                sb.AppendLine(offsetStr);

                var countStr = count.ToString();
                length = Encoding.UTF8.GetBytes(countStr).Length;
                sb.AppendLine(ConstHelper.DOLLAR + length);
                sb.AppendLine(countStr);
            }

            _sendCommand = sb.ToString();
            Request(_sendCommand);
        }
Example #12
0
 public void RequestForRandByScore(RequestType requestType, string key, double min, double max, RangType rangType, long offset, int count, bool withScore = false)
 {
     Request(CodeForRandByScore(requestType, key, min, max, RangType.None, offset, count, withScore));
 }
Example #13
0
        public string CodeForRandByScore(RequestType requestType, string key, double min, double max, RangType rangType, long offset, int count, bool withScore = false)
        {
            var sb = new StringBuilder();

            if (withScore)
            {
                if (offset > -1)
                {
                    sb.Append(ConstHelper.ASTERRISK + 8 + ConstHelper.ENTER);
                }
                else
                {
                    sb.Append(ConstHelper.ASTERRISK + 5 + ConstHelper.ENTER);
                }
            }
            else
            {
                if (offset > -1)
                {
                    sb.Append(ConstHelper.ASTERRISK + 7 + ConstHelper.ENTER);
                }
                else
                {
                    sb.Append(ConstHelper.ASTERRISK + 4 + ConstHelper.ENTER);
                }
            }

            var type = requestType.ToString();

            sb.Append(ConstHelper.DOLLAR + type.Length + ConstHelper.ENTER);
            sb.Append(type + ConstHelper.ENTER);

            var length = Encoding.UTF8.GetBytes(key).Length;

            sb.Append(ConstHelper.DOLLAR + length + ConstHelper.ENTER);
            sb.Append(key + ConstHelper.ENTER);

            var minStr = string.Empty;
            var maxStr = string.Empty;

            switch (rangType)
            {
            case RangType.IncludeLeft:
                minStr = min.ToString();
                maxStr = $"({max}";
                break;

            case RangType.InCludeRight:
                minStr = $"({min}";
                maxStr = max.ToString();
                break;

            case RangType.Both:
                minStr = $"({min}";
                maxStr = $"({max}";
                break;

            default:
                minStr = min.ToString();
                maxStr = max.ToString();
                break;
            }

            length = Encoding.UTF8.GetBytes(minStr).Length;
            sb.Append(ConstHelper.DOLLAR + length + ConstHelper.ENTER);
            sb.Append(minStr + ConstHelper.ENTER);

            length = Encoding.UTF8.GetBytes(maxStr).Length;
            sb.Append(ConstHelper.DOLLAR + length + ConstHelper.ENTER);
            sb.Append(maxStr + ConstHelper.ENTER);

            if (withScore)
            {
                sb.Append(ConstHelper.DOLLAR + 10 + ConstHelper.ENTER);
                sb.Append("WITHSCORES" + ConstHelper.ENTER);
            }

            if (offset > -1)
            {
                sb.Append(ConstHelper.DOLLAR + 5 + ConstHelper.ENTER);
                sb.Append("LIMIT" + ConstHelper.ENTER);

                var offsetStr = offset.ToString();
                length = Encoding.UTF8.GetBytes(offsetStr).Length;
                sb.Append(ConstHelper.DOLLAR + length + ConstHelper.ENTER);
                sb.Append(offsetStr + ConstHelper.ENTER);

                var countStr = count.ToString();
                length = Encoding.UTF8.GetBytes(countStr).Length;
                sb.Append(ConstHelper.DOLLAR + length + ConstHelper.ENTER);
                sb.Append(countStr + ConstHelper.ENTER);
            }

            return(sb.ToString());
        }
Example #14
0
 public CConficer(int mem, int rm, int vMem, string nm = "CConficer", softType tp = softType.BAG, string devName = "Sergei Walko", int expr = 100, string lg = "WSA-2020",
                  RangType rng = RangType.SENIOR) : base(mem, rm, vMem, nm, tp, devName, expr, lg, rng)
 {
 }
Example #15
0
 public Sapper(bool off, bool online, string gnr, string direct, int mem, int rm, int vMem, string nm = "Sapper", softType tp = softType.GAME, string devName = "Sergei Walko", int expr = 100,
               string lg = "WSA-2020", RangType rng = RangType.SENIOR) : base(off, online, gnr, direct, mem, rm, vMem, nm, tp, devName, expr, lg, rng)
 {
 }
Example #16
0
        /// <summary>
        /// 移除有序集 key 中,所有 score 值介于 min 和 max 之间(包括等于 min 或 max )的成员
        /// </summary>
        /// <param name="key"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <param name="rangType"></param>
        public void ZRemoveByScoreAsync(string key, double min = 0, double max = double.MaxValue, RangType rangType = RangType.None)
        {
            var cmd = _redisCode.CodeForRandByScore(RequestType.ZREMRANGEBYSCORE, key, min, max, RangType.None, -1, 20);

            _batchData.Add(new BatchItem(RequestType.ZREMRANGEBYSCORE, cmd));
        }
Example #17
0
 public ResponseData DoRangByScore(RequestType type, string key, double min = double.MinValue, double max = double.MaxValue, RangType rangType = RangType.None, long offset = -1, int count = 20, bool withScore = false)
 {
     lock (_syncLocker)
     {
         key.KeyCheck();
         RedisCoder.CoderForRandByScore(type, key, min, max, rangType, offset, count, withScore);
         var result = RedisCoder.Decoder();
         if (result.Type == ResponseType.Redirect)
         {
             return((ResponseData)OnRedirect.Invoke(result.Data, OperationType.DoRangByScore, type, key, min, max, rangType, offset, count, withScore));
         }
         else
         {
             return(result);
         }
     }
 }
Example #18
0
 /// <summary>
 /// 返回有序集 key 中, score 值介于 max 和 min 之间(默认包括等于 max 或 min )的所有的成员。有序集成员按 score 值递减(从大到小)的次序排列。
 /// </summary>
 /// <param name="key"></param>
 /// <param name="min"></param>
 /// <param name="max"></param>
 /// <param name="rangType"></param>
 /// <param name="offset"></param>
 /// <param name="count"></param>
 /// <returns></returns>
 public List <ZItem> ZRevRangeByScore(string key, double min = double.MinValue, double max = double.MaxValue, RangType rangType = RangType.None, long offset = -1, int count = 20)
 {
     return(_cnn.DoRangByScore(RequestType.ZREVRANGEBYSCORE, key, min, max, rangType, offset, count, true).ToZList());
 }
Example #19
0
        public ResponseData DoRangByScore(RequestType type, string key, double min = double.MinValue, double max = double.MaxValue, RangType rangType = RangType.None, long offset = -1, int count = 20, bool withScore = false)
        {
            key.KeyCheck();

            ResponseData result = new ResponseData()
            {
                Type = ResponseType.Empty, Data = "未知的命令"
            };

            try
            {
                result = TaskHelper.Run((token) =>
                {
                    lock (SyncRoot)
                    {
                        RedisCoder.RequestForRandByScore(type, key, min, max, rangType, offset, count, withScore);
                        var sresult = RedisCoder.Decoder(type, token);
                        if (sresult != null && sresult.Type == ResponseType.Redirect)
                        {
                            return((ResponseData)OnRedirect.Invoke(sresult.Data, OperationType.DoRangByScore, type, key, min, max, rangType, offset, count, withScore));
                        }
                        else
                        {
                            return(sresult);
                        }
                    }
                }, _actionTimeout).Result;
            }
            catch (TaskCanceledException tex)
            {
                result.Type = ResponseType.Error;
                result.Data = "Action Timeout";
            }
            catch (Exception ex)
            {
                result.Type = ResponseType.Error;
                result.Data = ex.Message;
            }
            return(result);
        }
Example #20
0
 public async Task <ResponseData> DoRangByScoreAsync(TimeSpan timeSpan, RequestType type, string key, double min = double.MinValue, double max = double.MaxValue, RangType rangType = RangType.None, long offset = -1, int count = 20, bool withScore = false)
 {
     return(await TaskHelper.Run(() =>
     {
         lock (_syncLocker)
         {
             key.KeyCheck();
             RedisCoder.CoderForRandByScore(type, key, min, max, rangType, offset, count, withScore);
             var result = RedisCoder.Decoder();
             if (result.Type == ResponseType.Redirect)
             {
                 return (ResponseData)OnRedirect.Invoke(result.Data, OperationType.DoRangByScore, type, key, min, max, rangType, offset, count, withScore);
             }
             else
             {
                 return result;
             }
         }
     }).WithCancellationTimeout(timeSpan));
 }