This commit is contained in:
孙源
2025-07-11 14:12:47 +08:00
commit 9dacccd1d5
404 changed files with 514108 additions and 0 deletions

121
Tool/CommonHelper.cs Normal file
View File

@ -0,0 +1,121 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tool
{
public class CommonHelper
{
public static bool IMEICheck(string imei)
{
int vl_Sum1 = 0, vl_Sum2 = 0, vl_Total = 0;
int vl_Temp = 0;
for (int i = 0; i < 14; i++)
{
/*(1)将奇数位数字相加(从1开始计数)*/
if ((i % 2) == 0)
{
vl_Sum1 = vl_Sum1 + int.Parse(imei[i].ToString());
}
else
{
/*(2)将偶数位数字分别乘以2,分别计算个位数和十位数之和(从1开始计数)*/
vl_Temp = (int.Parse(imei[i].ToString())) * 2;
if (vl_Temp < 10)
{
vl_Sum2 = vl_Sum2 + vl_Temp;
}
else
{
vl_Sum2 = vl_Sum2 + 1 + vl_Temp - 10;
}
}
}
/*(1)+(2)*/
vl_Total = vl_Sum1 + vl_Sum2;
/*如果得出的数个位是0则校验位为0,否则为10减去个位数 */
if ((vl_Total % 10) == 0)
{
if (imei[14] == '0')
{
return true;
}
}
else
{
if ((10 - (vl_Total % 10)).ToString() == imei[14].ToString())
{
return true;
}
}
return false;
}
public static string GetIMEI(string imei)
{
int vl_Sum1 = 0, vl_Sum2 = 0, vl_Total = 0;
int vl_Temp = 0;
for (int i = 0; i < 14; i++)
{
/*(1)将奇数位数字相加(从1开始计数)*/
if ((i % 2) == 0)
{
vl_Sum1 = vl_Sum1 + int.Parse(imei[i].ToString());
}
else
{
/*(2)将偶数位数字分别乘以2,分别计算个位数和十位数之和(从1开始计数)*/
vl_Temp = (int.Parse(imei[i].ToString())) * 2;
if (vl_Temp < 10)
{
vl_Sum2 = vl_Sum2 + vl_Temp;
}
else
{
vl_Sum2 = vl_Sum2 + 1 + vl_Temp - 10;
}
}
}
/*(1)+(2)*/
vl_Total = vl_Sum1 + vl_Sum2;
/*如果得出的数个位是0则校验位为0,否则为10减去个位数 */
if ((vl_Total % 10) == 0)
{
return imei + "0";
}
else
{
return imei + (10 - (vl_Total % 10)).ToString();
}
}
public static List<T> Clone<T>(List<T> list) where T : new()
{
List<T> items = new List<T>();
foreach (var m in list)
{
var model = new T();
var ps = model.GetType().GetProperties();
var properties = m.GetType().GetProperties();
foreach (var p in properties)
{
foreach (var pm in ps)
{
if (pm.Name == p.Name)
{
pm.SetValue(model, p.GetValue(m));
}
}
}
items.Add(model);
}
return items;
}
}
}

54
Tool/ConfigHelper.cs Normal file
View File

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tool
{
public class ConfigHelper
{
//向配置文件写入内容
public void Write(string key, string value)
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
config.AppSettings.Settings.Add(key, value);
}
else
{
config.AppSettings.Settings[key].Value = value;
}
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");// 重新加载新的配置文件
}
//读取配置文件内容
public Dictionary<string, string> ReadAll()
{
Dictionary<string, string> dic = new Dictionary<string, string>();
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
foreach (string key in config.AppSettings.Settings.AllKeys)
{
dic[key] = config.AppSettings.Settings[key].Value;
}
return dic;
}
public Dictionary<string, string> ReadAll(string path)
{
Dictionary<string, string> dic = new Dictionary<string, string>();
ExeConfigurationFileMap map = new ExeConfigurationFileMap
{
ExeConfigFilename = path
};
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
foreach (string key in config.AppSettings.Settings.AllKeys)
{
dic[key] = config.AppSettings.Settings[key].Value;
}
return dic;
}
}
}

46
Tool/FileHelper.cs Normal file
View File

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tool
{
public class FileHelper
{
public void Transport(string file, string dst, string product)
{
string src;
src = file;
FileStream inFileStream = new FileStream(src, FileMode.Open);
if (!Directory.Exists(dst))
{
Directory.CreateDirectory(dst);
}
dst = dst + "\\" + product;
FileStream outFileStream = new FileStream(dst, FileMode.OpenOrCreate);
try
{
byte[] buf = new byte[inFileStream.Length];
int byteCount;
while ((byteCount = inFileStream.Read(buf, 0, buf.Length)) > 0)
{
outFileStream.Write(buf, 0, byteCount);
}
inFileStream.Flush();
outFileStream.Flush();
}
finally
{
inFileStream.Close();
outFileStream.Close();
}
}
}
}

92
Tool/LogHelper.cs Normal file
View File

@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tool
{
public class LogHelper
{
private static readonly object LogLock = new object();
public static void WriteLog(string msg)
{
lock (LogLock)
{
string filePath = AppDomain.CurrentDomain.BaseDirectory + "Log";
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
string logPath = AppDomain.CurrentDomain.BaseDirectory + "Log\\" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
try
{
using (StreamWriter sw = File.AppendText(logPath))
{
sw.WriteLine("**************************************************");
sw.WriteLine("时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
sw.WriteLine(msg);
sw.WriteLine();
sw.Flush();
sw.Close();
sw.Dispose();
}
}
catch (IOException e)
{
using (StreamWriter sw = File.AppendText(logPath))
{
sw.WriteLine("**************************************************");
sw.WriteLine("时间:" + DateTime.Now.ToString("yyy-MM-dd HH:mm:ss"));
sw.WriteLine("异常:" + e.Message);
sw.WriteLine();
sw.Flush();
sw.Close();
sw.Dispose();
}
}
}
}
public static void WriteLogMater(string msg)
{
lock (LogLock)
{
string filePath = AppDomain.CurrentDomain.BaseDirectory + "Logmater";
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
string logPath = AppDomain.CurrentDomain.BaseDirectory + "Logmater\\" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
try
{
using (StreamWriter sw = File.AppendText(logPath))
{
sw.WriteLine("**************************************************");
sw.WriteLine("时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
sw.WriteLine(msg);
sw.WriteLine();
sw.Flush();
sw.Close();
sw.Dispose();
}
}
catch (IOException e)
{
using (StreamWriter sw = File.AppendText(logPath))
{
sw.WriteLine("**************************************************");
sw.WriteLine("时间:" + DateTime.Now.ToString("yyy-MM-dd HH:mm:ss"));
sw.WriteLine("异常:" + e.Message);
sw.WriteLine();
sw.Flush();
sw.Close();
sw.Dispose();
}
}
}
}
}
}

View File

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

165
Tool/SqlHelper.cs Normal file
View File

@ -0,0 +1,165 @@
using Model;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tool
{
public class SqlHelper
{
private ConnectionConfig connection2 = null;
public SqlSugarClient db2 = null;
private ConnectionConfig connection3 = null;
public SqlSugarClient db3 = null;
public SqlHelper()
{
string SqlIP2 = "192.168.2.2";
string SqlIP3 = "192.168.2.3";
string database = "MESDB";
string uid = "sa";
string pwd = "8ik,9ol.";
connection2 = new ConnectionConfig()
{
ConnectionString = "server='" + SqlIP2 + "';initial catalog='" + database + "';uid='" + uid + "';pwd='" + pwd + "'",
DbType = DbType.SqlServer,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute
};
db2 = new SqlSugarClient(connection2);
connection3 = new ConnectionConfig()
{
ConnectionString = "server='" + SqlIP3 + "';initial catalog='" + database + "';uid='" + uid + "';pwd='" + pwd + "'",
DbType = DbType.SqlServer,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute
};
db3 = new SqlSugarClient(connection3);
}
#region t_CMCC_Jinji
[SugarTable("t_CMCC_Jinji")]
public class t_CMCC_Jinji
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int id { get; set; }
public string type { get; set; }
public string snimei { get; set; }
public string inname { get; set; }
public DateTime? inTime { get; set; }
public string endname { get; set; }
public DateTime? endTime { get; set; }
}
#endregion
#region t_CMCC_JinjiPower
[SugarTable("t_CMCC_JinjiPower")]
public class t_CMCC_JinjiPower
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int id { get; set; }
public string type { get; set; }
public string snimei { get; set; }
public string Devcode { get; set; }
public string Band { get; set; }
public string Channel { get; set; }
public string Result { get; set; }
public string kind { get; set; }
public string textname { get; set; }
public string Powername { get; set; }
public DateTime? PowerTime { get; set; }
}
#endregion
#region t_CMCC_JinjiLine
[SugarTable("t_CMCC_JinjiLine")]
public class t_CMCC_JinjiLine
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int id { get; set; }
/// <summary>
/// 机型
/// </summary>
public string type { get; set; }
/// <summary>
/// 金机编码
/// </summary>
public string snimei { get; set; }
/// <summary>
/// 夹具号
/// </summary>
public string Devcode { get; set; }
/// <summary>
/// 类别
/// </summary>
public string kind { get; set; }
/// <summary>
/// 第几项线损
/// </summary>
public string several_line_loss { get; set; }
public string LTE_BAND_TX_LOW_LOSS { get; set; }
public string LTE_BAND_TX_MID_LOSS { get; set; }
public string LTE_BAND_TX_HIGH_LOSS { get; set; }
public string LTE_BAND_RX_LOW_LOSS { get; set; }
public string LTE_BAND_RX_MID_LOSS { get; set; }
public string LTE_BAND_RX_HIGH_LOSS { get; set; }
/// <summary>
/// 线损文件名称
/// </summary>
public string textname { get; set; }
/// <summary>
/// 录入人员名称
/// </summary>
public string Linename { get; set; }
/// <summary>
/// 录入时间
/// </summary>
public DateTime? LineTime { get; set; }
}
#endregion
#region t_DD_UserDetail
[SugarTable("t_DD_UserDetail")]
public class t_DD_UserDetail
{
/// <summary>
/// 姓名
/// </summary>
public string username { get; set; }
/// <summary>
/// 工号
/// </summary>
public string jobnumber { get; set; }
/// <summary>
/// 公司
/// </summary>
public string companyName { get; set; }
/// <summary>
/// 部门
/// </summary>
public string workPlace { get; set; }
/// <summary>
/// 职位
/// </summary>
public string position { get; set; }
}
#endregion
public UserModel GetUser(string jobnumber)
{
try
{
var userModel = db2.Queryable<t_DD_UserDetail>().Where(it => it.jobnumber == jobnumber && it.companyName == "重庆盟讯电子科技有限公司").First();
if (userModel == null)
{
return null;
}
return new UserModel() { userName = jobnumber, nickName = userModel.username, bumen = userModel.workPlace, zhiwei = userModel.position };
}
// return db.Queryable<t_DD_UserDetail>().Where(it => it.jobnumber == jobnumber && it.companyName == "重庆盟讯电子科技有限公司").First().username;
//}
catch (System.Exception ee)
{
LogHelper.WriteLog(ee.ToString());
throw ee;
}
}
}
}

65
Tool/Tool.csproj Normal file
View File

@ -0,0 +1,65 @@
<?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>{CC8994B7-1312-45E6-ABDA-92413692FEB3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Tool</RootNamespace>
<AssemblyName>Tool</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</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="SqlSugar, Version=5.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\点检\packages\SqlSugar.5.0.3\lib\SqlSugar.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<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="CommonHelper.cs" />
<Compile Include="ConfigHelper.cs" />
<Compile Include="FileHelper.cs" />
<Compile Include="LogHelper.cs" />
<Compile Include="SqlHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj">
<Project>{5A80DE64-FCD5-4D7C-8A1E-4199412D80BD}</Project>
<Name>Model</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

BIN
Tool/bin/Debug/Model.dll Normal file

Binary file not shown.

BIN
Tool/bin/Debug/Model.pdb Normal file

Binary file not shown.

BIN
Tool/bin/Debug/SqlSugar.dll Normal file

Binary file not shown.

BIN
Tool/bin/Debug/Tool.dll Normal file

Binary file not shown.

BIN
Tool/bin/Debug/Tool.pdb Normal file

Binary file not shown.

View File

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

Binary file not shown.

View File

@ -0,0 +1 @@
f94c390bd35cd2c22da9892b123575027c89d50c705b1483972981c73fe32bc2

View File

@ -0,0 +1,10 @@
D:\桌面文件夹\Desktop\中移版本库\金机点检\Tool\bin\Debug\Tool.dll
D:\桌面文件夹\Desktop\中移版本库\金机点检\Tool\bin\Debug\Tool.pdb
D:\桌面文件夹\Desktop\中移版本库\金机点检\Tool\obj\Debug\Tool.csproj.AssemblyReference.cache
D:\桌面文件夹\Desktop\中移版本库\金机点检\Tool\obj\Debug\Tool.csproj.CoreCompileInputs.cache
D:\桌面文件夹\Desktop\中移版本库\金机点检\Tool\obj\Debug\Tool.dll
D:\桌面文件夹\Desktop\中移版本库\金机点检\Tool\obj\Debug\Tool.pdb
D:\桌面文件夹\Desktop\中移版本库\金机点检\Tool\bin\Debug\Model.dll
D:\桌面文件夹\Desktop\中移版本库\金机点检\Tool\bin\Debug\SqlSugar.dll
D:\桌面文件夹\Desktop\中移版本库\金机点检\Tool\bin\Debug\Model.pdb
D:\桌面文件夹\Desktop\中移版本库\金机点检\Tool\obj\Debug\Tool.csproj.Up2Date

View File

BIN
Tool/obj/Debug/Tool.dll Normal file

Binary file not shown.

BIN
Tool/obj/Debug/Tool.pdb Normal file

Binary file not shown.

4
Tool/packages.config Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SqlSugar" version="5.0.3" targetFramework="net452" />
</packages>