using LeaRun.Application.Entity.DMAManage;
using LeaRun.Data;
using LeaRun.Util;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LeaRun.Application.Service.DMAManage
{
///
/// 分区绘制
///
public class PartitionDrawService
{
SqlHelper sqlHelper = new SqlHelper("DMADb");
#region 获取所有分区的数据
///
/// 获取所有分区的数据
///
///
public List GetAllPartitions()
{
string sql = "select * from DMA where DeleteMark = 0 and EnabledMark = 1";
try
{
DataTable dt = sqlHelper.ExecuteDataTable(sql, CommandType.Text, null);
return dt.Rows.Count > 0 ? DataHelper.DataTableToT(dt) : new List();
}
catch (Exception)
{
throw;
}
}
#endregion
#region 保存坐标数据
///
/// 保存坐标数据
///
///
public int SavePoints(string datas)
{
try
{
List values = Json.ToList(datas);
foreach (PointsEntity item in values)
{
StringBuilder sb = new StringBuilder("update DMA set");
sb.Append(" DMACoordinate = '" + item.points + "',");
sb.Append(" FillColor = '" + item.color + "' where DMACode = '");
sb.Append(item.DMACode + "'");
sqlHelper.ExecuteNonQuery(sb.ToString(), CommandType.Text, null);
}
return 0;
}
catch (Exception)
{
return 1;
}
}
#endregion
}
}