public void SetDataBaseType(DBType databaseType) { if (!string.IsNullOrEmpty(databaseType.ToString())) { m_dataBaseType = databaseType; } }
//设置web.config private void SetWebConfig(string connectionString, DBType dbType, out ConcurrentDictionary <string, string> messages) { messages = new ConcurrentDictionary <string, string>(); System.IO.FileInfo FileInfo = new FileInfo(Server.MapPath("~/web.config")); if (!FileInfo.Exists) { messages[string.Format("文件 : {0} 不存在", Server.MapPath("~/web.config"))] = ""; } XElement rootElement = XElement.Load(FileInfo.FullName); XElement connectionStringsElement = rootElement.Descendants("connectionStrings").FirstOrDefault(); if (connectionStringsElement != null && connectionStringsElement.HasElements) { XElement element = connectionStringsElement.Elements("add").LastOrDefault(n => n.NodeType != XmlNodeType.Comment); if (element != null) { try { element.Attribute("name").Value = dbType.ToString(); element.Attribute("connectionString").Value = connectionString; element.SetAttributeValue("providerName", GetProviderName(dbType)); } catch (Exception e) { messages[e.Message] = e.StackTrace; } } } rootElement.Save(FileInfo.FullName); }
/// <summary> /// 获取数据库连接 /// </summary> /// <param name="dbType">数据库类型</param> /// <param name="conStr">数据库连接字符串</param> /// <returns>数据库连接</returns> public static IDbConnection CreateConnection(DBType dbType, string strConn) { IDbConnection connection = null; if (strConn.IsNullOrWhiteSpace()) { throw new ArgumentNullException("数据库连接字符串为空!"); } switch (dbType) { case DBType.SqlServer: connection = new SqlConnection(strConn); break; case DBType.MySQL: connection = new MySqlConnection(strConn); break; case DBType.PostgreSQL: //connection = new NpgsqlConnection(strConn); break; default: throw new ArgumentNullException($"暂不支持的{dbType.ToString()}数据库类型"); } if (connection.State == ConnectionState.Closed) { connection.Open(); } return(connection); }
public List <string> GetTablesList(string Keyspace = null) { MakeSureConnectionIsOpen(); List <string> rc = new List <string>() { "" }; try { //if (oConn == null || oConn.State == ConnectionState.Closed) Connect(); if (DBType == Database.eDBTypes.Cassandra) { NoSqlBase.NoSqlBase NoSqlDriver = null; NoSqlDriver = new GingerCassandra(this); rc = NoSqlDriver.GetTableList(Keyspace); } else { DataTable table = oConn.GetSchema("Tables"); string tableName = ""; foreach (DataRow row in table.Rows) { switch (DBType) { case eDBTypes.MSSQL: tableName = (string)row[2]; break; case eDBTypes.Oracle: tableName = (string)row[1]; break; case eDBTypes.MSAccess: tableName = (string)row[2]; break; case eDBTypes.DB2: tableName = (string)row[2]; break; case eDBTypes.MySQL: tableName = (string)row[2]; break; } rc.Add(tableName); } } } catch (Exception e) { Reporter.ToLog(eLogLevel.ERROR, "Failed to get table list for DB:" + DBType.ToString(), e); throw (e); } return(rc); }
/// <summary> /// 后补的接口,适配旧的调用 /// </summary> /// <param name="tableName"></param> /// <param name="IdX"></param> /// <param name="IdY"></param> /// <returns></returns> public string GetJson(DBType dbType) { int x = -1; int y = -1; var list = new List <object>(); var json = GetJson(dbType.ToString(), ref x, ref y, ref list); return(json); }
public static string GetDBConnectString(DBType dbtype) { string connStr = null; connStr = GetItemValue(dbtype.ToString()); if (connStr == null || connStr == string.Empty) { connStr = string.Empty; } return(connStr); }
/// <summary> /// 根据数据库类型,获取指定数据库连接串 /// </summary> /// <param name="dataBaseType"></param> /// <param name="optType">The optType<see cref="DBOptType"/></param> /// <returns></returns> private static string GetDbConectionString(DBType dataBaseType, DBOptType optType = DBOptType.Read) { var connString = string.Empty; var configKey = string.Format("Gseey:Connections:{0}Db{1}ConnectionString", dataBaseType.ToString().ToUpper(), optType.ToString().ToUpper()); connString = ConfigHelper.Get(configKey); return(connString); }
internal static SqlType Get(DBType dbType, int length) { string key = GetKeyForLengthBased(dbType.ToString(), length); SqlType result; if (!SqlTypes.TryGetValue(key, out result)) { result = new SqlType(dbType, length); lock (SqlTypes) SqlTypes.Add(key, result); } return(result); }
/// <summary> /// 连接数据库 /// </summary> /// <param name="dbType">数据库类型(连接字符串默认:ConfigurationManager.ConnectionStrings[dbType.ToString()].ConnectionString)</param> /// <returns>数据库操作实例对象</returns> public static DB UseDB(DBType dbType, int cmdTimeOut = 30) { string connectionString = string.Empty; if (ConfigurationManager.ConnectionStrings[dbType.ToString()] != null) { connectionString = ConfigurationManager.ConnectionStrings[dbType.ToString()].ConnectionString; } else { throw new ArgumentNullException("connectionString", dbType.ToString() + "的connectionString不能为空!"); } //处理 如果Sqlite 连接字符串只提供 路径的情况 if (dbType == DBType.SQLite && Regex.IsMatch(connectionString, @"^(\w):\\(.*)(.+\.db)$", RegexOptions.IgnoreCase | RegexOptions.Compiled)) { connectionString = string.Format("Data Source={0};Pooling=True;BinaryGUID=True;Enlist=N;Synchronous=Off;Journal Mode=WAL;Cache Size=5000;", connectionString); } return(DBFactory.CreateInstance(dbType, connectionString, cmdTimeOut)); }
public string GetConnectionString(DBType db) { if (DbConnectionString.Count == 0) { InitDBConnection(); } string key = connCfg + "." + db.ToString(); if (!DbConnectionString.ContainsKey(key) || DbConnectionString[key] == null) { ConnectionStringSettings item = ConfigurationManager.ConnectionStrings[key]; if (item == null) { return(null); } return(item.ConnectionString); } return(DbConnectionString[key]); }
public static DBGeneral GetDBGeneralInfo(DBType dbType) { if (DBGeneralDic.ContainsKey(dbType)) { return(DBGeneralDic[dbType]); } DataBaseType curDBType = DataBaseType.SqlServer; if (dbType == DBType.LogTrace) { curDBType = AppConfig.GetFinalConfig("UserCfg_TraceDBTypeKey", DataBaseType.SqlServer, LogApi.GetUserCfg_TraceDBTypeKey()); } else { curDBType = AppConfig.GetFinalConfig("UserCfg_MonitorDBTypeKey", DataBaseType.SqlServer, LogApi.GetUserCfg_MonitorDBTypeKey()); } DBGeneral dBGeneral = new DBGeneral() { DataBaseType = curDBType }; if (curDBType == DataBaseType.SqlServer) { dBGeneral.SchemaName = "dbo"; } else if (curDBType == DataBaseType.Oracle) { dBGeneral.SchemaName = "scott"; } else if (curDBType == DataBaseType.MySql) { // dBGeneral.SchemaName = ""; } DBGeneralDic.Add(dbType, dBGeneral); string msg = dbType.ToString() + "的数据库类型为【" + dBGeneral.DataBaseType.ToString() + "】"; LogCom.WriteModelToFileForDebug(new { 内容 = msg }); return(dBGeneral); }
private static string strGetAllTablesSql(this IDbConnection dbConnection, DBType dbType) { string strGetAllTables = string.Empty; switch (dbType) { case DBType.SqlServer: strGetAllTables = @"SELECT DISTINCT d.name as TableName, f.value as TableComment FROM sys.syscolumns AS a LEFT OUTER JOIN sys.systypes AS b ON a.xusertype = b.xusertype INNER JOIN sys.sysobjects AS d ON a.id = d.id AND d.xtype = 'U' AND d.name <> 'dtproperties' LEFT OUTER JOIN sys.syscomments AS e ON a.cdefault = e.id LEFT OUTER JOIN sys.extended_properties AS g ON a.id = g.major_id AND a.colid = g.minor_id LEFT OUTER JOIN sys.extended_properties AS f ON d.id = f.major_id AND f.minor_id = 0"; break; case DBType.MySQL: strGetAllTables = "SELECT TABLE_NAME as TableName," + " Table_Comment as TableComment" + " FROM INFORMATION_SCHEMA.TABLES" + $" where TABLE_SCHEMA = '{dbConnection.Database}'"; break; case DBType.PostgreSQL: strGetAllTables = "select relname as TableName," + " cast(obj_description(relfilenode,'pg_class') as varchar) as TableComment" + " from pg_class c" + " where relkind = 'r' and relname not like 'pg_%' and relname not like 'sql_%'" + " order by relname"; break; default: throw new ArgumentNullException($"这是我的错,还不支持的{dbType.ToString()}数据库类型"); } return(strGetAllTables); }
/// <summary> /// Получение запросов для миграции /// </summary> public List <string> GetQueries(string direction, DBType type) { try { List <Dictionary <string, List <string> > > list = new List <Dictionary <string, List <string> > >(); List <string> queries = new List <string>(); switch (direction) { case "up": list = Up; break; case "down": list = Down; break; } foreach (Dictionary <string, List <string> > query in list) { List <string> strs = query.Where(p => p.Key == type.ToString().ToLower()) .Select(p => p.Value) .FirstOrDefault() ?? // Общие запросы query.Where(p => p.Key == "common") .Select(p => p.Value) .FirstOrDefault(); queries.Add(string.Join("", strs)); } return(queries); } catch { return(new List <string>()); } }
public XmlNode GenerateXmlNode() { XmlDocument xml = new XmlDocument(); XmlNode node = xml.CreateElement("Device"); node.Attributes.Append(XMLHelper.CreateAttribute(xml, "Name", Name)); node.Attributes.Append(XMLHelper.CreateAttribute(xml, "T133LeafID", T133LeafID.ToString())); node.Attributes.Append(XMLHelper.CreateAttribute(xml, "T216LeafID", T216LeafID.ToString())); node.Attributes.Append(XMLHelper.CreateAttribute(xml, "T107LeafID", T107LeafID.ToString())); node.Attributes.Append(XMLHelper.CreateAttribute(xml, "PLCType", PLCType.ToString())); node.Attributes.Append(XMLHelper.CreateAttribute(xml, "DBType", DBType.ToString())); node.Attributes.Append(XMLHelper.CreateAttribute(xml, "DBNumber", DBNumber.ToString())); node.Attributes.Append(XMLHelper.CreateAttribute(xml, "CycleReadMode", CycleReadMode.ToString())); node.Attributes.Append(XMLHelper.CreateAttribute(xml, "SplitterTime", SplitterTime.ToString())); node.AppendChild(xml.ImportNode(BelongPLC.GenerateXmlNode(), true)); foreach (GroupEntity group in Groups) { node.AppendChild(xml.ImportNode(group.GenerateXmlNode(), true)); } return(node); }
/// <summary> /// 根据connection string的key获取连接字符串 /// </summary> /// <param name="key"></param> /// <param name="type"></param> /// <returns></returns> public static IDBHelper CreateDBHelperByKey(string key, DBType type) { string strDBType = type.ToString(); bool logsql = false; if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["EnableSqlLog"])) { logsql = ConfigurationManager.AppSettings["EnableSqlLog"] == "1"; } string strConn = null; if (ConfigurationManager.ConnectionStrings[key] != null && !string.IsNullOrEmpty(ConfigurationManager.ConnectionStrings[key].ConnectionString)) { strConn = ConfigurationManager.ConnectionStrings[key].ConnectionString; } if (string.IsNullOrEmpty(strConn)) { throw new Exception("没有在ConnectionString配置节点配置连接字符串!"); } var helper = CreateDBHelper(strConn, strDBType); return(helper); }
public List <Row_R_Station_Output> GetStationOutputByStationID(string _StationID, OleExec DB) { string strsql = ""; List <Row_R_Station_Output> RET = new List <Row_R_Station_Output>(); if (DBType == DB_TYPE_ENUM.Oracle) { strsql = $@"select * from R_Station_Output where R_station_id = '{_StationID}' order by SEQ_NO"; DataSet res1 = DB.ExecSelect(strsql); for (int i = 0; i < res1.Tables[0].Rows.Count; i++) { Row_R_Station_Output R = (Row_R_Station_Output)this.NewRow(); R.loadData(res1.Tables[0].Rows[i]); RET.Add(R); } return(RET); //Row_R_Station R = (Row_R_Station)this.GetObjByID(ID, DB); //return R; } else { string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000019", new string[] { DBType.ToString() }); throw new MESReturnMessage(errMsg); } }
public Boolean Connect(bool displayErrorPopup = false) { DbProviderFactory factory; string connectConnectionString = string.Empty; if (DBType != eDBTypes.Cassandra && DBType != eDBTypes.Couchbase && DBType != eDBTypes.MongoDb) { connectConnectionString = GetConnectionString(); } try { switch (DBType) { case eDBTypes.MSSQL: oConn = new SqlConnection(); oConn.ConnectionString = connectConnectionString; oConn.Open(); break; case eDBTypes.Oracle: //TODO: Oracle connection is deprecated use another method - Switched to ODP.NET //Try Catch for Connecting DB Which having Oracle Version Less then 10.2 try { var DLL = Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory + @"Oracle.ManagedDataAccess.dll"); var class1Type = DLL.GetType("Oracle.ManagedDataAccess.Client.OracleConnection"); object[] param = new object[1]; param[0] = connectConnectionString; dynamic c = Activator.CreateInstance(class1Type, param); oConn = (DbConnection)c; oConn.Open(); break; } catch (Exception e) { String Temp = e.Message; //if (Temp.Contains ("ORA-03111")) if (Temp.Contains("ORA-03111")) { factory = DbProviderFactories.GetFactory("System.Data.OleDb"); oConn = factory.CreateConnection(); oConn.ConnectionString = "Provider=msdaora;" + connectConnectionString; oConn.Open(); break; } else if (Temp.Contains("ORA-01017")) { throw e; } else if (!System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"Oracle.ManagedDataAccess.dll")) { throw new Exception(GetMissingDLLErrorDescription()); } else { throw e; } } case eDBTypes.MSAccess: // anything better than below? // TODO: working only with mdb access97, not with accmdb factory = DbProviderFactories.GetFactory("System.Data.OleDb"); oConn = factory.CreateConnection(); oConn.ConnectionString = connectConnectionString; oConn.Open(); break; case eDBTypes.DB2: String DB2Cpath = (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\IBM\DB2\GLOBAL_PROFILE", "DB2PATH", "DNE"); if (System.IO.Directory.Exists(DB2Cpath)) { var DLL = Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory + @"DLLs\IBM.Data.DB2.dll"); var class1Type = DLL.GetType("IBM.Data.DB2.DB2Connection"); //Now you can use reflection or dynamic to call the method. I will show you the dynamic way object[] param = new object[1]; param[0] = connectConnectionString; dynamic c = Activator.CreateInstance(class1Type, param); oConn = (DbConnection)c; oConn.Open(); } else { throw new Exception("DB2 Connect or IBM DB2 Drivers not installed."); } break; case eDBTypes.PostgreSQL: oConn = new NpgsqlConnection(connectConnectionString); oConn.Open(); break; case eDBTypes.Cassandra: GingerCassandra CassandraDriver = new GingerCassandra(this); bool isConnection; isConnection = CassandraDriver.Connect(); if (isConnection == true) { LastConnectionUsedTime = DateTime.Now; return(true); } else { return(false); } case eDBTypes.Couchbase: GingerCouchbase CouchbaseDriver = new GingerCouchbase(this); bool isConnectionCB; isConnectionCB = CouchbaseDriver.Connect(); if (isConnectionCB == true) { LastConnectionUsedTime = DateTime.Now; return(true); } else { return(false); } case eDBTypes.MySQL: oConn = new MySqlConnection(); oConn.ConnectionString = connectConnectionString; oConn.Open(); break; case eDBTypes.MongoDb: bool isConnectionMDB; GingerMongoDb MongoDriver = new GingerMongoDb(this); isConnectionMDB = MongoDriver.Connect(); if (isConnectionMDB == true) { LastConnectionUsedTime = DateTime.Now; return(true); } else { return(false); } } if ((oConn != null) && (oConn.State == ConnectionState.Open)) { LastConnectionUsedTime = DateTime.Now; return(true); } } catch (Exception e) { Reporter.ToLog(eLogLevel.ERROR, "DB connection failed, DB type: " + DBType.ToString() + "; Connection String =" + General.HidePasswordFromString(connectConnectionString), e); throw (e); } return(false); }
public List <R_SN_LOCK> GetLockList(string LOCK_ID, string LOCK_LOT, string SN, string WORKORDERNO, string STATUS, OleExec DB) { List <R_SN_LOCK> Seq = new List <R_SN_LOCK>(); string sql = string.Empty; DataTable dt = new DataTable("C_SEQNO"); Row_R_SN_LOCK SeqRow = (Row_R_SN_LOCK)NewRow(); if (this.DBType.Equals(DB_TYPE_ENUM.Oracle)) { sql = $@" select * from R_SN_LOCK where 1=1 "; if (LOCK_ID != "") { sql += $@" and ID='{LOCK_ID}' "; } if (LOCK_LOT != "") { sql += $@" and LOCK_LOT='{LOCK_LOT}' "; } if (SN != "") { sql += $@" and SN='{SN}' "; } if (WORKORDERNO != "") { sql += $@" and WORKORDERNO='{WORKORDERNO}' "; } if (STATUS != "") { sql += $@" and LOCK_STATUS='{STATUS}'"; } if (LOCK_LOT == "" && SN == "" && WORKORDERNO == "") { sql += $@" and rownum<21 order by LOCK_TIME "; } dt = DB.ExecSelect(sql, null).Tables[0]; foreach (DataRow dr in dt.Rows) { SeqRow.loadData(dr); Seq.Add(SeqRow.GetDataObject()); } } else { string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000019", new string[] { DBType.ToString() }); throw new MESReturnMessage(errMsg); } return(Seq); }
public bool isUnLock(string LOCK_LOT, string SN, string WORKORDERNO, OleExec DB) { List <R_SN_LOCK> Seq = new List <R_SN_LOCK>(); string sql = string.Empty; bool isLock = true; if (this.DBType.Equals(DB_TYPE_ENUM.Oracle)) { sql = $@" select * from R_SN_LOCK where 1=1 and lock_status='1' "; if (LOCK_LOT != "") { sql += $@" and LOCK_LOT='{LOCK_LOT}' "; } if (SN != "") { sql += $@" and SN='{SN}' "; } if (WORKORDERNO != "") { sql += $@" and WORKORDERNO='{WORKORDERNO}' "; } if (DB.ExecSelect(sql, null).Tables[0].Rows.Count == 0) { isLock = false; } } else { string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000019", new string[] { DBType.ToString() }); throw new MESReturnMessage(errMsg); } return(isLock); }
public List <R_Station_Action_Para> GetActionParaByStationActionID(string _ID, OleExec DB) { string strsql = ""; List <R_Station_Action_Para> RET = new List <R_Station_Action_Para>(); if (DBType == DB_TYPE_ENUM.Oracle) { strsql = $@"select * from R_Station_Action_Para r where r.r_station_action_id='{_ID}' order by seq_no"; DataSet res1 = DB.ExecSelect(strsql); for (int i = 0; i < res1.Tables[0].Rows.Count; i++) { Row_R_Station_Action_Para R = (Row_R_Station_Action_Para)this.NewRow(); R.loadData(res1.Tables[0].Rows[i]); RET.Add(R.GetDataObject()); } return(RET); //Row_R_Station R = (Row_R_Station)this.GetObjByID(ID, DB); //return R; } else { string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000019", new string[] { DBType.ToString() }); throw new MESReturnMessage(errMsg); } }
public string GetMAXSAPStationCodeBySkuAndWorkorderType(string SkuNo, string WorkorderType, OleExec DB) { string result = ""; string sql = string.Empty; DataTable dt = new DataTable(); Row_C_SAP_STATION_MAP row = null; C_SAP_STATION_MAP map = null; if (DBType.Equals(DB_TYPE_ENUM.Oracle)) { sql = $@"SELECT MAX(SAP_STATION_CODE) FROM C_SAP_STATION_MAP WHERE SKUNO='{SkuNo}' AND WORKORDER_TYPE='{WorkorderType}' ORDER BY EDIT_TIME"; dt = DB.ExecSelect(sql).Tables[0]; if (dt.Rows.Count > 0) { result = dt.Rows[0][0].ToString(); } else { string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000007", new string[] { SkuNo + "," + WorkorderType }); throw new MESReturnMessage(errMsg); } } else { string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000019", new string[] { DBType.ToString() }); throw new MESReturnMessage(errMsg); } return(result); }
public int ReplaceSnKP(string newSn, string oldSn, OleExec sfcdb) { int result = 0; string sql = string.Empty; if (this.DBType == DB_TYPE_ENUM.Oracle) { sql = $@"UPDATE R_SN_KEYPART_DETAIL R SET R.SN='{newSn}' WHERE R.SN='{oldSn}'"; result = sfcdb.ExecSqlNoReturn(sql, null); } else { string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000019", new string[] { DBType.ToString() }); throw new MESReturnMessage(errMsg); } return(result); }
public override string ToString() { return(DBType.ToString()); }
public List <R_Input_Action> GetActionByInputID(string _InputID, OleExec DB) { string strsql = ""; List <R_Input_Action> RET = new List <R_Input_Action>(); if (DBType == DB_TYPE_ENUM.Oracle) { strsql = $@"select * from R_Input_Action r where r.input_id = '{_InputID}' "; DataSet res1 = DB.ExecSelect(strsql); for (int i = 0; i < res1.Tables[0].Rows.Count; i++) { Row_R_Input_Action R = (Row_R_Input_Action)this.NewRow(); R.loadData(res1.Tables[0].Rows[i]); RET.Add(R.GetDataObject()); } return(RET); } else { string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000019", new string[] { DBType.ToString() }); throw new MESReturnMessage(errMsg); } }
public Row_C_REPAIR_ITEMS GetIDByItemName(string _ItemName, OleExec DB) { string strsql = ""; if (DBType == DB_TYPE_ENUM.Oracle) { strsql = $@"select ID from c_repair_items where item_name='{_ItemName.Replace("'", "''")}'"; string ID = DB.ExecSelectOneValue(strsql)?.ToString(); if (ID == null) { string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000007", new string[] { "ItemName:" + _ItemName }); throw new MESReturnMessage(errMsg); } Row_C_REPAIR_ITEMS R = (Row_C_REPAIR_ITEMS)this.GetObjByID(ID, DB); return(R); } else { string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000019", new string[] { DBType.ToString() }); throw new MESReturnMessage(errMsg); } }
//设置web.config private void SetWebConfig(string connectionString, DBType dbType, out ConcurrentDictionary<string, string> messages) { messages = new ConcurrentDictionary<string, string>(); System.IO.FileInfo FileInfo = new FileInfo(Server.MapPath("~/web.config")); if (!FileInfo.Exists) { messages[string.Format("文件 : {0} 不存在", Server.MapPath("~/web.config"))] = ""; } XElement rootElement = XElement.Load(FileInfo.FullName); XElement connectionStringsElement = rootElement.Descendants("connectionStrings").FirstOrDefault(); if (connectionStringsElement != null && connectionStringsElement.HasElements) { XElement element = connectionStringsElement.Elements("add").LastOrDefault(n => n.NodeType != XmlNodeType.Comment); if (element != null) { try { element.Attribute("name").Value = dbType.ToString(); element.Attribute("connectionString").Value = connectionString; element.SetAttributeValue("providerName", GetProviderName(dbType)); } catch (Exception e) { messages[e.Message] = e.StackTrace; } } } rootElement.Save(FileInfo.FullName); }
public static bool SaveCurrentDBType(DBType dbType) { return(SaveConfigItem("dbType", dbType.ToString())); }
/// <summary> /// 获取安装脚本 /// </summary> /// <returns></returns> public static List <string> GetInstallFiles(DBType dbType, IList <string> applicationKeys = null, bool createAdministrator = false) { List <string> fileList = new List <string>(); if (applicationKeys == null) { applicationKeys = new List <string>() { "Common" }; var applicationsDirectory = WebUtility.GetPhysicalFilePath("~/Applications/"); foreach (string appPath in Directory.GetDirectories(applicationsDirectory)) { DirectoryInfo directoryInfo = new DirectoryInfo(appPath); if (directoryInfo != null & directoryInfo.Name != "Setup") { applicationKeys.Add(directoryInfo.Name); } } } string filePath; if (applicationKeys.Contains("Common")) { filePath = WebUtility.GetPhysicalFilePath("~/Applications/Setup/Setup/Install/" + dbType.ToString() + "/"); if (Directory.Exists(filePath)) { fileList.AddRange(Directory.GetFiles(filePath).ToList()); } } foreach (var applicationKey in applicationKeys) { filePath = WebUtility.GetPhysicalFilePath("~/Applications/" + applicationKey + "/Setup/Install/" + dbType.ToString() + "/"); if (Directory.Exists(filePath)) { fileList.AddRange(Directory.GetFiles(filePath).ToList()); } } string temp = fileList.FirstOrDefault(n => n.Contains("CreateAdministrator")); fileList.Remove(temp); if (createAdministrator) { fileList.Add(temp); } return(fileList); }
internal static SqlType Get(DBType dbType, int length) { string key = GetKeyForLengthBased(dbType.ToString(), length); SqlType result; if (!SqlTypes.TryGetValue(key, out result)) { result = new SqlType(dbType, length); lock (SqlTypes) SqlTypes.Add(key, result); } return result; }
/// <summary> /// add by fgg HWD 不看工單類型,MRB只取排序后的最後一個拋賬點 /// </summary> /// <param name="skuno"></param> /// <param name="DB"></param> /// <returns></returns> public string GetMAXSAPStationCodeBySku(string skuno, OleExec DB) { string result = ""; string sql = string.Empty; DataTable dt = new DataTable(); if (DBType.Equals(DB_TYPE_ENUM.Oracle)) { sql = $@"select sap_station_code from c_sap_station_map c where skuno = '{skuno}' order by c.sap_station_code"; dt = DB.ExecSelect(sql).Tables[0]; if (dt.Rows.Count > 0) { result = dt.Rows[dt.Rows.Count - 1]["sap_station_code"].ToString(); } else { string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000224", new string[] { skuno }); throw new MESReturnMessage(errMsg); } } else { string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000019", new string[] { DBType.ToString() }); throw new MESReturnMessage(errMsg); } return(result); }
public static IDbObject CreateDbObj(DBType dbtype,string connStr) { return CreateDbObj(dbtype.ToString(),connStr); }
public static bool SaveDBConnectString(DBType dbtype, string connectString) { return(SaveConfigItem(dbtype.ToString(), connectString)); }
public List <C_SAP_STATION_MAP> GetSAPStationMapBySkuOrderBySAPCodeASC(string SkuNo, OleExec DB) { List <C_SAP_STATION_MAP> mapList = new List <C_SAP_STATION_MAP>(); string sql = string.Empty; DataTable dt = new DataTable(); Row_C_SAP_STATION_MAP row = null; C_SAP_STATION_MAP map = null; if (DBType.Equals(DB_TYPE_ENUM.Oracle)) { sql = $@"SELECT * FROM C_SAP_STATION_MAP WHERE SKUNO='{SkuNo}' ORDER BY SAP_STATION_CODE ASC"; dt = DB.ExecSelect(sql).Tables[0]; foreach (DataRow dr in dt.Rows) { row = (Row_C_SAP_STATION_MAP)NewRow(); row.loadData(dr); map = row.GetDataObject(); mapList.Add(map); } } else { string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000019", new string[] { DBType.ToString() }); throw new MESReturnMessage(errMsg); } return(mapList); }