public int DeleteByTrans2(CauseObject_MCE_B_ASSETS_METER_TYPE cause, IDbTransaction transaction) { if (LocalMode) { return(HelperObject_MCE_B_ASSETS_METER_TYPE.Delete(cause, transaction)); //平台自动生成代码 } else { throw new InvalidConstraintException(); } }
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_TYPE p = new CauseObject_MCE_B_ASSETS_METER_TYPE(); p.ID = request["id"].ToString(); DisplayObject_MCE_B_ASSETS_METER_TYPE[] listHead = BizLogicObject_MCE_B_ASSETS_METER_TYPE.Proxy.Query(p); JSON_PAGER jsonPager = new JSON_PAGER(); if (listHead == null || listHead.Length == 0) { throw new Exception("获取列表信息失败."); } jsonPager.head = listHead[0]; 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); context.Response.Write(strMsg); context.Response.End(); } }
public DisplayObject_MCE_B_ASSETS_METER_TYPE[] Query(CauseObject_MCE_B_ASSETS_METER_TYPE cause, PagingParamter paging, OrderByParameter order) { if (LocalMode) { SystemLogic.Proxy.AuditQuery(cause); //平台自动生成代码 return(HelperObject_MCE_B_ASSETS_METER_TYPE.Query(cause, paging, order)); } else { using (ServiceManager <ServiceContract_MCE_B_ASSETS_METER_TYPE> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_METER_TYPE>(ServiceUri)) { return(smgr.Service.Query(cause, paging, order)); } } }
public BizLogicMsg Delete(CauseObject_MCE_B_ASSETS_METER_TYPE 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_TYPE.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_TYPE> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_METER_TYPE>(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; OrderByParameter orderBy = new OrderByParameter(); orderBy.Asc = true; 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_TYPE p = new CauseObject_MCE_B_ASSETS_METER_TYPE(); if (!string.IsNullOrEmpty(request["status"])) { p.STATE = int.Parse(request["status"].ToString()); } if (!string.IsNullOrEmpty(request["condition"])) { string strCondition = " and (MCE_B_ASSETS_METER_TYPE.code like '%" + request["condition"] + "%' or MCE_B_ASSETS_METER_TYPE.name like '%" + request["condition"] + "%' )"; p.SetCustomCondition(strCondition); } else { if (!string.IsNullOrEmpty(request["code"])) { p.CODE = "%" + request["code"].ToString() + "%"; } if (!string.IsNullOrEmpty(request["name"])) { p.NAME = "%" + request["name"].ToString() + "%"; } } DisplayObject_MCE_B_ASSETS_METER_TYPE[] list = BizLogicObject_MCE_B_ASSETS_METER_TYPE.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(); } }
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; StringBuilder rsb = new StringBuilder(); int bytelengg = (int)request.InputStream.Length; using (var reader = new StreamReader(request.InputStream, Encoding.UTF8)) { var read = new Char[bytelengg]; var count = reader.Read(read, 0, bytelengg); while (count > 0) { var str = new string(read, 0, count); rsb.Append(str); count = reader.Read(read, 0, bytelengg); } reader.Close(); reader.Dispose(); request.InputStream.Close(); request.InputStream.Dispose(); } if (string.IsNullOrEmpty(rsb.ToString())) { throw new Exception("参数错误."); } EntityObject_MCE_B_ASSETS_METER_TYPE item = JsonConvert.DeserializeObject <EntityObject_MCE_B_ASSETS_METER_TYPE>(rsb.ToString()); if (string.IsNullOrEmpty(item.CODE) || string.IsNullOrEmpty(item.NAME)) { throw new Exception("编码、名称不能为空."); } CauseObject_MCE_B_ASSETS_METER_TYPE p = new CauseObject_MCE_B_ASSETS_METER_TYPE(); p.CODE = item.CODE; string strCondition = ""; if (!string.IsNullOrEmpty(item.ID)) { strCondition = strCondition + " and MCE_B_ASSETS_METER_TYPE.ID<>'" + item.ID + "'"; p.SetCustomCondition(strCondition); } DisplayObject_MCE_B_ASSETS_METER_TYPE[] list = BizLogicObject_MCE_B_ASSETS_METER_TYPE.Proxy.Query(p); if (list != null && list.Length > 0) { throw new Exception("编码:[" + item.CODE + "]已经存在."); } BizLogicMsg msg = BizLogicObject_MCE_B_ASSETS_METER_TYPE.Proxy.Save_Ext(item); if (!msg.Succeed) { throw new Exception(msg.Message); } jsonMsg.Succeed = 1; jsonMsg.Message = msg.Message; } catch (Exception ex) { jsonMsg.Succeed = 0; jsonMsg.Message = ex.Message; } finally { context.Response.Write(JsonConvert.SerializeObject(jsonMsg)); context.Response.End(); } }