예제 #1
0
        public ResultMessage InData(DBHost host, DBInfo tmodel, SCHEMA source)
        {
            ResultMessage resultMessage = new ResultMessage();

            this.SetProgress("获取目标数据结构");
            SCHEMA      sCHEMA      = MySqlCore.GetSCHEMA(Data.Instance.InformationConnString(host), tmodel.DBName);
            MySqlScript mySqlScript = new MySqlScript(source, sCHEMA);
            TableMySQL  tableMySQL  = new TableMySQL(Data.Instance.DBConnString(host, tmodel.DBName));

            this.SetProgress("生成需要更新的脚本,并更新");
            try
            {
                foreach (string current in mySqlScript.MakeScript())
                {
                    this.SetProgress(current);
                    tableMySQL.ExecuteNonQuery(current);
                }
                this.SetProgress("更新成功");
                resultMessage.Result  = true;
                resultMessage.Message = "更新成功";
            }
            catch (Exception ex)
            {
                this.SetProgress("失败" + ex.Message);
                resultMessage.Result  = false;
                resultMessage.Message = ex.Message;
            }
            return(resultMessage);
        }
예제 #2
0
        public ResultMessage OutData(DBHost host, DBInfo model)
        {
            ResultMessage resultMessage = new ResultMessage();

            if (model.OutDBTag == null || model.OutDBTag != "")
            {
                PACKSCHEMA pACKSCHEMA = new PACKSCHEMA();
                string     text       = this.m_Path + string.Format("{0}{1:d5}_{2}.dat", model.OutDBTag, model.OutDBVersion + 1, DateTime.Now.ToString("MMddHH"));
                SCHEMA     sCHEMA     = MySqlCore.GetSCHEMA(Data.Instance.InformationConnString(host), model.DBName);
                pACKSCHEMA.PackDate = DateTime.Now;
                pACKSCHEMA.Schema   = sCHEMA;
                pACKSCHEMA.Tag      = model.OutDBTag;
                pACKSCHEMA.Version  = model.OutDBVersion + 1;
                resultMessage       = SerializeHelper.Serialize(text, pACKSCHEMA);
                if (resultMessage.Result)
                {
                    model.OutDBVersion++;
                    Data.Instance.SaveDbInfo(host, model);
                    resultMessage.Message = "导出成功\r\n" + text;
                }
            }
            else
            {
                resultMessage.Result  = false;
                resultMessage.Message = "导出标志不正确";
            }
            return(resultMessage);
        }
예제 #3
0
 public void DataInit()
 {
     this.m_DBHost = new List <DBHost>();
     if (File.Exists(this.m_HostConfigName))
     {
         ResultMessage resultMessage = SerializeHelper.XmlDeserialize <List <DBHost> >(this.m_HostConfigName);
         if (resultMessage.Result)
         {
             this.m_DBHost = (resultMessage.ObjResult as List <DBHost>);
         }
     }
     foreach (DBHost current in this.m_DBHost)
     {
         current.DBInfos = new List <DBInfo>();
         DataTable dataBase;
         try
         {
             dataBase = MySqlCore.GetDataBase(this.InformationConnString(current));
         }
         catch (Exception ex)
         {
             throw;
         }
         foreach (DataRow dataRow in dataBase.Rows)
         {
             DBInfo dBInfo = new DBInfo();
             dBInfo.DBName = dataRow["DataBase"].ToString();
             string[] dbInfo = MySqlCore.GetDbInfo(this.DBConnString(current, dBInfo.DBName));
             dBInfo.DBTag        = dbInfo[0];
             dBInfo.DBVersion    = Convert.ToInt32(dbInfo[1]);
             dBInfo.OutDBTag     = dbInfo[2];
             dBInfo.OutDBVersion = Convert.ToInt32(dbInfo[3]);
             current.DBInfos.Add(dBInfo);
         }
     }
 }
예제 #4
0
 public void SaveDbInfo(DBHost host, DBInfo model)
 {
     MySqlCore.SaveDbInfo(this.DBConnString(host, model.DBName), model.DBTag, model.DBVersion, model.OutDBTag, model.OutDBVersion);
 }