public static CacheUpdate BuildCache(uint CacheID, long CacheType, ISerializablePacket Packet) { CacheUpdate Data = new CacheUpdate(); Data.CacheType = CacheType; Data.CacheID = CacheID; Data.CacheDatas = new List<ISerializablePacket>() { Packet }; return Data; }
private void CacheUpdated(RedisChannel channel, RedisValue message) { var updateNotification = _itemSerializer.Deserialize <CacheUpdateNotificationArgs>(message); if (updateNotification.ClientName.Equals(_clientName)) { return; } CacheUpdate?.Invoke(this, updateNotification); }
public async Task <ActionResult> Parse(string fileName) { try { var token = GetToken(); List <UserDetail> izendaUsers; List <UserDetail> combinedList; try { izendaUsers = await IzendaUtilities.IzendaGetAllUsers(token); } catch (Exception e) { Console.WriteLine(e); throw; } var cachedList = CacheSystem.GetCacheItem("combinedList") as List <UserDetail>; if (cachedList == null) { var cachedFileString = CacheUpdate.GetCSV(); var delimitedByLine = cachedFileString.Split(new[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries).ToArray(); var employeeList = delimitedByLine.Select((x, index) => { var delimitedByTab = x.Split(new[] { "\t" }, StringSplitOptions.None); return(new UserDetail { DomainName = delimitedByTab[0].Replace("\"", ""), Name = delimitedByTab[1].ToUpper(), UserName = delimitedByTab[2], FirstName = delimitedByTab[3], LastName = delimitedByTab[4], EmailAddress = delimitedByTab[5], PhysicalDeliveryOfficeName = delimitedByTab[6] }); }).ToList(); foreach (var i in izendaUsers) { i.Name = (i.FirstName + " " + i.LastName).ToUpper(); var containsUser = employeeList.Any(e => e.Name == i.Name); if (containsUser) { var userToRemove = employeeList.FirstOrDefault(e => e.Name == i.Name); if (userToRemove != null) { employeeList.Remove(userToRemove); } } } combinedList = employeeList.Concat(izendaUsers).DistinctBy(i => i.Name).ToList(); CacheSystem.AddCacheItem("combinedList", combinedList, 60); } else { combinedList = cachedList.Concat(izendaUsers).DistinctBy(i => i.EmailAddress).ToList(); CacheSystem.AddCacheItem("combinedList", combinedList, 60); } return(PartialView("ActiveDirectoryList", combinedList)); } catch (Exception ex) { throw ex; } }
static void Main(string[] args) { Log.Texte("", "-------------------------------", ConsoleColor.DarkBlue); Log.Texte("", " _____ _____ ", ConsoleColor.Cyan); Log.Texte("", " /\\ | __ \\ / ____|", ConsoleColor.Cyan); Log.Texte("", " / \\ | |__) | (___ ", ConsoleColor.Cyan); Log.Texte("", " / /\\ \\ | ___/ \\___ \\ ", ConsoleColor.Cyan); Log.Texte("", " / ____ \\| | ____) |", ConsoleColor.Cyan); Log.Texte("", "/_/ \\_\\_| |_____/ Rift", ConsoleColor.Cyan); Log.Texte("", "http://AllPrivateServer.com", ConsoleColor.DarkCyan); Log.Texte("", "-------------------------------", ConsoleColor.DarkBlue); // Loading all configs files ConfigMgr.LoadConfigs(); Config = ConfigMgr.GetConfig <ExtractorConfig>(); // Loading log level from file if (!Log.InitLog(Config.LogLevel, "Cache")) { ConsoleMgr.WaitAndExit(2000); } WorldDB = DBManager.Start(Config.WorldDB.Total(), ConnectionType.DATABASE_MYSQL, "World"); if (WorldDB == null) { ConsoleMgr.WaitAndExit(2000); } PacketProcessor.RegisterDefinitions(); int Count = 0; foreach (string FileDir in Directory.EnumerateFiles(Config.CacheFolder)) { Log.Success("Extractor", "Opening Cache : " + FileDir); FileStream Str = File.Open(FileDir, FileMode.Open); byte[] Buff = new byte[Str.Length]; Str.Read(Buff, 0, Buff.Length); PacketInStream Pack = new PacketInStream(Buff, Buff.Length); ISerializablePacket Packet = PacketProcessor.ReadPacket(ref Pack); if (Packet != null && Packet is CacheUpdate) { CacheUpdate Cache = Packet as CacheUpdate; CacheTemplate Template = Cache.CacheDatas.Find(info => info.Opcode == (long)Opcodes.CacheTemplate) as CacheTemplate; CacheData Data = Cache.CacheDatas.Find(info => info.Opcode == (long)Opcodes.CacheData) as CacheData; if (Template != null) { Template.CacheID = Cache.CacheID; Template.CacheType = Cache.CacheType; WorldDB.AddObject(Template); } if (Data != null) { Data.CacheID = Cache.CacheID; Data.CacheType = Cache.CacheType; WorldDB.AddObject(Data); } ++Count; } Str.Dispose(); } Log.Success("Extractor", "" + Count + " Caches extracted"); ConsoleMgr.Start(); }