Commit 7730ec44 authored by Jason's avatar Jason

欄位新增使用者

parent e3d6c24e
......@@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using backstage.Helpers;
using backstage.Models;
using backstage.Models.Users;
using System.Net.Http;
using System.Security.Claims;
......@@ -50,7 +50,53 @@ namespace backstage.Controllers
public async Task<IActionResult> Index()
{
ResultModel result = new ResultModel();
#region department數量
var DepartmentsResponse = new DepartmentsResponse();
var url = _config["IP"] + "/merchant/list";
var httpMethod = HttpMethod.Post;
// 取得使用者的 "token" Claim 值
string token = User.FindFirstValue("token");
var parameters = new Dictionary<string, string>
{
{ "token", token }
};
var apiResult = await _callApi.CallAPI(url, parameters, httpMethod);
if (apiResult.IsSuccess)
{
DepartmentsResponse = JsonConvert.DeserializeObject<DepartmentsResponse>(apiResult.Data.ToString());
if (DepartmentsResponse.r == 0)
{
ViewBag.departmentCount = DepartmentsResponse.count;
}
}
#endregion
#region Token Vault 數量
#endregion
#region Token Vault Entry 資料數量
#endregion
#region Token Vualt Entry 本月新增資料數量
#endregion
#region Token Vualt Entry 本月修改資料數量
#endregion
......
......@@ -172,8 +172,7 @@ namespace backstage.Controllers
ViewBag.vault_id = vault_id;
ViewBag.field_id = field_id;
var DepartmentsResponse = new DepartmentsResponse();
var url = _config["IP"] + "/v2/vault/get";
var httpMethod = HttpMethod.Post;
// 取得使用者的 "token" Claim 值
......@@ -224,7 +223,7 @@ namespace backstage.Controllers
{
foreach (var u in UserResponse.Users)
{
var existUser = field.users.Where(uu => uu.uid == u.uid).Any();
var existUser = field.users.Where(uu => uu.id == u.uid).Any();
if (!existUser)
newUsers.Add(u);
......@@ -292,28 +291,282 @@ namespace backstage.Controllers
return View();
}
/// <summary>
/// 欄位添加使用者 ajax
/// </summary>
/// <param name="requestData"></param>
/// <returns></returns>
[Authorize(Policy = "AdminOnly")]
[HttpPost]
public async Task<IActionResult> AddUsers([FromBody] JsonElement requestData)
public async Task<ResultModel> AddUsers([FromBody] JsonElement requestData)
{
var result = new ResultModel();
int Merchant_id = requestData.GetProperty("Merchant_id").GetInt32();
int vault_id = requestData.GetProperty("vault_id").GetInt32();
int field_id = requestData.GetProperty("field_id").GetInt32();
int user_id = requestData.GetProperty("user_id").GetInt32();
// 構建包含參數的查詢字串
var queryString = new RouteValueDictionary {
{ "Merchant_id", Merchant_id },
{ "vault_id", vault_id },
{ "field_id", field_id },
};
{ "Merchant_id", Merchant_id },
{ "vault_id", vault_id },
{ "field_id", field_id },
};
// 確認使用者是否已經登入
if (!User.Identity.IsAuthenticated)
// 取得使用者的 "token" Claim 值
string token = User.FindFirstValue("token");
//檢查user_id是否存在
var url = _config["IP"] + "/user/list";
var httpMethod = HttpMethod.Post;
var types = new[] { "all" };
var types_data = new { inc = types };
var parameters = new Dictionary<string, string>
{
{ "token", token },
{ "types", JsonConvert.SerializeObject(types_data)},
{ "email","1"},
{ "phone","1"}
};
var apiResult = await _callApi.CallAPI(url, parameters, httpMethod);
if (apiResult.IsSuccess)
{
return RedirectToAction("Login", "User");
var UserResponse = JsonConvert.DeserializeObject<UserResponse>(apiResult.Data.ToString());
if (UserResponse.userCount > 0)
{
var existUser = UserResponse.Users.Where(u => u.uid == user_id).FirstOrDefault();
if (existUser == null)
{
result.IsSuccess = false;
result.Message = "user_id不存在";
return result;
}
}
else
{
result.IsSuccess = false;
result.Message = "user_id不存在";
return result;
}
}
else
{
result.IsSuccess = false;
result.Message = "檢查field_id失敗";
return result;
}
//檢查merchant_id是否存在
url = _config["IP"] + "/merchant/list";
httpMethod = HttpMethod.Post;
parameters = new Dictionary<string, string>
{
{ "token", token },
};
apiResult = await _callApi.CallAPI(url, parameters, httpMethod);
if (apiResult.IsSuccess)
{
var DepartmentsResponse = JsonConvert.DeserializeObject<DepartmentsResponse>(apiResult.Data.ToString());
if (DepartmentsResponse.count > 0)
{
var existDepartment = DepartmentsResponse.merchants.Where(m => m.merchant_id == Merchant_id).FirstOrDefault();
if (existDepartment == null)
{
result.IsSuccess = false;
result.Message = "merchant_id不存在";
return result;
}
}
else
{
result.IsSuccess = false;
result.Message = "merchant_id不存在";
return result;
}
}
else
{
result.IsSuccess = false;
result.Message = "檢查merchant_id失敗";
return result;
}
//檢查field_id是否存在
url = _config["IP"] + "/v2/vault/get";
httpMethod = HttpMethod.Post;
parameters = new Dictionary<string, string>
{
{ "Merchant_id", Merchant_id.ToString() },
{ "id", vault_id.ToString() },
{ "info", "FIELDS" },
};
apiResult = await _callApi.CallAPI(url, parameters, httpMethod);
if (apiResult.IsSuccess)
{
var FieldsResponse = JsonConvert.DeserializeObject<FieldsResponse>(apiResult.Data.ToString());
if (FieldsResponse.fields.Count > 0)
{
var existField = FieldsResponse.fields.Where(m => m.id == field_id).FirstOrDefault();
if (existField == null)
{
result.IsSuccess = false;
result.Message = "field_id不存在";
}
}
else
{
result.IsSuccess = false;
result.Message = "field_id不存在";
}
}
else
{
result.IsSuccess = false;
result.Message = "檢查field_id失敗";
return result;
}
//加入部門
url = _config["IP"] + "/merchant/adduser";
httpMethod = HttpMethod.Post;
var data = new[]
{
new {
userId = user_id.ToString(),
merchantId = Merchant_id.ToString()
}
};
parameters = new Dictionary<string, string>
{
{ "token", token},
{ "data", JsonConvert.SerializeObject(data)}
//{ "data", """userId"":""1"",""merchantId"":""1""")
};
apiResult = await _callApi.CallAPI(url, parameters, httpMethod);
if (!apiResult.IsSuccess)
{
var departmentResponse = JsonConvert.DeserializeObject<DepartmentsResponse>(apiResult.Data.ToString());
if (departmentResponse.r != 0)
{
result.IsSuccess = false;
result.Message = "加入部門失敗" + apiResult.Data.ToString();
return result;
}
}
//加入vault
var TokenVaultResponse = new TokenVaultResponse();
url = _config["IP"] + "/merchant/vault/access";
httpMethod = HttpMethod.Post;
parameters = new Dictionary<string, string>
{
{ "token", token},
{ "vault_id", vault_id.ToString()},
{ "access_code", "31"},
{ "merchant_id", Merchant_id.ToString()},
{ "user_id", user_id.ToString()},
};
apiResult = await _callApi.CallAPI(url, parameters, httpMethod);
if (!apiResult.IsSuccess)
{
result.IsSuccess = false;
result.Message = "加入vault失敗";
return result;
}
//加入欄位
var FieldsResponse2 = new FieldsResponse();
url = _config["IP"] + "/v2/vault";
httpMethod = HttpMethod.Post;
var addUserToField_data = new[]
{
new
{
action = "ADD",
id = user_id,
field_id = field_id,
allow_decrypt = "1",
allow_new = "1",
allow_update = "1",
allow_del = "1",
default_mask_id = "1"
}
};
parameters = new Dictionary<string, string>
{
{ "id", vault_id.ToString()},
{ "info", "USERS"},
{ "Merchant_id", Merchant_id.ToString()},
{ "data", JsonConvert.SerializeObject(addUserToField_data)},
};
apiResult = await _callApi.CallAPI(url, parameters, httpMethod);
if (apiResult.IsSuccess)
{
FieldsResponse2 = JsonConvert.DeserializeObject<FieldsResponse>(apiResult.Data.ToString());
if (FieldsResponse2.failInfo != null)
{
result.IsSuccess = false;
result.Message = "加入Fields失敗" + FieldsResponse2.m;
return result;
}
else
{
result.IsSuccess = true;
result.Message = "加入Fields成功";
return result;
}
}
else
{
result.IsSuccess = false;
result.Message = "加入Fields失敗" + apiResult.Data.ToString();
return result;
}
}
/// <summary>
/// 欄位移除'使用者 ajax
/// </summary>
/// <param name="requestData"></param>
/// <returns></returns>
[Authorize(Policy = "AdminOnly")]
[HttpPost]
public async Task<ResultModel> DelUsers([FromBody] JsonElement requestData)
{
var result = new ResultModel();
int Merchant_id = requestData.GetProperty("Merchant_id").GetInt32();
int vault_id = requestData.GetProperty("vault_id").GetInt32();
int field_id = requestData.GetProperty("field_id").GetInt32();
int user_id = requestData.GetProperty("user_id").GetInt32();
// 取得使用者的 "token" Claim 值
string token = User.FindFirstValue("token");
......@@ -340,23 +593,24 @@ namespace backstage.Controllers
var existUser = UserResponse.Users.Where(u => u.uid == user_id).FirstOrDefault();
if (existUser == null)
{
TempData["IsSuccess"] = false;
TempData["msg"] = "user_id不存在";
return RedirectToAction("ListUsers", queryString);
result.IsSuccess = false;
result.Message = "user_id不存在";
return result;
}
}
else
{
TempData["IsSuccess"] = false;
TempData["msg"] = "user_id不存在";
return RedirectToAction("ListUsers", queryString);
result.IsSuccess = false;
result.Message = "user_id不存在";
return result;
}
}
else
{
TempData["IsSuccess"] = false;
TempData["msg"] = "檢查field_id失敗";
return RedirectToAction("ListUsers", queryString);
result.IsSuccess = false;
result.Message = "檢查field_id失敗";
return result;
}
//檢查merchant_id是否存在
......@@ -377,25 +631,25 @@ namespace backstage.Controllers
var existDepartment = DepartmentsResponse.merchants.Where(m => m.merchant_id == Merchant_id).FirstOrDefault();
if (existDepartment == null)
{
TempData["IsSuccess"] = false;
TempData["msg"] = "merchant_id不存在";
return RedirectToAction("ListUsers", queryString);
result.IsSuccess = false;
result.Message = "merchant_id不存在";
return result;
}
}
else
{
TempData["IsSuccess"] = false;
TempData["msg"] = "merchant_id不存在";
return RedirectToAction("ListUsers", queryString);
result.IsSuccess = false;
result.Message = "merchant_id不存在";
return result;
}
}
else
{
TempData["IsSuccess"] = false;
TempData["msg"] = "檢查merchant_id失敗";
return RedirectToAction("ListUsers");
result.IsSuccess = false;
result.Message = "檢查merchant_id失敗";
return result;
}
//檢查field_id是否存在
......@@ -418,22 +672,22 @@ namespace backstage.Controllers
var existField = FieldsResponse.fields.Where(m => m.id == field_id).FirstOrDefault();
if (existField == null)
{
TempData["IsSuccess"] = false;
TempData["msg"] = "field_id不存在";
result.IsSuccess = false;
result.Message = "field_id不存在";
}
}
else
{
TempData["IsSuccess"] = false;
TempData["msg"] = "field_id不存在";
result.IsSuccess = false;
result.Message = "field_id不存在";
}
}
else
{
TempData["IsSuccess"] = false;
TempData["msg"] = "檢查field_id失敗";
return RedirectToAction("ListUsers", queryString);
result.IsSuccess = false;
result.Message = "檢查field_id失敗";
return result;
}
//加入部門
......@@ -461,9 +715,9 @@ namespace backstage.Controllers
var departmentResponse = JsonConvert.DeserializeObject<DepartmentsResponse>(apiResult.Data.ToString());
if (departmentResponse.r != 0)
{
TempData["IsSuccess"] = false;
TempData["msg"] = "加入部門失敗";
return RedirectToAction("ListUsers", queryString);
result.IsSuccess = false;
result.Message = "加入部門失敗" + apiResult.Data.ToString();
return result;
}
}
//加入vault
......@@ -484,9 +738,9 @@ namespace backstage.Controllers
if (!apiResult.IsSuccess)
{
TempData["IsSuccess"] = false;
TempData["msg"] = "加入vault失敗";
return RedirectToAction("ListUsers", queryString);
result.IsSuccess = false;
result.Message = "加入vault失敗";
return result;
}
//加入欄位
......@@ -494,16 +748,19 @@ namespace backstage.Controllers
var FieldsResponse2 = new FieldsResponse();
url = _config["IP"] + "/v2/vault";
httpMethod = HttpMethod.Post;
var addUserToField_data = new
var addUserToField_data = new[]
{
action = "ADD",
id = user_id,
field_id = field_id,
allow_decrypt = 1,
allow_new = 1,
allow_update = 1,
allow_del = 1,
default_mask_id = 1
new
{
action = "ADD",
id = user_id,
field_id = field_id,
allow_decrypt = "1",
allow_new = "1",
allow_update = "1",
allow_del = "1",
default_mask_id = "1"
}
};
parameters = new Dictionary<string, string>
{
......@@ -518,26 +775,26 @@ namespace backstage.Controllers
if (apiResult.IsSuccess)
{
FieldsResponse2 = JsonConvert.DeserializeObject<FieldsResponse>(apiResult.Data.ToString());
if (FieldsResponse2.r != 0)
if (FieldsResponse2.failInfo != null)
{
TempData["IsSuccess"] = false;
TempData["msg"] = "加入Fields失敗";
return RedirectToAction("ListUsers", queryString);
result.IsSuccess = false;
result.Message = "加入Fields失敗" + FieldsResponse2.m;
return result;
}
else
{
TempData["IsSuccess"] = true;
TempData["msg"] = "加入Fields成功";
return RedirectToAction("ListFields", queryString);
result.IsSuccess = true;
result.Message = "加入Fields成功";
return result;
}
}
else
{
TempData["IsSuccess"] = false;
TempData["msg"] = "加入Fields失敗";
return RedirectToAction("ListUsers", queryString);
result.IsSuccess = false;
result.Message = "加入Fields失敗" + apiResult.Data.ToString();
return result;
}
......
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="version" xml:space="preserve">
<value>version</value>
</data>
</root>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="version" xml:space="preserve">
<value>版本</value>
</data>
</root>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="version" xml:space="preserve">
<value>test</value>
</data>
</root>
\ No newline at end of file
......@@ -89,11 +89,17 @@ namespace backstage
services.AddScoped<ICallApi, CallApi>();
services.AddLocalization(options => options.ResourcesPath = "Resources");
services.Configure<RequestLocalizationOptions>(
options =>
services.AddControllersWithViews()
.AddViewLocalization(); // 添加視圖本地化支持
services.Configure<RequestLocalizationOptions>(options =>
{
var supportedCultures = new[] { new CultureInfo("en"), new CultureInfo("zh") };
options.DefaultRequestCulture = new RequestCulture(culture: "en", uiCulture: "en");
var supportedCultures = new[]
{
new CultureInfo("en"),
new CultureInfo("zh")
};
options.DefaultRequestCulture = new RequestCulture("en");
options.SupportedCultures = supportedCultures;
options.SupportedUICultures = supportedCultures;
});
......@@ -146,7 +152,7 @@ namespace backstage
app.UseAuthorization(); // 將 app.UseAuthorization() 放在 app.UseRouting() 之後
//�ҥ� cookie ��h�\��
app.UseCookiePolicy();
app.UseRequestLocalization(app.ApplicationServices.GetRequiredService<IOptions<RequestLocalizationOptions>>().Value);
app.UseEndpoints(endpoints =>
......
......@@ -137,6 +137,7 @@
<PackageReference Include="DocumentFormat.OpenXml" Version="2.10.0-beta0002" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageReference Include="Microsoft.AspNet.WebPages" Version="3.2.7" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Localization" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
......
......@@ -22,7 +22,7 @@
<h4 class="card-title">部門數量</h4>
<div class="card-content text-center">
<img src="~/images/admin-vault-department.svg" class="img-fuild">
<p class="number text-center">13</p>
<p class="number text-center">@ViewBag.departmentCount</p>
</div>
</div>
</div>
......

@using Microsoft.AspNetCore.Mvc.Localization
@inject IViewLocalizer Localizer
<!DOCTYPE html>
<html lang="en">
<head>
......@@ -140,7 +142,8 @@
<i class="mdi mdi-earth"></i>
</a>
<div class="dropdown-menu dropdown-menu-right navbar-dropdown preview-list" aria-labelledby="languageDropdown">
<a class="dropdown-item preview-item" href="/Home/ChangeLanguage?lang=en">>
<a class="dropdown-item preview-item" href="/Home/ChangeLanguage?lang=en">
<div class="preview-thumbnail">
<div class="preview-icon languageIcon">
<img src="/images/icon-lan-en-80.jpg">
......@@ -151,13 +154,14 @@
</div>
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item preview-item" href="/Home/ChangeLanguage?lang=zh">>
<a class="dropdown-item preview-item" href="/Home/ChangeLanguage?lang=zh">
<div class="preview-thumbnail">
<div class="preview-icon languageIcon">
<img src="/images/icon-lan-cn-80.jpg">
</div>
</div>
<div class="preview-item-content d-flex align-items-start flex-column justify-content-center">
<div class="preview-item-content d-flex align-items-start flex-column justify-content-center">
<h6 class="preview-subject font-weight-normal mb-1">中文</h6>
</div>
</a>
......@@ -183,7 +187,7 @@
<!-- partial:./partials/_sidebar.html -->
<nav class="sidebar sidebar-offcanvas" id="sidebar">
<div class="versionNo">
版本: v1.23
@Localizer["version"]: v1.23
</div>
<ul class="nav ">
<li class="nav-item">
......
......@@ -91,7 +91,7 @@
<td>@i.default_mask_id</td>
<td>
<a href="tokenVault_fields_users.html" class="btn btnPermission btn-sm">移除使用者</a>
<a class="btn btnPermission btn-sm">移除使用者</a>
</td>
</tr>
}
......@@ -167,10 +167,17 @@
contentType: "application/json",
data: JSON.stringify({ Merchant_id: merchant_id, vault_id: vault_id, field_id: field_id, user_id: selectedUser}),
success: function (response) {
// API 呼叫成功的處理程式碼
showAlert(response.isSuccess, response.message);
if (response.isSuccess) {
setTimeout(function () {
location.reload();
}, 2000);
}
},
error: function (xhr, status, error) {
// API 呼叫失敗的處理程式碼
showAlert(false, error.responseText);
}
});
});
......
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