Esempio n. 1
0
        public void AcquireLock(Guid serviceInstanceId, int pinId, int taskId)
        {
            if (pinId == 0)
            {
                return;
            }

            var dateTime = DateTime.Now;

            RetryableOperation.Invoke(ExceptionPolicies.General,
                                      () =>
            {
                // Check whether lock already exists
                var timerLock = _timerLockRepository.FirstOrDefault(x => x.LockedInstance == serviceInstanceId && x.LockedPin == pinId);

                if (timerLock == null)
                {
                    // Create new lock
                    var newLock = new TimerLock
                    {
                        LockedInstance = serviceInstanceId,
                        LockedPin      = pinId,
                        TaskId         = taskId,
                        InsertedBy     = _userIdentity.Name,
                        InsertedDate   = dateTime,
                        UpdatedBy      = _userIdentity.Name,
                        UpdatedDate    = dateTime
                    };

                    _timerLockRepository.Insert(newLock);
                    _unitOfWork.Save();
                }
            });
        }
Esempio n. 2
0
        public IEnumerable <Parameter> All()
        {
            IEnumerable <Parameter> result = null;

            RetryableOperation.Invoke(ExceptionPolicies.General, () => { result = _repository.All().ToList(); });
            return(result);
        }
Esempio n. 3
0
        public IQueryable <ServiceComponentListItem> GetByCustomerWithHierarchy(int customerId)
        {
            IQueryable <ServiceComponentListItem> result = null;

            RetryableOperation.Invoke(ExceptionPolicies.General, () =>
            {
                result = _serviceComponentRepository
                         .Query(x => x.ServiceFunction.ServiceDomain.ServiceDesk.CustomerId == customerId)
                         .Include(i => i.ChildServiceComponents)
                         .Include(i => i.Resolver)
                         .Include(i => i.Resolver.ServiceDeliveryOrganisationType)
                         .Include(i => i.Resolver.ServiceDeliveryUnitType)
                         .Include(i => i.Resolver.ResolverGroupType)
                         .AsNoTracking()
                         .Select(x => new ServiceComponentListItem
                {
                    ServiceDeskName   = x.ServiceFunction.ServiceDomain.ServiceDesk.DeskName,
                    ServiceDomainName = x.ServiceFunction.ServiceDomain.AlternativeName ??
                                        x.ServiceFunction.ServiceDomain.DomainType.DomainName,
                    ServiceFunctionId   = x.ServiceFunctionId,
                    ServiceFunctionName = x.ServiceFunction.AlternativeName ?? x.ServiceFunction.FunctionType.FunctionName,
                    ServiceComponent    = x
                });
            });

            return(result);
        }
Esempio n. 4
0
        public void CompleteUnrecoverableTaskException(Task task, string message)
        {
            RetryableOperation.Invoke(ExceptionPolicies.General,
                                      () =>
            {
                var timerLock = _timerLockRepository.Find(x => x.TaskId == task.Id).ToList();
                if (timerLock.Any())
                {
                    foreach (var lck in timerLock)
                    {
                        // Explicitly remove the timer lock
                        _timerLockRepository.Delete(lck);
                    }
                }

                // Create a history log
                var historyLog         = task.CreateHistoryLog(_userIdentity.Name);
                historyLog.EventType   = LoggingEventTypeNames.Error;
                historyLog.EventDetail = message;
                historyLog.Escalated   = false;
                _historyLogRepository.Insert(historyLog);

                // Delete the task
                _taskRepository.Delete(task);
                _unitOfWork.Save();
            });
        }
Esempio n. 5
0
        public T GetParameterByNameOrCreate <T>(string parameterName, T defaultValue, ParameterType parameterType)
        {
            var result = default(T);

            RetryableOperation.Invoke(ExceptionPolicies.General, () =>
            {
                var paramValue = _repository
                                 .Query(x => x.ParameterName == parameterName)
                                 .Select(s => s.ParameterValue)
                                 .SingleOrDefault();

                if (string.IsNullOrEmpty(paramValue))
                {
                    var entity = new Parameter
                    {
                        ParameterName  = parameterName,
                        ParameterValue = defaultValue.ConvertGenericValueToString(),
                        Type           = parameterType,
                        InsertedBy     = _userIdentity.Name,
                        InsertedDate   = DateTime.Now,
                        UpdatedBy      = _userIdentity.Name,
                        UpdatedDate    = DateTime.Now
                    };
                    _repository.Insert(entity);
                    result = defaultValue;
                }
                else
                {
                    result = paramValue.ConvertStringToGenericValue <T>();
                }
            });

            return(result);
        }
        public IEnumerable <ServiceDeliveryUnitTypeRefData> GetAllAndNotVisibleForCustomer(int customerId)
        {
            List <ServiceDeliveryUnitTypeRefData> result = null;

            RetryableOperation.Invoke(ExceptionPolicies.General, () =>
            {
                // Obtain all the visible resolver group types
                result = _serviceDeliveryUnitTypeRefDataRepository
                         .Query(x => x.Visible)
                         .ToList();


                // Add all the Non-Visible/Customer Unique Resolver Groups
                result.AddRange(_resolverRepository
                                .Query(x => x.ServiceDesk.CustomerId == customerId && !x.ServiceDeliveryUnitType.Visible)
                                .Select(x => x.ServiceDeliveryUnitType).Distinct()
                                .ToList());

                result = result
                         .OrderBy(x => x.SortOrder).ThenBy(x => x.ServiceDeliveryUnitTypeName)
                         .ToList();
            });

            return(result);
        }
Esempio n. 7
0
        public Parameter Find(string parameterName)
        {
            Parameter result = null;

            RetryableOperation.Invoke(ExceptionPolicies.General, () => { result = _repository.SingleOrDefault(x => x.ParameterName == parameterName); });
            return(result);
        }
        public IQueryable <ServiceFunctionListItem> CustomerServiceFunctions(int customerId)
        {
            IQueryable <ServiceFunctionListItem> result = null;

            RetryableOperation.Invoke(ExceptionPolicies.General,
                                      () =>
            {
                result = _serviceFunctionRepository
                         .Query(c => c.ServiceDomain.ServiceDesk.CustomerId == customerId).AsNoTracking().Select(x => new ServiceFunctionListItem
                {
                    Id                = x.Id,
                    CustomerName      = x.ServiceDomain.ServiceDesk.Customer.CustomerName,
                    ServiceDeskName   = x.ServiceDomain.ServiceDesk.DeskName,
                    ServiceDomainId   = x.ServiceDomainId,
                    ServiceDomainName = x.ServiceDomain.AlternativeName ?? x.ServiceDomain.DomainType.DomainName,
                    FunctionTypeId    = x.FunctionTypeId,
                    FunctionName      = x.FunctionType.FunctionName,
                    AlternativeName   = x.AlternativeName,
                    DiagramOrder      = x.DiagramOrder,
                    UpdatedBy         = x.UpdatedBy,
                    UpdatedDate       = x.UpdatedDate
                });
            });

            return(result);
        }
Esempio n. 9
0
        public ActionResult DownloadDiagram(int id)
        {
            ActionResult actionResult = null;

            try
            {
                RetryableOperation.Invoke(ExceptionPolicies.General, () =>
                {
                    var diagram = _diagramService.GetByCustomerAndId(_appUserContext.Current.CurrentCustomer.Id, id);
                    if (diagram != null)
                    {
                        var contentDisposition = new ContentDisposition
                        {
                            FileName = diagram.Filename,
                            Inline   = false,
                        };
                        _contextManager.ResponseManager.AppendHeader("Content-Disposition",
                                                                     contentDisposition.ToString());
                        actionResult = new FileStreamResult(new MemoryStream(diagram.DiagramData), diagram.MimeType);
                    }
                });
            }
            catch (Exception ex)
            {
                _contextManager.ResponseManager.StatusCode = 500;
                _contextManager.ResponseManager.AppendHeader(ModelStateErrorNames.ErrorMessage, ex.Message);
            }
            return(actionResult);
        }
Esempio n. 10
0
        public void CreateAuditBaseline(Customer customer)
        {
            RetryableOperation.Invoke(ExceptionPolicies.General, () =>
            {
                var userName = _userIdentity.Name;
                var now      = DateTime.Now;

                customer.Baseline    = true;
                customer.UpdatedDate = now;
                customer.UpdatedBy   = userName;
                _customerRepository.Update(customer);

                var audit = new Audit
                {
                    Customer       = customer,
                    CustomerId     = customer.Id,
                    ReasonForIssue = "Initial Customer Baseline Version",
                    Version        = 1.0,
                    InsertedBy     = userName,
                    InsertedDate   = now,
                    UpdatedBy      = userName,
                    UpdatedDate    = now
                };

                _auditRepository.Insert(audit);
                _unitOfWork.Save();
            });
        }
Esempio n. 11
0
 public void Create(IEnumerable <ServiceComponent> entities)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General, () =>
     {
         _serviceComponentRepository.AddRange(entities);
         _unitOfWork.Save();
     });
 }
Esempio n. 12
0
 public void Update(IEnumerable <ServiceComponent> entities)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General, () =>
     {
         entities?.ForEach(f => _serviceComponentRepository.Update(f));
         _unitOfWork.Save();
     });
 }
Esempio n. 13
0
 public void Update(ServiceComponent entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General, () =>
     {
         _serviceComponentRepository.Update(entity);
         _unitOfWork.Save();
     });
 }
Esempio n. 14
0
 public void Delete(OperationalProcessTypeRefData entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General, () =>
     {
         _operationalProcessRefDataRepository.Delete(entity);
         _unitOfWork.Save();
     });
 }
 public void Delete(ContextHelpRefData entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General, () =>
     {
         _contextHelpRefDataRepository.Delete(entity);
         _unitOfWork.Save();
     });
 }
Esempio n. 16
0
 public void Delete(Parameter entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General, () =>
     {
         _repository.Delete(entity);
         _unitOfWork.Save();
     });
 }
Esempio n. 17
0
 public void Delete(int id)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General, () =>
     {
         _parameterRepository.Delete(_parameterRepository.GetById(id));
         _unitOfWork.Save();
     });
 }
Esempio n. 18
0
 public void Update(Audit entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General, () =>
     {
         _auditRepository.Update(entity);
         _unitOfWork.Save();
     });
 }
 public void Delete(ResolverGroupTypeRefData entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General, () =>
     {
         _resolverGroupTypeRefDataRepository.Delete(entity);
         _unitOfWork.Save();
     });
 }
Esempio n. 20
0
 public void Delete(ServiceDeliveryOrganisationTypeRefData entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General, () =>
     {
         _serviceDeliveryOrganisationRefDataRepository.Delete(entity);
         _unitOfWork.Save();
     });
 }
Esempio n. 21
0
 public void Update(CustomerPack entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General, () =>
     {
         _customerPackRepository.Update(entity);
         _unitOfWork.Save();
     });
 }
Esempio n. 22
0
 public int Create(OperationalProcessTypeRefData entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General, () =>
     {
         _operationalProcessRefDataRepository.Insert(entity);
         _unitOfWork.Save();
     });
     return(entity.Id);
 }
Esempio n. 23
0
 public int Create(ServiceDeliveryOrganisationTypeRefData entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General, () =>
     {
         _serviceDeliveryOrganisationRefDataRepository.Insert(entity);
         _unitOfWork.Save();
     });
     return(entity.Id);
 }
Esempio n. 24
0
 public void Delete(TimerLock entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General,
                               () =>
     {
         _timerLockRepository.Delete(entity);
         _unitOfWork.Save();
     });
 }
 public int Create(ResolverGroupTypeRefData entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General, () =>
     {
         _resolverGroupTypeRefDataRepository.Insert(entity);
         _unitOfWork.Save();
     });
     return(entity.Id);
 }
Esempio n. 26
0
 public void Delete(Library entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General,
                               () =>
     {
         _libraryRepository.Delete(entity);
         _unitOfWork.Save();
     });
 }
Esempio n. 27
0
 public void Delete(int id)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General,
                               () =>
     {
         _taskRepository.Delete(id);
         _unitOfWork.Save();
     });
 }
Esempio n. 28
0
 public int Create(ServiceComponent entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General, () =>
     {
         _serviceComponentRepository.Insert(entity);
         _unitOfWork.Save();
     });
     return(entity.Id);
 }
Esempio n. 29
0
 public void Delete(HistoryLog entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General,
                               () =>
     {
         _taskHistoryLogRepository.Delete(entity);
         _unitOfWork.Save();
     });
 }
 public void Update(InputTypeRefData entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General,
                               () =>
     {
         _inputTypeRefDataRepository.Update(entity);
         _unitOfWork.Save();
     });
 }