Пример #1
0
        /// <summary>
        /// Builds the json from object.
        /// </summary>
        /// <param name="treeNode">The tree node.</param>
        /// <returns></returns>
        private JSONValue BuildJsonFromObject(TreeNode treeNode)
        {
            JSONObjectCollection result = new JSONObjectCollection();

            foreach (TreeNode child in treeNode.Nodes)
            {
                Node node = (Node)child.Tag;
                result.Add(new JSONStringValue(node.Name), BuildJson(child));
            }

            return result;
        }
Пример #2
0
        public bool reflashDictCache()
        {
            bool isSuccess = false;

            JSONObjectCollection jsonGraph = new JSONObjectCollection();

            JSONObjectCollection jarr = new JSONObjectCollection();

            ICriteria icr = CreateCriteria<DictTypeModel>();
            IList<DictTypeModel> dictTypes=icr.List<DictTypeModel>();
            icr=CreateCriteria<DictModel>();
            IList<DictModel> dicts=icr.List<DictModel>();
            foreach (DictTypeModel dictType in dictTypes) {
                IList<DictModel> tempDicts=new List<DictModel>();
                foreach (DictModel dict in dicts) {
                    if (dict.type != dictType.id) { continue; }
                    tempDicts.Add(dict);
                }
                jsonGraph.Add(new JSONStringValue(dictType.id),DatagridObject.ToDatagridObject<DictModel>(tempDicts).toJSONObjectCollection());
            }

            StringBuilder sbr = new StringBuilder("");
            sbr
            .Append("Class.forName(\"Toyz4js.cache\"); \n\n")
            .Append("Toyz4js[\"cache\"][\"DictModel\"]=").Append(jsonGraph.ToString()).Append(";  \n\n \n\n")
            .Append("Toyz4js[\"cache\"][\"DictTypeModel\"]=").Append(DatagridObject.ToDatagridObject<DictTypeModel>(dictTypes).toJSONObjectCollection()).Append(";  \n\n \n\n")
            ;
            try
            {
                FileUtil.WriteFile(this.pathDictCache, sbr.ToString());
            }
            catch(Exception ex) {
                isSuccess = false;
            }
            return isSuccess;
        }