public async Task <NullableValue> RegisterServiceInstanceAsync(ServiceInstanceRequest serviceInstanceRequest, CancellationToken cancellationToken = default(CancellationToken)) { if (!_connectionManager.Ready) { return(NullableValue.Null); } var connection = _connectionManager.GetConnection(); return(await new Call(_logger, _connectionManager).Execute(async() => { var client = new Register.RegisterClient(connection); var instance = new ServiceInstance { ServiceId = serviceInstanceRequest.ServiceId, InstanceUUID = serviceInstanceRequest.InstanceUUID, Time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }; instance.Properties.Add(new KeyStringValuePair { Key = OS_NAME, Value = serviceInstanceRequest.Properties.OsName }); instance.Properties.Add(new KeyStringValuePair { Key = HOST_NAME, Value = serviceInstanceRequest.Properties.HostName }); instance.Properties.Add(new KeyStringValuePair { Key = PROCESS_NO, Value = serviceInstanceRequest.Properties.ProcessNo.ToString() }); instance.Properties.Add(new KeyStringValuePair { Key = LANGUAGE, Value = serviceInstanceRequest.Properties.Language }); foreach (var ip in serviceInstanceRequest.Properties.IpAddress) { instance.Properties.Add(new KeyStringValuePair { Key = IPV4, Value = ip }); } var serviceInstances = new ServiceInstances(); serviceInstances.Instances.Add(instance); var mapping = await client.doServiceInstanceRegisterAsync(serviceInstances, null, _config.GetTimeout(), cancellationToken); foreach (var serviceInstance in mapping.ServiceInstances) { if (serviceInstance.Key == serviceInstanceRequest.InstanceUUID) { return new NullableValue(serviceInstance.Value); } } return NullableValue.Null; }, () => NullableValue.Null, () => ExceptionHelpers.RegisterServiceInstanceError)); }
public void DeletePerson(int personInternalId) { var serviceInstanceQuery = ServiceInstances.Where(a => a.InternalParentId == personInternalId); if (serviceInstanceQuery.Any()) { foreach (var serviceInstance in serviceInstanceQuery) { DeleteServiceInstance(serviceInstance.InternalId); } } var personFollowUpQuery = PersonFollowUps.Where(a => a.InternalParentId == personInternalId); if (personFollowUpQuery.Any()) { foreach (var personFollowUp in personFollowUpQuery) { DeletePersonFollowUp(personFollowUp.InternalId); } } DeletePersonCustomValues(personInternalId); var personQuery = People.Where(a => a.InternalId == personInternalId); if (personQuery.Any()) { People.RemoveRange(personQuery); } }
public virtual void Run() { ServiceInstances .Where(kv => kv.Value is IExecService) .Select(kv => new { a = Attr.Get <ExecOrderAttribute>(GetServiceType(kv.Key)), s = (IExecService)kv.Value }) .OrderBy(t => t.a.Order) .ForEach(t => t.s.Run()); }
// Deletes (calls require SaveChanges() from usage) public void DeleteServiceInstance(int serviceInstanceInternalId) { var serviceInstanceQuery = ServiceInstances.Where(a => a.InternalId == serviceInstanceInternalId); if (serviceInstanceQuery.Any()) { ServiceInstances.RemoveRange(serviceInstanceQuery); } }
public IService GetService(Type serviceType) { var serv = default(IService); if (!ServiceInstances.TryGetValue(serviceType, out serv)) { throw new ElideException("Service '{0}' not found.", serviceType); } return(serv); }
internal IService CreateService(string name) { if (ServiceInstances.ContainsKey(name)) { return(ServiceInstances[name]); } ObjectImpl impl = this.Services[name]; IService service = (IService)refl.CreateInstance(impl); ServiceInstances.Add(name, service); return(service); }
public void LoadRelatedData() { Households.Include(a => a.IncomeSources).Load(); People.Include(a => a.Gender) .Include(a => a.RelationshipToHeadOfHousehold) .Include(a => a.PeopleHouseholdTasks) .Include(a => a.PeopleWorkActivities) .Include(a => a.PeopleHazardousConditions) .Load(); PersonFollowUps.Include(a => a.PeopleFollowUpHouseholdTasks) .Include(a => a.PeopleFollowUpWorkActivities) .Include(a => a.PeopleFollowUpHazardousConditions) .Load(); ServiceInstances.Include(a => a.Service).Load(); }
private int instance(Channel connection, string instanceUUID, int serviceId) { var serviceInstanceId = 0; var properties = new AgentOsInfoRequest { HostName = DnsHelpers.GetHostName(), IpAddress = DnsHelpers.GetIpV4s(), OsName = PlatformInformation.GetOSName(), ProcessNo = Process.GetCurrentProcess().Id, Language = "dotnet" }; var request = new ServiceInstanceRequest { ServiceId = serviceId, InstanceUUID = instanceUUID, Properties = properties }; var client = new Register.RegisterClient(connection); var instance = new ServiceInstance { ServiceId = request.ServiceId, InstanceUUID = request.InstanceUUID, Time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }; instance.Properties.Add(new KeyStringValuePair { Key = OS_NAME, Value = request.Properties.OsName }); instance.Properties.Add(new KeyStringValuePair { Key = HOST_NAME, Value = request.Properties.HostName }); instance.Properties.Add(new KeyStringValuePair { Key = PROCESS_NO, Value = request.Properties.ProcessNo.ToString() }); instance.Properties.Add(new KeyStringValuePair { Key = LANGUAGE, Value = request.Properties.Language }); foreach (var ip in request.Properties.IpAddress) { instance.Properties.Add(new KeyStringValuePair { Key = IPV4, Value = ip }); } var serviceInstances = new ServiceInstances(); serviceInstances.Instances.Add(instance); try { var value = Task.Run(async() => { return(await Polly.Polling(3, () => client.doServiceInstanceRegisterAsync(serviceInstances))); }).Result; //var reply = Task.Run(async () => //{ // return await client.doServiceInstanceRegisterAsync(serviceInstances); //}).Result; //foreach (var serviceInstance in reply.ServiceInstances) //{ // serviceInstanceId = serviceInstance.Value; //} serviceInstanceId = value; } catch (Exception ex) { throw ex; } return(serviceInstanceId); }