protected override bool Initialize()
 {
     lock (this)
     {
         if (!this.initialized)
         {
             ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider();
             if (config != null)
             {
                 ConfigurationParameter param = config.Get(typeof(PgUserPasswordHistoryProviderFactory), "connectionString");
                 if (param != null)
                 {
                     string tName = param.Value as string;
                     if (!string.IsNullOrEmpty(tName))
                     {
                         if (NpgSqlCommandUtils.TestConnection(tName))
                         {
                             Db.ConnectionString = tName;
                             this.initialized    = true;
                             return(true);
                         }
                     }
                 }
             }
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
        protected override void InitializeImpl()
        {
            lock (instance)
            {
                if (RuntimeUtils.Initializable(this.State))
                {
                    string meth = "Initialize";
                    this.State  = RunState.Initializing;
                    this.logger = LogManager.Instance.GetProvider(typeof(EntityBundleManager));
                    Log(meth, LogLevel.Info, "Called");

                    ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider();
                    if (config != null)
                    {
                        ConfigurationParameter param = config.Get(typeof(EntityBundleProvider), "connectionString");
                        if (param != null)
                        {
                            string tName = param.Value as string;
                            if (!string.IsNullOrEmpty(tName))
                            {
                                if (NpgSqlCommandUtils.TestConnection(tName))
                                {
                                    Db.ConnectionString = tName;
                                    Log(meth, LogLevel.Info, "Succeeded");
                                    this.State = RunState.Initialized;
                                    return;
                                }
                            }
                            else
                            {
                                Log(meth, LogLevel.Error, "Failed to get connectionString param value");
                            }
                        }
                        else
                        {
                            Log(meth, LogLevel.Error, "Failed to get connectionString param");
                        }
                    }
                    else
                    {
                        Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider");
                    }


                    this.State = RunState.FailedInitializing;
                }
            }
        }
Ejemplo n.º 3
0
        protected override void InitializeImpl()
        {
            lock (instance)
            {
                if (RuntimeUtils.Initializable(this.State))
                {
                    string meth = "Initialize";
                    this.State  = RunState.Initializing;
                    this.logger = LogManager.Instance.GetProvider(typeof(UserAffilationSecurityManager));
                    Log(meth, LogLevel.Info, "Called");

                    ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider();
                    if (config != null)
                    {
                        ConfigurationParameter param = config.Get(NameReflectionUtils.GetType(TypeNameReference.Parse("Osrs.WellKnown.FieldActivities.Providers.PgFieldActivityProviderFactory, Osrs.WellKnown.FieldActivities.Providers.Postgres")), "connectionString");
                        if (param != null)
                        {
                            string tName = param.Value as string;
                            if (!string.IsNullOrEmpty(tName))
                            {
                                if (NpgSqlCommandUtils.TestConnection(tName))
                                {
                                    Db.ConnectionString = tName;
                                    this.initialized    = true;
                                    this.State          = RunState.Initialized;
                                    return;
                                }
                            }
                            else
                            {
                                Log(meth, LogLevel.Error, "Failed to get connectionString param value");
                            }
                        }
                        else
                        {
                            Log(meth, LogLevel.Error, "Failed to get connectionString param");
                        }
                    }
                    else
                    {
                        Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider");
                    }


                    this.State = RunState.FailedInitializing;
                }
            }
        }
Ejemplo n.º 4
0
        protected override bool Initialize()
        {
            lock (instance)
            {
                if (!this.initialized)
                {
                    string meth = "Initialize";
                    this.logger = LogManager.Instance.GetProvider(myType);
                    Log(meth, LogLevel.Info, "Called");

                    ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider();
                    if (config != null)
                    {
                        ConfigurationParameter param = config.Get(myType, "connectionString");
                        if (param != null)
                        {
                            string tName = param.Value as string;
                            if (!string.IsNullOrEmpty(tName))
                            {
                                if (NpgSqlCommandUtils.TestConnection(tName))
                                {
                                    Db.ConnectionString = tName;
                                    this.initialized    = true;
                                    return(true);
                                }
                            }
                            else
                            {
                                Log(meth, LogLevel.Error, "Failed to get connectionString param value");
                            }
                        }
                        else
                        {
                            Log(meth, LogLevel.Error, "Failed to get connectionString param");
                        }
                    }
                    else
                    {
                        Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider");
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 5
0
        internal bool Init()
        {
            string meth = "Initialize";

            this.logger = LogManager.Instance.GetProvider(typeof(DetRegistry));
            Log(meth, LogLevel.Info, "Called");

            ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider();

            if (config != null)
            {
                ConfigurationParameter param = config.Get(typeof(DetRegistry), "connectionString");
                if (param != null)
                {
                    string tName = param.Value as string;
                    if (!string.IsNullOrEmpty(tName))
                    {
                        if (NpgSqlCommandUtils.TestConnection(tName))
                        {
                            this.connString = tName;
                            Log(meth, LogLevel.Info, "Succeeded");
                            return(true);
                        }
                    }
                    else
                    {
                        Log(meth, LogLevel.Error, "Failed to get connectionString param value");
                    }
                }
                else
                {
                    Log(meth, LogLevel.Error, "Failed to get connectionString param");
                }
            }
            else
            {
                Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider");
            }
            return(false);
        }