DataBaseHelper.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using RDIFramework.Utilities;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. namespace TimedUpload.utils
  8. {
  9. public class DataBaseHelper
  10. {
  11. static IDbProvider dbHelper
  12. {
  13. get
  14. {
  15. var DbDefine = DbFactoryProvider.GetProvider(CurrentDbType.SqlServer, SystemConfig.pipeLineDbConn);
  16. return DbDefine;
  17. }
  18. }
  19. public static bool CheckTableExiste(string strTableName)
  20. {
  21. string strSql = "select * from sysobjects where name='" + strTableName + "'";
  22. if (CreateDataSet(strSql).Tables[0].Rows.Count == 0)
  23. {
  24. return false;
  25. }
  26. return true;
  27. }
  28. public static DataSet CreateDataSet(string strSql)
  29. {
  30. DataSet dataSet = new DataSet();
  31. try
  32. {
  33. dataSet = new DataSet();
  34. dbHelper.Fill(dataSet, strSql, "checkTable");
  35. }
  36. catch (Exception exception)
  37. {
  38. //log.Error("checkTable:" + exception.Message);
  39. }
  40. return dataSet;
  41. }
  42. public static string DataFormat(object value)
  43. {
  44. if (value == null)
  45. {
  46. return "NULL";
  47. }
  48. if (string.IsNullOrEmpty(value.ToString()))
  49. {
  50. return "NULL";
  51. }
  52. if (value.ToString() == "正常")
  53. {
  54. return "0";
  55. }
  56. if (value.ToString() == "停止")
  57. {
  58. return "1";
  59. }
  60. if (value.ToString() == "运行")
  61. {
  62. return "0";
  63. }
  64. if (value.ToString() == "故障")
  65. {
  66. return "1";
  67. }
  68. if (value.ToString() == "报警")
  69. {
  70. return "1";
  71. }
  72. return value.ToString();
  73. }
  74. }
  75. }