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,61 +36,74 @@ namespace WebAPI.Controllers ...@@ -28,61 +36,74 @@ 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)
{ {
String connString = ConfigurationManager.ConnectionStrings["eflow_cur"].ConnectionString; if (param != null && param.Input != null && !string.IsNullOrWhiteSpace((param.Input.ToString())))
List<Esn_Todos_FlowModel> Hislist = new List<Esn_Todos_FlowModel>();
try
{ {
using (SqlConnection Conn = new SqlConnection(connString)) string input = param.Input.ToString();
String connString = ConfigurationManager.ConnectionStrings["eflow_cur"].ConnectionString;
JObject obj_input = JObject.Parse(input.ToString());
List<Esn_Todos_FlowModel> Hislist = new List<Esn_Todos_FlowModel>();
try
{ {
Esn_Todos_FlowModel hisT = new Esn_Todos_FlowModel(); using (SqlConnection Conn = new SqlConnection(connString))
SqlCommand cmd = new SqlCommand("", Conn)
{ {
CommandText = @" select top 100 a.ConfirmTime Esn_Todos_FlowModel hisT = new Esn_Todos_FlowModel();
SqlCommand cmd = new SqlCommand("", Conn)
{
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);
DataSet ds = SqlToDs(cmd);
foreach (DataRow dr in ds.Tables[0].Rows)
{
hisT = new Esn_Todos_FlowModel()
{
ConfirmTime = (DateTime?)dr["ConfirmTime"],
ConfirmUserClass = dr["ConfirmUserClass"].ToString(),
ConfirmMethod = dr["ConfirmMethod"].ToString(),
Create_time = (DateTime?)dr["Create_time"],
Create_User_id = dr["Create_User_id"].ToString(),
From = dr["From"].ToString(),
To = dr["To"].ToString(),
Description = dr["Description"].ToString()
}; };
Hislist.Add(hisT); cmd.Parameters.AddWithValue("@Flow_id", obj_input["Flowid"].ToString());
DataSet ds = SqlToDs(cmd);
DateTime? ConfirmTime;
foreach (DataRow dr in ds.Tables[0].Rows)
{
ConfirmTime = (DateTime?)dr["ConfirmTime"];
hisT = new Esn_Todos_FlowModel()
{
ConfirmTime = ConfirmTime,
ConfirmUserClass = dr["ConfirmUserClass"].ToString(),
ConfirmMethod = dr["ConfirmMethod"].ToString(),
Create_User_Name = dr["Create_User_Name"].ToString(),
From = dr["From"].ToString(),
To = dr["To"].ToString(),
Description = dr["Description"].ToString()
};
Hislist.Add(hisT);
}
} }
response.Code = "1";
response.Msg = Hislist;
result.Content = new StringContent(JsonConvert.SerializeObject(response), System.Text.Encoding.UTF8, "application/json");
}
catch (Exception e)
{
response.Code = "0";
response.Msg = "Exception:" + e.StackTrace;
} }
Outmsg.FlowHislist = Hislist;
Outmsg.ListCode = 0;
Outmsg.Listmsg = "success";
} }
catch (Exception e) else
{ {
Outmsg.ListCode = 1; response.Code = "0";
Outmsg.Listmsg = "Exception:" + e.StackTrace; 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