260 lines
8.9 KiB
C#
260 lines
8.9 KiB
C#
/**************************************************************************
|
||
*
|
||
* =================================
|
||
* CLR版本 :4.0.30319.42000
|
||
* 命名空间 :NSAnalysis
|
||
* 文件名称 :Define.cs
|
||
* =================================
|
||
* 创 建 者 :shupeng.wang
|
||
* 创建日期 :2021/6/9 14:58:52
|
||
* 功能描述 :
|
||
* 使用说明 :
|
||
* =================================
|
||
* 修改者 :
|
||
* 修改日期 :
|
||
* 修改内容 :
|
||
* =================================
|
||
*
|
||
***************************************************************************/
|
||
|
||
using BaseFunction;
|
||
using System;
|
||
using System.IO;
|
||
using System.Windows.Forms;
|
||
|
||
namespace NSAnalysis
|
||
{
|
||
public class LogDebugDfn
|
||
{
|
||
public static string strDebugFile = Application.StartupPath + "\\Debug.txt"; //保存操作log的文件
|
||
public static string strStartTime = "";//程序启动时间
|
||
public static string strEndTime = ""; //程序关闭时间
|
||
}
|
||
|
||
public class ConfigDfn
|
||
{
|
||
#region 全局变量
|
||
|
||
public static string strKeyFolder = Application.StartupPath + "\\Key";
|
||
public static string strFileFolder = Application.StartupPath + "\\File";
|
||
public static string strDFQFolder = Application.StartupPath + "\\DFQFiles";
|
||
public static string strDebugFileFolder = Application.StartupPath + "\\File\\DebugFiles\\";
|
||
public static string strThemePath = Application.StartupPath + "\\ThemeSkin\\";
|
||
public static string strTheme = Application.StartupPath + "\\ThemeSkin\\";
|
||
|
||
/// <summary>
|
||
/// CheryAnalysisConfig.ini绝对路径地址
|
||
/// </summary>
|
||
public static string strConfigFile = Application.StartupPath + "\\File\\AnalysisConfig.ini";
|
||
|
||
public static string strImageFile = Application.StartupPath + "\\Images\\";
|
||
public static string strExpiredTime = "";
|
||
|
||
public static string strSkinName = "";
|
||
public static string strHelpDocumentName = "";
|
||
|
||
public static string strImagePath = "";
|
||
|
||
/// <summary>
|
||
/// true =中文 false =英语
|
||
/// </summary>
|
||
public static bool bLanguage = true;
|
||
|
||
public static bool bRememberMe = false;
|
||
public static string UserName = "";
|
||
public static string Password = "";
|
||
|
||
public static int gtm1_60 = 5000;
|
||
public static int gtmRMIDMode = 5000;
|
||
public static int gtmRCMMStatus = 6000;
|
||
|
||
public static string strNextSenseCSVEH3Path = "";
|
||
public static string strNextSenseCSVEHYPath = "";
|
||
public static string strNextSenseSelfMeasurePath = "";
|
||
public static string strPLCIP = "";
|
||
|
||
/// <summary>
|
||
/// NextSense 测量结果
|
||
/// </summary>
|
||
public static bool bMeasureResult = false;
|
||
|
||
public static string strMeasureTime = "";
|
||
|
||
public static double dFPY = 0.8;
|
||
public static double dFPY2 = 0.6;
|
||
|
||
public static string strCarModel = ""; //车型
|
||
public static string strEquipNo = ""; // 车号
|
||
public static string strEquipPosition = ""; //位置
|
||
public static string strIOTAddress = "";
|
||
public static string strIOTCarTypeAddress = "";
|
||
public static int iStartIOTFlag = 1;
|
||
public static int iShowCarDataFlag = 0;
|
||
public static string strShowCarLR = "";
|
||
public static string strCOMPort = "";
|
||
|
||
public static bool iEnableSort = false;
|
||
public static string strStationName = "";
|
||
public static string strUploadPath = "";
|
||
public static string strUploadPath2 = "";
|
||
public static double dLevel2 = 1.5;
|
||
|
||
public static double dLevel3 = 2.0;
|
||
public static string strReportPath = ""; //保存CSV报告的路径
|
||
|
||
// csv报告模板路径
|
||
public static string strCSVReportTemplatePath = Application.StartupPath + "\\File\\CSVReportTemplate.csv";
|
||
|
||
/// <summary>
|
||
/// 公差带百分比
|
||
/// </summary>
|
||
public static double dTolerancePer = 0.0;
|
||
|
||
public static double dExceptionTolerancePer = 0.0;
|
||
public static string strPwd = "";
|
||
public static int iAnalysisCSVFlag = 1;
|
||
public static int iRecordEncoderFlag = 0;
|
||
public static int iIncludeRangeFlag = 0;
|
||
public static int iMeasureItemsCount = 0;
|
||
public static int iFailedCarCount = 0;
|
||
|
||
#endregion 全局变量
|
||
|
||
public static void LoadConfig()
|
||
{
|
||
string strSection = "";
|
||
|
||
strSection = "Chery";
|
||
|
||
strSkinName = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "ConfigSkinName");
|
||
strTheme += strSkinName;
|
||
strHelpDocumentName = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "SoftwareHelpDocument");
|
||
strImagePath = strImageFile + FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "CNCPictureName");
|
||
bLanguage = FileIni.ReadBool(ConfigDfn.strConfigFile, strSection, "Language", 0);
|
||
bRememberMe = FileIni.ReadBool(ConfigDfn.strConfigFile, strSection, "RememberMe", 0);
|
||
|
||
//密码
|
||
strPwd = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "Password");
|
||
// 启用分发功能
|
||
iEnableSort = FileIni.ReadBool(ConfigDfn.strConfigFile, strSection, "EnableSort");
|
||
|
||
// 启用解析
|
||
iAnalysisCSVFlag = FileIni.ReadInt(ConfigDfn.strConfigFile, strSection, "AnalysisCSVFlag");
|
||
|
||
// 保存报告
|
||
strReportPath = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "ReportCSVPath");
|
||
}
|
||
|
||
// 保存配置,从全局变量中读取数据,写入到配置文件中
|
||
public static void SaveConfig()
|
||
{
|
||
try
|
||
{
|
||
MyBase.TraceWriteLine("保存配置文件——>开始");
|
||
if (File.Exists(strConfigFile))
|
||
{
|
||
string strSection = "Chery";
|
||
FileIni.WriteString(strConfigFile, strSection, "ConfigSkinName", strSkinName);
|
||
FileIni.WriteString(strConfigFile, strSection, "SoftwareHelpDocument", strHelpDocumentName);
|
||
FileIni.WriteString(strConfigFile, strSection, "CNCPictureName", Path.GetFileName(strImagePath));
|
||
FileIni.WriteBool(strConfigFile, strSection, "Language", bLanguage);
|
||
FileIni.WriteBool(strConfigFile, strSection, "RememberMe", bRememberMe);
|
||
FileIni.WriteString(strConfigFile, strSection, "Password", strPwd);
|
||
FileIni.WriteBool(strConfigFile, strSection, "EnableSort", iEnableSort);
|
||
FileIni.WriteInt(strConfigFile, strSection, "AnalysisCSVFlag", iAnalysisCSVFlag);
|
||
FileIni.WriteString(strConfigFile, strSection, "ReportCSVPath", strReportPath);
|
||
MyBase.TraceWriteLine("保存配置文件——>完成");
|
||
}
|
||
else
|
||
{
|
||
MyBase.TraceWriteLine("配置文件不存在!");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MyBase.TraceWriteLine("保存配置文件错误:" + ex.ToString());
|
||
}
|
||
}
|
||
|
||
public static void LoadConfigFile()
|
||
{
|
||
try
|
||
{
|
||
MyBase.TraceWriteLine("加载配置文件——>开始");
|
||
if (File.Exists(strConfigFile))
|
||
{
|
||
LoadConfig(); //加载软件配置
|
||
DatabaseDfn.LoadConfig(); //加载数据库配置
|
||
MyBase.TraceWriteLine("加载配置文件——>完成");
|
||
}
|
||
else
|
||
{
|
||
MyBase.TraceWriteLine("配置文件不存在!");
|
||
}
|
||
|
||
#region 检测文件夹,没有则创建
|
||
|
||
if (!Directory.Exists(ConfigDfn.strFileFolder))
|
||
Directory.CreateDirectory(ConfigDfn.strFileFolder);
|
||
if (!Directory.Exists(ConfigDfn.strDebugFileFolder))
|
||
Directory.CreateDirectory(ConfigDfn.strDebugFileFolder);
|
||
if (!Directory.Exists(ConfigDfn.strKeyFolder))
|
||
Directory.CreateDirectory(ConfigDfn.strKeyFolder);
|
||
if (!Directory.Exists(ConfigDfn.strThemePath))
|
||
Directory.CreateDirectory(ConfigDfn.strThemePath);
|
||
if (!Directory.Exists(ConfigDfn.strImageFile))
|
||
Directory.CreateDirectory(ConfigDfn.strImageFile);
|
||
if (!Directory.Exists(ConfigDfn.strDFQFolder))
|
||
Directory.CreateDirectory(ConfigDfn.strDFQFolder);
|
||
|
||
//创建保存报告的路径
|
||
if (!Directory.Exists(ConfigDfn.strReportPath))
|
||
Directory.CreateDirectory(ConfigDfn.strReportPath);
|
||
|
||
#endregion 检测文件夹,没有则创建
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MyBase.TraceWriteLine("加载配置文件错误:" + ex.ToString());
|
||
}
|
||
}
|
||
}
|
||
|
||
public class DatabaseDfn
|
||
{
|
||
public static string SqlServerName = "";
|
||
public static string SqlDbName = "";
|
||
public static string SqlUserName = "";
|
||
public static string SqlPassword = "";
|
||
|
||
public static string SqlConnectStr()
|
||
{
|
||
string strConnectString = "";
|
||
|
||
LoadConfig();
|
||
strConnectString = @"Data Source=" + SqlServerName
|
||
+ ";initial Catalog=" + SqlDbName
|
||
+ ";User ID=" + SqlUserName
|
||
+ ";password=" + SqlPassword + ";";
|
||
|
||
MyBase.TraceWriteLine("数据库连接字符串:" + strConnectString);
|
||
|
||
return strConnectString;
|
||
}
|
||
|
||
public static void LoadConfig()
|
||
{
|
||
string strSection = "MSDB";
|
||
SqlServerName = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "SqlServerName");
|
||
SqlUserName = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "SqlUserName");
|
||
SqlPassword = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "SqlPassword");
|
||
SqlDbName = FileIni.ReadString(ConfigDfn.strConfigFile, strSection, "SqlDbName");
|
||
|
||
//写入日志的
|
||
MyBase.TraceWriteLine("数据库连接 SqlServerName:" + SqlServerName);
|
||
MyBase.TraceWriteLine("数据库连接 SqlUserName:" + SqlUserName);
|
||
MyBase.TraceWriteLine("数据库连接 SqlPassword:" + SqlPassword);
|
||
MyBase.TraceWriteLine("数据库连接 SqlDbName:" + SqlDbName);
|
||
}
|
||
}
|
||
} |