初始化

This commit is contained in:
2025-11-26 11:18:26 +08:00
commit 0564b8c1f3
579 changed files with 346253 additions and 0 deletions

6
ServerHelp/App.config Normal file
View File

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

145
ServerHelp/Program.cs Normal file
View File

@@ -0,0 +1,145 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ServerHelp
{
internal class Program
{
static void Main(string[] args)
{
var a = new A { name = "ddd" };
FindDuplicate(a);
Console.WriteLine(a.name);
return;
string _path = @"F:\FEST.txt";
Thread thread = new Thread(() =>
{
FileStream fs = new FileStream(_path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter sr = new StreamWriter(fs, System.Text.Encoding.UTF8);
for (int i = 0; i < 1000; i++)
{
sr.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
sr.Flush();
Thread.Sleep(100);
}
});
Thread thread2 = new Thread(() =>
{
FileStream fs = new FileStream(_path, FileMode.Open, FileAccess.ReadWrite,FileShare.ReadWrite);
StreamReader sr = new StreamReader(fs, System.Text.Encoding.UTF8);
bool wu = false;
while (true)
{
var str = sr.ReadToEnd();
Thread.Sleep(100);
if (str.Length > 0)
Console.WriteLine(DateTime.Now + " ----- " + str.Replace(Environment.NewLine, "").Substring(0, "yyyy-MM-dd HH:mm:ss.fff".Length));
else
{
if (!wu)
{
Console.WriteLine("wu");
wu = true;
}
}
}
});
thread.Start();
thread2.Start();
return;
while (true)
{
try
{
string path = @"C:\wwwroot\App_Data\Server\Server.xcljj";
while (true)
{
var server = ServiceController.GetServices().FirstOrDefault(service => service.ServiceName == "BLV RUCS");
if (server == null)
{
Console.WriteLine("服务不存在!");
Thread.Sleep(1000);
continue;
}
if (!File.Exists(path))
{
Thread.Sleep(1000);
Console.WriteLine(server.Status.ToString());
continue;
}
int type = int.Parse(File.ReadAllText(path));
File.Delete(path);
Console.WriteLine(DateTime.Now.ToString() + (type == 1 ? "启动服务" : (type == 2 ? "重启" : "停止")) + "服务");
switch (type)
{
case 1:
if (server.Status != ServiceControllerStatus.Running)
{
server.Start();
}
break;
case 2:
if (server.Status == ServiceControllerStatus.Running)
{
server.Stop();
while (ServiceController.GetServices().FirstOrDefault(service => service.ServiceName == "BLV RUCS").Status != ServiceControllerStatus.Stopped)
{
}
}
server.Start();
break;
case 3:
server.Stop();
break;
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
Console.ReadLine();
}
public class A
{
public string name { get; set; }
}
public static void FindDuplicate(A s) { s.name = "sss"; }
public static int FindDuplicate(int[] arr)
{
int index = 0;
int res = arr[0];
int count = arr.Length - 1;
for (int i = 1; i <= count; i++)
{
if (res == arr[i])
{
break;
}
if (count == i && index != count)
{
index++;
res = arr[index];
// 下次循环是 index + 1
i = index;
}
}
return res == arr[0] ? -1 : res;
}
}
}

View File

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

View File

@@ -0,0 +1,66 @@
<?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>{90323D96-0FD3-46F8-ACBC-B4E9A9BD3464}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ServerHelp</RootNamespace>
<AssemblyName>ServerHelp</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</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>
<DocumentationFile>bin\Debug\ServerHelp.xml</DocumentationFile>
</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="System" />
<Reference Include="System.Core" />
<Reference Include="System.Diagnostics.EventLog, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.EventLog.6.0.0\lib\net461\System.Diagnostics.EventLog.dll</HintPath>
</Reference>
<Reference Include="System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
</Reference>
<Reference Include="System.ServiceProcess" />
<Reference Include="System.ServiceProcess.ServiceController, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.ServiceProcess.ServiceController.6.0.0\lib\net461\System.ServiceProcess.ServiceController.dll</HintPath>
</Reference>
<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="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="System.Diagnostics.EventLog" version="6.0.0" targetFramework="net472" />
<package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="net472" />
<package id="System.ServiceProcess.ServiceController" version="6.0.0" targetFramework="net472" />
</packages>