Ejemplo n.º 1
0
        public string DeviceTree()
        {
            var inputValue = _ntsPage.Request.Form["Inputs"];
            if (string.IsNullOrEmpty(inputValue))
            {
                var cacheTree = NTS.WEB.Common.CacheHelper.GetCache("device-tree");
                if (cacheTree != null)
                {
                    //var treeObject = cacheTree.ToString();
                    return cacheTree.ToString();
                }
                var res = new BaseTree().GetDeviceTree();
                NTS.WEB.Common.CacheHelper.SetCache("device-tree", res.TreeJson);
                // Framework.Common.BaseWcf.CreateChannel<ServiceInterface.IObjectTree>("ObjectTree").GetDeviceTree();
                return res.TreeJson;
            }
            else
            {

                var query = Newtonsoft.Json.JsonConvert.DeserializeObject<QueryDevice>(inputValue);
                var res = new BaseTree().GetDeviceListByArea(query);
                //Framework.Common.BaseWcf.CreateChannel<ServiceInterface.IObjectTree>("ObjectTree").GetDeviceListByArea(query);
                return res;
                // return Newtonsoft.Json.JsonConvert.SerializeObject(res);
            }
            //return Newtonsoft.Json.JsonConvert.SerializeObject(res);
        }
Ejemplo n.º 2
0
        public string objectItemTree_OLD()
        {
            try
            {
                string username    = Utils.GetCookie("userid");
                var    loginResult =
                    Framework.Common.BaseWcf.CreateChannel <NTS.WEB.ServiceInterface.IUser>("UserLogin").GetUserGroupID(
                        username);

                string itemcode     = _ntsPage.Request["ItemCode"].ToString();
                int    classid      = int.Parse(_ntsPage.Request["ClassId"].ToString());
                string strCacheName = "object-tree" + itemcode + classid + loginResult;

                var cacheTree = NTS.WEB.Common.CacheHelper.GetCache(strCacheName);

                if ((cacheTree != null) && (cacheTree.ToString() != "") && (cacheTree.ToString().Length > 6))
                {
                    return(cacheTree.ToString());
                }
                //  var res = Framework.Common.BaseWcf.CreateChannel<ServiceInterface.IObjectTree>("ObjectTree").GetObjectTree();
                var res = new BaseTree(itemcode, classid, "").GetObjectTree();
                NTS.WEB.Common.CacheHelper.SetCache(strCacheName, res.TreeJson, 10000);
                if ((res.TreeJson != "") && (res.TreeJson.ToString().Length > 8))
                {
                    return(res.TreeJson);
                }
                else
                {
                    return("[]");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            //string itemcode = "01A00";
            //int classid = 1;
        }
Ejemplo n.º 3
0
        public string ObjectTree()
        {
            var cacheTree = NTS.WEB.Common.CacheHelper.GetCache("object-tree");
            if (cacheTree != null)
            {

                return cacheTree.ToString();
            }
            //  var res = Framework.Common.BaseWcf.CreateChannel<ServiceInterface.IObjectTree>("ObjectTree").GetObjectTree();
            var res = new BaseTree().GetObjectTree();
            NTS.WEB.Common.CacheHelper.SetCache("object-tree", res.TreeJson);
            return res.TreeJson;
        }
Ejemplo n.º 4
0
        public string objectItemTree_OLD()
        {
            try
            {
                string username = Utils.GetCookie("userid");
                var loginResult =
                    Framework.Common.BaseWcf.CreateChannel<NTS.WEB.ServiceInterface.IUser>("UserLogin").GetUserGroupID(
                        username);

                string itemcode = _ntsPage.Request["ItemCode"].ToString();
                int classid = int.Parse(_ntsPage.Request["ClassId"].ToString());
                string strCacheName = "object-tree" + itemcode + classid + loginResult;

                var cacheTree = NTS.WEB.Common.CacheHelper.GetCache(strCacheName);

                if ((cacheTree != null) && (cacheTree.ToString() != "") && (cacheTree.ToString().Length > 6))
                {
                    return cacheTree.ToString();
                }
                //  var res = Framework.Common.BaseWcf.CreateChannel<ServiceInterface.IObjectTree>("ObjectTree").GetObjectTree();
                var res = new BaseTree(itemcode, classid, "").GetObjectTree();
                NTS.WEB.Common.CacheHelper.SetCache(strCacheName, res.TreeJson, 10000);
                if ((res.TreeJson != "") && (res.TreeJson.ToString().Length > 8))
                {
                    return res.TreeJson;
                }
                else
                {
                    return "[]";
                }

            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            //string itemcode = "01A00";
            //int classid = 1;
        }