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 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(','));
        }
        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(',') + "]");
        }
        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(','));
        }
        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);
            }
        }
        //
        // GET: /DBConnection/

        public ActionResult Index()
        {
            string query1 = string.Format("&appid={0}&tabid={1}", Request.QueryString["appid"], Request.QueryString["tabid"]);

            RoadFlow.Platform.DBConnection bdbconn = new RoadFlow.Platform.DBConnection();

            if (!Request.Form["DeleteBut"].IsNullOrEmpty())
            {
                string deleteID = Request.Form["checkbox_app"];
                System.Text.StringBuilder delxml = new System.Text.StringBuilder();
                foreach (string id in deleteID.Split(','))
                {
                    Guid gid;
                    if (id.IsGuid(out gid))
                    {
                        delxml.Append(bdbconn.Get(gid).Serialize());
                        bdbconn.Delete(gid);
                    }
                }
                bdbconn.ClearCache();
                RoadFlow.Platform.Log.Add("删除了数据连接", delxml.ToString(), RoadFlow.Platform.Log.Types.流程相关);
            }


            var connList = bdbconn.GetAll();

            ViewBag.Query1 = query1;
            return(View(connList));
        }
Exemple #7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string dbconn      = context.Request.QueryString["dbconn"];
            string dbtable     = context.Request.QueryString["dbtable"];
            string valuefield  = context.Request.QueryString["valuefield"];
            string titlefield  = context.Request.QueryString["titlefield"];
            string parentfield = context.Request.QueryString["parentfield"];

            string where = (context.Request.QueryString["where"] ?? "").UrlDecode();

            RoadFlow.Platform.DBConnection bdbconn = new RoadFlow.Platform.DBConnection();
            var       conn = bdbconn.Get(dbconn.ToGuid());
            string    sql  = "select " + valuefield + "," + titlefield + " from " + dbtable + (where.IsNullOrEmpty() ? "" : " where " + where);
            DataTable dt   = bdbconn.GetDataTable(conn, sql.ReplaceSelectSql());

            System.Text.StringBuilder json = new System.Text.StringBuilder(1000);
            foreach (System.Data.DataRow dr in dt.Rows)
            {
                string value     = dr[0].ToString();
                string title     = dt.Columns.Count > 1 ? dr[1].ToString() : value;
                string sql1      = "select * from " + dbtable + " where " + parentfield + "='" + value + "'";
                bool   hasChilds = bdbconn.GetDataTable(conn, sql1.ReplaceSelectSql()).Rows.Count > 0;
                json.Append("{");
                json.AppendFormat("\"id\":\"{0}\",", value);
                json.AppendFormat("\"parentID\":\"{0}\",", Guid.Empty.ToString());
                json.AppendFormat("\"title\":\"{0}\",", title);
                json.AppendFormat("\"type\":\"{0}\",", hasChilds ? "1" : "2"); //类型:0根 1父 2子
                json.AppendFormat("\"ico\":\"{0}\",", "");
                json.AppendFormat("\"hasChilds\":\"{0}\",", hasChilds ? "1" : "0");
                json.Append("\"childs\":[]},");
            }
            context.Response.Write("[" + json.ToString().TrimEnd(',') + "]");
        }
Exemple #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string query1 = string.Format("&appid={0}&tabid={1}", Request.QueryString["appid"], Request.QueryString["tabid"]);

            RoadFlow.Platform.DBConnection bdbconn = new RoadFlow.Platform.DBConnection();

            if (IsPostBack)
            {
                if (!Request.Form["DeleteBut"].IsNullOrEmpty())
                {
                    string deleteID = Request.Form["checkbox_app"];
                    System.Text.StringBuilder delxml = new System.Text.StringBuilder();
                    foreach (string id in deleteID.Split(','))
                    {
                        Guid gid;
                        if (id.IsGuid(out gid))
                        {
                            delxml.Append(bdbconn.Get(gid).Serialize());
                            bdbconn.Delete(gid);
                        }
                    }
                    bdbconn.ClearCache();
                    RoadFlow.Platform.Log.Add("删除了数据连接", delxml.ToString(), RoadFlow.Platform.Log.Types.流程相关);
                }
            }

            ConnList = bdbconn.GetAll();
            Query1   = query1;
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string dbconn      = context.Request.QueryString["dbconn"];
            string dbtable     = context.Request.QueryString["dbtable"];
            string valuefield  = context.Request.QueryString["valuefield"];
            string titlefield  = context.Request.QueryString["titlefield"];
            string parentfield = context.Request.QueryString["parentfield"];

            string where = context.Request.QueryString["where"];
            string values = context.Request.QueryString["values"] ?? "";

            RoadFlow.Platform.DBConnection bdbconn = new RoadFlow.Platform.DBConnection();
            var conn = bdbconn.Get(dbconn.ToGuid());

            System.Text.StringBuilder names = new System.Text.StringBuilder();
            foreach (string value in values.Split(','))
            {
                if (value.IsNullOrEmpty())
                {
                    continue;
                }
                string    sql = "select " + titlefield + " from " + dbtable + " where " + valuefield + "='" + value + "'";
                DataTable dt  = bdbconn.GetDataTable(conn, sql.ReplaceSelectSql());
                if (dt.Rows.Count > 0)
                {
                    names.Append(dt.Rows[0][0].ToString());
                    names.Append(",");
                }
            }
            context.Response.Write(names.ToString().TrimEnd(','));
        }
        /// <summary>
        /// 测试连接的sql条件
        /// </summary>
        /// <returns></returns>
        public string TestLineSqlWhere()
        {
            string connid  = Request["connid"];
            string table   = Request["table"];
            string tablepk = Request["tablepk"];

            string where = Request["where"];

            RoadFlow.Platform.DBConnection dbconn = new RoadFlow.Platform.DBConnection();

            if (!connid.IsGuid())
            {
                return("流程未设置数据连接!");
            }
            var conn = dbconn.Get(connid.ToGuid());

            if (conn == null)
            {
                return("未找到连接!");
            }
            string sql = "SELECT * FROM " + table + " WHERE 1=1 AND " + where;

            if (dbconn.TestSql(conn, sql))
            {
                return("SQL条件正确!");
            }
            else
            {
                return("SQL条件错误!");
            }
        }
Exemple #11
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(',') + "]");
        }
Exemple #12
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(','));
        }
Exemple #13
0
        public string GetNames_SQL()
        {
            string str1 = this.Request.QueryString["dbconn"];
            string str2 = this.Request.QueryString["sql"];

            RoadFlow.Platform.DBConnection dbConnection = new RoadFlow.Platform.DBConnection();
            DataTable     dataTable     = dbConnection.GetDataTable(dbConnection.Get(str1.ToGuid(), true), str2.UrlDecode().FilterWildcard("").ReplaceSelectSql(), (IDataParameter[])null);
            string        str3          = this.Request.QueryString["values"] ?? "";
            StringBuilder stringBuilder = new StringBuilder();

            char[] chArray = new char[1] {
                ','
            };
            foreach (string str4 in str3.Split(chArray))
            {
                string empty = string.Empty;
                string str5  = string.Empty;
                foreach (DataRow row in (InternalDataCollectionBase)dataTable.Rows)
                {
                    string str6 = row[0].ToString();
                    if (str4 == str6)
                    {
                        str5 = dataTable.Columns.Count > 1 ? row[1].ToString() : str6;
                        break;
                    }
                }
                stringBuilder.Append(str5);
                stringBuilder.Append(',');
            }
            return(stringBuilder.ToString().TrimEnd(','));
        }
Exemple #14
0
        public string GetJson_SQL()
        {
            if (!Tools.CheckLogin(false))
            {
                return("{}");
            }
            string str1 = this.Request.QueryString["dbconn"];
            string str2 = this.Request.QueryString["sql"];

            RoadFlow.Platform.DBConnection dbConnection = new RoadFlow.Platform.DBConnection();
            DataTable     dataTable     = dbConnection.GetDataTable(dbConnection.Get(str1.ToGuid(), true), str2.UrlDecode().FilterWildcard("").ReplaceSelectSql(), (IDataParameter[])null);
            StringBuilder stringBuilder = new StringBuilder(1000);

            foreach (DataRow row in (InternalDataCollectionBase)dataTable.Rows)
            {
                string str3 = row[0].ToString();
                string str4 = dataTable.Columns.Count > 1 ? row[1].ToString() : str3;
                stringBuilder.Append("{");
                stringBuilder.AppendFormat("\"id\":\"{0}\",", (object)str3);
                stringBuilder.AppendFormat("\"parentID\":\"{0}\",", (object)Guid.Empty.ToString());
                stringBuilder.AppendFormat("\"title\":\"{0}\",", (object)str4);
                stringBuilder.AppendFormat("\"type\":\"{0}\",", (object)"2");
                stringBuilder.AppendFormat("\"ico\":\"{0}\",", (object)"");
                stringBuilder.AppendFormat("\"hasChilds\":\"{0}\",", (object)"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 void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string dbconn = context.Request.QueryString["dbconn"];
            string sql    = context.Request.QueryString["sql"];

            RoadFlow.Platform.DBConnection conn = new RoadFlow.Platform.DBConnection();
            var       conn1 = conn.Get(dbconn.ToGuid());
            DataTable dt    = conn.GetDataTable(conn1, sql.UrlDecode().ReplaceSelectSql());

            string values = context.Request.QueryString["values"] ?? "";

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            foreach (string value in values.Split(','))
            {
                string value1 = string.Empty;
                string title1 = string.Empty;
                foreach (DataRow dr in dt.Rows)
                {
                    value1 = dr[0].ToString();
                    if (value == value1)
                    {
                        title1 = dt.Columns.Count > 1 ? dr[1].ToString() : value1;
                        break;
                    }
                }
                sb.Append(title1);
                sb.Append(',');
            }
            context.Response.Write(sb.ToString().TrimEnd(','));
        }
Exemple #17
0
        public string GetJson_TableRefresh()
        {
            string dbconn      = Request.QueryString["dbconn"];
            string dbtable     = Request.QueryString["dbtable"];
            string valuefield  = Request.QueryString["valuefield"];
            string titlefield  = Request.QueryString["titlefield"];
            string parentfield = Request.QueryString["parentfield"];

            string where = Request.QueryString["where"];
            string id = Request.QueryString["refreshid"];

            RoadFlow.Platform.DBConnection bdbconn = new RoadFlow.Platform.DBConnection();
            var       conn = bdbconn.Get(dbconn.ToGuid());
            string    sql  = "select " + valuefield + "," + titlefield + " from " + dbtable + " where " + parentfield + "='" + id + "'";
            DataTable dt   = bdbconn.GetDataTable(conn, sql.ReplaceSelectSql());

            System.Text.StringBuilder json = new System.Text.StringBuilder(1000);
            foreach (System.Data.DataRow dr in dt.Rows)
            {
                string value     = dr[0].ToString();
                string title     = dt.Columns.Count > 1 ? dr[1].ToString() : value;
                string sql1      = "select * from " + dbtable + " where " + parentfield + "='" + value + "'";
                bool   hasChilds = bdbconn.GetDataTable(conn, sql1.ReplaceSelectSql()).Rows.Count > 0;
                json.Append("{");
                json.AppendFormat("\"id\":\"{0}\",", value);
                json.AppendFormat("\"parentID\":\"{0}\",", Guid.Empty.ToString());
                json.AppendFormat("\"title\":\"{0}\",", title);
                json.AppendFormat("\"type\":\"{0}\",", hasChilds ? "1" : "2"); //类型:0根 1父 2子
                json.AppendFormat("\"ico\":\"{0}\",", "");
                json.AppendFormat("\"hasChilds\":\"{0}\",", hasChilds ? "1" : "0");
                json.Append("\"childs\":[]},");
            }
            return("[" + json.ToString().TrimEnd(',') + "]");
        }
Exemple #18
0
        public string GetJson_SQL()
        {
            if (!Common.Tools.CheckLogin(false))
            {
                return("{}");
            }
            string dbconn = Request.QueryString["dbconn"];
            string sql    = Request.QueryString["sql"];

            RoadFlow.Platform.DBConnection conn = new RoadFlow.Platform.DBConnection();
            var conn1 = conn.Get(dbconn.ToGuid());

            System.Data.DataTable     dt   = conn.GetDataTable(conn1, sql.UrlDecode().ReplaceSelectSql());
            System.Text.StringBuilder json = new System.Text.StringBuilder(1000);
            foreach (System.Data.DataRow dr in dt.Rows)
            {
                string value = dr[0].ToString();
                string title = dt.Columns.Count > 1 ? dr[1].ToString() : value;
                json.Append("{");
                json.AppendFormat("\"id\":\"{0}\",", value);
                json.AppendFormat("\"parentID\":\"{0}\",", Guid.Empty.ToString());
                json.AppendFormat("\"title\":\"{0}\",", title);
                json.AppendFormat("\"type\":\"{0}\",", "2"); //类型:0根 1父 2子
                json.AppendFormat("\"ico\":\"{0}\",", "");
                json.AppendFormat("\"hasChilds\":\"{0}\",", "0");
                json.Append("\"childs\":[]},");
            }
            return("[" + json.ToString().TrimEnd(',') + "]");
        }
Exemple #19
0
        public string GetNames_SQL()
        {
            string dbconn = Request.QueryString["dbconn"];
            string sql    = Request.QueryString["sql"];

            RoadFlow.Platform.DBConnection conn = new RoadFlow.Platform.DBConnection();
            var       conn1  = conn.Get(dbconn.ToGuid());
            DataTable dt     = conn.GetDataTable(conn1, sql.UrlDecode().ReplaceSelectSql());
            string    values = Request.QueryString["values"] ?? "";

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            foreach (string value in values.Split(','))
            {
                string value1 = string.Empty;
                string title1 = string.Empty;
                foreach (DataRow dr in dt.Rows)
                {
                    value1 = dr[0].ToString();
                    if (value == value1)
                    {
                        title1 = dt.Columns.Count > 1 ? dr[1].ToString() : value1;
                        break;
                    }
                }
                sb.Append(title1);
                sb.Append(',');
            }
            return(sb.ToString().TrimEnd(','));
        }
Exemple #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 string TestSql()
        {
            string str1 = this.Request["sql"];
            string str2 = this.Request["dbconn"];

            if (str1.IsNullOrEmpty() || !str2.IsGuid())
            {
                return("SQL语句为空或未设置数据连接");
            }
            RoadFlow.Platform.DBConnection dbConnection = new RoadFlow.Platform.DBConnection();
            return(dbConnection.TestSql(dbConnection.Get(str2.ToGuid(), true), str1.ReplaceSelectSql().FilterWildcard(""), true) ? "SQL语句测试正确" : "SQL语句测试错误");
        }
        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 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 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));
        }
        public string Delete()
        {
            RoadFlow.Platform.DBConnection dBConnection = new RoadFlow.Platform.DBConnection();
            string        text          = base.Request.Form["ids"];
            StringBuilder stringBuilder = new StringBuilder();

            string[] array = text.Split(',');
            for (int i = 0; i < array.Length; i++)
            {
                Guid id = default(Guid);
                if (MyExtensions.IsGuid(array[i], out id))
                {
                    stringBuilder.Append(MyExtensions.Serialize((object)dBConnection.Get(id)));
                    dBConnection.Delete(id);
                }
            }
            dBConnection.ClearCache();
            RoadFlow.Platform.Log.Add("删除了数据连接", stringBuilder.ToString(), RoadFlow.Platform.Log.Types.流程相关);
            return("删除成功!");
        }
Exemple #27
0
        public string TestSql()
        {
            string sql    = Request["sql"];
            string dbconn = Request["dbconn"];

            if (sql.IsNullOrEmpty() || !dbconn.IsGuid())
            {
                return("SQL语句为空或未设置数据连接");
            }

            RoadFlow.Platform.DBConnection bdbconn = new RoadFlow.Platform.DBConnection();
            var dbconn1 = bdbconn.Get(dbconn.Convert <Guid>());

            if (bdbconn.TestSql(dbconn1, sql))
            {
                return("SQL语句测试正确");
            }
            else
            {
                return("SQL语句测试错误");
            }
        }
Exemple #28
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string connid  = context.Request["connid"];
            string table   = context.Request["table"];
            string tablepk = context.Request["tablepk"];

            string where = context.Request["where"];

            RoadFlow.Platform.DBConnection dbconn = new RoadFlow.Platform.DBConnection();

            if (!connid.IsGuid())
            {
                context.Response.Write("流程未设置数据连接!");
                return;
            }
            var conn = dbconn.Get(connid.ToGuid());

            if (conn == null)
            {
                context.Response.Write("未找到连接!");
                return;
            }
            string sql = "SELECT * FROM " + table + " WHERE 1=1 AND " + where;

            if (dbconn.TestSql(conn, sql))
            {
                context.Response.Write("SQL条件正确!");
                return;
            }
            else
            {
                context.Response.Write("SQL条件错误!");
                return;
            }
        }
Exemple #29
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string sql    = context.Request["sql"];
            string dbconn = context.Request["dbconn"];

            if (sql.IsNullOrEmpty() || !dbconn.IsGuid())
            {
                context.Response.Write("SQL语句为空或未设置数据连接");
                return;
            }

            RoadFlow.Platform.DBConnection bdbconn = new RoadFlow.Platform.DBConnection();
            var dbconn1 = bdbconn.Get(dbconn.ToGuid());

            if (bdbconn.TestSql(dbconn1, sql))
            {
                context.Response.Write("SQL语句测试正确");
            }
            else
            {
                context.Response.Write("SQL语句测试错误");
            }
        }
Exemple #30
0
        public ActionResult Index()
        {
            RoadFlow.Platform.Dictionary dictionary = new RoadFlow.Platform.Dictionary();
            string    obj       = base.Request.QueryString["values"] ?? "";
            string    text12    = base.Request.QueryString["rootid"];
            string    text      = base.Request.QueryString["datasource"];
            string    text2     = base.Request.QueryString["sql"];
            DataTable dataTable = new DataTable();

            if ("1" == text)
            {
                string text3 = base.Request.QueryString["dbconn"];
                RoadFlow.Platform.DBConnection   dBConnection = new RoadFlow.Platform.DBConnection();
                RoadFlow.Data.Model.DBConnection dbconn       = dBConnection.Get(MyExtensions.ToGuid(text3));
                dataTable = dBConnection.GetDataTable(dbconn, MyExtensions.ReplaceSelectSql(MyExtensions.UrlDecode(text2).FilterWildcard()));
            }
            StringBuilder stringBuilder = new StringBuilder();

            string[] array = obj.Split(',');
            foreach (string text4 in array)
            {
                if (!MyExtensions.IsNullOrEmpty(text4))
                {
                    if (!(text == "0"))
                    {
                        if (text == "1")
                        {
                            string value = string.Empty;
                            foreach (DataRow row in dataTable.Rows)
                            {
                                if (text4 == row[0].ToString())
                                {
                                    value = ((dataTable.Columns.Count > 1) ? row[1].ToString() : text4);
                                    break;
                                }
                            }
                            stringBuilder.AppendFormat("<div onclick=\"currentDel=this;showinfo('{0}');\" class=\"selectorDiv\" ondblclick=\"currentDel=this;del();\" value=\"{0}\">", text4);
                            stringBuilder.Append(value);
                            stringBuilder.Append("</div>");
                            continue;
                        }
                        if (text == "2")
                        {
                            string text5 = base.Request.QueryString["url2"];
                            if (!MyExtensions.IsNullOrEmpty(text5))
                            {
                                text5 = ((text5.IndexOf('?') >= 0) ? (text5 + "&values=" + text4) : (text5 + "?values=" + text4));
                                StringBuilder stringBuilder2 = new StringBuilder();
                                try
                                {
                                    TextWriter writer = new StringWriter(stringBuilder2);
                                    base.Server.Execute(text5, writer);
                                }
                                catch
                                {
                                }
                                stringBuilder.AppendFormat("<div onclick=\"currentDel=this;showinfo('{0}');\" class=\"selectorDiv\" ondblclick=\"currentDel=this;del();\" value=\"{0}\">", text4);
                                stringBuilder.Append(stringBuilder2.ToString());
                                stringBuilder.Append("</div>");
                            }
                            continue;
                        }
                        if (text == "3")
                        {
                            string text6  = base.Request.QueryString["dbconn"];
                            string text7  = base.Request.QueryString["dbtable"];
                            string text8  = base.Request.QueryString["valuefield"];
                            string text9  = base.Request.QueryString["titlefield"];
                            string text13 = base.Request.QueryString["parentfield"];
                            string text10 = base.Request.QueryString["where1"];
                            RoadFlow.Platform.DBConnection   dBConnection2 = new RoadFlow.Platform.DBConnection();
                            RoadFlow.Data.Model.DBConnection dbconn2       = dBConnection2.Get(MyExtensions.ToGuid(text6));
                            string    text11     = "select " + text9 + " from " + text7 + " where " + text8 + "='" + text4 + "'";
                            DataTable dataTable2 = dBConnection2.GetDataTable(dbconn2, MyExtensions.ReplaceSelectSql(text11));
                            string    value2     = string.Empty;
                            if (dataTable2.Rows.Count > 0)
                            {
                                value2 = dataTable2.Rows[0][0].ToString();
                            }
                            stringBuilder.AppendFormat("<div onclick=\"currentDel=this;showinfo('{0}');\" class=\"selectorDiv\" ondblclick=\"currentDel=this;del();\" value=\"{0}\">", text4);
                            stringBuilder.Append(value2);
                            stringBuilder.Append("</div>");
                            base.ViewBag.where = MyExtensions.UrlEncode(text10);
                            continue;
                        }
                    }
                    Guid id = default(Guid);
                    if (MyExtensions.IsGuid(text4, out id))
                    {
                        stringBuilder.AppendFormat("<div onclick=\"currentDel=this;showinfo('{0}');\" class=\"selectorDiv\" ondblclick=\"currentDel=this;del();\" value=\"{0}\">", text4);
                        stringBuilder.Append(dictionary.GetTitle(id));
                        stringBuilder.Append("</div>");
                    }
                }
            }
            base.ViewBag.defaultValuesString = MyExtensions.Trim1(stringBuilder.ToString());
            return(View());
        }