1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Configuration;
- using System.Threading.Tasks;
- using System.Data;
- using LeaRun.Application.Entity.WaterWellManage;
- using LeaRun.Util;
- using LeaRun.Data;
- namespace LeaRun.Application.Service.WaterWellManage
- {
- public class DeviceService
- {
- SqlHelper sqlHelper = new SqlHelper("BaseDb");
- /// <summary>
- /// 获取根节点
- /// </summary>
- /// <param name="parentId"></param>
- /// <returns></returns>
- public IEnumerable<DeviceEntity> GetList(string parentId)
- {
- try
- {
- var strSql = "SELECT * FROM Base_Organize WHERE ParentId='" + parentId + "'";
- DataTable dtResult = sqlHelper.ExecuteDataTable(strSql, CommandType.Text, null);
- var modelList = new List<DeviceEntity>();
- for (int rowIndex = 0; rowIndex < dtResult.Rows.Count; rowIndex++)
- {
- DeviceEntity model = new DeviceEntity();
- model.OrganizeId = dtResult.Rows[rowIndex]["OrganizeId"].ToString();
- model.ShortName = dtResult.Rows[rowIndex]["ShortName"].ToString();
- model.ParentId = dtResult.Rows[rowIndex]["ParentId"].ToString();
- model.EnCode = dtResult.Rows[rowIndex]["EnCode"].ToString();
- modelList.Add(model);
- }
- return modelList;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 获取根节点
- /// </summary>
- /// <returns></returns>
- public string GetAllList()
- {
- try
- {
- var strSql = "SELECT * FROM Base_Organize";
- DataTable dtResult = sqlHelper.ExecuteDataTable(strSql, CommandType.Text, null);
- var modelList = new List<DeviceEntity>();
- for (int rowIndex = 0; rowIndex < dtResult.Rows.Count; rowIndex++)
- {
- DeviceEntity model = new DeviceEntity();
- model.OrganizeId = dtResult.Rows[rowIndex]["OrganizeId"].ToString();
- model.ShortName = dtResult.Rows[rowIndex]["ShortName"].ToString();
- model.ParentId = dtResult.Rows[rowIndex]["ParentId"].ToString();
- model.EnCode = dtResult.Rows[rowIndex]["EnCode"].ToString();
- modelList.Add(model);
- }
- return Json.ToJson(modelList);
- }
- catch (Exception e)
- {
- throw e;
- }
- }
- }
- }
|