Esempio n. 1
0
        public List <DBConnInfo> Update(DBConnInfo info)
        {
            var infos = Get();

            infos[infos.FindIndex(x => x.Id == info.Id)] = info;
            return(Save(infos));
        }
Esempio n. 2
0
        public List <DBConnInfo> Add(DBConnInfo info)
        {
            var infos = Get();

            infos.Add(info);
            return(Save(infos));
        }
Esempio n. 3
0
 public static string ExportDefinitionToTempCompareFile(DBConnInfo info, string objName, string file = "")
 {
     if (string.IsNullOrWhiteSpace(file))
     {
         file = $@".\temp\{info.Server}_{info.DBName}_{objName}.sql";
     }
     return(ExportDefinitionToFile(info, objName, file));
 }
Esempio n. 4
0
        public List <DBConnInfo> Delete(DBConnInfo info)
        {
            var infos = Get();

            infos.RemoveAll(x => x.Id == info.Id);
            Save(infos);
            return(infos);
        }
Esempio n. 5
0
 private void SwitchDB(DBConnInfo info)
 {
     CurrDBConnInfo  = info;
     tSSLName.Text   = $"Name : {CurrDBConnInfo.DBTxt}";
     tSSLServer.Text = $"Server : {CurrDBConnInfo.Server}";
     tSSLDBName.Text = $"DB : {CurrDBConnInfo.DBName}";
     db = new DBHelper(SqlClientFactory.Instance, CurrDBConnInfo.GetConnectionString());
     DGVObject.DataSource    = null;
     DGVSqlResult.DataSource = null;
 }
Esempio n. 6
0
        public static string ExportDefinitionToFile(DBConnInfo info, string objName, string file)
        {
            var dir = Path.GetDirectoryName(file);

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            var definition = GetDefinition(info, objName);

            File.WriteAllText(file, definition);
            return(Path.GetFullPath(file));
        }
Esempio n. 7
0
        public FmDBConnInfoUpsert(DBConnInfo info)
        {
            if (info == null)
            {
                this.connInfo = new DBConnInfo();
                maintainMode  = MaintainMode.Create;
            }
            else
            {
                this.connInfo = info;
                maintainMode  = MaintainMode.Update;
            }

            InitializeComponent();
            txtDBtxt.DataBindings.Add("Text", connInfo, "DBTxt", true);
            txtServer.DataBindings.Add("Text", connInfo, "Server", true);
            txtDBName.DataBindings.Add("Text", connInfo, "DBName", true);
            txtLoginId.DataBindings.Add("Text", connInfo, "LoginId", true);
            txtLoginPw.DataBindings.Add("Text", connInfo, "LoginPw", true);
        }
Esempio n. 8
0
        public static string SyncObj(DBConnInfo sour, DBConnInfo trgt, string objName)
        {
            try
            {
                var type = GetObjType(sour, objName);
                if (!SqlObjTypeFullName.ContainsKey(type))
                {
                    return($"該物件類型{type}尚不支援同步功能");
                }

                var typeName = SqlObjTypeFullName[type];
                var sql      = $@"if exists(select 1 from sys.sysobjects where name = {{0}}) Drop {typeName} [{objName}];
                EXEC dbo.sp_executesql @statement = {{1}}";
                var db       = new DBHelper(SqlClientFactory.Instance, trgt.GetConnectionString());
                db.ExecuteNonQuery(sql, objName, GetDefinition(sour, objName));
                return(string.Empty);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Esempio n. 9
0
        public static string GetObjType(DBConnInfo info, string objName)
        {
            var db = new DBHelper(SqlClientFactory.Instance, info.GetConnectionString());

            return(db.ExecuteScalar <String>("select type from sys.sysobjects where name = {0}", objName).Trim());
        }
Esempio n. 10
0
        public static string GetDefinition(DBConnInfo info, string objName)
        {
            var db = new DBHelper(SqlClientFactory.Instance, info.GetConnectionString());

            return(db.ExecuteScalar <String>("select b.definition from sys.sysobjects a, sys.sql_modules b where a.name = {0} and a.id=b.object_id", objName));
        }