Example #1
0
        /// <summary>
        /// json 文件生产 3种数据库
        /// </summary>
        public bool GeneratedMibInfoList(string ConnectIp)
        {
            initDbMemory();
            ///
            ReadIniFile iniFile      = new ReadIniFile();
            string      jsonfilepath = iniFile.IniReadValue(
                iniFile.getIniFilePath("JsonDataMgr.ini"), "JsonFileInfo", "jsonfilepath");

            JsonFile json = new JsonFile();
            JObject  JObj = json.ReadJsonFileForJObject(jsonfilepath + "mib.json");

            foreach (var table in JObj["tableList"])
            {
                CreateNameEnByTableInfo(table);
                CreateOidByTableInfo(table);
                CreateTableByTableInfo(table);
                foreach (var child in table["childList"])
                {
                    CreateNameEnByChildInfo(child, table);

                    CreateOidByChildInfo(child, table);
                }
            }
            //TestWriteListDbFile2();
            if (!AddDBList(ConnectIp))
            {
                Console.WriteLine("add Db list err.");
                return(false);
            }
            TestWriteListDbFile2();
            DelDbMemory();
            return(true);
        }
Example #2
0
        /********************************    私有,原来的代码     ********************************/
        /// <summary>
        /// json 文件生产 3种数据库
        /// </summary>
        private void GeneratedMibInfoList()
        {
            initDbMemory();
            ///
            ReadIniFile iniFile      = new ReadIniFile();
            string      jsonfilepath = iniFile.IniReadValue(iniFile.getIniFilePath(
                                                                "JsonDataMgr.ini"), "JsonFileInfo", "jsonfilepath");

            JsonFile json = new JsonFile();
            JObject  JObj = json.ReadJsonFileForJObject(jsonfilepath + "mib.json");

            foreach (var table in JObj["tableList"])
            {
                CreateNameEnByTableInfo(table);
                CreateOidByTableInfo(table);
                CreateTableByTableInfo(table);

                foreach (var child in table["childList"])
                {
                    CreateNameEnByChildInfo(child, table);
                    CreateOidByChildInfo(child, table);
                }
            }
            //TestWriteListDbFile2();
            return;
        }
Example #3
0
        /**********   私有函数   **********/


        //////////

        public bool testGetDataByTableEnglishName()
        {
            ReadIniFile iniFile      = new ReadIniFile();
            string      jsonfilepath = iniFile.IniReadValue(iniFile.getIniFilePath("JsonDataMgr.ini"), "JsonFileInfo", "jsonfilepath");

            JsonFile json = new JsonFile();
            JObject  JObj = json.ReadJsonFileForJObject(jsonfilepath + "Tree_Reference.json");

            foreach (var table in JObj["NodeList"])
            {
                IReDataByTableEnglishName reData;
                string MibTableName = table["MibTableName"].ToString();
                if (String.Equals("/", MibTableName))
                {
                    continue;
                }
                if (false == getDataByTableEnglishName(MibTableName, out reData))
                {
                    Console.WriteLine("===={0} not exist.", MibTableName);
                }
            }
            return(true);
        }
Example #4
0
        /// <summary>
        /// json 文件生产 3种数据库
        /// </summary>
        private void GeneratedMibInfoList(bool useOld)
        {
            initDbMemory();
            ///
            ReadIniFile iniFile      = new ReadIniFile();
            string      jsonfilepath = iniFile.IniReadValue(
                iniFile.getIniFilePath("JsonDataMgr.ini"),
                "JsonFileInfo", "jsonfilepath");

            JsonFile json = new JsonFile();
            JObject  JObj = json.ReadJsonFileForJObject(jsonfilepath + "mib.json");

            foreach (var table in JObj["tableList"])
            {
                Dictionary <string, string> nameEnTableInfo = new Dictionary <string, string>();
                Dictionary <string, string> oidTableInfo    = new Dictionary <string, string>();
                string  tableName     = table["nameMib"].ToString();
                string  tableOid      = table["oid"].ToString();
                string  tableIndexNum = table["indexNum"].ToString();
                string  nameCh        = table["nameCh"].ToString();
                dynamic childList     = table["childList"];

                nameEnTableInfo.Add("isLeaf", "0");
                nameEnTableInfo.Add("oid", tableOid);
                nameEnTableInfo.Add("indexNum", tableIndexNum);
                nameEnTableInfo.Add("nameCh", nameCh);
                this.nameEn_info_db.Add(tableName, nameEnTableInfo);

                oidTableInfo.Add("isLeaf", "0");
                oidTableInfo.Add("nameMib", tableName);
                oidTableInfo.Add("indexNum", tableIndexNum);
                oidTableInfo.Add("nameCh", nameCh);
                this.oid_info_db.Add(tableOid, oidTableInfo);

                this.table_info_db.Add(tableName, table);
                foreach (var child in childList)
                {
                    Dictionary <string, string> nameEnChildInfo = new Dictionary <string, string>();
                    Dictionary <string, string> oidChildInfo    = new Dictionary <string, string>();
                    string childName   = child["childNameMib"];
                    string childOid    = child["childOid"];
                    string childNameCh = child["childNameCh"];

                    nameEnChildInfo.Add("tableNameEn", tableName);
                    nameEnChildInfo.Add("isLeaf", "1");
                    nameEnChildInfo.Add("oid", childOid);
                    nameEnChildInfo.Add("indexNum", tableIndexNum);
                    nameEnChildInfo.Add("nameCh", childNameCh);

                    try
                    {
                        this.nameEn_info_db.Add(childName, nameEnChildInfo);
                    }
                    catch (Exception ex)
                    {
                        this.nameEn_info_db[childName]["oid"] = this.nameEn_info_db[childName]["oid"] + "|" + childOid;
                        Console.WriteLine("生成json_db时{0},{1}", childName, ex.Message);
                    }

                    oidChildInfo.Add("isLeaf", "1");
                    oidChildInfo.Add("nameMib", childName);
                    oidChildInfo.Add("indexNum", tableIndexNum);
                    this.oid_info_db.Add(childOid, oidChildInfo);
                }
            }
            TestWriteListDbFile();
            return;
        }