public static ServiceFunction GetSourceFunction(this ServiceFunction value, int serviceFunctionId) { using (var sourceDb = new SLMDataContext("Name=SLMSourceDataContext")) { // For expediency grab everything and store in memory return(sourceDb.ServiceFunctions.AsNoTracking() .Include(c => c.ServiceDomain) .Include(c => c.FunctionType) .Include(c => c.ServiceComponents) .Include(c => c.ServiceComponents.Select(cc => cc.ChildServiceComponents)) .Include(c => c.ServiceComponents.Select(r => r.Resolver)) .Include(c => c.ServiceComponents.Select(r => r.Resolver.OperationalProcessTypes.Select(op => op.OperationalProcessTypeRefData))) .Include(c => c.ServiceComponents.Select(r => r.Resolver.ServiceDeliveryOrganisationType)) .Include(c => c.ServiceComponents.Select(r => r.Resolver.ServiceDeliveryUnitType)) .Include(c => c.ServiceComponents.Select(r => r.Resolver.ResolverGroupType)) .Include(c => c.ServiceComponents.Select(r => r.Resolver.ServiceComponent)) .Include(c => c.ServiceComponents.Select(r => r.Resolver.ServiceDesk)) .Include(c => c.ServiceComponents.Select(cc => cc.ChildServiceComponents.Select(ccr => ccr.Resolver))) .Include(c => c.ServiceComponents.Select(cc => cc.ChildServiceComponents.Select(ccr => ccr.Resolver.OperationalProcessTypes.Select(op => op.OperationalProcessTypeRefData)))) .Include(c => c.ServiceComponents.Select(cc => cc.ChildServiceComponents.Select(ccr => ccr.Resolver.ServiceDeliveryOrganisationType))) .Include(c => c.ServiceComponents.Select(cc => cc.ChildServiceComponents.Select(ccr => ccr.Resolver.ServiceDeliveryUnitType))) .Include(c => c.ServiceComponents.Select(cc => cc.ChildServiceComponents.Select(ccr => ccr.Resolver.ResolverGroupType))) .Include(c => c.ServiceComponents.Select(cc => cc.ChildServiceComponents.Select(ccr => ccr.Resolver.ServiceComponent))) .Include(c => c.ServiceComponents.Select(cc => cc.ChildServiceComponents.Select(ccr => ccr.Resolver.ServiceDesk))) .FirstOrDefault(x => x.Id == serviceFunctionId)); } }
public void ServiceFunctionService_Update_CallUpdatesFunctionAndCallsSaveChanges() { #region Arrange var dateTimeNow = DateTime.Now; var serviceFunction = new ServiceFunction { Id = 3, FunctionType = _serviceFunctionTypes.FirstOrDefault(x => x.Id == 1), ServiceDomain = new ServiceDomain { Id = 1, ServiceDeskId = 1 }, InsertedBy = Username, InsertedDate = dateTimeNow, UpdatedBy = Username, UpdatedDate = dateTimeNow, }; #endregion #region Act _serviceFunctionService.Update(serviceFunction); #endregion #region Assert _mockServiceFunctionRepository.Verify(x => x.Update(It.IsAny <ServiceFunction>()), Times.Once()); _mockUnitOfWork.Verify(x => x.Save(), Times.Exactly(1)); #endregion }
private void TransformServiceFunction(ServiceDomain serviceDomain, TemplateRow templateRow) { var serviceFunction = serviceDomain.ServiceFunctions.FirstOrDefault(d => d.FunctionType.FunctionName.Trim() == templateRow.ServiceFunction.Trim()); if (serviceFunction == null) { var dateTimeNow = DateTime.Now; serviceFunction = new ServiceFunction { ServiceDomain = serviceDomain, FunctionType = _functionTypeRefDataService.InsertorUpdate(templateRow.ServiceFunction), ServiceComponents = new List <ServiceComponent>(), DiagramOrder = 5, InsertedBy = _userIdentity.Name, InsertedDate = dateTimeNow, UpdatedBy = _userIdentity.Name, UpdatedDate = dateTimeNow }; serviceDomain.ServiceFunctions.Add(serviceFunction); _serviceDomainService.Update(serviceDomain); } if (!string.IsNullOrEmpty(templateRow.ServiceComponentLevel1)) { TransformComponentLevelOne(serviceFunction, templateRow); } }
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); } }
public void Update(ServiceFunction entity) { RetryableOperation.Invoke(ExceptionPolicies.General, () => { _serviceFunctionRepository.Update(entity); _unitOfWork.Save(); }); }
public AdvertiseServiceOptions(string service, ServiceFunction <MReq, MRes> serviceCallback) { this.Service = service; ServiceCallback = serviceCallback; Helper = new ServiceCallbackHelper <MReq, MRes>(serviceCallback); RequestDataType = new MReq().MessageType.Replace("/Request", "__Request"); ResponseDataType = new MRes().MessageType.Replace("/Response", "__Response"); SrvType = RequestDataType.Replace("__Request", ""); Md5Sum = RosService.Generate(SrvType).MD5Sum(); }
public int Create(ServiceFunction entity) { RetryableOperation.Invoke(ExceptionPolicies.General, () => { _serviceFunctionRepository.Insert(entity); _unitOfWork.Save(); }); return(entity.Id); }
/// <summary> /// Advertises a named ServiceServer /// </summary> /// <typeparam name="MReq">Request sub-srv type</typeparam> /// <typeparam name="MRes">Response sub-srv type</typeparam> /// <param name="service">The name of the service to advertise</param> /// <param name="srv_func">The handler for the service</param> /// <returns>The ServiceServer that will call the ServiceFunction on behalf of ServiceClients</returns> public ServiceServer advertiseService <MReq, MRes>(string service, ServiceFunction <MReq, MRes> srv_func) where MReq : IRosMessage, new() where MRes : IRosMessage, new() { if (started_by_visual_studio) { return(null); } return(advertiseService(new AdvertiseServiceOptions <MReq, MRes>(service, srv_func))); }
public ServiceFunction GetById(int id) { ServiceFunction result = null; RetryableOperation.Invoke(ExceptionPolicies.General, () => { result = _serviceFunctionRepository.GetById(id); }); return(result); }
public AdvertiseServiceOptions(string service, ServiceFunction <MReq, MRes> serviceCallback) { this.service = service; srv_func = serviceCallback; helper = new ServiceCallbackHelper <MReq, MRes>(serviceCallback); req_datatype = new MReq().MessageType.Replace("/Request", "__Request"); res_datatype = new MRes().MessageType.Replace("/Response", "__Response"); SrvType = req_datatype.Replace("__Request", ""); datatype = SrvType; md5sum = RosService.Generate(SrvType).MD5Sum(); }
public void init(string service, ServiceFunction <MReq, MRes> callback) { this.service = service; srv_func = callback; helper = new ServiceCallbackHelper <MReq, MRes>(callback); req_datatype = new MReq().msgtype.ToString().Replace("__", "/").Replace("/Request", "__Request"); res_datatype = new MRes().msgtype.ToString().Replace("__", "/").Replace("/Response", "__Response"); srvtype = (SrvTypes)Enum.Parse(typeof(SrvTypes), req_datatype.Replace("__Request", "").Replace("/", "__")); datatype = srvtype.ToString().Replace("__", "/"); md5sum = IRosService.generate(srvtype).MD5Sum; }
public ServiceComponentProcessor(ServiceDesk serviceDesk, ServiceFunction serviceFunction, ServiceComponent serviceComponent, ISLMDataContext dataContext, IUnitOfWork unitOfWork) { _serviceDesk = serviceDesk; _serviceFunction = serviceFunction; _serviceComponent = serviceComponent; _dataContext = dataContext; _unitOfWork = unitOfWork; }
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; }
public void Execute() { foreach (var serviceFunction in _serviceFunctions) { var serviceFunctionTypeRefData = serviceFunction.FunctionType; if (!_dataContext.FunctionTypeRefData.Any(x => x.FunctionName == serviceFunctionTypeRefData.FunctionName)) { var functionType = new FunctionTypeRefData { FunctionName = serviceFunctionTypeRefData.FunctionName, Visible = serviceFunctionTypeRefData.Visible, SortOrder = serviceFunctionTypeRefData.SortOrder }; _dataContext.FunctionTypeRefData.Add(functionType); _unitOfWork.Save(); } var functionTypeRefData = _dataContext.FunctionTypeRefData.Single(x => x.FunctionName == serviceFunctionTypeRefData.FunctionName); var newServiceFunction = new ServiceFunction { ServiceDomainId = _serviceDomain.Id, ServiceDomain = _serviceDomain, FunctionType = functionTypeRefData, FunctionTypeId = functionTypeRefData.Id, AlternativeName = serviceFunction.AlternativeName, ServiceComponents = new List <ServiceComponent>(), InsertedBy = serviceFunction.InsertedBy, InsertedDate = serviceFunction.InsertedDate, UpdatedBy = serviceFunction.UpdatedBy, UpdatedDate = serviceFunction.UpdatedDate }; _serviceDomain.ServiceFunctions.Add(newServiceFunction); _unitOfWork.Save(); } }
public void Delete(ServiceFunction 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("spDeleteServiceFunction", dbConnection, transaction, new SqlParameter("@ServiceFunctionId", 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 ServiceFunctionService_Create_CallInsertsFunctionAndCallsSaveChanges() { #region Arrange var dateTimeNow = DateTime.Now; var serviceFunction = new ServiceFunction() { Id = 5, FunctionType = _serviceFunctionTypes.FirstOrDefault(x => x.Id == 1), ServiceDomain = new ServiceDomain { Id = 1, ServiceDeskId = 1 }, InsertedBy = Username, InsertedDate = dateTimeNow, UpdatedBy = Username, UpdatedDate = dateTimeNow, }; #endregion #region Act var response = _serviceFunctionService.Create(serviceFunction); #endregion #region Assert _mockServiceFunctionRepository.Verify(x => x.Insert(It.IsAny <ServiceFunction>()), Times.Once()); _mockUnitOfWork.Verify(x => x.Save(), Times.Exactly(1)); Assert.IsNotNull(response); Assert.AreEqual(_serviceFunctions.Count, response); #endregion }
public ServiceCallbackHelper(ServiceFunction <MReq, MRes> srv_func) { // TODO: Complete member initialization _callback = srv_func; }
public AdvertiseServiceOptions(string service, ServiceFunction <MReq, MRes> srv_func) { // TODO: Complete member initialization init(service, srv_func); }
/// <summary> /// Advertises a named ServiceServer /// </summary> /// <typeparam name="MReq">Request sub-srv type</typeparam> /// <typeparam name="MRes">Response sub-srv type</typeparam> /// <param name="service">The name of the service to advertise</param> /// <param name="srv_func">The handler for the service</param> /// <returns>The ServiceServer that will call the ServiceFunction on behalf of ServiceClients</returns> public ServiceServer advertiseService <MReq, MRes>(string service, ServiceFunction <MReq, MRes> srv_func) where MReq : IRosMessage, new() where MRes : IRosMessage, new() { return(advertiseService(new AdvertiseServiceOptions <MReq, MRes>(service, srv_func))); }
protected IServiceCallbackHelper(ServiceFunction <RosMessage, RosMessage> callback) { this.callback = callback; }
public ServiceCallbackHelper(ServiceFunction <MReq, MRes> srv_func) { callback = srv_func; }
public ActionResult CreateAjaxServiceAddFunctionGrid([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable <BulkServiceFunctionViewModel> serviceFunctions) { var inputFunctions = serviceFunctions as IList <BulkServiceFunctionViewModel> ?? serviceFunctions.ToList(); var outputFunctions = new List <BulkServiceFunctionViewModel>(); if (ModelState.IsValid) { try { var customerSpecificTypeThreshold = _parameterService.GetParameterByNameAndCache <int>(ParameterNames.CustomerSpecificTypeThreshold); if (serviceFunctions != null && inputFunctions.Any()) { var userName = _contextManager.UserManager.Name; var now = DateTime.Now; var customerId = _appUserContext.Current.CurrentCustomer.Id; // Make sure all the of the specified Service Domains exist. var checkServiceDomainIds = inputFunctions .Where(w => w.ServiceDomainId.HasValue) .Select(s => s.ServiceDomainId.Value) .Distinct() .ToList(); var serviceDomainIds = _serviceDomainService.GetByCustomer(customerId) .Where(w => checkServiceDomainIds.Contains(w.Id)) .Select(s => s.Id) .ToList(); foreach (var inputFunction in inputFunctions) { if (!inputFunction.ServiceDomainId.HasValue || inputFunction.ServiceDomainId == 0 || inputFunction.FunctionTypeId == 0 || !serviceDomainIds.Contains(inputFunction.ServiceDomainId.Value)) { continue; } var diagramDisplayOrder = inputFunction.DiagramOrder ?? 5; if (diagramDisplayOrder < 1) { diagramDisplayOrder = 5; } var newServiceFunction = new ServiceFunction { AlternativeName = inputFunction.AlternativeName, DiagramOrder = diagramDisplayOrder, FunctionTypeId = inputFunction.FunctionTypeId, ServiceDomainId = inputFunction.ServiceDomainId.Value, InsertedBy = userName, InsertedDate = now, UpdatedBy = userName, UpdatedDate = now }; newServiceFunction.Id = _serviceFunctionService.Create(newServiceFunction); outputFunctions.Add(Mapper.Map <BulkServiceFunctionViewModel>(newServiceFunction)); var functionType = _functionTypeRefDataService.GetById(inputFunction.FunctionTypeId); if (!functionType.Visible && _functionTypeRefDataService.GetNumberOfFunctionTypeReferences(inputFunction.FunctionTypeId) >= customerSpecificTypeThreshold) { functionType.Visible = true; _functionTypeRefDataService.Update(functionType); } } } } catch (Exception ex) { _contextManager.ResponseManager.StatusCode = 500; _contextManager.ResponseManager.AppendHeader(ModelStateErrorNames.ErrorMessage, ex.Message); } } return(Json(outputFunctions.ToDataSourceResult(request, ModelState))); }
public virtual ServiceFunction <RosMessage, RosMessage> Callback(ServiceFunction <RosMessage, RosMessage> cb) { callback = cb; return(callback); }
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}"); } } } } }
protected IServiceCallbackHelper(ServiceFunction <IRosMessage, IRosMessage> Callback) { //EDB.WriteLine("ISubscriptionCallbackHelper: 1 arg constructor"); //throw new NotImplementedException(); _callback = Callback; }
public static void ProcessServiceComponents(this ChartDataListItem chartData, bool resolvers, bool svcActivities, bool opProcs, string customerName, ServiceFunction domainFunction, List <List <DotMatrixListItem> > dotMatrix) { if (domainFunction.ServiceComponents == null) { return; } foreach (var parentComponent in domainFunction.ServiceComponents.Where(x => x.ComponentLevel == 1).OrderBy(x => x.DiagramOrder).ThenBy(x => x.ComponentName).ToList()) { var parentComponentListItem = new ChartDataListItem { Id = parentComponent.Id, Title = parentComponent.ComponentName, Type = DecompositionType.Component.ToString(), CenteredTitle = string.Empty, Units = new List <ChartDataListItem>() }; if (parentComponent.ChildServiceComponents != null && parentComponent.ChildServiceComponents.Count > 0) { foreach (var childComponent in parentComponent.ChildServiceComponents.OrderBy(x => x.DiagramOrder).ThenBy(x => x.ComponentName)) { // Add Child Component var childComponentListItem = new ChartDataListItem { Id = childComponent.Id, Title = childComponent.ComponentName, Type = DecompositionType.Component.ToString(), CenteredTitle = string.Empty, Units = new List <ChartDataListItem>() }; if (resolvers) { childComponentListItem.ProcessResolvers(svcActivities, opProcs, customerName, childComponent, dotMatrix); } else if (svcActivities) { childComponentListItem.ProcessServiceActivities(opProcs, childComponent, dotMatrix); } parentComponentListItem.Units.Add(childComponentListItem); } } else if (resolvers || svcActivities) { // Create A Dummy Child Component var childComponentListItem = new ChartDataListItem { Id = 0, Title = string.Empty, CenteredTitle = string.Empty, Type = DecompositionType.LineForDummyChildComponent.ToString(), Units = new List <ChartDataListItem>() }; if (resolvers) { childComponentListItem.ProcessResolvers(svcActivities, opProcs, customerName, parentComponent, dotMatrix); } else { childComponentListItem.ProcessServiceActivities(opProcs, parentComponent, dotMatrix); } if (childComponentListItem.Units.Any()) { parentComponentListItem.Units.Add(childComponentListItem); } } chartData.Units.Add(parentComponentListItem); } }
public virtual ServiceFunction <IRosMessage, IRosMessage> callback(ServiceFunction <IRosMessage, IRosMessage> cb) { _callback = cb; return(_callback); }
protected IServiceCallbackHelper(ServiceFunction <RosMessage, RosMessage> Callback) { _callback = Callback; }