public async Task <JsonResult> Sops(String LINE, String STN, String PARTNO) { BizRequest req = ClientMgr.Instance.CreateRequest("MES", LINE, "ESOP", "LoadESOP", new Dictionary <string, string>() { { "ln", LINE }, { "st", STN }, { "pn", String.IsNullOrEmpty(PARTNO) ? "ALL" : PARTNO } }); req.UserId = User.Identity.Name; BizResponse resp = await Task <BizResponse> .Run(() => { return(ClientMgr.Instance.RunCmd(req.CmdName, req)); }); CmdResponse response = new CmdResponse() { Code = resp.ErrorCode, Msg = resp.ErrorMessage, Data = resp.Data }; return(Json(response)); }
public async Task ModifyCommandAsync( [Summary("vim2meta")] CustomCmd command, [Summary("RETARD THAT'S AS BLIND AS ME GRAN")][Remainder][MaxLength(Config.MAX_CMD_LENGTH)] CmdResponse response = null) { await _dbCustomCmds.UpdateAsync(command, x => x.Response = response.Value); await Context.ReplyAsync("You have successfully updated this command."); }
public async Task AddCommandAsync( [Summary("retarded")][UniqueCustomCmd] string name, [Summary("VIM2META LOL DUDE IS THICC AS BALLS")][Remainder][MaxLength(Config.MAX_CMD_LENGTH)] CmdResponse response) { var newCmd = new CustomCmd(Context.User.Id, Context.Guild.Id, name.ToLower(), response.Value); await _dbCustomCmds.InsertOneAsync(newCmd); await Context.ReplyAsync("You have successfully added a new custom command."); }
public override Task <TypeReaderResult> ReadAsync(ICommandContext context, string input, IServiceProvider services) { var cmdResponse = new CmdResponse(services, input); if (cmdResponse.Value.Length == 0) { return(Task.FromResult(TypeReaderResult.FromError(CommandError.Unsuccessful, "You have provided an invalid command response."))); } return(Task.FromResult(TypeReaderResult.FromSuccess(cmdResponse))); }
static void Main(string[] args) { RunCommand c1 = new RunCommand(); CmdResponse res = new CmdResponse(); // Return Code | Std Output | Std Error //String RESP = c1.run_cmd("C:\\Python27\\python.exe", "C:\\Python27\\test.py", "123 345", "|"); //Console.WriteLine(RESP); String RESP1 = c1.run_os_cmd("ipconfig", "/all", "|"); Console.WriteLine(RESP1); Console.WriteLine(res.RetCode); Console.ReadKey(); }
private bool HandleFailure(CmdResponse request, RegisterAction action) { if (request.HttpStatusCode is HttpStatusCode.Accepted) { return(false); } SweetAlertService.FireAsync($"An error occured while creating your account: {request.Message}", $"", SweetAlertIcon.Error); // If Fail URL property is provided, navigate to the given URL if (!string.IsNullOrEmpty(action.NavigateToOnFailure)) { NavigationManager.NavigateTo(action.NavigateToOnFailure); } return(true); }
public async Task <IHttpActionResult> Run([FromBody] CmdRequest request) { BizRequest req = ClientMgr.Instance.CreateRequest(request.Server, request.Client, request.Entity, request.Cmd, request.Args); req.UserId = User.Identity.Name; BizResponse resp = await Task <BizResponse> .Run(() => { return(ClientMgr.Instance.RunCmd(req.CmdName, req)); }); CmdResponse response = new CmdResponse() { Code = resp.ErrorCode, Msg = resp.ErrorMessage, Code2 = resp.ReturnCode, Msg2 = resp.ReturnMessage, Data = resp.Data }; return(Ok(response)); }
public async Task <bool> HandleFailure <TAction>(CmdResponse response, TAction action, bool silent = false, string customMessage = "") { if (response.HttpStatusCode is HttpStatusCode.Accepted) { return(false); } // Display message to UI switch (silent) { case true: SweetAlertService.FireAsync("Error", $"There was an error while trying to process your request, please try again later"); break; case false: SweetAlertService.FireAsync("Error", string.IsNullOrEmpty(customMessage) ? $"There was an error while trying to process your request: {response.Message}" : $"{customMessage}: {response.Message}"); break; } // Display error to the console Console.WriteLine($"Error from response: {response.Message}"); // If Fail URL property is provided, navigate to the given URL if (!action.ContainsProperty("NavigateToOnFailure")) { return(true); } var s = action.GetPropertyValue("NavigateToOnFailure"); if (s is null) { return(true); } NavigationManager.NavigateTo(s.ToString()); return(true); }
private bool GetCredential(ChangePasswordCmd request, CancellationToken cancellationToken, out TblIdentityCredential entity, out CmdResponse <ChangePasswordCmd> handle) { entity = _dataLayer.TblIdentityCredentials .Where(i => i.Guid == $"{request.CredentialGuid}" || i.UserName == request.UserName) .FirstOrDefault(); if (entity != null) { handle = new(); return(false); } var entityList1 = _dataLayer.TblIdentityContacts .Include(i => i.UserCredential) .Where(i => i.Value == request.PhoneNumber.ValidatePhoneNumber(false) && i.UcentitiesId == (long?)GenericContactType.Phone) .Select(i => i.UserCredential) .ToList(); if (entityList1.Count > 1) { { handle = new() { Message = $"Identity with data [PhoneNumber: {request.PhoneNumber}] exists on multiple identities and is therefore ambiguous", HttpStatusCode = HttpStatusCode.Conflict }; return(true); } } if (entityList1.Any()) { entity = entityList1.First(); } if (entity != null) { handle = new(); return(false); } request.Email.ValidateEmailAddress(); var entityList2 = _dataLayer.TblIdentityContacts .Include(i => i.UserCredential) .Where(i => i.Value == request.Email && i.UcentitiesId == (long?)GenericContactType.Email) .Select(i => i.UserCredential) .ToList(); if (entityList2.Count > 1) { { handle = new() { Message = $"Identity with data [Email: {request.Email};] exists on multiple identities and is therefore ambiguous", HttpStatusCode = HttpStatusCode.Conflict }; return(true); } } if (entityList2.Any()) { entity = entityList2.First(); } if (entity != null) { handle = new(); return(false); } handle = new() { Message = $"Identity with data [GUID: {request.CredentialGuid}; UserName: {request.UserName}; Email: {request.Email}; PhoneNumber: {request.PhoneNumber}] does not exist", HttpStatusCode = HttpStatusCode.NotFound }; return(true); } }