Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
JmpZbChannel
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
zxw
JmpZbChannel
Commits
12d783ae
Commit
12d783ae
authored
Mar 06, 2023
by
zxw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
3d36b9c8
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
120 行增加
和
2 行删除
+120
-2
HttpHelper.cs
LiteChannel/Commons/HttpHelper.cs
+55
-0
Win32API.cs
LiteChannel/Commons/Win32API.cs
+60
-0
LiteCaChe.cs
LiteChannel/LiteCaChe.cs
+1
-0
LiteChannel.csproj
LiteChannel/LiteChannel.csproj
+1
-0
MainWindow.xaml.cs
LiteChannel/MainWindow.xaml.cs
+3
-2
没有找到文件。
LiteChannel/Commons/HttpHelper.cs
View file @
12d783ae
...
...
@@ -126,6 +126,61 @@ namespace LiteChannel.Commons
}
/// <summary>
/// 与服务器同步时间
/// </summary>
/// <returns></returns>
public
static
bool
SetLocalTime
()
{
try
{
var
json
=
HttpGet
(
LiteCaChe
.
SysConfig
.
DomainUrl
+
Config
.
GetServerime
);
if
(
string
.
IsNullOrEmpty
(
json
))
{
Log
.
WorkLog
(
"服务器时间获取失败"
,
"获取失败"
);
return
default
;
}
else
{
var
res_data
=
JsonConvert
.
DeserializeObject
<
respone
<
DateTime
>>(
json
);
if
(
res_data
==
null
||
res_data
.
code
!=
10000
)
{
Log
.
WorkLog
(
"服务器时间获取失败"
,
"获取失败"
);
return
default
;
}
else
{
Log
.
WorkLog
(
"服务器时间获取成功"
,
"获取成功"
);
if
(
res_data
.
data
!=
null
&&
res_data
.
data
!=
default
)
{
SYSTEMTIME
_time
=
new
SYSTEMTIME
();
_time
.
FromDateTime
(
res_data
.
data
);
var
res
=
Win32API
.
SetLocalTime
(
ref
_time
);
if
(
res
)
{
Log
.
WorkLog
(
"时间同步成功"
,
"同步成功"
);
}
else
{
Log
.
WorkLog
(
$"时间同步失败,时间:
{
res_data
.
data
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
"
,
"同步失败"
);
}
return
res
;
}
else
{
return
false
;
}
}
}
}
catch
(
Exception
ex
)
{
Log
.
ErrorLog
(
ex
.
ToString
());
return
false
;
}
}
/// <summary>
/// 获取物资信息
/// </summary>
/// <returns></returns>
...
...
LiteChannel/Commons/Win32API.cs
0 → 100644
View file @
12d783ae
using
System
;
using
System.Runtime.InteropServices
;
namespace
LiteChannel.Commons
{
public
class
Win32API
{
[
DllImport
(
"Kernel32.dll"
)]
public
static
extern
bool
SetLocalTime
(
ref
SYSTEMTIME
Time
);
[
DllImport
(
"Kernel32.dll"
)]
public
static
extern
void
GetLocalTime
(
ref
SYSTEMTIME
Time
);
}
/// <summary>
///
/// </summary>
public
struct
SYSTEMTIME
{
public
ushort
wYear
;
public
ushort
wMonth
;
public
ushort
wDayOfWeek
;
public
ushort
wDay
;
public
ushort
wHour
;
public
ushort
wMinute
;
public
ushort
wSecond
;
public
ushort
wMilliseconds
;
/// <summary>
/// 从System.DateTime转换。
/// </summary>
/// <param name="time">System.DateTime类型的时间。</param>
public
void
FromDateTime
(
DateTime
time
)
{
wYear
=
(
ushort
)
time
.
Year
;
wMonth
=
(
ushort
)
time
.
Month
;
wDayOfWeek
=
(
ushort
)
time
.
DayOfWeek
;
wDay
=
(
ushort
)
time
.
Day
;
wHour
=
(
ushort
)
time
.
Hour
;
wMinute
=
(
ushort
)
time
.
Minute
;
wSecond
=
(
ushort
)
time
.
Second
;
wMilliseconds
=
(
ushort
)
time
.
Millisecond
;
}
/// <summary>
/// 转换为System.DateTime类型。
/// </summary>
/// <returns></returns>
public
DateTime
ToDateTime
()
{
return
new
DateTime
(
wYear
,
wMonth
,
wDay
,
wHour
,
wMinute
,
wSecond
,
wMilliseconds
);
}
/// <summary>
/// 静态方法。转换为System.DateTime类型。
/// </summary>
/// <param name="time">SYSTEMTIME类型的时间。</param>
/// <returns></returns>
public
static
DateTime
ToDateTime
(
SYSTEMTIME
time
)
{
return
time
.
ToDateTime
();
}
}
}
LiteChannel/LiteCaChe.cs
View file @
12d783ae
...
...
@@ -101,6 +101,7 @@ namespace LiteChannel
public
const
string
GetAllInventoryList
=
"/api/Inventory/GetAllInventoryList"
;
public
const
string
AddAndApprovalBorrowOrder
=
"/api/Borrow/AddAndApprovalBorrowOrder"
;
public
const
string
AddAndApprovalBorrowJYOrder
=
"/api/Borrow/AddAndApprovalBorrowJYOrder"
;
public
const
string
GetServerime
=
"/api/ChannelCfg/GetServerTime"
;
public
Config
()
{
...
...
LiteChannel/LiteChannel.csproj
View file @
12d783ae
...
...
@@ -126,6 +126,7 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Commons\ReaderHelper.cs" />
<Compile Include="Commons\Win32API.cs" />
<Compile Include="SelectPoliceWindow.xaml.cs">
<DependentUpon>SelectPoliceWindow.xaml</DependentUpon>
</Compile>
...
...
LiteChannel/MainWindow.xaml.cs
View file @
12d783ae
...
...
@@ -114,7 +114,8 @@ namespace LiteChannel
});
}
//设置系统时间
HttpHelper
.
SetLocalTime
();
}
private
void
MainWindowLoaded
(
object
sender
,
RoutedEventArgs
e
)
...
...
@@ -152,7 +153,7 @@ namespace LiteChannel
if
(!
IsLoaded
)
return
;
cbo_warehouse
.
ItemsSource
=
StoreList
.
Where
(
t
=>
t
.
name
.
Contains
(
e
.
Text
));
}
private
void
cbo_warehouse_SelectionChanged
(
object
sender
,
SelectionChangedEventArgs
e
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论