优化自动更新、成品报工、操作日志等。。。

master
zhaoaomin 2 years ago
parent 4f9ec5720a
commit e0cb00aec5

Binary file not shown.

@ -14,7 +14,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>BF6HEC9M/jagPc3wN6LzoIFOcqz6U6GkFfq7B5nijQc=</dsig:DigestValue>
<dsig:DigestValue>ih3KkGKpdid9dU5UoQEXXgsZpplgMpRUQ8Tqz1i1/wQ=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>

@ -49,7 +49,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>iy/mPB9no8LMx3n5XtwTBu3OAI6tw4qGaQVBeTlUnhM=</dsig:DigestValue>
<dsig:DigestValue>g3bEdlk6z/YhmxjUvrtfWuYKNM4Z225YvrpzH8n8vcI=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>

@ -14,7 +14,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>BF6HEC9M/jagPc3wN6LzoIFOcqz6U6GkFfq7B5nijQc=</dsig:DigestValue>
<dsig:DigestValue>ih3KkGKpdid9dU5UoQEXXgsZpplgMpRUQ8Tqz1i1/wQ=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>

@ -49,7 +49,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>iy/mPB9no8LMx3n5XtwTBu3OAI6tw4qGaQVBeTlUnhM=</dsig:DigestValue>
<dsig:DigestValue>g3bEdlk6z/YhmxjUvrtfWuYKNM4Z225YvrpzH8n8vcI=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>

@ -27,6 +27,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPFupdate", "WPFupdate\WPFu
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XGLFinishPro", "XGLFinishPro\XGLFinishPro.csproj", "{9EF5B36A-859B-4445-9F7C-B6D796898AD6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestartApp", "RestartApp\RestartApp.csproj", "{CACAA9D6-5778-491A-A04F-261CF356DC6D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -331,6 +333,30 @@ Global
{9EF5B36A-859B-4445-9F7C-B6D796898AD6}.Release|x64.Build.0 = Release|Any CPU
{9EF5B36A-859B-4445-9F7C-B6D796898AD6}.Release|x86.ActiveCfg = Release|x86
{9EF5B36A-859B-4445-9F7C-B6D796898AD6}.Release|x86.Build.0 = Release|x86
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Debug|ARM.ActiveCfg = Debug|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Debug|ARM.Build.0 = Debug|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Debug|ARM64.Build.0 = Debug|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Debug|x64.ActiveCfg = Debug|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Debug|x64.Build.0 = Debug|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Debug|x86.ActiveCfg = Debug|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Debug|x86.Build.0 = Debug|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Release|Any CPU.Build.0 = Release|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Release|ARM.ActiveCfg = Release|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Release|ARM.Build.0 = Release|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Release|ARM64.ActiveCfg = Release|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Release|ARM64.Build.0 = Release|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Release|x64.ActiveCfg = Release|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Release|x64.Build.0 = Release|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Release|x86.ActiveCfg = Release|Any CPU
{CACAA9D6-5778-491A-A04F-261CF356DC6D}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -1,4 +1,6 @@
using CommonFunc.Tools;
using System;
using System.Data;
using System.Data.SqlClient;
namespace CommonFunc
@ -104,8 +106,17 @@ namespace CommonFunc
{
get
{
ConnectionConfig conSetting = DatabaseConfig.GetSettingsDirectory();
return CommonFunc.DESProvider.DecryptString(conSetting.MESNetClientConnectionString);
string sql = $"SELECT db_url FROM[dbo].[sys_datasource] where dept_id = '{Utils.GetAppSetting("SiteCode")}'";
DataTable dt = Utils.cloudDBHelper.getDataSet(sql).Tables[0];
if (dt == null || dt.Rows.Count <= 0 || string.IsNullOrEmpty(dt.Rows[0][0].ToString()))
{
ConnectionConfig conSetting = DatabaseConfig.GetSettingsDirectory();
return CommonFunc.DESProvider.DecryptString(conSetting.MESNetClientConnectionString);
}
else
{
return dt.Rows[0][0].ToString();
}
}
}

@ -55,6 +55,10 @@ namespace CommonFunc
/// 版本
/// </summary>
public static string End_Time { get; set; }
/// <summary>
/// 当前设备IP
/// </summary>
public static string CurrDeviceIP { get; set; }
}

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("WPFupdate")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP")]
[assembly: AssemblyProduct("WPFupdate")]
[assembly: AssemblyCopyright("Copyright © HP 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("703cdc32-203a-4b71-8b3e-306a48ab3f8b")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace WPFupdate
{
internal class WPFupdate1
{
public static void Main(string[] args)
{
Console.WriteLine(args[0]);
Thread.Sleep(1500);
// 设置要启动的应用程序名称和参数
string appName = args[0];//"XGLFinishPro.exe"; // 替换为你的目标控制台应用程序的名称
string appArguments = " ";// 替换为你的应用程序需要的参数
Console.WriteLine(appName);
// 创建进程启动信息
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = appName,
Arguments = appArguments,
RedirectStandardOutput = false, // 可以选择是否重定向标准输出
UseShellExecute = false, // 必须设置为false以便在控制台中启动应用程序
CreateNoWindow = false // 设置为true以便在后台启动应用程序
};
// 创建并启动进程
Process process = new Process
{
StartInfo = startInfo
};
process.Start();
Environment.Exit(0);
Console.ReadLine();
// 在这里添加你的应用程序的主要逻辑
}
}
}

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CACAA9D6-5778-491A-A04F-261CF356DC6D}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>RestartApp</RootNamespace>
<AssemblyName>RestartApp</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="HtmlAgilityPack, Version=1.11.54.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlAgilityPack.1.11.54\lib\Net45\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="RestartApp.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="update.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

File diff suppressed because it is too large Load Diff

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]

@ -0,0 +1,12 @@
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp\bin\Debug\RestartApp.exe.config
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp\bin\Debug\RestartApp.exe
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp\bin\Debug\RestartApp.pdb
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp\bin\Debug\HtmlAgilityPack.dll
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp\bin\Debug\HtmlAgilityPack.pdb
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp\bin\Debug\HtmlAgilityPack.xml
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp\obj\Debug\RestartApp.csproj.AssemblyReference.cache
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp\obj\Debug\RestartApp.csproj.SuggestedBindingRedirects.cache
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp\obj\Debug\RestartApp.csproj.CoreCompileInputs.cache
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp\obj\Debug\RestartApp.csproj.CopyComplete
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp\obj\Debug\RestartApp.exe
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp\obj\Debug\RestartApp.pdb

@ -0,0 +1,24 @@
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\WPFupdate\bin\Debug\WPFupdate.exe.config
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\WPFupdate\bin\Debug\WPFupdate.exe
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\WPFupdate\bin\Debug\WPFupdate.pdb
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\WPFupdate\bin\Debug\HtmlAgilityPack.dll
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\WPFupdate\bin\Debug\HtmlAgilityPack.pdb
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\WPFupdate\bin\Debug\HtmlAgilityPack.xml
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\WPFupdate\obj\Debug\WPFupdate.csproj.AssemblyReference.cache
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\WPFupdate\obj\Debug\WPFupdate.csproj.SuggestedBindingRedirects.cache
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\WPFupdate\obj\Debug\WPFupdate.csproj.CoreCompileInputs.cache
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\WPFupdate\obj\Debug\WPFupdate.csproj.CopyComplete
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\WPFupdate\obj\Debug\WPFupdate.exe
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\WPFupdate\obj\Debug\WPFupdate.pdb
E:\workspace\LanJu\client\shangjian\WPFupdate\bin\Debug\WPFupdate.exe.config
E:\workspace\LanJu\client\shangjian\WPFupdate\bin\Debug\WPFupdate.exe
E:\workspace\LanJu\client\shangjian\WPFupdate\bin\Debug\WPFupdate.pdb
E:\workspace\LanJu\client\shangjian\WPFupdate\bin\Debug\HtmlAgilityPack.dll
E:\workspace\LanJu\client\shangjian\WPFupdate\bin\Debug\HtmlAgilityPack.pdb
E:\workspace\LanJu\client\shangjian\WPFupdate\bin\Debug\HtmlAgilityPack.xml
E:\workspace\LanJu\client\shangjian\WPFupdate\obj\Debug\WPFupdate.csproj.AssemblyReference.cache
E:\workspace\LanJu\client\shangjian\WPFupdate\obj\Debug\WPFupdate.csproj.SuggestedBindingRedirects.cache
E:\workspace\LanJu\client\shangjian\WPFupdate\obj\Debug\WPFupdate.csproj.CoreCompileInputs.cache
E:\workspace\LanJu\client\shangjian\WPFupdate\obj\Debug\WPFupdate.csproj.CopyComplete
E:\workspace\LanJu\client\shangjian\WPFupdate\obj\Debug\WPFupdate.exe
E:\workspace\LanJu\client\shangjian\WPFupdate\obj\Debug\WPFupdate.pdb

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="HtmlAgilityPack" version="1.11.54" targetFramework="net48" />
</packages>

@ -0,0 +1,202 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using HtmlAgilityPack;
using System.Linq;
using System.Diagnostics;
class Update
{
public void Update1(string args)
{
string[] str = args.Split(',');
string iisServerBaseUrl = "http://192.168.202.23:8081/"; // IIS服务器基本URL
Console.WriteLine("args[0]>>"+ str[0]);
Console.WriteLine("args[1]>>" + str[1]);
string iisFolder = ""; // IIS服务器上的文件夹路径
string localFolderBase = AppDomain.CurrentDomain.BaseDirectory; // 本地文件夹的基本路径
SynchronizeFiles(iisServerBaseUrl, iisFolder, localFolderBase);
string fileName = "vsion.txt"; // 指定要操作的文件名
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); // 构建完整的文件路径
// 读取文本文件内容
string fileContent = File.ReadAllText(filePath);
// 在文件内容中进行修改
fileContent = str[0];//args; // 将 "old text" 替换为 "new text"
// 将修改后的内容写回文件
File.WriteAllText(filePath, fileContent);
Console.WriteLine("文件已修改并保存。");
// 继续运行应用程序的主要逻辑
Console.WriteLine("应用程序启动...!!!"+ args);
// 设置要启动的应用程序名称和参数
string appName = str[1];//"XGLFinishPro.exe"; // 替换为你的目标控制台应用程序的名称
string appArguments = " ";// 替换为你的应用程序需要的参数
// 创建进程启动信息
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = appName,
Arguments = appArguments,
RedirectStandardOutput = false, // 可以选择是否重定向标准输出
UseShellExecute = false, // 必须设置为false以便在控制台中启动应用程序
CreateNoWindow = false // 设置为true以便在后台启动应用程序
};
// 创建并启动进程
Process process = new Process
{
StartInfo = startInfo
};
process.Start();
Environment.Exit(0);
// 在这里添加你的应用程序的主要逻辑
Console.ReadLine();
}
public void SynchronizeFiles(string serverBaseUrl, string serverFolder, string localFolder)
{
System.Threading.Thread.Sleep(3000);
using (HttpClient client = new HttpClient())
{
try
{
HttpResponseMessage response = client.GetAsync(new Uri(serverBaseUrl + serverFolder)).Result;
response.EnsureSuccessStatusCode();
string responseContent = response.Content.ReadAsStringAsync().Result;
// 使用HtmlAgilityPack解析HTML内容
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(responseContent);
// 查找所有包含文件名和文件夹名的<a>标签
var links = doc.DocumentNode.SelectNodes("//a");
if (links != null)
{
foreach (var link in links)
{
string itemName = link.InnerText;
string itemUrl = serverBaseUrl + serverFolder + itemName;
string localPath = Path.Combine(localFolder, itemName);
if (link.InnerText.StartsWith("<dir>"))
{
// 这是一个文件夹
if (!Directory.Exists(localPath))
{
Directory.CreateDirectory(localPath);
}
// 递归处理文件夹中的内容
SynchronizeFiles(serverBaseUrl, serverFolder + itemName + "/", localPath);
}
else
{
// 这是一个文件
if (!string.Equals(itemName, "web.config", StringComparison.OrdinalIgnoreCase))
{
// 检查文件类型是否需要更新
string fileExtension = Path.GetExtension(itemName).ToLower();
if (ShouldUpdateFile(fileExtension))
{
if (File.Exists(localPath))
{
DownloadFile(itemUrl, localPath);
Console.WriteLine($"已下载并覆盖文件: {itemName}");
}
else
{
DownloadFile(itemUrl, localPath);
Console.WriteLine($"已下载文件: {itemName}");
}
}
else
{
Console.WriteLine($"不需要更新的文件类型: {fileExtension}");
}
}
}
}
}
else
{
Console.WriteLine("未找到文件列表");
}
}
catch (HttpRequestException ex)
{
Console.WriteLine($"HTTP请求失败: {ex.Message}");
}
catch (Exception ex)
{
Console.WriteLine($"发生错误: {ex.Message}");
}
}
}
public bool ShouldUpdateFile(string fileExtension)
{
// 添加需要更新的文件类型
string[] allowedExtensions = { ".exe", ".dll", ".json", ".xml" };
// 如果文件类型在允许更新的文件类型列表中,则返回 true否则返回 false
return allowedExtensions.Contains(fileExtension);
}
public void DownloadFile(string fileUrl, string localFilePath)
{
using (HttpClient client = new HttpClient())
{
try
{
HttpResponseMessage response = client.GetAsync(new Uri(fileUrl)).Result;
response.EnsureSuccessStatusCode();
using (Stream contentStream = response.Content.ReadAsStreamAsync().Result)
{
using (Stream fileStream = File.Create(localFilePath))
{
contentStream.CopyTo(fileStream);
}
}
Console.WriteLine($"已成功下载文件: {localFilePath}");
}
catch (HttpRequestException ex)
{
// 处理连接断开或其他HTTP请求错误
Console.WriteLine($"HTTP请求失败: {ex.Message}");
// 在这里可以添加重试逻辑或其他处理方式
}
catch (Exception ex)
{
Console.WriteLine($"发生错误: {ex.Message}");
}
}
}
public bool AreFilesEqual(string file1Url, string file2Path)
{
byte[] file1Content = File.ReadAllBytes(file2Path);
using (HttpClient client = new HttpClient())
{
byte[] file2Content = client.GetByteArrayAsync(file1Url).Result;
return StructuralComparisons.StructuralEqualityComparer.Equals(file1Content, file2Content);
}
}
}

@ -0,0 +1,40 @@
using System;
using System.Diagnostics;
using System.Threading;
namespace RestartApp1
{
internal class Program
{
static void Main(string[] args)
{
Thread.Sleep(5000);
// 设置要启动的应用程序名称和参数
string appName = args[0];//"XGLFinishPro.exe"; // 替换为你的目标控制台应用程序的名称
string appArguments = " ";// 替换为你的应用程序需要的参数
Console.WriteLine(appName);
// 创建进程启动信息
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = appName,
Arguments = appArguments,
RedirectStandardOutput = false, // 可以选择是否重定向标准输出
UseShellExecute = false, // 必须设置为false以便在控制台中启动应用程序
CreateNoWindow = false // 设置为true以便在后台启动应用程序
};
// 创建并启动进程
Process process = new Process
{
StartInfo = startInfo
};
process.Start();
Console.ReadLine();
Environment.Exit(0);
// 在这里添加你的应用程序的主要逻辑
}
}
}

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
</Project>

@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v5.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v5.0": {
"RestartApp1/1.0.0": {
"runtime": {
"RestartApp1.dll": {}
}
}
}
},
"libraries": {
"RestartApp1/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

@ -0,0 +1,10 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\18366\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\18366\\.nuget\\packages",
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages",
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
]
}
}

@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "net5.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "5.0.0"
}
}
}

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")]

@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("RestartApp1")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("RestartApp1")]
[assembly: System.Reflection.AssemblyTitleAttribute("RestartApp1")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// 由 MSBuild WriteCodeFragment 类生成。

@ -0,0 +1,10 @@
is_global = true
build_property.TargetFramework = net5.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = RestartApp1
build_property.ProjectDir = D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp1\

@ -0,0 +1,16 @@
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp1\bin\Debug\net5.0\RestartApp1.exe
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp1\bin\Debug\net5.0\RestartApp1.deps.json
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp1\bin\Debug\net5.0\RestartApp1.runtimeconfig.json
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp1\bin\Debug\net5.0\RestartApp1.runtimeconfig.dev.json
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp1\bin\Debug\net5.0\RestartApp1.dll
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp1\bin\Debug\net5.0\RestartApp1.pdb
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp1\obj\Debug\net5.0\RestartApp1.csproj.AssemblyReference.cache
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp1\obj\Debug\net5.0\RestartApp1.GeneratedMSBuildEditorConfig.editorconfig
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp1\obj\Debug\net5.0\RestartApp1.AssemblyInfoInputs.cache
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp1\obj\Debug\net5.0\RestartApp1.AssemblyInfo.cs
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp1\obj\Debug\net5.0\RestartApp1.csproj.CoreCompileInputs.cache
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp1\obj\Debug\net5.0\RestartApp1.dll
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp1\obj\Debug\net5.0\refint\RestartApp1.dll
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp1\obj\Debug\net5.0\RestartApp1.pdb
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp1\obj\Debug\net5.0\RestartApp1.genruntimeconfig.cache
D:\WorkSpace\KHD\Project\Lanju\Lanju-client\shangjian\RestartApp1\obj\Debug\net5.0\ref\RestartApp1.dll

@ -0,0 +1,68 @@
{
"format": 1,
"restore": {
"D:\\WorkSpace\\KHD\\Project\\Lanju\\Lanju-client\\shangjian\\RestartApp1\\RestartApp1.csproj": {}
},
"projects": {
"D:\\WorkSpace\\KHD\\Project\\Lanju\\Lanju-client\\shangjian\\RestartApp1\\RestartApp1.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "D:\\WorkSpace\\KHD\\Project\\Lanju\\Lanju-client\\shangjian\\RestartApp1\\RestartApp1.csproj",
"projectName": "RestartApp1",
"projectPath": "D:\\WorkSpace\\KHD\\Project\\Lanju\\Lanju-client\\shangjian\\RestartApp1\\RestartApp1.csproj",
"packagesPath": "C:\\Users\\18366\\.nuget\\packages\\",
"outputPath": "D:\\WorkSpace\\KHD\\Project\\Lanju\\Lanju-client\\shangjian\\RestartApp1\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages",
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
],
"configFilePaths": [
"C:\\Users\\18366\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net5.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Users\\18366\\.nuget\\packages\\kingerrobot.core\\2022.11.8\\lib\\net6.0\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net5.0": {
"targetAlias": "net5.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net5.0": {
"targetAlias": "net5.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.300\\RuntimeIdentifierGraph.json"
}
}
}
}
}

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\18366\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages;C:\Program Files\dotnet\sdk\NuGetFallbackFolder</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.2.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\18366\.nuget\packages\" />
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
<SourceRoot Include="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\" />
</ItemGroup>
</Project>

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

@ -0,0 +1,75 @@
{
"version": 3,
"targets": {
"net5.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net5.0": []
},
"packageFolders": {
"C:\\Users\\18366\\.nuget\\packages\\": {},
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {},
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "D:\\WorkSpace\\KHD\\Project\\Lanju\\Lanju-client\\shangjian\\RestartApp1\\RestartApp1.csproj",
"projectName": "RestartApp1",
"projectPath": "D:\\WorkSpace\\KHD\\Project\\Lanju\\Lanju-client\\shangjian\\RestartApp1\\RestartApp1.csproj",
"packagesPath": "C:\\Users\\18366\\.nuget\\packages\\",
"outputPath": "D:\\WorkSpace\\KHD\\Project\\Lanju\\Lanju-client\\shangjian\\RestartApp1\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages",
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
],
"configFilePaths": [
"C:\\Users\\18366\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net5.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Users\\18366\\.nuget\\packages\\kingerrobot.core\\2022.11.8\\lib\\net6.0\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net5.0": {
"targetAlias": "net5.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net5.0": {
"targetAlias": "net5.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.300\\RuntimeIdentifierGraph.json"
}
}
}
}

@ -0,0 +1,8 @@
{
"version": 2,
"dgSpecHash": "S/En5MItEphQbqA+OXsB7SKRR23houz4mu3ptCKbm/Bi9ESl9ot2IDmY2U0pQEvGCjbARCmufOMFMUdsCgnCRg==",
"success": true,
"projectFilePath": "D:\\WorkSpace\\KHD\\Project\\Lanju\\Lanju-client\\shangjian\\RestartApp1\\RestartApp1.csproj",
"expectedPackageFiles": [],
"logs": []
}

@ -54,5 +54,9 @@
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="RestartApp1.dll" />
<Content Include="RestartApp1.exe" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
</Project>

@ -11,6 +11,7 @@ namespace WPFupdate
public static void Main(string[] args)
{
Update update = new Update();
Console.WriteLine(args[0]);
update.Update1(args[0]);
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save