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

            if (request.Operation == null)//添加一条数据
            {
                Log.Debug("添加布控任务");
                SurveillanceTask task = SurveillanceTask.CreateInstanceFromJson(request.PostParams);
                if (null != task)
                {
                    //添加到数据库
                    status = bll.Add(task.ToDataAngineModel());
                }
            }
            else
            {
                if (request.Operation == "update")//更新
                {
                    Log.Debug("更新布控任务");
                    SurveillanceTask task = SurveillanceTask.CreateInstanceFromJson(request.PostParams);
                    if (null != task)
                    {
                        //添加到数据库
                        status = bll.Update(task.ToDataAngineModel());
                    }
                }
                else if (request.Operation == "delete")//删除
                {
                    Log.Debug("删除布控任务");
                    int id = -1;
                    try
                    {
                        id = Convert.ToInt32(request.RestConvention);
                    }
                    catch
                    {
                    }
                    status = bll.Delete(id);
                }
                else if (request.Operation == "list")
                {
                    Log.Debug(string.Format("返回所有库信息"));
                    SearchInfo_SurveillanceTask searchinfo = SearchInfo_SurveillanceTask.CreateInstanceFromJSON(request.PostParams);
                    if (searchinfo != null)
                    {
                        //Log.Debug("xxxx");
                        //int num = bll.DataTableToList(bll.GetAllList().Tables[0]).Count;
                        //List<DataAngineSet.Model.surveillance_task> datasets = bll.DataTableToList(bll.GetAllList(searchinfo.StartIndex, searchinfo.PageSize, "").Tables[0]);
                        SurveillanceTask_Cascade[] des = SurveillanceTask_Cascade.CreateInstanceFromDataAngineDataSet(bll.GetAllList_Cascade(searchinfo.StartIndex, searchinfo.PageSize, ""));
                        response.SetContent(JsonConvert.SerializeObject(des));
                    }
                }
            }
            response.Send();
        }
        /// <summary>
        /// Post时调用
        /// </summary>
        public override void OnPost(HttpRequest request, HttpResponse response)
        {
            bool status = false;

            if (request.Operation == null)//添加一条数据
            {
                Log.Debug("添加布控任务");
                SurveillanceTask task = SurveillanceTask.CreateInstanceFromJson(request.PostParams);
                if (null != task)
                {
                    //添加到数据库
                    status = bll.Add(task.ToDataAngineModel());
                }
            }
            else
            {
                if (request.Operation == "update")//更新
                {
                    Log.Debug("更新布控任务");
                    SurveillanceTask task = SurveillanceTask.CreateInstanceFromJson(request.PostParams);
                    if (null != task)
                    {
                        //添加到数据库
                        status = bll.Update(task.ToDataAngineModel());
                    }
                }
                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());
            response.Send();
        }