/// <summary> /// Добавление детальной информацией RSS /// </summary> /// <param name="item"></param> public void AddDetailRSSItems(ModelTableDetailRSS item) { RealmDB.Write(() => { RealmDB.Add(item); }); }
/// <summary> /// Метод обновление RSS /// </summary> private void UpdateRSS() { var list = AllListDetailRSSTable(SourceModel); if (!SourceModel.URLRSS.Equals(NewURLRSS)) { // Если список подробного RSS не пуст то удаляем if (list.Count != 0) { foreach (var item in list) { DeleteDetailRSSItems(item); } } } using (var db = RealmDB.BeginWrite()) { SourceModel.Title = NewTitleRSS; SourceModel.URLRSS = NewURLRSS; db.Commit(); } OnPropertyChanged(""); }
/// <summary> /// Удаление детальной информацией RSS /// </summary> /// <param name="item"></param> public void DeleteRSSItems(ModelTableRSS item) { using (var db = RealmDB.BeginWrite()) { RealmDB.Remove(item); db.Commit(); } }
private int AddFightsToDatabase(string _fightCollectionFile) { try { List <string> sessionDebugData = new List <string>(); int totalFightCount = 0; string filenameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(_fightCollectionFile); string fightCollectionDatName = "DataFiles\\" + DateTime.UtcNow.ToString("yyyy_MM") + "\\" + filenameWithoutExtension + ".dat"; fightCollectionDatName = VF.Utility.ConvertToUniqueFilename(fightCollectionDatName); List <DamageDataSession> dataSessions = new List <DamageDataSession>(); dataSessions = DamageDataParser.ParseFile(_fightCollectionFile, ref sessionDebugData); Console.Write("Generating Fights..."); var fights = FightDataCollection.GenerateFights(dataSessions);//, BossInformation.BossFights); Console.WriteLine("DONE"); if (fights.Fights.Count >= 1) { Logger.ConsoleWriteLine(_fightCollectionFile + " contained " + fights.Fights.Count + " fights", ConsoleColor.Yellow); List <RaidCollection_Raid> raidsModified = new List <RaidCollection_Raid>(); List <RaidCollection_Dungeon> dungeonsModified = new List <RaidCollection_Dungeon>(); m_RaidCollection.AddFightCollection(fights, fightCollectionDatName, raidsModified, dungeonsModified); //TESTING if (raidsModified.Count > 0 || dungeonsModified.Count > 0) { Logger.ConsoleWriteLine("--------------------", ConsoleColor.White); foreach (var raid in raidsModified) { var bossFights = raid.GetBossFights(fights, null); Logger.ConsoleWriteLine("Raid: " + raid.RaidInstance + "(" + raid.RaidID + ") by " + raid.RaidOwnerName, ConsoleColor.White); foreach (var bossFight in bossFights) { ++totalFightCount; bossFight.GetFightDetails(); //Trigger FightDetail request, so we get error here instead of later on the website. //Logger.ConsoleWriteLine("Fight: " + bossFight.GetBossName() + " added to RaidCollection", ConsoleColor.Green); } if (raid.RaidOwnerName.ToLower() == "unknown" || raid.RaidOwnerName == "") { try { lock (m_RPPDatabaseHandler.GetLockObject()) { var realmDB = new RealmDB(m_RPPDatabaseHandler.GetRealmDB(raid.Realm)); List <string> attendingPlayers = new List <string>(); foreach (var bossFight in bossFights) { attendingPlayers.AddRange(bossFight.GetAttendingUnits(realmDB.RD_IsPlayerFunc(bossFight))); } if (attendingPlayers.Distinct().Count() > 2) { Dictionary <string, int> guildCount = new Dictionary <string, int>(); foreach (var attendingPlayer in attendingPlayers) { string guildName = realmDB.GetPlayer(attendingPlayer).Guild.GuildName; if (guildCount.ContainsKey(guildName)) { guildCount[guildName] = guildCount[guildName] + 1; } else { guildCount.Add(guildName, 1); } } var biggestGuildCount = guildCount.OrderByDescending((_Value) => _Value.Value).First(); if (biggestGuildCount.Value >= (int)(0.7f * (float)attendingPlayers.Count)) { raid.RaidOwnerName = biggestGuildCount.Key; } else { raid.RaidOwnerName = "PUG"; } Logger.ConsoleWriteLine("Raid: Changed RaidOwnerName for " + raid.RaidInstance + "(" + raid.RaidID + ") to " + raid.RaidOwnerName, ConsoleColor.White); } else { raid.RaidOwnerName = "PUG"; } } } catch (Exception ex) { raid.RaidOwnerName = "PUG"; Logger.LogException(ex); } } } foreach (var dungeon in dungeonsModified) { var bossFights = dungeon.GetBossFights(fights); Logger.ConsoleWriteLine("Dungeon: " + dungeon.m_Dungeon + "(" + dungeon.m_UniqueDungeonID + ") by \"" + dungeon.m_GroupMembers.MergeToStringVF("\", \"") + "\"", ConsoleColor.White); foreach (var bossFight in bossFights) { ++totalFightCount; bossFight.GetFightDetails(); //Trigger FightDetail request, so we get error here instead of later on the website. //Logger.ConsoleWriteLine("Fight: " + bossFight.GetBossName() + " added to RaidCollection", ConsoleColor.Green); } } Logger.ConsoleWriteLine("--------------------", ConsoleColor.White); VF.Utility.SaveSerialize(m_RDDBFolder + fightCollectionDatName, fights); VF.Utility.BackupFile(m_RDDBFolder + "RaidCollection.dat", VF.Utility.BackupMode.Backup_Daily); VF.Utility.SaveSerialize(m_RDDBFolder + "RaidCollection.dat", m_RaidCollection, false); Logger.ConsoleWriteLine(_fightCollectionFile + " added " + totalFightCount + " fights to RaidCollection", ConsoleColor.Green); Dictionary <string, FightDataCollection> getFightDataCollectionCache = new Dictionary <string, FightDataCollection>(); getFightDataCollectionCache.Add(fightCollectionDatName, fights); UpdateSummaryDatabase(getFightDataCollectionCache, raidsModified); string debugFilePath = m_RDDBFolder + "\\DebugData\\SessionDebug\\" + DateTime.UtcNow.ToString("yyyy_MM_dd") + ".txt"; VF.Utility.AssertFilePath(debugFilePath); if (System.IO.File.Exists(debugFilePath) == true) { System.IO.File.AppendAllLines(debugFilePath, sessionDebugData); } else { System.IO.File.WriteAllLines(debugFilePath, sessionDebugData); } } else { Logger.ConsoleWriteLine(_fightCollectionFile + " already exists in RaidCollection, skipping", ConsoleColor.Green); } } return(totalFightCount); } catch (Exception ex) { Logger.LogException(ex); Logger.ConsoleWriteLine("DUE TO ERRORS WE ARE RELOADING RAIDCOLLECTION!!!", ConsoleColor.Red); //RESET m_RaidCollection!!! VF.Utility.LoadSerialize <RaidCollection>(m_RDDBFolder + "RaidCollection.dat", out m_RaidCollection); Logger.ConsoleWriteLine("RELOAD OF RAIDCOLLECTION WAS SUCCESSFULL!!!", ConsoleColor.Green); } return(0); }
/// <summary> /// Метод запрос на получение подробнх данных RSS /// </summary> /// <returns> Возврощает список студентов</returns> public List <ModelTableDetailRSS> AllListDetailRSSTable(ModelTableRSS model) => RealmDB.All <ModelTableDetailRSS>().ToList().Where( x => x.IdRSS == model.Id).ToList();
/// <summary> /// Метод поиска RSS по Id /// </summary> /// <param name="id"></param> /// <returns>Возврощает данные студента</returns> public ModelTableRSS FindRSS(int id) => RealmDB.All <ModelTableRSS>().First( b => b.Id == id);
/// <summary> /// Метод запрос на получение данных RSS /// </summary> /// <returns> Возврощает список студентов</returns> public List <ModelTableRSS> AllListRSSTable() => RealmDB.All <ModelTableRSS>().ToList();