初始化项目

This commit is contained in:
2025-11-20 09:50:21 +08:00
commit 94b24e1a5d
4209 changed files with 1570805 additions and 0 deletions

View File

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

108
UH_CENTER/UH_CENTER.csproj Normal file
View File

@@ -0,0 +1,108 @@
<?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>{D0F758E7-F93D-4AC6-950F-7A34522116F7}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UH_CENTER</RootNamespace>
<AssemblyName>UH_CENTER</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="BouncyCastle.Crypto, Version=1.8.5.0, Culture=neutral, PublicKeyToken=0e99375e54769942">
<HintPath>..\packages\BouncyCastle.1.8.5\lib\BouncyCastle.Crypto.dll</HintPath>
</Reference>
<Reference Include="Google.Protobuf, Version=3.19.4.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.19.4\lib\net45\Google.Protobuf.dll</HintPath>
</Reference>
<Reference Include="K4os.Compression.LZ4, Version=1.2.6.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
<HintPath>..\packages\K4os.Compression.LZ4.1.2.6\lib\net46\K4os.Compression.LZ4.dll</HintPath>
</Reference>
<Reference Include="K4os.Compression.LZ4.Streams, Version=1.2.6.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
<HintPath>..\packages\K4os.Compression.LZ4.Streams.1.2.6\lib\net46\K4os.Compression.LZ4.Streams.dll</HintPath>
</Reference>
<Reference Include="K4os.Hash.xxHash, Version=1.0.6.0, Culture=neutral, PublicKeyToken=32cd54395057cec3, processorArchitecture=MSIL">
<HintPath>..\packages\K4os.Hash.xxHash.1.0.6\lib\net46\K4os.Hash.xxHash.dll</HintPath>
</Reference>
<Reference Include="MySql.Data, Version=8.0.29.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>..\packages\MySql.Data.8.0.29\lib\net452\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="SqlSugar, Version=5.0.9.2, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SqlSugar.5.0.9.2\lib\SqlSugar.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.Management" />
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Transactions" />
<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" />
<Reference Include="Ubiety.Dns.Core, Version=2.2.1.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>..\packages\MySql.Data.8.0.29\lib\net452\Ubiety.Dns.Core.dll</HintPath>
</Reference>
<Reference Include="ZstdNet, Version=1.4.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>..\packages\MySql.Data.8.0.29\lib\net452\ZstdNet.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="UH_CENTER_Help.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Models\Models.csproj">
<Project>{8C60AE21-34FD-4C98-BC52-68CEEF63B5E1}</Project>
<Name>Models</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

303
UH_CENTER/UH_CENTER_Help.cs Normal file
View File

@@ -0,0 +1,303 @@
using Models;
using Models.ModelItems;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Models.View;
using Models.ApiModei;
using System.Security.Cryptography;
using Org.BouncyCastle.Ocsp;
namespace UH_CENTER
{
public class UH_CENTER_Help
{
/// <summary>
/// 查询酒店权限 数量
/// </summary>
/// <param name="u">用户</param>
/// <returns></returns>
public static List<QxIfo> Sel_Hotel(View_UserInfo u)
{
List<QxIfo> res = new List<QxIfo>();
try
{
if (!string.IsNullOrEmpty(u.Hotel_Data))
res = JsonConvert.DeserializeObject<List<QxIfo>>(u.Hotel_Data);
else
throw new Exception("u.Hotel_Data is null");
}
catch (Exception EX)
{
return Sel_Hotel(u.Id, true);
}
return res;
}
public static void Sel_Hotel_All()
{
//0. 取到所有用户
List<UserInfo> usrlist = SqlSugarBase.Db.Queryable<UserInfo>().With(SqlSugar.SqlWith.NoLock).ToList();
//获取用户权限
List<UserAuthoes> usrAuth = SqlSugarBase.Db.Queryable<UserAuthoes>().With(SqlSugar.SqlWith.NoLock).ToList();
//获取酒店
List<Hotels> htlist = SqlSugarBase.Db.Queryable<Hotels>().With(SqlSugar.SqlWith.NoLock).ToList();
//获取酒店组
List<HotelGroups> htgrplist = SqlSugarBase.Db.Queryable<HotelGroups>().With(SqlSugar.SqlWith.NoLock).ToList();
foreach (var usr in usrlist)
{
List<QxIfo> res = new List<QxIfo>();
//1. 根据不同类型客户,不同处理
if (usr.IsImport == 0)
{
res = usrAuth
.Where(X => X.UserId == usr.Id)
.Select(x => x.HotelId)
.ToArray() //只要酒店ID形成数组, 一个用户可能有多个酒店ID
.GroupBy(X => X) //酒店ID去重复
.Select(X => new QxIfo()
{ //酒店ID 用户ID 同一个酒店给同一个用户赋予权限的方法次数
id = X.Key,
uid = usr.Id,
sum = X.Count()
})
.ToList();
}
else
{
if (usr.HotelGroupID > 0)
{
int V = (int)usr.HotelGroupID;
//返回本酒店组和本酒店组下面的所有酒店,酒店组
IEnumerable<int> hs;
if(V == 1)//超级权限,所有酒店的权限。
{
hs = htlist.Select(x => x.Id);
}
else
{
hs = getHotels(V, htlist, htgrplist).Select(x => x.Id);
}
//这个用户有权限的酒店的统计信息, 这个时候授权表还是老数据
var data = usrAuth
.Where(X => X.UserId == usr.Id && hs.Contains(X.HotelId))
.Select(x => x.HotelId)
.ToArray()
.GroupBy(x => x)
.Select(x => new { x.Key, sum = x.Count() })
.ToArray();
//返回基于酒店的统计信息, 这个里面的信息应该比老数据多。
foreach (var item in hs)
{
var s = data.FirstOrDefault(x => x.Key == item);
res.Add(new QxIfo() { id = item, uid = usr.Id, sum = s == null ? 0 : s.sum });
}
}
else
{
if (usr.HotelID > 0)//用户的酒店ID
{
var count = usrAuth
.Where(X => X.UserId == usr.Id && X.HotelId == usr.HotelID)//用户有多种权限的酒店,并且限制为用户表里面的唯一酒店
.Count();
res.Add(new QxIfo() { id = (int)usr.HotelID, uid = usr.Id, sum = count });
}
}
}
usr.Hotel_Data = JsonConvert.SerializeObject(res);
}
//9. 更新所有用户的Hotel_Data数据
var result = SqlSugarBase.Db.Updateable(usrlist).UpdateColumns(it => new { it.Hotel_Data }).ExecuteCommand();
}
/// <summary>
/// 查询酒店权限 数量
/// </summary>
/// <param name="uid">用户id </param>
/// <param name="isup">是否统计查询 更新到数据库 </param>
/// <returns></returns>
public static List<QxIfo> Sel_Hotel(int uid,bool isup = false)
{
List<QxIfo> res = new List<QxIfo>();
List<Hotels> htlist = SqlSugarBase.Db.Queryable<Hotels>().With(SqlSugar.SqlWith.NoLock).ToList();
List<HotelGroups> htgrplist = SqlSugarBase.Db.Queryable<HotelGroups>().With(SqlSugar.SqlWith.NoLock).ToList();
//0. 取到这个用户的用户信息
var uinfo = SqlSugarBase.Db.Queryable<UserInfo>().With(SqlSugar.SqlWith.NoLock)
.Where(X => X.Id == uid)
.Select(x => new {x.IsImport,x.HotelGroupID,x.HotelID,x.Hotel_Data })
.First();
if (uinfo == null)
return res;
// 直接取表字段
// 同步的时候不会进这个 isup = true
if (!isup)
{
try
{
res = JsonConvert.DeserializeObject<List<QxIfo>>(uinfo.Hotel_Data);
}
catch (Exception)
{
return Sel_Hotel(uid, true);
}
return res;
}
//1. 查该用户可用拥有的酒店列表,并返回该用户基于酒店的统计信息
//1.1. 是管理员手工录入用户?那么
// 1.1.1. 查用户权限表得到这个用户被授予的酒店id列表并去重合并。
//1.2. 是真实用户自动生成用户?那么
// 1.1.1. 优先查酒店组,查用户拥有酒店组
// 1.1.1. 否则,查用户拥有酒店
if (uinfo.IsImport == 0)
{
res = SqlSugarBase.Db.Queryable<UserAuthoes>()
.Where(X => X.Id == uid) //??? 应该是X=>X.UserId == uid
.Select(x=>x.HotelId)
.ToArray() //只要酒店ID形成数组, 一个用户可能有多个酒店ID
.GroupBy(X=>X) //酒店ID去重复
.Select(X=>new QxIfo() { //酒店ID 用户ID 同一个酒店给同一个用户赋予权限的方法次数
id = X.Key,
uid = uid,
sum = X.Count()
})
.ToList();
}
else
{
if(uinfo.HotelGroupID > 0)
{
int V = (int)uinfo.HotelGroupID;
//返回本酒店组和本酒店组下面的所有酒店,酒店组
var hs = getHotels(V,htlist, htgrplist).Select(x=>x.Id);
//这个用户有权限的酒店的统计信息
var data = SqlSugarBase.Db.Queryable<UserAuthoes>()
.Where(X => X.UserId == uid && hs.Contains(X.HotelId))
.Select(x=>x.HotelId)
.ToArray()
.GroupBy(x=>x)
.Select(x=>new {x.Key,sum = x.Count() })
.ToArray();
//返回基于酒店的统计信息
foreach (var item in hs)
{
var s = data.FirstOrDefault(x => x.Key == item);
res.Add(new QxIfo() {id = item,uid = uid, sum = s==null?0:s.sum });
}
}
else
{
if (uinfo.HotelID > 0)//用户的酒店ID
{
var count = SqlSugarBase.Db.Queryable<UserAuthoes>()
.Where(X => X.Id == uid && X.HotelId == uinfo.HotelID)//用户有多种权限的酒店,并且限制为用户表里面的唯一酒店
.Count();
res.Add(new QxIfo() { id = (int)uinfo.HotelID, uid = uid, sum = count });
}
}
}
//更新统计信息到每个用户记录里面。
UserInfo U = new UserInfo() { Id = uid, Hotel_Data = JsonConvert.SerializeObject(res) };
var result = SqlSugarBase.Db.Updateable(U).UpdateColumns(it => new { it.Hotel_Data }).ExecuteCommand();
return res;
}
//前置条件是jsondata刚刚更新过不用再重新计算了。
//同上面函数逻辑,但是不每条更新数据库,而是收集起来,返回给上级函数。
//上级函数可以批量更新数据库。
public static Dictionary<int, List<QxIfo>> Sel_HotelOptimized(List<View_UserInfo> usrlist)
{
Dictionary<int, List<QxIfo>> usrResult = new Dictionary<int, List<QxIfo>>();
foreach(var it in usrlist)
{
List<QxIfo> retList = JsonConvert.DeserializeObject<List<QxIfo>>(it.Hotel_Data);
usrResult.Add(it.Id, retList);
}
return usrResult;
}
public static void Sel_Hotel_JSON_All_ByAutoAutho()
{
//0. 取到所有自动授权用户
List<UserInfo> usrlist = SqlSugarBase.Db.Queryable<UserInfo>().Where(x => x.Autho == 1).ToList();
List<int> usridList = usrlist.Select(x => x.Id).ToList();
//取到所有自动授权用户的授权关系记录
List<UserAuthoes> usrAuth = SqlSugarBase.Db.Queryable<UserAuthoes>().Where(x=> usridList.Contains(x.UserId)).ToList();
foreach (var usr in usrlist)
{
List<QxIfo> res = new List<QxIfo>();
res = usrAuth
.Where(X => X.UserId == usr.Id)
.Select(x => x.HotelId)
.ToArray() //只要酒店ID形成数组, 一个用户可能有多个酒店ID
.GroupBy(X => X) //酒店ID去重复
.Select(X => new QxIfo()
{ //酒店ID 用户ID 同一个酒店给同一个用户赋予权限的方法次数
id = X.Key,
uid = usr.Id,
sum = X.Count()
})
.ToList();
usr.Hotel_Data = JsonConvert.SerializeObject(res);
}
//9. 更新所有用户的Hotel_Data数据
var result = SqlSugarBase.Db.Updateable(usrlist).UpdateColumns(it => new { it.Hotel_Data }).ExecuteCommand();
}
public static List<Hotels> getHotels(int groupid, List<Hotels> htlist, List<HotelGroups> htgrplist)
{
List<Hotels> res = new List<Hotels>();
//返回组ID 这个组下面的第一层ID如果其中包括组ID那么继续下面一层酒店ID
//直到最下面一层。
var group = getgroup(groupid, htgrplist);
var D = htlist.Where(x => group.Contains(x.GroupId)).ToArray();
res.AddRange(D);
return res;
}
private static List<int> getgroup(int groupid, List<HotelGroups> htgrplist)
{
List<int> res = new List<int>();
res.Add(groupid);
var D = htgrplist.Where(x => x.ParentId == groupid).ToArray();
foreach (var tump in D)
{
res.AddRange(getgroup(tump.Id, htgrplist));
}
return res;
}
}
}

19
UH_CENTER/app.config Normal file
View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.29.0" newVersion="8.0.29.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /></startup></configuration>

15
UH_CENTER/packages.config Normal file
View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BouncyCastle" version="1.8.5" targetFramework="net461" />
<package id="Google.Protobuf" version="3.19.4" targetFramework="net461" />
<package id="K4os.Compression.LZ4" version="1.2.6" targetFramework="net461" />
<package id="K4os.Compression.LZ4.Streams" version="1.2.6" targetFramework="net461" />
<package id="K4os.Hash.xxHash" version="1.0.6" targetFramework="net461" />
<package id="MySql.Data" version="8.0.29" targetFramework="net461" requireReinstallation="true" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
<package id="SqlSugar" version="5.0.9.2" targetFramework="net47" />
<package id="System.Buffers" version="4.5.1" targetFramework="net461" />
<package id="System.Memory" version="4.5.4" targetFramework="net461" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net461" />
<package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net461" />
</packages>