Commit c1a47508 authored by charleslee's avatar charleslee

Merge branch 'master' of https://gitlab.essenptl.com/sol/code

parents dc91ba3c f17a2088
using Dapper;
using DapperQueryBuilder;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using WebAPI.Models;
using static WebAPI.Tool.Common;
namespace WebAPI.Controllers
{
public class EssenToCrmController : ApiController
{
HttpResponseMessage result;
CommonResponseMsg response;
String connString;
public EssenToCrmController()
{
result = new HttpResponseMessage(HttpStatusCode.OK);
response = new CommonResponseMsg();
connString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
}
/// <summary>
/// 取得 essen_request_info 資訊
/// </summary>
/// <param name="param"></param>
/// <returns></returns>
[Route("Get_essen_request_info")]
[CorsHandle]
[HttpPost]
public HttpResponseMessage Get_essen_request_info(ParamModel param)
{
if (param != null && param.Input != null && !string.IsNullOrWhiteSpace((param.Input.ToString())))
{
string input = param.Input.ToString();
try
{
JObject obj_input = JObject.Parse(input.ToString());
using (SqlConnection Conn = new SqlConnection(connString))
{
var dysql = Conn.QueryBuilder($@" select eri.request_id,eri.customer_id,iri.invoice_title, cc.customer_name from essen_request_info eri
left join i_request_info iri on eri.request_id=iri.request_id
left join c_customer cc on cc.customer_id=eri.customer_id
/**where**/ ");
if (obj_input["request_id"] != null)
{
dysql.Where( $"eri.request_id = {obj_input["request_id"].ToString()}");
}
if (obj_input["customer_id"] != null)
{
dysql.Where($" eri.customer_id = {obj_input["customer_id"].ToString()}");
}
var results = dysql.Query();
response.Msg = JsonConvert.SerializeObject(results);
response.Code = "1";
}
}
catch (Exception e)
{
response.Code = "0";
response.Msg = "Exception:" + e.StackTrace;
}
}
else
{
response.Code = "0";
response.Msg = "no input or format error";
}
result.Content = new StringContent(JsonConvert.SerializeObject(response), System.Text.Encoding.UTF8, "application/json");
return result;
}
}
}
......@@ -271,7 +271,11 @@ namespace WebAPI.Controllers
var table = ds.Tables[0];
DataRow drh = table.Rows[0];
for (int i = 0; i < drh.ItemArray.Length; i++)
{
string a = drh[i].ToString();
Console.WriteLine(ToTraditional(drh[i].ToString()));
table.Columns[i].ColumnName = ToTraditional(drh[i].ToString());
}
Dictionary<String, String> ids = new Dictionary<String, String>(), Temps = new Dictionary<String, String>();
DataRow drRow;
......
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.IO;
using System.Linq;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Net;
using System.Net.Http;
using System.Web;
using Dapper;
using Dapper.Contrib.Extensions;
using System.Web.Http;
using WebAPI.Models;
using MySql.Data.MySqlClient;
using static WebAPI.Tool.Common;
using System.Text;
namespace WebAPI.Controllers
{
[RoutePrefix("RoleInfo")]
public class RoleInfoController : ApiController
{
HttpResponseMessage result;
CommonResponseMsg response;
String connString;
public RoleInfoController()
{
result = new HttpResponseMessage(HttpStatusCode.OK);
response = new CommonResponseMsg();
connString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
}
/// <summary>
/// 取得角色資訊
/// </summary>
/// <param name="param"></param>
/// <returns></returns>
[Route("Get_s_role_info")]
[CorsHandle]
[HttpPost]
public HttpResponseMessage Get_s_role_info(ParamModel param)
{
if (param != null && param.Input != null && !string.IsNullOrWhiteSpace((param.Input.ToString())))
{
string input = param.Input.ToString();
JObject obj_input = JObject.Parse(input.ToString());
try
{
string JSONString = string.Empty;
using (SqlConnection Conn = new SqlConnection(connString))
{
string sqlstr = @"select c.* from evw_Employee a
left join s_user_role b on a.user_id = b.user_id
left join s_role_info c on b.role_id = c.role_id
where a.user_id = @user_id ";
if (obj_input["role_code"] != null)
{
sqlstr += " and role_code=@role_code";
}
var results = Conn.Query<Get_s_role_infoModel>(sqlstr
, new
{
user_id = obj_input["user_id"] == null ? "" : obj_input["user_id"].ToString(),
role_code = obj_input["role_code"] == null ? "" : obj_input["role_code"].ToString()
}
, commandType: CommandType.Text);
JSONString = JsonConvert.SerializeObject(results);
}
response.Msg = JSONString;
response.Code = "1";
}
catch (Exception e)
{
response.Code = "0";
response.Msg = "Exception:" + e.StackTrace;
}
}
else
{
response.Code = "0";
response.Msg = "no input or format error";
}
result.Content = new StringContent(JsonConvert.SerializeObject(response), System.Text.Encoding.UTF8, "application/json");
return result;
}
}
}
using System;
using Dapper.Contrib.Extensions;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WebAPI.Models
{
[Table("s_role_info")]
public class s_role_infoModel
{
public String user_id { get; set; }
public String role_id { get; set; }
public String identity_id { get; set; }
}
public class Get_s_role_infoModel
{
public String role_id { get; set; }
public String role_name { get; set; }
public String role_code { get; set; }
public String is_default { get; set; }
public String remark { get; set; }
public String is_show { get; set; }
}
}
\ No newline at end of file
......@@ -61,6 +61,12 @@
<Reference Include="Dapper.Contrib, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Dapper.Contrib.2.0.78\lib\net461\Dapper.Contrib.dll</HintPath>
</Reference>
<Reference Include="Dapper.SqlBuilder, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Dapper.SqlBuilder.2.0.78\lib\net461\Dapper.SqlBuilder.dll</HintPath>
</Reference>
<Reference Include="DapperQueryBuilder, Version=1.2.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Dapper-QueryBuilder.1.2.5\lib\net472\DapperQueryBuilder.dll</HintPath>
</Reference>
<Reference Include="DocumentFormat.OpenXml, Version=2.7.2.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL">
<HintPath>packages\DocumentFormat.OpenXml.2.7.2\lib\net46\DocumentFormat.OpenXml.dll</HintPath>
</Reference>
......@@ -204,11 +210,13 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Controllers\AnnualInfoController.cs" />
<Compile Include="Controllers\EssenToCrmController.cs" />
<Compile Include="Controllers\Esn_Subitem\Esn_todos_SettleController.cs" />
<Compile Include="Controllers\Esn_Subitem\Esn_todosController.cs" />
<Compile Include="Controllers\DictionaryController.cs" />
<Compile Include="Controllers\Esn_Subitem\Esn_Todos_FlowController.cs" />
<Compile Include="Controllers\CustomerController.cs" />
<Compile Include="Controllers\RoleInfoController.cs" />
<Compile Include="Controllers\FileController.cs" />
<Compile Include="Controllers\InventorController.cs" />
<Compile Include="Controllers\RequestController.cs" />
......@@ -220,6 +228,7 @@
<Compile Include="Dal\DalFee.cs" />
<Compile Include="Dal\DalCaseInfo.cs" />
<Compile Include="Dal\DalProcInfo.cs" />
<Compile Include="Models\RoleInfo.cs" />
<Compile Include="Models\DataObjects\PCaseInfo.cs" />
<Compile Include="Models\DataObjects\SDeptInfo.cs" />
<Compile Include="Models\DataObjects\SDeptUser.cs" />
......
......@@ -5,6 +5,8 @@
<package id="BouncyCastle" version="1.8.9" targetFramework="net48" />
<package id="Dapper" version="2.0.123" targetFramework="net48" />
<package id="Dapper.Contrib" version="2.0.78" targetFramework="net48" />
<package id="Dapper.SqlBuilder" version="2.0.78" targetFramework="net48" />
<package id="Dapper-QueryBuilder" version="1.2.5" targetFramework="net48" />
<package id="EastAsiaNumericFormatter" version="1.0.0" targetFramework="net48" />
<package id="EntityFramework" version="6.2.0" targetFramework="net48" />
<package id="EntityFramework.zh-Hant" version="6.2.0" targetFramework="net48" />
......
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