Exemplo n.º 1
0
        public void Execute(int serviceDeskId, IReadOnlyCollection <TemplateDomainListItem> selectedDomains)
        {
            using (var dbConnection = _unitOfWork.CreateConnection())
            {
                try
                {
                    // Open the connection and begin a transaction
                    dbConnection.Open();
                    _repositoryTransaction = _unitOfWork.BeginTransaction();

                    foreach (var selectedDomain in selectedDomains)
                    {
                        var templateRows = _templateRowRepository.All().Where(x => x.TemplateId == selectedDomain.TemplateId && x.ServiceDomain == selectedDomain.DomainName).ToList();
                        _transformTemplateToDesign.Transform(serviceDeskId, templateRows);
                    }

                    Save();
                }
                catch (Exception)
                {
                    // If we have a transaction then roll it back
                    Rollback();

                    // Throw the exception
                    throw;
                }
            }
        }
Exemplo n.º 2
0
        public ConsolidationTask(IQueueService queueService, IRepositoryTransaction repositoryTransaction, IConfiguration configuration)
        {
            _queueService          = queueService;
            _repositoryTransaction = repositoryTransaction;
            _configuration         = configuration;

            queueName = _configuration.GetSection("RabbitMQ").GetSection("QueueName").Value;
        }
Exemplo n.º 3
0
 /// <summary>
 /// <para>Overloaded.  Commits this entity tracker's workload to the repository.</para>
 /// </summary>
 public virtual void PerformWork()
 {
     using (IRepositoryTransaction transaction = this.Connection.CreateTransaction())
     {
         this.PerformWork(transaction);
         transaction.Commit();
     }
 }
        public void Execute(string serviceDecompositionFilePath, string filename, int serviceDeskId)
        {
            if (serviceDecompositionFilePath == null)
            {
                throw new ArgumentNullException(nameof(serviceDecompositionFilePath));
            }

            if (filename == null)
            {
                throw new ArgumentNullException(nameof(filename));
            }

            if (!File.Exists(serviceDecompositionFilePath))
            {
                throw new FileNotFoundException(serviceDecompositionFilePath);
            }

            // Read the contents of Service Decomposition spreadsheet (This will have been uploaded via the Web UI)
            var importResults = _serviceDecompositionTemplateImporter.ImportSpreadsheet(serviceDecompositionFilePath);


            if (importResults.ValidationResults.Count > 0)
            {
                throw new DataImportException(
                          $"Error reading Service Decomposition Template spreadsheet ({filename}) - ", importResults.ValidationResults);
            }

            if (importResults.Results.Count == 0)
            {
                throw new DataImportException(
                          $"Error reading Service Decomposition Template spreadsheet ({filename}) - Spreadsheet does not contain any valid data.");
            }

            using (var dbConnection = _unitOfWork.CreateConnection())
            {
                try
                {
                    // Open the connection and begin a transaction
                    dbConnection.Open();
                    _repositoryTransaction = _unitOfWork.BeginTransaction();

                    _serviceDeskService.Clear(serviceDeskId);

                    _transformTemplateToDesign.Transform(serviceDeskId, importResults.AsTemplateRows());

                    Save();
                }
                catch (Exception)
                {
                    // If we have a transaction then roll it back
                    Rollback();

                    // Throw the exception
                    throw;
                }
            }
        }
Exemplo n.º 5
0
 public TradeManager(
     IRepositoryClient repositoryClient,
     IRepositoryStock repositoryStock,
     IRepositoryTransaction repositoryTransaction,
     IClientService clientService,
     IStockService stockService,
     ITransactionService transactionService,
     ILoggerService loggerService,
     ITransactionGenerator transactionGenerator,
     IEnumerable <ITransactionValidator> transactionValidators)
 {
     _repositoryClient      = repositoryClient;
     _repositoryStock       = repositoryStock;
     _repositoryTransaction = repositoryTransaction;
     _clientService         = clientService;
     _stockService          = stockService;
     _transactionService    = transactionService;
     _loggerService         = loggerService;
     _transactionGenerator  = transactionGenerator;
     _transactionValidators = transactionValidators;
     IsContinue             = true;
 }
Exemplo n.º 6
0
        /// <summary>
        /// <para>Overloaded.  Commits this entity tracker's workload to the repository.</para>
        /// </summary>
        /// <param name="transaction">
        /// A <see cref="IRepositoryTransaction"/>
        /// </param>
        public virtual void PerformWork(IRepositoryTransaction transaction)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException(this.GetType().FullName, "This entity tracker has already been disposed.");
            }

            foreach (IEntity entity in this.NewEntities)
            {
                entity.Create(this.Connection);
            }

            foreach (IEntity entity in this.DirtyEntities)
            {
                entity.Update(this.Connection);
            }

            foreach (IEntity entity in this.DeletedEntities)
            {
                entity.Delete(this.Connection);
            }
        }
Exemplo n.º 7
0
 public TransactionService(IRepositoryTransaction repositoryTransaction)
 {
     _repositoryTransaction = repositoryTransaction;
 }
Exemplo n.º 8
0
        public void Execute()
        {
            // HMRC
            // =====
            // 45 = HMRC (Live Services) ( * - Copied )
            // 69 = HMRC ( * - Copied )
            // 84 = HMRC Service Management ( * - Copied )
            // 118 = HMRC FAST-DA ( * - Copied )
            // 180 = HMRC FAST-DA_COPY ( * - Copied )


            // MATT TEST
            // ==========
            // 184 = Matt Test

            // VANDA
            // ======
            // 185 = TestingMagic

            var customer = new Customer().GetSourceCustomer(84);

            if (customer != null)
            {
                using (var targetDbContext = new SLMDataContext("Name=SLMTargetDataContext"))
                {
                    var unitOfWork = new UnitOfWork(targetDbContext);
                    IRepositoryTransaction repositoryTransaction = null;

                    using (var dbConnection = unitOfWork.CreateConnection())
                    {
                        try
                        {
                            // Open the connection and begin a transaction
                            dbConnection.Open();
                            repositoryTransaction = unitOfWork.BeginTransaction();

                            if (!targetDbContext.Customers.Any(x => x.CustomerName == customer.CustomerName))
                            {
                                var targetCustomer = new Customer
                                {
                                    Active            = customer.Active,
                                    CustomerName      = customer.CustomerName,
                                    CustomerNotes     = customer.CustomerNotes,
                                    AssignedArchitect = customer.AssignedArchitect,
                                    Contributors      = new List <Contributor>(),
                                    ServiceDesks      = new List <ServiceDesk>(),
                                    InsertedBy        = customer.InsertedBy,
                                    InsertedDate      = customer.InsertedDate,
                                    UpdatedBy         = customer.UpdatedBy,
                                    UpdatedDate       = customer.UpdatedDate
                                };

                                targetDbContext.Customers.Add(targetCustomer);
                                unitOfWork.Save();

                                if (customer.Contributors.Any())
                                {
                                    var contributorProcessor = new ContributorProcessor(targetCustomer, customer.Contributors.ToList(), unitOfWork);
                                    contributorProcessor.Execute();
                                }

                                if (customer.ServiceDesks.Any())
                                {
                                    foreach (var serviceDesk in customer.ServiceDesks.ToList())
                                    {
                                        var serviceDeskProcessor = new ServiceDeskProcessor(targetCustomer, serviceDesk, unitOfWork);
                                        serviceDeskProcessor.Execute();

                                        var targetServiceDesk      = targetDbContext.ServiceDesks.Single(x => x.DeskName == serviceDesk.DeskName && x.CustomerId == targetCustomer.Id);
                                        var deskInputTypeProcessor = new DeskInputTypeProcessor(targetServiceDesk, serviceDesk.DeskInputTypes.ToList(), targetDbContext, unitOfWork);
                                        deskInputTypeProcessor.Execute();

                                        var serviceDeskResolverProcessor = new ServiceDeskResolverProcessor(targetServiceDesk, serviceDesk.Resolvers, targetDbContext, unitOfWork);
                                        serviceDeskResolverProcessor.Execute();

                                        var serviceDomainProcessor = new ServiceDomainProcessor(targetServiceDesk, serviceDesk.ServiceDomains.ToList(), targetDbContext, unitOfWork);
                                        serviceDomainProcessor.Execute();
                                    }
                                }
                                repositoryTransaction?.Save();
                                System.Console.WriteLine($@"Successfully Migrated Customer > {customer.CustomerName}");
                            }
                        }
                        catch (Exception ex)
                        {
                            // If we have a transaction then roll it back
                            repositoryTransaction?.Rollback();

                            System.Console.WriteLine($@"Exception => {ex.Message}");
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
 public ServiceTransaction(IRepositoryTransaction repositoryTransaction)
     : base(repositoryTransaction)
 {
     _repositoryTransaction = repositoryTransaction;
 }
 public DomainServiceTransaction(IRepositoryTransaction repositorio)
     : base(repositorio)
 {
     this.repositorio = repositorio;
 }
Exemplo n.º 11
0
        public void Execute()
        {
            // HMRC
            // =====
            // xxx = HMRC FAST-DA ( * - Copied )

            // Domains
            // ========
            // xxx = Network Services (Source)
            // xxx = Security Services (Target)

            var sourceFunctionId = 978;
            var targetDomainId   = 280;

            var serviceFunction = new ServiceFunction().GetSourceFunction(sourceFunctionId);

            if (serviceFunction != null)
            {
                using (var targetDbContext = new SLMDataContext("Name=SLMTargetDataContext"))
                {
                    var unitOfWork = new UnitOfWork(targetDbContext);
                    IRepositoryTransaction repositoryTransaction = null;

                    using (var dbConnection = unitOfWork.CreateConnection())
                    {
                        try
                        {
                            // Open the connection and begin a transaction
                            dbConnection.Open();
                            repositoryTransaction = unitOfWork.BeginTransaction();

                            var targetDomain = targetDbContext.ServiceDomains.Single(x => x.Id == targetDomainId);

                            var serviceFunctions = new List <ServiceFunction> {
                                serviceFunction
                            };

                            var serviceFunctionProcessor = new ServiceFunctionProcessor(targetDomain, serviceFunctions, targetDbContext, unitOfWork);
                            serviceFunctionProcessor.Execute();

                            var targetServiceFunction = targetDomain.ServiceFunctions.Single(x => x.FunctionType.FunctionName == serviceFunction.FunctionType.FunctionName);
                            // Add underlying Service Function hierarchy
                            foreach (var serviceComponent in serviceFunction.ServiceComponents.Where(x => x.ComponentLevel == 1))
                            {
                                var serviceComponentProcessor = new ServiceComponentProcessor(targetDomain.ServiceDesk, targetServiceFunction, serviceComponent, targetDbContext, unitOfWork);
                                serviceComponentProcessor.Execute();
                            }

                            repositoryTransaction?.Save();
                            System.Console.WriteLine($@"Successfully Copied Service Function [{serviceFunction.FunctionType.FunctionName}] To Service Domain [{targetDomain.DomainType.DomainName}]");
                        }
                        catch (Exception ex)
                        {
                            // If we have a transaction then roll it back
                            repositoryTransaction?.Rollback();

                            System.Console.WriteLine($@"Exception => {ex.Message}");
                        }
                    }
                }
            }
        }
Exemplo n.º 12
0
 public TransactionService(IRepositoryTransaction repository) : base(repository)
 {
     _repositoryTransaction = repository;
 }
Exemplo n.º 13
0
 public BusinessAccount(IRepositoryBase <Account> persistence, IUnitOfWork uow, ILogger logger, IRepositoryBase <Customer> persistenceCustomer, IRepositoryTransaction persistenceTransaction) : base(persistence, uow, logger)
 {
     _persistenceCustomer    = persistenceCustomer;
     _persistenceTransaction = persistenceTransaction;
 }