Commit ca6040f9 authored by solho's avatar solho

修改為 commonformat

parent e9ca3ab4
using System; using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration; using System.Configuration;
using System.Data; using System.Data;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Net;
using System.Net.Http;
using System.Web.Http; using System.Web.Http;
using System.Web.Http.Cors; using System.Web.Http.Cors;
using WebAPI.Models; using WebAPI.Models;
...@@ -14,10 +18,14 @@ namespace WebAPI.Controllers ...@@ -14,10 +18,14 @@ namespace WebAPI.Controllers
[RoutePrefix("Esn_Subitem")] [RoutePrefix("Esn_Subitem")]
public class Esn_Todos_FlowController : ApiController public class Esn_Todos_FlowController : ApiController
{ {
HttpResponseMessage result;
CommonResponseMsg response ;
MessageList_ETF Outmsg; MessageList_ETF Outmsg;
public Esn_Todos_FlowController() public Esn_Todos_FlowController()
{ {
if (Outmsg == null) Outmsg = new MessageList_ETF(); if (Outmsg == null) Outmsg = new MessageList_ETF();
result = new HttpResponseMessage(HttpStatusCode.OK);
response = new CommonResponseMsg();
} }
/// <summary> /// <summary>
...@@ -28,10 +36,14 @@ namespace WebAPI.Controllers ...@@ -28,10 +36,14 @@ namespace WebAPI.Controllers
[Route("GetFlowHis")] [Route("GetFlowHis")]
[CorsHandle] [CorsHandle]
[HttpPost] [HttpPost]
[HttpGet] //[HttpGet]
public MessageList_ETF Get_Flow_his(int Flowid) public HttpResponseMessage Get_Flow_his(ParamModel param)
{ {
if (param != null && param.Input != null && !string.IsNullOrWhiteSpace((param.Input.ToString())))
{
string input = param.Input.ToString();
String connString = ConfigurationManager.ConnectionStrings["eflow_cur"].ConnectionString; String connString = ConfigurationManager.ConnectionStrings["eflow_cur"].ConnectionString;
JObject obj_input = JObject.Parse(input.ToString());
List<Esn_Todos_FlowModel> Hislist = new List<Esn_Todos_FlowModel>(); List<Esn_Todos_FlowModel> Hislist = new List<Esn_Todos_FlowModel>();
try try
...@@ -44,27 +56,28 @@ namespace WebAPI.Controllers ...@@ -44,27 +56,28 @@ namespace WebAPI.Controllers
CommandText = @" select top 100 a.ConfirmTime CommandText = @" select top 100 a.ConfirmTime
,Case When a.ConfirmUserClass='PG' Then '程序' When a.ConfirmUserClass='PE' Then '承辦人' When a.ConfirmUserClass='Leader' Then '主管' else '其他' End as ConfirmUserClass ,Case When a.ConfirmUserClass='PG' Then '程序' When a.ConfirmUserClass='PE' Then '承辦人' When a.ConfirmUserClass='Leader' Then '主管' else '其他' End as ConfirmUserClass
,Case When a.ConfirmMethod='CF' Then '確認' When a.ConfirmMethod='RJ' Then '退回' When a.ConfirmMethod='RV' Then '撤回' else '其他' End as ConfirmMethod ,Case When a.ConfirmMethod='CF' Then '確認' When a.ConfirmMethod='RJ' Then '退回' When a.ConfirmMethod='RV' Then '撤回' else '其他' End as ConfirmMethod
,a.Create_time,a.Create_User_id,b.Step_Text as ""From"",c.Step_Text as ""To"",a.Description ,a.Create_time,d.cn_name as Create_User_Name,b.Step_Text as ""From"",c.Step_Text as ""To"",a.Description
from esn_Todos_flow_his a from esn_Todos_flow_his a
left left join esn_todos_Flow_StepType b on a.FromType_id = b.id
join esn_todos_Flow_StepType b on a.FromType_id = b.id left join esn_todos_Flow_StepType c on a.ToType_id = c.id
left left join evw_Employee d on a.Create_User_id = d.user_id
join esn_todos_Flow_StepType c on a.ToType_id = c.id
where a.Flow_id = @Flow_id where a.Flow_id = @Flow_id
order by ConfirmTime desc order by ConfirmTime desc
" "
}; };
cmd.Parameters.AddWithValue("@Flow_id", Flowid); cmd.Parameters.AddWithValue("@Flow_id", obj_input["Flowid"].ToString());
DataSet ds = SqlToDs(cmd); DataSet ds = SqlToDs(cmd);
DateTime? ConfirmTime;
foreach (DataRow dr in ds.Tables[0].Rows) foreach (DataRow dr in ds.Tables[0].Rows)
{ {
ConfirmTime = (DateTime?)dr["ConfirmTime"];
hisT = new Esn_Todos_FlowModel() hisT = new Esn_Todos_FlowModel()
{ {
ConfirmTime = (DateTime?)dr["ConfirmTime"],
ConfirmTime = ConfirmTime,
ConfirmUserClass = dr["ConfirmUserClass"].ToString(), ConfirmUserClass = dr["ConfirmUserClass"].ToString(),
ConfirmMethod = dr["ConfirmMethod"].ToString(), ConfirmMethod = dr["ConfirmMethod"].ToString(),
Create_time = (DateTime?)dr["Create_time"], Create_User_Name = dr["Create_User_Name"].ToString(),
Create_User_id = dr["Create_User_id"].ToString(),
From = dr["From"].ToString(), From = dr["From"].ToString(),
To = dr["To"].ToString(), To = dr["To"].ToString(),
Description = dr["Description"].ToString() Description = dr["Description"].ToString()
...@@ -73,16 +86,24 @@ namespace WebAPI.Controllers ...@@ -73,16 +86,24 @@ namespace WebAPI.Controllers
} }
} }
Outmsg.FlowHislist = Hislist; response.Code = "1";
Outmsg.ListCode = 0; response.Msg = Hislist;
Outmsg.Listmsg = "success"; result.Content = new StringContent(JsonConvert.SerializeObject(response), System.Text.Encoding.UTF8, "application/json");
} }
catch (Exception e) catch (Exception e)
{ {
Outmsg.ListCode = 1;
Outmsg.Listmsg = "Exception:" + e.StackTrace; response.Code = "0";
response.Msg = "Exception:" + e.StackTrace;
}
}
else
{
response.Code = "0";
response.Msg = "no input or format error";
} }
return Outmsg; result.Content = new StringContent(JsonConvert.SerializeObject(response), System.Text.Encoding.UTF8, "application/json");
return result;
} }
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment