Пример #1
0
        public static void LoadFromSystemDB(MieSystemDB systemDB, MieLanguageInfo langInfo)
        {
            SQLiteCommand command = systemDB.Connection.CreateCommand();

            command.CommandText = @"SELECT * FROM LanguageEntries ORDER BY FileCode;";
            using (SQLiteDataReader reader = command.ExecuteReader())
            {
                while (reader.Read() == true)
                {
                    var fileCode     = (long)reader["FileCode"];
                    var id           = (int)(long)reader["ID"];
                    var referenceID  = (long)reader["ReferenceID"];
                    var defaultText  = (string)reader["DefaultText"];
                    var femaleText   = (string)reader["FemaleText"];
                    var xProductLine = (long)reader["ProductLine"];
                    var xUpdatedAt   = (long)reader["UpdatedAt"];

                    MieProduct.NProductLine productLine = (MieProduct.NProductLine)Enum.ToObject(typeof(MieProduct.NProductLine), xProductLine);
                    DateTime updateAt = new DateTime(xUpdatedAt);

                    MieLanguageEntry langEntry = new MieLanguageEntry(id, defaultText, femaleText, productLine, referenceID, updateAt);
                    langInfo.AddFileEntry(fileCode, langEntry);
                }
            }
        }
Пример #2
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();
            }
        }
        public static void LoadFromSystemDB(MieSystemDB systemDB, MieCharacterAttributeFile charAttr)
        {
            SQLiteCommand command = systemDB.Connection.CreateCommand();

            command.CommandText = @"SELECT * FROM CharacterAttributes;";
            using (SQLiteDataReader sdr = command.ExecuteReader())
            {
                while (sdr.Read() == true)
                {
                    var byteID        = (byte[])sdr["ID"];
                    var name          = (string)sdr["Name"];
                    var intGender     = (long)sdr["Gender"];
                    var byteSpeakerID = (byte[])sdr["SpeakerID"];
                    var byteRaceID    = (byte[])sdr["RaceID"];

                    Guid id        = new Guid(byteID);
                    Guid speakerID = new Guid(byteSpeakerID);
                    Guid raceID    = new Guid(byteRaceID);

                    MieCharacterAttributeFile.NGender gender =
                        (MieCharacterAttributeFile.NGender)Enum.ToObject(typeof(MieCharacterAttributeFile.NGender), intGender);

                    MieCharacterAttributeEntry charEntry = new MieCharacterAttributeEntry(id, name, gender, speakerID, raceID);
                    charAttr.AddCharacterAttributeEntry(charEntry);
                }
            }
        }
        /// <summary>
        /// 話者情報をDBに格納する。
        /// </summary>
        /// <param name="systemDb">Connection of SystemDB</param>
        /// <param name="charFile">CharacterAttributeFile</param>
        public static void SaveToSysyemDB(MieSystemDB systemDb, MieCharacterAttributeFile charFile)
        {
            using (SQLiteTransaction trans = systemDb.Connection.BeginTransaction())
            {
                SQLiteCommand cmd = systemDb.Connection.CreateCommand();
                cmd.CommandText = "INSERT INTO CharacterAttributes VALUES(@ID,@Name,@Gender,@SpeakerID,@RaceID);";
                //// パラメータのセット
                cmd.Parameters.Add("ID", System.Data.DbType.Guid);
                cmd.Parameters.Add("Name", System.Data.DbType.String);
                cmd.Parameters.Add("Gender", System.Data.DbType.Int32);
                cmd.Parameters.Add("SpeakerID", System.Data.DbType.Guid);
                cmd.Parameters.Add("RaceID", System.Data.DbType.Guid);

                foreach (var charEntry in charFile.CharacterItems.Values)
                {
                    cmd.Parameters["ID"].Value        = charEntry.ID;
                    cmd.Parameters["Name"].Value      = charEntry.Name;
                    cmd.Parameters["Gender"].Value    = charEntry.Gender;
                    cmd.Parameters["SpeakerID"].Value = charEntry.SpeakerID;
                    cmd.Parameters["RaceID"].Value    = charEntry.RaceID;

                    try
                    {
                        cmd.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        logger.Error($"{ex.Message}\r\nCharacterAttributes: ID({charEntry.ID.ToString()}) Name({charEntry.Name}) Gender({charEntry.Gender.ToString()}) SpeakerID({charEntry.SpeakerID.ToString()}) RaceID({charEntry.RaceID.ToString()})");
                    }
                }

                trans.Commit();
            }
        }
Пример #5
0
        /// <summary>
        /// FileList
        /// </summary>
        /// <param name="systemDb">SystemDB</param>
        /// <param name="fileList">FileListオブジェクト</param>
        /// <param name="updateMode">更新モード</param>
        public static void SaveToSystemDB(MieSystemDB systemDb, MieFileList fileList, NUpdateMode updateMode)
        {
            using (SQLiteTransaction trans = systemDb.Connection.BeginTransaction())
            {
                SQLiteCommand cmd = systemDb.Connection.CreateCommand();
                switch (updateMode)
                {
                case NUpdateMode.Add:
                    cmd.CommandText = "INSERT INTO FileList VALUES(@FileCode,@FileID,@LanguageType,@UpdatedAt);";
                    ExecuteUpsertCommand(cmd, fileList);
                    break;

                case NUpdateMode.Update:
                    cmd.CommandText = "REPLACE INTO FileList VALUES(@FileCode,@FileID,@LanguageType,@UpdatedAt);";
                    ExecuteUpsertCommand(cmd, fileList);
                    break;

                case NUpdateMode.Delete:
                    cmd.CommandText = "DELETE FROM FileList WHERE FileCode = @FileCode";
                    ExecuteDeleteCommand(cmd, fileList);
                    break;

                default:
                    var msg = $"Unknown Update Mode({updateMode}).";
                    logger.Fatal(msg);
                    throw new InvalidEnumArgumentException(msg);
                }

                trans.Commit();
            }
        }
Пример #6
0
        public static void SaveToSysyemDB(MieSystemDB systemDb, MieLanguageInfo langInfo)
        {
            using (SQLiteTransaction trans = systemDb.Connection.BeginTransaction())
            {
                foreach (var langFile in langInfo.Items.Values)
                {
                    if (langFile.FileCode == 0)
                    {
                        var msg = $"Unknown FileCode({langFile.FileCode}).";
                        logger.Fatal(msg);
                        throw new Exception(msg);
                    }
                    else
                    {
                        SQLiteCommand cmd = systemDb.Connection.CreateCommand();
                        cmd.CommandText = "INSERT INTO LanguageEntries VALUES(@FileCode,@ID,@ReferenceID,@ReferenceText,@DefaultText,@FemaleText,@ProductLine,@UpdatedAt);";
                        //// パラメータのセット
                        cmd.Parameters.Add("FileCode", System.Data.DbType.Int64);
                        cmd.Parameters.Add("ID", System.Data.DbType.Int32);
                        cmd.Parameters.Add("ReferenceID", System.Data.DbType.Int64);
                        cmd.Parameters.Add("ReferenceText", System.Data.DbType.String);
                        cmd.Parameters.Add("DefaultText", System.Data.DbType.String);
                        cmd.Parameters.Add("FemaleText", System.Data.DbType.String);
                        cmd.Parameters.Add("ProductLine", System.Data.DbType.Int32);
                        cmd.Parameters.Add("UpdatedAt", System.Data.DbType.Int64);

                        foreach (var entry in langFile.Items)
                        {
                            cmd.Parameters["FileCode"].Value      = langFile.FileCode;
                            cmd.Parameters["ID"].Value            = entry.ID;
                            cmd.Parameters["ReferenceID"].Value   = entry.ReferenceID;
                            cmd.Parameters["ReferenceText"].Value = MieHashTools.ComputeHashIds(entry.ReferenceID);
                            cmd.Parameters["DefaultText"].Value   = entry.DefaultText;
                            cmd.Parameters["FemaleText"].Value    = entry.FemaleText;
                            cmd.Parameters["ProductLine"].Value   = (int)entry.ProductLine;
                            cmd.Parameters["UpdatedAt"].Value     = entry.UpdatedAt.Ticks;

                            try
                            {
                                cmd.ExecuteNonQuery();
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex, $"LanguageEntries: FileCode({langFile.FileCode}) ID({entry.ID})");
                            }
                        }
                    }
                }

                trans.Commit();
            }
        }
Пример #7
0
        public static void ClearTable(MieSystemDB systemDb)
        {
            using (SQLiteTransaction trans = systemDb.Connection.BeginTransaction())
            {
                using (SQLiteCommand cmd = systemDb.Connection.CreateCommand())
                {
                    cmd.CommandText = "DELETE FROM ChatterNodeLinks";
                    cmd.ExecuteNonQuery();
                }

                trans.Commit();
            }
        }
Пример #8
0
        public static void LoadFromSystemDB(MieSystemDB systemDB, MieChatterNodeInfo convNodeInfo)
        {
            SQLiteCommand command = systemDB.Connection.CreateCommand();

            command.CommandText = @"SELECT FileCode,FromNodeID,ToNodeID FROM ChatterNodeLinks 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);
                    MieChatterLink nodeLink = new MieChatterLink(fromNodeID, toNodeID);
                    nodeFile.AddLinkEntry(nodeLink);
                }
            }
        }
Пример #9
0
        public static void SaveToDB(MieSystemDB systemDb, MieChatterNodeInfo nodeInfo)
        {
            using (SQLiteTransaction trans = systemDb.Connection.BeginTransaction())
            {
                foreach (var nodeFile in nodeInfo.Files.Values)
                {
                    if (nodeFile.FileCode == 0)
                    {
                        var msg = $"Unknown FileCode({nodeFile.FileCode}). Skipping File...";
                        logger.Warn(msg);
                    }
                    else
                    {
                        SaveToTable(systemDb.Connection, nodeFile, nodeFile.FileCode);
                    }
                }

                trans.Commit();
            }
        }
        public static void LoadFromSystemDB(MieSystemDB systemDB, MieCharacterAttributeFile raceAttr)
        {
            SQLiteCommand command = systemDB.Connection.CreateCommand();

            command.CommandText = @"SELECT * FROM RaceAttributes";
            using (SQLiteDataReader sdr = command.ExecuteReader())
            {
                while (sdr.Read() == true)
                {
                    var byteRaceID = (byte[])sdr["RaceID"];
                    var name       = (string)sdr["Name"];

                    Guid raceID = new Guid(byteRaceID);

                    MieRaceAttributeEntry raceEntry = new MieRaceAttributeEntry(raceID, name);

                    raceAttr.AddRaceEntry(raceEntry);
                }
            }
        }
        public static void SaveToSysyemDB(MieSystemDB systemDb, MieCharacterAttributeFile raceAttrBefore)
        {
            using (SQLiteTransaction trans = systemDb.Connection.BeginTransaction())
            {
                SQLiteCommand cmd = systemDb.Connection.CreateCommand();
                cmd.CommandText = "INSERT INTO RaceAttributes VALUES(@RaceID,@Name)";
                //// パラメータのセット
                cmd.Parameters.Add("RaceID", System.Data.DbType.Guid);
                cmd.Parameters.Add("Name", System.Data.DbType.String);

                foreach (var raceEntry in raceAttrBefore.RaceItems.Values)
                {
                    cmd.Parameters["RaceID"].Value = raceEntry.RaceID;
                    cmd.Parameters["Name"].Value   = raceEntry.Name;

                    cmd.ExecuteNonQuery();
                }

                trans.Commit();
            }
        }
Пример #12
0
        public void LoadFromDB(MieSystemDB systemDb)
        {
            //// キャラクター情報の作成。
            {
                this.CharacterAttributeFile = new MieCharacterAttributeFile();
                MieTableCharacterAttributesDao.LoadFromSystemDB(systemDb, this.CharacterAttributeFile);
                MieTableSpeakerAttributesDao.LoadFromSystemDB(systemDb, this.CharacterAttributeFile);
                MieTableRaceAttributesDao.LoadFromSystemDB(systemDb, this.CharacterAttributeFile);
            }

            //// 言語情報を作成。
            {
                this.LanguageInfo = new MieLanguageInfo();
                MieTableLanguageDao.LoadFromSystemDB(systemDb, this.LanguageInfo);
                this.FileList = MieTableFileListDao.LoadFromSystemDB(systemDb);
            }

            //// 会話ノード情報を作成。
            {
                this.ConversationInfo = new MieConversationNodeInfo();
                MieTableConversationNodeLinksDao.LoadFromSystemDB(systemDb, this.ConversationInfo);
                MieTableConversationEntriesDao.LoadFromSystemDB(systemDb, this.ConversationInfo);
            }

            //// クエストノード情報を作成。
            {
                this.QuestsInfo = new MieQuestsNodeInfo();
                MieTableQuestsNodeLinksDao.LoadFromSystemDB(systemDb, this.QuestsInfo);
                MieTableQuestsEntriesDao.LoadFromSystemDB(systemDb, this.QuestsInfo);
            }

            //// チャッターノード情報を作成。
            {
                this.ChatterInfo = new MieChatterNodeInfo();
                MieTableChatterNodeLinksDao.LoadFromSystemDB(systemDb, this.ChatterInfo);
                MieTableChatterEntriesDao.LoadFromSystemDB(systemDb, this.ChatterInfo);
            }
        }
Пример #13
0
        public static MieFileList LoadFromSystemDB(MieSystemDB systemDB)
        {
            MieFileList fileList = new MieFileList();

            SQLiteCommand command = systemDB.Connection.CreateCommand();

            command.CommandText = @"SELECT * FROM FileList;";
            using (SQLiteDataReader sdr = command.ExecuteReader())
            {
                while (sdr.Read() == true)
                {
                    var fileCode      = (long)sdr["FileCode"];
                    var fileID        = (string)sdr["FileID"];
                    var xLanguageType = (int)(long)sdr["LanguageType"];
                    var updatedAt     = (long)sdr["UpdatedAt"];

                    MieProduct.NLanguageType languageType = (MieProduct.NLanguageType)Enum.ToObject(typeof(MieProduct.NLanguageType), xLanguageType);
                    MieFileEntry             fileEntry    = new MieFileEntry(fileCode, fileID, languageType, updatedAt);
                    fileList.AddEntry(fileEntry);
                }
            }

            return(fileList);
        }