public void ProcessRequest(HttpContext context) { var type = context.Request.GetRequestValue("type"); DataResult result = new DataResult(); var error = string.Empty; if (!string.IsNullOrEmpty(type)) { type = type.ToLower(); switch (type) { case "existname": var name = context.Request.GetRequestValue("name"); var id = context.Request.GetRequestValue("id"); if (!id.IsInt()) { error = "数据错误"; break; } result.Data = DependencyResolver.Resolver<WebCrm.Model.Services.IUserInfoService>().ExistName(name, int.Parse(id)); break; } } result.Error = error; result.Success = string.IsNullOrEmpty(error); context.Response.Write(result.ToJson()); }
public void ProcessRequest(HttpContext context) { DataResult result = new DataResult(); try { var model = WebCrm.Framework.DependencyResolver.Resolver<IFileService>().UpLoadFile(context.Request); if (model != null) { result.Success = true; result.Data = new { ID = model.Id, CreateTime = model.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), FileName = model.FileName, FileSize = (int)model.FileSize / 1024 }; } else { result.Success = false; result.Error = "没有文件"; } } catch (Exception e) { result.Success = false; result.Error = e.Message; } context.Response.Write(result.ToJson()); }