示例#1
0
        public ConnectionResult connectionToRemoteDatabase()
        {
            remoteExcuteDataBase = new RemoteExcuteDataBase(DataBaseInfo.IP, DataBaseInfo.database, DataBaseInfo.userid, DataBaseInfo.password);
            if (!remoteExcuteDataBase.connectionToRemoteDatabase().Sucessd)
            {
                BussnessLog.WriteBussnessLog(remoteExcuteDataBase, "DATABASE", "");
                remoteExcuteDataBase.Result = false;
            }
            remoteExcuteDataBase.Result = true;
            ConnectionResult result = remoteExcuteDataBase.connectionToRemoteDatabase();

            return(result);
        }
示例#2
0
        public void excuteSQL(string model, ConnectionResult result, Context ctx)
        {
            BussnessLog.WriteBussnessLog("", model + "更新", "开始更新");
            if (string.Equals(CustomerSQLObject.Customer, model, StringComparison.CurrentCultureIgnoreCase))
            {
                SQLStatement       = "SELECT FNUMBER,FNAME FROM T_KF_CUSTOMER WHERE FSTATUS = 3";
                UpdateSQLStatement = "UPDATE T_BD_CUSTOMER_L SET FNAME = '{0}' WHERE FCUSTID = (SELECT FCUSTID FROM T_BD_CUSTOMER WHERE FNUMBER = '{1}')";
                UpdateSQLStatementList.Add(UpdateSQLStatement);
            }
            if (string.Equals(SupplierSQLObject.Supplier, model, StringComparison.CurrentCultureIgnoreCase))
            {
                SQLStatement        = "SELECT FNUMBER,FNAME,FOPENBANKNAME,FBANKCODE FROM T_KF_SUPPLIER WHERE FSTATUS = 3";
                UpdateSQLStatement1 = " UPDATE T_BD_SUPPLIER_L SET FNAME = '{0}' WHERE FSUPPLIERID IN (SELECT FSUPPLIERID FROM T_BD_SUPPLIER WHERE FNUMBER='{1}')";
                UpdateSQLStatement2 = " UPDATE T_BD_SUPPLIERBANK SET FBANKCODE = '{0}' WHERE FSUPPLIERID IN (SELECT FSUPPLIERID FROM T_BD_SUPPLIER WHERE FNUMBER='{1}')";
                UpdateSQLStatement3 = "UPDATE T_BD_SUPPLIERBANK_L SET FOPENBANKNAME = '{0}' WHERE FBANKID IN (SELECT  FBANKID FROM T_BD_SUPPLIER T1 LEFT JOIN T_BD_SUPPLIERBANK T2 ON T1.FSUPPLIERID = T2.FSUPPLIERID WHERE T1.FNUMBER ='{1}')";
                UpdateSQLStatementList.Add(UpdateSQLStatement1);
                UpdateSQLStatementList.Add(UpdateSQLStatement2);
                UpdateSQLStatementList.Add(UpdateSQLStatement3);
            }
            RemoteExcuteDataBase dbOjbect   = new RemoteExcuteDataBase(DataBaseInfo.IP, DataBaseInfo.database, DataBaseInfo.userid, DataBaseInfo.password);
            ExcuteDataBaseResult dataResult = dbOjbect.excuteStatement(SQLStatement, result.Sqlconn);

            if (dataResult.Ds.Tables[0].Rows.Count <= 0)
            {
                BussnessLog.WriteBussnessLog("", model + "更新", "无字段需要更新");
                return;
            }
            //取数
            Dictionary <string, UpdateFields> updateMap = getUpdateFields(model, dataResult);

            //更新金蝶数据库
            if (updateKingDeeDataBase(model, UpdateSQLStatementList, updateMap, ctx))
            {
                //更新中间表数据库
                updateMiddleDataBase(model, dataResult, result, dbOjbect);
                BussnessLog.WriteBussnessLog("", model + "更新", "更新金蝶数据库成功!");
            }


            //关闭
            //if (dbOjbect.closeConnection(result.Sqlconn))
            //{
            //    BussnessLog.WriteBussnessLog("", model + "更新", "更新结束,关闭数据库连接成功!");
            //}
            //else {
            //    BussnessLog.WriteBussnessLog("", model + "更新", "更新结束,关闭数据库连接失败!");
            //}
        }
示例#3
0
 public void updateMiddleDataBase(string model, ExcuteDataBaseResult dataResult, ConnectionResult result, RemoteExcuteDataBase dbOjbect)
 {
     if (string.Equals(CustomerSQLObject.Customer, model, StringComparison.CurrentCultureIgnoreCase))
     {
         foreach (string s in CustomerFnunbers)
         {
             SQLStatement = "UPDATE T_KF_CUSTOMER SET FSTATUS = 1, FResultMessage=' ', FLASTUPDATETIME='{0}' WHERE FNUMBER = '{1}'";
             string mSQL = string.Format(SQLStatement, System.DateTime.Now, s);
             ExcuteDataBaseResult excuteResult = dbOjbect.excuteStatement(mSQL, result.Sqlconn);
             if (!excuteResult.Sucessd)
             {
                 BussnessLog.WriteBussnessLog("", model + "更新", "更新中间表失败! fnumber=" + s);
             }
             else
             {
                 BussnessLog.WriteBussnessLog("", model + "更新", "更新中间表成功!");
             }
         }
     }
     if (string.Equals(SupplierSQLObject.Supplier, model, StringComparison.CurrentCultureIgnoreCase))
     {
         foreach (string s in SupplierFnumbers)
         {
             SQLStatement = "UPDATE T_KF_SUPPLIER SET FSTATUS = 1, FResultMessage=' ', FLastUpdateTime = '{0}'  WHERE FNUMBER = '{1}'";
             string mSQL = string.Format(SQLStatement, System.DateTime.Now, s);
             ExcuteDataBaseResult excuteResult = dbOjbect.excuteStatement(mSQL, result.Sqlconn);
             if (!excuteResult.Sucessd)
             {
                 BussnessLog.WriteBussnessLog("", model + "更新", "更新中间表失败! fnumber = " + s);
             }
             else
             {
                 BussnessLog.WriteBussnessLog("", model + "更新", "更新中间表成功!");
             }
         }
     }
 }