Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
Setup
Project
Project
Details
Activity
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
黄树航
Setup
Commits
36ad5bcd
Commit
36ad5bcd
authored
May 22, 2023
by
Damon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改接口
parent
e8774519
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
77 additions
and
22 deletions
+77
-22
ApiHelper.cs
Common/ApiHelper.cs
+43
-8
ProcessHelper.cs
Common/ProcessHelper.cs
+1
-1
Utils.cs
Common/Utils.cs
+20
-0
AssemblyInfo.cs
Properties/AssemblyInfo.cs
+2
-2
ProgressView.xaml.cs
View/ProgressView.xaml.cs
+11
-11
No files found.
Common/ApiHelper.cs
View file @
36ad5bcd
using
System.Data
;
using
Dqkj.Setup
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.Linq
;
using
System.Net.Http
;
using
System.Text.RegularExpressions
;
...
...
@@ -8,19 +10,52 @@ namespace Setup.Common
{
internal
class
ApiHelper
{
private
const
string
_url
=
"https://b.dqukj.com/api/client/product/list?productId=P00687"
;
//private const string _url = "https://b.dqukj.com/api/client/product/list?productId=P00687";
private
static
readonly
string
_ossRequestHost
=
"https://http-2023.oss-cn-shenzhen.aliyuncs.com/crm"
;
private
static
readonly
HttpClient
_httpClient
=
new
HttpClient
();
public
static
string
AppLauncherName
{
get
;
private
set
;
}
p
ublic
static
async
Task
<
string
>
CheckAsync
()
p
rivate
static
async
Task
<
List
<
string
>>
GetOssIps
()
{
var
ret
=
await
_httpClient
.
GetAsync
(
_url
);
ret
.
EnsureSuccessStatusCode
();
HttpResponseMessage
response
=
await
_httpClient
.
GetAsync
(
_ossRequestHost
);
var
response
=
await
ret
.
Content
.
ReadAsStringAsync
();
if
(
response
.
StatusCode
==
System
.
Net
.
HttpStatusCode
.
OK
)
{
var
data
=
await
response
.
Content
.
ReadAsStringAsync
();
if
(!
string
.
IsNullOrEmpty
(
data
))
{
return
data
.
TrimStart
(
'['
).
TrimEnd
(
']'
).
Split
(
','
).
Select
(
x
=>
x
.
Trim
(
'"'
)).
ToList
();
}
}
return
null
;
}
public
static
async
Task
<
string
>
CheckAsync
()
{
string
_tempIp
=
Utils
.
ArrayRandomItem
(
await
GetOssIps
());
if
(
string
.
IsNullOrEmpty
(
_tempIp
))
return
default
;
int
i
=
20
;
while
(
i
>
0
)
{
var
ret
=
await
_httpClient
.
GetAsync
(
$@"http://
{
_tempIp
}
/client/product/list?productId=P00687"
);
if
(
ret
.
StatusCode
==
System
.
Net
.
HttpStatusCode
.
OK
)
{
var
response
=
await
ret
.
Content
.
ReadAsStringAsync
();
var
lastFile
=
GetValue
(
response
,
"lastFile"
);
AppLauncherName
=
new
Regex
(
@"(?<=\""launcherName\"":\"")[^\""]+(?=\"")"
).
Match
(
response
)?.
Value
;
return
lastFile
;
}
else
{
_tempIp
=
Utils
.
ArrayRandomItem
(
await
GetOssIps
());
i
--;
continue
;
}
}
return
null
;
}
private
static
string
GetValue
(
string
input
,
string
key
)
{
...
...
Common/ProcessHelper.cs
View file @
36ad5bcd
...
...
@@ -28,7 +28,7 @@ namespace Dqkj.Setup.Common
{
if
(
process
.
ProcessName
.
ToLower
()
==
name
.
ToLower
())
{
MessageBox
.
Show
(
process
.
ProcessName
);
//
MessageBox.Show(process.ProcessName);
return
true
;
}
}
...
...
Common/Utils.cs
View file @
36ad5bcd
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Net
;
using
System.Text
;
using
System.Threading.Tasks
;
...
...
@@ -132,5 +134,23 @@ namespace Dqkj.Setup
return
flag
;
}
public
static
T
ArrayRandomItem
<
T
>(
List
<
T
>
sources
)
{
if
(
sources
==
null
)
return
default
;
Random
rd
=
new
Random
();
T
temp
;
for
(
int
i
=
0
;
i
<
sources
.
Count
;
i
++)
{
int
index
=
rd
.
Next
(
0
,
sources
.
Count
-
1
);
if
(
index
!=
i
)
{
temp
=
sources
[
i
];
sources
[
i
]
=
sources
[
index
];
sources
[
index
]
=
temp
;
}
}
return
sources
.
FirstOrDefault
();
}
}
}
Properties/AssemblyInfo.cs
View file @
36ad5bcd
...
...
@@ -50,5 +50,5 @@ using System.Windows;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.
0
")]
[assembly: AssemblyFileVersion("1.0.0.
0
")]
[assembly: AssemblyVersion("1.0.0.
5
")]
[assembly: AssemblyFileVersion("1.0.0.
5
")]
View/ProgressView.xaml.cs
View file @
36ad5bcd
...
...
@@ -46,7 +46,7 @@ namespace Dqkj.Setup
//#endif
defaultUpdateXmlUrl
=
await
ApiHelper
.
CheckAsync
();
executeName
=
"电趣助手
.exe"
;
executeName
=
ApiHelper
.
AppLauncherName
??
"DqBox
.exe"
;
formTitle
=
$"电趣助手-自动更新"
;
}
...
...
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