public Task<ServiceInfo[]> LookupAsync(string name, string group)
		{
			if (name == null) return Task.FromResult((ServiceInfo[])null);

			EnsureStartComplete();

			var key = new ServiceIdentifier(name, group);
			var url = _serviceAddressDictionary.GetOrAdd(key, key1 =>
			{
				try
				{
					var urls = LookupInternalAsync(key1);
					var item = new ClientLookupItem
					{
						ClientInfo = key1,
						Addresses = urls.Result,
					};
					return item;
				}
				catch (AggregateException ex)
				{
					var kex = ex.InnerException as KeeperException;
					if (kex?.getCode() == KeeperException.Code.SESSIONEXPIRED)
					{
						if (_startTask?.IsCompleted == true)
							_startTask = Start();
					}

					throw ex.InnerException;
				}
			});

			return Task.FromResult(url?.Addresses);
		}
Exemple #2
0
        public async Task <byte[]> GetWsdlAsync(Uri securityServerUri, SubSystemIdentifier subSystemId,
                                                ServiceIdentifier targetService)
        {
            byte[] wsdlFileBytes = { };

            var client = SoapClient.Prepare()
                         .WithHandler(new DelegatingSoapHandler
            {
                OnHttpResponseAsyncAction = async(soapClient, httpContext, cancellationToken) =>
                {
                    if (httpContext.Response.Content.IsMimeMultipartContent())
                    {
                        var streamProvider =
                            await httpContext.Response.Content.ReadAsMultipartAsync(cancellationToken);
                        var contentCursor = streamProvider.Contents.GetEnumerator();

                        contentCursor.MoveNext();
                        var soapResponse = contentCursor.Current;

                        contentCursor.MoveNext();
                        var wsdlFile = contentCursor.Current;

                        contentCursor.Dispose();

                        wsdlFileBytes = await wsdlFile.ReadAsByteArrayAsync();
                        httpContext.Response.Content = soapResponse;
                    }
                }
            });

            var body = SoapEnvelope.Prepare().Body(new GetWsdlRequest
            {
                ServiceCode    = targetService.ServiceCode,
                ServiceVersion = targetService.ServiceVersion
            }).WithHeaders(new List <SoapHeader>
            {
                IdHeader.Random,
                UserIdHeader,
                ProtocolVersionHeader.Version40,
                (XRoadClient)subSystemId,
                new XRoadService
                {
                    Instance       = targetService.Instance,
                    MemberClass    = targetService.MemberClass,
                    MemberCode     = targetService.MemberCode,
                    SubSystemCode  = targetService.SubSystemCode,
                    ServiceCode    = "getWsdl",
                    ServiceVersion = "v1"
                }
            });

            var result = await client.SendAsync(securityServerUri.ToString(), string.Empty, body);

            client.Dispose();

            result.ThrowIfFaulted();

            return(wsdlFileBytes);
        }
        /// <summary>
        ///		Creates new instance from the specified service type.
        /// </summary>
        /// <param name="serviceType">The concrete type which implements given service contract.</param>
        /// <returns>
        ///		<see cref="ServiceDescription"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        ///		<paramref name="serviceType"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///		<paramref name="serviceType"/> is abstract class or interface.
        ///		Or, <paramref name="serviceType"/> does not have service contract, that is, it is not marked by <see cref="MessagePackRpcServiceContractAttribute"/>.
        ///		Or, <paramref name="serviceType"/> does not have publicly visible default constructor.
        ///		Or, any <see cref="MessagePackRpcServiceContractAttribute"/> property of <paramref name="serviceType"/> is invalid.
        /// </exception>
        public static ServiceDescription FromServiceType(Type serviceType)
        {
            if (serviceType == null)
            {
                throw new ArgumentNullException("serviceType");
            }

            if (serviceType.IsAbstract)
            {
                throw new ArgumentException(
                          String.Format(
                              CultureInfo.CurrentCulture,
                              "Service type '{0}' is not concrete type.",
                              serviceType.AssemblyQualifiedName
                              ),
                          "serviceType"
                          );
            }

            Contract.EndContractBlock();

            var serviceContract = Attribute.GetCustomAttribute(serviceType, typeof(MessagePackRpcServiceContractAttribute), true) as MessagePackRpcServiceContractAttribute;

            if (serviceContract == null)
            {
                throw new ArgumentException(
                          String.Format(
                              CultureInfo.CurrentCulture,
                              "Service type '{0}' does not have service contract.",
                              serviceType.AssemblyQualifiedName
                              ),
                          "serviceType"
                          );
            }

            var serviceName = String.IsNullOrWhiteSpace(serviceContract.Name) ? ServiceIdentifier.TruncateGenericsSuffix(serviceType.Name) : serviceContract.Name;

            var ctor = serviceType.GetConstructor(Type.EmptyTypes);

            if (ctor == null)
            {
                throw new ArgumentException(
                          String.Format(
                              CultureInfo.CurrentCulture,
                              "Service type '{0}' does not have public default constructor.",
                              serviceType.AssemblyQualifiedName
                              ),
                          "serviceType"
                          );
            }

            return
                (new ServiceDescription(serviceName, Expression.Lambda <Func <object> >(Expression.New(ctor)).Compile())
            {
                Version = serviceContract.Version,
                _serviceType = serviceType
            });
        }
Exemple #4
0
        private Task <ServiceMetadata> GetServiceMetadata(ServiceIdentifier serviceIdentifier)
        {
            Func <ServiceMetadata> fetchServiceMetadata =
                () =>
                _repository.GetServiceMetaData(
                    serviceIdentifier.Org,
                    serviceIdentifier.Service);

            return(Task <ServiceMetadata> .Factory.StartNew(fetchServiceMetadata));
        }
Exemple #5
0
        private Task <CodeCompilationResult> Compile(ServiceIdentifier service)
        {
            Func <CodeCompilationResult> compile =
                () =>
                _compilation.CreateServiceAssembly(
                    service.Org,
                    service.Service);

            return(Task <CodeCompilationResult> .Factory.StartNew(compile));
        }
        private Task <ModelMetadata> GetServiceMetadata(ServiceIdentifier serviceIdentifier)
        {
            // TODO: figure out if name of serviceMetadata is essential here.
            Func <ModelMetadata> fetchServiceMetadata =
                () =>
                _repository.GetModelMetadata(
                    serviceIdentifier.Org,
                    serviceIdentifier.Service);

            return(Task <ModelMetadata> .Factory.StartNew(fetchServiceMetadata));
        }
Exemple #7
0
        private static bool Setup(this UIElement element, ServiceIdentifier serviceIdentifier)
        {
            var bag = s_serviceIdentifiers.GetOrCreateValue(element);

            if (bag.Contains(serviceIdentifier.Type))
            {
                return(false);
            }

            bag.Add(serviceIdentifier);
            return(true);
        }
Exemple #8
0
        private ServiceInfo[] GetAddressInternal(string name, string group)
        {
            var itemKey = new ServiceIdentifier(name, group);
            // ReSharper disable once InconsistentlySynchronizedField
            var url = _defaultBaseUrlDictionary.GetOrAdd(itemKey, key =>
            {
                if (key == ServiceIdentifier.Empty)
                {
                    return(null);
                }
                if (_registryClient.Value == null)
                {
                    return(null);
                }

                var request = new GetServiceInfoRequest
                {
                    Services = new[]
                    {
                        new ServiceIdentifierDto
                        {
                            Name  = name,
                            Group = group,
                        }
                    }
                };
                try
                {
                    var response     = _registryClient.Value.GetServiceInfo(request);
                    var result       = response.Services.FirstOrDefault();
                    var serviceInfos = result?.ServiceInfos
                                       .Select(it => new ServiceInfo
                    {
                        Name    = name,
                        Group   = group,
                        Address = it.Address,
                        Data    = it.Data,
                    })
                                       .ToArray();

                    _updateTimeDic.AddOrUpdate(itemKey, DateTime.Now, (k, oldValue) => DateTime.Now);

                    return(serviceInfos);
                }
                catch (Exception ex)
                {
                    LogHelper.Error(ex);
                    throw;
                }
            });

            return(url);
        }
Exemple #9
0
        public async Task <ServiceInfo[]> LookupInternalAsync(ServiceIdentifier clientInfo)
        {
            try
            {
                var appId = clientInfo.Name;

                var appNodePath = GetAppNodePath(appId);
                var envNodePath = appNodePath + "/" + (string.IsNullOrWhiteSpace(clientInfo.Group) ? "_" : clientInfo.Group);

                var serviceNodes = await _zookeeper.GetChildrenAsync(envNodePath, true).ConfigureAwait(false);

                if (serviceNodes?.Children?.Count > 0)
                {
                    var addresses = new List <string>();
                    foreach (var item in serviceNodes.Children)
                    {
                        var addr = await _zookeeper.GetDataAsync(envNodePath + "/" + item, true).ConfigureAwait(false);

                        var addrString = Encoding.UTF8.GetString(addr.Data);
                        addresses.Add(addrString);
                    }
                    return(addresses
                           .Distinct()
                           .Select(it => new ServiceInfo {
                        Name = clientInfo.Name, Group = clientInfo.Group, Address = it
                    })
                           .ToArray());
                }

                return(new ServiceInfo[0]);
            }
            catch (KeeperException)
            {
                //if (ex.getCode() == KeeperException.Code.SESSIONEXPIRED)
                //{
                //	throw new SessionExpireException(ex.Message, ex);
                //}
                //else if (ex.getCode() == KeeperException.Code.CONNECTIONLOSS)
                //{
                //	throw new ConnectionLossException(ex.Message, ex);
                //}
                throw;
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                throw;
            }
        }
Exemple #10
0
        private void DoUpdate()
        {
            var toUpdateServices = _updateTimeDic
                                   .Where(it => (DateTime.Now - it.Value).TotalSeconds > UpdateInterval)
                                   .Select(it => it.Key)
                                   .ToArray();

            var services = toUpdateServices
                           .Select(it => new ServiceIdentifierDto
            {
                Name  = it.Name,
                Group = it.Group
            })
                           .ToArray();

            if (services.Length == 0)
            {
                return;
            }

            var request = new GetServiceInfoRequest {
                Services = services
            };

            try
            {
                var response = _registryClient.Value.GetServiceInfo(request);
                foreach (var item in response.Services)
                {
                    var serviceInfos = item.ServiceInfos
                                       ?.Select(it => new ServiceInfo
                    {
                        Name    = it.Name,
                        Group   = it.Group,
                        Address = it.Address,
                        Data    = it.Data,
                    })
                                       .ToArray();

                    var key = new ServiceIdentifier(item.Identifier.Name, item.Identifier.Group);
                    _defaultBaseUrlDictionary[key] = serviceInfos;
                    _updateTimeDic.AddOrUpdate(key, DateTime.Now, (k, oldValue) => DateTime.Now);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
        }
Exemple #11
0
        public void T01()
        {
            var test0 = new EventId(1);
            var test1 = new EventId(2);

            //var d = test0 + test1;



            var svc0 = new ServiceIdentifier(1000, "ciao");
            var svc1 = new ServiceIdentifier(2000, "ciao caro");

            var t0 = svc0 - svc1;

            var t1 = svc0 + test0;
        }
		public async Task<ServiceInfo[]> LookupInternalAsync(ServiceIdentifier clientInfo)
		{
			try
			{
				var appId = clientInfo.Name;

				var appNodePath = GetAppNodePath(appId);
				var envNodePath = appNodePath + "/" + (string.IsNullOrWhiteSpace(clientInfo.Group) ? "_" : clientInfo.Group);

				var serviceNodes = await _zookeeper.GetChildrenAsync(envNodePath, true).ConfigureAwait(false);
				if (serviceNodes?.Children?.Count > 0)
				{
					var addresses = new List<string>();
					foreach (var item in serviceNodes.Children)
					{
						var addr = await _zookeeper.GetDataAsync(envNodePath + "/" + item, true).ConfigureAwait(false);
						var addrString = Encoding.UTF8.GetString(addr.Data);
						addresses.Add(addrString);
					}
					return addresses
						.Distinct()
						.Select(it => new ServiceInfo { Name = clientInfo.Name, Group = clientInfo.Group, Address = it })
						.ToArray();
				}

				return new ServiceInfo[0];
			}
			catch (KeeperException)
			{
				//if (ex.getCode() == KeeperException.Code.SESSIONEXPIRED)
				//{
				//	throw new SessionExpireException(ex.Message, ex);
				//}
				//else if (ex.getCode() == KeeperException.Code.CONNECTIONLOSS)
				//{
				//	throw new ConnectionLossException(ex.Message, ex);
				//}
				throw;
			}
			catch (Exception ex)
			{
				LogHelper.Error(ex);
				throw;
			}

		}
Exemple #13
0
        /// <summary>
        /// Invokes the Component async.
        /// </summary>
        /// <param name="org">Unique identifier of the organisation responsible for the app.</param>
        /// <param name="app">Application identifier which is unique within an organisation.</param>
        /// <param name="serviceMetadata">The service metadata.</param>
        /// <param name="codeCompilationResult">The code compilation result.</param>
        /// <returns>The <see cref="Task"/>.</returns>
        public async Task <IViewComponentResult> InvokeAsync(
            string org,
            string app,
            ServiceMetadata serviceMetadata             = null,
            CodeCompilationResult codeCompilationResult = null)
        {
            var serviceIdentifier = new ServiceIdentifier {
                Org = org, Service = app
            };
            var compilation = codeCompilationResult ?? await CompileHelper.CompileService(_compilation, serviceIdentifier);

            var metadata = serviceMetadata ?? await GetServiceMetadata(serviceIdentifier);

            var model = CreateModel(serviceIdentifier, compilation, metadata);

            return(View(model));
        }
Exemple #14
0
        private static ServiceIdentifier GetServiceIdentifier(this IService service, Type type)
        {
            Debug.Assert(service != null);
            Debug.Assert(type != null);

            ServiceIdentifierBag bag = s_serviceIdentifiers.GetOrCreateValue(service);

            if (bag.Contains(type))
            {
                return(bag[type]);
            }
            else
            {
                var result = new ServiceIdentifier(service, type);
                bag.Add(result);
                return(result);
            }
        }
Exemple #15
0
        private ServiceStatusViewModel CreateModel(
            ServiceIdentifier serviceIdentifier,
            CodeCompilationResult compilationResult,
            ServiceMetadata serviceMetadata)
        {
            var userMessages =
                CompilationUserMessages(compilationResult)
                .Union(ServiceMetadataMessages(serviceMetadata))
                .ToList();

            userMessages.Sort();

            return(new ServiceStatusViewModel
            {
                ServiceIdentifier = serviceIdentifier,
                CodeCompilationMessages = FilterCompilationInfos(compilationResult).ToList(),
                UserMessages = userMessages,
            });
        }
Exemple #16
0
        public void ConsulServicesLocatorCanLocate()
        {
            var serviceIdentifier         = new ServiceIdentifier <ServiceDiscoveryTest>("ServiceDiscoveryTest");
            var mockConsulServiceEndpoint = new Mock <IConsulServiceEndpoint>();

            mockConsulServiceEndpoint
            .Setup(se => se.GetService("ServiceDiscoveryTest", It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(
                         new QueryResult <ServiceEntry[]>
            {
                StatusCode = HttpStatusCode.OK,
                Response   = new [] { new ServiceEntry {
                                          Service = new AgentService()
                                      } }
            }
                         ));
            var consulServicesLocator = new ConsulServicesLocator(mockConsulServiceEndpoint.Object);
            var serviceLocations      = consulServicesLocator.LocateService(serviceIdentifier, CancellationToken.None).Result;

            Assert.NotEmpty(serviceLocations);
        }
        public async Task <IActionResult> Compile(string org, string app)
        {
            if (string.IsNullOrWhiteSpace(org) || string.IsNullOrWhiteSpace(app))
            {
                return(BadRequest("Org or app not supplied"));
            }

            try
            {
                ServiceIdentifier serviceIdentifier = new ServiceIdentifier {
                    Org = org, Service = app
                };
                CodeCompilationResult compileResult = await CompileHelper.CompileService(_compilation, serviceIdentifier);

                return(Ok(compileResult));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Compiling services files for org: {org}, app: {app} failed with message: {ex.Message}");
                return(StatusCode(500, ex.Message));
            }
        }
Exemple #18
0
        public Task <ServiceInfo[]> LookupAsync(string name, string group)
        {
            if (name == null)
            {
                return(Task.FromResult((ServiceInfo[])null));
            }

            EnsureStartComplete();

            var key = new ServiceIdentifier(name, group);
            var url = _serviceAddressDictionary.GetOrAdd(key, key1 =>
            {
                try
                {
                    var urls = LookupInternalAsync(key1);
                    var item = new ClientLookupItem
                    {
                        ClientInfo = key1,
                        Addresses  = urls.Result,
                    };
                    return(item);
                }
                catch (AggregateException ex)
                {
                    var kex = ex.InnerException as KeeperException;
                    if (kex?.getCode() == KeeperException.Code.SESSIONEXPIRED)
                    {
                        if (_startTask?.IsCompleted == true)
                        {
                            _startTask = Start();
                        }
                    }

                    throw ex.InnerException;
                }
            });

            return(Task.FromResult(url?.Addresses));
        }
        /// <summary>
        ///		Initializes a new instance of the <see cref="AsyncServiceInvoker&lt;T&gt;"/> class.
        /// </summary>
        /// <param name="runtime">The <see cref="RpcServerRuntime"/> which provides runtime services.</param>
        /// <param name="serviceDescription">The service description which defines target operation.</param>
        /// <param name="targetOperation">The target operation to be invoked.</param>
        /// <exception cref="ArgumentNullException">
        ///		<paramref name="runtime"/> is <c>null</c>.
        ///		Or, <paramref name="serviceDescription"/> is <c>null</c>.
        ///		Or, <paramref name="targetOperation"/> is <c>null</c>.
        /// </exception>
        internal AsyncServiceInvoker(RpcServerRuntime runtime, ServiceDescription serviceDescription, MethodInfo targetOperation)
        {
            if (runtime == null)
            {
                throw new ArgumentNullException("runtime");
            }

            if (serviceDescription == null)
            {
                throw new ArgumentNullException("serviceDescription");
            }

            if (targetOperation == null)
            {
                throw new ArgumentNullException("targetOperation");
            }

            Contract.EndContractBlock();

            this._runtime            = runtime;
            this._serviceDescription = serviceDescription;
            this._targetOperation    = targetOperation;
            this._operationId        = ServiceIdentifier.TruncateGenericsSuffix(targetOperation.Name);
        }
Exemple #20
0
        /// <summary>
        /// The invokes the Component async.
        /// </summary>
        /// <param name="org"> The org. </param>
        /// <param name="service"> The service. </param>
        /// <param name="serviceMetadata"> The service Metadata. </param>
        /// <param name="codeCompilationResult"> The code Compilation Result. </param>
        /// <returns> The <see cref="Task"/>.  </returns>
        public async Task <IViewComponentResult> InvokeAsync(
            string org,
            string service,
            ServiceMetadata serviceMetadata             = null,
            CodeCompilationResult codeCompilationResult = null)
        {
            ServiceIdentifier serviceIdentifier = new ServiceIdentifier {
                Org = org, Service = service
            };
            CodeCompilationResult compilation = null;

            if (string.IsNullOrEmpty(_generalSettings.RuntimeMode) || !_generalSettings.RuntimeMode.Equals("ServiceContainer"))
            {
                compilation = codeCompilationResult ?? await Compile(serviceIdentifier);

                var metadata = serviceMetadata ?? await GetServiceMetadata(serviceIdentifier);

                ServiceStatusViewModel model = CreateModel(serviceIdentifier, compilation, metadata);

                return(View(model));
            }

            return(View(new ServiceStatusViewModel()));
        }
 /// <summary>
 ///		Returns a <see cref="System.String"/> that represents this instance.
 /// </summary>
 /// <returns>
 ///		A <see cref="System.String"/> that represents this instance.
 /// </returns>
 public sealed override string ToString()
 {
     return(ServiceIdentifier.CreateServiceId(this._name, this._version));
 }
Exemple #22
0
 public Channel(ServiceIdentifier service)
 {
     this.Service = service;
 }
Exemple #23
0
 public BaseSystemEvent(ServiceIdentifier service)
 {
     this.Service = service;
 }
Exemple #24
0
 public UnmappedEvent(ServiceIdentifier service, string serviceMessageType, dynamic data)
     : base(service)
 {
     this.serviceMessageType = serviceMessageType;
     this.data = data;
 }
Exemple #25
0
        private ServiceInfo[] GetAddressInternal(string name, string group)
        {
            var itemKey = new ServiceIdentifier(name, group);
            // ReSharper disable once InconsistentlySynchronizedField
            var url = _defaultBaseUrlDictionary.GetOrAdd(itemKey, key =>
            {
                if (key == ServiceIdentifier.Empty) return null;
                if (_registryClient.Value == null) return null;

                var request = new GetServiceInfoRequest
                {
                    Services = new[]
                    {
                        new ServiceIdentifierDto
                        {
                            Name = name,
                            Group = group,
                        }
                    }
                };
                try
                {
                    var response = _registryClient.Value.GetServiceInfo(request);
                    var result = response.Services.FirstOrDefault();
                    var serviceInfos = result?.ServiceInfos
                        .Select(it => new ServiceInfo
                        {
                            Name = name,
                            Group = group,
                            Address = it.Address,
                            Data = it.Data,
                        })
                        .ToArray();

                    _updateTimeDic.AddOrUpdate(itemKey, DateTime.Now, (k, oldValue) => DateTime.Now);

                    return serviceInfos;
                }
                catch (Exception ex)
                {
                    LogHelper.Error(ex);
                    throw;
                }
            });

            return url;
        }
Exemple #26
0
 /// <summary>
 /// Retrieves a AID specification based on a given SID e AID.
 /// </summary>
 /// <param name="sid">Service Indentifier</param>
 /// <param name="aid">Action Identifier</param>
 /// <returns></returns>
 private AIDGlobal GetAID(ServiceIdentifier sid, ushort aid)
 {
     switch (sid)
     {
         case ServiceIdentifier.SERVICE_MANAGEMENT:
             {
                 switch (aid)
                 {
                     case 1: { return AIDGlobal.SERVICE_MANAGEMENT_MIH_CAPABILITY_DISCOVER; }
                     case 2: { return AIDGlobal.SERVICE_MANAGEMENT_MIH_REGISTER; }
                     case 3: { return AIDGlobal.SERVICE_MANAGEMENT_MIH_DEREGISTER; }
                     case 4: { return AIDGlobal.SERVICE_MANAGEMENT_MIH_EVENT_SUBSCRIBE; }
                     case 5: { return AIDGlobal.SERVICE_MANAGEMENT_MIH_EVENT_UNSUBSCRIBE; }
                 }
                 break;
             }
         case ServiceIdentifier.EVENT_SERVICE:
             {
                 switch (aid)
                 {
                     case 1: { return AIDGlobal.EVENT_SERVICE_MIH_LINK_DETECTED; }
                     case 2: { return AIDGlobal.EVENT_SERVICE_MIH_LINK_UP; }
                     case 3: { return AIDGlobal.EVENT_SERVICE_MIH_LINK_DOWN; }
                     case 5: { return AIDGlobal.EVENT_SERVICE_MIH_LINK_PARAMETERS_REPORT; }
                     case 6: { return AIDGlobal.EVENT_SERVICE_MIH_LINK_GOING_DOWN; }
                     case 7: { return AIDGlobal.EVENT_SERVICE_MIH_LINK_HANDOVER_IMMINENT; }
                     case 8: { return AIDGlobal.EVENT_SERVICE_MIH_LINK_HANDOVER_COMPLETE; }
                 }
                 break;
             }
         case ServiceIdentifier.INFORMATION_SERVICE:
             {
                 switch (aid)
                 {
                     case 1: { return AIDGlobal.INFORMATION_SERVICE_MIH_GET_INFORMATION; }
                     case 2: { return AIDGlobal.INFORMATION_SERVICE_MIH_PUSH_INFORMATION; }
                 }
                 break;
             }
         case ServiceIdentifier.COMMAND_SERVICE:
             {
                 switch (aid)
                 {
                     case 1: { return AIDGlobal.COMMAND_SERVICE_MIH_LINK_GET_PARAMETERS; }
                     case 2: { return AIDGlobal.COMMAND_SERVICE_MIH_LINK_CONFIGURE_THRESHOLDS; }
                     case 3: { return AIDGlobal.COMMAND_SERVICE_MIH_LINK_ACTIONS; }
                     case 4: { return AIDGlobal.COMMAND_SERVICE_MIH_NET_HO_CANDIDATE_QUERY; }
                     case 5: { return AIDGlobal.COMMAND_SERVICE_MIH_MN_HO_CANDIDATE_QUERY; }
                     case 6: { return AIDGlobal.COMMAND_SERVICE_MIH_N2N_HO_QUERY_RESOURCES; }
                     case 7: { return AIDGlobal.COMMAND_SERVICE_MIH_MN_HO_COMMIT; }
                     case 8: { return AIDGlobal.COMMAND_SERVICE_MIH_NET_HO_COMMIT; }
                     case 9: { return AIDGlobal.COMMAND_SERVICE_MIH_N2N_HO_COMMIT; }
                     case 10: { return AIDGlobal.COMMAND_SERVICE_MIH_MN_HO_COMPLETE; }
                     case 11: { return AIDGlobal.COMMAND_SERVICE_MIH_N2N_HO_COMPLETE; }
                 }
                 break;
             }
     }
     return 0;
 }
Exemple #27
0
 /// <summary>
 /// MessageID main constructor.
 /// </summary>
 /// <param name="serviceIdentifier">The Service Identifier (MIH Services).</param>
 /// <param name="operationCode">The Operation Code.</param>
 /// <param name="AID">The Action Identifier.</param>
 public MessageID(ServiceIdentifier serviceIdentifier, OperationCode operationCode, ushort AID)
 {
     this.SID = serviceIdentifier;
     this.OpCode = operationCode;
     this.AIDValue = AID;
 }
Exemple #28
0
 public Connect(ServiceIdentifier service)
     : base(service)
 {
 }
Exemple #29
0
 public ReplyToken(ServiceIdentifier service)
 {
     this.Service = service;
 }
Exemple #30
0
 public User(ServiceIdentifier service)
 {
     this.Service = service;
 }
Exemple #31
0
 public Error(ServiceIdentifier serviceIdentifier)
     : base(serviceIdentifier)
 {
 }
Exemple #32
0
 public Disconnect(ServiceIdentifier serviceIdentifier)
     : base(serviceIdentifier)
 {
 }
Exemple #33
0
        private void DoUpdate()
        {
            var toUpdateServices = _updateTimeDic
                .Where(it => (DateTime.Now - it.Value).TotalSeconds > UpdateInterval)
                .Select(it => it.Key)
                .ToArray();

            var services = toUpdateServices
                .Select(it => new ServiceIdentifierDto
                {
                    Name = it.Name,
                    Group = it.Group
                })
                .ToArray();

            if (services.Length == 0) return;

            var request = new GetServiceInfoRequest { Services = services };

            try
            {
                var response = _registryClient.Value.GetServiceInfo(request);
                foreach (var item in response.Services)
                {
                    var serviceInfos = item.ServiceInfos
                        ?.Select(it => new ServiceInfo
                        {
                            Name = it.Name,
                            Group = it.Group,
                            Address = it.Address,
                            Data = it.Data,
                        })
                        .ToArray();

                    var key = new ServiceIdentifier(item.Identifier.Name, item.Identifier.Group);
                    _defaultBaseUrlDictionary[key] = serviceInfos;
                    _updateTimeDic.AddOrUpdate(key, DateTime.Now, (k, oldValue) => DateTime.Now);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
        }
Exemple #34
0
 public MonitorPath(FolderPath Path, ServiceIdentifier Receiver)
 {
     this.Path     = Path;
     this.Receiver = Receiver;
 }
Exemple #35
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="b"></param>
 /// <returns></returns>
 public bool Equals(ServiceIdentifier b)
 {
     return(Name == b.Name && Group == b.Group);
 }
Exemple #36
0
        /// <summary>
        /// Creates an asynchronous task for compiling an app
        /// </summary>
        /// <param name="compilation">The ICompilation implementation</param>
        /// <param name="identifier">The service identifier</param>
        /// <returns>The started compile task</returns>
        public static Task <CodeCompilationResult> CompileService(ICompilation compilation, ServiceIdentifier identifier)
        {
            Func <CodeCompilationResult> compile =
                () =>
                compilation.CreateServiceAssembly(
                    identifier.Org,
                    identifier.Service,
                    true);

            return(Task <CodeCompilationResult> .Factory.StartNew(compile));
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="b"></param>
 /// <returns></returns>
 public bool Equals(ServiceIdentifier b)
 {
     return Name == b.Name && Group == b.Group;
 }