009_DI-Elec/Learun.Application.Web/AppApi/ParallelCableApiController.cs

111 lines
3.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using System.Web.Http.Description;
using Learun.Application.Base.SystemModule;
using Learun.Application.TwoDevelopment.ZZDT_EC;
using Learun.Util;
using log4net.Config;
using NPOI.POIFS.Properties;
using Pipelines.Sockets.Unofficial.Arenas;
namespace Learun.Application.Web.AppApi
{
/// <summary>
/// 平行电缆By YuXH暂时没用
/// </summary>
[HandlerApiLogin(FilterMode.Enforce)]
[TokenAuthorize]
public class ParallelCableApiController : WebApiControllerBase
{
#region
/// <summary>
/// 查询
/// </summary>
/// <param name="projId"></param>
/// <param name="cableId">如果为0或空则查询所有。</param>
/// <returns></returns>
[HttpGet]
public IHttpActionResult GetParalleCable(string projId, string cableId = "")
{
List<string> Ids = new List<string>();
if (string.IsNullOrEmpty(cableId) || cableId == "0")
{
cableId = "";
}
else
{
Ids = cableId.Split(',').ToList();
}
var res = new ec_parallel_CableService().GetList(projId, Ids);
return Success(res);
}
/// <summary>
/// 批量保存增、改。传入ec_cable的集合
/// </summary>
/// <param name="projId"></param>
/// <returns></returns>
[HttpPost]
public IHttpActionResult Save(string projId)
{
try
{
var serv = new ec_parallel_CableService();
var asyncContent = Request.Content.ReadAsStringAsync().Result;
var entity = asyncContent.ToObject<List<ec_CableEntity>>();
foreach (var c in entity)
{
foreach (var p in c.parallelCables)
{
var id = p.p_CableId;
serv.SaveEntity(projId, ref id, p);
p.p_CableId = id;
}
}
return Success(entity);
}
catch (Exception e)
{
return Fail(e.Message);
}
}
/// <summary>
/// 移除某一个平行电缆
/// </summary>
/// <param name="projId"></param>
/// <param name="pCableIds">删除多个,以逗号隔开</param>
/// <returns></returns>
[HttpPost]
public IHttpActionResult Remove(string projId, string pCableIds)
{
try
{
var serv = new ec_parallel_CableService();
var IDs = pCableIds.Split(',');
foreach (var Id in IDs)
{
serv.DeleteEntity(projId, Id);
}
return Success("OK");
}
catch (Exception e)
{
return Fail(e.Message);
}
}
#endregion
}
}