public List <DataModel> ReadData(ServiceMap service) { List <DataModel> dataCollection = new List <DataModel>(); DataModel data = new DataModel(); using (var clientConnection = ClientCon) { var files = clientConnection.ListDirectory(service.RemoteDir); foreach (var file in (files.Where(x => !x.Name.StartsWith(".")).ToList())) { if (file.Name.StartsWith(service.FileNamePrefix)) { string remoteFileName = file.Name; FileWriter.WriteFile(service.LocalDir, remoteFileName); File.OpenWrite(remoteFileName); Stream dataStream = File.OpenWrite(service.LocalDir + remoteFileName); clientConnection.DownloadFile(service.RemoteDir + remoteFileName, dataStream); var remoteData = clientConnection.ReadAllLines(service.RemoteDir + remoteFileName); FileWriter.WriteFile(service.LocalRemoteDir, remoteFileName, remoteData.ToList()); data.DataList = remoteData.ToList(); data.FileName = remoteFileName; dataCollection.Add(data); clientConnection.RenameFile(service.RemoteDir + remoteFileName, service.RemoteArchiveDir + remoteFileName); clientConnection.RenameFile(service.RemoteArchiveDir + remoteFileName, service.RemoteArchiveDir + remoteFileName.Replace("txt", "done")); Console.WriteLine("Downloaded " + service.ServiceName + " File " + remoteFileName + " on " + Convert.ToString(DateTime.Now)); } } return(dataCollection); } }
public void DoesNotCrash() { ServiceMap.Create(x => { return(GetType().Assembly == x.Assembly); }, _subject).Map(); }
/// <summary> /// 插入数据 /// </summary> /// <param name="map"></param> /// <returns></returns> public int InsertMapData(ServiceMap map) { StringBuilder sb = new StringBuilder(); sb.Append(" INSERT INTO dbo.ServiceConfig "); sb.Append(" ("); sb.Append(" ServiceId"); sb.Append(" ,ServiceName"); sb.Append(" ,ServiceFullName"); sb.Append(" ,ServiceDLLName"); sb.Append(" ,Priority"); sb.Append(" ,Description"); sb.Append(" ,ModuleType)"); sb.Append(" VALUES ( "); sb.AppendFormat("'{0}'", map.ServiceId); sb.AppendFormat(",'{0}'", map.ServiceName); sb.AppendFormat(",'{0}'", map.ServiceFullName); sb.AppendFormat(",'{0}'", map.ServiceDLLName); sb.AppendFormat(",{0}", map.Priority); sb.AppendFormat(",'{0}'", map.Description); sb.AppendFormat(",'{0}' )", map.ModuleType); return(Execute(sb.ToString() , null, "PostLoanDB", System.Data.CommandType.Text)); }
private IServiceMap DefaultMap() { return(ServiceMap.Create(x => { return GetType().Assembly == x.Assembly; }, _mapper.Object)); }
/// <summary> /// 移除ServiceMap /// </summary> /// <param name="map"></param> /// <returns></returns> public bool RemoveServiceMap(ServiceMap map) { m_Logger.Debug("移除服务配置信息,服务名称:" + map.ServiceFullName); ServiceMap outMap = null; return(m_ServiceMapDic.TryRemove(map.ServiceId, out outMap)); }
public List <DataModel> ProcessDownloadedData(ServiceMap service, List <DataModel> dataCollection = null) { int count = 0; List <DataModel> ack = new List <DataModel>(); DataModel res = new DataModel(); res.DataList = new List <string>(); DynamicParameters parameter = new DynamicParameters(); foreach (var dataFile in dataCollection) { // dataFile.DataList.RemoveAt(0); foreach (var data in dataFile.DataList) { using (var connection = DbConnection._dbConnection) { parameter.Add("@as_message_type", service.ServiceName); parameter.Add("@as_message", data); parameter.Add("@as_file_name", dataFile.FileName.Replace(".txt", "")); var result = (connection.Query <AckDataDto>("sp_create_inward_data_cedge", parameter, commandType: CommandType.StoredProcedure)).First(); count = count + result.Count; } } if (service.ServiceName == "TRANSACTION") { res.FileName = dataFile.FileName; res.DataList.Add(count.ToString()); ack.Add(res); } } return(ack); }
/// <summary> /// этот метод вызовет программа обновления службы, сообщив свою /// локальную директорию и статус обновления /// </summary> public void UpdateServiceFilesStates(string serviceFolder, int filesUpdated, int filesLeft, bool updateFinished) { // найти сервис по директории var map = ServiceMap.LoadSettings(); if (map.Items.Count == 0) { return; } var srv = map.Items.FirstOrDefault(m => m.Folder == serviceFolder); if (srv == null) { Logger.DebugFormat("Информация по сервису в каталоге [{0}] - сервис не найден", serviceFolder); return; } if (updateFinished) { serviceStatus.TryRemove(s => s.ServiceName == srv.ServiceName, 2000); return; } var srvStatus = new ServiceUpdateStatus { FilesLeft = filesLeft, FilesUpdated = filesUpdated, ServiceName = srv.ServiceName }; serviceStatus.TryRemove(s => s.ServiceName == srv.ServiceName, 2000); serviceStatus.Add(srvStatus, 2000); }
public void Maps_all_from_specific_assembly_ignored() { ServiceMap.Create(typeof(ITest).Assembly, x => { return(GetType().Assembly == x.Assembly); }, _mapper.Object).Map(); _mapper.Verify(x => x.Map(It.IsAny <Map>()), Times.AtLeast(2)); Assert.That(maps.Any(x => x.Type == typeof(ITest)), Is.True); Assert.That(maps.Any(x => x.Type == typeof(ITest2)), Is.True); }
/// <summary> /// 获取服务配置信息 /// </summary> /// <param name="serviceId"></param> /// <returns></returns> public ServiceMap GetServiceMap(string serviceId) { m_Logger.Debug("获取服务配置信息,服务ID:" + serviceId); ServiceMap map = null; m_ServiceMapDic.TryGetValue(serviceId, out map); return(map); }
public static Boolean CanAppAdmin(IUser user, IMember owner, Type appType, int appInstanceId) { int roleId = ((User)user).RoleId; IMemberAppService appService = ServiceMap.GetUserAppService(owner.GetType()); IMemberApp app = appService.GetByApp(appType, appInstanceId); return(IsRoleInApp(roleId, app.Id)); }
protected override void OnModelCreating(DbModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); ProductMap.Map(modelBuilder.Entity <Product>()); ServiceMap.Map(modelBuilder.Entity <Service>()); TransactionMap.Map(modelBuilder.Entity <Transaction>()); ItemTransactionMap.Map(modelBuilder.Entity <ItemTransaction>()); ItemTransactionChargeMap.Map(modelBuilder.Entity <ItemTransactionCharge>()); }
protected virtual IEnumerable <ServiceMap> Find(Assembly assembly) { foreach (Type processorType in assembly.GetTypes().Where(IsThriftProcessor)) { ServiceMap serviceMap = GetServiceMap(processorType); if (serviceMap != null) { yield return(serviceMap); } } }
/// <summary> /// добавить службы в список менеджера обновлений /// </summary> public void TryUpdateServices(List <string> serviceNames) { var map = ServiceMap.LoadSettings(); var services = map.Items.Where(i => serviceNames.Contains(i.ServiceName)).ToList(); if (services.Count == 0) { return; } UpdateServiceManager.Instance.ScheduleUpdate(services); }
/// <summary> /// 添加ServiceMap /// </summary> /// <param name="map"></param> public bool AddServiceMap(ServiceMap map) { m_Logger.Debug("添加服务配置信息,服务名称:" + map.ServiceFullName); if (!CheckServiceMapExist(map)) { return(m_ServiceMapDic.TryAdd(map.ServiceId, map)); } return(true); }
/// <summary> /// 获取件数 /// </summary> /// <param name="map"></param> /// <returns></returns> public int GetCount(ServiceMap map) { StringBuilder sb = new StringBuilder(); sb.Append(" SELECT COUNT(1) FROM dbo.ServiceConfig"); sb.Append(" WHERE ServiceFullName = '"); sb.Append(map.ServiceFullName); sb.Append("'"); return((int)QueryScalar(sb.ToString() , null, "PostLoanDB", System.Data.CommandType.Text)); }
public KillProcessStatus TryStopService(string serviceName) { var map = ServiceMap.LoadSettings(); var process = map.Items.FirstOrDefault(i => i.ServiceName == serviceName); if (process == null) { return(KillProcessStatus.TaskNotFound); } return(ServiceProcessManager.KillProcess(process.ServiceName, process.ServiceExecFileName)); }
public StartProcessStatus TryStartService(string serviceName) { var map = ServiceMap.LoadSettings(); var process = map.Items.FirstOrDefault(i => i.ServiceName == serviceName); if (process == null) { return(StartProcessStatus.NotFound); } return(ServiceProcessManager.StartProcess(process.ServiceName)); }
/// <summary> /// Starts the fixture including a <typeparamref name="TService"/> service instance if /// the fixture is not already running. /// </summary> /// <param name="serviceCreator">Callback that creates and returns the new service instance.</param> /// <param name="serviceMap"> /// Optionally passed as the service map describing an emulated deployment. When this is /// not <c>null</c>, the fixture will call <see cref="NeonService.Name"/> on the service /// returned by your service creator function and then look up the service by name from /// the <paramref name="serviceMap"/>. If an entry exists for the service, the fixture will /// add any environment variables or configuration files from the <see cref="ServiceDescription"/> /// to the <see cref="NeonService"/> before starting it. /// </param> /// <param name="readyTimeout"> /// Optionally specifies the maximum time the fixture should wait for the service to transition /// to the <see cref="NeonServiceStatus.Running"/> state. This defaults to <b>30 seconds</b>. /// </param> /// <returns> /// <see cref="TestFixtureStatus.Started"/> if the fixture wasn't previously started and /// this method call started it or <see cref="TestFixtureStatus.AlreadyRunning"/> if the /// fixture was already running. /// </returns> /// <exception cref="TimeoutException"> /// Thrown if the service didn't transition to the running (or terminated) state /// within <paramref name="readyTimeout"/>. /// </exception> /// <remarks> /// <para> /// This method first calls the <paramref name="serviceCreator"/> callback and expects it to /// return a new service instance that has been initialized by setting its environment variables /// and configuration files as required. The callback should <b>not start</b> the service. /// </para> /// </remarks> public TestFixtureStatus Start(Func <TService> serviceCreator, ServiceMap serviceMap = null, TimeSpan readyTimeout = default) { Covenant.Requires <ArgumentNullException>(serviceCreator != null, nameof(serviceCreator)); base.CheckDisposed(); return(base.Start( () => { StartAsComposed(serviceCreator, serviceMap, readyTimeout); })); }
public async Task <object> Execute <TService>(object args = null) where TService : IViewService { Type type = typeof(TService); IViewService service; if (!ServiceMap.TryGetValue(type, out service)) { throw new InvalidOperationException($"Unknown service of type {type}"); } return(await service.Execute(Window, args)); }
/// <summary> /// Returns the service map. /// </summary> private ServiceMap CreateServiceMap() { var description = new ServiceDescription() { Name = "queue-service", }; var serviceMap = new ServiceMap(); serviceMap.Add(description); return(serviceMap); }
//----------------------------------------------------------------- // Static members private static ServiceMap CreateServiceMap() { var serviceMap = new ServiceMap(); var description = new ServiceDescription() { Name = "test-service" }; serviceMap.Add(description); return(serviceMap); }
public async Task SaveServiceMap(ServiceMap map) { var serviceMapDbo = new ServiceMapDbo { Services = map.AllServices.Select(s => new ServiceNodeWithDependentServicesDbo { ServiceEndPoint = s.ServiceEndPoint, Services = s.ConnectedServices, IsReachable = s.IsReachable }) }; await InsertOrUpdate(serviceMapDbo); }
async private Task ApplyMetadata(Map map) { try { if (map == null) { return; } FileInfo fi = new FileInfo(_mapServerService.Options.ServicesPath + @"/" + map.Name + ".meta"); IEnumerable <IMapApplicationModule> modules = null; if (MapDocument is IMapDocumentModules) { modules = ((IMapDocumentModules)MapDocument).GetMapModules(map); } IServiceMap sMap = await ServiceMap.CreateAsync(map, _mapServerService.Instance, modules); XmlStream xmlStream; // 1. Bestehende Metadaten auf sds anwenden if (fi.Exists) { xmlStream = new XmlStream(""); xmlStream.ReadStream(fi.FullName); sMap.ReadMetadata(xmlStream); } // 2. Metadaten neu schreiben... xmlStream = new XmlStream("Metadata"); await sMap.WriteMetadata(xmlStream); if (map is Metadata) { await map.SetMetadataProviders(await sMap.GetMetadataProviders(), map, true); await map.UpdateMetadataProviders(); } // Overriding: no good idea -> problem, if multiple instances do this -> killing the metadata file!!! //fi.Refresh(); //if (!fi.Exists) //{ // xmlStream.WriteStream(fi.FullName); //} } catch (Exception ex) { _logger.LogError($"Map { map.Name }: ApplyMetadata - { ex.Message }"); } }
public void GetNodesAndEdges() { var discoMock = new Mock <IDiscoveryHandler>(); var map = new ServiceMap(new List <MicrowaveServiceNode> { MicrowaveServiceNode.ReachableMicrowaveServiceNode(new ServiceEndPoint(new Uri("http://12.de"), "Name"), new List <ServiceEndPoint> { new ServiceEndPoint(new Uri("http://123.de"), "Name"), new ServiceEndPoint(new Uri("http://1234.de"), "Name") }), MicrowaveServiceNode.ReachableMicrowaveServiceNode(new ServiceEndPoint(new Uri("http://123.de"), "Name2"), new List <ServiceEndPoint> { new ServiceEndPoint(new Uri("http://12.de"), "Name2"), new ServiceEndPoint(new Uri("http://1234.de"), "Name") }), MicrowaveServiceNode.ReachableMicrowaveServiceNode(new ServiceEndPoint(new Uri("http://1234.de"), "MostFrequentService"), new List <ServiceEndPoint>()) }); discoMock.Setup(m => m.GetServiceMap()).ReturnsAsync(map); var serviceMapPage = new ServiceMapPage(discoMock.Object, null); serviceMapPage.OnGetAsync().Wait(); var nodes = serviceMapPage.OrderedNodes.ToList(); Assert.AreEqual(3, nodes.Count); Assert.AreEqual("http://1234.de/", nodes[0].serviceAddress); Assert.AreEqual("MostFrequentService", nodes[0].label); Assert.AreEqual("http://1234.de/", nodes[0].id); Assert.AreEqual(0, nodes[0].x); Assert.AreEqual(0, nodes[0].y); Assert.AreEqual(new Uri("http://123.de"), nodes[1].serviceAddress); Assert.AreEqual(new Uri("http://12.de"), nodes[2].serviceAddress); Assert.AreEqual(0, nodes[2].x); Assert.AreEqual(1, nodes[2].y); var edges = serviceMapPage.Edges.ToList(); Assert.AreEqual(4, edges.Count); Assert.AreEqual("http://12.de/", edges[0].source); Assert.AreEqual("http://123.de/", edges[0].target); Assert.AreEqual("http://12.de/", edges[1].source); Assert.AreEqual("http://1234.de/", edges[1].target); Assert.AreEqual("http://123.de/", edges[2].source); Assert.AreEqual("http://12.de/", edges[2].target); Assert.AreEqual("http://123.de/", edges[3].source); Assert.AreEqual("http://1234.de/", edges[3].target); }
public async Task DiscoverServiceMap() { var allServices = new List <MicrowaveServiceNode>(); foreach (var serviceAddress in _serviceBaseAddressCollection) { var node = await _discoveryRepository.GetDependantServices(serviceAddress); allServices.Add(node); } var map = new ServiceMap(allServices); await _statusRepository.SaveServiceMap(map); }
protected virtual Service CreateService(AgentServiceMap agentMap, ServiceMap serviceMap) { if (agentMap.Tags.Item1 == "thrift") { return(new ThriftService { Address = agentMap.Service.Address, Name = agentMap.Service.ID, Port = agentMap.Service.Port, ServiceType = serviceMap.Implement }); } return(null); }
public LambdaTestDispatcher(TContract instance) : base(new JsonProxySerializer()) { _instance = instance; LambdaServiceBuilder serviceBuilder = new LambdaServiceBuilder() .ConfigureDependencies(x => { x.AddSingleton(typeof(TContract), instance); }) .AddProxyService <TContract>(); _serviceMap = new ServiceMap(); _serviceMap.RegisterContract <TContract>(); _lambdaService = serviceBuilder.Build(); }
/// <summary> /// Constructor for non-<see cref="NeonServiceFixture{TService}"/> fixtures. /// </summary> /// <param name="fixture">The subfixture.</param> /// <param name="actionTarget">The optional fixture action instance.</param> /// <param name="actionMethod">The optional fixture action method.</param> /// <param name="group">The fixture group.</param> public SubFixture(ITestFixture fixture, object actionTarget, MethodInfo actionMethod, int group) { // $hack(jefflill): // // I'm having the caller pass the action instance and method manually to // avoid casting errors. There's probably a cleaner way to do this but // this'll work fine. this.Fixture = fixture; this.IsNeonService = false; this.ActionTarget = actionTarget; this.ActionMethod = actionMethod; this.ServiceCreator = null; this.ServiceMap = null; this.StartTimeout = default; this.Group = group; }
/// <summary> /// Constructor for <see cref="NeonServiceFixture{TService}"/> fixtures. /// </summary> /// <param name="fixture">The subfixture.</param> /// <param name="serviceCreator">The service creator function as an object.</param> /// <param name="serviceMap">Specifies the service map, if any.</param> /// <param name="startTimeout">Specifies the maximum time to wait for the service to transition to the running state.</param> /// <param name="group">The fixture group.</param> public SubFixture(ITestFixture fixture, object serviceCreator, ServiceMap serviceMap, TimeSpan startTimeout, int group) { // $hack(jefflill): // // I'm having the caller pass the action instance and method manually to // avoid casting errors. There's probably a cleaner way to do this but // this'll work fine. this.Fixture = fixture; this.IsNeonService = true; this.ActionTarget = null; this.ActionMethod = null; this.ServiceCreator = serviceCreator; this.StartTimeout = startTimeout; this.ServiceMap = serviceMap; this.Group = group; }
private UserMenu getBlogMenu(User user) { List <IMenu> menus = ServiceMap.GetMenuService(typeof(User)).GetList(user); foreach (IMenu x in menus) { if (x.RawUrl == null) { continue; } if (x.RawUrl.ToLower().IndexOf("blog/index") > 0) { return(x as UserMenu); } } return(null); }