RoadFlow2.1 临时演示

GetNames_SQL.ashx.cs 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Data;
  6. using System.Text;
  7. namespace WebForm.Controls.SelectDictionary
  8. {
  9. /// <summary>
  10. /// GetNames_SQL 的摘要说明
  11. /// </summary>
  12. public class GetNames_SQL : IHttpHandler
  13. {
  14. public void ProcessRequest(HttpContext context)
  15. {
  16. context.Response.ContentType = "text/plain";
  17. string dbconn = context.Request.QueryString["dbconn"];
  18. string sql = context.Request.QueryString["sql"];
  19. RoadFlow.Platform.DBConnection conn = new RoadFlow.Platform.DBConnection();
  20. var conn1 = conn.Get(dbconn.ToGuid());
  21. DataTable dt = conn.GetDataTable(conn1, sql.UrlDecode().ReplaceSelectSql());
  22. string values = context.Request.QueryString["values"] ?? "";
  23. System.Text.StringBuilder sb = new System.Text.StringBuilder();
  24. foreach (string value in values.Split(','))
  25. {
  26. string value1 = string.Empty;
  27. string title1 = string.Empty;
  28. foreach (DataRow dr in dt.Rows)
  29. {
  30. value1 = dr[0].ToString();
  31. if (value == value1)
  32. {
  33. title1 = dt.Columns.Count > 1 ? dr[1].ToString() : value1;
  34. break;
  35. }
  36. }
  37. sb.Append(title1);
  38. sb.Append(',');
  39. }
  40. context.Response.Write(sb.ToString().TrimEnd(','));
  41. }
  42. public bool IsReusable
  43. {
  44. get
  45. {
  46. return false;
  47. }
  48. }
  49. }
  50. }