public async Task <IActionResult> Login(LoginInputViewModel viewModel) { if (!ModelState.IsValid) { return(View(new LoginViewModel(viewModel))); } Membership membership = null; try { membership = (_queryService.ExecuteQuery <GetMembershipByUsername, Membership>(new GetMembershipByUsername { Username = viewModel.Username }).Result); } catch (MemberNotFoundException) { //Let this exception pass. } catch (Exception) { //Need a way to redirect here. } var password = _cryptographicService.ComputeHash(string.Concat(viewModel.Password, membership?.PasswordSalt)); if (membership == null || password == null || membership?.Password != password || !membership.IsEmailConfirmed || membership.IsLocked) { ModelState.AddModelError("InvalidPassword", "Invalid Username/Password combination OR you are yet to confirm your email OR account is locked."); await _commandService.ExecuteCommand(new FailedSignInAttemptCommand { Username = viewModel.Username }); return(View(new LoginViewModel(viewModel))); } AuthenticationProperties props = null; if (viewModel.RememberMe) { props = new AuthenticationProperties { IsPersistent = true, ExpiresUtc = DateTimeOffset.UtcNow.AddMonths(1) }; } ; var result = await _commandService.ExecuteCommand(new SuccessfulSignInCommand { Username = viewModel.Username }); await HttpContext.SignInAsync(membership.GetClaim(JwtClaimTypes.Subject), viewModel.Username, props); return(Redirect(_interactionService.IsValidReturnUrl(viewModel.ReturnUrl) ? viewModel.ReturnUrl : "~/")); }
public async Task <string> Command(ExecuteCommandRequest request) { var chandnel = await _channelService.Get(request.Id); if (chandnel == null) { return("命令发送失败"); } List <CommandDto> data = new List <CommandDto>(); if (request.CommandType == CommandTypeEnum.Stop) { data.Add(new CommandDto { ChanneId = request.Id, CommandType = request.CommandType, FactoryCode = chandnel.FactoryCode }); } else { data = _pullInfoService.GetPullInfoPageList(new PullInfoSearchDto { ChannelId = request.Id, ResultCount = 999 }) .Items.Select(s => new CommandDto { ChanneId = request.Id, CommandType = request.CommandType, FactoryCode = chandnel.FactoryCode, PullAddress = s.Url, PushAddress = chandnel.PushUrl }).ToList(); } if (data.Count > 0) { var model = LiveChannelManager.Data.FirstOrDefault(m => m.Id == request.Id); if (model != null) { _commandService.ExecuteCommand(data[model.PullIndex]); } else { _commandService.ExecuteCommand(data.FirstOrDefault()); } return("命令已发送"); } else { return("命令发送失败,为查询到对应的数据"); } }
internal void Handle() { try { Log.WriteLine("Receiving request...", 2); byte[] bytes = new byte[1024]; int bytesRec = clientSocket.Receive(bytes); Log.WriteLine("Creating response...", 2); Message request = new Message(Encoding.ASCII.GetString(bytes, 0, bytesRec)); string result = commandService.ExecuteCommand(request.ToString()); Log.WriteLine("Sending response...", 2); byte[] bytesRequest = Encoding.ASCII.GetBytes(result); clientSocket.Send(bytesRequest); Log.WriteLine("Shutting down...", 2); clientSocket.Shutdown(SocketShutdown.Both); clientSocket.Close(); } catch (SocketException se) { string error = "Socket Exception: " + se.Message; Log.WriteError(error); } }
private async Task ExecuteCommand() { _hubConnection.On <CommandDto>("SendCommand", async command => { _logger.LogInformation($"{command.Argument}"); await _hubConnection.InvokeAsync("Receive", await _commandService.ExecuteCommand(command)); }); await Task.CompletedTask; }
public IActionResult ExecuteCommand(Command command) { try { var response = _commandService.ExecuteCommand(command); return(Ok(response)); } catch (Exception ex) { Log.Information($"ExecuteCommand Exception {ex.Message} {ex.InnerException.Message}"); return(BadRequest()); } }
public void ExecuteCommand(params string[] paramList) { string command = string.Join("|", paramList); string response; try { response = commandService.ExecuteCommand(command); Console.WriteLine(response); } catch (ServiceException e) { response = "Service Exception: " + e.Message; Log.WriteError(response); } }
string ExecuteCommand(params string[] paramList) { string command = string.Join("|", paramList); string response; try { response = commandService.ExecuteCommand(command); } catch (ServiceException e) { response = e.Message; ShowMessageDialog("Error", response, MessageType.Error, ButtonsType.Ok); Log.WriteError(response); } return(response); }
public IActionResult ExecuteCommand([FromBody] string command) { var result = _commandService.ExecuteCommand(command); return(Ok(result)); }
private ServiceCommandOutput <object> ExecuteCommandInternal(string command) { return(_commandService.ExecuteCommand(command, _authenticationOutput.Token)); }
private bool NavigateTo(SearchableEntry entry) { if (entry.SearchableEntryType == SearchableEntryOption.Variable) { itemToFocus = entry.ModelItem.Parent.Parent; HighlightModelItem(itemToFocus); this.lastNavigatedItem = itemToFocus; var designerView = this.editingContext.Services.GetService <DesignerView>(); // Open the variable designer. designerView.CheckButtonVariables(); designerView.variables1.SelectVariable(entry.ModelItem); } else if (entry.SearchableEntryType == SearchableEntryOption.Argument) { itemToFocus = this.modelService.Root; HighlightModelItem(itemToFocus); var designerView = this.editingContext.Services.GetService <DesignerView>(); // Open the argument designer. designerView.CheckButtonArguments(); designerView.arguments1.SelectArgument(entry.ModelItem); this.lastNavigatedItem = entry.ModelItem; } else { itemToFocus = entry.ModelItem; HighlightModelItem(itemToFocus); this.lastNavigatedItem = itemToFocus; ICommandService commandService = this.editingContext.Services.GetService <ICommandService>(); if (commandService != null) { commandService.ExecuteCommand(CommandValues.ShowProperties, null); } PropertyInspector propertiesGrid = this.designer.PropertyInspectorView as PropertyInspector; propertiesGrid.SelectPropertyByPath(entry.PropertyPath); if (ShouldShowSearchToolTip(itemToFocus)) { Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() => { WorkflowViewElement viewElement = itemToFocus.View as WorkflowViewElement; if (viewElement != null) { this.adornerLayer = AdornerLayer.GetAdornerLayer(viewElement as WorkflowViewElement); if (this.adornerLayer != null) { DesignerView designerView = this.editingContext.Services.GetService <DesignerView>(); string toolTipText = string.Format(CultureInfo.CurrentUICulture, SR.SearchHintText, entry.ModelProperty.Name); this.toolTipAdorner = new SearchToolTipAdorner(viewElement, designerView, toolTipText); viewElement.CustomItemStatus = "SearchToolTip=" + toolTipText; this.lastWorkflowViewElement = viewElement; this.adornerLayer.Add(this.toolTipAdorner); } } }), DispatcherPriority.ApplicationIdle); } } return(true); }
public async Task <IActionResult> Action() { try { string json = string.Empty; if (Request.HasFormContentType) { var jObject = new JObject(); foreach (var item in Request.Form) { jObject.Add(item.Key, new JValue(item.Value)); } json = JsonConvert.SerializeObject(jObject); } else { var stream = new StreamReader(HttpContext.Request.Body); json = await stream.ReadToEndAsync(); } var url = (string)HttpContext.GetRouteValue("url"); var apiClientRegistration = _apiClientRegistrations.FirstOrDefault(p => p.Route == url); if (apiClientRegistration == null) { return(NotFound()); } var request = JsonConvert.DeserializeObject(json, apiClientRegistration.Type); if (typeof(Command).IsAssignableFrom(apiClientRegistration.Type)) { var command = request as Command; command.RequestedBy = HttpContext.User.Claims.FirstOrDefault(p => p.Type == "sub")?.Value; if (Request.HasFormContentType) { if (Request.Form.Files != null) { return(Ok(_commandService.ExecuteCommandWithAttachments((Command)request, Request.Form.Files.Select(p => new Attachment { FileStream = p.OpenReadStream(), Name = p.Name }).ToList()))); } } return(Ok(_commandService.ExecuteCommand((Command)request))); } if (apiClientRegistration.Type.IsSubClassOfGeneric(typeof(QueryRequest <>))) { var responseType = apiClientRegistration.Type.BaseType?.GetGenericArguments()[0]; var method = _queryService.GetType().GetMethod("ExecuteQuery"); var generic = method.MakeGenericMethod(apiClientRegistration.Type, responseType); var query = (dynamic)request; query.RequestedBy = HttpContext.User.Claims.FirstOrDefault(p => p.Type == "sub")?.Value; var result = generic.Invoke(_queryService, new[] { request }); return(Ok(result)); } return(NotFound()); } catch (Exception e) { _logger.Error(e, ""); return(StatusCode(500)); } }