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

            if (request.Operation == null)//添加一条数据
            {
                Log.Debug("添加一个设备");
                Device device = Device.CreateInstanceFromJSON(request.PostParams);
                if (null != device)
                {
                    //添加到数据库

                    status = bll.Add(device.ToDataAngineModel());
                }
            }
            else
            {
                if (request.Operation == "update")//更新
                {
                    Log.Debug("更新一个设备");
                    Device device = Device.CreateInstanceFromJSON(request.PostParams);
                    if (null != device)
                    {
                        status = bll.Update(device.ToDataAngineModel());
                    }
                    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 == "list")
                {
                    Log.Debug(string.Format("返回所有设备信息"));
                    SearchInfo_Device searchinfo = SearchInfo_Device.CreateInstanceFromJSON(request.PostParams);
                    if (searchinfo != null)
                    {
                        //int num = bll.DataTableToList(bll.GetAllList().Tables[0]).Count;
                        //List<DataAngineSet.Model.device> deviceslist = bll.DataTableToList(bll.GetAllList(searchinfo.StartIndex, searchinfo.PageSize, "").Tables[0]);
                        Device_Cascade[] des = Device_Cascade.CreateInstanceFromDataAngineDataSet(bll.GetAllList_Cascade(searchinfo.StartIndex, searchinfo.PageSize, ""));
                        response.SetContent(JsonConvert.SerializeObject(des));
                    }
                }
            }

            response.Send();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Post时调用
        /// </summary>
        public override void OnPost(HttpRequest request, HttpResponse response)
        {
            bool status = false;

            if (request.Operation == null)//添加一条数据
            {
                Log.Debug("添加一个设备");
                Device device = Device.CreateInstanceFromJSON(request.PostParams);
                if (null != device)
                {
                    //添加到数据库

                    status = bll.Add(device.ToDataAngineModel());
                }
            }
            else
            {
                if (request.Operation == "update")//更新
                {
                    Log.Debug("更新一个设备");
                    Device device = Device.CreateInstanceFromJSON(request.PostParams);
                    if (null != device)
                    {
                        status = bll.Update(device.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();
        }