public void Dispose()
            {
                if (_disposed)
                {
                    throw new ObjectDisposedException(nameof(LockInstance),
                                                      $"This lock {LockType} for {InstanceId} has already been disposed");
                }

                _lockRepository.ReleaseLock(LockType, InstanceId);
                _lockManager.LockReleased(this);
                _disposed = true;
            }
Exemple #2
0
        public void RemoveLockPageEvent(string id, string entityName, string groupName)
        {
            string _user = _userManager.GetUserName(Context.User);

            try
            {
                _lockManager.ReleaseLock(int.Parse(id), entityName, _user);
                Clients.All.SendAsync("updateListLockReleased", new { Id = id });

                Clients.Group(groupName)
                .SendAsync("informGroupLockReleased", new { Message = $"The user {_user} has finished and realeased the lock. Please, refresh the page." });
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Exemple #3
0
        public IActionResult Edit(int id, EventDTO obj, string cancel, string notify)
        {
            string _user      = _userManager.GetUserName(this.User);
            string _groupName = $"{_entityName}-{id}";

            if (!string.IsNullOrEmpty(cancel))
            {
                if (_lockRepository.HasLock(obj.Id, _entityName, _user))
                {
                    _lockRepository.ReleaseLock(obj.Id, _entityName, _user);
                    _signalREventService.InformLockReleased(_groupName, id, _user);
                }

                return(RedirectToAction("index"));
            }

            if (!string.IsNullOrEmpty(notify))
            {
                TempData["Notification"] = "You will be notified as soon as the user finish working on this document.";
                return(View(obj));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _repository.Update(_mapper.Map <Event>(obj), _user);
                    _signalREventService.InformLockReleased(_groupName, id, _user);

                    return(RedirectToAction(nameof(Index)));
                }
                catch (ConcurrencyException ex)
                {
                    ModelState.AddModelError("", ex.Message);
                    return(View(obj));
                }
            }
            return(View(obj));
        }