示例#1
0
        /// <summary>
        /// 添加记录
        /// </summary>
        /// <param name="model">RoadFlow.Data.Model.DBConnection实体类</param>
        /// <returns>操作所影响的行数</returns>
        public int Add(RoadFlow.Data.Model.DBConnection model)
        {
            string sql = @"INSERT INTO DBConnection
				(ID,Name,Type,ConnectionString,Note) 
				VALUES(:ID,:Name,:Type,:ConnectionString,:Note)"                ;

            OracleParameter[] parameters = new OracleParameter[] {
                new OracleParameter(":ID", OracleDbType.Varchar2, 40)
                {
                    Value = model.ID
                },
                new OracleParameter(":Name", OracleDbType.Varchar2, 500)
                {
                    Value = model.Name
                },
                new OracleParameter(":Type", OracleDbType.Varchar2, 500)
                {
                    Value = model.Type
                },
                new OracleParameter(":ConnectionString", OracleDbType.Clob)
                {
                    Value = model.ConnectionString
                },
                model.Note == null ? new OracleParameter(":Note", OracleDbType.Clob)
                {
                    Value = DBNull.Value
                } : new OracleParameter(":Note", OracleDbType.Clob)
                {
                    Value = model.Note
                }
            };
            return(dbHelper.Execute(sql, parameters));
        }
        public string GetNames_Table()
        {
            string text  = base.Request.QueryString["dbconn"];
            string text2 = base.Request.QueryString["dbtable"];
            string text3 = base.Request.QueryString["valuefield"];
            string text4 = base.Request.QueryString["titlefield"];
            string text7 = base.Request.QueryString["parentfield"];
            string text8 = base.Request.QueryString["where"];
            string obj   = base.Request.QueryString["values"] ?? "";

            RoadFlow.Platform.DBConnection   dBConnection = new RoadFlow.Platform.DBConnection();
            RoadFlow.Data.Model.DBConnection dbconn       = dBConnection.Get(MyExtensions.ToGuid(text));
            StringBuilder stringBuilder = new StringBuilder();

            string[] array = obj.Split(',');
            foreach (string text5 in array)
            {
                if (!MyExtensions.IsNullOrEmpty(text5))
                {
                    string    text6     = "select " + text4 + " from " + text2 + " where " + text3 + "='" + text5 + "'";
                    DataTable dataTable = dBConnection.GetDataTable(dbconn, MyExtensions.ReplaceSelectSql(text6));
                    if (dataTable.Rows.Count > 0)
                    {
                        stringBuilder.Append(dataTable.Rows[0][0].ToString());
                        stringBuilder.Append(",");
                    }
                }
            }
            return(stringBuilder.ToString().TrimEnd(','));
        }
示例#3
0
        /// <summary>
        /// 更新记录
        /// </summary>
        /// <param name="model">RoadFlow.Data.Model.DBConnection实体类</param>
        public int Update(RoadFlow.Data.Model.DBConnection model)
        {
            string sql = @"UPDATE DBConnection SET 
				Name=:Name,Type=:Type,ConnectionString=:ConnectionString,Note=:Note
				WHERE ID=:ID"                ;

            OracleParameter[] parameters = new OracleParameter[] {
                new OracleParameter(":Name", OracleDbType.Varchar2, 500)
                {
                    Value = model.Name
                },
                new OracleParameter(":Type", OracleDbType.Varchar2, 500)
                {
                    Value = model.Type
                },
                new OracleParameter(":ConnectionString", OracleDbType.Clob)
                {
                    Value = model.ConnectionString
                },
                model.Note == null ? new OracleParameter(":Note", OracleDbType.Clob)
                {
                    Value = DBNull.Value
                } : new OracleParameter(":Note", OracleDbType.Clob)
                {
                    Value = model.Note
                },
                new OracleParameter(":ID", OracleDbType.Varchar2, 40)
                {
                    Value = model.ID
                }
            };
            return(dbHelper.Execute(sql, parameters));
        }
        public string GetJson_TableRefresh()
        {
            string text   = base.Request.QueryString["dbconn"];
            string text2  = base.Request.QueryString["dbtable"];
            string text3  = base.Request.QueryString["valuefield"];
            string text4  = base.Request.QueryString["titlefield"];
            string text5  = base.Request.QueryString["parentfield"];
            string text10 = base.Request.QueryString["where"];
            string text6  = base.Request.QueryString["refreshid"];

            RoadFlow.Platform.DBConnection   dBConnection = new RoadFlow.Platform.DBConnection();
            RoadFlow.Data.Model.DBConnection dbconn       = dBConnection.Get(MyExtensions.ToGuid(text));
            string        text7         = "select " + text3 + "," + text4 + " from " + text2 + " where " + text5 + "='" + text6 + "'";
            DataTable     dataTable     = dBConnection.GetDataTable(dbconn, MyExtensions.ReplaceSelectSql(text7));
            StringBuilder stringBuilder = new StringBuilder(1000);

            foreach (DataRow row in dataTable.Rows)
            {
                string text8 = row[0].ToString();
                string arg   = (dataTable.Columns.Count > 1) ? row[1].ToString() : text8;
                string text9 = "select * from " + text2 + " where " + text5 + "='" + text8 + "'";
                bool   flag  = dBConnection.GetDataTable(dbconn, MyExtensions.ReplaceSelectSql(text9)).Rows.Count > 0;
                stringBuilder.Append("{");
                stringBuilder.AppendFormat("\"id\":\"{0}\",", text8);
                stringBuilder.AppendFormat("\"parentID\":\"{0}\",", Guid.Empty.ToString());
                stringBuilder.AppendFormat("\"title\":\"{0}\",", arg);
                stringBuilder.AppendFormat("\"type\":\"{0}\",", flag ? "1" : "2");
                stringBuilder.AppendFormat("\"ico\":\"{0}\",", "");
                stringBuilder.AppendFormat("\"hasChilds\":\"{0}\",", flag ? "1" : "0");
                stringBuilder.Append("\"childs\":[]},");
            }
            return("[" + stringBuilder.ToString().TrimEnd(',') + "]");
        }
        public string TestLineSqlWhere()
        {
            string msg;

            if (!WebMvc.Common.Tools.CheckLogin(out msg))
            {
                return("");
            }
            string str1 = this.Request["connid"];
            string str2 = this.Request["table"];
            string str3 = this.Request["tablepk"];
            string str4 = this.Request["where"] ?? "";

            RoadFlow.Platform.DBConnection dbConnection = new RoadFlow.Platform.DBConnection();
            if (!str1.IsGuid())
            {
                return("流程未设置数据连接!");
            }
            RoadFlow.Data.Model.DBConnection dbconn = dbConnection.Get(str1.ToGuid(), true);
            if (dbconn == null)
            {
                return("未找到连接!");
            }
            string sql = "SELECT * FROM " + str2 + " WHERE 1=1 AND " + str4.FilterWildcard("");

            return(dbConnection.TestSql(dbconn, sql, true) ? "SQL条件正确!" : "SQL条件错误!");
        }
        public string GetNames_SQL()
        {
            string text  = base.Request.QueryString["dbconn"];
            string text2 = base.Request.QueryString["sql"];

            RoadFlow.Platform.DBConnection   dBConnection = new RoadFlow.Platform.DBConnection();
            RoadFlow.Data.Model.DBConnection dbconn       = dBConnection.Get(MyExtensions.ToGuid(text));
            DataTable     dataTable     = dBConnection.GetDataTable(dbconn, MyExtensions.ReplaceSelectSql(MyExtensions.UrlDecode(text2).FilterWildcard()));
            string        obj           = base.Request.QueryString["values"] ?? "";
            StringBuilder stringBuilder = new StringBuilder();

            string[] array = obj.Split(',');
            foreach (string a in array)
            {
                string empty = string.Empty;
                string value = string.Empty;
                foreach (DataRow row in dataTable.Rows)
                {
                    empty = row[0].ToString();
                    if (a == empty)
                    {
                        value = ((dataTable.Columns.Count > 1) ? row[1].ToString() : empty);
                        break;
                    }
                }
                stringBuilder.Append(value);
                stringBuilder.Append(',');
            }
            return(stringBuilder.ToString().TrimEnd(','));
        }
示例#7
0
 /// <summary>
 /// 得到一个连接所有表
 /// </summary>
 /// <param name="conn"></param>
 /// <returns></returns>
 private List <string> getTables_SqlServer(RoadFlow.Data.Model.DBConnection conn)
 {
     using (SqlConnection sqlConn = new SqlConnection(conn.ConnectionString))
     {
         try
         {
             sqlConn.Open();
         }
         catch (SqlException err)
         {
             Log.Add(err);
             return(new List <string>());
         }
         List <string> tables = new List <string>();
         string        sql    = "SELECT name FROM sysobjects WHERE xtype='U' ORDER BY name";
         using (SqlCommand sqlCmd = new SqlCommand(sql, sqlConn))
         {
             SqlDataReader dr = sqlCmd.ExecuteReader();
             while (dr.Read())
             {
                 tables.Add(dr.GetString(0));
             }
             dr.Close();
             return(tables);
         }
     }
 }
示例#8
0
        /// <summary>
        /// 更新
        /// </summary>
        public int Update(RoadFlow.Data.Model.DBConnection model)
        {
            int i = dataDBConnection.Update(model);

            ClearCache();
            return(i);
        }
示例#9
0
        /// <summary>
        /// 得到一个连接一个表一个字段的值(Oracle)
        /// </summary>
        /// <param name="linkID">连接ID</param>
        /// <param name="table">表</param>
        /// <param name="field">字段</param>
        /// <param name="pkField">主键字段</param>
        /// <param name="pkFieldValue">主键值</param>
        /// <returns></returns>
        private string getFieldValue_Oracle(RoadFlow.Data.Model.DBConnection conn, string table, string field, string pkField, string pkFieldValue)
        {
            string v = "";

            using (OracleConnection sqlConn = new OracleConnection(conn.ConnectionString))
            {
                try
                {
                    sqlConn.Open();
                }
                catch (OracleException err)
                {
                    Log.Add(err);
                    return("");
                }
                string sql = string.Format("SELECT {0} FROM {1} WHERE {2} = '{3}'", field, table, pkField, pkFieldValue);
                using (OracleDataAdapter dap = new OracleDataAdapter(sql, sqlConn))
                {
                    try
                    {
                        DataTable dt = new DataTable();
                        dap.Fill(dt);
                        if (dt.Rows.Count > 0)
                        {
                            v = dt.Rows[0][0].ToString();
                        }
                    }
                    catch (OracleException err)
                    {
                        Log.Add(err);
                    }
                    return(v);
                }
            }
        }
示例#10
0
 /// <summary>
 /// 得到一个连接所有表(oracle)
 /// </summary>
 /// <param name="conn"></param>
 /// <returns></returns>
 private List <string> getTables_Oracle(RoadFlow.Data.Model.DBConnection conn)
 {
     using (OracleConnection oraConn = new OracleConnection(conn.ConnectionString))
     {
         try
         {
             oraConn.Open();
         }
         catch (SqlException err)
         {
             Log.Add(err);
             return(new List <string>());
         }
         List <string> tables = new List <string>();
         string        sql    = "select * from tab where instr(tname,'$',1,1)=0";
         using (OracleCommand sqlCmd = new OracleCommand(sql, oraConn))
         {
             OracleDataReader dr = sqlCmd.ExecuteReader();
             while (dr.Read())
             {
                 tables.Add(dr.GetString(0));
             }
             dr.Close();
             return(tables);
         }
     }
 }
示例#11
0
        /// <summary>
        /// 更新记录
        /// </summary>
        /// <param name="model">RoadFlow.Data.Model.DBConnection实体类</param>
        public int Update(RoadFlow.Data.Model.DBConnection model)
        {
            string sql = @"UPDATE DBConnection SET 
				Name=@Name,Type=@Type,ConnectionString=@ConnectionString,Note=@Note
				WHERE ID=@ID"                ;

            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter("@Name", SqlDbType.VarChar, 500)
                {
                    Value = model.Name
                },
                new SqlParameter("@Type", SqlDbType.VarChar, 500)
                {
                    Value = model.Type
                },
                new SqlParameter("@ConnectionString", SqlDbType.VarChar, -1)
                {
                    Value = model.ConnectionString
                },
                model.Note == null ? new SqlParameter("@Note", SqlDbType.VarChar, -1)
                {
                    Value = DBNull.Value
                } : new SqlParameter("@Note", SqlDbType.VarChar, -1)
                {
                    Value = model.Note
                },
                new SqlParameter("@ID", SqlDbType.UniqueIdentifier, -1)
                {
                    Value = model.ID
                }
            };
            return(dbHelper.Execute(sql, parameters));
        }
        public string GetJson_SQL()
        {
            if (!Tools.CheckLogin(redirect: false))
            {
                return("{}");
            }
            string text  = base.Request.QueryString["dbconn"];
            string text2 = base.Request.QueryString["sql"];

            RoadFlow.Platform.DBConnection   dBConnection = new RoadFlow.Platform.DBConnection();
            RoadFlow.Data.Model.DBConnection dbconn       = dBConnection.Get(MyExtensions.ToGuid(text));
            DataTable     dataTable     = dBConnection.GetDataTable(dbconn, MyExtensions.ReplaceSelectSql(MyExtensions.UrlDecode(text2).FilterWildcard()));
            StringBuilder stringBuilder = new StringBuilder(1000);

            foreach (DataRow row in dataTable.Rows)
            {
                string text3 = row[0].ToString();
                string arg   = (dataTable.Columns.Count > 1) ? row[1].ToString() : text3;
                stringBuilder.Append("{");
                stringBuilder.AppendFormat("\"id\":\"{0}\",", text3);
                stringBuilder.AppendFormat("\"parentID\":\"{0}\",", Guid.Empty.ToString());
                stringBuilder.AppendFormat("\"title\":\"{0}\",", arg);
                stringBuilder.AppendFormat("\"type\":\"{0}\",", "2");
                stringBuilder.AppendFormat("\"ico\":\"{0}\",", "");
                stringBuilder.AppendFormat("\"hasChilds\":\"{0}\",", "0");
                stringBuilder.Append("\"childs\":[]},");
            }
            return("[" + stringBuilder.ToString().TrimEnd(',') + "]");
        }
示例#13
0
        public string GetNames_Table()
        {
            string str1 = this.Request.QueryString["dbconn"];
            string str2 = this.Request.QueryString["dbtable"];
            string str3 = this.Request.QueryString["valuefield"];
            string str4 = this.Request.QueryString["titlefield"];
            string str5 = this.Request.QueryString["parentfield"];
            string str6 = this.Request.QueryString["where"];
            string str7 = this.Request.QueryString["values"] ?? "";

            RoadFlow.Platform.DBConnection   dbConnection = new RoadFlow.Platform.DBConnection();
            RoadFlow.Data.Model.DBConnection dbconn       = dbConnection.Get(str1.ToGuid(), true);
            StringBuilder stringBuilder = new StringBuilder();

            char[] chArray = new char[1] {
                ','
            };
            foreach (string str8 in str7.Split(chArray))
            {
                if (!str8.IsNullOrEmpty())
                {
                    string    str9      = "select " + str4 + " from " + str2 + " where " + str3 + "='" + str8 + "'";
                    DataTable dataTable = dbConnection.GetDataTable(dbconn, str9.ReplaceSelectSql(), (IDataParameter[])null);
                    if (dataTable.Rows.Count > 0)
                    {
                        stringBuilder.Append(dataTable.Rows[0][0].ToString());
                        stringBuilder.Append(",");
                    }
                }
            }
            return(stringBuilder.ToString().TrimEnd(','));
        }
示例#14
0
        /// <summary>
        /// 添加记录
        /// </summary>
        /// <param name="model">RoadFlow.Data.Model.DBConnection实体类</param>
        /// <returns>操作所影响的行数</returns>
        public int Add(RoadFlow.Data.Model.DBConnection model)
        {
            string sql = @"INSERT INTO DBConnection
				(ID,Name,Type,ConnectionString,Note) 
				VALUES(@ID,@Name,@Type,@ConnectionString,@Note)"                ;

            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter("@ID", SqlDbType.UniqueIdentifier, -1)
                {
                    Value = model.ID
                },
                new SqlParameter("@Name", SqlDbType.VarChar, 500)
                {
                    Value = model.Name
                },
                new SqlParameter("@Type", SqlDbType.VarChar, 500)
                {
                    Value = model.Type
                },
                new SqlParameter("@ConnectionString", SqlDbType.VarChar, -1)
                {
                    Value = model.ConnectionString
                },
                model.Note == null ? new SqlParameter("@Note", SqlDbType.VarChar, -1)
                {
                    Value = DBNull.Value
                } : new SqlParameter("@Note", SqlDbType.VarChar, -1)
                {
                    Value = model.Note
                }
            };
            return(dbHelper.Execute(sql, parameters));
        }
示例#15
0
        public string GetJson_TableRefresh()
        {
            string str1 = this.Request.QueryString["dbconn"];
            string str2 = this.Request.QueryString["dbtable"];
            string str3 = this.Request.QueryString["valuefield"];
            string str4 = this.Request.QueryString["titlefield"];
            string str5 = this.Request.QueryString["parentfield"];
            string str6 = this.Request.QueryString["where"];
            string str7 = this.Request.QueryString["refreshid"];

            RoadFlow.Platform.DBConnection   dbConnection = new RoadFlow.Platform.DBConnection();
            RoadFlow.Data.Model.DBConnection dbconn       = dbConnection.Get(str1.ToGuid(), true);
            string        str8          = "select " + str3 + "," + str4 + " from " + str2 + " where " + str5 + "='" + str7 + "'";
            DataTable     dataTable     = dbConnection.GetDataTable(dbconn, str8.ReplaceSelectSql(), (IDataParameter[])null);
            StringBuilder stringBuilder = new StringBuilder(1000);

            foreach (DataRow row in (InternalDataCollectionBase)dataTable.Rows)
            {
                string str9  = row[0].ToString();
                string str10 = dataTable.Columns.Count > 1 ? row[1].ToString() : str9;
                string str11 = "select * from " + str2 + " where " + str5 + "='" + str9 + "'";
                bool   flag  = dbConnection.GetDataTable(dbconn, str11.ReplaceSelectSql(), (IDataParameter[])null).Rows.Count > 0;
                stringBuilder.Append("{");
                stringBuilder.AppendFormat("\"id\":\"{0}\",", (object)str9);
                stringBuilder.AppendFormat("\"parentID\":\"{0}\",", (object)Guid.Empty.ToString());
                stringBuilder.AppendFormat("\"title\":\"{0}\",", (object)str10);
                stringBuilder.AppendFormat("\"type\":\"{0}\",", flag ? (object)"1" : (object)"2");
                stringBuilder.AppendFormat("\"ico\":\"{0}\",", (object)"");
                stringBuilder.AppendFormat("\"hasChilds\":\"{0}\",", flag ? (object)"1" : (object)"0");
                stringBuilder.Append("\"childs\":[]},");
            }
            return("[" + stringBuilder.ToString().TrimEnd(',') + "]");
        }
示例#16
0
        /// <summary>
        /// 得到一个连接一个表所有字段
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="table"></param>
        /// <returns></returns>
        private Dictionary <string, string> getFields_SqlServer(RoadFlow.Data.Model.DBConnection conn, string table)
        {
            using (SqlConnection sqlConn = new SqlConnection(conn.ConnectionString))
            {
                try
                {
                    sqlConn.Open();
                }
                catch (SqlException err)
                {
                    Log.Add(err);
                    return(new Dictionary <string, string>());
                }
                Dictionary <string, string> fields = new Dictionary <string, string>();
                string sql = string.Format(@"SELECT a.name as f_name, b.value from 
sys.syscolumns a LEFT JOIN sys.extended_properties b on a.id=b.major_id AND a.colid=b.minor_id AND b.name='MS_Description' 
WHERE object_id('{0}')=a.id ORDER BY a.colid", table);
                using (SqlCommand sqlCmd = new SqlCommand(sql, sqlConn))
                {
                    SqlDataReader dr = sqlCmd.ExecuteReader();
                    while (dr.Read())
                    {
                        fields.Add(dr.GetString(0), dr.IsDBNull(1) ? "" : dr.GetString(1));
                    }
                    dr.Close();
                    return(fields);
                }
            }
        }
示例#17
0
 /// <summary>
 /// 得到一个连接一个表所有字段(Oracle)
 /// </summary>
 /// <param name="conn"></param>
 /// <param name="table"></param>
 /// <returns></returns>
 private Dictionary <string, string> getFields_Oracle(RoadFlow.Data.Model.DBConnection conn, string table)
 {
     using (OracleConnection sqlConn = new OracleConnection(conn.ConnectionString))
     {
         try
         {
             sqlConn.Open();
         }
         catch (OracleException err)
         {
             Log.Add(err);
             return(new Dictionary <string, string>());
         }
         Dictionary <string, string> fields = new Dictionary <string, string>();
         string sql = string.Format("select COLUMN_NAME,COMMENTS from user_col_comments where TABLE_NAME='{0}'", table);
         using (OracleCommand sqlCmd = new OracleCommand(sql, sqlConn))
         {
             OracleDataReader dr = sqlCmd.ExecuteReader();
             while (dr.Read())
             {
                 fields.Add(dr.GetString(0), dr.IsDBNull(1) ? "" : dr.GetString(1));
             }
             dr.Close();
             return(fields);
         }
     }
 }
示例#18
0
 /// <summary>
 /// 测试一个sql条件合法性(oracle)
 /// </summary>
 /// <param name="conn"></param>
 /// <param name="where"></param>
 /// <returns></returns>
 private string testSql_Oracle(RoadFlow.Data.Model.DBConnection conn, string sql)
 {
     using (OracleConnection sqlConn = new OracleConnection(conn.ConnectionString))
     {
         try
         {
             sqlConn.Open();
         }
         catch (OracleException err)
         {
             return(err.Message);
         }
         using (OracleCommand cmd = new OracleCommand(sql, sqlConn))
         {
             try
             {
                 cmd.ExecuteNonQuery();
             }
             catch (OracleException err)
             {
                 return(err.Message);
             }
         }
         return("");
     }
 }
示例#19
0
        /// <summary>
        /// 得到一个连接一个表一个字段的值(Oracle)
        /// </summary>
        /// <param name="conn">连接ID</param>
        /// <param name="table">表名</param>
        /// <param name="field">字段名</param>
        /// <param name="pkFieldValue">主键和值字典</param>
        /// <returns></returns>
        private string getFieldValue_Oracle(RoadFlow.Data.Model.DBConnection conn, string table, string field, Dictionary <string, string> pkFieldValue)
        {
            using (OracleConnection sqlConn = new OracleConnection(conn.ConnectionString))
            {
                try
                {
                    sqlConn.Open();
                }
                catch (OracleException err)
                {
                    Log.Add(err);
                    return("");
                }
                List <string> fields = new List <string>();
                StringBuilder sql    = new StringBuilder();
                sql.AppendFormat("select {0} from {1} where 1=1", field, table);
                foreach (var pk in pkFieldValue)
                {
                    sql.AppendFormat(" and {0}='{1}'", pk.Key, pk.Value);
                }

                using (OracleCommand sqlCmd = new OracleCommand(sql.ToString(), sqlConn))
                {
                    OracleDataReader dr    = sqlCmd.ExecuteReader();
                    string           value = string.Empty;
                    if (dr.HasRows)
                    {
                        dr.Read();
                        value = dr.GetString(0);
                    }
                    dr.Close();
                    return(value);
                }
            }
        }
示例#20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string editid = Request.QueryString["id"];

            RoadFlow.Platform.DBConnection   bdbConn = new RoadFlow.Platform.DBConnection();
            RoadFlow.Data.Model.DBConnection dbconn  = null;
            if (editid.IsGuid())
            {
                dbconn = bdbConn.Get(editid.ToGuid());
            }
            bool   isAdd  = !editid.IsGuid();
            string oldXML = string.Empty;

            if (dbconn == null)
            {
                dbconn    = new RoadFlow.Data.Model.DBConnection();
                dbconn.ID = Guid.NewGuid();
            }
            else
            {
                oldXML = dbconn.Serialize();
            }

            if (IsPostBack)
            {
                string Name     = Request.Form["Name"];
                string LinkType = Request.Form["LinkType"];
                string ConnStr  = Request.Form["ConnStr"];
                string Note     = Request.Form["Note"];
                dbconn.Name             = Name.Trim();
                dbconn.Type             = LinkType;
                dbconn.ConnectionString = ConnStr;
                dbconn.Note             = Note;

                if (isAdd)
                {
                    bdbConn.Add(dbconn);
                    RoadFlow.Platform.Log.Add("添加了应用程序库", dbconn.Serialize(), RoadFlow.Platform.Log.Types.角色应用);
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('添加成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();", true);
                }
                else
                {
                    bdbConn.Update(dbconn);
                    RoadFlow.Platform.Log.Add("修改了应用程序库", "", RoadFlow.Platform.Log.Types.角色应用, oldXML, dbconn.Serialize());
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('修改成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();", true);
                }
                bdbConn.ClearCache();
            }
            if (dbconn != null)
            {
                this.Name.Value    = dbconn.Name;
                this.ConnStr.Value = dbconn.ConnectionString;
                this.Note.Value    = dbconn.Note;
            }
            this.TypeOptions.Text = bdbConn.GetAllTypeOptions(dbconn.Type);
        }
        public ActionResult Edit(FormCollection collection)
        {
            string editid = Request.QueryString["id"];

            RoadFlow.Platform.DBConnection   bdbConn = new RoadFlow.Platform.DBConnection();
            RoadFlow.Data.Model.DBConnection dbconn  = null;
            if (editid.IsGuid())
            {
                dbconn = bdbConn.Get(editid.Convert <Guid>());
            }
            bool   isAdd  = !editid.IsGuid();
            string oldXML = string.Empty;

            if (dbconn == null)
            {
                dbconn    = new RoadFlow.Data.Model.DBConnection();
                dbconn.ID = Guid.NewGuid();
            }
            else
            {
                oldXML = dbconn.Serialize();
            }

            if (collection != null)
            {
                string Name     = Request.Form["Name"];
                string LinkType = Request.Form["LinkType"];
                string ConnStr  = Request.Form["ConnStr"];
                string Note     = Request.Form["Note"];
                dbconn.Name             = Name.Trim();
                dbconn.Type             = LinkType;
                dbconn.ConnectionString = ConnStr;
                dbconn.Note             = Note;

                if (isAdd)
                {
                    bdbConn.Add(dbconn);
                    RoadFlow.Platform.Log.Add("添加了应用程序库", dbconn.Serialize(), RoadFlow.Platform.Log.Types.角色应用);
                    ViewBag.Script = "alert('添加成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();";
                }
                else
                {
                    bdbConn.Update(dbconn);
                    RoadFlow.Platform.Log.Add("修改了应用程序库", "", RoadFlow.Platform.Log.Types.角色应用, oldXML, dbconn.Serialize());
                    ViewBag.Script = "alert('修改成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();";
                }
                bdbConn.ClearCache();
            }

            ViewBag.TypeOptions = bdbConn.GetAllTypeOptions(dbconn.Type);

            return(View(dbconn));
        }
        public ActionResult TableQuery(FormCollection collection)
        {
            RoadFlow.Platform.DBConnection dBConnection = new RoadFlow.Platform.DBConnection();
            string empty  = string.Empty;
            string empty2 = string.Empty;

            RoadFlow.Data.Model.DBConnection dBConnection2 = null;
            string empty3 = string.Empty;

            empty         = base.Request.QueryString["tablename"];
            empty2        = base.Request.QueryString["dbconnid"];
            dBConnection2 = dBConnection.Get(MyExtensions.ToGuid(empty2));
            if (dBConnection2 == null)
            {
                base.ViewBag.LiteralResult           = "未找到数据连接";
                base.ViewBag.LiteralResultCount.Text = "";
                return(View());
            }
            if (collection != null)
            {
                empty3 = base.Request.Form["sqltext"];
            }
            else
            {
                if (MyExtensions.IsNullOrEmpty(empty))
                {
                    base.ViewBag.LiteralResult      = "";
                    base.ViewBag.LiteralResultCount = "";
                    return(View());
                }
                empty3 = dBConnection.GetDefaultQuerySql(dBConnection2, empty);
            }
            if (MyExtensions.IsNullOrEmpty(empty3))
            {
                base.ViewBag.LiteralResult      = "SQL为空!";
                base.ViewBag.LiteralResultCount = "";
                return(View());
            }
            if (!dBConnection.CheckSql(empty3))
            {
                base.ViewBag.LiteralResult      = "SQL含有破坏系统表的语句,禁止执行!";
                base.ViewBag.LiteralResultCount = "";
                RoadFlow.Platform.Log.Add("尝试执行有破坏系统表的SQL语句", empty3, RoadFlow.Platform.Log.Types.数据连接);
                return(View());
            }
            DataTable dataTable = dBConnection.GetDataTable(dBConnection2, empty3);

            RoadFlow.Platform.Log.Add("执行了SQL", empty3, RoadFlow.Platform.Log.Types.数据连接, MyExtensions.ToJsonString((object)dataTable));
            base.ViewBag.LiteralResult      = Tools.DataTableToHtml(dataTable);
            base.ViewBag.LiteralResultCount = "(共" + dataTable.Rows.Count + "行)";
            base.ViewBag.sqltext            = empty3;
            return(View());
        }
        public ActionResult Table(FormCollection collection)
        {
            string text = base.Request.QueryString["connid"];
            List <Tuple <string, int> > list = new List <Tuple <string, int> >();

            RoadFlow.Platform.DBConnection dBConnection = new RoadFlow.Platform.DBConnection();
            string        empty            = string.Empty;
            string        empty2           = string.Empty;
            List <string> systemDataTables = RoadFlow.Utility.Config.get_SystemDataTables();

            if (!MyExtensions.IsGuid(text))
            {
                base.Response.Write("数据连接ID错误");
                base.Response.End();
                return(null);
            }
            RoadFlow.Data.Model.DBConnection dBConnection2 = dBConnection.Get(MyExtensions.ToGuid(text));
            if (dBConnection2 == null)
            {
                base.Response.Write("未找到数据连接");
                base.Response.End();
                return(null);
            }
            empty2 = dBConnection2.Type;
            foreach (string table2 in dBConnection.GetTables(dBConnection2.ID, 1))
            {
                list.Add(new Tuple <string, int>(table2, 0));
            }
            foreach (string table3 in dBConnection.GetTables(dBConnection2.ID, 2))
            {
                list.Add(new Tuple <string, int>(table3, 1));
            }
            JsonData jsonData = new JsonData();

            foreach (Tuple <string, int> item in list)
            {
                bool          flag          = systemDataTables.Find((string p) => p.Equals(item.Item1, StringComparison.CurrentCultureIgnoreCase)) != null;
                StringBuilder stringBuilder = new StringBuilder("<a class=\"viewlink\" href=\"javascript:void(0);\" onclick=\"queryTable('" + text + "','" + item.Item1 + "');\">查询</a>");
                JsonData      jsonData2     = new JsonData();
                jsonData2["Name"]    = item.Item1;
                jsonData2["Type"]    = ((item.Item2 == 0) ? (flag ? "系统表" : "表") : "视图");
                jsonData2["Opation"] = stringBuilder.ToString();
                jsonData.Add(jsonData2);
            }
            empty = "&connid=" + text + "&appid=" + base.Request.QueryString["appid"] + "&tabid=" + base.Request.QueryString["tabid"];
            base.ViewBag.Query    = empty;
            base.ViewBag.dbconnID = text;
            base.ViewBag.DBType   = empty2;
            base.ViewBag.list     = jsonData.ToJson();
            return(View());
        }
        public ActionResult Edit(FormCollection collection)
        {
            string text = base.Request.QueryString["id"];

            RoadFlow.Platform.DBConnection   dBConnection  = new RoadFlow.Platform.DBConnection();
            RoadFlow.Data.Model.DBConnection dBConnection2 = null;
            if (MyExtensions.IsGuid(text))
            {
                dBConnection2 = dBConnection.Get(MyExtensions.ToGuid(text));
            }
            bool   flag   = !MyExtensions.IsGuid(text);
            string oldXML = string.Empty;

            if (dBConnection2 == null)
            {
                dBConnection2    = new RoadFlow.Data.Model.DBConnection();
                dBConnection2.ID = Guid.NewGuid();
            }
            else
            {
                oldXML = MyExtensions.Serialize((object)dBConnection2);
            }
            if (collection != null)
            {
                string text2            = base.Request.Form["Name"];
                string type             = base.Request.Form["LinkType"];
                string connectionString = base.Request.Form["ConnStr"];
                string note             = base.Request.Form["Note"];
                dBConnection2.Name             = text2.Trim();
                dBConnection2.Type             = type;
                dBConnection2.ConnectionString = connectionString;
                dBConnection2.Note             = note;
                if (flag)
                {
                    dBConnection.Add(dBConnection2);
                    RoadFlow.Platform.Log.Add("添加了数据库连接", MyExtensions.Serialize((object)dBConnection2), RoadFlow.Platform.Log.Types.数据连接);
                    base.ViewBag.Script = "alert('添加成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();";
                }
                else
                {
                    dBConnection.Update(dBConnection2);
                    RoadFlow.Platform.Log.Add("修改了数据库连接", "", RoadFlow.Platform.Log.Types.数据连接, oldXML, MyExtensions.Serialize((object)dBConnection2));
                    base.ViewBag.Script = "alert('修改成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();";
                }
                dBConnection.ClearCache();
            }
            base.ViewBag.TypeOptions = dBConnection.GetAllTypeOptions(dBConnection2.Type);
            return(View(dBConnection2));
        }
示例#25
0
 /// <summary>
 /// 测试一个连接
 /// </summary>
 /// <param name="conn"></param>
 /// <returns></returns>
 private string test_SqlServer(RoadFlow.Data.Model.DBConnection conn)
 {
     using (SqlConnection sqlConn = new SqlConnection(conn.ConnectionString))
     {
         try
         {
             sqlConn.Open();
             return("连接成功!");
         }
         catch (SqlException err)
         {
             return(err.Message);
         }
     }
 }
示例#26
0
 /// <summary>
 /// 测试一个连接(oracle)
 /// </summary>
 /// <param name="conn"></param>
 /// <returns></returns>
 private string test_Oracle(RoadFlow.Data.Model.DBConnection conn)
 {
     using (OracleConnection sqlConn = new OracleConnection(conn.ConnectionString))
     {
         try
         {
             sqlConn.Open();
             return("连接成功!");
         }
         catch (OracleException err)
         {
             return(err.Message);
         }
     }
 }
示例#27
0
        private List <RoadFlow.Data.Model.DBConnection> DataReaderToList(OracleDataReader dataReader)
        {
            List <RoadFlow.Data.Model.DBConnection> dbConnectionList = new List <RoadFlow.Data.Model.DBConnection>();

            while (dataReader.Read())
            {
                RoadFlow.Data.Model.DBConnection dbConnection = new RoadFlow.Data.Model.DBConnection();
                dbConnection.ID               = dataReader.GetString(0).ToGuid();
                dbConnection.Name             = dataReader.GetString(1);
                dbConnection.Type             = dataReader.GetString(2);
                dbConnection.ConnectionString = dataReader.GetString(3);
                if (!dataReader.IsDBNull(4))
                {
                    dbConnection.Note = dataReader.GetString(4);
                }
                dbConnectionList.Add(dbConnection);
            }
            return(dbConnectionList);
        }
示例#28
0
        public int Add(RoadFlow.Data.Model.DBConnection model)
        {
            string sql = "INSERT INTO DBConnection\r\n\t\t\t\t(ID,Name,Type,ConnectionString,Note) \r\n\t\t\t\tVALUES(:ID,:Name,:Type,:ConnectionString,:Note)";

            OracleParameter[] oracleParameterArray = new OracleParameter[5];
            int             index1           = 0;
            OracleParameter oracleParameter1 = new OracleParameter(":ID", OracleDbType.Varchar2, 40);

            oracleParameter1.Value       = (object)model.ID;
            oracleParameterArray[index1] = oracleParameter1;
            int             index2           = 1;
            OracleParameter oracleParameter2 = new OracleParameter(":Name", OracleDbType.Varchar2, 500);

            oracleParameter2.Value       = (object)model.Name;
            oracleParameterArray[index2] = oracleParameter2;
            int             index3           = 2;
            OracleParameter oracleParameter3 = new OracleParameter(":Type", OracleDbType.Varchar2, 500);

            oracleParameter3.Value       = (object)model.Type;
            oracleParameterArray[index3] = oracleParameter3;
            int             index4           = 3;
            OracleParameter oracleParameter4 = new OracleParameter(":ConnectionString", OracleDbType.Clob);

            oracleParameter4.Value       = (object)model.ConnectionString;
            oracleParameterArray[index4] = oracleParameter4;
            int             index5 = 4;
            OracleParameter oracleParameter5;

            if (model.Note != null)
            {
                OracleParameter oracleParameter6 = new OracleParameter(":Note", OracleDbType.Clob);
                oracleParameter6.Value = (object)model.Note;
                oracleParameter5       = oracleParameter6;
            }
            else
            {
                oracleParameter5       = new OracleParameter(":Note", OracleDbType.Clob);
                oracleParameter5.Value = (object)DBNull.Value;
            }
            oracleParameterArray[index5] = oracleParameter5;
            OracleParameter[] parameter = oracleParameterArray;
            return(this.dbHelper.Execute(sql, parameter));
        }
示例#29
0
        public int Update(RoadFlow.Data.Model.DBConnection model)
        {
            string sql = "UPDATE DBConnection SET \r\n\t\t\t\tName=@Name,Type=@Type,ConnectionString=@ConnectionString,Note=@Note\r\n\t\t\t\tWHERE ID=@ID";

            SqlParameter[] sqlParameterArray = new SqlParameter[5];
            int            index1            = 0;
            SqlParameter   sqlParameter1     = new SqlParameter("@Name", SqlDbType.VarChar, 500);

            sqlParameter1.Value       = (object)model.Name;
            sqlParameterArray[index1] = sqlParameter1;
            int          index2        = 1;
            SqlParameter sqlParameter2 = new SqlParameter("@Type", SqlDbType.VarChar, 500);

            sqlParameter2.Value       = (object)model.Type;
            sqlParameterArray[index2] = sqlParameter2;
            int          index3        = 2;
            SqlParameter sqlParameter3 = new SqlParameter("@ConnectionString", SqlDbType.VarChar, -1);

            sqlParameter3.Value       = (object)model.ConnectionString;
            sqlParameterArray[index3] = sqlParameter3;
            int          index4 = 3;
            SqlParameter sqlParameter4;

            if (model.Note != null)
            {
                SqlParameter sqlParameter5 = new SqlParameter("@Note", SqlDbType.VarChar, -1);
                sqlParameter5.Value = (object)model.Note;
                sqlParameter4       = sqlParameter5;
            }
            else
            {
                sqlParameter4       = new SqlParameter("@Note", SqlDbType.VarChar, -1);
                sqlParameter4.Value = (object)DBNull.Value;
            }
            sqlParameterArray[index4] = sqlParameter4;
            int          index5        = 4;
            SqlParameter sqlParameter6 = new SqlParameter("@ID", SqlDbType.UniqueIdentifier, -1);

            sqlParameter6.Value       = (object)model.ID;
            sqlParameterArray[index5] = sqlParameter6;
            SqlParameter[] parameter = sqlParameterArray;
            return(this.dbHelper.Execute(sql, parameter, false));
        }