Example #1
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 id = context.Request.QueryString["refreshid"];

            FoWoSoft.Platform.DBConnection bdbconn = new FoWoSoft.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\":[]},");
            }
            context.Response.Write("[" + json.ToString().TrimEnd(',') + "]");
        }
Example #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string dbconn = context.Request.QueryString["dbconn"];
            string sql    = context.Request.QueryString["sql"];

            FoWoSoft.Platform.DBConnection conn = new FoWoSoft.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(','));
        }
Example #3
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"] ?? "";

            FoWoSoft.Platform.DBConnection bdbconn = new FoWoSoft.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(','));
        }
Example #4
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"];

            FoWoSoft.Platform.DBConnection conn = new FoWoSoft.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(',') + "]");
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            FoWoSoft.Platform.Dictionary Dict = new FoWoSoft.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"];
                FoWoSoft.Platform.DBConnection conn = new FoWoSoft.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 (Exception err) { }
                        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["where"];
                    FoWoSoft.Platform.DBConnection bdbconn = new FoWoSoft.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>");
                    break;
                }
            }
            defaultValuesString = defautlSB.ToString();
        }