Beispiel #1
0
        /// <summary>
        /// 把数据库内容,写到文件中,便于查看
        /// </summary>
        void TestWriteListDbFile()
        {
            ReadIniFile iniFile      = new ReadIniFile();
            string      jsonfilepath = iniFile.IniReadValue(iniFile.getIniFilePath("JsonDataMgr.ini"), "JsonFileInfo", "jsonfilepath");

            JsonFile json = new JsonFile();

            json.WriteFile(jsonfilepath + "oid_info_db.json", JsonConvert.SerializeObject(oid_info_db));
            json.WriteFile(jsonfilepath + "nameEn_info_db.json", JsonConvert.SerializeObject(nameEn_info_db));
            json.WriteFile(jsonfilepath + "table_info_db.json", JsonConvert.SerializeObject(table_info_db));
        }
Beispiel #2
0
        /// <summary>
        /// 解析lm.dtz 写 cmd.json
        /// </summary>
        public void ConvertAccessDbToJsonCmdTree()
        {
            //Console.WriteLine("DbToJsonCmdTree start " + DateTime.Now.ToString("yyyy年MM月dd日HH时mm分ss秒fff毫秒"));
            //生产 cmdTree 命令树文件
            string          sqlContent   = "select * from CmdTree order by CmdID";
            DataSet         dataSet      = GetRecordByAccessDb(mdbFile, sqlContent);
            CmdTreeJsonData cmdJsonDatat = new CmdTreeJsonData();

            cmdJsonDatat.CmdParseDataSet(dataSet);

            JsonFile jsonObjFile = new JsonFile();

            //jsonObjFile.WriteFile("D:\\C#\\SCMT\\obj.json", objTreeJson.GetStringObjTreeJson());
            jsonObjFile.WriteFile(jsonfilepath + "cmd.json", cmdJsonDatat.GetStringObjTreeJson());
            this.cmdTreeInfo = cmdJsonDatat.GetStringObjTreeJson();

            isCmdJsonOK = true;
            //Console.WriteLine("DbToJsonCmdTree end " + DateTime.Now.ToString("yyyy年MM月dd日HH时mm分ss秒fff毫秒"));
            return;
        }
Beispiel #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);
        }
Beispiel #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;
        }
Beispiel #5
0
        void JsonFileWrite(string fileName, string content)
        {
            JsonFile jsonMibFile = new JsonFile();

            jsonMibFile.WriteFile(fileName, content);
        }