コード例 #1
0
        public void AddRedisEvent(ISession _session, string key, object value, string EncyptedKey)
        {
            if (!string.IsNullOrEmpty(key) && value != null)
            {
                if (!_session.IsAvailable)
                {
                    _session.LoadAsync();
                }
                if (value != null)
                {
                    string Data = JsonConvert.SerializeObject(value);
                    if (!string.IsNullOrEmpty(EncyptedKey))
                    {
                        Data = SessionDataEncyptedDecrypted.Encrypt(Data, EncyptedKey);
                    }


                    _session.SetString(key, Data);
                    _session.CommitAsync();
                }
            }



            //_domainEvents = _domainEvents ?? new List<INotification>();
            //_domainEvents.Add(eventItem);
        }
コード例 #2
0
        public T GetRedisEvent <T>(ISession _session, string key, string EncyptedKey)
        {
            try
            {
                string data = _session.GetString(key);

                if (data != null)
                {
                    if (!string.IsNullOrEmpty(EncyptedKey))
                    {
                        data = SessionDataEncyptedDecrypted.Decrypt(data, EncyptedKey);
                    }
                }

                return(data == null ? default(T) : JsonConvert.DeserializeObject <T>(data));
            }
            catch (Exception ex)
            {
                throw;
            }
        }