public ServiceComponentEditState GetEditState(ServiceComponent serviceComponent)
        {
            if (serviceComponent == null)
            {
                return(ServiceComponentEditState.None);
            }
            if (serviceComponent.ComponentLevel == (int)ServiceComponentLevel.Level2)
            {
                return(ServiceComponentEditState.Level2);
            }
            if ((serviceComponent.ChildServiceComponents == null || !serviceComponent.ChildServiceComponents.Any()) &&
                serviceComponent.Resolver == null &&
                serviceComponent.ComponentLevel == (int)ServiceComponentLevel.Level1)
            {
                return(ServiceComponentEditState.Level1WithNoChildComponentOrResolver);
            }
            if (serviceComponent.ChildServiceComponents != null && serviceComponent.ChildServiceComponents.Any() &&
                serviceComponent.ComponentLevel == (int)ServiceComponentLevel.Level1)
            {
                return(ServiceComponentEditState.Level1WithChildComponent);
            }
            if ((serviceComponent.Resolver != null) &&
                serviceComponent.ComponentLevel == (int)ServiceComponentLevel.Level1)
            {
                return(ServiceComponentEditState.Level1WithResolver);
            }

            return(ServiceComponentEditState.None);
        }
Example #2
0
 private static void InitCustomComponents()
 {
     Database = UnityGameFramework.Runtime.GameEntry.GetComponent <DatabaseComponent>();
     Command  = UnityGameFramework.Runtime.GameEntry.GetComponent <CommandComponent>();
     TempData = UnityGameFramework.Runtime.GameEntry.GetComponent <TempDataComponent>();
     Service  = UnityGameFramework.Runtime.GameEntry.GetComponent <ServiceComponent>();
 }
Example #3
0
        public void Execute()
        {
            foreach (var childServiceComponent in _childServiceComponents)
            {
                var newServiceComponent = new ServiceComponent
                {
                    ServiceFunctionId        = _serviceFunction.Id,
                    ServiceFunction          = _serviceFunction,
                    ParentServiceComponent   = _parentServiceComponent,
                    ParentServiceComponentId = _parentServiceComponent.Id,
                    ComponentName            = childServiceComponent.ComponentName,
                    ComponentLevel           = childServiceComponent.ComponentLevel,
                    ServiceActivities        = childServiceComponent.ServiceActivities,
                    InsertedBy   = childServiceComponent.InsertedBy,
                    InsertedDate = childServiceComponent.InsertedDate,
                    UpdatedBy    = childServiceComponent.UpdatedBy,
                    UpdatedDate  = childServiceComponent.UpdatedDate
                };

                _parentServiceComponent.ChildServiceComponents.Add(newServiceComponent);
                _unitOfWork.Save();

                if (childServiceComponent.Resolver != null)
                {
                    var serviceComponentResolverProcessor = new ServiceComponentResolverProcessor(_serviceDesk, childServiceComponent, newServiceComponent, _dataContext, _unitOfWork);
                    serviceComponentResolverProcessor.Execute();
                }
            }
        }
Example #4
0
        public void ServiceComponentHelper_ServiceComponentHelper_ServiceComponentIsNotNull_ReturnsHelper()
        {
            var sc     = new ServiceComponent();
            var helper = sc.ServiceComponentHelper();

            Assert.IsInstanceOfType(helper, typeof(IServiceComponentHelper));
        }
Example #5
0
        private static void ProcessComponentServiceActivity(
            bool opProcs,
            ServiceComponent component,
            List <List <DotMatrixListItem> > dotMatrix,
            ChartDataListItem chartData)
        {
            var activities = new ChartDataListItem
            {
                Id            = component.Resolver?.Id ?? component.Id,
                Title         = NoneSpecified,
                Type          = DecompositionType.Activity.ToString(),
                CenteredTitle = string.Empty,
                Units         = new List <ChartDataListItem>()
            };

            // Add Service Activity
            activities.Id = component.Id;
            if (!string.IsNullOrEmpty(component.ServiceActivities))
            {
                activities.Title = component.ServiceActivities;
            }
            else if (component.ComponentLevel == (int)ServiceComponentLevel.Level2 && !string.IsNullOrEmpty(component.ParentServiceComponent.ServiceActivities))
            {
                activities.Title = component.ParentServiceComponent.ServiceActivities;
            }

            chartData.Units.Add(activities);

            if (opProcs)
            {
                ProcessOpProcs(component, dotMatrix, activities);
            }
        }
Example #6
0
        public void Execute()
        {
            var newServiceComponent = new ServiceComponent
            {
                ServiceFunctionId      = _serviceFunction.Id,
                ServiceFunction        = _serviceFunction,
                ComponentName          = _serviceComponent.ComponentName,
                ComponentLevel         = _serviceComponent.ComponentLevel,
                ServiceActivities      = _serviceComponent.ServiceActivities,
                ChildServiceComponents = new List <ServiceComponent>(),
                InsertedBy             = _serviceComponent.InsertedBy,
                InsertedDate           = _serviceComponent.InsertedDate,
                UpdatedBy   = _serviceComponent.UpdatedBy,
                UpdatedDate = _serviceComponent.UpdatedDate
            };

            _serviceFunction.ServiceComponents.Add(newServiceComponent);
            _unitOfWork.Save();

            if (_serviceComponent.Resolver != null)
            {
                var serviceComponentResolverProcessor = new ServiceComponentResolverProcessor(_serviceDesk, _serviceComponent, newServiceComponent, _dataContext, _unitOfWork);
                serviceComponentResolverProcessor.Execute();
            }
            else if (_serviceComponent.ChildServiceComponents != null && _serviceComponent.ChildServiceComponents.Any())
            {
                var childServiceComponentProcessor = new ChildServiceComponentProcessor(_serviceDesk, _serviceFunction, newServiceComponent, _serviceComponent.ChildServiceComponents, _dataContext, _unitOfWork);
                childServiceComponentProcessor.Execute();
            }
        }
Example #7
0
        public JsonResult SaveMedicalConsultation(List <ServiceComponentFieldsList> oServicecomponentfields, string oServicecomponent,
                                                  string serviceComponentId)
        {
            //int permiss;
            //if (permission == "true")
            //{
            //    permiss = (int)Enumeratores.SaveEso.Allowed;
            //}
            //else
            //{
            //    permiss = (int)Enumeratores.SaveEso.Denied;
            //}
            ServiceComponent oservicecomponent = JsonConvert.DeserializeObject <ServiceComponent>(oServicecomponent);
            var NodeId       = ViewBag.USER.NodeId;
            var SystemUserId = ViewBag.USER.SystemUserId;

            oservicecomponent.i_ApprovedUpdateUserId = SystemUserId;
            //var NodeId = 1;
            //var SystemUserId = 49;
            var API = new Api();
            var url = "Eso/SaveMedicalConsultation";

            Dictionary <string, string> arg = new Dictionary <string, string>()
            {
                { "String1", JsonConvert.SerializeObject(oServicecomponentfields) },
                { "String2", JsonConvert.SerializeObject(oservicecomponent) },//AMC
                { "Int1", NodeId.ToString() },
                { "Int2", SystemUserId.ToString() },
                //{ "Int3",permiss.ToString()}
            };

            var response = API.Post <string>(url, arg);

            return(Json(response));
        }
        private void TransformComponentLevelOne(ServiceFunction serviceFunction, TemplateRow templateRow)
        {
            var serviceComponent = serviceFunction.ServiceComponents.FirstOrDefault(d => d.ComponentName == templateRow.ServiceComponentLevel1 && d.ComponentLevel == 1);

            if (serviceComponent == null)
            {
                var dateTimeNow = DateTime.Now;
                serviceComponent = new ServiceComponent
                {
                    ServiceFunction   = serviceFunction,
                    ComponentName     = templateRow.ServiceComponentLevel1,
                    ComponentLevel    = 1,
                    ServiceActivities = string.IsNullOrEmpty(templateRow.ServiceComponentLevel2) &&
                                        !string.IsNullOrEmpty(templateRow.ServiceActivities)
                        ? templateRow.ServiceActivities
                        : string.Empty,
                    DiagramOrder = 5,
                    InsertedBy   = _userIdentity.Name,
                    InsertedDate = dateTimeNow,
                    UpdatedBy    = _userIdentity.Name,
                    UpdatedDate  = dateTimeNow
                };

                serviceFunction.ServiceComponents.Add(serviceComponent);
                _serviceFunctionService.Update(serviceFunction);
            }
            //else if (!string.IsNullOrEmpty(templateRow.ServiceActivities))
            //{
            //    if (!string.IsNullOrEmpty(serviceComponent.ServiceActivities))
            //        serviceComponent.ServiceActivities += $"\r\n{templateRow.ServiceActivities}";
            //    else
            //    {
            //        serviceComponent.ServiceActivities = templateRow.ServiceActivities;
            //    }

            //    _serviceComponentService.Update(serviceComponent);
            //}

            if (!string.IsNullOrEmpty(templateRow.ServiceComponentLevel2))
            {
                if (serviceComponent.Resolver != null)
                {
                    throw new DataImportException(
                              $"Error reading Service Decomposition Design spreadsheet. Worksheet, Resolvers and Childs Components detected on Component [{templateRow.ServiceComponentLevel1}].");
                }

                TransformComponentLevelTwo(serviceComponent, templateRow);
            }
            else if (!string.IsNullOrEmpty(templateRow.ServiceDeliveryOrganisation))
            {
                if (serviceComponent.Resolver != null)
                {
                    throw new DataImportException(
                              $"Error reading Service Decomposition Design spreadsheet. Worksheet, Multiple Resolvers per Component detected on Component [{templateRow.ServiceComponentLevel1}].");
                }

                TransformResolver(serviceComponent, templateRow);
            }
        }
Example #9
0
 public void Update(ServiceComponent entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General, () =>
     {
         _serviceComponentRepository.Update(entity);
         _unitOfWork.Save();
     });
 }
Example #10
0
 public int Create(ServiceComponent entity)
 {
     RetryableOperation.Invoke(ExceptionPolicies.General, () =>
     {
         _serviceComponentRepository.Insert(entity);
         _unitOfWork.Save();
     });
     return(entity.Id);
 }
        public void ServiceComponentHelper_CanDelete_ResolverHasValue_CannotDelete()
        {
            var component = new ServiceComponent
            {
                Resolver = new Resolver()
            };

            Assert.IsFalse(_target.CanDelete(component));
        }
        public void ServiceComponentHelper_GetEditState_ComponentIsLevel2_EditStateLevel2()
        {
            var sc = new ServiceComponent {
                ComponentLevel = (int)ServiceComponentLevel.Level2
            };
            var state = _target.GetEditState(sc);

            Assert.AreEqual(ServiceComponentEditState.Level2, state);
        }
        public void ServiceComponentHelper_GetEditState_ComponentHasNoChildComponentOrResolverAndIsLevel1_EditStateLevel1WithNoChildComponentOrResolver()
        {
            var sc = new ServiceComponent {
                ComponentLevel = (int)ServiceComponentLevel.Level1
            };
            var state = _target.GetEditState(sc);

            Assert.AreEqual(ServiceComponentEditState.Level1WithNoChildComponentOrResolver, state);
        }
 private static void CreateResolver(ServiceComponent component)
 {
     component.Resolver = UnitTestHelper.GenerateRandomData <Resolver>(x =>
     {
         x.ServiceDeliveryOrganisationType = UnitTestHelper.GenerateRandomData <ServiceDeliveryOrganisationTypeRefData>();
         x.ServiceDeliveryUnitType         = UnitTestHelper.GenerateRandomData <ServiceDeliveryUnitTypeRefData>();
         x.ResolverGroupType = UnitTestHelper.GenerateRandomData <ResolverGroupTypeRefData>();
         x.ServiceDesk       = UnitTestHelper.GenerateRandomData <ServiceDesk>();
     });
 }
Example #15
0
        public ServiceComponent GetById(int id)
        {
            ServiceComponent result = null;

            RetryableOperation.Invoke(ExceptionPolicies.General, () =>
            {
                result = _serviceComponentRepository.GetById(id);
            });
            return(result);
        }
        public void ServiceComponentHelper_CanDelete_ChildServiceComponentNotNull_CannotDelete()
        {
            var component = new ServiceComponent
            {
                ChildServiceComponents = new List <ServiceComponent>(),
            };

            component.ChildServiceComponents.Add(new ServiceComponent());
            Assert.IsFalse(_target.CanDelete(component));
        }
        public void ServiceComponentHelper_GetEditState_ComponentHasResolverAndIsLevel1_EditStateLevel1WithResolver()
        {
            var sc = new ServiceComponent
            {
                ComponentLevel = (int)ServiceComponentLevel.Level1,
                Resolver       = UnitTestHelper.GenerateRandomData <Resolver>(),
            };
            var state = _target.GetEditState(sc);

            Assert.AreEqual(ServiceComponentEditState.Level1WithResolver, state);
        }
 public ServiceComponentResolverProcessor(ServiceDesk serviceDesk,
                                          ServiceComponent serviceComponent,
                                          ServiceComponent targetServiceComponent,
                                          ISLMDataContext dataContext,
                                          IUnitOfWork unitOfWork)
 {
     _serviceDesk            = serviceDesk;
     _serviceComponent       = serviceComponent;
     _targetServiceComponent = targetServiceComponent;
     _dataContext            = dataContext;
     _unitOfWork             = unitOfWork;
 }
Example #19
0
        private void RegisterComponents()
        {
            _container = new UnityContainer();

            var businessComponent = new BusinessComponent();
            var dataComponent     = new DataComponent();
            var serviceComponent  = new ServiceComponent();

            _container = businessComponent.Register(_container);
            _container = dataComponent.Register(_container);
            _container = serviceComponent.Register(_container);
        }
Example #20
0
 public ServiceComponentProcessor(ServiceDesk serviceDesk,
                                  ServiceFunction serviceFunction,
                                  ServiceComponent serviceComponent,
                                  ISLMDataContext dataContext,
                                  IUnitOfWork unitOfWork)
 {
     _serviceDesk      = serviceDesk;
     _serviceFunction  = serviceFunction;
     _serviceComponent = serviceComponent;
     _dataContext      = dataContext;
     _unitOfWork       = unitOfWork;
 }
 private static void CreateServiceOrganisationResolverNoResolverDependencies(ServiceComponent component, string organisationType, int id)
 {
     component.Resolver = UnitTestHelper.GenerateRandomData <Resolver>(x =>
     {
         x.Id = id;
         x.ServiceDeliveryOrganisationType = UnitTestHelper.GenerateRandomData <ServiceDeliveryOrganisationTypeRefData>(
             r =>
         {
             r.ServiceDeliveryOrganisationTypeName = organisationType;
         });
         x.ServiceDesk = UnitTestHelper.GenerateRandomData <ServiceDesk>();
     });
 }
Example #22
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;
 }
Example #23
0
        private static void ProcessComponentResolver(bool svcActivities,
                                                     bool opProcs,
                                                     string customerName,
                                                     ServiceComponent component,
                                                     List <List <DotMatrixListItem> > dotMatrix,
                                                     ChartDataListItem chartData)
        {
            var resolver = new ChartDataListItem
            {
                Id            = component.Id,
                Title         = ToBeConfirmed,
                TitleTwo      = string.Empty,
                TitleThree    = string.Empty,
                Type          = DecompositionType.Resolver.ToString(),
                CenteredTitle = string.Empty,
                Units         = new List <ChartDataListItem>()
            };

            if (component.Resolver != null)
            {
                var serviceDeliveryOrganisation =
                    component.Resolver.ServiceDeliveryOrganisationType.ServiceDeliveryOrganisationTypeName.SafeEquals(ServiceDeliveryOrganisationNames.Fujitsu)
                        ? component.Resolver.ServiceDeliveryOrganisationType.ServiceDeliveryOrganisationTypeName
                        : component.Resolver.ServiceDeliveryOrganisationType.ServiceDeliveryOrganisationTypeName.SafeEquals(ServiceDeliveryOrganisationNames.Customer) ? customerName : $"{customerName} Third Party";

                // Add Resolver Group
                resolver = new ChartDataListItem
                {
                    Id            = component.Id,
                    Title         = serviceDeliveryOrganisation,
                    TitleTwo      = !string.IsNullOrEmpty(component.Resolver.ServiceDeliveryUnitType?.ServiceDeliveryUnitTypeName) ? component.Resolver.ServiceDeliveryUnitType.ServiceDeliveryUnitTypeName : ToBeConfirmed,
                    TitleThree    = !string.IsNullOrEmpty(component.Resolver.ResolverGroupType?.ResolverGroupTypeName) ? component.Resolver.ResolverGroupType.ResolverGroupTypeName : ToBeConfirmed,
                    Type          = DecompositionType.Resolver.ToString(),
                    CenteredTitle = string.Empty,
                    Units         = new List <ChartDataListItem>()
                };
            }

            if (svcActivities)
            {
                resolver.ProcessServiceActivities(opProcs, component, dotMatrix);
            }
            else if (opProcs)
            {
                ProcessOpProcs(component, dotMatrix, resolver);
            }

            chartData.Units.Add(resolver);
        }
Example #24
0
        private static ChartDataListItem AddServiceComponent(ServiceComponent component)
        {
            // Add Child Component
            var componentListItem =
                new ChartDataListItem
            {
                Id            = component.Id,
                Title         = component.ComponentName,
                Type          = DecompositionType.Component.ToString(),
                CenteredTitle = string.Empty,
                Units         = new List <ChartDataListItem>()
            };

            return(componentListItem);
        }
Example #25
0
        private void ParseReferencedServices(OSGiProject osgiProject, ServiceComponent serviceComponent,
                                             JSONObject fieldReferencedServices)
        {
            if (fieldReferencedServices == null)
            {
                return;
            }

            List <int> serviceReferences = _referenceResolver.ResolveServiceReferenceList(fieldReferencedServices);

            foreach (int serviceReference in serviceReferences)
            {
                serviceComponent.ReferencedServices.Add(osgiProject.Services[serviceReference]);
                osgiProject.Services[serviceReference].ReferencingComponents.Add(serviceComponent);
            }
        }
        public void ServiceComponentHelper_GetEditState_ComponentHasChildComponentAndIsLevel1_EditStateLevel1WithChildComponent()
        {
            var sc = new ServiceComponent
            {
                ComponentLevel         = (int)ServiceComponentLevel.Level1,
                ChildServiceComponents = new List <ServiceComponent> {
                    new ServiceComponent {
                        Id             = 4567,
                        ComponentLevel = (int)ServiceComponentLevel.Level2, ComponentName = "Test"
                    }
                }
            };

            var state = _target.GetEditState(sc);

            Assert.AreEqual(ServiceComponentEditState.Level1WithChildComponent, state);
        }
Example #27
0
        private static void AddComponentWithChildren(bool svcActivities, string organisationType,
                                                     ChartDataListItem chartData, ServiceComponent component)
        {
            foreach (
                var childComponent in component.ChildServiceComponents.Where(c => c.Resolver != null && c.Resolver.ServiceDeliveryOrganisationType
                                                                             .ServiceDeliveryOrganisationTypeName == organisationType).OrderBy(c => c.DiagramOrder).ThenBy(c => c.ComponentName))
            {
                var childComponentListItem = AddServiceComponent(childComponent);

                if (svcActivities)
                {
                    AddServiceActivity(childComponent, childComponentListItem);
                }

                chartData.Units.Add(childComponentListItem);
            }
        }
        protected void SaveServiceComponentResolver(ServiceComponent component, EditServiceComponentWithResolverViewModel model)
        {
            if (!model.ResolverServiceDeliveryOrganisation.ServiceDeliveryOrganisationTypeId.HasValue ||
                !(model.ResolverServiceDeliveryOrganisation.ServiceDeliveryOrganisationTypeId > 0))
            {
                return;
            }

            component.Resolver.ServiceDeliveryOrganisationType = _serviceDeliveryOrganisationTypeRefDataService.GetById(model.ResolverServiceDeliveryOrganisation.ServiceDeliveryOrganisationTypeId.Value);

            component.Resolver.ServiceDeliveryOrganisationNotes = model.ResolverServiceDeliveryOrganisation.ServiceDeliveryOrganisationNotes;

            if (model.ResolverServiceDeliveryUnit.ServiceDeliveryUnitTypeId.HasValue &&
                model.ResolverServiceDeliveryUnit.ServiceDeliveryUnitTypeId > 0)
            {
                component.Resolver.ServiceDeliveryUnitType =
                    _serviceDeliveryUnitTypeRefDataService.GetById(
                        model.ResolverServiceDeliveryUnit.ServiceDeliveryUnitTypeId.Value);
            }
            else
            {
                component.Resolver.ServiceDeliveryUnitType = null;
            }

            component.Resolver.ServiceDeliveryUnitNotes =
                model.ResolverServiceDeliveryUnit.ServiceDeliveryUnitNotes;

            if (model.ResolverGroup.ResolverGroupTypeId.HasValue && model.ResolverGroup.ResolverGroupTypeId > 0)
            {
                var resolverGroupType = _resolverGroupTypeRefDataService.GetById(model.ResolverGroup.ResolverGroupTypeId.Value);
                component.Resolver.ResolverGroupType = resolverGroupType;

                var customerSpecificTypeThreshold = _parameterService.GetParameterByNameAndCache <int>(ParameterNames.CustomerSpecificTypeThreshold);
                if (!resolverGroupType.Visible &&
                    _resolverGroupTypeRefDataService.GetNumberOfResolverGroupTypeReferences(resolverGroupType.Id) >= customerSpecificTypeThreshold - 1)
                {
                    resolverGroupType.Visible = true;
                    _resolverGroupTypeRefDataService.Update(resolverGroupType);
                }
            }
            else
            {
                component.Resolver.ResolverGroupType = null;
            }
        }
Example #29
0
 public static void ProcessResolvers(this ChartDataListItem chartData,
                                     bool svcActivities,
                                     bool opProcs,
                                     string customerName,
                                     ServiceComponent component,
                                     List <List <DotMatrixListItem> > dotMatrix)
 {
     if (component.ChildServiceComponents != null && component.ChildServiceComponents.Any())
     {
         foreach (var childComponent in component.ChildServiceComponents)
         {
             ProcessComponentResolver(svcActivities, opProcs, customerName, childComponent, dotMatrix, chartData);
         }
     }
     else
     {
         ProcessComponentResolver(svcActivities, opProcs, customerName, component, dotMatrix, chartData);
     }
 }
Example #30
0
        private static void AddServiceActivity(ServiceComponent component, ChartDataListItem chartData)
        {
            // Add Service Activity
            if (component.Resolver != null)
            {
                if (!string.IsNullOrEmpty(component.ServiceActivities))
                {
                    AddResolverServiceActivity(component.Id, component.ServiceActivities, chartData);
                    return;
                }
                if (component.ComponentLevel == (int)ServiceComponentLevel.Level2 && !string.IsNullOrEmpty(component.ParentServiceComponent.ServiceActivities))
                {
                    AddResolverServiceActivity(component.Id, component.ParentServiceComponent.ServiceActivities, chartData);
                    return;
                }
            }

            AddResolverServiceActivity(component.Id, NoneSpecified, chartData);
        }