public APIReturn RunJava(string code) { if (string.IsNullOrEmpty(code)) { APIReturn.BuildFail("code不能为空"); } string codeStr = code.Base64ToString(); if (string.IsNullOrEmpty(code)) { APIReturn.BuildFail("无效的code"); } string path = Path.Combine(GetNewPath(), "Test.java"); //System.IO.File.WriteAllText(path, codeStr, Encoding.UTF8); using (StreamWriter sw = System.IO.File.CreateText(path)) { sw.WriteLine(codeStr); sw.Flush(); } CmResult cr = cmd.RunJava(path); return(cr.Success ? APIReturn.BuildSuccess(cr.Message) : APIReturn.BuildFail(cr.ExecMsg)); }
public async Task <ActionResult> Edit(string taskId, [Bind("taskId,TaskName,TaskDesc,CronExpressionString,CronRemark,IsDce,TaskUrl,IsActive")] TaskModel task) { TaskModel taskModel = await DbContext.Task.FindAsync(Guid.Parse(taskId)); if (taskModel == null) { return(APIReturn.BuildFail("记录不存在")); } taskModel.TaskName = task.TaskName; taskModel.TaskDesc = task.TaskDesc; taskModel.CronExpressionString = task.CronExpressionString; taskModel.CronRemark = task.CronRemark; taskModel.IsDce = task.IsDce; taskModel.TaskUrl = task.TaskUrl; taskModel.IsActive = task.IsActive; DbContext.Task.Update(taskModel); await DbContext.SaveChangesAsync(); ICache.SetList <TaskModel>("task_list", delegate() { return(DbContext.Task.ToArray()); }); RabbitMQHelper.PublishMessage(ConnectionFactory, GlobalVariable.EXCHANGE, taskModel.TaskKey, taskModel.TaskID.ToString()); return(APIReturn.BuildSuccess("修改成功")); }
public async Task <IActionResult> C([FromRoute] string act, string code) { if (string.IsNullOrEmpty(act)) { return(APIReturn.BuildFail("无效的请求")); } if (string.IsNullOrEmpty(code)) { return(APIReturn.BuildFail("code不能为空")); } string codeStr = code.Base64ToString(); if (string.IsNullOrEmpty(codeStr)) { return(APIReturn.BuildFail("无效的code")); } CmResult cm = null; if ("c".Equals(act)) { cm = await coreService.C(codeStr); } else if ("cpp".Equals(act)) { cm = await coreService.CPlusPlus(codeStr); } else if ("java".Equals(act)) { cm = await coreService.Java(codeStr); } else if ("python".Equals(act)) { cm = await coreService.Python(codeStr); } else if ("csharp".Equals(act)) { cm = await coreService.CSharp(codeStr); } else if ("nodejs".Equals(act)) { cm = await coreService.Nodejs(codeStr); } else { cm = CmResult.BuildFail("", "无效的请求"); } if (cm.Success) { return(APIReturn.BuildSuccess(cm.Message)); } return(APIReturn.BuildFail(cm.ExecMsg)); }
public async Task <ActionResult> Create([Bind("Name,Email")] UserModel user) { if (!ModelState.IsValid) { return(APIReturn.BuildFail("数据验证不通过")); } user.CreateTime = DateTime.Now; user.IsActive = true; await DbContext.User.AddAsync(user); DbContext.SaveChanges(); return(APIReturn.BuildSuccess("添加成功")); }
public APIReturn RunCsharp(string code) { if (string.IsNullOrEmpty(code)) { APIReturn.BuildFail("code不能为空"); } string codeStr = code.Base64ToString(); if (string.IsNullOrEmpty(code)) { APIReturn.BuildFail("无效的code"); } CmResult cr = cmd.RunCSharp(codeStr); return(cr.Success ? APIReturn.BuildSuccess(cr.Message) : APIReturn.BuildFail(cr.ExecMsg)); }
public APIReturn RunCPlusPlus(string code) { if (string.IsNullOrEmpty(code)) { APIReturn.BuildFail("code不能为空"); } string codeStr = code.Base64ToString(); if (string.IsNullOrEmpty(code)) { APIReturn.BuildFail("无效的code"); } string path = Path.Combine(GetNewPath(), $"{Guid.NewGuid().ToString("N")}.cpp"); System.IO.File.WriteAllText(path, codeStr, Encoding.UTF8); CmResult cr = cmd.RunCPlusPlus(path); return(cr.Success ? APIReturn.BuildSuccess(cr.Message) : APIReturn.BuildFail(cr.ExecMsg)); }