Skip to content

Commit

Permalink
feat: lastest version get & deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
huiyadanli committed Mar 26, 2022
1 parent 6aeeeaa commit 38b7f54
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 17 deletions.
12 changes: 12 additions & 0 deletions Build/Build&Package.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe" ..\PasteEx.sln /t:Rebuild /p:Configuration=Release

echo 打包中...
xcopy /y "..\PasteEx\bin\Release\PasteEx.exe" PasteEx\
xcopy /s /y "..\PasteEx\bin\Release\User" PasteEx\User\
xcopy /s /y "..\PasteEx\bin\Release\Language" PasteEx\Language\
"D:/Program Files/WinRAR/WinRAR.exe" a -as -r "PasteEx.v%~1.zip" "PasteEx"

echo 打包完成,删除 PasteEx 目录

rd /s /q PasteEx
pause
2 changes: 1 addition & 1 deletion PasteEx.Deploy/FormMian.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void btnUpdateVersion_Click(object sender, EventArgs e)
Console.WriteLine(readmeFileName + "");
}

GetSurrentVersion();
GetCurrentVersion();

MessageBox.Show("Done!");

Expand Down
1 change: 1 addition & 0 deletions PasteEx/Forms/FormInfo.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 26 additions & 2 deletions PasteEx/Forms/FormSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,31 @@ private void linkLabels_LinkClicked(object sender, LinkLabelLinkClickedEventArgs
//System.Diagnostics.Process.Start(e.Link.LinkData as string);
AppInfo appInfo = e.Link.LinkData as AppInfo;
FormInfo f = FormInfo.GetInstance();
f.SetInfo(appInfo.InfoCN);
string info = null;
try
{
string i = Properties.Settings.Default.language;
if (string.IsNullOrWhiteSpace(i))
{
i = I18n.FindLanguageByCurrentThreadInfo().Index.ToString();
}
int index = Convert.ToInt32(i);
// zh-CN || zh-Hant
if (index == 1 || index == 2)
{
info = appInfo.InfoCN;
}
// en-US
else
{
info = appInfo.InfoEN;
}
}
catch (Exception ex)
{
Logger.Error(ex);
}
f.SetInfo(info);
if (f.Visible == true)
{
f.Show();
Expand Down Expand Up @@ -294,7 +318,7 @@ private async void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
int currentVersionNum = VersionToNumber(currentVersion);
if (latestVersionNum > 1000000 && currentVersionNum > 1000000)
{
if (latestVersionNum > 1)
if (latestVersionNum > currentVersionNum)
{
// have new version
labelUpdateinfo.Text = Resources.Strings.TxtNewVersion + latestVersion;
Expand Down
30 changes: 16 additions & 14 deletions PasteEx/Util/HttpUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ static HttpUtil()
/// </summary>
private static readonly string[] urlsCN = new string[]
{
"https://gitee.com/huiyadanli/PasteEx/raw/master/PasteEx.Deploy/latest.json",
"https://huiyadanli.coding.net/p/PasteEx/d/PasteEx/git/raw/master/PasteEx.Deploy/latest.json",
"https://raw.githubusercontent.com/huiyadanli/PasteEx/master/PasteEx.Deploy/latest.json"

};
private static readonly string[] urlsOther = new string[]
{
"https://raw.githubusercontent.com/huiyadanli/PasteEx/master/PasteEx.Deploy/latest.json",
"https://gitee.com/huiyadanli/PasteEx/raw/master/PasteEx.Deploy/latest.json",
"https://huiyadanli.coding.net/p/PasteEx/d/PasteEx/git/raw/master/PasteEx.Deploy/latest.json"
};

Expand Down Expand Up @@ -74,24 +72,28 @@ public static async Task<string> GetSoftInfoJsonAsync()
Init();
}

try
{
return await Client.GetStringAsync(urls[i]);
}
catch (Exception ex)
int i = 0;
while (i < urls.Length)
{
Logger.Warning("" + (i + 1) + "次请求异常:[" + ex.Message + "]\nURL:" + urls[i]);
i++;
if (i >= urls.Length)
try
{
i = 0;
return null;
string json = await Client.GetStringAsync(urls[i]);
if (!string.IsNullOrEmpty(json) && json.Contains("Version"))
{
return json;
}
else
{
Logger.Warning("" + (i + 1) + "次请求获得的数据并非期望数据\nURL:" + urls[i]);
}
}
else
catch (Exception ex)
{
return await GetSoftInfoJsonAsync();
Logger.Warning("" + (i + 1) + "次请求异常:[" + ex.Message + "]\nURL:" + urls[i]);
}
i++;
}
return null;
}
}
}

0 comments on commit 38b7f54

Please sign in to comment.