/// <summary> /// 添加配置 /// </summary> /// <param name="newConfiguration"></param> /// <returns></returns> public async Task <JsonDataMsg <string> > UserAddConfigurationToToolAsync(ToolConfigDto newConfiguration) { //参数为空检查 if (null == newConfiguration) { NLogMgr.DebugLog(_programLog, "后台接收配置数据失败"); return(new JsonDataMsg <string>(null, false, "后台接收数据失败")); } //使用mapper装换成聚合根 MapperConfiguration cfg = EntityAutoMapper.Instance.AutoMapperConfig(nameof(JobConfiguration)); CheckConfig checkConfig = EntityAutoMapper.Instance.GetMapperResult <CheckConfig>(cfg, newConfiguration); var success = await Repository.AddConfigDataAsync(checkConfig); if (!success) { NLogMgr.DebugLog(_programLog, "增添配置异常"); return(new JsonDataMsg <string>(null, success, "增添配置异常")); } //异步IPC通知工具客户端配置已变化 _client.InvokeAsync(p => p.ConfigWasModify()); NLogMgr.DebugLog(_programLog, "已经为您加入该配置"); return(new JsonDataMsg <string>(null, success, "已经为您加入该配置")); }
/// <inheritdoc /> public async Task ExecuteAsync(CancellationToken cancellationToken) { var simpleModules = await _client.InvokeAsync(host => host.GetSimpleModules(), cancellationToken) .ConfigureAwait(false); if (simpleModules.Count == 0) { return; } var simpleModuleItems = await _client.InvokeAsync( host => host.GetSimpleModuleInfo(simpleModules.ToArray()), cancellationToken) .ConfigureAwait(false); if (simpleModuleItems.Count == 0) { return; } var maxLabelLength = simpleModuleItems.SelectMany(x => x.Value).Max(x => x.Key.Length); var formatString = $"\t{{0,{-maxLabelLength}}} = {{1}}"; foreach (var moduleName in simpleModules) { if (simpleModuleItems.TryGetValue(moduleName, out var items)) { Console.WriteLine($"{moduleName}:"); foreach (var(label, value) in items) { Console.WriteLine(formatString, label, value); } } } }
public void SendMethod() { if (!string.IsNullOrEmpty(ChatText)) { client.InvokeAsync(x => x.SendChat(Username, ChatText)); } ChatText = string.Empty; }
public async Task <JsonDataMsg <string> > ImportingMachinesAsync(IFormCollection formCollection) { if (null == formCollection || null == formCollection.Files || !formCollection.Files.Any()) { NLogMgr.ErrorExLog(_errorLog, "服务器接收不到文件文件", null); return(new JsonDataMsg <string>(null, false, "服务器接收不到文件")); } IFormFile file = formCollection.Files[0]; if (!ExcelFile.ValidExcelFile(file)) { NLogMgr.DebugLog(_programLog, "您上传的文件不是*.xlsx后缀的文件"); return(new JsonDataMsg <string>(null, false, "您上传的文件不是*.xlsx后缀的文件")); } //导入前通知工具停止作业 NLogMgr.DebugLog(_programLog, "通知工具停止作业"); try { bool ipcResult = await _client.InvokeAsync(p => p.StopJob()); NLogMgr.DebugLog(_programLog, "工具反馈结果:" + ipcResult); } catch (Exception ipcEx) { NLogMgr.ErrorExLog(_errorLog, "ipc通信失败", ipcEx); } List <EquipmentDto> list = await ExcelFileService.GetExcelDataAsync(file); bool success = await Repository.ReplaceTargetsAsync(list); JsonDataMsg <string> result = null; if (success) { NLogMgr.DebugLog(_programLog, "设备导入完毕"); result = new JsonDataMsg <string>(null, success, "设备导入完毕"); } else { NLogMgr.DebugLog(_programLog, "导入设备操作过程发生异常"); result = new JsonDataMsg <string>(null, success, "导入设备操作过程发生异常"); } //导入后重新开始作业 NLogMgr.DebugLog(_programLog, "通知工具可以继续作业"); _client.InvokeAsync(p => p.JobRestart()); return(result); }
public async Task <List <string> > GetProjectsId() { List <string> projectList; try { projectList = await _client.InvokeAsync(x => x.GetProjects()); } catch (Exception e) { throw new Exception("An error occured while retrieving a new Task", e); } return(projectList); }
public static async Task OrderAsync <TInterface>( this IpcServiceClient <TInterface> client, Expression <Func <TInterface, Order> > action) where TInterface : class { var result = await client.InvokeAsync(action); if (!result.Success) { throw new InvalidOperationException(result.UserErrorMessage); } }
/// <inheritdoc /> public async Task ExecuteAsync(CancellationToken cancellationToken) { var connections = await _client .InvokeAsync(host => host.GetConnections(), cancellationToken) .ConfigureAwait(false); Console.WriteLine("ID \tIs alive?\tRemote IP"); foreach (var connection in connections) { Console.WriteLine($"{connection.Id}\t{connection.IsAlive}\t{connection.RemoteIp}"); } }
public static async Task InvokeWithDelayAsync <TInterface>(this IpcServiceClient <TInterface> client, Expression <Func <TInterface, Task> > exp, TimeSpan delay, CancellationToken cancellationToken = default(CancellationToken)) where TInterface : class { var task = client.InvokeAsync(exp, cancellationToken); if (await Task.WhenAny(task, Task.Delay(delay, cancellationToken)) != task) { throw new TimeoutException(); } }
/// <inheritdoc /> public async Task ExecuteAsync(CancellationToken cancellationToken) { var info = await _client.InvokeAsync(host => host.GetExtendedModuleInfo(Name), cancellationToken) .ConfigureAwait(false); if (!info.TryGetValue(Name, out var lines)) { return; } foreach (var line in lines) { Console.WriteLine(line); } }
public async void LoginMethod() { if (!string.IsNullOrEmpty(Username)) { LoginVisibility = Visibility.Collapsed; ChatViewVisibility = Visibility.Visible; client = new IpcServiceClientBuilder <IChatService>() .UseTcp(IPAddress.Loopback, 8000) .Build(); await client.InvokeAsync(x => x.Join(Username)); var dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(RefreshMethod); dispatcherTimer.Interval = new TimeSpan(0, 0, 1); dispatcherTimer.Start(); } }
public async Task <TaskBox> GetNewTaskBoxAsync(string brief, string summary, string assignedUser, string reviewer, DateTime dueDate, TaskType taskType) { ITaskItem taskItem; try { taskItem = await _client.InvokeAsync(x => x.AddTask(brief, summary, assignedUser, reviewer, dueDate, taskType)); } catch (Exception e) { throw new Exception("An error occured while retrieving a new Task", e); } return(AddTaskBox(taskItem)); // return new ChatBox(10); // return AddChatBox(_chatboxManager.AddRoom()); }
/// <inheritdoc /> public Task ExecuteAsync(CancellationToken cancellationToken) { return(_client.InvokeAsync(host => host.CloseConnectionAsync(Name), cancellationToken)); }
public void AddMessage(string roomID, string author, string message) { // _chatboxManager.AddRoomMessage(roomID, author, message); _client.InvokeAsync(x => x.AddRoomMessage(roomID, author, message)); }
public Task <int> InvokeMethodAsync(string assemblyPath, string typeAndMethodName, string[] args, CancellationToken token = default) { return(m_client.InvokeAsync(s => s.InvokeMethod(assemblyPath, typeAndMethodName, args), token)); }
/// <inheritdoc /> public Task ExecuteAsync(CancellationToken cancellationToken) { _status.Closed = true; return(_client.InvokeAsync(host => host.StopAsync(), cancellationToken)); }
public async Task TestConnection__OKAsync() { bool isConnected = await _client.InvokeAsync(x => x.IsConnected()); Assert.IsTrue(isConnected); }
static async Task GoAsync(IpcServiceClient <IBmsService> client) { var result = await client.InvokeAsync(x => x.AddFloat(1.23f, 4.56f)); }
public Guid?TryGetElementUnderCursor() { return(_client.InvokeAsync(x => x.TryGetElementUnderCursor()).GetAwaiter().GetResult()); }
/// <inheritdoc /> public Task ExecuteAsync(CancellationToken cancellationToken) { return(_client.InvokeAsync(host => host.PauseAsync(), cancellationToken)); }
public async Task HighlightElement(Guid elementId) { await _ipcServiceClient.InvokeAsync(x => x.HighlightGuiElement(elementId), new CancellationTokenSource(5000).Token); }