public override void AddUser(DIUser user) { if (user.Division == null) { user.Division = "Unassigned"; } if (SubUnits.All(x => x.UnitId != user.Division)) { SubUnits.Add(new DIDivision(user.Division)); } SubUnits.First(x => x.UnitId == user.Division).AddUser(user); if (user.Position == DIPosition.HouseGeneral) { _houseGeneralId = user.Id; } else if (user.Position == DIPosition.FirstCommander) { _firstCommanderId = user.Id; } else if (user.Position == DIPosition.HouseAide) { _houseAideId = user.Id; } }
public void Update() { var oldUsers = Members.ToList(); SubUnits.Clear(); try { var handler = new HttpClientHandler(); handler.CookieContainer = new CookieContainer(); ConfigUtil.Config.AuthConfig.Cookies .Select(x => new System.Net.Cookie(x.Name, x.Value, x.Path, x.Domain)) .ToList() .ForEach(x => handler.CookieContainer.Add(x)); var result = new DIHttpClient(handler).GetStringAsync("mdr/").GetAwaiter().GetResult(); var doc = new HtmlDocument(); doc.LoadHtml(result); foreach (var node in doc.DocumentNode.SelectNodes("//a")) { var user = new DIUser(); if (!Enum.TryParse(node.Attributes["class"]?.Value.Replace("-", "") ?? "", true, out user.Rank)) { continue; } user.Name = node.InnerText.Split(' ')[0].Trim(); user.Id = Convert.ToInt32(ProfileUrlRegex.Match(node.Attributes["href"].Value).Groups[2].Value); AddDIUnitInformation(user, node); DIUser oldUser = null; if ((oldUser = oldUsers.FirstOrDefault(x => x.Id == user.Id)) != null) { user.DiscordId = oldUser.DiscordId; user.ImageUrl = oldUser.ImageUrl; } AddUser(user); } } catch (Exception e) { e.ToString(); } }
public override void AddUser(DIUser user) { if (user.House == null) { user.House = "Unassigned"; } if (SubUnits.All(x => x.UnitId != user.House)) { SubUnits.Add(new DIHouse(user.House)); } SubUnits.First(x => x.UnitId == user.House).AddUser(user); }
public override void AddUser(DIUser user) { if (user.Roster == null) { user.Roster = "Unassigned"; } if (SubUnits.All(x => x.UnitId != user.Roster)) { SubUnits.Add(new DIRoster(user.Roster)); } SubUnits.First(x => x.UnitId == user.Roster).AddUser(user); if (user.Position == DIPosition.TeamLeader) { _teamLeaderId = user.Id; } else if (user.Position == DIPosition.SecondInCommand) { _secondInCommandId = user.Id; } }
public override void AddUser(DIUser user) { if (user.Team == null) { user.Team = "Unassigned"; } if (SubUnits.All(x => x.UnitId != user.Team)) { SubUnits.Add(new DITeam(user.Team)); } SubUnits.First(x => x.UnitId == user.Team).AddUser(user); if (user.Position == DIPosition.DivisionCommander) { _divisionCommanderId = user.Id; } else if (user.Position == DIPosition.DivisionVice) { _divisionViceId = user.Id; } }
private void AssignTrayBufferModule(Modules.BufferConveyorModule module, SubUnits.InletBufferConveyorUnit unit, bool useAligner) { module.OutCompletedSensor = unit.OutCompletedSensor; module.TrayInSensor = unit.TrayInSensor; module.TrayStopSensor = unit.TrayStopSensor; module.ConveyorMotor = unit.ConveyorMotor; module.Stopper = unit.Stopper; if (useAligner) module.Aligner = unit.Aligner; }