Example #1
0
        /// <summary>
        /// Post时调用
        /// </summary>
        public override void OnPost(HttpRequest request, HttpResponse response)
        {
            bool status = false;

            if (request.Operation == "update")//更新
            {
                Log.Debug("更新一个人员库");
                RegisterInfo registerInfo = RegisterInfo.CreateInstanceFromJSON(request.PostParams);
                if (registerInfo != null)
                {
                    int DatasetId = Convert.ToInt32(request.RestConvention);
                    //初始化
                    InitFRS();
                    int num = fa.RegisterInBulk1(registerInfo.Path, DatasetId);
                    if (num > 0)
                    {
                        status = true;
                    }
                    Log.Debug(string.Format("共注册{0}人", num));
                }
                response.SetContent(status.ToString());
            }

            else if (request.Operation == "add")//单人添加
            {
                Log.Debug("添加一个人员");
                int id = -1;
                try
                {
                    id = Convert.ToInt32(request.RestConvention);
                }
                catch
                {
                }

                UserInfo           usr                = new UserInfo();
                string             result             = Base64Decode(request.PostParams);
                RegisterSingleInfo registersingleinfo = RegisterSingleInfo.CreateInstanceFromJSON(result);
                usr.personDatasetId = id;
                usr.name            = registersingleinfo.Name;
                usr.gender          = registersingleinfo.Gender;
                usr.cardId          = registersingleinfo.CardId;


                //初始化
                InitFRS();
                //Console.WriteLine("TEST1!");
                //Bitmap Bitmapsrc = Base64ToImage(registersingleinfo.PicSrc);
                //Console.WriteLine("TEST2!");
                //Bitmap bmpsrc = new Bitmap(Bitmapsrc.Width, Bitmapsrc.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                //Console.WriteLine("TEST3!");
                //Graphics.FromImage(bmpsrc).DrawImage(Bitmapsrc, new Rectangle(0, 0, bmpsrc.Width, bmpsrc.Height));

                //Console.WriteLine("TEST4!");

                int statusnum = fa.Register(registersingleinfo.PicSrc, usr);
                //int statusnum = fa.Register("E:/phpStudy/PHPTutorial/WWW/hisense/data/upload/portal/20180408/5ac9be9e264b5.jpg", usr);
                Console.WriteLine(statusnum);
                if (statusnum == 0)
                {
                    status = true;
                    Log.Debug(string.Format("注册成功"));
                }

                response.SetContent(statusnum.ToString());
            }
            else if (request.Operation == "delete")//删除
            {
                Log.Debug("删除一个人员");

                int id = -1;
                try
                {
                    id = Convert.ToInt32(request.RestConvention);
                }
                catch
                {
                }
                status = personbll.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);
                    //int num = personbll.DataTableToList(personbll.GetList_Library(DatasetId.ToString()).Tables[0]).Count;
                    PersonData[] users = PersonData.CreateInstanceFromDataAngineDataSet(personbll.GetList(viewinfo.StartIndex, viewinfo.PageSize, DatasetId.ToString()));
                    response.SetContent(JsonConvert.SerializeObject(users));
                }
                else
                {
                    int DatasetId = Convert.ToInt32(request.RestConvention);
                    int num       = personbll.DataTableToList(personbll.GetList_Library(DatasetId.ToString()).Tables[0]).Count;
                    response.SetContent(num.ToString());
                }
            }

            response.Send();
        }
Example #2
0
        /// <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();
        }