コード例 #1
0
        public ActionResult GetDeviceTreeForJson()
        {
            string prjGUID = this.PrjGUID;

            if (string.IsNullOrEmpty(prjGUID))
            {
                return(null);
            }
            BLL.tHostInfo             hiBLL  = new BLL.tHostInfo();
            BLL.tLightInfoes          liBLL  = new BLL.tLightInfoes();
            List <Model.tHostInfo>    hiList = hiBLL.GetModelListByPrjGUID(prjGUID);
            List <Model.tLightInfoes> liList;

            if (hiList.Count == 0)
            {
                return(null);
            }
            StringBuilder result = new StringBuilder();

            result.Append("[");
            for (int i = 0; i < hiList.Count; i++)
            {
                Model.tHostInfo hi = hiList[i];

                result.Append("{\"id\":\"" + hi.sGUID + "\",");
                result.Append("\"text\":\"" + hi.sName + "\",");
                result.Append("\"icon\":\"" + "fa fa-warning icon-state-danger" + "\",");
                result.Append("\"state\":{\"opened\": false},");
                result.Append("\"children\":[");  // 下面是子节点,注意]关闭
                liList = liBLL.GetModelListByHostGUID(hi.sGUID);
                for (int j = 0; j < liList.Count; j++)
                {
                    Model.tLightInfoes li = liList[j];

                    result.Append("{\"id\":\"" + li.sGUID + "\",");
                    result.Append("\"text\":\"" + li.sName + "\",");
                    result.Append("\"icon\":\"" + "fa fa-warning icon-state-danger" + "\"}");
                    if (j < liList.Count - 1)
                    {
                        result.Append(",");
                    }
                }
                result.Append("]}");
                if (i < hiList.Count - 1)
                {
                    result.Append(",");
                }
            }
            result.Append("]");
            return(Content(result.ToString()));
        }
コード例 #2
0
ファイル: LightInfo.cs プロジェクト: mylovsz/NPN
 public LightInfo(string roadID)
 {
     tLightInfo = new Model.tLightInfoes();
     RoadID     = roadID;
 }
コード例 #3
0
ファイル: LightInfo.cs プロジェクト: mylovsz/NPN
 public LightInfo(Model.tLightInfoes hi, string roadID)
 {
     tLightInfo = hi;
     RoadID     = roadID;
 }
コード例 #4
0
ファイル: tLightInfoes.cs プロジェクト: mylovsz/NPN
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(LumluxSSYDB.Model.tLightInfoes model)
 {
     return(dal.Update(model));
 }
コード例 #5
0
ファイル: tLightInfoes.cs プロジェクト: mylovsz/NPN
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(LumluxSSYDB.Model.tLightInfoes model)
 {
     return(dal.Add(model));
 }