Ejemplo n.º 1
0
        private string getFieldValue_MySql(RoadFlow.Data.Model.DBConnection conn, string table, string field, string pkField, string pkFieldValue)
        {
            string v = "";

            using (MySqlConnection sqlConn = new MySqlConnection(conn.ConnectionString))
            {
                try
                {
                    sqlConn.Open();
                }
                catch (MySqlException err)
                {
                    Log.Add(err);
                    return("");
                }
                string sql = string.Format("SELECT {0} FROM {1} WHERE {2} = '{3}'", field, table, pkField, pkFieldValue);
                using (MySqlDataAdapter dap = new MySqlDataAdapter(sql, sqlConn))
                {
                    try
                    {
                        DataTable dt = new DataTable();
                        dap.Fill(dt);
                        if (dt.Rows.Count > 0)
                        {
                            v = dt.Rows[0][0].ToString();
                        }
                    }
                    catch (MySqlException err)
                    {
                        Log.Add(err);
                    }
                    return(v);
                }
            }
        }
Ejemplo n.º 2
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)";

            SqlParameter[] parameter = new SqlParameter[5]
            {
                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, parameter));
        }
Ejemplo n.º 3
0
        public int Update(RoadFlow.Data.Model.DBConnection model)
        {
            //IL_001a: Unknown result type (might be due to invalid IL or missing references)
            //IL_001f: Unknown result type (might be due to invalid IL or missing references)
            //IL_002b: Expected O, but got Unknown
            //IL_002c: Expected O, but got Unknown
            //IL_003a: Unknown result type (might be due to invalid IL or missing references)
            //IL_003f: Unknown result type (might be due to invalid IL or missing references)
            //IL_004b: Expected O, but got Unknown
            //IL_004c: Expected O, but got Unknown
            //IL_0055: Unknown result type (might be due to invalid IL or missing references)
            //IL_005a: Unknown result type (might be due to invalid IL or missing references)
            //IL_0066: Expected O, but got Unknown
            //IL_0067: Expected O, but got Unknown
            //IL_0078: Unknown result type (might be due to invalid IL or missing references)
            //IL_007d: Unknown result type (might be due to invalid IL or missing references)
            //IL_0089: Expected O, but got Unknown
            //IL_0092: Unknown result type (might be due to invalid IL or missing references)
            //IL_0097: Unknown result type (might be due to invalid IL or missing references)
            //IL_00a2: Expected O, but got Unknown
            //IL_00a3: Expected O, but got Unknown
            //IL_00ae: Unknown result type (might be due to invalid IL or missing references)
            //IL_00b3: Unknown result type (might be due to invalid IL or missing references)
            //IL_00c4: Expected O, but got Unknown
            //IL_00c5: Expected O, but got Unknown
            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";

            OracleParameter[] obj = new OracleParameter[5];
            OracleParameter   val = new OracleParameter(":Name", 126, 500);

            ((DbParameter)val).Value = model.Name;
            obj[0] = val;
            OracleParameter val2 = new OracleParameter(":Type", 126, 500);

            ((DbParameter)val2).Value = model.Type;
            obj[1] = val2;
            OracleParameter val3 = new OracleParameter(":ConnectionString", 105);

            ((DbParameter)val3).Value = model.ConnectionString;
            obj[2] = val3;
            _003F val4;

            if (model.Note != null)
            {
                val4 = new OracleParameter(":Note", 105);
                ((DbParameter)val4).Value = model.Note;
            }
            else
            {
                val4 = new OracleParameter(":Note", 105);
                ((DbParameter)val4).Value = DBNull.Value;
            }
            obj[3] = val4;
            OracleParameter val5 = new OracleParameter(":ID", 126, 40);

            ((DbParameter)val5).Value = model.ID;
            obj[4] = val5;
            OracleParameter[] parameter = (OracleParameter[])obj;
            return(dbHelper.Execute(sql, parameter));
        }
Ejemplo n.º 4
0
        private string getFieldValue_MySql(RoadFlow.Data.Model.DBConnection conn, string table, string field, Dictionary <string, string> pkFieldValue)
        {
            using (MySqlConnection sqlConn = new MySqlConnection(conn.ConnectionString))
            {
                try
                {
                    sqlConn.Open();
                }
                catch (MySqlException 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 (MySqlCommand sqlCmd = new MySqlCommand(sql.ToString(), sqlConn))
                {
                    MySqlDataReader dr    = sqlCmd.ExecuteReader();
                    string          value = string.Empty;
                    if (dr.HasRows)
                    {
                        dr.Read();
                        value = dr.GetString(0);
                    }
                    dr.Close();
                    return(value);
                }
            }
        }
Ejemplo n.º 5
0
 private List <string> getTables_MySql(RoadFlow.Data.Model.DBConnection conn)
 {
     using (MySqlConnection sqlConn = new MySqlConnection(conn.ConnectionString))
     {
         try
         {
             sqlConn.Open();
         }
         catch (MySqlException err)
         {
             Log.Add(err);
             return(new List <string>());
         }
         List <string> tables = new List <string>();
         string        sql    = string.Format("select table_name from information_schema.tables where table_schema='{0}'", sqlConn.Database);
         using (MySqlCommand sqlCmd = new MySqlCommand(sql, sqlConn))
         {
             MySqlDataReader dr = sqlCmd.ExecuteReader();
             while (dr.Read())
             {
                 tables.Add(dr.GetString(0));
             }
             dr.Close();
             return(tables);
         }
     }
 }
Ejemplo n.º 6
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);
     }
 }
Ejemplo n.º 7
0
 private string testSql_MySql(RoadFlow.Data.Model.DBConnection conn, string sql)
 {
     using (MySqlConnection sqlConn = new MySqlConnection(conn.ConnectionString))
     {
         try
         {
             sqlConn.Open();
         }
         catch (MySqlException err)
         {
             return(err.Message);
         }
         using (MySqlCommand cmd = new MySqlCommand(sql, sqlConn))
         {
             try
             {
                 cmd.ExecuteNonQuery();
             }
             catch (MySqlException err)
             {
                 return(err.Message);
             }
         }
         return("");
     }
 }
Ejemplo n.º 8
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' OR xtype='V' 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);
         }
     }
 }
Ejemplo n.º 9
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[] parameter = new SqlParameter[5]
            {
                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, parameter));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 更新
        /// </summary>
        public int Update(RoadFlow.Data.Model.DBConnection model)
        {
            int i = dataDBConnection.Update(model);

            ClearCache();
            return(i);
        }
Ejemplo n.º 11
0
        public Dictionary <string, string> GetOptionsFields(Guid id, string sql)
        {
            Dictionary <string, string> list = new Dictionary <string, string>();

            RoadFlow.Platform.DBConnection   bdbconn = new RoadFlow.Platform.DBConnection();
            RoadFlow.Data.Model.DBConnection dbconn  = bdbconn.Get(id);
            using (System.Data.IDbConnection conn = bdbconn.GetConnection(dbconn))
            {
                if (conn == null)
                {
                    return(list);
                }
                try
                {
                    conn.Open();
                }
                catch (Exception ex)
                {
                    System.Web.HttpContext.Current.Response.Write("连接数据库出错:" + ex.Message);
                    RoadFlow.Platform.Log.Add(ex);
                }
                List <System.Data.IDataParameter> parList     = new List <System.Data.IDataParameter>();
                System.Data.IDbDataAdapter        dataAdapter = bdbconn.GetDataAdapter(conn, dbconn.Type, sql, parList.ToArray());
                System.Data.DataSet ds = new System.Data.DataSet();
                dataAdapter.Fill(ds);
                foreach (System.Data.DataRow row in ds.Tables[0].Rows)
                {
                    list.Add(row[0].ToString(), row[1].ToString());
                }
                return(list);
            }
        }
Ejemplo n.º 12
0
        public string GetNames_Table()
        {
            string str   = base.Request.QueryString["dbconn"];
            string text  = base.Request.QueryString["dbtable"];
            string text2 = base.Request.QueryString["valuefield"];
            string text3 = base.Request.QueryString["titlefield"];
            string text5 = base.Request.QueryString["parentfield"];
            string text6 = 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(str.ToGuid());
            StringBuilder stringBuilder = new StringBuilder();

            string[] array = obj.Split(',');
            foreach (string text4 in array)
            {
                if (!text4.IsNullOrEmpty())
                {
                    string    str2      = "select " + text3 + " from " + text + " where " + text2 + "='" + text4 + "'";
                    DataTable dataTable = dBConnection.GetDataTable(dbconn, str2.ReplaceSelectSql());
                    if (dataTable.Rows.Count > 0)
                    {
                        stringBuilder.Append(dataTable.Rows[0][0].ToString());
                        stringBuilder.Append(",");
                    }
                }
            }
            return(stringBuilder.ToString().TrimEnd(','));
        }
Ejemplo n.º 13
0
        public string GetJson_TableRefresh()
        {
            string str   = base.Request.QueryString["dbconn"];
            string text  = base.Request.QueryString["dbtable"];
            string text2 = base.Request.QueryString["valuefield"];
            string text3 = base.Request.QueryString["titlefield"];
            string text4 = base.Request.QueryString["parentfield"];
            string text7 = base.Request.QueryString["where"];
            string text5 = base.Request.QueryString["refreshid"];

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

            foreach (DataRow row in dataTable.Rows)
            {
                string text6 = row[0].ToString();
                string arg   = (dataTable.Columns.Count > 1) ? row[1].ToString() : text6;
                string str3  = "select * from " + text + " where " + text4 + "='" + text6 + "'";
                bool   flag  = dBConnection.GetDataTable(dbconn, str3.ReplaceSelectSql()).Rows.Count > 0;
                stringBuilder.Append("{");
                stringBuilder.AppendFormat("\"id\":\"{0}\",", text6);
                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(',') + "]");
        }
Ejemplo n.º 14
0
        public string GetJson_SQL()
        {
            if (!Tools.CheckLogin(false))
            {
                return("{}");
            }
            string str  = base.Request.QueryString["dbconn"];
            string str2 = base.Request.QueryString["sql"];

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

            foreach (DataRow row in dataTable.Rows)
            {
                string text = row[0].ToString();
                string arg  = (dataTable.Columns.Count > 1) ? row[1].ToString() : text;
                stringBuilder.Append("{");
                stringBuilder.AppendFormat("\"id\":\"{0}\",", text);
                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(',') + "]");
        }
Ejemplo n.º 15
0
 private Dictionary <string, string> getFields_MySql(RoadFlow.Data.Model.DBConnection conn, string table)
 {
     using (MySqlConnection MysqlConn = new MySqlConnection(conn.ConnectionString))
     {
         try
         {
             MysqlConn.Open();
         }
         catch (MySqlException err)
         {
             Log.Add(err);
             return(new Dictionary <string, string>());
         }
         Dictionary <string, string> fields = new Dictionary <string, string>();
         string sql = string.Format(@"select column_name as f_name,column_comment as value from information_schema.columns where  table_name='{0}'and table_schema ='{1}' ", table, MysqlConn.Database);
         using (MySqlCommand mysqlCmd = new MySqlCommand(sql, MysqlConn))
         {
             MySqlDataReader dr = mysqlCmd.ExecuteReader();
             while (dr.Read())
             {
                 fields.Add(dr.GetString(0), dr.IsDBNull(1) ? "" : dr.GetString(1));
             }
             dr.Close();
             return(fields);
         }
     }
 }
Ejemplo n.º 16
0
        public string TestLineSqlWhere()
        {
            string msg;

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

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

            if (dBConnection.TestSql(dBConnection2, sql))
            {
                return("SQL条件正确!");
            }
            return("SQL条件错误!");
        }
Ejemplo n.º 17
0
        public string GetNames_SQL()
        {
            string str  = base.Request.QueryString["dbconn"];
            string str2 = base.Request.QueryString["sql"];

            RoadFlow.Platform.DBConnection   dBConnection = new RoadFlow.Platform.DBConnection();
            RoadFlow.Data.Model.DBConnection dbconn       = dBConnection.Get(str.ToGuid());
            DataTable     dataTable     = dBConnection.GetDataTable(dbconn, str2.UrlDecode().FilterWildcard().ReplaceSelectSql());
            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(','));
        }
Ejemplo n.º 18
0
        public int Add(RoadFlow.Data.Model.DBConnection model)
        {
            //IL_0017: Unknown result type (might be due to invalid IL or missing references)
            //IL_001c: Unknown result type (might be due to invalid IL or missing references)
            //IL_002d: Expected O, but got Unknown
            //IL_002e: Expected O, but got Unknown
            //IL_003c: Unknown result type (might be due to invalid IL or missing references)
            //IL_0041: Unknown result type (might be due to invalid IL or missing references)
            //IL_004d: Expected O, but got Unknown
            //IL_004e: Expected O, but got Unknown
            //IL_005c: Unknown result type (might be due to invalid IL or missing references)
            //IL_0061: Unknown result type (might be due to invalid IL or missing references)
            //IL_006d: Expected O, but got Unknown
            //IL_006e: Expected O, but got Unknown
            //IL_0077: Unknown result type (might be due to invalid IL or missing references)
            //IL_007c: Unknown result type (might be due to invalid IL or missing references)
            //IL_0088: Expected O, but got Unknown
            //IL_0089: Expected O, but got Unknown
            //IL_009a: Unknown result type (might be due to invalid IL or missing references)
            //IL_009f: Unknown result type (might be due to invalid IL or missing references)
            //IL_00ab: Expected O, but got Unknown
            //IL_00b4: Unknown result type (might be due to invalid IL or missing references)
            //IL_00b9: Unknown result type (might be due to invalid IL or missing references)
            //IL_00c4: Expected O, but got Unknown
            //IL_00c5: Expected O, but got Unknown
            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[] obj = new OracleParameter[5];
            OracleParameter   val = new OracleParameter(":ID", 126, 40);

            ((DbParameter)val).Value = model.ID;
            obj[0] = val;
            OracleParameter val2 = new OracleParameter(":Name", 126, 500);

            ((DbParameter)val2).Value = model.Name;
            obj[1] = val2;
            OracleParameter val3 = new OracleParameter(":Type", 126, 500);

            ((DbParameter)val3).Value = model.Type;
            obj[2] = val3;
            OracleParameter val4 = new OracleParameter(":ConnectionString", 105);

            ((DbParameter)val4).Value = model.ConnectionString;
            obj[3] = val4;
            _003F val5;

            if (model.Note != null)
            {
                val5 = new OracleParameter(":Note", 105);
                ((DbParameter)val5).Value = model.Note;
            }
            else
            {
                val5 = new OracleParameter(":Note", 105);
                ((DbParameter)val5).Value = DBNull.Value;
            }
            obj[4] = val5;
            OracleParameter[] parameter = (OracleParameter[])obj;
            return(dbHelper.Execute(sql, parameter));
        }
Ejemplo n.º 19
0
        public int Update(RoadFlow.Data.Model.DBConnection model)
        {
            //IL_0019: Unknown result type (might be due to invalid IL or missing references)
            //IL_001e: Unknown result type (might be due to invalid IL or missing references)
            //IL_002a: Expected O, but got Unknown
            //IL_002b: Expected O, but got Unknown
            //IL_0038: Unknown result type (might be due to invalid IL or missing references)
            //IL_003d: Unknown result type (might be due to invalid IL or missing references)
            //IL_0049: Expected O, but got Unknown
            //IL_004a: Expected O, but got Unknown
            //IL_0057: Unknown result type (might be due to invalid IL or missing references)
            //IL_005c: Unknown result type (might be due to invalid IL or missing references)
            //IL_0068: Expected O, but got Unknown
            //IL_0069: Expected O, but got Unknown
            //IL_007e: Unknown result type (might be due to invalid IL or missing references)
            //IL_0083: Unknown result type (might be due to invalid IL or missing references)
            //IL_008f: Expected O, but got Unknown
            //IL_009c: Unknown result type (might be due to invalid IL or missing references)
            //IL_00a1: Unknown result type (might be due to invalid IL or missing references)
            //IL_00ac: Expected O, but got Unknown
            //IL_00ad: Expected O, but got Unknown
            //IL_00bb: Unknown result type (might be due to invalid IL or missing references)
            //IL_00c0: Unknown result type (might be due to invalid IL or missing references)
            //IL_00d1: Expected O, but got Unknown
            //IL_00d2: Expected O, but got Unknown
            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";

            MySqlParameter[] obj = new MySqlParameter[5];
            MySqlParameter   val = new MySqlParameter("@Name", 752, -1);

            ((DbParameter)val).Value = model.Name;
            obj[0] = val;
            MySqlParameter val2 = new MySqlParameter("@Type", 752, -1);

            ((DbParameter)val2).Value = model.Type;
            obj[1] = val2;
            MySqlParameter val3 = new MySqlParameter("@ConnectionString", 751, -1);

            ((DbParameter)val3).Value = model.ConnectionString;
            obj[2] = val3;
            _003F val4;

            if (model.Note != null)
            {
                val4 = new MySqlParameter("@Note", 751, -1);
                ((DbParameter)val4).Value = model.Note;
            }
            else
            {
                val4 = new MySqlParameter("@Note", 751, -1);
                ((DbParameter)val4).Value = DBNull.Value;
            }
            obj[3] = val4;
            MySqlParameter val5 = new MySqlParameter("@ID", 253, 36);

            ((DbParameter)val5).Value = model.ID;
            obj[4] = val5;
            MySqlParameter[] parameter = (MySqlParameter[])obj;
            return(dbHelper.Execute(sql, parameter));
        }
Ejemplo n.º 20
0
        public int Add(RoadFlow.Data.Model.DBConnection model)
        {
            //IL_001a: Unknown result type (might be due to invalid IL or missing references)
            //IL_001f: Unknown result type (might be due to invalid IL or missing references)
            //IL_0030: Expected O, but got Unknown
            //IL_0031: Expected O, but got Unknown
            //IL_003e: Unknown result type (might be due to invalid IL or missing references)
            //IL_0043: Unknown result type (might be due to invalid IL or missing references)
            //IL_004f: Expected O, but got Unknown
            //IL_0050: Expected O, but got Unknown
            //IL_005d: Unknown result type (might be due to invalid IL or missing references)
            //IL_0062: Unknown result type (might be due to invalid IL or missing references)
            //IL_006e: Expected O, but got Unknown
            //IL_006f: Expected O, but got Unknown
            //IL_007c: Unknown result type (might be due to invalid IL or missing references)
            //IL_0081: Unknown result type (might be due to invalid IL or missing references)
            //IL_008d: Expected O, but got Unknown
            //IL_008e: Expected O, but got Unknown
            //IL_00a3: Unknown result type (might be due to invalid IL or missing references)
            //IL_00a8: Unknown result type (might be due to invalid IL or missing references)
            //IL_00b4: Expected O, but got Unknown
            //IL_00c1: Unknown result type (might be due to invalid IL or missing references)
            //IL_00c6: Unknown result type (might be due to invalid IL or missing references)
            //IL_00d1: Expected O, but got Unknown
            //IL_00d2: Expected O, but got Unknown
            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)";

            MySqlParameter[] obj = new MySqlParameter[5];
            MySqlParameter   val = new MySqlParameter("@ID", 253, 36);

            ((DbParameter)val).Value = model.ID;
            obj[0] = val;
            MySqlParameter val2 = new MySqlParameter("@Name", 752, -1);

            ((DbParameter)val2).Value = model.Name;
            obj[1] = val2;
            MySqlParameter val3 = new MySqlParameter("@Type", 752, -1);

            ((DbParameter)val3).Value = model.Type;
            obj[2] = val3;
            MySqlParameter val4 = new MySqlParameter("@ConnectionString", 751, -1);

            ((DbParameter)val4).Value = model.ConnectionString;
            obj[3] = val4;
            _003F val5;

            if (model.Note != null)
            {
                val5 = new MySqlParameter("@Note", 751, -1);
                ((DbParameter)val5).Value = model.Note;
            }
            else
            {
                val5 = new MySqlParameter("@Note", 751, -1);
                ((DbParameter)val5).Value = DBNull.Value;
            }
            obj[4] = val5;
            MySqlParameter[] parameter = (MySqlParameter[])obj;
            return(dbHelper.Execute(sql, parameter));
        }
Ejemplo n.º 21
0
        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(empty2.ToGuid());
            if (dBConnection2 == null)
            {
                base.ViewBag.LiteralResult           = "未找到数据连接";
                base.ViewBag.LiteralResultCount.Text = "";
                return(View());
            }
            if (collection != null)
            {
                empty3 = base.Request.Form["sqltext"];
            }
            else
            {
                if (empty.IsNullOrEmpty())
                {
                    base.ViewBag.LiteralResult      = "";
                    base.ViewBag.LiteralResultCount = "";
                    return(View());
                }
                empty3 = dBConnection.GetDefaultQuerySql(dBConnection2, empty);
            }
            if (empty3.IsNullOrEmpty())
            {
                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.数据连接, dataTable.ToJsonString());
            base.ViewBag.LiteralResult      = Tools.DataTableToHtml(dataTable);
            base.ViewBag.LiteralResultCount = "(共" + dataTable.Rows.Count + "行)";
            base.ViewBag.sqltext            = empty3;
            return(View());
        }
Ejemplo n.º 22
0
        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.SystemDataTables;

            if (!text.IsGuid())
            {
                base.Response.Write("数据连接ID错误");
                base.Response.End();
                return(null);
            }
            RoadFlow.Data.Model.DBConnection dBConnection2 = dBConnection.Get(text.ToGuid());
            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());
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 根据连接实体得到数据表
        /// </summary>
        /// <param name="linkID"></param>
        /// <returns></returns>
        public System.Data.DataTable GetDataTable(RoadFlow.Data.Model.DBConnection dbconn, string sql)
        {
            if (dbconn == null || dbconn.Type.IsNullOrEmpty() || dbconn.ConnectionString.IsNullOrEmpty())
            {
                return(null);
            }
            DataTable dt = new DataTable();

            switch (dbconn.Type)
            {
            case "SqlServer":
                using (SqlConnection conn = new SqlConnection(dbconn.ConnectionString))
                {
                    try
                    {
                        conn.Open();
                        using (SqlDataAdapter dap = new SqlDataAdapter(sql, conn))
                        {
                            dap.Fill(dt);
                        }
                    }
                    catch (SqlException ex)
                    {
                        Platform.Log.Add(ex);
                    }
                }
                break;

            case "MySql":
                using (MySqlConnection conn = new MySqlConnection(dbconn.ConnectionString))
                {
                    try
                    {
                        conn.Open();
                        using (MySqlDataAdapter dap = new MySqlDataAdapter(sql, conn))
                        {
                            dap.Fill(dt);
                        }
                    }
                    catch (MySqlException ex)
                    {
                        Platform.Log.Add(ex);
                    }
                }
                break;
            }

            return(dt);
        }
Ejemplo n.º 24
0
        public ActionResult Edit(FormCollection collection)
        {
            string str = base.Request.QueryString["id"];

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

            if (dBConnection2 == null)
            {
                dBConnection2    = new RoadFlow.Data.Model.DBConnection();
                dBConnection2.ID = Guid.NewGuid();
            }
            else
            {
                oldXML = dBConnection2.Serialize();
            }
            if (collection != null)
            {
                string text             = base.Request.Form["Name"];
                string type             = base.Request.Form["LinkType"];
                string connectionString = base.Request.Form["ConnStr"];
                string note             = base.Request.Form["Note"];
                dBConnection2.Name             = text.Trim();
                dBConnection2.Type             = type;
                dBConnection2.ConnectionString = connectionString;
                dBConnection2.Note             = note;
                if (flag)
                {
                    dBConnection.Add(dBConnection2);
                    RoadFlow.Platform.Log.Add("添加了数据库连接", dBConnection2.Serialize(), 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, dBConnection2.Serialize());
                    base.ViewBag.Script = "alert('修改成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();";
                }
                dBConnection.ClearCache();
            }
            base.ViewBag.TypeOptions = dBConnection.GetAllTypeOptions(dBConnection2.Type);
            return(View(dBConnection2));
        }
Ejemplo n.º 25
0
 private string test_MySql(RoadFlow.Data.Model.DBConnection conn)
 {
     using (MySqlConnection sqlConn = new MySqlConnection(conn.ConnectionString))
     {
         try
         {
             sqlConn.Open();
             return("连接成功!");
         }
         catch (MySqlException err)
         {
             return(err.Message);
         }
     }
 }
        public string TestSql()
        {
            string str  = base.Request["sql"];
            string str2 = base.Request["dbconn"];

            if (str.IsNullOrEmpty() || !str2.IsGuid())
            {
                return("SQL语句为空或未设置数据连接");
            }
            RoadFlow.Platform.DBConnection   dBConnection = new RoadFlow.Platform.DBConnection();
            RoadFlow.Data.Model.DBConnection dbconn       = dBConnection.Get(str2.ToGuid());
            if (dBConnection.TestSql(dbconn, str.ReplaceSelectSql().FilterWildcard()))
            {
                return("SQL语句测试正确");
            }
            return("SQL语句测试错误");
        }
Ejemplo n.º 27
0
        private List <RoadFlow.Data.Model.DBConnection> DataReaderToList(SqlDataReader dataReader)
        {
            List <RoadFlow.Data.Model.DBConnection> list = new List <RoadFlow.Data.Model.DBConnection>();

            RoadFlow.Data.Model.DBConnection dBConnection = null;
            while (dataReader.Read())
            {
                dBConnection                  = new RoadFlow.Data.Model.DBConnection();
                dBConnection.ID               = dataReader.GetGuid(0);
                dBConnection.Name             = dataReader.GetString(1);
                dBConnection.Type             = dataReader.GetString(2);
                dBConnection.ConnectionString = dataReader.GetString(3);
                if (!dataReader.IsDBNull(4))
                {
                    dBConnection.Note = dataReader.GetString(4);
                }
                list.Add(dBConnection);
            }
            return(list);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 将DataRedar转换为List
        /// </summary>
        private List <RoadFlow.Data.Model.DBConnection> DataReaderToList(SqlDataReader dataReader)
        {
            List <RoadFlow.Data.Model.DBConnection> List = new List <RoadFlow.Data.Model.DBConnection>();

            RoadFlow.Data.Model.DBConnection model = null;
            while (dataReader.Read())
            {
                model                  = new RoadFlow.Data.Model.DBConnection();
                model.ID               = dataReader.GetGuid(0);
                model.Name             = dataReader.GetString(1);
                model.Type             = dataReader.GetString(2);
                model.ConnectionString = dataReader.GetString(3);
                if (!dataReader.IsDBNull(4))
                {
                    model.Note = dataReader.GetString(4);
                }
                List.Add(model);
            }
            return(List);
        }
Ejemplo n.º 29
0
        private List <RoadFlow.Data.Model.DBConnection> DataReaderToList(OracleDataReader dataReader)
        {
            List <RoadFlow.Data.Model.DBConnection> list = new List <RoadFlow.Data.Model.DBConnection>();

            RoadFlow.Data.Model.DBConnection dBConnection = null;
            while (((DbDataReader)dataReader).Read())
            {
                dBConnection                  = new RoadFlow.Data.Model.DBConnection();
                dBConnection.ID               = ((DbDataReader)dataReader).GetString(0).ToGuid();
                dBConnection.Name             = ((DbDataReader)dataReader).GetString(1);
                dBConnection.Type             = ((DbDataReader)dataReader).GetString(2);
                dBConnection.ConnectionString = ((DbDataReader)dataReader).GetString(3);
                if (!((DbDataReader)dataReader).IsDBNull(4))
                {
                    dBConnection.Note = ((DbDataReader)dataReader).GetString(4);
                }
                list.Add(dBConnection);
            }
            return(list);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 根据连接实体得到连接
        /// </summary>
        /// <param name="linkID"></param>
        /// <returns></returns>
        public System.Data.IDbConnection GetConnection(RoadFlow.Data.Model.DBConnection dbconn)
        {
            if (dbconn == null || dbconn.Type.IsNullOrEmpty() || dbconn.ConnectionString.IsNullOrEmpty())
            {
                return(null);
            }
            IDbConnection conn = null;

            switch (dbconn.Type)
            {
            case "SqlServer":
                conn = new SqlConnection(dbconn.ConnectionString);
                break;

            case "MySql":
                conn = new MySqlConnection(dbconn.ConnectionString);
                break;
            }

            return(conn);
        }