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("参数错误."); } JsonMceAssetsRollEquip item = JsonConvert.DeserializeObject <JsonMceAssetsRollEquip>(rsb.ToString()); if (item == null) { throw new Exception("参数错误."); } if (string.IsNullOrEmpty(item.assetsid)) { throw new Exception("资产ID不能为空."); } if (string.IsNullOrEmpty(item.rollid)) { throw new Exception("案卷ID不能为空."); } BizLogicMsg msg = BizLogicObject_MCE_B_ASSETS_ROLL.Proxy.Save_RollEquip(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(); } }
public BizLogicMsg Save_RollEquip(JsonMceAssetsRollEquip item) { if (LocalMode) { BizLogicMsg msg = new BizLogicMsg(); using (IDbConnection connection = IDALProvider.IDAL.PopConnection()) { using (IDbTransaction transaction = connection.BeginTransaction()) { try { EntityObject_MCE_B_ASSETS_ROLL objRoll = new EntityObject_MCE_B_ASSETS_ROLL(); objRoll.ID = item.rollid; objRoll = HelperObject_MCE_B_ASSETS_ROLL.Get(objRoll); if (objRoll == null) { throw new Exception("获取数据出错."); } if (objRoll.AUDIT_STATE == 3 || objRoll.AUDIT_STATE == 4) { throw new Exception("已经审核的案卷信息不能再添加关联设备."); } CauseObject_MCE_B_ASSETS_ROLLEQUIP pMCE_B_ASSETS_ROLLEQUIP = new CauseObject_MCE_B_ASSETS_ROLLEQUIP(); pMCE_B_ASSETS_ROLLEQUIP.ROLL_ID = item.rollid; pMCE_B_ASSETS_ROLLEQUIP.ASSETS_ID = item.assetsid; DisplayObject_MCE_B_ASSETS_ROLLEQUIP[] listMCE_B_ASSETS_ROLLEQUIP = BizLogicObject_MCE_B_ASSETS_ROLLEQUIP.Proxy.Query(pMCE_B_ASSETS_ROLLEQUIP); if (listMCE_B_ASSETS_ROLLEQUIP == null || listMCE_B_ASSETS_ROLLEQUIP.Length == 0) { EntityObject_MCE_B_ASSETS_ROLLEQUIP objEquip = new EntityObject_MCE_B_ASSETS_ROLLEQUIP(); objEquip.ASSETS_ID = item.assetsid; objEquip.ROLL_ID = item.rollid; HelperObject_MCE_B_ASSETS_ROLLEQUIP.Save(objEquip, transaction); } else { throw new Exception("该案卷信息中已经添加了此设备."); } 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_ROLL> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_ROLL>(ServiceUri)) { return(smgr.Service.Save_RollEquip(item)); } } }