public BizLogicMsg Save_Ext2(JsonMCE_Write_Off json_Write_Off) { if (LocalMode) { BizLogicMsg msg = new BizLogicMsg(); using (IDbConnection connection = IDALProvider.IDAL.PopConnection()) { using (IDbTransaction transaction = connection.BeginTransaction()) { try { EntityObject_MCE_B_ASSETS_WRITE_OFF entity = new EntityObject_MCE_B_ASSETS_WRITE_OFF(); if (!string.IsNullOrEmpty(json_Write_Off.ID)) { entity.ID = json_Write_Off.ID; entity = HelperObject_MCE_B_ASSETS_WRITE_OFF.Get(entity); if (entity == null) { throw new Exception("获取数据出错."); } } entity.CODE = json_Write_Off.CODE; if (!string.IsNullOrEmpty(json_Write_Off.CREATE_DATE)) { entity.CREATE_DATE = DateTime.Parse(json_Write_Off.CREATE_DATE); } entity.DEPT_ID = json_Write_Off.DEPT_ID; entity.USER_ID = json_Write_Off.USER_ID; entity.FINANCE_CYCLE = json_Write_Off.FINANCE_CYCLE; entity.WRITE_OFF_TYPE_ID = json_Write_Off.WRITE_OFF_TYPE_ID; entity.WRITE_OFF_CAUSE_ID = json_Write_Off.WRITE_OFF_CAUSE_ID; entity.INCOME = json_Write_Off.INCOME; entity.USAGE = json_Write_Off.USAGE; entity.COMMENTS = json_Write_Off.COMMENTS; entity.STATE = 1; if (string.IsNullOrEmpty(json_Write_Off.ID)) { entity.CREATE_TIME = DateTime.Now; entity.CREATE_USER_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.ID; int amount = HelperObject_MCE_B_ASSETS_WRITE_OFF.Save(entity, transaction); } else { entity.MODIFY_TIME = DateTime.Now; entity.MODIFY_USER_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.ID; int amount = HelperObject_MCE_B_ASSETS_WRITE_OFF.Update(entity, transaction); CauseObject_MCE_B_ASSETS_WRITE_OFF_D pWriteOffDetail = new CauseObject_MCE_B_ASSETS_WRITE_OFF_D(); pWriteOffDetail.BASE_ID = json_Write_Off.ID; HelperObject_MCE_B_ASSETS_WRITE_OFF_D.Delete(pWriteOffDetail, transaction); CauseObject_MCE_B_ASSETS_WRITE_OFF_ATTACH pWriteOffAttach = new CauseObject_MCE_B_ASSETS_WRITE_OFF_ATTACH(); pWriteOffAttach.BASE_ID = json_Write_Off.ID; HelperObject_MCE_B_ASSETS_WRITE_OFF_ATTACH.Delete(pWriteOffAttach, transaction); } if (json_Write_Off.children != null && json_Write_Off.children.Count > 0) { foreach (JsonMCE_Write_Off_D item in json_Write_Off.children) { EntityObject_MCE_B_ASSETS_WRITE_OFF_D entity_D = new EntityObject_MCE_B_ASSETS_WRITE_OFF_D(); entity_D.BASE_ID = entity.ID; entity_D.ASSET_ID = item.ASSET_ID; HelperObject_MCE_B_ASSETS_WRITE_OFF_D.Save(entity_D, transaction); } } if (json_Write_Off.listAttach != null && json_Write_Off.listAttach.Count > 0) { foreach (JsonMCE_Write_Off__ATTACH item in json_Write_Off.listAttach) { EntityObject_MCE_B_ASSETS_WRITE_OFF_ATTACH entity_D = new EntityObject_MCE_B_ASSETS_WRITE_OFF_ATTACH(); entity_D.BASE_ID = entity.ID; entity_D.FILE_NAME = item.FILE_NAME; entity_D.SAVENAME = item.SAVENAME; entity_D.USER_ID = item.USER_ID; entity_D.CREATE_DATE = item.CREATE_DATE; HelperObject_MCE_B_ASSETS_WRITE_OFF_ATTACH.Save(entity_D, transaction); } } msg.Message = entity.ID; 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_WRITE_OFF> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_WRITE_OFF>(ServiceUri)) { return(smgr.Service.Save_Ext2(json_Write_Off)); } } }
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("参数错误."); } JsonMCE_Write_Off entity = JsonConvert.DeserializeObject <JsonMCE_Write_Off>(rsb.ToString()); if (string.IsNullOrEmpty(entity.CODE)) { throw new Exception("参数错误,单号不能为空."); } if (string.IsNullOrEmpty(entity.CREATE_DATE)) { throw new Exception("参数错误,申请日期不能为空."); } if (string.IsNullOrEmpty(entity.DEPT_ID)) { throw new Exception("参数错误,申请科室不能为空."); } if (string.IsNullOrEmpty(entity.USER_ID)) { throw new Exception("参数错误,申请人不能为空."); } if (string.IsNullOrEmpty(entity.FINANCE_CYCLE)) { throw new Exception("参数错误,财务月份不能为空."); } if (entity.children != null && entity.children.Count > 0) { foreach (JsonMCE_Write_Off_D item in entity.children) { if (string.IsNullOrEmpty(item.ASSET_ID)) { throw new Exception("参数错误,设备名称不能为空."); } } } else { throw new Exception("没有明细数据"); } BizLogicMsg msg = BizLogicObject_MCE_B_ASSETS_WRITE_OFF.Proxy.Save_Ext2(entity); 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(); } }