Commit 91c64fe7 authored by charleslee's avatar charleslee

feat:fee batch

parent 104076d9
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using WebAPI.Tool;
namespace WebAPI
{
......@@ -9,6 +11,8 @@ namespace WebAPI
{
public static void Register(HttpConfiguration config)
{
LogHelper.InitLog4Net(HttpContext.Current.Server.MapPath("\\log4net.config"));
//EnableCors
config.EnableCors();
// Web API 設定和服務
......
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using WebAPI.Dal;
using WebAPI.Models;
using WebAPI.Tool;
namespace WebAPI.Controllers
{
public class AnnualInfoController : ApiController
{
public AnnualInfoController()
{
}
#region 獲取年費訊息
[Route("AnnualInfo")]
[CorsHandle]
[HttpGet]
public HttpResponseMessage GetAnnualInfo(string id)
{
HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
CommonResponseMsg response = new CommonResponseMsg();
DalProcInfo dal_proc_info = new DalProcInfo();
string cur_review_stage = "";
int cur_stage = dal_proc_info.GetAnnualStageByProc("66AE6B1D-690E-49D1-A98C-2195FDFDAA2A", "CN", ref cur_review_stage);
//AnnualInfo ai = this.GetAnnualInfo(cur_stage, case_type_id, country_id, apply_type_id);
try
{
/*if (string.IsNullOrWhiteSpace(case_type_id))
{
response.Code = "0";
response.Msg = "no case_type_id";
}
else
{
*/
}
catch (Exception e)
{
response.Code = "0";
response.Msg = e.Message;
}
result.Content = new StringContent(JsonConvert.SerializeObject(response), System.Text.Encoding.UTF8, "application/json");
return result;
}
#endregion
}
}
\ No newline at end of file
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 Dal
{
protected SqlServerHelper sql_server_helper = new SqlServerHelper();
public CommonResponseMsg update_by_dict(string type, string table_name, Dictionary<string, object> dic, string where_col_name = null)
{
CommonResponseMsg result = new CommonResponseMsg();
try
{
CommonResponseMsg result_sql = DicToSql(type, table_name, dic, where_col_name);
if (result_sql.Code == "1")
{
result.Code = "1";
result.Msg = sql_server_helper.ExecuteSqlCommand(result_sql.Msg.ToString());
}
}
catch(Exception e)
{
result.Code = "0";
result.Msg = e.Message;
}
return result;
}
public static CommonResponseMsg DicToSql(string type, string table_name, Dictionary<string, object> dic, string where_col_name = null)
{
CommonResponseMsg result = new CommonResponseMsg();
try
{
string sql = "";
List<string> list_col = new List<string>();
List<string> list_val = new List<string>();
if (type == "insert")
{
foreach (string key in dic.Keys)
{
if (dic[key] != null)
{
list_col.Add(key);
if (dic[key].GetType() == typeof(int))
{
list_val.Add(dic[key].ToString());
}
else
{
list_val.Add(string.Format("'{0}'", dic[key].ToString()));
}
}
}
sql = string.Format("insert into {0} ({1}) values({2})", table_name, string.Join(",", list_col), string.Join(",", list_val));
result.Code = "1";
result.Msg = sql;
}
else if (type == "update")
{
sql = string.Format("UPDATE {0} set ", table_name);
int i = 0;
foreach (string key in dic.Keys)
{
if (key == where_col_name || dic[key] == null)
{
continue;
}
if (i > 0)
{
sql += ", ";
}
if (dic[key].GetType() == typeof(int))
{
sql += string.Format("{0} = {1}", key, dic[key].ToString());
}
else
{
sql += string.Format("{0} = '{1}'", key, dic[key].ToString());
}
i++;
}
if (string.IsNullOrEmpty(dic[where_col_name].ToString()))
{
result.Code = "0";
result.Msg = "where col empty";
}
else
{
if (dic[where_col_name].GetType() == typeof(int))
sql += string.Format(" where {0} = {1}", where_col_name, dic[where_col_name].ToString());
else
sql += string.Format(" where {0} = '{1}'", where_col_name, dic[where_col_name].ToString());
result.Code = "1";
result.Msg = sql;
}
}
}
catch (Exception err)
{
result.Code = "0";
result.Msg = err.Message;
}
return result;
}
}
}
\ No newline at end of file
......@@ -8,10 +8,8 @@ using WebAPI.Tool;
namespace WebAPI.Dal
{
public class DalBaseInfo
{
SqlServerHelper sql_server_helper = new SqlServerHelper();
public class DalBaseInfo : Dal
{
public CommonResponseMsg GetDictionaryByName(string field = "*", string dictionary_name = null)
{
CommonResponseMsg result = new CommonResponseMsg();
......@@ -60,15 +58,33 @@ namespace WebAPI.Dal
return result;
}
public CommonResponseMsg GetDataByTable(string field, string table_name, string primary_key = null, string id = null)
public CommonResponseMsg GetDataByTable(string field, string table_name, bool? is_enabled=null, string primary_key = null, string id = null)
{
CommonResponseMsg result = new CommonResponseMsg();
try
{
string sql = string.Format(@"SELECT {0} FROM dbo.{1}", field, table_name);
Dictionary<string, object> dic_condition = new Dictionary<string, object>();
if (!string.IsNullOrEmpty(id))
{
sql += string.Format(@" where {0} = '{1}'", primary_key, id);
dic_condition[primary_key] = id;
}
if (is_enabled != null)
{
dic_condition["is_enabled"] = is_enabled;
}
int i = 0;
foreach(string key in dic_condition.Keys)
{
if (i > 0)
sql += " and ";
else
sql += " where ";
if (dic_condition[key].GetType() == typeof(int))
sql += string.Format(@"{0} = {1}", key, dic_condition[key]);
else
sql += string.Format(@"{0} = '{1}'", key, dic_condition[key]);
i++;
}
DataTable dt = sql_server_helper.GetTable(sql);
......
......@@ -8,10 +8,8 @@ using WebAPI.Tool;
namespace WebAPI.Dal
{
public class DalCaseInfo
public class DalCaseInfo : Dal
{
SqlServerHelper sql_server_helper = new SqlServerHelper();
public CommonResponseMsg GetCaseInfoByCaseVolume(string field = "*", string case_volume = null)
{
CommonResponseMsg result = new CommonResponseMsg();
......@@ -35,5 +33,29 @@ namespace WebAPI.Dal
}
return result;
}
public CommonResponseMsg GetpAgencyList(string field, string obj_id = null)
{
CommonResponseMsg result = new CommonResponseMsg();
try
{
string sql = string.Format(@"SELECT {0} FROM dbo.p_agency_list", field);
sql += " where is_enabled = 1";
if (!string.IsNullOrEmpty(obj_id))
{
sql += string.Format(@" and obj_id = '{0}'", obj_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
......@@ -8,10 +8,8 @@ using WebAPI.Tool;
namespace WebAPI.Dal
{
public class DalFee
public class DalFee : Dal
{
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();
......@@ -21,19 +19,19 @@ namespace WebAPI.Dal
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);
sql += string.Format(@" and (concat(';',case_type_id,';') like '%;{0};%' or case_type_id = 'ALL')", case_type_id);
}
if (!string.IsNullOrEmpty(business_type_id))
{
sql += string.Format(@" and business_type_id = '{0}'", business_type_id);
sql += string.Format(@" and (concat(';',business_type_id,';') like '%;{0};%' or business_type_id = 'ALL')", business_type_id);
}
if (!string.IsNullOrEmpty(apply_type_id))
{
sql += string.Format(@" and apply_type_id = '{0}'", apply_type_id);
sql += string.Format(@" and (concat(';',apply_type_id,';') like '%;{0};%' or apply_type_id = 'ALL')", apply_type_id);
}
if (!string.IsNullOrEmpty(country_id))
{
sql += string.Format(@" and country_id = '{0}'", country_id);
sql += string.Format(@" and (concat(';',country_id,';') like '%;{0};%' or country_id = 'ALL')", country_id);
}
if (!string.IsNullOrEmpty(fee_cate_workitem))
{
......@@ -59,5 +57,73 @@ namespace WebAPI.Dal
}
return result;
}
public CommonResponseMsg GetFeeTypeByRule(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) && case_type_id != "ALL")
{
sql += string.Format(@" and (concat(';',case_type_id,';') like '%;{0};%' or case_type_id = 'ALL')", case_type_id);
}
if (!string.IsNullOrEmpty(business_type_id) && business_type_id != "ALL")
{
sql += string.Format(@" and (concat(';',business_type_id,';') like '%;{0};%' or business_type_id = 'ALL')", business_type_id);
}
if (!string.IsNullOrEmpty(apply_type_id) && apply_type_id != "ALL")
{
sql += string.Format(@" and (concat(';',apply_type_id,';') like '%;{0};%' or apply_type_id = 'ALL')", apply_type_id);
}
if (!string.IsNullOrEmpty(country_id) && country_id != "ALL")
{
sql += string.Format(@" and (concat(';',country_id,';') like '%;{0};%' or country_id = 'ALL')", 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;
}
public CommonResponseMsg GetProcFeeList(string field, string proc_id, string fee_type_id)
{
CommonResponseMsg result = new CommonResponseMsg();
try
{
string sql = string.Format(@"SELECT {0} FROM dbo.p_proc_fee_list", field);
sql += string.Format(" where proc_id = '{0}' and fee_type_id = '{1}'", proc_id, fee_type_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
This diff is collapsed.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WebAPI.Models
{
public class AnnualInfo
{
public string annual_fee_id
{
get;
set;
}
public double basic_fee
{
get;
set;
}
public double basic_fee_micro
{
get;
set;
}
public double basic_fee_small
{
get;
set;
}
public string begin_type
{
get;
set;
}
public string currency_id
{
get;
set;
}
public double item_fee
{
get;
set;
}
public int legal_due_day
{
get;
set;
}
public int legal_due_month
{
get;
set;
}
public int legal_due_year
{
get;
set;
}
public int proc_stage
{
get;
set;
}
public AnnualInfo()
{
}
}
}
\ No newline at end of file
......@@ -20,8 +20,8 @@ namespace WebAPI.Models
get { return this.msg; }
set { this.msg = value; }
}
private string extraInfo="";
public string ExtraInfo
private object extraInfo ="";
public object ExtraInfo
{
get { return this.extraInfo; }
set { this.extraInfo = value; }
......
......@@ -24,7 +24,7 @@ public class CorsHandle : Attribute, ICorsPolicyProvider
objProlicy.Origins.Add("https://ipeasy.essenptl.com");
//objProlicy.Origins.Add("http://127.0.0.1");
//objProlicy.Origins.Add("http://localhost");
//objProlicy.Origins.Add("https://dev.essenptl.com");
objProlicy.Origins.Add("https://dev.essenptl.com");
//objProlicy.Origins.Add("http://ite.essenptl.com");
//objProlicy.Origins.Add("https://ite.essenptl.com");
......
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace WebAPI.Tool
{
public class LogHelper
{
private static string m_logFile;
private static Dictionary<string, log4net.ILog> m_lstLog = new Dictionary<string, log4net.ILog>();
public static void InitLog4Net(string strLog4NetConfigFile)
{
log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo(strLog4NetConfigFile));
m_logFile = strLog4NetConfigFile;
m_lstLog["info_logo"] = log4net.LogManager.GetLogger("info_logo");
m_lstLog["error_logo"] = log4net.LogManager.GetLogger("error_logo");
}
/// <summary>
/// 功能描述:寫入常規日志
/// </summary>
/// <param name="strInfoLog">strInfoLog</param>
public static void WriteInfoLog(string strInfoLog, string class_name=null)
{
if (m_lstLog["info_logo"].IsInfoEnabled)
{
var disposable = ThreadContext.Stacks["NDC"].Push(class_name);
m_lstLog["info_logo"].Info(strInfoLog);
disposable.Dispose();
}
}
/// <summary>
/// 功能描述:寫入錯誤日志
/// </summary>
/// <param name="strErrLog">strErrLog</param>
/// <param name="ex">ex</param>
public static void WriteErrorLog(string strErrLog, Exception ex = null, string class_name = null)
{
if (m_lstLog["error_logo"].IsErrorEnabled)
{
var disposable = ThreadContext.Stacks["NDC"].Push(class_name);
m_lstLog["error_logo"].Error(strErrLog, ex);
disposable.Dispose();
}
}
/// <summary>
/// 功能描述:寫入日志
/// </summary>
/// <param name="strType">日志類型(對應log4net配置文件中logger.nama)</param>
/// <param name="strLog">strLog</param>
public static void WriteByLogType(string strType, string strLog)
{
if (!m_lstLog.ContainsKey(strType))
{
//判斷是否存在節點
if (!HasLogNode(strType))
{
WriteErrorLog("log4net配置文件不存在【" + strType + "】配置");
return;
}
m_lstLog[strType] = log4net.LogManager.GetLogger(strType);
}
m_lstLog[strType].Error(strLog);
}
/// <summary>
/// 功能描述:是否存在指定的配置
/// </summary>
/// <param name="strNodeName">strNodeName</param>
/// <returns>返回值</returns>
private static bool HasLogNode(string strNodeName)
{
XmlDocument doc = new XmlDocument();
doc.Load(m_logFile);
var lstNodes = doc.SelectNodes("//configuration/log4net/logger");
foreach (XmlNode item in lstNodes)
{
if (item.Attributes["name"].Value.ToLower() == strNodeName)
return true;
}
return false;
}
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Web;
using WebAPI.Models;
......@@ -120,6 +122,7 @@ namespace WebAPI.Tool
}
catch (Exception e)
{
LogHelper.WriteErrorLog(string.Format(@"{0}", sqlCmd), e, this.GetType().Name + ":" + MethodBase.GetCurrentMethod().Name);
throw new Exception("SQL语句存在错误:" + e);
}
}
......@@ -142,6 +145,7 @@ namespace WebAPI.Tool
}
catch (Exception e)
{
LogHelper.WriteErrorLog(string.Format(@"{0}", selectSqlCommand), e, this.GetType().Name + ":" + MethodBase.GetCurrentMethod().Name);
throw new Exception("select语句有错或者数据表不存在:" + e);
}
finally
......@@ -151,6 +155,44 @@ namespace WebAPI.Tool
return dataTable;
}
public DataSet GetDataSet(string selectSqlCommand, Hashtable ht = null)
{
if (string.IsNullOrEmpty(selectSqlCommand))
throw new Exception("要执行的select语句不能为空");
OpenConnection();
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(selectSqlCommand, SqlCnt);
DataSet ds = new DataSet();
try
{
using (SqlCommand cmd = new SqlCommand(selectSqlCommand, SqlCnt))
{
if (ht != null)
{
foreach (string key in ht.Keys)
{
cmd.Parameters.AddWithValue("@" + key, ht[key].ToString());
}
}
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
da.Fill(ds);
}
}
}
catch (Exception e)
{
LogHelper.WriteErrorLog(string.Format(@"{0}", selectSqlCommand), e, this.GetType().Name + ":" + MethodBase.GetCurrentMethod().Name);
throw new Exception("select语句有错或者数据表不存在:" + e);
}
finally
{
CloseConnection();
}
return ds;
}
/// <summary>
/// 通过表名获取数据表
/// </summary>
......
......@@ -14,6 +14,7 @@
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<!--
在下列範例中,"Replace" 轉換會取代
......
......@@ -18,7 +18,7 @@
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6" />
<httpRuntime targetFramework="4.6" />
<httpRuntime targetFramework="4.6" maxRequestLength="102400" executionTimeout="6000"/>
</system.web>
<system.webServer>
<handlers>
......@@ -27,10 +27,7 @@
<remove name="TRACEVerbHandler" />
<remove name="WebDAV" />
<!--<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />-->
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*."
verb="GET,HEAD,POST,PUT,DELETE,OPTIONS"
type="System.Web.Handlers.TransferRequestHandler"
preCondition="integratedMode,runtimeVersionv4.0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,PUT,DELETE,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<modules>
<add name="HelloWorldModule" type="HelloWorldModule" />
......
......@@ -78,6 +78,9 @@
<Reference Include="K4os.Hash.xxHash, Version=1.0.6.0, Culture=neutral, PublicKeyToken=32cd54395057cec3, processorArchitecture=MSIL">
<HintPath>packages\K4os.Hash.xxHash.1.0.6\lib\net46\K4os.Hash.xxHash.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="MySql.Data, Version=8.0.22.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
......@@ -196,6 +199,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Controllers\AnnualInfoController.cs" />
<Compile Include="Controllers\Esn_Subitem\Esn_todos_SettleController.cs" />
<Compile Include="Controllers\Esn_Subitem\Esn_todosController.cs" />
<Compile Include="Controllers\DictionaryController.cs" />
......@@ -205,11 +209,13 @@
<Compile Include="Controllers\InventorController.cs" />
<Compile Include="Controllers\SubProcInfoController.cs" />
<Compile Include="Controllers\ProcInfoController.cs" />
<Compile Include="Dal\Dal.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_SettleModel.cs" />
<Compile Include="Models\AnnualInfo.cs" />
<Compile Include="Models\Esn_Todos_FlowModel.cs" />
<Compile Include="Models\Esn_TodosModel.cs" />
<Compile Include="Models\ParamModel.cs" />
......@@ -217,6 +223,7 @@
<Compile Include="Tool\Common.cs" />
<Compile Include="Tool\CorsHandle.cs" />
<Compile Include="Tool\ExcelHelper.cs" />
<Compile Include="Tool\LogHelper.cs" />
<Compile Include="Tool\MySqlHelper.cs" />
<Compile Include="Tool\SqlServerHelper.cs" />
<Content Include="App_Code\HelloWorldModule.cs" />
......@@ -295,6 +302,9 @@
<Content Include="Areas\HelpPage\Views\Help\DisplayTemplates\CollectionModelDescription.cshtml" />
<Content Include="Areas\HelpPage\Views\Help\DisplayTemplates\ApiGroup.cshtml" />
<Content Include="Areas\HelpPage\Views\Help\Api.cshtml" />
<Content Include="log4net.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="Properties\PublishProfiles\FolderProfile.pubxml" />
<None Include="Scripts\jquery-3.4.1.intellisense.js" />
<Content Include="Scripts\jquery-3.4.1.js" />
......
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<!--新增節點說明: -->
<!--1、復制一個appender節點,修改name,修改file,其他內容看情況修改-->
<!--2、復制一個logger節點,修改appender-ref為步驟2appendername,修改name(調用WriteByLogType函數,傳入的type),-->
<appender name="InfoAppender" type="log4net.Appender.RollingFileAppender">
<!--保存路徑:下面路徑項目啟動的時候自動在C盤中創建loglogError文件-->
<file value="log\\Info\\"/>
<!-- 如果想在本項目中添加路徑,那就直接去掉C:\\ 只設置log\\LogError 項目啟動中默認創建文件 -->
<appendToFile value="true"/>
<!--按照何種方式產生多個日志文件(日期[Date],文件大小[Size],混合[Composite])-->
<rollingStyle value="Composite"/>
<!--這是按日期產生文件夾-->
<datePattern value="yyyy-MM\\yyyy-MM-dd'.txt'"/>
<!--是否只寫到一個文件中-->
<staticLogFileName value="false"/>
<!--保留的log文件數量 超過此數量后 自動刪除之前的 好像只有在 按Size分割時有效 設定值value="-1"為不限文件數-->
<param name="MaxSizeRollBackups" value="100"/>
<!--每個文件的大小。只在混合方式與文件大小方式下使用。超出大小后在所有文件名后自動增加正整數重新命名,數字最大的最早寫入。可用的單位:KB|MB|GB。不要使用小數,否則會一直寫入當前日志-->
<maximumFileSize value="10240KB" />
<!-- layout 控制Appender的輸出格式,也可以是xml 一個Appender只能是一個layout-->
<layout type="log4net.Layout.PatternLayout">
<!--每條日志末尾的文字說明-->
<!--輸出格式 模板-->
<!-- <param name="ConversionPattern" value="記錄時間:%date 線程ID:[%thread] 日志級別:%-5level 記錄類:%logger
操作者ID:%property{Operator} 操作類型:%property{Action}%n 當前機器名:%property%n當前機器名及登錄用戶:%username %n
記錄位置:%location%n 消息描述:%property{Message}%n 異常:%exception%n 消息:%message%newline%n%n" />-->
<!--樣例:2008-03-26 13:42:32,111 [10] INFO Log4NetDemo.MainClass [(null)] - info-->
<!--<conversionPattern value="%newline %n記錄時間:%date %n線程ID:[%thread] %n日志級別: %-5level %n錯誤描述:%message%newline %n"/>-->
<conversionPattern value="%n==========
%n【記錄時間】%date
%n【記錄的類】%logger 屬性[%property{NDC}]
%n【內容描述】%message"/>
</layout>
</appender>
<appender name="ErrorAppender" type="log4net.Appender.RollingFileAppender">
<!--保存路徑:下面路徑項目啟動的時候自動在C盤中創建loglogError文件-->
<file value="log\\Error\\"/>
<!-- 如果想在本項目中添加路徑,那就直接去掉C:\\ 只設置log\\LogError 項目啟動中默認創建文件 -->
<appendToFile value="true"/>
<!--按照何種方式產生多個日志文件(日期[Date],文件大小[Size],混合[Composite])-->
<rollingStyle value="Composite"/>
<!--這是按日期產生文件夾-->
<datePattern value="yyyy-MM\\yyyy-MM-dd'.txt'"/>
<!--是否只寫到一個文件中-->
<staticLogFileName value="false"/>
<!--保留的log文件數量 超過此數量后 自動刪除之前的 好像只有在 按Size分割時有效 設定值value="-1"為不限文件數-->
<param name="MaxSizeRollBackups" value="100"/>
<!--每個文件的大小。只在混合方式與文件大小方式下使用。超出大小后在所有文件名后自動增加正整數重新命名,數字最大的最早寫入。可用的單位:KB|MB|GB。不要使用小數,否則會一直寫入當前日志-->
<maximumFileSize value="10240KB" />
<!-- layout 控制Appender的輸出格式,也可以是xml 一個Appender只能是一個layout-->
<layout type="log4net.Layout.PatternLayout">
<!--每條日志末尾的文字說明-->
<!--輸出格式 模板-->
<!-- <param name="ConversionPattern" value="記錄時間:%date 線程ID:[%thread] 日志級別:%-5level 記錄類:%logger
操作者ID:%property{Operator} 操作類型:%property{Action}%n 當前機器名:%property%n當前機器名及登錄用戶:%username %n
記錄位置:%location%n 消息描述:%property{Message}%n 異常:%exception%n 消息:%message%newline%n%n" />-->
<!--樣例:2008-03-26 13:42:32,111 [10] INFO Log4NetDemo.MainClass [(null)] - info-->
<!--<conversionPattern value="%newline %n記錄時間:%date %n線程ID:[%thread] %n日志級別: %-5level %n錯誤描述:%message%newline %n"/>-->
<conversionPattern value="%n==========
%n【日志級別】%-5level
%n【記錄時間】%date
%n【線程編號】[%thread]
%n【執行時間】[%r]毫秒
%n【出錯文件】%F
%n【出錯行號】%L
%n【出錯的類】%logger 屬性[%property{NDC}]
%n【錯誤描述】%message
%n【錯誤詳情】%newline"/>
</layout>
</appender>
<logger name="info_logo">
<level value="ALL" />
<appender-ref ref="InfoAppender" />
</logger>
<logger name="error_logo">
<level value="ALL" />
<appender-ref ref="ErrorAppender" />
</logger>
</log4net>
</configuration>
\ No newline at end of file
......@@ -14,6 +14,7 @@
<package id="K4os.Compression.LZ4" version="1.1.11" targetFramework="net46" />
<package id="K4os.Compression.LZ4.Streams" version="1.1.11" targetFramework="net46" />
<package id="K4os.Hash.xxHash" version="1.0.6" targetFramework="net46" />
<package id="log4net" version="2.0.12" targetFramework="net46" />
<package id="Microsoft.AspNet.Cors" version="5.2.7" targetFramework="net46" />
<package id="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net46" />
<package id="Microsoft.AspNet.Mvc.zh-Hant" version="5.2.7" targetFramework="net46" />
......
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