/// <summary>
        /// 数据源 run sql ,返回table .
        /// </summary>
        /// <param name="selectSql"></param>
        /// <returns></returns>
        public DataTable FromDBUrlRunSQLReturnTable(string selectSql)
        {
            // 得到数据源.
            DataTable dt = new DataTable();

            switch (this.FromDBUrl)
            {
            case DBUrlType.AppCenterDSN:
                dt = DBAccess.RunSQLReturnTable(selectSql);
                break;

            case DBUrlType.DBAccessOfMSMSSQL:
                dt = DBAccessOfMSMSSQL.RunSQLReturnTable(selectSql);
                break;

            case DBUrlType.DBAccessOfODBC:
                dt = DBAccessOfODBC.RunSQLReturnTable(selectSql);
                break;

            case DBUrlType.DBAccessOfOLE:
                dt = DBAccessOfOLE.RunSQLReturnTable(selectSql);
                break;

            case DBUrlType.DBAccessOfOracle:
                dt = DBAccessOfOracle.RunSQLReturnTable(selectSql);
                break;

            //case DBUrlType.DBAccessOfOracle1:
            //    dt=DBAccessOfOracle1.RunSQLReturnTable( selectSql );
            //    break;
            default:
                break;
            }
            return(dt);
        }
示例#2
0
文件: EnDa.cs 项目: zhaoyingju/ccflow
        public static int Retrieve(Entity en, string sql, Paras paras)
        {
            DataTable dt;

            switch (en.EnMap.EnDBUrl.DBUrlType)
            {
            case DBUrlType.AppCenterDSN:
                dt = DBAccess.RunSQLReturnTable(sql, paras);
                break;

            case DBUrlType.DBAccessOfMSMSSQL:
                dt = DBAccessOfMSMSSQL.RunSQLReturnTable(sql);
                break;

            case DBUrlType.DBAccessOfOracle:
                dt = DBAccessOfOracle.RunSQLReturnTable(sql);
                break;

            default:
                throw new Exception("@没有设置DB类型。");
            }

            if (dt.Rows.Count == 0)
            {
                return(0);
            }
            Attrs attrs = en.EnMap.Attrs;

            EnDA.fullDate(dt, en, attrs);
            int i = dt.Rows.Count;

            dt.Dispose();
            return(i);
        }
示例#3
0
文件: EnDa.cs 项目: zhaoyingju/ccflow
        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="en"></param>
        /// <returns></returns>
        public static int Insert_del(Entity en)
        {
            if (en.EnMap.EnType == EnType.Ext)
            {
                throw new Exception("@实体[" + en.EnDesc + "]是扩展类型,不能执行插入。");
            }

            if (en.EnMap.EnType == EnType.View)
            {
                throw new Exception("@实体[" + en.EnDesc + "]是视图类型,不能执行插入。");
            }

            try
            {
                switch (en.EnMap.EnDBUrl.DBUrlType)
                {
                case DBUrlType.AppCenterDSN:
                    return(DBAccess.RunSQL(SqlBuilder.Insert(en)));

                case DBUrlType.DBAccessOfMSMSSQL:
                    return(DBAccessOfMSMSSQL.RunSQL(SqlBuilder.Insert(en)));

                case DBUrlType.DBAccessOfOracle:
                    return(DBAccessOfOracle.RunSQL(SqlBuilder.Insert(en)));

                default:
                    throw new Exception("@没有设置类型。");
                }
            }
            catch (Exception ex)
            {
                en.CheckPhysicsTable();                 // 检查物理表。
                throw ex;
            }
        }
示例#4
0
文件: EnDa.cs 项目: zhaoyingju/ccflow
        public static int Retrieve(Entities ens, string sql)
        {
            try
            {
                DataTable dt = new DataTable();
                switch (ens.GetNewEntity.EnMap.EnDBUrl.DBUrlType)
                {
                case DBUrlType.AppCenterDSN:
                    dt = DBAccess.RunSQLReturnTable(sql);
                    break;

                case DBUrlType.DBAccessOfMSMSSQL:
                    dt = DBAccessOfMSMSSQL.RunSQLReturnTable(sql);
                    break;

                case DBUrlType.DBAccessOfOracle:
                    dt = DBAccessOfOracle.RunSQLReturnTable(sql);
                    break;

                case DBUrlType.DBAccessOfOLE:
                    dt = DBAccessOfOLE.RunSQLReturnTable(sql);
                    break;

                default:
                    throw new Exception("@没有设置DB类型。");
                }

                if (dt.Rows.Count == 0)
                {
                    return(0);
                }

                Map   enMap = ens.GetNewEntity.EnMap;
                Attrs attrs = enMap.Attrs;

                //Entity  en1 = ens.GetNewEntity;
                foreach (DataRow dr in dt.Rows)
                {
                    Entity en = ens.GetNewEntity;
                    //Entity  en = en1.CreateInstance();
                    foreach (Attr attr in attrs)
                    {
                        en.Row.SetValByKey(attr.Key, dr[attr.Key]);
                    }
                    ens.AddEntity(en);
                }
                int i = dt.Rows.Count;
                dt.Dispose();
                return(i);
                //return dt.Rows.Count;
            }
            catch (System.Exception ex)
            {
                // ens.GetNewEntity.CheckPhysicsTable();
                throw new Exception("@在[" + ens.GetNewEntity.EnDesc + "]查询时出现错误:" + ex.Message);
            }
        }
示例#5
0
        public static int Retrieve(Entities ens, string sql, Paras paras, string[] fullAttrs)
        {
            DataTable dt = null;

            switch (ens.GetNewEntity.EnMap.EnDBUrl.DBUrlType)
            {
            case DBUrlType.AppCenterDSN:
                dt = DBAccess.RunSQLReturnTable(sql, paras);
                break;

            case DBUrlType.DBAccessOfMSMSSQL:
                dt = DBAccessOfMSMSSQL.RunSQLReturnTable(sql);
                break;

            case DBUrlType.DBAccessOfOracle:
                dt = DBAccessOfOracle.RunSQLReturnTable(sql);
                break;

            case DBUrlType.DBAccessOfOLE:
                dt = DBAccessOfOLE.RunSQLReturnTable(sql);
                break;

            default:
                throw new Exception("@没有设置DB类型。");
            }

            if (dt.Rows.Count == 0)
            {
                return(0);
            }

            //设置查询.
            QueryObject.InitEntitiesByDataTable(ens, dt, fullAttrs);

            int i = dt.Rows.Count;

            dt.Dispose();
            return(i);
            //return dt.Rows.Count;
        }
示例#6
0
文件: EnDa.cs 项目: zhaoyingju/ccflow
        public static int Update(Entity en)
        {
            try
            {
                switch (en.EnMap.EnDBUrl.DBUrlType)
                {
                case DBUrlType.AppCenterDSN:
                    switch (SystemConfig.AppCenterDBType)
                    {
                    case DBType.Oracle:
                        return(DBAccess.RunSQL(en.SQLCash.Update, SqlBuilder.GenerParas(en, null)));

                    case DBType.Access:
                        return(DBAccess.RunSQL(SqlBuilder.UpdateOfMSAccess(en, null)));

                    default:
                        return(DBAccess.RunSQL(SqlBuilder.Update(en, null)));
                    }

                case DBUrlType.DBAccessOfMSMSSQL:
                    return(DBAccessOfMSMSSQL.RunSQL(SqlBuilder.Update(en, null)));

                case DBUrlType.DBAccessOfOracle:
                    return(DBAccessOfOracle.RunSQL(SqlBuilder.Update(en, null)));

                default:
                    throw new Exception("@没有设置类型。");
                }
            }
            catch (Exception ex)
            {
                if (BP.SystemConfig.IsDebug)
                {
                    en.CheckPhysicsTable();
                }
                throw ex;
            }
        }
示例#7
0
        /// <summary>
        /// 是否存在?
        /// </summary>
        /// <param name="sql">要判断的sql</param>
        /// <returns></returns>
        public bool ToDBUrlIsExit(string sql)
        {
            switch (this.ToDBUrl)
            {
            case DBUrlType.AppCenterDSN:
                return(DBAccess.IsExits(sql));

            case DBUrlType.DBAccessOfMSMSSQL:
                return(DBAccessOfMSMSSQL.IsExits(sql));

            case DBUrlType.DBAccessOfODBC:
                return(DBAccessOfODBC.IsExits(sql));

            case DBUrlType.DBAccessOfOLE:
                return(DBAccessOfOLE.IsExits(sql));

            case DBUrlType.DBAccessOfOracle:
                return(DBAccessOfOracle.IsExits(sql));

            default:
                throw new Exception("@ error it");
            }
        }
示例#8
0
        public int ToDBUrlRunDropTable(string table)
        {
            switch (this.ToDBUrl)
            {
            case DBUrlType.AppCenterDSN:
                return(DBAccess.RunSQLDropTable(table));

            case DBUrlType.DBAccessOfMSMSSQL:
                return(DBAccessOfMSMSSQL.RunSQL(table));

            case DBUrlType.DBAccessOfODBC:
                return(DBAccessOfODBC.RunSQL(table));

            case DBUrlType.DBAccessOfOLE:
                return(DBAccessOfOLE.RunSQL(table));

            case DBUrlType.DBAccessOfOracle:
                return(DBAccessOfOracle.RunSQLTRUNCATETable(table));

            default:
                throw new Exception("@ error it");
            }
        }
示例#9
0
        /// <summary>
        /// 删除之后插入, 用于数据量不太大,更新频率不太频繁的数据处理.
        /// </summary>
        public void DeleteInsert()
        {
            this.DoBefore();             //调用业务处理。
            // 得到源表.
            DataTable FromDataTable = this.GetFromDataTable();

            this.DeleteObjData();

            #region  遍历源表 插入操作
            string InsertSQL = "";
            foreach (DataRow FromDR in FromDataTable.Rows)
            {
                InsertSQL = "INSERT INTO " + this.ToTable + "(";
                foreach (FF ff in this.FFs)
                {
                    InsertSQL += ff.ToField.ToString() + ",";
                }
                InsertSQL  = InsertSQL.Substring(0, InsertSQL.Length - 1);
                InsertSQL += ") values(";
                foreach (FF ff in this.FFs)
                {
                    if (ff.DataType == DataType.AppString || ff.DataType == DataType.AppDateTime)
                    {
                        InsertSQL += "'" + FromDR[ff.FromField].ToString() + "',";
                    }
                    else
                    {
                        InsertSQL += FromDR[ff.FromField].ToString() + ",";
                    }
                }
                InsertSQL  = InsertSQL.Substring(0, InsertSQL.Length - 1);
                InsertSQL += ")";

                switch (this.ToDBUrl)
                {
                case DA.DBUrlType.AppCenterDSN:
                    DBAccess.RunSQL(InsertSQL);
                    break;

                case DA.DBUrlType.DBAccessOfMSMSSQL:
                    DBAccessOfMSMSSQL.RunSQL(InsertSQL);
                    break;

                case DA.DBUrlType.DBAccessOfOLE:
                    DBAccessOfOLE.RunSQL(InsertSQL);
                    break;

                case DA.DBUrlType.DBAccessOfOracle:
                    DBAccessOfOracle.RunSQL(InsertSQL);
                    break;

                case DA.DBUrlType.DBAccessOfODBC:
                    DBAccessOfODBC.RunSQL(InsertSQL);
                    break;

                default:
                    break;
                }
            }
            #endregion



            this.DoAfter();             // 调用业务处理。
        }
示例#10
0
文件: EnDa.cs 项目: zhaoyingju/ccflow
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="en">产生要更新的语句</param>
        /// <param name="keys">要更新的属性(null,认为更新全部)</param>
        /// <returns>sql</returns>
        public static int Update(Entity en, string[] keys)
        {
            if (en.EnMap.EnType == EnType.View)
            {
                return(0);
            }
            try
            {
                switch (en.EnMap.EnDBUrl.DBUrlType)
                {
                case DBUrlType.AppCenterDSN:
                    switch (SystemConfig.AppCenterDBType)
                    {
                    case DBType.MSSQL:
                    case DBType.Oracle:
                    case DBType.MySQL:
                        return(DBAccess.RunSQL(en.SQLCash.GetUpdateSQL(en, keys), SqlBuilder.GenerParas(en, keys)));

                    case DBType.Informix:
                        return(DBAccess.RunSQL(en.SQLCash.GetUpdateSQL(en, keys), SqlBuilder.GenerParas_Update_Informix(en, keys)));

                    case DBType.Access:
                        return(DBAccess.RunSQL(SqlBuilder.UpdateOfMSAccess(en, keys)));

                    default:
                        //return DBAccess.RunSQL(en.SQLCash.GetUpdateSQL(en, keys),
                        //    SqlBuilder.GenerParas(en, keys));
                        if (keys != null)
                        {
                            Paras ps   = new Paras();
                            Paras myps = SqlBuilder.GenerParas(en, keys);
                            foreach (Para p in myps)
                            {
                                foreach (string s in keys)
                                {
                                    if (s == p.ParaName)
                                    {
                                        ps.Add(p);
                                        break;
                                    }
                                }
                            }
                            return(DBAccess.RunSQL(en.SQLCash.GetUpdateSQL(en, keys), ps));
                        }
                        else
                        {
                            return(DBAccess.RunSQL(en.SQLCash.GetUpdateSQL(en, keys),
                                                   SqlBuilder.GenerParas(en, keys)));
                        }
                        break;
                    }

                case DBUrlType.DBAccessOfMSMSSQL:
                    return(DBAccessOfMSMSSQL.RunSQL(SqlBuilder.Update(en, keys)));

                case DBUrlType.DBAccessOfOracle:

                    return(DBAccessOfOracle.RunSQL(SqlBuilder.Update(en, keys)));

                default:
                    throw new Exception("@没有设置类型。");
                }
            }
            catch (Exception ex)
            {
                if (BP.SystemConfig.IsDebug)
                {
                    en.CheckPhysicsTable();
                }
                throw ex;
            }
        }
示例#11
0
文件: EnDa.cs 项目: zhaoyingju/ccflow
        public static int Retrieve(Entities ens, string sql, Paras paras, string[] fullAttrs)
        {
            DataTable dt = null;

            switch (ens.GetNewEntity.EnMap.EnDBUrl.DBUrlType)
            {
            case DBUrlType.AppCenterDSN:
                dt = DBAccess.RunSQLReturnTable(sql, paras);
                break;

            case DBUrlType.DBAccessOfMSMSSQL:
                dt = DBAccessOfMSMSSQL.RunSQLReturnTable(sql);
                break;

            case DBUrlType.DBAccessOfOracle:
                dt = DBAccessOfOracle.RunSQLReturnTable(sql);
                break;

            case DBUrlType.DBAccessOfOLE:
                dt = DBAccessOfOLE.RunSQLReturnTable(sql);
                break;

            default:
                throw new Exception("@没有设置DB类型。");
            }

            if (dt.Rows.Count == 0)
            {
                return(0);
            }

            if (fullAttrs == null)
            {
                Map   enMap = ens.GetNewEntity.EnMap;
                Attrs attrs = enMap.Attrs;
                try
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        Entity en = ens.GetNewEntity;
                        foreach (Attr attr in attrs)
                        {
                            en.Row.SetValByKey(attr.Key, dr[attr.Key]);
                        }
                        ens.AddEntity(en);
                    }
                }
                catch (Exception ex)
                {
                    #warning  应该出现的错误. 2011-12-03 add
                    string cols = "";
                    foreach (DataColumn dc in dt.Columns)
                    {
                        cols += " , " + dc.ColumnName;
                    }
                    throw new Exception("Columns=" + cols + "@Ens=" + ens.ToString() + "@SQL=" + sql + ". @异常信息:" + ex.Message);
                }
            }
            else
            {
                foreach (DataRow dr in dt.Rows)
                {
                    Entity en = ens.GetNewEntity;
                    foreach (string str in fullAttrs)
                    {
                        en.Row.SetValByKey(str, dr[str]);
                    }
                    ens.AddEntity(en);
                }
            }
            int i = dt.Rows.Count;
            dt.Dispose();
            return(i);
            //return dt.Rows.Count;
        }