예제 #1
0
        string GetConnectionString()
        {
            var connection = new EntityConnection("name=KsmedEntities");
            var sqlBuild   = new SqlConnectionStringBuilder(connection.StoreConnection.ConnectionString);

            sqlBuild.Password = ConnectionStringsSecurity.DecryptPassword(sqlBuild.Password);
            return(sqlBuild.ConnectionString);
        }
예제 #2
0
        public static string GetConnectionString()
        {
            var connectionStringBuilder = new SqlConnectionStringBuilder
            {
                DataSource     = ConfigurationManager.AppSettings[DataSourceKey],
                InitialCatalog = ConfigurationManager.AppSettings[InitialCatalogKey],
                UserID         = Const.DataBaseAdminUser,
                Password       = ConnectionStringsSecurity.DecryptPassword(Const.DataBaseAdminCryptedPassword)
            };

            return(connectionStringBuilder.ConnectionString);
        }
예제 #3
0
        private static void ExportApplicationDB(string connectionString = "db")
        {
            _resources.Clear();
            var cs  = ConfigurationManager.ConnectionStrings[connectionString];
            var csb = new SqlConnectionStringBuilder(cs.ConnectionString);

            csb.Password = ConnectionStringsSecurity.DecryptPassword(csb.Password);
            using (var connection = new SqlConnection(csb.ToString()))
            {
                connection.Open();
                using (var command = connection.CreateCommand())
                {
                    string query = @"SELECT k.ResourceKey, LanguageCode, v.Value, v.Comment 
FROM AppResourceValue v LEFT JOIN AppResourceKey k ON v.ResourceId = k.ResourceId WHERE LanguageCode IN ({0})";

                    var whereQUery = new StringBuilder();
                    foreach (var culture in _appCultures)
                    {
                        whereQUery.Append("'");
                        whereQUery.Append(culture.ToString());
                        whereQUery.Append("',");
                    }
                    whereQUery.Remove(whereQUery.Length - 1, 1);

                    query = string.Format(query, whereQUery.ToString());

                    command.CommandText = query;

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            AddResource(
                                Source.ApplicationDB,
                                reader.GetString(0),
                                CultureInfo.GetCultureInfo(reader.GetString(1)),
                                reader.GetString(2),
                                reader.IsDBNull(3) ? null : reader.GetString(3)
                                );
                        }
                    }
                }
            }
        }