Example #1
0
        private string GetConnectionStringTemplate(MapDataSet.durados_SqlConnectionRow sqlConnectionRow)
        {
            int sqlProductId = sqlConnectionRow.SqlProductId;

            if (((SqlProduct)sqlProductId) == SqlProduct.MySql)
            {
                return(ConnectionStringHelper.GetConnectionStringSchema(sqlConnectionRow));
            }
            return("Data Source={0};Initial Catalog={1};User ID={2};Password={3};Integrated Security=False;");
        }
Example #2
0
        protected override void AfterDeleteBeforeCommit(Durados.DeleteEventArgs e)
        {
            base.AfterDeleteBeforeCommit(e);
            string name = e.PrevRow["Name"].ToString();

            Maps.Instance.Delete(name);

            try
            {
                int id = Convert.ToInt32(e.PrimaryKey);

                System.Data.SqlClient.SqlConnectionStringBuilder scsb = new System.Data.SqlClient.SqlConnectionStringBuilder(Maps.Instance.ConnectionString);
                string mapServer = scsb.DataSource;
                MapDataSet.durados_SqlConnectionRow systemConnectionRow = ((MapDataSet.durados_AppRow)e.PrevRow).durados_SqlConnectionRowByFK_durados_App_durados_SqlConnection_System;
                if (systemConnectionRow != null)
                {
                    string systemServer   = systemConnectionRow.IsServerNameNull() ? null : systemConnectionRow.ServerName;
                    string systemDatabase = systemConnectionRow.IsCatalogNull() ? null : systemConnectionRow.Catalog;

                    if (string.IsNullOrEmpty(systemServer) || systemServer.Equals(mapServer))
                    {
                        DropDatabase(systemDatabase);
                    }
                }

                MapDataSet.durados_SqlConnectionRow appConnectionRow = ((MapDataSet.durados_AppRow)e.PrevRow).durados_SqlConnectionRowByFK_durados_App_durados_SqlConnection;
                if (appConnectionRow != null)
                {
                    string appServer   = appConnectionRow.IsServerNameNull() ? null : appConnectionRow.ServerName;
                    string appDatabase = appConnectionRow.IsCatalogNull() ? null : appConnectionRow.Catalog;

                    if (string.IsNullOrEmpty(appServer) || appServer.Equals(mapServer))
                    {
                        if (Maps.DropAppDatabase)
                        {
                            if (!HasOtherConnectios(appDatabase))
                            {
                                DropDatabase(appDatabase);
                            }
                        }
                    }
                }

                //DeleteConfig(id);
                //DeleteUploads(id);
            }

            catch (Exception exception)
            {
                Map.Logger.Log(GetControllerNameForLog(this.ControllerContext), "AfterDeleteBeforeCommit", exception.Source, exception, 2, "delete databases and config");
            }
        }
Example #3
0
        public static string GetConnectionStringSchema(MapDataSet.durados_SqlConnectionRow sqlConnectionRow)
        {
            bool       usesSsh      = !sqlConnectionRow.IsSshUsesNull() && sqlConnectionRow.SshUses;
            bool       usesSsl      = !sqlConnectionRow.IsSslUsesNull() && sqlConnectionRow.SslUses;
            string     localPort    = sqlConnectionRow.ProductPort;
            SqlProduct sqlProductId = (SqlProduct)sqlConnectionRow.SqlProductId;

            switch ((SqlProduct)sqlProductId)
            {
            case SqlProduct.MySql:
                return(Durados.DataAccess.MySqlAccess.GetConnectionStringSchema(usesSsh));

            case SqlProduct.Postgre:
                return(Durados.DataAccess.PostgreAccess.GetConnectionStringSchema(usesSsl));

            case SqlProduct.Oracle:
                return(Durados.DataAccess.OracleAccess.GetConnectionStringSchema());

            default:
                return("Data Source={0};Initial Catalog={1};User ID={2};Password={3};Integrated Security=False;");
            }
        }
Example #4
0
 public object GetConnection(MapDataSet.durados_SqlConnectionRow sqlConnectionRow, int dataSourceTypeId, System.Data.SqlClient.SqlConnectionStringBuilder builder)
 {
     return(GetConnection(sqlConnectionRow, dataSourceTypeId, builder, GetConnectionStringTemplate(sqlConnectionRow)));
 }
Example #5
0
 public object GetConnection(MapDataSet.durados_SqlConnectionRow sqlConnectionRow, int dataSourceTypeId, object builder)
 {
     return(GetConnection(sqlConnectionRow, dataSourceTypeId, (System.Data.SqlClient.SqlConnectionStringBuilder)builder));
 }
Example #6
0
        public object GetConnection(MapDataSet.durados_SqlConnectionRow sqlConnectionRow, int dataSourceTypeId, System.Data.SqlClient.SqlConnectionStringBuilder builder, string template)
        {
            string connectionString   = null;
            string serverName         = null;
            bool?  integratedSecurity = null;

            if (dataSourceTypeId == 2 || dataSourceTypeId == 4)
            {
                if (sqlConnectionRow.IsServerNameNull())
                {
                    serverName = builder.DataSource;
                }
                else
                {
                    serverName = sqlConnectionRow.ServerName;
                }

                if (sqlConnectionRow.IsIntegratedSecurityNull())
                {
                    integratedSecurity = builder.IntegratedSecurity;
                }
                else
                {
                    integratedSecurity = sqlConnectionRow.IntegratedSecurity;
                }
            }
            else
            {
                integratedSecurity = builder.IntegratedSecurity;
                serverName         = builder.DataSource;
            }

            if (integratedSecurity.HasValue && integratedSecurity.Value)
            {
                connectionString = "Data Source={0};Initial Catalog={1};Integrated Security=True;";
                return(string.Format(connectionString, serverName, sqlConnectionRow.Catalog));
            }
            else
            {
                //connectionString = "Data Source={0};Initial Catalog={1};User ID={2};Password={3};Integrated Security=False;";
                connectionString = template;
                string username = null;
                string password = null;
                if (dataSourceTypeId == 2 || dataSourceTypeId == 4)
                {
                    if (sqlConnectionRow.IsUsernameNull())
                    {
                        username = builder.UserID;
                    }
                    else
                    {
                        username = sqlConnectionRow.Username;
                    }
                    if (sqlConnectionRow.IsPasswordNull())
                    {
                        password = builder.Password;
                    }
                    else
                    {
                        password = sqlConnectionRow.Password;
                    }
                }
                else
                {
                    username = builder.UserID;
                    password = builder.Password;
                }
                if (!sqlConnectionRow.IsProductPortNull())
                {
                    return(string.Format(connectionString, serverName, sqlConnectionRow.Catalog, username, password, sqlConnectionRow.ProductPort));
                }
                else
                {
                    return(string.Format(connectionString, serverName, sqlConnectionRow.Catalog, username, password));
                }
            }
        }