예제 #1
0
파일: Sync.cs 프로젝트: KeliBox/CK_Sync
        /// <summary>
        /// 同步Oracle数据
        /// </summary>
        /// <param name="dbORA">Oracle数据库连接</param>
        /// <param name="dbMDB">mdb数据库连接</param>
        /// <returns></returns>
        public static bool SynORA(DatabaseORC dbORA, DatabaseOledb dbMDB)
        {
            try
            {
                bool b = true;

                string    mdbSQL = "select * from 采矿申请登记 where 签发时间 is not null";
                DataTable dt     = dbMDB.GetDataSet(mdbSQL).Tables[0];
                DataRow   dr     = null;
                string    oraSQL = string.Empty;
                string    upSQL  = string.Empty;

                #region 更新『采矿申请登记』表
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dr     = dt.Rows[i];
                    oraSQL = "select * from 采矿申请登记 where 项目档案号='" + dr["项目档案号"] + "' and 签发时间=to_date('" + dr["签发时间"] + "','yyyy-mm-dd hh24:mi:ss')";
                    DataSet ds = dbORA.GetDataSet(oraSQL);
                    if (!(ds.Tables[0].Rows.Count > 0))
                    {
                        upSQL = UpdateSQL(dr, "采矿申请登记");
                        dbORA.ExecuteSql(upSQL);
                    }
                }
                #endregion

                #region 更新『项目档案』表
                mdbSQL = "select * from 项目档案 where 签发时间 is not null";
                dt     = dbMDB.GetDataSet(mdbSQL).Tables[0];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dr = dt.Rows[i];
                    //oraSQL = "select * from 采矿申请登记 where 项目档案号='" + dr["项目档案号"] + "' and 签发时间 is not null and to_char(签发时间,'yyyy-mm-dd,hh:mi:ss')='" + dr["签发时间"] + "'";
                    oraSQL = "select * from 项目档案 where 项目档案号='" + dr["项目档案号"] + "' and 签发时间=to_date('" + dr["签发时间"] + "','yyyy-mm-dd hh24:mi:ss')";
                    DataSet ds = dbORA.GetDataSet(oraSQL);

                    if (!(ds.Tables[0].Rows.Count > 0))
                    {
                        upSQL = UpdateSQL(dr, "项目档案");
                        dbORA.ExecuteSql(upSQL);
                    }
                }
                #endregion

                return(b);
            }
            catch (Exception ex)
            {
                Log.WriteLog("SynORA同步错误>>>>" + ex.Message);
                errorMsg = "同步MapGIS一张图数据库时出错,请检查相关配置信息!";
                return(false);

                throw ex;
            }
        }
예제 #2
0
파일: MainFrm.cs 프로젝트: KeliBox/CK_Sync
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_OADbTest_Click(object sender, EventArgs e)
 {
     try
     {
         string sMessage = "";
         bool   b        = DatabaseORC.TestOracleConn(txt_OA_DBIP.Text, txt_OA_DBPort.Text, txt_OA_DBName.Text, txt_OA_DBUserName.Text, txt_OA_DBPassword.Text, ref sMessage);
         if (b)
         {
             MessageBox.Show(sMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show(sMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         throw ex;
     }
 }
예제 #3
0
파일: MainFrm.cs 프로젝트: KeliBox/CK_Sync
        private void SyncData()
        {
            try
            {
                DialogResult ret = MessageBox.Show("同步之前请检查、测试各项设置并保存!", "注意", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (ret == DialogResult.Yes)
                {
                    //Log.WriteDebug("确认");
                    //Log.WriteLog("确认");
                    DatabaseOledb dbMDB = new DatabaseOledb(Config.GetConfigValue("MDB_ConnectString"));//MDB连接

                    #region Oracle连接串StringBuilder ora_Conn
                    StringBuilder ora_Conn = new StringBuilder("Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=");
                    ora_Conn.Append(Config.GetConfigValue("OA_DBIP"));
                    ora_Conn.Append(")(PORT=");
                    ora_Conn.Append(Config.GetConfigValue("OA_DBPort"));
                    ora_Conn.Append(")))(CONNECT_DATA=(SERVICE_NAME=");
                    ora_Conn.Append(Config.GetConfigValue("OA_DBName"));
                    ora_Conn.Append(")));User Id=");
                    ora_Conn.Append(Config.GetConfigValue("OA_DBUserName"));
                    ora_Conn.Append(";Password="******"OA_DBPassword"));
                    ora_Conn.Append(";");
                    #endregion

                    DatabaseORC dbORA = new DatabaseORC(ora_Conn.ToString());



                    #region  步数据

                    string IGSUri = Config.GetConfigValue("IGS_PATH");

                    #region MDBSyn=false
                    if (Config.GetConfigValue("MDBSyn") == "false")
                    {
                        MessageBox.Show("请检查采矿权数据库配置并保存!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    #endregion

                    #region OASyn=true
                    else if (Config.GetConfigValue("OASyn") == "true")
                    {
                        #region OASyn/IGSSyn都为true
                        if (Config.GetConfigValue("IGSSyn") == "true")
                        {
                            if (Sync.SynORA(dbORA, dbMDB) && Sync.SynIGS(dbMDB, IGSUri))
                            {
                                MessageBox.Show("成功!", "同步成功", MessageBoxButtons.OK, MessageBoxIcon.None);
                                return;
                            }
                            else
                            {
                                MessageBox.Show(Sync.errorMsg.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        #endregion

                        #region IGSSyn为false
                        else
                        {
                            if (Sync.SynORA(dbORA, dbMDB))
                            {
                                MessageBox.Show("成功!", "同步成功", MessageBoxButtons.OK, MessageBoxIcon.None);
                                return;
                            }
                            else
                            {
                                MessageBox.Show(Sync.errorMsg.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        #endregion
                    }
                    #endregion

                    #region OASyn=false/IGSSyn=true
                    else if (Config.GetConfigValue("IGSSyn") == "true")
                    {
                        if (Sync.SynIGS(dbMDB, IGSUri))
                        {
                            MessageBox.Show("成功!", "同步成功", MessageBoxButtons.OK, MessageBoxIcon.None);
                            return;
                        }
                        else
                        {
                            MessageBox.Show("图形同步失败,请检查配置并保存!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            //Log.WriteLog("IGSSyn错误『OASyn=false/IGSSyn=true』>>>>" + errorMsg);
                            return;
                        }
                    }
                    #endregion

                    #region MDBSyn=true&&OASyn=false&&IGSSyn=false
                    else
                    {
                        MessageBox.Show("请检查MapGIS一张图政务/图形同步设置并保存!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Question);
                        return;
                    }
                    #endregion
                    #endregion
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }