Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
mall.oytour.com
Commits
8baabe39
Commit
8baabe39
authored
Sep 03, 2020
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
a0e64181
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
0 additions
and
608 deletions
+0
-608
ApiMonitorLog.cs
Mall.Common/Models/ApiMonitorLog.cs
+0
-156
AssemblyModel.cs
Mall.Common/Models/AssemblyModel.cs
+0
-47
BaiDuOCRHelper.cs
Mall.Common/Plugin/BaiDuOCRHelper.cs
+0
-112
ColorHelper.cs
Mall.Common/Plugin/ColorHelper.cs
+0
-117
FileCommonHelper.cs
Mall.Common/Plugin/FileCommonHelper.cs
+0
-112
MapHelper.cs
Mall.Common/Plugin/MapHelper.cs
+0
-64
No files found.
Mall.Common/Models/ApiMonitorLog.cs
deleted
100644 → 0
View file @
a0e64181
using
System
;
using
System.Collections.Generic
;
namespace
Mall.Common.Models
{
/// <summary>
/// API日志
/// </summary>
public
class
ApiMonitorLog
{
/// <summary>
/// 请求地址
/// </summary>
public
string
Url
{
get
;
set
;
}
/// <summary>
/// 控制器名
/// </summary>
public
string
ControllerName
{
get
;
set
;
}
/// <summary>
/// 方法名
/// </summary>
public
string
ActionName
{
get
;
set
;
}
/// <summary>
/// 开始时间
/// </summary>
public
DateTime
ExecuteStartTime
{
get
;
set
;
}
/// <summary>
/// 结束时间
/// </summary>
public
DateTime
ExecuteEndTime
{
get
;
set
;
}
/// <summary>
/// 请求地址携带的参数
/// </summary>
public
string
QueryString
{
get
;
set
;
}
/// <summary>
/// 请求的Action 参数
/// </summary>
public
Dictionary
<
string
,
object
>
ActionParams
{
get
;
set
;
}
/// <summary>
/// Http请求头
/// </summary>
public
string
HttpRequestHeaders
{
get
;
set
;
}
/// <summary>
/// 请求方式
/// </summary>
public
string
HttpMethod
{
get
;
set
;
}
/// <summary>
/// 请求的IP地址
/// </summary>
public
string
IP
{
get
;
set
;
}
/// <summary>
/// 请求总时间
/// </summary>
public
double
RequestTotalSecond
{
get
{
return
(
ExecuteEndTime
-
ExecuteStartTime
).
TotalSeconds
;
}
}
/// <summary>
/// 获取监控指标日志
/// </summary>
/// <returns></returns>
public
string
GetLoginfo
()
{
string
Msg
=
@"
Action执行时间监控:
请求地址:{0}
ControllerName:{1}Controller
ActionName:{2}
开始时间:{3}
结束时间:{4}
总 时 间:{5}秒
请求地址携带参数:{6}
Action参数:{7}
Http请求头:{8}
客户端IP:{9},
HttpMethod:{10}
"
;
return
string
.
Format
(
Msg
,
Url
,
ControllerName
,
ActionName
,
ExecuteStartTime
,
ExecuteEndTime
,
RequestTotalSecond
,
QueryString
,
GetCollections
(
ActionParams
),
HttpRequestHeaders
,
IP
,
HttpMethod
);
}
/// <summary>
/// 获取监控指标日志
/// </summary>
/// <returns></returns>
public
string
GetLoginfo2
()
{
string
Msg
=
@"
HKAction执行时间监控:
开始时间:{0}
结束时间:{1}
总 时 间:{2}秒
客户端IP:{3}
Action参数:{4}
"
;
return
string
.
Format
(
Msg
,
ExecuteStartTime
,
ExecuteEndTime
,
RequestTotalSecond
,
IP
,
GetCollections
(
ActionParams
)
);
}
/// <summary>
/// 获取Action 参数
/// </summary>
/// <param name="Collections"></param>
/// <returns></returns>
public
string
GetCollections
(
Dictionary
<
string
,
object
>
Collections
)
{
string
Parameters
=
string
.
Empty
;
if
(
Collections
==
null
||
Collections
.
Count
==
0
)
{
return
Parameters
;
}
foreach
(
string
key
in
Collections
.
Keys
)
{
Parameters
+=
string
.
Format
(
"{0}={1}&"
,
key
,
Collections
[
key
]);
}
if
(!
string
.
IsNullOrWhiteSpace
(
Parameters
)
&&
Parameters
.
EndsWith
(
"&"
))
{
Parameters
=
Parameters
.
Substring
(
0
,
Parameters
.
Length
-
1
);
}
return
Parameters
;
}
/// <summary>
/// 获取IP
/// </summary>
/// <returns></returns>
//public string GetIP()
//{
// string ip = string.Empty;
// if (!string.IsNullOrEmpty(.HttpContext.Current.Request.ServerVariables["HTTP_VIA"]))
// ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]);
// if (string.IsNullOrEmpty(ip))
// ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]);
// return ip;
//}
}
}
\ No newline at end of file
Mall.Common/Models/AssemblyModel.cs
deleted
100644 → 0
View file @
a0e64181
namespace
Mall.Common.Models
{
/// <summary>
/// APICMD
/// </summary>
public
class
AssemblyModel
{
/// <summary>
/// 命令
/// </summary>
public
string
Cmd
{
get
;
set
;
}
/// <summary>
/// 是否允许匿名访问,ture是允许,默认是false
/// </summary>
public
bool
AllowAnonymous
{
get
;
set
;
}
/// <summary>
/// Dll名称
/// </summary>
public
string
DllName
{
get
;
set
;
}
/// <summary>
/// 命名空间+类名
/// </summary>
public
string
FullName
{
get
;
set
;
}
/// <summary>
/// 对应方法名称
/// </summary>
public
string
Method
{
get
;
set
;
}
/// <summary>
/// 后期拓展URL
/// </summary>
public
string
Url
{
get
;
set
;
}
/// <summary>
/// 开启验证表单重复提交
/// </summary>
public
bool
CheckFormRepeatSubmit
{
get
;
set
;
}
/// <summary>
/// 多少秒内禁止重复提交
/// </summary>
public
int
HowManySecondsForbid
{
get
;
set
;
}
}
}
\ No newline at end of file
Mall.Common/Plugin/BaiDuOCRHelper.cs
deleted
100644 → 0
View file @
a0e64181
using
Newtonsoft.Json.Linq
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Mall.Common.Plugin
{
/// <summary>
/// 用于处理百度的OCR图片识别
/// </summary>
public
class
BaiDuOCRHelper
{
private
static
readonly
string
clientId
=
"OGAhU38ib8EweXMtPVqCbkpN"
;
private
static
readonly
string
clientSecret
=
"OcqfFF5hlleWovzA6vLweykxPgwE8XF2"
;
private
static
string
accessToken
=
""
;
private
static
DateTime
lastAccessTokenTime
=
DateTime
.
Now
;
/// <summary>
/// 实例化
/// </summary>
public
BaiDuOCRHelper
()
{
if
(
accessToken
.
Equals
(
""
))
{
InitAccessToken
();
}
TimeSpan
ts
=
DateTime
.
Now
-
lastAccessTokenTime
;
if
(
ts
.
TotalDays
>
29
)
{
InitAccessToken
();
}
}
/// <summary>
/// 初始化Tocken
/// </summary>
public
void
InitAccessToken
()
{
string
url
=
"https://aip.baidubce.com/oauth/2.0/token"
;
string
body
=
$"grant_type=client_credentials&client_id=
{
clientId
}
&client_secret=
{
clientSecret
}
"
;
string
result
=
HttpHelper
.
HttpPost
(
url
,
body
,
""
);
JObject
obj
=
JObject
.
Parse
(
result
);
accessToken
=
obj
[
"access_token"
].
ToString
();
lastAccessTokenTime
=
DateTime
.
Now
;
}
/// <summary>
/// 识别文字
/// </summary>
/// <param name="sourceUrl"></param>
/// <returns></returns>
public
JToken
GetFonts
(
string
sourceUrl
)
{
if
(
accessToken
==
string
.
Empty
)
{
InitAccessToken
();
}
string
url
=
"https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token="
+
accessToken
;
string
dataUrlFormat
=
"data:image/"
;
if
(
sourceUrl
.
ToLower
().
Contains
(
"jpg"
))
{
dataUrlFormat
+=
"jpg;base64,"
;
}
else
if
(
sourceUrl
.
ToLower
().
Contains
(
"png"
))
{
dataUrlFormat
+=
"png;base64,"
;
}
else
if
(
sourceUrl
.
ToLower
().
Contains
(
"bmp"
))
{
dataUrlFormat
+=
"bmp;base64,"
;
}
else
{
dataUrlFormat
=
""
;
}
string
body
=
$"image=
{
System
.
Web
.
HttpUtility
.
UrlEncode
(
FileToBase64
(
sourceUrl
))}
&language_type=CHN_ENG"
;
string
result
=
HttpHelper
.
HttpPost
(
url
,
body
,
"application/x-www-form-urlencoded"
);
JObject
obj
=
JObject
.
Parse
(
result
);
return
obj
[
"words_result"
];
}
/// <summary>
/// 读取文件base64
/// </summary>
/// <param name="sourceUrl"></param>
/// <returns></returns>
public
static
String
FileToBase64
(
string
sourceUrl
)
{
string
strRet
=
""
;
try
{
FileStream
fs
=
new
FileStream
(
sourceUrl
,
FileMode
.
Open
);
byte
[]
bt
=
new
byte
[
fs
.
Length
];
fs
.
Read
(
bt
,
0
,
bt
.
Length
);
strRet
=
Convert
.
ToBase64String
(
bt
);
fs
.
Close
();
}
catch
(
Exception
ex
)
{
Common
.
Plugin
.
LogHelper
.
Write
(
ex
,
"FileToBase64"
);
strRet
=
null
;
}
return
strRet
;
}
}
}
Mall.Common/Plugin/ColorHelper.cs
deleted
100644 → 0
View file @
a0e64181
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Mall.Common.Plugin
{
/// <summary>
/// 颜色帮助类
/// </summary>
public
class
ColorHelper
{
/// <summary>
///颜色数组
/// </summary>
private
static
string
[]
colorArray
=
new
string
[]
{
"#FFB6C1"
,
"#DC143C"
,
"#FFF0F5"
,
"#DB7093"
,
"#FF1493"
,
"#DA70D6"
,
"#FF00FF"
,
"#800080"
,
"#4B0082"
,
"#7B68EE"
,
"#483D8B"
,
"#0000FF"
,
"#708090"
,
"#1E90FF"
,
"#00BFFF"
,
"#00FFFF"
,
"#7FFFAA"
,
"#32CD32"
,
"#006400"
,
"#EEE8AA"
,
"#8B4513"
,
"#FF4500"
};
/// <summary>
/// NOPI HSSFColor 索引数组
/// </summary>
public
static
short
[]
colorIndexArray
=
new
short
[]
{
45
,
22
,
61
,
40
,
51
,
11
,
13
,
47
,
15
,
43
,
9
,
41
,
44
,
46
,
14
,
24
,
26
,
25
,
28
,
29
,
30
,
42
,
55
,
57
,
48
,
8
,
60
,
59
,
58
,
56
,
18
,
62
,
63
,
16
,
53
,
19
,
17
,
21
,
12
,
54
,
23
,
10
,
52
,
50
,
31
,
49
,
20
,
64
};
/// <summary>
/// 颜色对象列表
/// </summary>
public
List
<
ColorModel
>
ColorList
{
get
;
set
;
}
/// <summary>
/// 构造函数
/// </summary>
public
ColorHelper
()
{
ColorList
=
new
List
<
ColorModel
>();
}
/// <summary>
/// 获取颜色
/// </summary>
/// <param name="ObjValue"></param>
/// <returns></returns>
public
short
GetColor
(
string
ObjValue
)
{
if
(
this
.
ColorList
==
null
)
{
this
.
ColorList
=
new
List
<
ColorModel
>();
}
ColorModel
model
=
new
ColorModel
();
model
=
this
.
ColorList
.
Where
(
qitem
=>
qitem
.
ObjValue
==
ObjValue
).
FirstOrDefault
();
if
(
model
==
null
)
{
model
=
new
ColorModel
()
{
ObjIndex
=
this
.
ColorList
.
Count
,
ColorShortIndex
=
GetColorStr
(),
ObjValue
=
ObjValue
};
this
.
ColorList
.
Add
(
model
);
}
return
model
.
ColorShortIndex
;
}
/// <summary>
/// 生成不重复的颜色
/// </summary>
/// <returns></returns>
public
short
GetColorStr
()
{
short
colorStr
=
colorIndexArray
[
GetRandomNumIndex
()];
while
(
ColorList
.
Where
(
qitem
=>
qitem
.
ColorShortIndex
==
colorStr
).
Count
()
>
0
)
{
colorStr
=
colorIndexArray
[
GetRandomNumIndex
()];
}
return
colorStr
;
}
/// <summary>
/// 生成随机数
/// </summary>
/// <returns></returns>
public
static
int
GetRandomNumIndex
()
{
Random
rd
=
new
Random
();
int
num
=
rd
.
Next
(
0
,
colorIndexArray
.
Length
-
1
);
return
num
;
}
/// <summary>
/// 生成随机数
/// </summary>
/// <returns></returns>
public
static
int
GetRandomNum
()
{
Random
rd
=
new
Random
();
int
num
=
rd
.
Next
(
0
,
colorArray
.
Length
-
1
);
return
num
;
}
}
/// <summary>
/// 颜色帮助实体
/// </summary>
public
class
ColorModel
{
/// <summary>
/// 对象索引
/// </summary>
public
int
ObjIndex
{
get
;
set
;
}
/// <summary>
/// 对象值
/// </summary>
public
string
ObjValue
{
get
;
set
;
}
/// <summary>
/// 颜色
/// </summary>
public
short
ColorShortIndex
{
get
;
set
;
}
}
}
Mall.Common/Plugin/FileCommonHelper.cs
deleted
100644 → 0
View file @
a0e64181
using
Mall.Common
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Mall.Common.Plugin
{
/// <summary>
/// 公共帮助类
/// </summary>
public
class
FileCommonHelper
{
/// <summary>
/// 文件转义URL
/// </summary>
public
static
string
FileCopyUrl
{
get
{
string
url
=
Mall
.
Common
.
Config
.
UploadSiteUrl
+
"/Home/FileCopy?filePath={0}&newFilePath={1}"
;
return
url
;
}
}
/// <summary>
/// 文件移动
/// </summary>
/// <param name="images">上传图片</param>
/// <param name="filePath">文件保存相对路径</param>
public
static
List
<
string
>
OssFileMove
(
List
<
string
>
images
,
string
filePath
)
{
List
<
string
>
imgList
=
new
List
<
string
>();
if
(
images
!=
null
&&
images
.
Count
()
>
0
)
{
foreach
(
var
item
in
images
)
{
string
fileFullPath
=
filePath
+
Path
.
GetFileName
(
item
);
string
url
=
string
.
Format
(
FileCopyUrl
,
Config
.
GetFilePath
(
item
),
fileFullPath
);
try
{
Common
.
Plugin
.
HttpHelper
.
HttpPost
(
url
,
""
);
}
catch
(
Exception
ex
)
{
Common
.
Plugin
.
LogHelper
.
Write
(
ex
,
"OssFileMove:URL:"
+
url
);
}
imgList
.
Add
(
fileFullPath
);
}
}
return
imgList
;
}
/// <summary>
/// 文件移动
/// </summary>
/// <param name="images">上传图片(支持相对路径和绝对路径)</param>
/// <param name="filePath">文件保存相对路径</param>
public
static
string
OssFileMove
(
string
images
,
string
filePath
)
{
List
<
string
>
imgList
=
new
List
<
string
>();
if
(!
string
.
IsNullOrWhiteSpace
(
images
))
{
string
fileFullPath
=
filePath
+
Path
.
GetFileName
(
images
);
string
url
=
string
.
Format
(
FileCopyUrl
,
Config
.
GetFilePath
(
images
),
fileFullPath
);
try
{
Common
.
Plugin
.
HttpHelper
.
HttpPost
(
url
,
""
);
}
catch
(
Exception
ex
)
{
Common
.
Plugin
.
LogHelper
.
Write
(
ex
,
"OssFileMove2:URL:"
+
url
);
}
return
fileFullPath
;
}
else
{
return
""
;
}
}
/// <summary>
/// 文件批量移动
/// </summary>
/// <param name="images">上传图片(支持相对路径和绝对路径)</param>
/// <param name="filePath">文件保存相对路径</param>
public
static
List
<
string
>
OssFileBatchMove
(
List
<
string
>
images
,
string
filePath
)
{
List
<
string
>
imgList
=
new
List
<
string
>();
if
(
images
!=
null
&&
images
.
Any
())
{
foreach
(
var
item
in
images
)
{
string
fileFullPath
=
filePath
+
Path
.
GetFileName
(
item
);
string
url
=
string
.
Format
(
FileCopyUrl
,
Config
.
GetFilePath
(
item
),
fileFullPath
);
try
{
Common
.
Plugin
.
HttpHelper
.
HttpPost
(
url
,
""
);
}
catch
(
Exception
ex
)
{
Common
.
Plugin
.
LogHelper
.
Write
(
ex
,
"OssFileBatchMove:URL:"
+
url
);
}
imgList
.
Add
(
fileFullPath
);
}
}
return
imgList
;
}
}
}
\ No newline at end of file
Mall.Common/Plugin/MapHelper.cs
deleted
100644 → 0
View file @
a0e64181
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Mall.Common.Plugin
{
/// <summary>
/// 地图帮助类
/// </summary>
public
class
MapHelper
{
//地球半径,单位米
private
const
double
EARTH_RADIUS
=
6378137
;
/// <summary>
/// 计算两点位置的距离,返回两点的距离,单位 米
/// </summary>
/// <param name="lat1">第一点纬度</param>
/// <param name="lng1">第一点经度</param>
/// <param name="lat2">第二点纬度</param>
/// <param name="lng2">第二点经度</param>
/// <returns></returns>
public
static
double
GetDistance
(
double
lat1
,
double
lng1
,
double
lat2
,
double
lng2
)
{
double
radLat1
=
Rad
(
lat1
);
double
radLng1
=
Rad
(
lng1
);
double
radLat2
=
Rad
(
lat2
);
double
radLng2
=
Rad
(
lng2
);
double
a
=
radLat1
-
radLat2
;
double
b
=
radLng1
-
radLng2
;
double
result
=
2
*
Math
.
Asin
(
Math
.
Sqrt
(
Math
.
Pow
(
Math
.
Sin
(
a
/
2
),
2
)
+
Math
.
Cos
(
radLat1
)
*
Math
.
Cos
(
radLat2
)
*
Math
.
Pow
(
Math
.
Sin
(
b
/
2
),
2
)))
*
EARTH_RADIUS
;
return
result
;
}
/// <summary>
/// 计算两个坐标点之间的距离
/// 计算两点位置的距离,返回两点的距离,单位 米
/// </summary>
/// <param name="firstPoint">第一个坐标点的(纬度,经度)</param>
/// <param name="secondPoint">第二个坐标点的(纬度,经度)</param>
/// <returns>返回两点之间的距离,单位:公里/千米</returns>
public
static
double
GetPointDistance
(
string
firstPoint
,
string
secondPoint
)
{
var
firstArray
=
firstPoint
.
Split
(
','
);
var
secondArray
=
secondPoint
.
Split
(
','
);
var
firstLatitude
=
Convert
.
ToDouble
(
firstArray
[
0
].
Trim
());
var
firstLongitude
=
Convert
.
ToDouble
(
firstArray
[
1
].
Trim
());
var
secondLatitude
=
Convert
.
ToDouble
(
secondArray
[
0
].
Trim
());
var
secondLongitude
=
Convert
.
ToDouble
(
secondArray
[
1
].
Trim
());
return
GetDistance
(
firstLatitude
,
firstLongitude
,
secondLatitude
,
secondLongitude
);
}
/// <summary>
/// 经纬度转化成弧度
/// </summary>
/// <param name="d"></param>
/// <returns></returns>
private
static
double
Rad
(
double
d
)
{
return
(
double
)
d
*
Math
.
PI
/
180d
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment