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

            command.CommandText = @"SELECT FileCode,FromNodeID,ToNodeID FROM ConversationNodeLinks ORDER BY FileCode;";
            using (SQLiteDataReader reader = command.ExecuteReader())
            {
                while (reader.Read() == true)
                {
                    var fileCode   = (long)reader["FileCode"];
                    var fromNodeID = (int)(long)reader["FromNodeID"];
                    var toNodeID   = (int)(long)reader["ToNodeID"];

                    var nodeFile = convNodeInfo.GetNodeFile(fileCode);
                    MieConversationLink nodeLink = new MieConversationLink(fromNodeID, toNodeID);
                    nodeFile.AddLinkEntry(nodeLink);
                }
            }
        }
        /// <summary>
        /// JSON形式の会話ファイルを読み込み、会話ファイルを返す。
        /// [非OE DLL]
        /// </summary>
        /// <param name="path">会話ファイルのパス</param>
        /// <param name="fileList">FileLIst</param>
        /// <returns>会話ファイル</returns>
        private static MieConversationNodeFile LoadFromJson(string path, MieFileList fileList)
        {
            MieConversationNodeFile mieConversationsFile = null;

            var ctext = LoadJson(path);

            ctext = ctext.Replace("$type", "MieFlowChartsDataTypeTag");
            var oeConversations = JsonConvert.DeserializeObject <MieOEConversations>(ctext);

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

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

                //// ノード情報作成
                foreach (var node in conv.Nodes)
                {
                    var nodeType = GetFlowChartsDataTypeTag(node.MieFlowChartsDataTypeTag);

                    MieConversationNodeEntry conversationNode = null;

                    Guid speakerGuid;
                    if (node.SpeakerGuid == null)
                    {
                        speakerGuid = default(Guid);
                    }
                    else
                    {
                        speakerGuid = new Guid(node.SpeakerGuid);
                    }

                    Guid listenerGuid;
                    if (node.ListenerGuid == null)
                    {
                        listenerGuid = default(Guid);
                    }
                    else
                    {
                        listenerGuid = new Guid(node.ListenerGuid);
                    }

                    //// Root node は NodeIDで判断する。
                    conversationNode = new MieConversationNodeEntry(
                        nodeType,
                        node.NodeID,
                        speakerGuid,
                        listenerGuid,
                        node.NodeID == 0 ? true : false,
                        node.IsQuestionNode);

                    //// リンク情報作成
                    foreach (var link in node.Links)
                    {
                        MieConversationLink mieConversationLinks = new MieConversationLink(link.FromNodeID, link.ToNodeID);
                        mieConversationsFile.AddLinkEntry(mieConversationLinks);
                    }

                    mieConversationsFile.AddFlatNodeEntry(conversationNode);
                }

                //// キャラクターマップ情報作成
                foreach (var map in conv.CharacterMappings)
                {
                    MieCharacterMapEntry mapEntry = new MieCharacterMapEntry(new Guid(map.Guid));
                    mieConversationsFile.AddCharacterMapEntry(mapEntry);
                }
            }

            if (mieConversationsFile != null)
            {
                mieConversationsFile.BuildLink();
                mieConversationsFile.UpdateDepth();
            }

            return(mieConversationsFile);
        }