PartitionDrawService.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using LeaRun.Application.Entity.DMAManage;
  2. using LeaRun.Data;
  3. using LeaRun.Util;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace LeaRun.Application.Service.DMAManage
  11. {
  12. /// <summary>
  13. /// 分区绘制
  14. /// </summary>
  15. public class PartitionDrawService
  16. {
  17. SqlHelper sqlHelper = new SqlHelper("DMADb");
  18. #region 获取所有分区的数据
  19. /// <summary>
  20. /// 获取所有分区的数据
  21. /// </summary>
  22. /// <returns></returns>
  23. public List<DMAEntity> GetAllPartitions()
  24. {
  25. string sql = "select * from DMA where DeleteMark = 0 and EnabledMark = 1";
  26. try
  27. {
  28. DataTable dt = sqlHelper.ExecuteDataTable(sql, CommandType.Text, null);
  29. return dt.Rows.Count > 0 ? DataHelper.DataTableToT<DMAEntity>(dt) : new List<DMAEntity>();
  30. }
  31. catch (Exception)
  32. {
  33. throw;
  34. }
  35. }
  36. #endregion
  37. #region 保存坐标数据
  38. /// <summary>
  39. /// 保存坐标数据
  40. /// </summary>
  41. /// <returns></returns>
  42. public int SavePoints(string datas)
  43. {
  44. try
  45. {
  46. List<PointsEntity> values = Json.ToList<PointsEntity>(datas);
  47. foreach (PointsEntity item in values)
  48. {
  49. StringBuilder sb = new StringBuilder("update DMA set");
  50. sb.Append(" DMACoordinate = '" + item.points + "',");
  51. sb.Append(" FillColor = '" + item.color + "' where DMACode = '");
  52. sb.Append(item.DMACode + "'");
  53. sqlHelper.ExecuteNonQuery(sb.ToString(), CommandType.Text, null);
  54. }
  55. return 0;
  56. }
  57. catch (Exception)
  58. {
  59. return 1;
  60. }
  61. }
  62. #endregion
  63. }
  64. }