/// <summary> /// Post时调用 /// </summary> public override void OnPost(HttpRequest request, HttpResponse response) { bool status = false; if (request.Operation == null)//添加一条数据 { Dataset da = Dataset.CreateInstanceFromJSON(request.PostParams); if (null != da) { //添加到数据库 Console.WriteLine("添加数据库信息"); status = bll.Add(da.ToDataAngineModel()); } } else { if (request.Operation == "update")//更新 { Console.WriteLine("更新数据库信息"); Dataset da = Dataset.CreateInstanceFromJSON(request.PostParams); if (null != da) { status = bll.Update(da.ToDataAngineModel()); } } else if (request.Operation == "delete")//删除 { int id = -1; try { id = Convert.ToInt32(request.RestConvention); } catch { } status = bll.Delete(id); } } response.SetContent(status.ToString()); response.Send(); }
/// <summary> /// Post时调用 /// </summary> public override void OnPost(HttpRequest request, HttpResponse response) { bool status = false; if (request.Operation == null)//添加一条数据 { Log.Debug("添加一个人员库"); AddInfo addinfo = AddInfo.CreateInstanceFromJSON(request.PostParams); if (addinfo != null) { DataAngine_Set.Model.dataset ds = new DataAngine_Set.Model.dataset(); ds.datasetname = addinfo.DatasetName; ds.remark = addinfo.Remark; status = bll.Add(ds); if (status) { Log.Debug(string.Format("创建人员库成功")); //初始化 //InitFRS(); //int num = fa.RegisterInBulk1(addinfo.Path, ds.datasetname); //Log.Debug(string.Format("共注册{0}人", num)); } } } else { if (request.Operation == "update")//更新 { Log.Debug("更新一个人员库"); RegisterInfo registerInfo = RegisterInfo.CreateInstanceFromJSON(request.PostParams); if (registerInfo != null) { int DatasetId = Convert.ToInt32(request.RestConvention); DataAngine_Set.Model.dataset ds = new DataAngine_Set.Model.dataset(); ds = bll.GetModel(DatasetId); //初始化 InitFRS(); int num = fa.RegisterInBulk1(registerInfo.Path, ds.datasetname); if (num > 0) { status = true; } Log.Debug(string.Format("共注册{0}人", num)); } response.SetContent(status.ToString()); } else if (request.Operation == "delete")//删除 { Log.Debug("删除更新一个人员库"); int id = -1; try { id = Convert.ToInt32(request.RestConvention); } catch { } status = bll.Delete(id); //删除设备 response.SetContent(status.ToString()); } else if (request.Operation == "view")//查看 { Log.Debug("更新一个人员库"); ViewInfo viewinfo = ViewInfo.CreateInstanceFromJSON(request.PostParams); if (viewinfo != null) { int DatasetId = Convert.ToInt32(request.RestConvention); DataAngine_Set.Model.dataset ds = new DataAngine_Set.Model.dataset(); ds = bll.GetModel(DatasetId); UserData[] users = UserData.CreateInstanceFromDataAngineDataSet(userbll.GetPicPathList(null, viewinfo.StartIndex, viewinfo.PageSize, ds.datasetname)); response.SetContent(JsonConvert.SerializeObject(users)); } } } response.Send(); }