Commit 91a9f41b authored by charleslee's avatar charleslee

fee import

parent 2a469cb9
This diff is collapsed.
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using WebAPI.Models;
using WebAPI.Tool;
namespace WebAPI.Dal
{
public class DalBaseInfo
{
SqlServerHelper sql_server_helper = new SqlServerHelper();
public CommonResponseMsg GetDictionaryByName(string field = "*", string dictionary_name = null)
{
CommonResponseMsg result = new CommonResponseMsg();
try
{
string sql = string.Format(@"SELECT {0} FROM dbo.s_dictionary", field);
if (!string.IsNullOrEmpty(dictionary_name))
{
sql += string.Format(@" where dictionary_name = '{0}'", dictionary_name);
}
DataTable dt = sql_server_helper.GetTable(sql);
result.Code = "1";
result.Msg = dt;
}
catch (Exception err)
{
result.Code = "0";
result.Msg = err.Message;
}
return result;
}
public CommonResponseMsg GetFcCategory(string field = "*", string fc_cate_id = null)
{
CommonResponseMsg result = new CommonResponseMsg();
try
{
string sql = string.Format(@"SELECT {0} FROM dbo.i_fc_category", field);
sql += " where is_enabled = 1";
if (!string.IsNullOrEmpty(fc_cate_id))
{
sql += string.Format(@" and fc_cate_id = '{0}'", fc_cate_id);
}
DataTable dt = sql_server_helper.GetTable(sql);
result.Code = "1";
result.Msg = dt;
}
catch (Exception err)
{
result.Code = "0";
result.Msg = err.Message;
}
return result;
}
public CommonResponseMsg GetDataByTable(string field, string table_name, string primary_key = null, string id = null)
{
CommonResponseMsg result = new CommonResponseMsg();
try
{
string sql = string.Format(@"SELECT {0} FROM dbo.{1}", field, table_name);
if (!string.IsNullOrEmpty(id))
{
sql += string.Format(@" where {0} = '{1}'", primary_key, id);
}
DataTable dt = sql_server_helper.GetTable(sql);
result.Code = "1";
result.Msg = dt;
}
catch (Exception err)
{
result.Code = "0";
result.Msg = err.Message;
}
return result;
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using WebAPI.Models;
using WebAPI.Tool;
namespace WebAPI.Dal
{
public class DalCaseInfo
{
SqlServerHelper sql_server_helper = new SqlServerHelper();
public CommonResponseMsg GetCaseInfoByCaseVolume(string field = "*", string case_volume = null)
{
CommonResponseMsg result = new CommonResponseMsg();
try
{
string sql = string.Format(@"SELECT {0} FROM dbo.p_case_info", field);
sql += " where is_enabled = 1";
if (!string.IsNullOrEmpty(case_volume))
{
sql += string.Format(@" and case_volume = '{0}'", case_volume);
}
DataTable dt = sql_server_helper.GetTable(sql);
result.Code = "1";
result.Msg = dt;
}
catch (Exception err)
{
result.Code = "0";
result.Msg = err.Message;
}
return result;
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using WebAPI.Models;
using WebAPI.Tool;
namespace WebAPI.Dal
{
public class DalFee
{
SqlServerHelper sql_server_helper = new SqlServerHelper();
public CommonResponseMsg GetFeeTypeByName(string field, string case_type_id, string business_type_id, string apply_type_id, string country_id, string fee_cate_workitem, string fc_cate, string fee_type_name)
{
CommonResponseMsg result = new CommonResponseMsg();
try
{
string sql = string.Format(@"SELECT {0} FROM dbo.i_fee_type", field);
sql += " where is_enabled = 1 and is_work_item = 1";
if (!string.IsNullOrEmpty(case_type_id))
{
sql += string.Format(@" and case_type_id = '{0}'", case_type_id);
}
if (!string.IsNullOrEmpty(business_type_id))
{
sql += string.Format(@" and business_type_id = '{0}'", business_type_id);
}
if (!string.IsNullOrEmpty(apply_type_id))
{
sql += string.Format(@" and apply_type_id = '{0}'", apply_type_id);
}
if (!string.IsNullOrEmpty(country_id))
{
sql += string.Format(@" and country_id = '{0}'", country_id);
}
if (!string.IsNullOrEmpty(fee_cate_workitem))
{
sql += string.Format(@" and fee_cate_workitem = '{0}'", fee_cate_workitem);
}
if (!string.IsNullOrEmpty(fc_cate))
{
sql += string.Format(@" and fc_cate_id = '{0}'", fc_cate);
}
if (!string.IsNullOrEmpty(fee_type_name))
{
sql += string.Format(@" and (fee_type_zh_cn = '{0}' or fee_type_zh_tw = '{0}')", fee_type_name);
}
DataTable dt = sql_server_helper.GetTable(sql);
result.Code = "1";
result.Msg = dt;
}
catch (Exception err)
{
result.Code = "0";
result.Msg = err.Message;
}
return result;
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using WebAPI.Models;
using WebAPI.Tool;
namespace WebAPI.Dal
{
public class DalProcInfo
{
SqlServerHelper sql_server_helper = new SqlServerHelper();
public CommonResponseMsg GetCtrlProc(string field = "*" ,string ctrl_proc_id = null, string ctrl_proc_name = null)
{
CommonResponseMsg result = new CommonResponseMsg();
try
{
string sql = string.Format(@"SELECT {0} FROM dbo.i_ctrl_proc", field);
if(string.IsNullOrEmpty(ctrl_proc_id))
{
if(!string.IsNullOrEmpty(ctrl_proc_name))
{
sql += string.Format(@" where (ctrl_proc_zh_cn = '{0}' or ctrl_proc_zh_tw = '{0}') and is_enabled = 1", ctrl_proc_name);
}
}
else
{
sql += string.Format(@" where ctrl_proc_id = '{0}' and is_enabled = 1", ctrl_proc_id);
}
DataTable dt = sql_server_helper.GetTable(sql);
result.Code = "1";
result.Msg = dt;
}
catch(Exception err)
{
result.Code = "0";
result.Msg = err.Message;
}
return result;
}
public CommonResponseMsg GetCaseStatus(string field = "*", string case_status_id = null, string case_status_name = null)
{
CommonResponseMsg result = new CommonResponseMsg();
try
{
string sql = string.Format(@"SELECT {0} FROM dbo.i_case_status", field);
if (string.IsNullOrEmpty(case_status_id))
{
if (!string.IsNullOrEmpty(case_status_name))
{
sql += string.Format(@" where (case_status_zh_cn = '{0}' or case_status_zh_tw = '{0}')", case_status_name);
}
}
else
{
sql += string.Format(@" where case_status_id = '{0}'", case_status_id);
}
DataTable dt = sql_server_helper.GetTable(sql);
result.Code = "1";
result.Msg = dt;
}
catch (Exception err)
{
result.Code = "0";
result.Msg = err.Message;
}
return result;
}
public CommonResponseMsg GetProcInfo(string field, string proc_id = null)
{
CommonResponseMsg result = new CommonResponseMsg();
try
{
string sql = string.Format(@"SELECT {0} FROM dbo.p_proc_info ppi
LEFT JOIN dbo.p_case_info pci ON ppi.case_id = pci.case_id
LEFT JOIN dbo.i_ctrl_proc icp ON ppi.ctrl_proc_id = icp.ctrl_proc_id
LEFT JOIN dbo.i_case_status ics ON ppi.review_stage = ics.case_status_id", field);
sql += " where ppi.is_enabled = 1";
if (!string.IsNullOrEmpty(proc_id))
{
sql += string.Format(@" and proc_id = '{0}'", proc_id);
}
DataTable dt = sql_server_helper.GetTable(sql);
result.Code = "1";
result.Msg = dt;
}
catch (Exception err)
{
result.Code = "0";
result.Msg = err.Message;
}
return result;
}
public CommonResponseMsg GetProcInfoByName(string field = "*", string case_volume = null, string proc_name = null, string case_status_name = null)
{
CommonResponseMsg result = new CommonResponseMsg();
try
{
string sql = string.Format(@"SELECT {0} FROM dbo.p_proc_info ppi
LEFT JOIN dbo.p_case_info pci ON ppi.case_id = pci.case_id
LEFT JOIN dbo.i_ctrl_proc icp ON ppi.ctrl_proc_id = icp.ctrl_proc_id
LEFT JOIN dbo.i_case_status ics ON ppi.review_stage = ics.case_status_id", field);
sql += " where ppi.is_enabled = 1";
if (!string.IsNullOrEmpty(case_volume))
{
sql += string.Format(@" and case_volume = '{0}'", case_volume);
}
if (!string.IsNullOrEmpty(proc_name))
{
sql += string.Format(@" and (ctrl_proc_zh_cn = '{0}' or ctrl_proc_zh_cn = '{0}')", proc_name);
}
if (!string.IsNullOrEmpty(case_status_name))
{
sql += string.Format(@" and (case_status_zh_cn = '{0}' or case_status_zh_tw = '{0}')", case_status_name);
}
DataTable dt = sql_server_helper.GetTable(sql);
result.Code = "1";
result.Msg = dt;
}
catch (Exception err)
{
result.Code = "0";
result.Msg = err.Message;
}
return result;
}
}
}
\ No newline at end of file
......@@ -14,5 +14,12 @@ namespace WebAPI.Models
get { return this.input; }
set { this.input = value; }
}
private object file = "";
public object File
{
get { return this.file; }
set { this.file = value; }
}
}
}
\ No newline at end of file
using ExcelDataReader;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using WebAPI.Models;
namespace WebAPI.Tool
{
public class ExcelHelper
{
public CommonResponseMsg LoadFromStream(Stream stream, string file_name, bool use_column_data_type = false , bool use_header_row = true)
{
CommonResponseMsg result = new CommonResponseMsg();
DataSet ds;
string extension = Path.GetExtension(file_name);
//判斷格式套用讀取方法
IExcelDataReader reader = null;
if (extension == ".xls")
{
Console.WriteLine(" => XLS格式");
reader = ExcelReaderFactory.CreateBinaryReader(stream, new ExcelReaderConfiguration()
{
FallbackEncoding = Encoding.GetEncoding("big5")
});
}
else if (extension == ".xlsx")
{
Console.WriteLine(" => XLSX格式");
reader = ExcelReaderFactory.CreateOpenXmlReader(stream);
}
else if (extension == ".csv")
{
Console.WriteLine(" => CSV格式");
reader = ExcelReaderFactory.CreateCsvReader(stream, new ExcelReaderConfiguration()
{
FallbackEncoding = Encoding.GetEncoding("big5")
});
}
else if (extension == ".txt")
{
Console.WriteLine(" => Text(Tab Separated)格式");
reader = ExcelReaderFactory.CreateCsvReader(stream, new ExcelReaderConfiguration()
{
FallbackEncoding = Encoding.GetEncoding("big5"),
AutodetectSeparators = new char[] { '\t' }
});
}
//沒有對應產生任何格式
if (reader == null)
{
result.Code = "-1";
result.Msg = "Format Not Support";
}
using (reader)
{
ds = reader.AsDataSet(new ExcelDataSetConfiguration()
{
UseColumnDataType = use_column_data_type,
ConfigureDataTable = (tableReader) => new ExcelDataTableConfiguration()
{
//設定讀取資料時是否忽略標題
UseHeaderRow = use_header_row
}
});
result.Code = "1";
result.Msg = ds;
}
return result;
}
}
}
\ No newline at end of file
......@@ -177,9 +177,6 @@
<Reference Include="Ubiety.Dns.Core, Version=2.2.1.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>packages\MySql.Data.8.0.22\lib\net452\Ubiety.Dns.Core.dll</HintPath>
</Reference>
<Reference Include="WebActivator, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\WebActivator.1.0.0.0\lib\WebActivator.dll</HintPath>
</Reference>
<Reference Include="WebGrease">
<Private>True</Private>
<HintPath>.\packages\WebGrease.1.6.0\lib\WebGrease.dll</HintPath>
......@@ -206,12 +203,17 @@
<Compile Include="Controllers\InventorController.cs" />
<Compile Include="Controllers\SubProcInfoController.cs" />
<Compile Include="Controllers\ProcInfoController.cs" />
<Compile Include="Dal\DalBaseInfo.cs" />
<Compile Include="Dal\DalFee.cs" />
<Compile Include="Dal\DalCaseInfo.cs" />
<Compile Include="Dal\DalProcInfo.cs" />
<Compile Include="Models\Esn_Todos_FlowModel.cs" />
<Compile Include="Models\Esn_TodosModel.cs" />
<Compile Include="Models\ParamModel.cs" />
<Compile Include="Models\CommonResponseMsg.cs" />
<Compile Include="Tool\Common.cs" />
<Compile Include="Tool\CorsHandle.cs" />
<Compile Include="Tool\ExcelHelper.cs" />
<Compile Include="Tool\MySqlHelper.cs" />
<Compile Include="Tool\SqlServerHelper.cs" />
<Content Include="App_Code\HelloWorldModule.cs" />
......
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