Example #1
0
        private void Save()
        {
            try
            {
                var session = ZenSession.Get(Id) ?? new ZenSession {
                    Id = Id
                };

                var mustSave = _isModified || session.LastUpdate?.AddSeconds(60) < DateTime.Now;

                if (!mustSave)
                {
                    return;
                }

                session.Store      = _store;
                session.LastUpdate = DateTime.Now;
                session.Save();
            }
            catch (Exception exception)
            {
                Base.Current.Log.Warn <ZenDistributedSession>($"Write Exception: {Id}");
                Base.Current.Log.Add <ZenDistributedSession>(exception);
            }
        }
Example #2
0
        private void Load()
        {
            if (_sourceModel != null)
            {
                return;
            }

            try
            {
                _sourceModel = ZenSession.Get(Id) ?? new ZenSession {
                    Id = Id
                };

                if (_sourceModel != null)
                {
                    FetchFromSourceModel();
                }

                _isAvailable = true;
                _isModified  = false;
            }
            catch (Exception exception)
            {
                Base.Current.Log.Warn <ZenDistributedSession>($"Read Exception: {Id}");
                Base.Current.Log.Add <ZenDistributedSession>(exception);

                _isAvailable = false;
                Id           = null;
                _store       = null;
            }
        }