Ejemplo n.º 1
0
 public FLSequentialWorkflow()
 {
     _timeUnit = TimeUnit.Day;
     _urgentTime = 0;
     _expTime = 0;
     _orgKind = "0";
     _connectionType = DbConnectionType.SqlClient;
     //_keys = new KeyItems(this, typeof(KeyItem));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 获取数据库连接(读写分离)
 /// </summary>
 /// <param name="connectionType">读写分离</param>
 /// <returns></returns>
 public static IDbConnection CetDbConnection(DbConnectionType connectionType)
 {
     if (connectionType == DbConnectionType.Write)
     {
         return(GetInstance.GetWriteDbConnection());
     }
     else
     {
         return(GetInstance.GetReadDbConnection());
     }
 }
Ejemplo n.º 3
0
            public static IDbConnection createConnection(DbConnectionType dbConnType)
            {
                switch (dbConnType)
                {
                    case DbConnectionType.Oracle:
                        return new OracleDbConnection();
                    case DbConnectionType.MySql:
                        return new MySqlDbConnection();
                    case DbConnectionType.MsSql:
                        return new MsSqlDbConnection();
                }

                return null;
            }
Ejemplo n.º 4
0
        public static T CreateDbContext <T>(DbConnectionType connectionType, string connectionString) where T : DbContext
        {
            switch (connectionType)
            {
            case DbConnectionType.MySql:
                var mysql_connection = new MySqlConnection(connectionString);
                return((T)Activator.CreateInstance(typeof(T), new object[] { mysql_connection, true }));

            case DbConnectionType.SqLite:
                var sqlite_connection = new SQLiteConnection(connectionString);
                sqlite_connection.Open();
                return((T)Activator.CreateInstance(typeof(T), new object[] { sqlite_connection, true }));

            default:
                return(null);
            }
        }
Ejemplo n.º 5
0
        ///////////////////////////////////////////////////////////////////////

        public static ReturnCode CreateDbConnection(
            Interpreter interpreter,
            DbConnectionType dbConnectionType,
            string connectionString,
            string typeFullName,
            string typeName,
            ValueFlags valueFlags,
            ref IDbConnection connection,
            ref Result error
            )
        {
            return(CreateDbConnection(interpreter, dbConnectionType,
                                      connectionString, typeFullName, typeName, valueFlags,
                                      GetOtherDbConnectionTypeNames(true, false),
                                      GetOtherDbConnectionTypeNames(false, false),
                                      ref connection, ref error));
        }
Ejemplo n.º 6
0
        public static DbConnection Create(String connection, DbConnectionType type = DbConnectionType.MySQL)
        {
            DbConnection cn = type switch
            {
                DbConnectionType.MySQL => new MySqlConnection(connection),
                DbConnectionType.SQLite => new SqliteConnection(connection),
                _ => throw new ArgumentException(nameof(type))
            };

            try
            {
                cn.Open();
            }
            catch (Exception)
            {
                return(null);
            }

            return(cn);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="alias"></param>
        /// <param name="dbConnectionType"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        private static string GetConnectionString(string alias, out DbConnectionType dbConnectionType, bool b)
        {
            alias = b ? GetSplitSysDB(alias) : alias;

            String xmlName = SystemFile.DBFile;
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(xmlName);

            XmlNode node = xmlDoc.FirstChild.FirstChild.SelectSingleNode(alias);

            string DbString = "";
            string Pwd = "";
            if (node != null)
            {
                DbString = node.Attributes["String"].Value.Trim();
                Pwd = GetPwdString(node.Attributes["Password"].Value.Trim());
            }
            if (DbString.Length > 0 && Pwd.Length > 0 && Pwd != string.Empty)
            {
                if (DbString[DbString.Length - 1] != ';')
                    DbString = DbString + ";Password="******"Password="******"1";
            if (node != null)
            {
                value = node.Attributes["Type"].Value;
                if (value == "1")
                {
                    dbConnectionType = DbConnectionType.SqlClient;
                }
                else if (value == "2")
                {
                    dbConnectionType = DbConnectionType.OleDb;
                }
                else if (value == "3")
                {
                    dbConnectionType = DbConnectionType.OracleClient;
                }
                else if (value == "4")
                {
                    dbConnectionType = DbConnectionType.Odbc;
                }
                else if (value == "5")
                {
                    dbConnectionType = DbConnectionType.MySQL;
                }
                else if (value == "6")
                {
                    dbConnectionType = DbConnectionType.Informix;
                }
                else
                {
                    dbConnectionType = DbConnectionType.SqlClient;
                }
            }
            else
            {
                dbConnectionType = DbConnectionType.SqlClient;
            }

            return DbString;
        }
Ejemplo n.º 8
0
		/// <summary>
		/// Loads a config file into a XMLDocument and populates a DBConnectionTypes collection of the 
		/// database connection details found in the config file. 
		/// </summary>
		/// <param name="config">The name (and path) of a config file containing <connection> elements</param>
		/// <returns>A Collection of Connection Types</returns>
		private DbConnectionTypes LoadConfig ( string config ) {

			try {
				this.ReadXml(config);
				DbConnectionTypes connectionTypes = new DbConnectionTypes();
				DataRow connectionsRow = this.Tables["connections"].Rows[0];

				// Read the available connections from the connections collection
				// --------------------------------------------------------------
				foreach (DataRow connectionRow in connectionsRow.GetChildRows("connections_connection")) {

					DbConnectionType connectionType = new DbConnectionType();
					connectionType.Name = connectionRow["name"].ToString();
					connectionType.DbTypeName = connectionRow["type"].ToString();
					connectionType.InternalProviderName = connectionRow["internalProvider"].ToString();

					// Read the Settings for this connection type
					// --------------------------------------------------------------
					foreach (DataRow settingsRow in connectionRow.GetChildRows("connection_settings")) {
						if (settingsRow.Table.Columns.Contains("file"))		{
							connectionType.SupportsFile = GetSettingState(settingsRow["file"].ToString(),false);
							connectionType.PromptFile   = GetSettingValue(settingsRow["file"].ToString());
						}
						if (settingsRow.Table.Columns.Contains("server"))		{
							connectionType.SupportsServer = GetSettingState(settingsRow["server"].ToString(),true);
							connectionType.PromptServer   = GetSettingValue(settingsRow["server"].ToString());
						}
						if (settingsRow.Table.Columns.Contains("name"))		{
							connectionType.SupportsName = GetSettingState(settingsRow["name"].ToString(),true);
							connectionType.PromptName   = GetSettingValue(settingsRow["name"].ToString());
						}
						if (settingsRow.Table.Columns.Contains("userid"))		{
							connectionType.SupportsUserID = GetSettingState(settingsRow["userid"].ToString(),true);
							connectionType.PromptUserID   = GetSettingValue(settingsRow["userid"].ToString());
						}
						if (settingsRow.Table.Columns.Contains("password"))		{
							connectionType.SupportsPassword = GetSettingState(settingsRow["password"].ToString(),true);
							connectionType.PromptPassword   = GetSettingValue(settingsRow["password"].ToString());
						}
						if (settingsRow.Table.Columns.Contains("filter"))		{
							connectionType.SupportsFilter = GetSettingState(settingsRow["filter"].ToString(),false);
							connectionType.PromptFilter   = GetSettingValue(settingsRow["filter"].ToString());
						}
					}

					// Read each of the Providers Details
					// --------------------------------------------------------------
					foreach (DataRow providersRow in connectionRow.GetChildRows("connection_providers")) {
						foreach (DataRow providerRow in providersRow.GetChildRows("providers_provider")) {

							DbConnectionProvider connectionProvider = new DbConnectionProvider();
							connectionProvider.Name = providerRow["name"].ToString();
							connectionProvider.ProviderTypeName = providerRow["type"].ToString();
							connectionProvider.Parent = connectionType;
							connectionProvider.Template = Regex.Replace(providerRow["provider_Text"].ToString(), @"[\r\t\n]", "");

							if (providerRow.Table.Columns.Contains("allowEmptyParameters")) connectionProvider.AllowEmptyParameters = GetSettingState(providerRow["allowEmptyParameters"].ToString(), true);
							if (providerRow.Table.Columns.Contains("enabled")) connectionProvider.Enabled = GetSettingState(providerRow["enabled"].ToString(),true);
							if (providerRow.Table.Columns.Contains("fileMask")) connectionProvider.FileMask = providerRow["fileMask"].ToString();

							connectionType.Providers.Add(connectionProvider); 
						}
					}
					connectionTypes.Add(connectionType);
				}
				return connectionTypes;
			}
			catch (Exception ex) {
				throw new ApplicationException(String.Format("Could not reference the ProviderConfig.xml configuration file: {0}\n{1}", config, ex.Message));
			}
		}
Ejemplo n.º 9
0
 public DatabasePokayoke(string name, string connectionString, DbConnectionType dbType) : base()
 {
     _connectionString = connectionString; _dbType = dbType; Title = string.Format("{0} Database Available", name);
 }
Ejemplo n.º 10
0
 public DatabasePokayoke(string connectionString, DbConnectionType dbType) : base()
 {
     _connectionString = connectionString; _dbType = dbType; Title = string.Format("{0} Available", DatabaseCatalog.Name(connectionString));
 }
		public DbConnectionProvider( string name, string type, string template, DbConnectionType parent) {
			Name			 = name;
			Template		 = template;
			ProviderTypeName = type;
			Parent			 = parent;
		}
Ejemplo n.º 12
0
        ///////////////////////////////////////////////////////////////////////

        public static ReturnCode CreateDbConnection(
            Interpreter interpreter,
            DbConnectionType dbConnectionType,
            string connectionString,
            string typeFullName,
            string typeName,
            ValueFlags valueFlags,
            DbConnectionTypeStringDictionary dbConnectionTypeFullNames,
            DbConnectionTypeStringDictionary dbConnectionTypeNames,
            ref IDbConnection connection,
            ref Result error
            )
        {
            try
            {
                switch (dbConnectionType)
                {
                case DbConnectionType.None:
                {
                    //
                    // NOTE: The caller explicitly requested an invalid
                    //       database connection; therefore, return one.
                    //
                    connection = null;
                    return(ReturnCode.Ok);
                }

                case DbConnectionType.Odbc:
                {
                    connection = new OdbcConnection(connectionString);
                    return(ReturnCode.Ok);
                }

                case DbConnectionType.OleDb:
                {
                    connection = new OleDbConnection(connectionString);
                    return(ReturnCode.Ok);
                }

                case DbConnectionType.Sql:
                {
                    connection = new SqlConnection(connectionString);
                    return(ReturnCode.Ok);
                }

                case DbConnectionType.Other:
                {
                    return(CreateOtherDbConnection(
                               interpreter, dbConnectionType, connectionString,
                               typeFullName, typeName, valueFlags, ref connection,
                               ref error));
                }

                default:
                {
                    //
                    // NOTE: Lookup the type name and/or full name and
                    //       then go to the "other" case (for database
                    //       connection types that are not "built-in").
                    //
                    bool found = false;

                    if ((dbConnectionTypeFullNames != null) &&
                        dbConnectionTypeFullNames.TryGetValue(
                            dbConnectionType, out typeFullName))
                    {
                        found = true;
                    }

                    if ((dbConnectionTypeNames != null) &&
                        dbConnectionTypeNames.TryGetValue(
                            dbConnectionType, out typeName))
                    {
                        found = true;
                    }

                    if (found)
                    {
                        goto case DbConnectionType.Other;
                    }

                    error = String.Format(
                        "unsupported database connection type \"{0}\"",
                        dbConnectionType);

                    break;
                }
                }
            }
            catch (Exception e)
            {
                error = e;
            }

            return(ReturnCode.Error);
        }
Ejemplo n.º 13
0
        ///////////////////////////////////////////////////////////////////////

        private static ReturnCode CreateOtherDbConnection(
            Interpreter interpreter,
            DbConnectionType dbConnectionType,
            string connectionString,
            string typeFullName,
            string typeName,
            ValueFlags valueFlags,
            ref IDbConnection connection,
            ref Result error
            )
        {
            if (interpreter == null)
            {
                error = "invalid interpreter";
                return(ReturnCode.Error);
            }

            if (String.IsNullOrEmpty(typeFullName) &&
                String.IsNullOrEmpty(typeName))
            {
                error = String.Format(
                    "invalid type name for database connection type \"{0}\"",
                    dbConnectionType);

                return(ReturnCode.Error);
            }

            ResultList errors = null;

            foreach (string thisTypeName in new string[] {
                typeFullName, typeName
            })
            {
                if (!String.IsNullOrEmpty(thisTypeName))
                {
                    try
                    {
                        Type type = null;

                        if (Value.GetType(
                                interpreter, thisTypeName, null,
                                interpreter.GetAppDomain(), valueFlags,
                                interpreter.CultureInfo, ref type,
                                ref errors) == ReturnCode.Ok)
                        {
                            connection = (IDbConnection)Activator.CreateInstance(
                                type, new object[] { connectionString });

                            return(ReturnCode.Ok);
                        }
                    }
                    catch (Exception e)
                    {
                        if (errors == null)
                        {
                            errors = new ResultList();
                        }

                        errors.Add(e);
                    }
                }
            }

            error = errors;
            return(ReturnCode.Error);
        }
Ejemplo n.º 14
0
 //DbConnectionType  is a custom enum
 public MultiSqlCommand(DbConnectionType connType, DbConnection conn)
 {
Ejemplo n.º 15
0
 public bool Equals(GenericDbConnectionInfo?other) => other != null && DbConnectionType.Equals(other.DbConnectionType) && DataReaderType.Equals(other.DataReaderType);