常用网站资源
2021-01-20 21:13
标签:ase get ace pass manager path upn das bond 1.在线颜色 https://sunpma.com/other/rgb/ 2.阿里巴巴图库 https://www.iconfont.cn/search/index?spm=a313x.7781069.1998910419.dac382181&searchType=icon&q=%E7%99%BB%E5%BD%95 3.WPF 开源UI库 https://blog.csdn.net/bondw/article/details/102762156 using MySql.Data.MySqlClient;using System;using System.Data;using Utility; 常用网站资源 标签:ase get ace pass manager path upn das bond 原文地址:https://www.cnblogs.com/gkxg/p/13304964.html
namespace OFZ.DBLib{ public class MySqlDBHelper { #region Instance private static MySqlDBHelper m_Instance; public static MySqlDBHelper Instance { get { if (m_Instance == null) { m_Instance = new MySqlDBHelper(); } return m_Instance; } } #endregion Instance
#region Fields private string _ServerIP = string.Empty; private string _DBName = string.Empty; private uint _DBPort = 0; private string _UserName = string.Empty; private string _UserPassword = string.Empty; private string _ConnectionStringWithoutDB = string.Empty; public string _ConnectionStringWithDB = string.Empty; #endregion Fields
public bool CreateDB(string ServerIP, string dbName, uint dbPort, string userName, string userPassword, ref string errorInfo) { _ServerIP = ServerIP; _DBName = dbName; _DBPort = dbPort; _UserName = userName; _UserPassword = userPassword;
string strTemp = @"SERVER={0};Port={1};UID={2};PASSWORD={3};Charset=utf8;"; _ConnectionStringWithoutDB = string.Format(strTemp, ServerIP, dbPort, userName, userPassword); strTemp = @"SERVER={0};Port={1};DATABASE={2};UID={3};PASSWORD={4};Charset=utf8;"; _ConnectionStringWithDB = string.Format(strTemp, ServerIP, dbPort, dbName, userName, userPassword);
if (!CreateDatabase()) { errorInfo = string.Format("数据库:{0} 创建失败!", _DBName); return false; }
MySqlManager.Instance.Init(_ConnectionStringWithDB); if (!CreateAlarmsTable()) { errorInfo = "数据库表:Alarms 创建失败!"; return false; }
if (!CreatePermissions()) { errorInfo = "数据库表:Permissions 创建失败!"; return false; }
if (!CreateGroups()) { errorInfo = "数据库表:Groups 创建失败!"; return false; }
if (!CreateUsersTable()) { errorInfo = "数据库表:Users 创建失败!"; return false; }
if (!CreateLogTable()) { errorInfo = "数据库表:Log 创建失败!"; return false; }
if(!CreatePRTable()) { errorInfo = "数据库表:PR 创建失败!"; return false; }
if (!CreatePRBackupTable()) { errorInfo = "数据库表:PRBackup 创建失败!"; return false; }
if (!CreatePRSourceTable()) { errorInfo = "数据库表:PRSourceData 创建失败!"; return false; }
if (!CreateDebugLogTable()) { errorInfo = "数据库表:DebugLogTable 创建失败!"; return false; } return true; }
///
///
if (rslt { return false; } return true; } catch (Exception ex) { LogHelper.LogError("CreateUsersTable" + ex.Message); } return false; }
///
try { int rslt = MySqlManager.Instance.Execute(sql); if (rslt
sql = "Select * from Permissions;"; DataTable dt = MySqlManager.Instance.Query(sql); if (dt == null || 0 == dt.Rows.Count) { sql = "Insert into Permissions(PermissionId,Settings,WaveView,Waterfall,DasSettings,Selflearning," + "PRManage,LogView,UserManage,EventCenter,CameraManage,DeviceAdd,DeviceModify,DeviceDel,AllArming,AllDisarming,TimeDisarming,LinkageSettings)" + "values (‘0‘,‘1‘,‘1‘,‘1‘,‘1‘,‘1‘,‘1‘,‘1‘,‘1‘, ‘1‘,‘1‘,‘1‘,‘1‘,‘1‘,‘1‘,‘1‘,‘1‘,‘1‘)," + "(‘1‘,‘1‘,‘1‘,‘1‘,‘1‘,‘0‘,‘1‘,‘1‘,‘1‘,‘1‘,‘1‘,‘1‘,‘1‘,‘1‘,‘1‘,‘1‘,‘1‘,‘1‘)," + "(‘2‘,‘0‘,‘0‘,‘0‘,‘0‘,‘0‘,‘0‘,‘0‘,‘0‘,‘0‘,‘0‘,‘0‘,‘0‘,‘0‘,‘1‘,‘1‘,‘1‘,‘0‘)"; if (MySqlManager.Instance.Execute(sql) } return true; } catch (Exception ex) { LogHelper.LogError("CreateUsersTable" + ex.Message); } return false; }
///
sql = "Select * from groups;"; DataTable dt = MySqlManager.Instance.Query(sql); if (dt == null || 0 == dt.Rows.Count) { sql = "Insert into groups(GroupId,GroupName,PermissionId)" + "values (‘0‘,‘SuperAdmin‘,‘0‘)," + "(‘1‘,‘Admin‘,‘1‘)," + "(‘2‘,‘operator‘,‘2‘)";
if (MySqlManager.Instance.Execute(sql) } return true; } catch (Exception ex) { Console.WriteLine(ex.ToString()); LogHelper.LogError("CreateUsersTable" + ex.Message); } return false; }
///
sql = "Select * from users;"; DataTable dt = MySqlManager.Instance.Query(sql); if (dt == null || 0 == dt.Rows.Count) { sql = "Insert into users (UserId,Name,Password,GroupId) Values(‘ksgz001‘,‘Maintainer‘,‘FlPMSLj/XGPXVVYDeDRtjQ==‘,‘0‘),(‘ksgz002‘,‘Admin‘,‘GKFZy3ZETQ8=‘,‘1‘),(‘ksgz003‘,‘operator‘,‘XyQUovF++8c=‘,‘2‘);"; if (MySqlManager.Instance.Execute(sql) } return true; } catch (Exception ex) { LogHelper.LogError("CreateUsersTable" + ex.Message); } return false; }
///
try { int rslt = MySqlManager.Instance.Execute(sql); if (rslt
return true; } catch (Exception ex) { LogHelper.LogError("CreateLogTable" + ex.Message); } return false; }
private bool CreatePRTable() { string sql = "CREATE TABLE if not exists `pr`("; sql += "`pr_ID` varchar(45) NOT NULL,"; sql += "`pr_Type` int(11) NOT NULL,"; sql += "`pr_Name` varchar(45) NOT NULL,"; sql += "`pr_Time` datetime NOT NULL,"; sql += "`pr_Datas` text NOT NULL,"; sql += "PRIMARY KEY (`pr_ID`)) ENGINE=InnoDB DEFAULT CHARSET=gb2312;";
try { int rslt = MySqlManager.Instance.Execute(sql); if (rslt
return true; } catch (Exception ex) { LogHelper.LogError("CreatePRTable:" + ex.Message); } return false; }
private bool CreatePRBackupTable() { string sql = "CREATE TABLE if not exists `prbackup`("; sql += "`pr_ID` varchar(45) NOT NULL,"; sql += "`pr_Type` int(11) NOT NULL,"; sql += "`pr_Name` varchar(45) NOT NULL,"; sql += "`pr_Time` datetime NOT NULL,"; sql += "`pr_Datas` text NOT NULL,"; sql += "PRIMARY KEY (`pr_ID`)) ENGINE=InnoDB DEFAULT CHARSET=gb2312;";
try { int rslt = MySqlManager.Instance.Execute(sql); if (rslt
return true; } catch (Exception ex) { LogHelper.LogError("CreatePRBackupTable:" + ex.Message); } return false; }
private bool CreatePRSourceTable() { string sql = "CREATE TABLE if not exists `prsource`("; sql += "`pr_ID` varchar(45) NOT NULL,"; sql += "`pr_Type` int(11) NOT NULL,"; sql += "`pr_Name` varchar(45) NOT NULL,"; sql += "`pr_Time` datetime NOT NULL,"; sql += "`pr_Datas` text NOT NULL,"; sql += "PRIMARY KEY (`pr_ID`)) ENGINE=InnoDB DEFAULT CHARSET=gb2312;";
try { int rslt = MySqlManager.Instance.Execute(sql); if (rslt
return true; } catch (Exception ex) { LogHelper.LogError("CreatePRSourceDataTable:" + ex.Message); } return false; }
private bool CreateDebugLogTable() { string sql = "CREATE TABLE if not exists Debuglog("; sql += "LogId int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,"; sql += "DeviceType varchar(20) NOT NULL,"; sql += "DeviceId varchar(45) NOT NULL,"; sql += "LogTime DATETIME NOT NULL,"; sql += "Info TEXT NOT NULL);";
try { int rslt = MySqlManager.Instance.Execute(sql); if (rslt
return true; } catch (Exception ex) { LogHelper.LogError("CreateLogTable" + ex.Message); } return false; }
}}