private void TransformServiceDomain(ServiceDesk serviceDesk, TemplateRow templateRow)
        {
            var serviceDomain = serviceDesk.ServiceDomains.FirstOrDefault(d => d.DomainType.DomainName.Trim() == templateRow.ServiceDomain.Trim());

            if (serviceDomain == null)
            {
                var dateTimeNow = DateTime.Now;
                serviceDomain = new ServiceDomain
                {
                    DomainType       = _domainTypeRefDataService.InsertorUpdate(templateRow.ServiceDomain),
                    ServiceFunctions = new List <ServiceFunction>(),
                    DiagramOrder     = 5,
                    InsertedBy       = _userIdentity.Name,
                    InsertedDate     = dateTimeNow,
                    UpdatedBy        = _userIdentity.Name,
                    UpdatedDate      = dateTimeNow
                };

                serviceDesk.ServiceDomains.Add(serviceDomain);
                _serviceDeskService.Update(serviceDesk);
            }

            if (!string.IsNullOrEmpty(templateRow.ServiceFunction))
            {
                TransformServiceFunction(serviceDomain, templateRow);
            }
        }
示例#2
0
        public void ServiceDeskService_Create_CallInsertServiceDeskAndCallsSaveChanges()
        {
            #region Arrange

            var dateTimeNow = DateTime.Now;

            var serviceDesk = new ServiceDesk
            {
                Id           = 3,
                DeskName     = "A New ServiceDesk MJJ",
                CustomerId   = 1,
                InsertedBy   = UserNameOne,
                InsertedDate = dateTimeNow,
                UpdatedBy    = UserNameOne,
                UpdatedDate  = dateTimeNow,
            };

            #endregion

            #region Act

            var response = _serviceDeskService.Create(serviceDesk);

            #endregion

            #region Assert

            _mockServiceDeskRepository.Verify(x => x.Insert(It.IsAny <ServiceDesk>()), Times.Once());
            _mockUnitOfWork.Verify(x => x.Save(), Times.Exactly(1));

            Assert.IsNotNull(response);
            Assert.AreEqual(3, response);

            #endregion
        }
示例#3
0
        public void ServiceDeskService_Update_CallUpdateServiceDeskAndCallsSaveChanges()
        {
            #region Arrange

            var dateTimeNow = DateTime.Now;

            var serviceDesk = new ServiceDesk
            {
                Id          = 2,
                CustomerId  = 1,
                DeskName    = "Fujitsu Service Desk",
                UpdatedBy   = UserNameOne,
                UpdatedDate = dateTimeNow,
            };

            #endregion

            #region Act

            _serviceDeskService.Update(serviceDesk);

            #endregion

            #region Assert

            _mockServiceDeskRepository.Verify(x => x.Update(It.IsAny <ServiceDesk>()), Times.Once());
            _mockUnitOfWork.Verify(x => x.Save(), Times.Exactly(1));

            #endregion
        }
示例#4
0
        public void CalculateRepUtiliziationTestPerformCalculation()
        {
            //initialize a product type.
            string[] productTypes = new string[] { ProductData.CAR_STEREO_PRODUCT };

            //initialize a service desk.
            ServiceDesk sd = new ServiceDesk(productTypes[0], 1, 0, null);

            //initialze the service desk representative work time (30 minutes in seconds)
            sd.AddEntity(null, 1800);

            //initialize  a statistic handler.
            StatisticsHandler_Accessor target = new StatisticsHandler_Accessor(0, productTypes);

            //initialize the total work time (in minutes)
            target.ObserveTime = 60;

            //intialize the expected result (the service rep should have worked
            //for 50% of the available time).
            double expected = 0.5;

            //perform action
            target.CalculateRepUtiliziation(sd);
            double result = target.RepUtilization[productTypes[0]];

            //check results
            Assert.AreEqual(expected, result);
        }
示例#5
0
 public ServiceDeskProcessor(Customer customer,
                             ServiceDesk serviceDesk,
                             IUnitOfWork unitOfWork)
 {
     _customer    = customer;
     _serviceDesk = serviceDesk;
     _unitOfWork  = unitOfWork;
 }
示例#6
0
 public void Update(ServiceDesk entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General,
                               () =>
     {
         _serviceDeskRepository.Update(entity);
         _unitOfWork.Save();
     });
 }
示例#7
0
 public int Create(ServiceDesk entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General,
                               () =>
     {
         _serviceDeskRepository.Insert(entity);
         _unitOfWork.Save();
     });
     return(entity.Id);
 }
 public ServiceDomainProcessor(ServiceDesk serviceDesk,
                               IEnumerable <ServiceDomain> serviceDomains,
                               ISLMDataContext dataContext,
                               IUnitOfWork unitOfWork)
 {
     _serviceDesk    = serviceDesk;
     _serviceDomains = serviceDomains;
     _dataContext    = dataContext;
     _unitOfWork     = unitOfWork;
 }
示例#9
0
 public DeskInputTypeProcessor(ServiceDesk serviceDesk,
                               IEnumerable <DeskInputType> deskInputTypes,
                               ISLMDataContext dataContext,
                               IUnitOfWork unitOfWork)
 {
     _serviceDesk    = serviceDesk;
     _deskInputTypes = deskInputTypes;
     _dataContext    = dataContext;
     _unitOfWork     = unitOfWork;
 }
示例#10
0
 public ServiceDeskResolverProcessor(ServiceDesk serviceDesk,
                                     IEnumerable <Resolver> resolvers,
                                     ISLMDataContext dataContext,
                                     IUnitOfWork unitOfWork)
 {
     _serviceDesk = serviceDesk;
     _resolvers   = resolvers;
     _dataContext = dataContext;
     _unitOfWork  = unitOfWork;
 }
示例#11
0
        public ServiceDesk GetByCustomerAndId(int customerId, int id)
        {
            ServiceDesk result = null;

            RetryableOperation.Invoke(ExceptionPolicies.General, () =>
            {
                result = _serviceDeskRepository.SingleOrDefault(x => x.CustomerId == customerId && x.Id == id);
            });
            return(result);
        }
示例#12
0
        public ServiceDesk GetById(int id)
        {
            ServiceDesk result = null;

            RetryableOperation.Invoke(ExceptionPolicies.General,
                                      () =>
            {
                result = _serviceDeskRepository.GetById(id);
            });
            return(result);
        }
 public ServiceComponentResolverProcessor(ServiceDesk serviceDesk,
                                          ServiceComponent serviceComponent,
                                          ServiceComponent targetServiceComponent,
                                          ISLMDataContext dataContext,
                                          IUnitOfWork unitOfWork)
 {
     _serviceDesk            = serviceDesk;
     _serviceComponent       = serviceComponent;
     _targetServiceComponent = targetServiceComponent;
     _dataContext            = dataContext;
     _unitOfWork             = unitOfWork;
 }
示例#14
0
 public ServiceComponentProcessor(ServiceDesk serviceDesk,
                                  ServiceFunction serviceFunction,
                                  ServiceComponent serviceComponent,
                                  ISLMDataContext dataContext,
                                  IUnitOfWork unitOfWork)
 {
     _serviceDesk      = serviceDesk;
     _serviceFunction  = serviceFunction;
     _serviceComponent = serviceComponent;
     _dataContext      = dataContext;
     _unitOfWork       = unitOfWork;
 }
示例#15
0
        public void Update(ServiceDesk entity, List <int> inputTypeDeletions)
        {
            RetryableOperation.Invoke(ExceptionPolicies.General,
                                      () =>
            {
                foreach (var inputType in inputTypeDeletions)
                {
                    _deskInputTypeRepository.Delete(inputType);
                }

                _serviceDeskRepository.Update(entity);
                _unitOfWork.Save();
            });
        }
示例#16
0
 public ChildServiceComponentProcessor(ServiceDesk serviceDesk,
                                       ServiceFunction serviceFunction,
                                       ServiceComponent parentServiceComponent,
                                       IEnumerable <ServiceComponent> childServiceComponents,
                                       ISLMDataContext dataContext,
                                       IUnitOfWork unitOfWork)
 {
     _serviceDesk            = serviceDesk;
     _serviceFunction        = serviceFunction;
     _parentServiceComponent = parentServiceComponent;
     _childServiceComponents = childServiceComponents;
     _dataContext            = dataContext;
     _unitOfWork             = unitOfWork;
 }
示例#17
0
        public void Execute()
        {
            var newServiceDesk = new ServiceDesk
            {
                Customer       = _customer,
                CustomerId     = _customer.Id,
                DeskName       = _serviceDesk.DeskName,
                ServiceDomains = new List <ServiceDomain>(),
                DeskInputTypes = new List <DeskInputType>(),
                Resolvers      = new List <Resolver>(),
                InsertedBy     = _serviceDesk.InsertedBy,
                InsertedDate   = _serviceDesk.InsertedDate,
                UpdatedBy      = _serviceDesk.UpdatedBy,
                UpdatedDate    = _serviceDesk.UpdatedDate
            };

            _customer.ServiceDesks.Add(newServiceDesk);
            _unitOfWork.Save();
        }
示例#18
0
        public void CalculateRepUtiliziationTestDivisionByZero()
        {
            //initialize a product type.
            string[] productTypes = new string[] { ProductData.CAR_STEREO_PRODUCT };

            //initialize a service desk.
            ServiceDesk sd = new ServiceDesk(productTypes[0], 1, 0, null);

            //initialize  a statistic handler.
            StatisticsHandler_Accessor target = new StatisticsHandler_Accessor(0, productTypes);

            //intialize the expected result.
            double expected = double.NaN;

            //perform atcion
            target.CalculateRepUtiliziation(sd);
            double result = target.RepUtilization[productTypes[0]];

            //check results
            Assert.AreEqual(expected, result);
        }
        public ActionResult Add(string level, string deskName, int[] deskInputTypes)
        {
            if (_appUserContext.Current.CurrentCustomer == null || _appUserContext.Current.CurrentCustomer.Id <= 0)
            {
                // No context
                return(RedirectToAction("Index", "ServiceDesk", new { level = level }));
            }

            // Create Service Desk
            var serviceDesk = new ServiceDesk();
            var now         = DateTime.Now;
            var user        = _contextManager.UserManager.Name;

            serviceDesk.CustomerId     = _appUserContext.Current.CurrentCustomer.Id;
            serviceDesk.DeskName       = deskName;
            serviceDesk.DeskInputTypes = new List <DeskInputType>();

            if (deskInputTypes != null && deskInputTypes.Length > 0)
            {
                // Add Desk Input Types
                foreach (var deskInputTypeId in deskInputTypes)
                {
                    serviceDesk.DeskInputTypes.Add(new DeskInputType
                    {
                        InputTypeRefData = _inputTypeRefDataService.GetById(deskInputTypeId)
                    });
                }
            }

            serviceDesk.InsertedBy   = user;
            serviceDesk.InsertedDate = now;
            serviceDesk.UpdatedBy    = user;
            serviceDesk.UpdatedDate  = now;

            _serviceDeskService.Create(serviceDesk);

            return(RedirectToAction("Index", "ServiceDesk", new { level = level }));
        }
示例#20
0
        public void Delete(ServiceDesk entity)
        {
            RetryableOperation.Invoke(ExceptionPolicies.General,
                                      () =>
            {
                // Get a new sql connection from the unit of work
                using (var dbConnection = _unitOfWork.CreateConnection())
                {
                    // Create a null transaction
                    SqlTransaction transaction = null;

                    try
                    {
                        // Open the connection and begin a transaction
                        dbConnection.Open();
                        transaction = dbConnection.BeginTransaction();

                        // Execute the stored procedure to delete the customer
                        _unitOfWork.ExecuteNonQueryStoredProcedure("spDeleteServiceDesk",
                                                                   dbConnection,
                                                                   transaction,
                                                                   new SqlParameter("@ServiceDeskId", SqlDbType.Int)
                        {
                            Value = entity.Id
                        });

                        // Command has executed successfully, commit the transaction
                        transaction.Commit();
                    }
                    catch (Exception)
                    {
                        // If we have a transaction then roll it back
                        transaction?.Rollback();
                        throw;
                    }
                }
            });
        }
        public void Initialize()
        {
            Bootstrapper.SetupAutoMapper();

            _serviceDesk = UnitTestHelper.GenerateRandomData <ServiceDesk>();

            _domainTypeRefDatas = new List <DomainTypeRefData>
            {
                UnitTestHelper.GenerateRandomData <DomainTypeRefData>(x =>
                {
                    x.Id      = 1;
                    x.Visible = true;
                }),
                UnitTestHelper.GenerateRandomData <DomainTypeRefData>(x =>
                {
                    x.Id      = 2;
                    x.Visible = false;
                }),
                UnitTestHelper.GenerateRandomData <DomainTypeRefData>(x =>
                {
                    x.Id      = 3;
                    x.Visible = false;
                }),
                UnitTestHelper.GenerateRandomData <DomainTypeRefData>(x =>
                {
                    x.Id      = 4;
                    x.Visible = true;
                }),
                UnitTestHelper.GenerateRandomData <DomainTypeRefData>(x =>
                {
                    x.Id      = 5;
                    x.Visible = true;
                })
            };

            _mockDomainTypeRefDataService = new Mock <IDomainTypeRefDataService>();
            _mockDomainTypeRefDataService.Setup(s => s.GetById(1)).Returns(_domainTypeRefDatas[0]);
            _mockDomainTypeRefDataService.Setup(s => s.GetById(2)).Returns(_domainTypeRefDatas[1]);
            _mockDomainTypeRefDataService.Setup(s => s.GetById(3)).Returns(_domainTypeRefDatas[2]);
            _mockDomainTypeRefDataService.Setup(s => s.GetById(4)).Returns(_domainTypeRefDatas[3]);
            _mockDomainTypeRefDataService.Setup(s => s.GetById(5)).Returns(_domainTypeRefDatas[4]);
            _mockDomainTypeRefDataService.Setup(s => s.GetAllAndNotVisibleForCustomer(CustomerId))
            .Returns(_domainTypeRefDatas);

            _serviceDomain = UnitTestHelper.GenerateRandomData <ServiceDomain>();
            _serviceDomain.ServiceFunctions = new List <ServiceFunction>();

            _serviceDomainListItems = new List <ServiceDomainListItem>
            {
                UnitTestHelper.GenerateRandomData <ServiceDomainListItem>(),
                UnitTestHelper.GenerateRandomData <ServiceDomainListItem>(),
                UnitTestHelper.GenerateRandomData <ServiceDomainListItem>(),
                UnitTestHelper.GenerateRandomData <ServiceDomainListItem>(),
                UnitTestHelper.GenerateRandomData <ServiceDomainListItem>(),
            };

            _templateListItems = new List <TemplateListItem>
            {
                UnitTestHelper.GenerateRandomData <TemplateListItem>(x =>
                {
                    x.Id           = TemplateId;
                    x.TemplateType = TemplateTypeNames.SORT;
                }),
                UnitTestHelper.GenerateRandomData <TemplateListItem>(),
                UnitTestHelper.GenerateRandomData <TemplateListItem>(),
                UnitTestHelper.GenerateRandomData <TemplateListItem>()
            };

            _mockServiceDomainService = new Mock <IServiceDomainService>();
            _mockServiceDomainService.Setup(s => s.GetByCustomerAndId(CustomerId, ServiceDomainId))
            .Returns(_serviceDomain);
            _mockServiceDomainService.Setup(s => s.GetById(ServiceDomainId)).Returns(_serviceDomain);
            _mockServiceDomainService.Setup(s => s.ServiceDeskDomains(ServiceDeskId))
            .Returns(_serviceDomainListItems.AsQueryable());
            _mockServiceDomainService.Setup(s => s.CustomerServiceDomains(CustomerId))
            .Returns(_serviceDomainListItems.AsQueryable());

            _mockResponseManager = new Mock <IResponseManager>();
            _mockRequestManager  = new Mock <IRequestManager>();

            _mockUserManager = new Mock <IUserManager>();
            _mockUserManager.Setup(s => s.Name).Returns(UserName);

            _mockNameValueCollection = new Mock <NameValueCollection>();

            _mockContextManager = new Mock <IContextManager>();
            _mockContextManager.Setup(s => s.UserManager).Returns(_mockUserManager.Object);
            _mockContextManager.Setup(s => s.ResponseManager).Returns(_mockResponseManager.Object);
            _mockContextManager.Setup(s => s.RequestManager).Returns(_mockRequestManager.Object);
            _mockRequestManager.Setup(s => s.Form).Returns(_mockNameValueCollection.Object);

            _serviceDesks = new List <ServiceDesk>
            {
                UnitTestHelper.GenerateRandomData <ServiceDesk>(),
                UnitTestHelper.GenerateRandomData <ServiceDesk>(),
                UnitTestHelper.GenerateRandomData <ServiceDesk>(x =>
                {
                    x.Id = ServiceDeskId;
                }),
                UnitTestHelper.GenerateRandomData <ServiceDesk>(),
                UnitTestHelper.GenerateRandomData <ServiceDesk>()
            };

            _mockServiceDeskService = new Mock <IServiceDeskService>();
            _mockServiceDeskService.Setup(s => s.GetByCustomer(CustomerId)).Returns(_serviceDesks.AsQueryable());
            _mockServiceDeskService.Setup(s => s.GetByCustomerAndId(CustomerId, ServiceDeskId)).Returns(_serviceDesk);

            _mockAppUserContext = new Mock <IAppUserContext>();
            _mockAppUserContext.Setup(s => s.Current).Returns(new AppContext
            {
                CurrentCustomer = new CurrentCustomerViewModel
                {
                    Id = CustomerId
                }
            });

            _mockTemplateService = new Mock <ITemplateService>();
            _mockTemplateService.Setup(s => s.GetById(TemplateId))
            .Returns(new Template {
                Id = TemplateId, Filename = "example.xlxs"
            });
            _mockTemplateService.Setup(s => s.AllTemplates())
            .Returns(_templateListItems);

            _mockServiceDecompositionTemplateDataImportProcessor = new Mock <IServiceDecompositionTemplateDataImportProcessor>();
            _mockServiceDecompositionDesignDataImportProcessor   = new Mock <IServiceDecompositionDesignDataImportProcessor>();
            _mockTemplateProcessor = new Mock <ITemplateProcessor>();


            _target = new TemplateController(_mockTemplateService.Object,
                                             _mockServiceDeskService.Object,
                                             _mockServiceDecompositionTemplateDataImportProcessor.Object,
                                             _mockServiceDecompositionDesignDataImportProcessor.Object,
                                             _mockTemplateProcessor.Object,
                                             _mockContextManager.Object,
                                             _mockAppUserContext.Object);

            _controllerContextMocks   = new ControllerContextMocks();
            _target.ControllerContext = new ControllerContext(_controllerContextMocks.MockHttpContextBase.Object,
                                                              new RouteData(),
                                                              _target);
            if (RouteTable.Routes.Count == 0)
            {
                RouteConfig.RegisterRoutes(RouteTable.Routes);
            }
            _target.Url =
                new UrlHelper(new RequestContext(_controllerContextMocks.MockHttpContextBase.Object, new RouteData()));
        }
示例#22
0
        public static void CreateServiceDeskWithInputs(this ChartDataListItem serviceDeskChart, ServiceDesk serviceDesk)
        {
            if (serviceDesk.DeskInputTypes != null && serviceDesk.DeskInputTypes.Any())
            {
                // Add Service Desk Inputs
                foreach (var deskInput in serviceDesk.DeskInputTypes.OrderBy(o => o.InputTypeRefData.InputTypeNumber))
                {
                    var deskInputName = new ChartDataListItem
                    {
                        Id            = deskInput.Id,
                        CenteredTitle = deskInput.InputTypeRefData.InputTypeName,
                        Title         = string.Empty,
                        Type          = DecompositionType.InputTypeName.ToString(),
                        Units         = new List <ChartDataListItem>()
                    };

                    var deskInputNumber = new ChartDataListItem
                    {
                        Id            = deskInput.Id,
                        CenteredTitle = deskInput.InputTypeRefData.InputTypeNumber.ToString(),
                        Title         = string.Empty,
                        Type          = DecompositionType.InputTypeNumber.ToString(),
                        Units         = new List <ChartDataListItem>()
                    };

                    var emptyForLayout = new ChartDataListItem
                    {
                        Id            = 0,
                        CenteredTitle = string.Empty,
                        Type          = DecompositionType.EmptyForLayout.ToString()
                    };

                    serviceDeskChart.Inputs.Add(deskInputName);
                    deskInputName.Units.Add(deskInputNumber);
                    deskInputNumber.Units.Add(emptyForLayout);
                }

                serviceDeskChart.Width = serviceDeskChart.Inputs.Count * Diagram.ShapeWidth;
            }

            serviceDeskChart.CenteredTitle = serviceDesk.DeskName;
            serviceDeskChart.Type          = DecompositionType.Desk.ToString();
        }