| | |
| | | using IStation.Common; |
| | | using IStation.CalcModel; |
| | | using IStation.Common; |
| | | using IStation.Dto; |
| | | using System; |
| | | using System.Collections.Generic; |
| | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using System.Web; |
| | | using System.Web.Http; |
| | | using System.Web.UI.WebControls; |
| | | using System.Web.UI.WebControls.WebParts; |
| | | using System.Web.Http; |
| | | |
| | | namespace IStation.WebApi.Controllers |
| | | { |
| | |
| | | [Route("Debug")] |
| | | [HttpGet] |
| | | public IStation.Dto.ApiResult Debug(string info) |
| | | { |
| | | |
| | | { |
| | | IStation.LogHelper.Info("debug:"+ info); |
| | | |
| | | |
| | | //IStation.CalcModel.AnaPrj entity = new IStation.CalcModel.AnaPrj(); |
| | | //entity.ID = "123"; |
| | | //entity.StartTime = DateTime.Now; |
| | | //entity.EndTime = DateTime.Now; |
| | | //entity.Name = "232"; |
| | | |
| | | //IStation.CalcModel.AnaRequest ana_request = new AnaRequest(); |
| | | //ana_request.TotalFlow取水总量 = 102; |
| | | |
| | | //var dal = new IStation.DAL.AnaProject(); |
| | | //dal.Insert(entity, ana_request); |
| | | |
| | | |
| | | var dal = new IStation.DAL.AnaProject(); |
| | | var aa = dal.GetLastRecord(); |
| | | return new IStation.Dto.ApiResult<string >("ok"); |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | /// <param name="day"></param> |
| | | /// <returns></returns> |
| | | [Route("GetPrj")] |
| | | [Route("GetPrjByDay")] |
| | | [HttpGet] |
| | | public IStation.Dto.ApiResult GetPrj(string day) |
| | | public IStation.Dto.ApiResult GetPrjByDay(string day) |
| | | { |
| | | if (day == null) |
| | | { |
| | |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day 格式不正确" }; |
| | | } |
| | | |
| | | var prj = Common.HistoryAnaPrjFileHelper.GetPrj(d); |
| | | IStation.CalcModel.AnaRequestBase requestBase = null; |
| | | var prj = Common.HistoryAnaPrjFileHelper.GetByDay(d,out requestBase); |
| | | |
| | | return new IStation.Dto.ApiResult<IStation.CalcModel.AnaPrj>(prj); |
| | | } |
| | |
| | | [HttpGet] |
| | | public IStation.Dto.ApiResult GetLastTimeOpenPumpCount(DateTime day) |
| | | { |
| | | int dict = HistoryAnaPrjFileHelper.GetLastTime_OpenPumpCount(day); |
| | | |
| | | return new IStation.Dto.ApiResult<int>(dict); |
| | | var status = HistoryAnaPrjFileHelper.GetLastTime_OpenPumpStatus (day); |
| | | if(status == null) |
| | | { |
| | | return new IStation.Dto.ApiResult<int>(-1); |
| | | } |
| | | else |
| | | { |
| | | return new IStation.Dto.ApiResult<int>(status.Count); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="day"></param> |
| | | /// <returns></returns> |
| | | [Route("GetLastTimeOpenPumpStatus")] |
| | | [HttpGet] |
| | | public IStation.Dto.ApiResult GetLastTimeOpenPumpStatus(DateTime day) |
| | | { |
| | | var status = HistoryAnaPrjFileHelper.GetLastTime_OpenPumpStatus(day); |
| | | if(status == null) |
| | | return new IStation.Dto.ApiResult<string >(""); |
| | | else |
| | | return new IStation.Dto.ApiResult<string >(string.Join(",",status)); |
| | | } |
| | | |
| | | public class SavePrjRequest |
| | | { |
| | | public string day { get; set; } |
| | | public Model.AnaSetting settting { get; set; } |
| | | public Model.AnaRequestBase requestBase { get; set; } |
| | | { |
| | | public IStation.CalcModel.AnaSetting settting { get; set; } |
| | | public IStation.CalcModel.AnaRequestBase requestBase { get; set; } |
| | | public IStation.CalcModel.AnaPrj prj { get; set; } |
| | | public bool isSubmit { get; set; } |
| | | } |
| | |
| | | [HttpPost] |
| | | public async Task<IStation.Dto.ApiResult> SavePrj([FromBody] SavePrjRequest request) |
| | | { |
| | | if (request == null || request.day == null) |
| | | if (request == null ) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day null" }; |
| | | } |
| | |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "prj null" }; |
| | | } |
| | | DateTime d; |
| | | if (!DateTime.TryParse(request.day, out d)) |
| | | { |
| | | return new IStation.Dto.ApiResult() { Code = ApiResultCode.Error, Message = "day 格式不正确" }; |
| | | } |
| | | var ret = Common.HistoryAnaPrjFileHelper.SavePrj(d, request.settting, request.requestBase, request.prj); |
| | | |
| | | var ret = Common.HistoryAnaPrjFileHelper.SavePrj(request.settting, request.requestBase, request.prj); |
| | | |
| | | //插入到数据库 |
| | | //var dal = new IStation.DAL.AnaProject(); |
| | | //dal.Insert(request.prj, request.requestBase); |
| | | |
| | | |
| | | if (request.isSubmit) |
| | | { |
| | | string error = await ZyConnectHelper.SubmitPrj(request.prj);//, (id) => { IStation.LogHelper.Info("SavePrj success id=" + id); }, (info) => { IStation.LogHelper.Info("SavePrj failse info:" + info); });//.Result; |
| | | |
| | | |
| | | |
| | | string error = await ZyProjectHelper.SubmitPrj(request.prj);//, (id) => { IStation.LogHelper.Info("SavePrj success id=" + id); }, (info) => { IStation.LogHelper.Info("SavePrj failse info:" + info); });//.Result; |
| | | |
| | | if(!string.IsNullOrEmpty(error)) |
| | | { |
| | | IStation.LogHelper.Info("Submit prj finish (fail) day:" + request.day+ ",error:" + error); |
| | | IStation.LogHelper.Info("Submit prj finish (fail) day:" + request.requestBase.StartTime + ",error:" + error); |
| | | return new IStation.Dto.ApiResult<string>(error) { Code = ApiResultCode.Error}; |
| | | } |
| | | else |
| | | { |
| | | IStation.LogHelper.Info("Submit prj finish (success) day:" + request.day); |
| | | IStation.LogHelper.Info("Submit prj finish (success) day:" + request.requestBase.StartTime); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |