private MenuList BuildSection(DynamicService service)
 {
     var items = service.GetActions()
         .Select(s => BuildMenuItem(s, service))
         .Where(s => s != null);
     var section = Menu.Items(service.Name, items.ToArray());
     // mvc contrib menu builder should allow me to controll collapsing menus with one item instead of just doing it: idiots
     if (items.Count() == 1)
     {
         section[0].Title = string.Format("{0} - {1}", service.Name, section[0].Title);
     }
     return section;
 }
        public DynamicService CreateServiceEntry()
        {
            var findServices = new DynamicService {
                Name = HandlesType(), DataListSpecification = new StringBuilder("<DataList><ResourceType ColumnIODirection=\"Input\"/><Roles ColumnIODirection=\"Input\"/><ResourceName ColumnIODirection=\"Input\"/><ResourceId ColumnIODirection=\"Input\"/><Dev2System.ManagmentServicePayload ColumnIODirection=\"Both\"></Dev2System.ManagmentServicePayload></DataList>")
            };

            var findServiceAction = new ServiceAction {
                Name = HandlesType(), ActionType = enActionType.InvokeManagementDynamicService, SourceMethod = HandlesType()
            };

            findServices.Actions.Add(findServiceAction);

            return(findServices);
        }
Example #3
0
        public DynamicService CreateServiceEntry()
        {
            DynamicService reloadResourceServicesBinder = new DynamicService {
                Name = HandlesType(), DataListSpecification = new StringBuilder("<DataList><ResourceID ColumnIODirection=\"Input\"/><ResourceType ColumnIODirection=\"Input\"/><Dev2System.ManagmentServicePayload ColumnIODirection=\"Both\"></Dev2System.ManagmentServicePayload></DataList>")
            };

            ServiceAction reloadResourceServiceActionBinder = new ServiceAction {
                Name = HandlesType(), SourceMethod = HandlesType(), ActionType = enActionType.InvokeManagementDynamicService
            };

            reloadResourceServicesBinder.Actions.Add(reloadResourceServiceActionBinder);

            return(reloadResourceServicesBinder);
        }
Example #4
0
        private MenuList BuildSection(DynamicService service)
        {
            var items = service.GetActions()
                        .Select(s => BuildMenuItem(s, service))
                        .Where(s => s != null);
            var section = Menu.Items(service.Name, items.ToArray());

            // mvc contrib menu builder should allow me to controll collapsing menus with one item instead of just doing it: idiots
            if (items.Count() == 1)
            {
                section[0].Title = string.Format("{0} - {1}", service.Name, section[0].Title);
            }
            return(section);
        }
Example #5
0
        public DynamicService CreateServiceEntry()
        {
            DynamicService pluginMetaDataService = new DynamicService {
                Name = HandlesType(), DataListSpecification = new StringBuilder("<DataList><AssemblyLocation ColumnIODirection=\"Input\"/><ProtectionLevel ColumnIODirection=\"Input\"/><NameSpace ColumnIODirection=\"Input\"/><MethodName ColumnIODirection=\"Input\"/><Dev2System.ManagmentServicePayload ColumnIODirection=\"Both\"></Dev2System.ManagmentServicePayload></DataList>")
            };

            ServiceAction pluginMetaDataAction = new ServiceAction {
                Name = HandlesType(), SourceMethod = HandlesType(), ActionType = enActionType.InvokeManagementDynamicService
            };

            pluginMetaDataService.Actions.Add(pluginMetaDataAction);

            return(pluginMetaDataService);
        }
Example #6
0
        public DynamicService CreateServiceEntry()
        {
            DynamicService findDirectoryService = new DynamicService {
                Name = HandlesType(), DataListSpecification = new StringBuilder("<DataList><Directory ColumnIODirection=\"Input\"/><FilePath ColumnIODirection=\"Input\"/><Dev2System.ManagmentServicePayload ColumnIODirection=\"Both\"></Dev2System.ManagmentServicePayload></DataList>")
            };

            ServiceAction findDirectoryServiceAction = new ServiceAction {
                Name = HandlesType(), ActionType = enActionType.InvokeManagementDynamicService, SourceMethod = HandlesType()
            };

            findDirectoryService.Actions.Add(findDirectoryServiceAction);

            return(findDirectoryService);
        }
Example #7
0
        public DynamicService CreateServiceEntry()
        {
            var workspaceItemService = new DynamicService {
                Name = HandlesType(), DataListSpecification = new StringBuilder("<DataList><IsLocalSave ColumnIODirection=\"Input\"/><ItemXml ColumnIODirection=\"Input\"/><Roles ColumnIODirection=\"Input\"/><Dev2System.ManagmentServicePayload ColumnIODirection=\"Both\"></Dev2System.ManagmentServicePayload></DataList>")
            };

            var workspaceItemAction = new ServiceAction {
                Name = HandlesType(), ActionType = enActionType.InvokeManagementDynamicService, SourceMethod = HandlesType()
            };

            workspaceItemService.Actions.Add(workspaceItemAction);

            return(workspaceItemService);
        }
Example #8
0
        /// <summary>
        ///     根据字段求和 统计报表
        /// </summary>
        /// <param name="reportInput"></param>
        /// <returns></returns>
        public Tuple <ServiceResult, List <AutoReport> > GetSumReport2(SumTableInput reportInput)
        {
            var returnList = new List <AutoReport>();

            #region 安全验证

            if (reportInput == null)
            {
                if (string.IsNullOrEmpty(reportInput.Type))
                {
                    return(Tuple.Create(ServiceResult.Failure("实体类型不能为空"), returnList));
                }

                return(Tuple.Create(ServiceResult.Failure("实体类型不能为空"), returnList));
            }

            Type   typeFind     = null;
            object instanceFind = null;
            var    checkType    = Resolve <IUIBaseService>().CheckType(reportInput.Type, ref typeFind, ref instanceFind);
            if (!checkType.Succeeded)
            {
                return(Tuple.Create(ServiceResult.Failure("实体类型不存在"), returnList));
            }

            if (!(instanceFind is IEntity)) // 非实体类型不能完成数据统计
            {
                return(Tuple.Create(ServiceResult.Failure("非实体类型不能进行数据统计"), returnList));
            }

            if (reportInput.Fields.Count <= 0)
            {
                return(Tuple.Create(ServiceResult.Failure("统计的字段不能为空"), returnList));
            }

            //验证传入的统计字段和表是否匹配
            var fieldsList = reportInput.Fields;
            fieldsList.ForEach(p => { });

            #endregion 安全验证

            var table = Resolve <ITableService>().GetSingle(r => r.Key == typeFind.Name);
            if (table == null)
            {
                return(Tuple.Create(ServiceResult.Failure("查询的表不存在"), returnList));
            }

            var rs     = DynamicService.ResolveMethod(typeFind.Name, "GetSumReport", reportInput);
            var rsList = rs.Item2 as List <AutoReport>;
            return(Tuple.Create(ServiceResult.Success, rsList));
        }
Example #9
0
        public DynamicService CreateServiceEntry()
        {
            DynamicService getScheduledResourcesService = new DynamicService {
                Name = HandlesType(), DataListSpecification = new StringBuilder("<DataList></DataList>")
            };

            ServiceAction getScheduledResourcesAction = new ServiceAction {
                Name = HandlesType(), ActionType = enActionType.InvokeManagementDynamicService, SourceName = HandlesType(), SourceMethod = HandlesType()
            };

            getScheduledResourcesService.Actions.Add(getScheduledResourcesAction);

            return(getScheduledResourcesService);
        }
Example #10
0
        public DynamicService CreateServiceEntry()
        {
            var getServerVersion = new ServiceAction {
                Name = HandlesType(), ActionType = enActionType.InvokeManagementDynamicService, SourceMethod = HandlesType()
            };

            var getServerVersionService = new DynamicService {
                Name = HandlesType(), DataListSpecification = new StringBuilder("<DataList><Dev2System.ManagmentServicePayload ColumnIODirection=\"Both\"></Dev2System.ManagmentServicePayload></DataList>")
            };

            getServerVersionService.Actions.Add(getServerVersion);

            return(getServerVersionService);
        }
Example #11
0
        public List <DynamicServiceObjectBase> GenerateServiceGraph(StringBuilder serviceData)
        {
            if (serviceData == null || serviceData.Length == 0)
            {
                throw new ArgumentException("serviceData");
            }
            var result = new List <DynamicServiceObjectBase>();
            var xe     = serviceData.ToXElement();

            if (IsSource(serviceData))
            {
                var src = new Source();
                var tmp = src as DynamicServiceObjectBase;
                ServiceMetaData.ExtractMetaData(xe, ref tmp);

                var typeOf = xe.AttributeSafe("ResourceType");

                src.Type = !Enum.TryParse(typeOf, out enSourceType sourceType) ? enSourceType.Unknown : sourceType;

                src.ConnectionString = xe.AttributeSafe("ConnectionString");
                src.AssemblyName     = xe.AttributeSafe("AssemblyName");
                src.AssemblyLocation = xe.AttributeSafe("AssemblyLocation");

                // PBI 6597: TWR - added source ID check
                var id = ServiceMetaData.SetID(ref xe);
                src.ID = id;
                src.ResourceDefinition = serviceData;

                result.Add(src);
            }
            else
            {
                var ds  = new DynamicService();
                var tmp = ds as DynamicServiceObjectBase;
                ServiceMetaData.ExtractMetaData(xe, ref tmp);

                // set the resource def ;)
                ds.ResourceDefinition = serviceData;

                var actions = xe.Element("Actions");
                var action  = actions != null?actions.Element("Action") : xe.Element("Action");

                if (action != null)
                {
                    xe = AddServiceAction(serviceData, result, xe, ds, action);
                }
            }
            return(result);
        }
        public async Task NullEndpointTest()
        {
            var serviceInfo = new ServiceInfo();
            var cacheRegion = "cacheRegion";

            var cache             = Substitute.For <ICache>();
            var httpClientWrapper = Substitute.For <IHttpClientWrapper>();
            var tokenService      = Substitute.For <ITokenService>();

            var sut = new DynamicService(cache, httpClientWrapper, tokenService);

            ServiceResponse actual = await sut.CallService(serviceInfo, cacheRegion, CancellationToken.None, null);

            Assert.IsNull(actual);
        }
        public DynamicService CreateServiceEntry()
        {
            DynamicService newDs = new DynamicService();

            newDs.Name = HandlesType();
            newDs.DataListSpecification = "<DataList><Roles/><ResourceXml/><Dev2System.ManagmentServicePayload ColumnIODirection=\"Both\"></Dev2System.ManagmentServicePayload></DataList>";
            ServiceAction sa = new ServiceAction();

            sa.Name         = HandlesType();
            sa.ActionType   = enActionType.InvokeManagementDynamicService;
            sa.SourceMethod = HandlesType();
            newDs.Actions.Add(sa);

            return(newDs);
        }
        public void ServiceActionRepo_ReadFromCache_WhenNotExisting_ShouldReturnNull()
        {
            //------------Setup for test--------------------------
            var id = Guid.NewGuid();
            var ds = new DynamicService {
                DisplayName = "Ds 1"
            };

            ServiceActionRepo.Instance.AddToCache(id, ds);
            //------------Execute Test---------------------------
            var readDs = ServiceActionRepo.Instance.ReadCache(Guid.NewGuid());

            //------------Assert Results-------------------------
            Assert.IsNull(readDs);
        }
Example #15
0
        public void WorkflowResume_Execute_Returns_Execution_Completed()
        {
            //------------Setup for test--------------------------
            var resourceID = Guid.NewGuid();
            var values     = new Dictionary <string, StringBuilder>
            {
                { "resourceID", new StringBuilder(resourceID.ToString()) },
                { "environment", new StringBuilder("") },
                { "startActivityId", new StringBuilder("4032a11e-4fb3-4208-af48-b92a0602ab4b") },
                { "versionNumber", new StringBuilder("1") },
                { "currentuserprincipal", new StringBuilder(WindowsIdentity.GetCurrent().Name) }
            };
            var resourceCatalog = new Mock <IResourceCatalog>();
            var newDs           = new DynamicService {
                Name = HandlesType(), ID = resourceID
            };
            var sa = new ServiceAction {
                Name = HandlesType(), ActionType = enActionType.InvokeManagementDynamicService, SourceMethod = HandlesType()
            };

            newDs.Actions.Add(sa);
            resourceCatalog.Setup(catalog => catalog.GetService(GlobalConstants.ServerWorkspaceID, It.IsAny <Guid>(), "")).Returns(newDs);


            var errors = new ErrorResultTO();
            var mockResumableExecutionContainer = new Mock <IResumableExecutionContainer>();

            mockResumableExecutionContainer.Setup(o => o.Execute(out errors, 0)).Verifiable();

            var mockResumableExecutionContainerFactory = new Mock <IResumableExecutionContainerFactory>();

            mockResumableExecutionContainerFactory.Setup(o => o.New(It.IsAny <Guid>(), It.IsAny <ServiceAction>(), It.IsAny <DsfDataObject>()))
            .Returns(mockResumableExecutionContainer.Object);
            CustomContainer.Register(mockResumableExecutionContainerFactory.Object);
            //------------Execute Test---------------------------

            var workflowResume = new WorkflowResume();

            workflowResume.ResourceCatalogInstance = resourceCatalog.Object;
            var jsonResult = workflowResume.Execute(values, null);

            //------------Assert Results-------------------------
            var serializer = new Dev2JsonSerializer();
            var result     = serializer.Deserialize <ExecuteMessage>(jsonResult);

            Assert.IsFalse(result.HasError);
            Assert.AreEqual("Execution Completed.", result.Message.ToString());
        }
        public void ServiceActionRepo_AddToCache_WhenNotExisting_ShouldAdd()
        {
            //------------Setup for test--------------------------
            var id = Guid.NewGuid();
            var ds = new DynamicService {
                DisplayName = "Ds 1"
            };

            //------------Execute Test---------------------------
            ServiceActionRepo.Instance.AddToCache(id, ds);
            //------------Assert Results-------------------------
            var readDs = ServiceActionRepo.Instance.ReadCache(id);

            Assert.IsNotNull(readDs);
            Assert.AreEqual("Ds 1", readDs.DisplayName);
        }
Example #17
0
        /// <summary>
        ///     根据字段求和 生成报表表格
        /// </summary>
        /// <param name="reportInput"></param>
        /// <returns></returns>
        public Tuple <ServiceResult, PagedList <SumReportTable> > GetCountSumTable2(SumTableInput reportInput)
        {
            var resultPage = new PagedList <SumReportTable>();

            #region 安全验证

            if (reportInput == null)
            {
                if (string.IsNullOrEmpty(reportInput.Type))
                {
                    return(Tuple.Create(ServiceResult.FailedMessage("实体类型不能为空"), resultPage));
                }

                return(Tuple.Create(ServiceResult.FailedMessage("实体类型不能为空"), resultPage));
            }

            Type   typeFind     = null;
            object instanceFind = null;
            var    checkType    = Resolve <IUIBaseService>().CheckType(reportInput.Type, ref typeFind, ref instanceFind);

            if (!checkType.Succeeded)
            {
                return(Tuple.Create(ServiceResult.FailedMessage("所输入实体不存在"), resultPage));
            }

            if (!(instanceFind is IEntity)) // 非实体类型不能完成数据统计
            {
                return(Tuple.Create(ServiceResult.FailedMessage("非实体类型不能进行数据统计"), resultPage));
            }

            if (reportInput.Fields.Count <= 0)
            {
                return(Tuple.Create(ServiceResult.FailedMessage("统计的字段不能为空"), resultPage));
            }

            #endregion 安全验证

            var table = Resolve <ITableService>().GetSingle(r => r.Key == typeFind.Name);
            if (table == null)
            {
                return(Tuple.Create(ServiceResult.FailedMessage("查询的表不存在"), resultPage));
            }

            var rs     = DynamicService.ResolveMethod(typeFind.Name, "GetSumReportTable", reportInput);
            var rsList = rs.Item2 as PagedList <SumReportTable>;
            return(Tuple.Create(ServiceResult.Success, rsList));
        }
Example #18
0
        private void ExecuteBackJob(TaskQueue taskQueue)
        {
            var backJobParameter = taskQueue.Parameter.ToObject <BackJobParameter>();

            if (backJobParameter != null)
            {
                if (backJobParameter.Parameter.IsNullOrEmpty()) // 无参数方法
                {
                    DynamicService.ResolveMethod(backJobParameter.ServiceName, backJobParameter.Method);
                }
                else   // 有参数方法
                {
                    DynamicService.ResolveMethod(backJobParameter.ServiceName, backJobParameter.Method,
                                                 backJobParameter.Parameter);
                }
            }
        }
Example #19
0
        public void GenerateInvokeContainer_GivenValidArgsAndIsLocalInvokeTrueEmptyCacheNewService_IsTestExecution_ShouldAddToCache()
        {
            //---------------Set up test pack-------------------
            //GenerateInvokeContainer(IDSFDataObject dataObject, String serviceName, bool isLocalInvoke, Guid masterDataListId = default(Guid))
            var channel        = new Mock <IEsbChannel>();
            var workSpace      = new Mock <IWorkspace>();
            var obj            = new Mock <IDSFDataObject>();
            var locater        = new Mock <IServiceLocator>();
            var executeRequest = new EsbExecuteRequest();
            var serviceId      = Guid.NewGuid();
            var dynamicService = new DynamicService()
            {
                ID      = serviceId,
                Actions = new List <ServiceAction>
                {
                    new ServiceAction()
                    {
                        ServiceName = "serviceName",
                        ServiceID   = serviceId,
                        SourceName  = "sourceName",
                        ActionType  = enActionType.Workflow
                    }
                }
            };

            obj.SetupGet(o => o.ResourceID).Returns(serviceId);
            obj.SetupGet(o => o.IsServiceTestExecution).Returns(true);
            locater.Setup(l => l.FindService(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(dynamicService);
            locater.Setup(l => l.FindSourceByName(It.IsAny <string>(), It.IsAny <Guid>())).Returns(new Source());


            var invoker       = new EsbServiceInvoker(channel.Object, workSpace.Object, executeRequest);
            var privateObject = new PrivateObject(invoker);

            privateObject.SetField("_serviceLocator", locater.Object);
            //---------------Assert Precondition----------------
            Assert.IsNotNull(invoker);
            //---------------Execute Test ----------------------
            var executionContainer = invoker.GenerateInvokeContainer(obj.Object, serviceId, true);

            //---------------Test Result -----------------------
            Assert.IsNotNull(executionContainer);
            Assert.IsInstanceOfType(executionContainer, typeof(ServiceTestExecutionContainer));
            locater.VerifyAll();
        }
Example #20
0
        /// <summary>
        ///     根据指定字段-统计(count)所有实体报表表格
        /// </summary>
        /// <param name="reportInput"></param>
        /// <returns></returns>
        public Tuple <ServiceResult, PagedList <CountReportTable> > GetDayCountTable2(CountReportInput reportInput)
        {
            var returnList = new PagedList <CountReportTable>();
            var TempTable  = string.Empty;

            #region 安全验证

            if (reportInput == null)
            {
                if (string.IsNullOrEmpty(reportInput.EntityType))
                {
                    return(Tuple.Create(ServiceResult.FailedMessage("实体类型不能为空"), returnList));
                }

                return(Tuple.Create(ServiceResult.FailedMessage("实体类型不能为空"), returnList));
            }

            Type   typeFind     = null;
            object instanceFind = null;
            var    checkType    = Resolve <IUIBaseService>().CheckType(reportInput.EntityType, ref typeFind, ref instanceFind);
            if (!checkType.Succeeded)
            {
                return(Tuple.Create(ServiceResult.FailedMessage("实体类型不存在"), returnList));
            }

            if (!(instanceFind is IEntity)) // 非实体类型不能完成数据统计
            {
                return(Tuple.Create(ServiceResult.FailedMessage("非实体类型不能进行数据统计"), returnList));
            }

            #endregion 安全验证

            // 特殊字段处理
            if (reportInput.Field.IsNotNullOrEmpty())
            {
                var property  = instanceFind.GetType().GetProperty(reportInput.Field);
                var filedType = property.GetType();
                var filed     = reportInput.Field.GetPropertyValue(instanceFind);
            }

            var rs     = DynamicService.ResolveMethod(typeFind.Name, "GetCountTable", reportInput);
            var rsList = rs.Item2 as PagedList <CountReportTable>;
            return(Tuple.Create(ServiceResult.Success, rsList));
        }
Example #21
0
        public DynamicService CreateServiceEntry()
        {
            var checkPermissionsService = new DynamicService
            {
                Name = HandlesType(),
                DataListSpecification = new StringBuilder("<DataList><FilePath ColumnIODirection=\"Input\"><Username ColumnIODirection=\"Input\"/><Password ColumnIODirection=\"Input\"/><Dev2System.ManagmentServicePayload ColumnIODirection=\"Both\"></Dev2System.ManagmentServicePayload></DataList>")
            };

            var checkPermissionsServiceAction = new ServiceAction
            {
                Name         = HandlesType(),
                ActionType   = enActionType.InvokeManagementDynamicService,
                SourceMethod = HandlesType()
            };

            checkPermissionsService.Actions.Add(checkPermissionsServiceAction);

            return(checkPermissionsService);
        }
Example #22
0
 public void go(string username, string password, string data, string url)
 {
     try
     {
         Uri            uri     = new Uri(url);
         DynamicService service = new DynamicService(url, "http://tempuri.org/");
         string         str_qdn = data;
         str_qdn = str_qdn.Substring(0, str_qdn.Length - 1);
         //Object result_qdn = service.Invoke("SaveHunanGps_pxjlByStr", new Object[] { username, password, str_qdn });
         //int resultNum = Convert.ToInt32(result_qdn.ToString().Substring(13));
         Service1Client client = new Service1Client();
         client.Endpoint.Address = new EndpointAddress(url);
         string str = client.SaveHunanGps_pxjlByStr(username, password, str_qdn);
         //System.out.println("成功数量:" + resultNum)
     }
     catch (Exception e)
     {
     }
 }
Example #23
0
        public DynamicService GetService(Guid workspaceID, Guid resourceID, string resourceName)
        {
            DynamicService serviceAction = null;

            if (resourceID != Guid.Empty)
            {
                var services = GetDynamicObjects <DynamicService>(workspaceID, resourceID);
                serviceAction = services.FirstOrDefault();
            }
            else
            {
                if (!string.IsNullOrEmpty(resourceName))
                {
                    var services = GetDynamicObjects <DynamicService>(workspaceID, resourceName);
                    serviceAction = services.FirstOrDefault();
                }
            }
            return(serviceAction);
        }
Example #24
0
        public DynamicService CreateServiceEntry()
        {
            DynamicService registeredAssemblyService = new DynamicService
            {
                Name = HandlesType(),
                DataListSpecification = new StringBuilder("<DataList><Dev2System.ManagmentServicePayload ColumnIODirection=\"Both\"></Dev2System.ManagmentServicePayload></DataList>")
            };

            ServiceAction registeredAssemblyAction = new ServiceAction
            {
                Name         = HandlesType(),
                SourceMethod = HandlesType(),
                ActionType   = enActionType.InvokeManagementDynamicService
            };

            registeredAssemblyService.Actions.Add(registeredAssemblyAction);

            return(registeredAssemblyService);
        }
        public DynamicService CreateServiceEntry()
        {
            var dynamicService = new DynamicService
            {
                Name = HandlesType(),
                DataListSpecification = new StringBuilder("<DataList><SecuritySettings ColumnIODirection=\"Input\"></SecuritySettings><Result/><Dev2System.ManagmentServicePayload ColumnIODirection=\"Both\"></Dev2System.ManagmentServicePayload></DataList>")
            };

            var serviceAction = new ServiceAction
            {
                Name         = HandlesType(),
                ActionType   = enActionType.InvokeManagementDynamicService,
                SourceMethod = HandlesType()
            };

            dynamicService.Actions.Add(serviceAction);

            return(dynamicService);
        }
        /// <summary>
        /// Creates the service entry.
        /// </summary>
        /// <returns></returns>
        public DynamicService CreateServiceEntry()
        {
            var ds = new DynamicService
            {
                Name = HandlesType(),
                DataListSpecification = new StringBuilder("<DataList><Database ColumnIODirection=\"Input\"/><TableName ColumnIODirection=\"Input\"/><Dev2System.ManagmentServicePayload ColumnIODirection=\"Both\"></Dev2System.ManagmentServicePayload></DataList>")
            };

            var sa = new ServiceAction
            {
                Name         = HandlesType(),
                ActionType   = enActionType.InvokeManagementDynamicService,
                SourceMethod = HandlesType()
            };

            ds.Actions.Add(sa);

            return(ds);
        }
        private MenuItem BuildMenuItem(DynamicAction s, DynamicService service)
        {
            if (s is EntityAction || (!s.IsCollectionQuery() && s.IsQuery())|| !_Offica.IzOk(s))
            {
                return null;
            }
            var action = s.Method.Name;
            if (s.IsCollectionQuery())
            {
                action = action + ".jqgrid";
            }

            return new MenuItem
                   {
                   	Title = s.Method.Name,
                   	ActionUrl = VirtualPathUtility.ToAbsolute(string.Format("~/{0}/{1}", service.Name, action))
                   	,
                   	AnchorClass = "parent",
                   };
        }
        public static DynamicService CreateESBManagementServiceEntry(string HandleType, string DataListSpecification)
        {
            var findServices = new DynamicService
            {
                Name = HandleType,
                DataListSpecification = new StringBuilder(DataListSpecification)
            };

            using (ServiceAction serviceAction = new ServiceAction
            {
                Name = HandleType,
                ActionType = enActionType.InvokeManagementDynamicService,
                SourceMethod = HandleType,
                DataListSpecification = new StringBuilder(DataListSpecification)
            })
            {
                findServices.Actions.Add(serviceAction);
                return(findServices);
            }
        }
        public async Task ServiceCircuitBreakerTest()
        {
            var cacheRegion = "cacheRegion";
            var serviceInfo = new CalledServiceInfo
            {
                Name               = "Service",
                Id                 = Guid.NewGuid(),
                Endpoint           = "Endpoint",
                CircuitBreakerInfo = new CircuitBreakerInfo
                {
                    ExceptionCount = 1,
                    BreakDuration  = TimeSpan.FromSeconds(1000)
                },
                Timeout = TimeSpan.FromSeconds(100)
            };
            var httpClientResponse = new HttpClientResponse
            {
                HttpStatusCode = HttpStatusCode.InternalServerError,
                Response       = ""
            };

            var cache             = Substitute.For <ICache>();
            var httpClientWrapper = Substitute.For <IHttpClientWrapper>();
            var tokenService      = Substitute.For <ITokenService>();

            httpClientWrapper.PostAsync(serviceInfo.Endpoint, null, CancellationToken.None).ReturnsForAnyArgs(httpClientResponse);

            var sut = new DynamicService(cache, httpClientWrapper, tokenService);

            ServiceResponse actual = await sut.CallService(serviceInfo, cacheRegion, CancellationToken.None, null);

            Assert.AreEqual(ServiceResponseStatus.Error, actual.Status);

            await Task.Delay(10);

            actual = await sut.CallService(serviceInfo, cacheRegion, CancellationToken.None, null);

            await httpClientWrapper.ReceivedWithAnyArgs(1).PostAsync(serviceInfo.Endpoint, null, CancellationToken.None);

            Assert.AreEqual(ServiceResponseStatus.Error, actual.Status);
        }
Example #30
0
        public Tuple <ServiceResult, AutoForm> GetView(string type, object id, AutoBaseModel autoModel)
        {
            Type     typeFind     = null;
            object   instanceFind = null;
            AutoForm autoForm     = null;
            var      checkType    = Resolve <IUIBaseService>().CheckType(type, ref typeFind, ref instanceFind);

            if (!checkType.Succeeded)
            {
                return(new Tuple <ServiceResult, AutoForm>(checkType, new AutoForm()));
            }

            if (instanceFind is IAutoConfig)
            {
                autoForm = Resolve <IApIAlaboAutoConfigService>().GetView(instanceFind.GetType(), id);
                return(new Tuple <ServiceResult, AutoForm>(ServiceResult.Success, autoForm));
            }

            if (instanceFind is IAutoForm set)
            {
                autoForm = set.GetView(id, autoModel);
                return(new Tuple <ServiceResult, AutoForm>(ServiceResult.Success, autoForm));
            }

            if (instanceFind is IEntity)
            {
                var result = DynamicService.ResolveMethod(typeFind.Name, "GetViewById", id);
                if (result.Item1.Succeeded)
                {
                    autoForm = AutoFormMapping.Convert(result.Item2);
                }
                else
                {
                    autoForm = AutoFormMapping.Convert(typeFind.FullName);
                }

                return(new Tuple <ServiceResult, AutoForm>(ServiceResult.Success, autoForm));
            }

            return(new Tuple <ServiceResult, AutoForm>(ServiceResult.Failure("未知类型"), new AutoForm()));
        }
Example #31
0
        private MenuItem BuildMenuItem(DynamicAction s, DynamicService service)
        {
            if (s is EntityAction || (!s.IsCollectionQuery() && s.IsQuery()) || !_Offica.IzOk(s))
            {
                return(null);
            }
            var action = s.Method.Name;

            if (s.IsCollectionQuery())
            {
                action = action + ".jqgrid";
            }

            return(new MenuItem
            {
                Title = s.Method.Name,
                ActionUrl = VirtualPathUtility.ToAbsolute(string.Format("~/{0}/{1}", service.Name, action))
                ,
                AnchorClass = "parent",
            });
        }
        public DynamicServiceTests()
        {
            _log = new LogToMemory();

            fromAddress = new BitcoinPubKeyAddress(from);
            fromKey     = Key.Parse(fromPrivateKey);
            toAddress   = new BitcoinPubKeyAddress(to);
            tx          = txBuilder
                          .AddCoins(prevTx.Outputs.AsCoins().Where(c => c.ScriptPubKey.GetDestinationAddress(network).ToString() == from).ToArray())
                          .Send(toAddress, Money.Coins(1))
                          .SetChange(fromAddress)
                          .SubtractFees()
                          .SendFees(txBuilder.EstimateFees(new FeeRate(Money.Satoshis(1024))))
                          .BuildTransaction(false);
            spentCoins = txBuilder.FindSpentCoins(tx);
            service    = new DynamicService(_log, "dynamic-testnet");

            serviceProvider = new Mock <IServiceProvider>();
            serviceProvider.Setup(provider => provider.GetService(typeof(IDynamicService)))
            .Returns(service);
        }
 public ScriptController()
 {
     _dynamicService = new DynamicService();
 }