コード例 #1
0
        public override void SetJobState([NotNull] string jobId, [NotNull] IState state)
        {
            if (jobId == null)
            {
                throw new ArgumentNullException(nameof(jobId));
            }
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            //_transaction.HashSetAsync(_storage.GetRedisKey($"job:{jobId}"), "State", state.Name);
            redisClientPipe.HSet(_storage.GetRedisKey($"job:{jobId}"), "State", state.Name);
            //_transaction.KeyDeleteAsync(_storage.GetRedisKey($"job:{jobId}:state"));
            redisClientPipe.Del(_storage.GetRedisKey($"job:{jobId}:state"));

            var storedData = new Dictionary <string, string>(state.SerializeData())
            {
                { "State", state.Name }
            };

            if (state.Reason != null)
            {
                storedData.Add("Reason", state.Reason);
            }

            //_transaction.HashSetAsync(_storage.GetRedisKey($"job:{jobId}:state"), storedData.ToHashEntries());
            redisClientPipe.HMSet(_storage.GetRedisKey($"job:{jobId}:state"), storedData.DicToObjectArray());

            AddJobState(jobId, state);
        }