public int DeleteByTrans2(CauseObject_MCE_B_ASSETS_METER_CHECK cause, IDbTransaction transaction)
 {
     if (LocalMode)
     {
         return(HelperObject_MCE_B_ASSETS_METER_CHECK.Delete(cause, transaction));
         //平台自动生成代码
     }
     else
     {
         throw new InvalidConstraintException();
     }
 }
        public DisplayObject_MCE_B_ASSETS_METER_CHECK[] Query(CauseObject_MCE_B_ASSETS_METER_CHECK cause, PagingParamter paging, OrderByParameter order)
        {
            if (LocalMode)
            {
                SystemLogic.Proxy.AuditQuery(cause);

                //平台自动生成代码
                return(HelperObject_MCE_B_ASSETS_METER_CHECK.Query(cause, paging, order));
            }
            else
            {
                using (ServiceManager <ServiceContract_MCE_B_ASSETS_METER_CHECK> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_METER_CHECK>(ServiceUri))
                {
                    return(smgr.Service.Query(cause, paging, order));
                }
            }
        }
 public BizLogicMsg Delete(CauseObject_MCE_B_ASSETS_METER_CHECK cause)
 {
     if (LocalMode)
     {
         BizLogicMsg msg = new BizLogicMsg();
         using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
         {
             using (IDbTransaction transaction = connection.BeginTransaction())
             {
                 try
                 {
                     int amount = HelperObject_MCE_B_ASSETS_METER_CHECK.Delete(cause, transaction);
                     //平台自动生成代码
                     transaction.Commit();
                 }
                 catch (Exception expt)
                 {
                     transaction.Rollback();
                     msg = new BizLogicMsg(false, expt.Message);
                     Error(expt);
                 }
                 finally
                 {
                     IDALProvider.IDAL.PushConnection(connection);
                 }
             }
         }
         return(msg);
     }
     else
     {
         using (ServiceManager <ServiceContract_MCE_B_ASSETS_METER_CHECK> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_METER_CHECK>(ServiceUri))
         {
             return(smgr.Service.Delete(cause));
         }
     }
 }
        public void ProcessRequest(HttpContext context)
        {
            //允许跨域
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            JSON_MSG jsonMsg = new JSON_MSG();

            try
            {
                context.Response.ContentType = "text/plain";
                HttpRequest request = context.Request;

                if (string.IsNullOrEmpty(request["id"]))
                {
                    throw new Exception("参数错误.");
                }

                CauseObject_MCE_B_ASSETS_METER_CHECK p = new CauseObject_MCE_B_ASSETS_METER_CHECK();
                p.ID = request["id"].ToString();

                DisplayObject_MCE_B_ASSETS_METER_CHECK[] listHead = BizLogicObject_MCE_B_ASSETS_METER_CHECK.Proxy.Query(p);


                JSON_PAGER_MT_EXEC jsonPager = new JSON_PAGER_MT_EXEC();
                if (listHead == null)
                {
                    throw new Exception("获取列表信息失败.");
                }

                if (listHead[0].STATE <= 1 && listHead[0].ACTUAL_IDENTIFICATION < DateTime.Now.AddYears(-100))
                {
                    listHead[0].ACTUAL_IDENTIFICATION = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                }

                jsonPager.head = listHead[0];



                OrderByParameter orderByAttach = new OrderByParameter();
                orderByAttach.Asc     = false;
                orderByAttach.OrderBy = "CREATE_TIME";

                CauseObject_COM_FILE pCOM_FILE = new CauseObject_COM_FILE();
                pCOM_FILE.REF_TAB_ID   = request["id"];
                pCOM_FILE.REF_TAB_NAME = "MCE_B_ASSETS_METER_CHECK";

                List <JsonMCEMT_APPLY_MTN_ATTACH> list = new List <JsonMCEMT_APPLY_MTN_ATTACH>();

                DisplayObject_COM_FILE[] listAttach = BizLogicObject_COM_FILE.Proxy.Query(pCOM_FILE, null, orderByAttach);
                if (listAttach != null && listAttach.Length > 0)
                {
                    foreach (DisplayObject_COM_FILE item in listAttach)
                    {
                        JsonMCEMT_APPLY_MTN_ATTACH attach = new JsonMCEMT_APPLY_MTN_ATTACH();
                        attach.ID             = item.ID;
                        attach.CLIENT_NAME    = item.CLIENT_NAME;
                        attach.SERVER_NAME    = item.SERVER_NAME;
                        attach.CREATE_USER_ID = item.CREATE_USER_ID;

                        if (!string.IsNullOrEmpty(attach.CREATE_USER_ID))
                        {
                            EntityObject_COM_USER entity = new EntityObject_COM_USER();

                            entity.ID = attach.CREATE_USER_ID;

                            entity = BizLogicObject_COM_USER.Proxy.Get(entity);

                            if (entity != null)
                            {
                                attach.CREATE_USER_ID_NAME = entity.NAME;
                            }
                        }
                        attach.CREATE_TIME = item.CREATE_TIME;
                        list.Add(attach);
                    }
                }
                jsonPager.attach = list;


                jsonMsg.Succeed = 1;
                jsonMsg.Message = jsonPager;
            }
            catch (Exception ex)
            {
                jsonMsg.Succeed = 0;
                jsonMsg.Message = ex.Message;
            }
            finally
            {
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter {
                    DateTimeFormat = "yyyy'-'MM'-'dd HH':'mm"
                };

                string strMsg = JsonConvert.SerializeObject(jsonMsg, Formatting.Indented, timeConverter);
                strMsg = strMsg.Replace("0001-01-01 00:00", "");
                context.Response.Write(strMsg);


                context.Response.End();
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            //允许跨域
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            JSON_MSG jsonMsg = new JSON_MSG();

            try
            {
                context.Response.ContentType = "text/plain";
                HttpRequest request = context.Request;

                OrderByParameter orderBy = new OrderByParameter();
                orderBy.Asc     = false;
                orderBy.OrderBy = "CODE";

                PagingParamter pager = new PagingParamter();
                pager.PageSize  = string.IsNullOrEmpty(request["limit"]) ? 10 : int.Parse(request["limit"].ToString());
                pager.PageIndex = string.IsNullOrEmpty(request["offset"]) ? 0 : (int.Parse(request["offset"].ToString()) <= 0) ? 0 : int.Parse(request["offset"].ToString()) - 1;

                CauseObject_MCE_B_ASSETS_METER_CHECK p = new CauseObject_MCE_B_ASSETS_METER_CHECK();

                if (!string.IsNullOrEmpty(request["status"]))
                {
                    p.STATE = int.Parse(request["status"].ToString());
                }


                if (!string.IsNullOrEmpty(request["dept"]))
                {
                    p.USING_DEPT_ID = request["dept"].ToString();
                }


                if (!string.IsNullOrEmpty(request["asset"]))
                {
                    p.ASSETS_ID = request["asset"].ToString();
                }


                if (!string.IsNullOrEmpty(request["meter_type"]))
                {
                    p.METER_TYPE = request["meter_type"].ToString();
                }

                if (!string.IsNullOrEmpty(request["code"]))
                {
                    p.CODE = "%" + request["code"].ToString() + "%";
                }

                if (!string.IsNullOrEmpty(request["beginspan"]))
                {
                    p.PLAN_IDENTIFICATION     = new DateSpan();
                    p.PLAN_IDENTIFICATION.End = DateTime.Parse(request["beginspan"].ToString()).AddDays(1);
                }



                DisplayObject_MCE_B_ASSETS_METER_CHECK[] list = BizLogicObject_MCE_B_ASSETS_METER_CHECK.Proxy.Query(p, pager, orderBy);



                JSON_PAGER jsonPager = new JSON_PAGER();

                jsonPager.total = pager.TotalRecords;
                jsonPager.rows  = list;

                jsonMsg.Message = jsonPager;
                jsonMsg.Succeed = 1;
            }
            catch (Exception ex)
            {
                jsonMsg.Succeed = 0;
                jsonMsg.Message = ex.Message;
            }
            finally
            {
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter {
                    DateTimeFormat = "yyyy'-'MM'-'dd HH':'mm"
                };

                string strMsg = JsonConvert.SerializeObject(jsonMsg, Formatting.Indented, timeConverter);
                strMsg = strMsg.Replace("0001-01-01 00:00", "");
                context.Response.Write(strMsg);

                context.Response.End();
            }
        }