using System; using System.Collections.Generic; using System.IO; using System.Security.Cryptography; using System.Text; using System.Web; using System.Web.Http; using Common.Logging; using Learun.Application.Base.SystemModule; using Learun.Application.Organization; using Learun.Application.TwoDevelopment.ZZDT_EC; using Learun.Loger; using Learun.Util; using Learun.Util.Operat; using log4net.Config; using Pipelines.Sockets.Unofficial.Arenas; namespace Learun.Application.Web.AppApi { /// /// 关联关系的接口 /// [RoutePrefix("api/RelApi")] [HandlerApiLogin(FilterMode.Ignore)] public class RelApiController : WebApiControllerBase { #region 模块对象 private ec_reltypeIBLL ec_reltypeIBLL = new ec_reltypeBLL(); private ec_relDataBLL ec_relDataBLL = new ec_relDataBLL(); #endregion /// /// 根据关联关系的名字拿关联关系的Id /// /// /// /// [HttpGet] public IHttpActionResult GetRelDefByName(string RelName, string projId) { var data = ec_reltypeIBLL.GetList("{\"ProjectId\":\"" + projId + "\", \"RelTypeName\": \"" + RelName + "\"}"); return Success(data); } /// /// 增加 编辑对象和对象之间的关系。 /// 请求的Body中带上Json格式的ec_reldata数据集合 /// /// /// /// /// /// /// [HttpGet] [HandlerApiLogin(FilterMode.Enforce)] public IHttpActionResult SaveRelDataBatch(string ProjectId) { var asyncContent = Request.Content.ReadAsStringAsync().Result; try { var entityCol = asyncContent.ToObject>(); ec_relDataBLL.AddEntityBatch(ProjectId,ref entityCol); return Success("创建成功"); } catch (Exception ex) { return Fail(ex.Message); } } /// /// 根据主键,删除某条关联关系 /// /// /// /// [HttpGet] [HandlerApiLogin(FilterMode.Enforce)] public IHttpActionResult RemoveRelData(string ProjectId, string RelDataId) { ec_relDataBLL.RemoveEntity(ProjectId, RelDataId); return Success("delete成功"); } /// /// 找单一记录 /// /// /// /// /// /// /// //[HttpGet] //[HandlerApiLogin(FilterMode.Ignore)] //public IHttpActionResult GetRelData(string ProjectId, string RelTypeId, string ID1, string ID2, int seq = 0) //{ // var res = ec_relDataBLL.GetRelData(ProjectId, RelTypeId, ID1, ID2, seq); // return Success(res); //} /// /// 主力查询 /// /// /// /// 1 or 2 /// 对应startPort出发的设备ID /// /// [HttpGet] [HandlerApiLogin(FilterMode.Ignore)] public IHttpActionResult GetRelCollection(string ProjectId, string RelTypeId, string ID1 = "", string ID2 = "", int seq = 0) { if (!string.IsNullOrEmpty(ID1) && !string.IsNullOrEmpty(ID2)) { //查单一记录 var res = ec_relDataBLL.GetRelData(ProjectId, RelTypeId, ID1, ID2, seq); return Success(res); } else { var res = ec_relDataBLL.GetRelCollection(ProjectId, RelTypeId, ID1, ID2, seq); return Success(res); } } } }