Exemplo n.º 1
0
        public static void LoadFromSystemDB(MieSystemDB systemDB, MieChatterNodeInfo chatterNodeInfo)
        {
            SQLiteCommand command = systemDB.Connection.CreateCommand();

            command.CommandText = @"SELECT * FROM ChatterNodeEntries ORDER BY FileCode;";
            using (SQLiteDataReader reader = command.ExecuteReader())
            {
                while (reader.Read() == true)
                {
                    var fileCode    = (long)reader["FileCode"];
                    var nodeID      = (int)(long)reader["NodeID"];
                    var xNodeType   = (long)reader["NodeType"];
                    var xIsRootNode = (long)reader["IsRootNode"];

                    MieChatterNodeEntry.NNodeType nodeType =
                        (MieChatterNodeEntry.NNodeType)Enum.ToObject(typeof(MieChatterNodeEntry.NNodeType), xNodeType);
                    bool isRootNode = xIsRootNode == 0 ? false : true;

                    MieChatterNodeEntry nodeEntry = new MieChatterNodeEntry(
                        nodeType,
                        nodeID,
                        isRootNode);

                    var nodeFile = chatterNodeInfo.GetNodeFile(fileCode);
                    var rc       = nodeFile.AddFlatNodeEntry(nodeEntry);
                }
            }

            foreach (var nodeFile in chatterNodeInfo.Files.Values)
            {
                nodeFile.BuildLink();
                nodeFile.UpdateDepth();
            }
        }
Exemplo n.º 2
0
        private static void CreateChatterInfo(string ctext, MieChatterNodeInfo mieChatterInfo, MieFileList fileList)
        {
            //// デシリアライズ
            var oeChatter = JsonConvert.DeserializeObject <MieOEChatter>(ctext);

            foreach (var chatterFile in oeChatter.ChatterFiles)
            {
                var fileID = chatterFile.Filename.Replace(".chatter", string.Empty);
                //// FileIDを統一形式に変換する。
                fileID = MieFileUtils.ConvertFileIDToCommon(fileID);
                fileID = MieStringUtils.NormalizedFileID(fileID);

                MieChatterNodeFile chatterNodeFile = null;

                var fileCode = fileList.GetHashByFileID(fileID);
                if (fileCode == 0)
                {
                    //// 言語情報から生成されたFileListに含まれないものは無視する。
                    continue;
                }
                else
                {
                    chatterNodeFile = new MieChatterNodeFile(fileCode);
                    mieChatterInfo.AddFile(chatterNodeFile);
                }

                foreach (var node in chatterFile.Nodes)
                {
                    var dataType = node.MieChatterNodeDataTypeTag;

                    var  nodeID         = node.NodeID;
                    var  isQuestionNode = node.IsQuestionNode;
                    bool isRootNode     = node.NodeID == 0 ? true : false;

                    //// チャッターエントリー
                    MieChatterNodeEntry.NNodeType nodeType  = MieChatterNodeEntry.NNodeType.Unknown;
                    MieChatterNodeEntry           nodeEntry = new MieChatterNodeEntry(nodeType, nodeID, isRootNode);
                    chatterNodeFile.AddFlatNodeEntry(nodeEntry);

                    //// Link情報の登録
                    foreach (var link in node.Links)
                    {
                        MieChatterLink mieChatterLink = new MieChatterLink(link.FromNodeID, link.ToNodeID);
                        chatterNodeFile.AddLinkEntry(mieChatterLink);
                    }
                }
            }
        }