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_D_MCE_TYPE p = new CauseObject_MCE_D_MCE_TYPE(); p.ID = request["id"].ToString(); DisplayObject_MCE_D_MCE_TYPE[] listHead = BizLogicObject_MCE_D_MCE_TYPE.Proxy.Query(p); JSON_PAGER jsonPager = new JSON_PAGER(); if (listHead == null || listHead.Length == 0) { throw new Exception("获取列表信息失败."); } jsonPager.head = listHead[0]; CauseObject_MCE_D_TYPE_DEPT pd = new CauseObject_MCE_D_TYPE_DEPT(); pd.MCE_TYPE_ID = request["id"].ToString(); DisplayObject_MCE_D_TYPE_DEPT[] listDetail = BizLogicObject_MCE_D_TYPE_DEPT.Proxy.Query(pd); jsonPager.total = listDetail.Length; jsonPager.rows = listDetail; 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 List <JsonMceTypeTree> getMceTypeTree() { if (LocalMode) { List <JsonMceTypeTree> nodes = new List <JsonMceTypeTree>(); using (IDbConnection connection = IDALProvider.IDAL.PopConnection()) { using (IDbTransaction transaction = connection.BeginTransaction()) { try { OrderByParameter orderBy = new OrderByParameter(); orderBy.Asc = true; orderBy.OrderBy = "CODE"; CauseObject_MCE_D_MCE_TYPE pType = new CauseObject_MCE_D_MCE_TYPE(); pType.SetCustomCondition(" and MCE_D_MCE_TYPE.PARENT_ID is null "); EntityObject_MCE_D_MCE_TYPE[] types = HelperObject_MCE_D_MCE_TYPE.Query(pType, null, orderBy, transaction); foreach (EntityObject_MCE_D_MCE_TYPE type in types) { JsonMceTypeTree tmp = new JsonMceTypeTree(); tmp.id = type.ID.Trim(); tmp.text = type.NAME; tmp.state = "open"; tmp.children = new List <JsonMceTypeTree>(); nodes.Add(tmp); } int count = 0; CauseObject_MCE_D_MCE_TYPE pChild = new CauseObject_MCE_D_MCE_TYPE(); foreach (JsonMceTypeTree node in nodes) { addTreeNode(node, count, pChild, orderBy, transaction); } transaction.Commit(); } catch (Exception expt) { nodes = null; transaction.Rollback(); Error(expt); } finally { IDALProvider.IDAL.PushConnection(connection); } } } return(nodes); } else { using (ServiceManager <ServiceContract_MCE_D_MCE_TYPE> smgr = new ServiceManager <ServiceContract_MCE_D_MCE_TYPE>(ServiceUri)) { return(smgr.Service.getMceTypeTree()); } } }
public int DeleteByTrans2(CauseObject_MCE_D_MCE_TYPE cause, IDbTransaction transaction) { if (LocalMode) { return(HelperObject_MCE_D_MCE_TYPE.Delete(cause, transaction)); //平台自动生成代码 } else { throw new InvalidConstraintException(); } }
public DisplayObject_MCE_D_MCE_TYPE[] Query(CauseObject_MCE_D_MCE_TYPE cause, PagingParamter paging, OrderByParameter order) { if (LocalMode) { SystemLogic.Proxy.AuditQuery(cause); //平台自动生成代码 return(HelperObject_MCE_D_MCE_TYPE.Query(cause, paging, order)); } else { using (ServiceManager <ServiceContract_MCE_D_MCE_TYPE> smgr = new ServiceManager <ServiceContract_MCE_D_MCE_TYPE>(ServiceUri)) { return(smgr.Service.Query(cause, paging, order)); } } }
public BizLogicMsg Delete(CauseObject_MCE_D_MCE_TYPE cause) { if (LocalMode) { BizLogicMsg msg = new BizLogicMsg(); using (IDbConnection connection = IDALProvider.IDAL.PopConnection()) { using (IDbTransaction transaction = connection.BeginTransaction()) { try { int amount = HelperObject_MCE_D_MCE_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_D_MCE_TYPE> smgr = new ServiceManager <ServiceContract_MCE_D_MCE_TYPE>(ServiceUri)) { return(smgr.Service.Delete(cause)); } } }
private void addTreeNode(JsonMceTypeTree node, int count, CauseObject_MCE_D_MCE_TYPE pChild, OrderByParameter orderBy, IDbTransaction transaction) { if (count > 5) { return; } pChild.PARENT_ID = node.id; EntityObject_MCE_D_MCE_TYPE[] typeChildren = HelperObject_MCE_D_MCE_TYPE.Query(pChild, null, orderBy, transaction); if (typeChildren == null || typeChildren.Length == 0) { node.state = ""; return; } foreach (EntityObject_MCE_D_MCE_TYPE typeChild in typeChildren) { JsonMceTypeTree tmp = new JsonMceTypeTree(); tmp.id = typeChild.ID.Trim(); tmp.text = typeChild.NAME; tmp.state = "closed"; tmp.children = new List <JsonMceTypeTree>(); node.children.Add(tmp); addTreeNode(tmp, count + 1, pChild, orderBy, transaction); } }
public BizLogicMsg Delete_Ext(List <string> listID) { if (LocalMode) { BizLogicMsg msg = new BizLogicMsg(); using (IDbConnection connection = IDALProvider.IDAL.PopConnection()) { using (IDbTransaction transaction = connection.BeginTransaction()) { try { if (listID != null && listID.Count > 0) { foreach (string strID in listID) { CauseObject_MCE_D_MCE_TYPE p_Type = new CauseObject_MCE_D_MCE_TYPE(); p_Type.PARENT_ID = strID; DisplayObject_MCE_D_MCE_TYPE[] listMCE_D_MCE_TYPE = BizLogicObject_MCE_D_MCE_TYPE.Proxy.Query(p_Type); if (listMCE_D_MCE_TYPE != null && listMCE_D_MCE_TYPE.Length > 0) { throw new Exception("该资产分类下存在子分类,不能删除."); } CauseObject_MCE_B_ASSETS p = new CauseObject_MCE_B_ASSETS(); p.MACHINE_TYPE_ID = strID; DisplayObject_MCE_B_ASSETS[] list = BizLogicObject_MCE_B_ASSETS.Proxy.Query(p); if (list != null && list.Length > 0) { throw new Exception("在资产卡片中已经使用的资产分类不能删除."); } EntityObject_MCE_D_MCE_TYPE obj = new EntityObject_MCE_D_MCE_TYPE(); obj.ID = strID; if (obj.STATE == 1) { throw new Exception("状态为[正常]的资产分类不能删除."); } obj = HelperObject_MCE_D_MCE_TYPE.Get(obj); if (obj != null) { HelperObject_MCE_D_MCE_TYPE.Delete(obj, 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_D_MCE_TYPE> smgr = new ServiceManager <ServiceContract_MCE_D_MCE_TYPE>(ServiceUri)) { return(smgr.Service.Delete_Ext(listID)); } } }
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; // string strID = request["id"].ToString(); 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("参数错误."); } JsonMceType jsonMceType = JsonConvert.DeserializeObject <JsonMceType>(rsb.ToString()); if (string.IsNullOrEmpty(jsonMceType.parent_id) || string.IsNullOrEmpty(jsonMceType.code) || string.IsNullOrEmpty(jsonMceType.name) || jsonMceType.state <= 0) { throw new Exception("父类、类型编码、类型名称、状态不能为空."); } CauseObject_MCE_D_MCE_TYPE p = new CauseObject_MCE_D_MCE_TYPE(); p.CODE = jsonMceType.code; string strCondition = ""; if (!string.IsNullOrEmpty(jsonMceType.id)) { strCondition = strCondition + " and MCE_D_MCE_TYPE.ID<>'" + jsonMceType.id + "'"; p.SetCustomCondition(strCondition); } DisplayObject_MCE_D_MCE_TYPE[] list = BizLogicObject_MCE_D_MCE_TYPE.Proxy.Query(p); if (list != null && list.Length > 0) { throw new Exception("分类编码:[" + jsonMceType.code + "]已经存在."); } BizLogicMsg msg = BizLogicObject_MCE_D_MCE_TYPE.Proxy.Save_Ext(jsonMceType); if (!msg.Succeed) { throw new Exception(msg.Message); } jsonMsg.Succeed = 1; } catch (Exception ex) { jsonMsg.Succeed = 0; jsonMsg.Message = ex.Message; } finally { context.Response.Write(JsonConvert.SerializeObject(jsonMsg)); 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 = 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_D_MCE_TYPE p = new CauseObject_MCE_D_MCE_TYPE(); if (!string.IsNullOrEmpty(request["status"])) { p.STATE = int.Parse(request["status"].ToString()); } if (!string.IsNullOrEmpty(request["parent_id"])) { p.PARENT_ID = request["parent_id"].ToString(); } if (!string.IsNullOrEmpty(request["condition"])) { p.SetCustomCondition(string.Format(" and (upper(MCE_D_MCE_TYPE.CODE) like upper('%{0}%') or upper(MCE_D_MCE_TYPE.NAME) like upper('%{0}%')) ", request["condition"].ToString().Trim())); } else { if (!string.IsNullOrEmpty(request["code"])) { p.CODE = "%" + request["code"].ToString() + "%"; } if (!string.IsNullOrEmpty(request["name"])) { p.NAME = "%" + request["name"].ToString() + "%"; } } DisplayObject_MCE_D_MCE_TYPE[] list = BizLogicObject_MCE_D_MCE_TYPE.Proxy.Query(p, pager, orderBy); JSON_PAGER jsonPager = new JSON_PAGER(); if (list == null) { throw new Exception("获取列表信息失败."); } 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; if (request["id"] == null) { throw new Exception("参数错误."); } OrderByParameter orderBy = new OrderByParameter(); orderBy.Asc = true; orderBy.OrderBy = "CODE"; CauseObject_MCE_D_MCE_TYPE p = new CauseObject_MCE_D_MCE_TYPE(); string strCondition = " and MCE_D_MCE_TYPE.ID in(select type_id from MCE_B_ASSETS_CHECK_TYPE where base_id='" + request["id"] + "')"; p.SetCustomCondition(strCondition); DisplayObject_MCE_D_MCE_TYPE[] list = BizLogicObject_MCE_D_MCE_TYPE.Proxy.Query(p, null, orderBy); /* * JSON_PAGER jsonPager = new JSON_PAGER(); * * * CauseObject_MCE_B_ASSETS_CHECK_TYPE pd = new CauseObject_MCE_B_ASSETS_CHECK_TYPE(); * pd.BASE_ID = request["id"].ToString(); * * DisplayObject_MCE_B_ASSETS_CHECK_TYPE[] listDetail = BizLogicObject_MCE_B_ASSETS_CHECK_TYPE.Proxy.Query(pd, null, orderBy); */ jsonMsg.Succeed = 1; jsonMsg.Message = list; } 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(); } }