public async Task <IApiOut> UpLoadFile([ApiVal(Val.File)] IFormFile file, [ApiVal(Val.Service)] UpLoad upFiles, string DelFilePath)//string DelFilePath, string Filedata, string IsWater, string IsThumbnail { AjaxJson _ajv = new(); string _delfile = DelFilePath?.TrimStart('/'); bool _iswater = false; //默认不打水印 bool _isthumbnail = false; //默认不生成缩略图 //if (IsWater == "1") // _iswater = true; //if (IsThumbnail == "1") // _isthumbnail = true; if (file == null) { //Json("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}"); _ajv.code = 1; _ajv.msg = "请选择要上传文件!"; return(await ApiOut.JsonAsync(_ajv)); } //UpLoad upFiles = new(); //删除已存在的旧文件,旧文件不为空且应是上传文件,防止跨目录删除 if (upFiles.FileSaveAs(file, _isthumbnail, _iswater, ref _ajv) && !string.IsNullOrEmpty(_delfile) && _delfile.StartsWith(upFiles.Config.Webpath + upFiles.Config.Filepath, StringComparison.OrdinalIgnoreCase)) { upFiles.DeleteUpFile(_delfile); } //返回成功信息 return(await ApiOut.JsonAsync(_ajv)); }
protected override IApiOut Initialize(AshxRouteData ashxRoute) { if (!ashxRoute.HttpContext.Session.IsAvailable) { return(ApiOut.View("500.html")); } return(RoleAction.Initialize(ashxRoute)); }
//[AshxRoute(template: "小鸟/{id?}")] //[AshxRoute(template: "小鸟/{id=cs}.html")] //public IApiOut Index([ApiVal(Val.RouteKey)] string id) //{ // "hhh".ToInt(); // return ApiOut.View(id + ".html");// ApiOut.ViewAsyn(); // //} public async Task <IApiOut> Index(string p, int a, decimal c, [ApiVal(Val.AllMode)] Api.ps app, [ApiVal(Val.RouteKey)] string d, [ApiVal(Val.Service)] AshxRouteData e, [ApiVal(Val.RouteKey)] string id = "cs") { "hhh".ToInt(); return(await ApiOut.PathViewAsync(id));// ApiOut.ViewAsyn(); // }
public async Task <IApiOut> Upload( [ApiVal(Val.File)] IFormFile file_data, [ApiVal(Val.Header, ".123")] string abc, [ApiVal(Val.Header, "User-Agent")] string agent) { await file_data.Save(AppContext.BaseDirectory + "Upload\\" + file_data.FileName); return(await ApiOut.JsonAsync(new { mag = "保存成功!" })); }
public IApiOut As() { return(ApiOut.Json(new { a = 5 })); }
public async Task <IApiOut> RoleManageEdit() => await ApiOut.PathViewAsync("System");
/// <summary> /// 用户管理 /// </summary> /// <returns></returns> public async Task <IApiOut> ManageList() => await ApiOut.PathViewAsync("System");
public async Task <IApiOut> MenuEdil() => await ApiOut.PathViewAsync("System");
/// <summary> /// 玩家列表 /// </summary> /// <returns></returns> public IApiOut AccountList() => ApiOut.View();
/// <summary> /// 默认页面 /// </summary> /// <returns></returns> //[AshxRoute("login.html")] public async Task <IApiOut> Welcome() => await ApiOut.ViewAsync("Views/welcome.html");
/// <summary> /// 后台首页 /// </summary> /// <returns></returns> //[AshxRoute("login.html")] public async Task <IApiOut> Login() => await ApiOut.ViewAsync("Views/login.html");
/// <summary> /// 后台首页 /// </summary> /// <returns></returns> //[AshxRoute("index.html")] public async Task <IApiOut> Index() => await ApiOut.ViewAsync("Views/index.html");
protected override IApiOut AshxException(AshxException ex) { Tool.Utils.Log.Fatal("全局错误:", ex); return(ApiOut.View("404.html")); }
//Api/{controller=Heheh}/{action=Download}/{id1?} //[AshxRoute(template: "小鸟/{id1=index}.html")] public async Task <IApiOut> Download([ApiVal(Val.RouteKey)] string id, [ApiVal(Val.Service)] Microsoft.AspNetCore.Hosting.IWebHostEnvironment webHost) { return(await ApiOut.FileAsync(id, System.IO.File.OpenRead(webHost.WebRootPath + "\\Download\\" + id))); }
//[AshxRoute(template: "小鸟/{id?}/{id1?}")] public async Task <IApiOut> Cs([ApiVal(Val.RouteKey)] string action, [ApiVal(Val.RouteKey)] string id, [ApiVal(Val.RouteKey)] string id1) { return(await ApiOut.WriteAsync(action + id + id1)); }
public JsonOut GetSql( HttpContext context , [ApiVal(Val.Query)] int Id , [ApiVal(Val.Form)] string Key , [ApiVal(Val.Service)] Tool.SqlCore.DbHelper dbHelper , [ApiVal(Val.File)] IFormFile file //,[ApiVal(Val.Session)] int key10 //,[ApiVal(Val.Session)] ps key11 , [ApiVal(Val.RouteKey)] int id1 , [ApiVal(Val.RouteKey)] string controller , [ApiVal(Val.RouteKey)] string action , [ApiVal(Val.Service)] Microsoft.Extensions.Logging.ILoggerFactory factory , [ApiVal(Val.Cookie)] int SessionId , [ApiVal(Val.Header)] string Cookie1 , [ApiVal(Val.QueryMode)] system whereSort) { //System.Data.DataSet ds = dbHelper.Query("SELECT * FROM system WHERE Id=@a OrDER by id desc", new { a = 1, b = "2", c = true, d = DateTime.Now, e = new byte[] { 60, 254 } }); //MySql.Data.MySqlClient.MySqlTransaction sqlConnection = dbHelper.CreateTransaction<MySql.Data.MySqlClient.MySqlTransaction>(); //DbTransResult trans = sqlConnection.ExecuteNonQuery(dbHelper, // dbHelper.GetTextParameter("INSERT INTO system(id,key_en,key_cn,value)VALUES(@Id,'1','1','1')", new { Id = 4 }) // , dbHelper.GetTextParameter("INSERT INTO system(id,key_en,key_cn,value)VALUES(@Id,'1','1','1')", new { Id = 5 }) // , dbHelper.GetTextParameter("INSERT INTO system(id,key_en,key_cn,value)VALUES(@Id,'1','1','1')", new { Id = 4 })); ////new SqlTextParameter("INSERT INTO [dbo].[Backpacks]([Name],[Capacity],[PropId])VALUES('1',1,1)") //// , new SqlTextParameter("INSERT INTO [dbo].[Backpacks]([Name],[Capacity],[PropId])VALUES('1',1,1)") //// , dbHelper.GetTextParameter("INSERT INTO [dbo].[Backpacks]([Id],[Name],[Capacity],[PropId])VALUES(@Id'1',1,1)", new { Id = 4 })); //if (trans.Success) //{ // //trans.Rows;//影响函数 //} ////trans.Exception;//异常情况 ////System.Data.Common.DbParameter[] dbParameter = dbHelper.GetSpParameterSet("spName"); ////dbHelper.TransactionExecuteNonQuery //var da0 = dbHelper.Select("SELECT * FROM system OrDER by id desc", new { a = 1 }); ////var da1 = dbHelper.Insert("system", new { id = 4, key_en = "market", key_cn = "可用积分价值", value = "1" }); ////var da1_1 = dbHelper.Insert<system>(new { id = 4, key_en = "market", key_cn = "可用积分价值", value = "1" }); ////var da2 = dbHelper.Update("system", "WHERE Id=@a", new { value = 5 }, new { a = 4 }); ////var da2_1 = dbHelper.Update("system", "WHERE Id=1", new { value = 1 }); ////var da2_2 = dbHelper.Update<system>("WHERE Id=1", new { value = 1 }, new { a = 1 }); ////var da2_3 = dbHelper.Update<system>("Id=@Id", new { value = "5" }, new { Id = 4 }); ////var da0_1 = dbHelper.Select("SELECT * FROM system OrDER by id desc", new { a = 1 }); ////var da3 = dbHelper.Delete("system", "WHERE Id=@a", new { a = 1 }); ////var da3_1 = dbHelper.Delete<system>("WHERE Id=@Id", new { Id = 4 }); ////var da3_2 = dbHelper.Delete<system>("Id=@a", new { a = 1 }); //if (!ds.IsEmpty()) //{ // return ApiOut.Json(ds.Tables[0].ToDictionary()); //} return(ApiOut.Json(new { msg = $"暂无数据。 action:{controller}\\action:{action}\\action:{id1}", IsTask = false, count })); }