예제 #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (!Common.Tools.CheckLogin(false))
            {
                context.Response.Write("{}");
                context.Response.End();
                return;
            }
            string dbconn = context.Request.QueryString["dbconn"];
            string sql    = context.Request.QueryString["sql"];

            MyCreek.Platform.DBConnection conn = new MyCreek.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\":[]},");
            }
            context.Response.Write("[" + json.ToString().TrimEnd(',') + "]");
        }
예제 #2
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"];
            string values = context.Request.QueryString["values"] ?? "";

            MyCreek.Platform.DBConnection bdbconn = new MyCreek.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(','));
        }
예제 #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string dbconn = context.Request.QueryString["dbconn"];
            string sql    = context.Request.QueryString["sql"];

            MyCreek.Platform.DBConnection conn = new MyCreek.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(','));
        }
예제 #4
0
        //
        // GET: /DBConnection/

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

            MyCreek.Platform.DBConnection bdbconn = new MyCreek.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();
                MyCreek.Platform.Log.Add("删除了数据连接", delxml.ToString(), MyCreek.Platform.Log.Types.流程相关);
            }


            var connList = bdbconn.GetAll();

            ViewBag.Query1 = query1;
            return(View(connList));
        }
예제 #5
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"];

            MyCreek.Platform.DBConnection bdbconn = new MyCreek.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(',') + "]");
        }
예제 #6
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();

            MyCreek.Platform.DBConnection bdbconn = new MyCreek.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(',') + "]");
        }
        /// <summary>
        /// 测试连接的sql条件
        /// </summary>
        /// <returns></returns>
        public string TestLineSqlWhere()
        {
            string connid  = Request["connid"];
            string table   = Request["table"];
            string tablepk = Request["tablepk"];

            string where = Request["where"];

            MyCreek.Platform.DBConnection dbconn = new MyCreek.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条件错误!");
            }
        }
예제 #8
0
        public string GetNames_SQL()
        {
            string dbconn = Request.QueryString["dbconn"];
            string sql    = Request.QueryString["sql"];

            MyCreek.Platform.DBConnection conn = new MyCreek.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(','));
        }
예제 #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string query1 = string.Format("&appid={0}&tabid={1}", Request.QueryString["appid"], Request.QueryString["tabid"]);

            MyCreek.Platform.DBConnection bdbconn = new MyCreek.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();
                    MyCreek.Platform.Log.Add("删除了数据连接", delxml.ToString(), MyCreek.Platform.Log.Types.流程相关);
                }
            }

            ConnList = bdbconn.GetAll();
            Query1   = query1;
        }
예제 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string editid = Request.QueryString["id"];

            MyCreek.Platform.DBConnection   bdbConn = new MyCreek.Platform.DBConnection();
            MyCreek.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 MyCreek.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);
                    MyCreek.Platform.Log.Add("添加了应用程序库", dbconn.Serialize(), MyCreek.Platform.Log.Types.角色应用);
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('添加成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();", true);
                }
                else
                {
                    bdbConn.Update(dbconn);
                    MyCreek.Platform.Log.Add("修改了应用程序库", "", MyCreek.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);
        }
예제 #11
0
        public ActionResult Edit(FormCollection collection)
        {
            string editid = Request.QueryString["id"];

            MyCreek.Platform.DBConnection   bdbConn = new MyCreek.Platform.DBConnection();
            MyCreek.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 MyCreek.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);
                    MyCreek.Platform.Log.Add("添加了应用程序库", dbconn.Serialize(), MyCreek.Platform.Log.Types.角色应用);
                    ViewBag.Script = "alert('添加成功!');new RoadUI.Window().reloadOpener();new RoadUI.Window().close();";
                }
                else
                {
                    bdbConn.Update(dbconn);
                    MyCreek.Platform.Log.Add("修改了应用程序库", "", MyCreek.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 string TestSql()
        {
            string sql    = Request["sql"];
            string dbconn = Request["dbconn"];

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

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

            if (bdbconn.TestSql(dbconn1, sql))
            {
                return("SQL语句测试正确");
            }
            else
            {
                return("SQL语句测试错误");
            }
        }
예제 #13
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;
            }

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

            if (bdbconn.TestSql(dbconn1, sql))
            {
                context.Response.Write("SQL语句测试正确");
            }
            else
            {
                context.Response.Write("SQL语句测试错误");
            }
        }
예제 #14
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"];

            MyCreek.Platform.DBConnection dbconn = new MyCreek.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;
            }
        }
예제 #15
0
        //
        // GET: /Controls/SelectDict/

        public ActionResult Index()
        {
            MyCreek.Platform.Dictionary Dict = new MyCreek.Platform.Dictionary();

            string values     = Request.QueryString["values"] ?? "";
            string rootid     = Request.QueryString["rootid"];
            string datasource = Request.QueryString["datasource"];
            string sql        = Request.QueryString["sql"];

            DataTable SqlDataTable = new DataTable();

            if ("1" == datasource)
            {
                string dbconn = Request.QueryString["dbconn"];
                MyCreek.Platform.DBConnection conn = new MyCreek.Platform.DBConnection();
                var conn1 = conn.Get(dbconn.ToGuid());
                SqlDataTable = conn.GetDataTable(conn1, sql.UrlDecode().ReplaceSelectSql());
            }

            System.Text.StringBuilder defautlSB = new System.Text.StringBuilder();
            foreach (string value in values.Split(','))
            {
                switch (datasource)
                {
                case "0":
                default:
                    Guid id;
                    if (!value.IsGuid(out id))
                    {
                        continue;
                    }
                    defautlSB.AppendFormat("<div onclick=\"currentDel=this;showinfo('{0}');\" class=\"selectorDiv\" ondblclick=\"currentDel=this;del();\" value=\"{0}\">", value);
                    defautlSB.Append(Dict.GetTitle(id));
                    defautlSB.Append("</div>");
                    break;

                case "1":    //SQL
                    string title1 = string.Empty;
                    foreach (DataRow dr in SqlDataTable.Rows)
                    {
                        if (value == dr[0].ToString())
                        {
                            title1 = SqlDataTable.Columns.Count > 1 ? dr[1].ToString() : value;
                            break;
                        }
                    }
                    defautlSB.AppendFormat("<div onclick=\"currentDel=this;showinfo('{0}');\" class=\"selectorDiv\" ondblclick=\"currentDel=this;del();\" value=\"{0}\">", value);
                    defautlSB.Append(title1);
                    defautlSB.Append("</div>");
                    break;

                case "2":    //url
                    string url2 = Request.QueryString["url2"];
                    if (!url2.IsNullOrEmpty())
                    {
                        url2 = url2.IndexOf('?') >= 0 ? url2 + "&values=" + value : url2 + "?values=" + value;
                        System.Text.StringBuilder sb = new System.Text.StringBuilder();

                        try
                        {
                            System.IO.TextWriter tw = new System.IO.StringWriter(sb);
                            Server.Execute(url2, tw);
                        }
                        catch { }
                        defautlSB.AppendFormat("<div onclick=\"currentDel=this;showinfo('{0}');\" class=\"selectorDiv\" ondblclick=\"currentDel=this;del();\" value=\"{0}\">", value);
                        defautlSB.Append(sb.ToString());
                        defautlSB.Append("</div>");
                    }
                    break;

                case "3":    //table
                    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["where1"];
                    MyCreek.Platform.DBConnection bdbconn = new MyCreek.Platform.DBConnection();
                    var       conn   = bdbconn.Get(dbconn.ToGuid());
                    string    sql2   = "select " + titlefield + " from " + dbtable + " where " + valuefield + "='" + value + "'";
                    DataTable dt     = bdbconn.GetDataTable(conn, sql2.ReplaceSelectSql());
                    string    title3 = string.Empty;
                    if (dt.Rows.Count > 0)
                    {
                        title3 = dt.Rows[0][0].ToString();
                    }
                    defautlSB.AppendFormat("<div onclick=\"currentDel=this;showinfo('{0}');\" class=\"selectorDiv\" ondblclick=\"currentDel=this;del();\" value=\"{0}\">", value);
                    defautlSB.Append(title3);
                    defautlSB.Append("</div>");
                    ViewBag.where = where.UrlEncode();
                    break;
                }
            }
            ViewBag.defaultValuesString = defautlSB.ToString();
            return(View());
        }