protected override async void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); builder.Entity <Admin>() .HasKey(x => x.Id); builder.Entity <Blog>() .HasKey(x => x.Id); builder.Entity <Blog>() .HasAlternateKey(x => x.Address); builder.Entity <Comment>() .HasKey(x => x.Id); builder.Entity <Post>() .HasKey(x => x.Id); builder.Entity <Post>() .HasAlternateKey(x => x.Url); builder.Entity <User>() .HasKey(x => x.Id); Admin admin; string path = @"D:\adminemail.json"; using (FileStream fs = new FileStream(path, FileMode.Open)) { admin = await JsonSerializer.DeserializeAsync <Admin>(fs); } Admins.Add(admin); }
private static void Interpreter_OnAddUser(string UserName) { try { System.Console.WriteLine(string.Format("User login '{0}'", UserName)); System.Console.WriteLine(string.Format("Enter password for user '{0}':", UserName)); string password = string.Empty; try { password = InputPassword(); } catch (Exception ex) { Logger.Info(ex, ""); return; } System.Console.WriteLine("Please enter full user name"); string fullUserName = System.Console.ReadLine(); System.Console.WriteLine("Please enter comment (if you need)"); string comment = System.Console.ReadLine(); Admins.Add(UserName, password, fullUserName, comment); } catch (Exception ex) { System.Console.WriteLine($"Add user error: {ex.Message}"); Logger.Error(ex, "Create user error"); } }
public void add_valid_item_to_db() { Init(); // TEST: add new Admins with good data to db try { Admins.Add(item_with_valid_data); } catch (Exception ex) { Assert.Fail($"Failed TEST: add_good_item_to_db: {ex}"); } bool result = false; using (cap01devContext db = new cap01devContext()) { foreach (Admins a in db.Admins) { if (a.Email == item_with_valid_data.Email) { result = true; break; } } } Assert.IsTrue(result); }
public void delete_admin() { Init(); // TEST: add new Admins without email to db Admins.Add(item_enabled); Admins.Delete(item_enabled.Email); Assert.AreEqual(Admins.All().Count, 0); }
public override void OnLoginCompleted() { List <Inventory.Item> itemsToTrade = new List <Inventory.Item>(); // Must get inventory here Log.Info("Getting Inventory"); Bot.GetInventory(); // Optional Crafting if (AutoCraftWeps) { AutoCraftAll(); } if (ManageCrates) { DeleteSelectedCrates(DeleteCrates); // One more break before updating inventory Thread.Sleep(500); Bot.GetInventory(); itemsToTrade = GetTradeItems(Bot.MyInventory, TransferCrates); } else { itemsToTrade = GetTradeItems(Bot.MyInventory, 0); } if (!BotItemMap.ContainsKey(mySteamID)) { BotItemMap.Add(mySteamID, itemsToTrade); Admins.Add(mySteamID); } Log.Info("[Giving] " + Bot.DisplayName + " checking in. " + BotItemMap.Count + " of " + NumberOfBots + " Bots."); if (!Bot.MyInventory.IsFreeToPlay()) { if (BotItemMap[mySteamID].Count > 0) { TradeReadyBots.Add(mySteamID); Log.Info(Bot.DisplayName + " has items. Added to list." + TradeReadyBots.Count + " Bots waiting to trade."); } else { Log.Warn(Bot.DisplayName + " did not have an item to trade."); Log.Warn("Stopping bot."); Bot.StopBot(); } } else { // Requires more info on f2p item characteristics. Log.Warn(Bot.DisplayName + " is free to play. F2P trading is not configured yet."); Bot.StopBot(); } }
public void add_without_email_item_to_db() { Init(); // TEST: add new Admins without email to db Assert.ThrowsException <ValidationException>(() => { Admins.Add(item_without_email); }); }
public void add_without_full_name_item_to_db() { Init(); // TEST: add new Admins without FullName to db Assert.ThrowsException <ValidationException>(() => { Admins.Add(item_without_full_name); }); }
public void add_without_password_item_to_db() { Init(); // TEST: add new Admins without PasswordHash to db Assert.ThrowsException <ValidationException>(() => { Admins.Add(item_without_password); }); }
public static void AddLevels(Player player) { if (player.Data.LevelAdmin > 0) { Admins.Add(player); } if (player.Data.LevelVip > 0) { Vips.Add(player); } }
public void Update() { IEnumerable <AdminDisplayModel> admins = facade.GetAll(); Admins.Clear(); foreach (AdminDisplayModel admin in admins) { Admins.Add(admin); } RaisePropertyChangedEvent("SelectedAdmin"); }
/// <summary> /// Attempts to register the specified client as an admin using the specified password. This checks against the server password, and will /// return true if the password was correct (and the client was elevated to an admin), otherwise it returns false. /// </summary> /// <param name="c">The client requesting administrative priveleges.</param> /// <param name="pass">The password that the client provided, to be checked against the actual password for the server.</param> /// <returns></returns> public bool RegisterAdmin(Client c, string pass) { if (pass == AdminPassword) { Admins.Add(c); return(true); } else { return(false); } }
private void LoadAdmins() { using (var rd = new StreamReader("admins.txt")) { int n = Convert.ToInt32(rd.ReadLine()); Admins.Clear(); for (int i = 0; i < n; ++i) { Admins.Add(new Admin(rd.ReadLine(), rd.ReadLine())); } } }
// Метод для підключення існуючих пар ім'я (адміністратора) + пароль до системи готелю. public void ConnectAdmins() { Admins.Clear(); Admins.Add(new Admin { Name = "Дмитрий", Password = "******" }); Admins.Add(new Admin { Name = "Елена", Password = "******" }); Admins.Add(new Admin { Name = "Сергей", Password = "******" }); }
public override void OnLoginCompleted() { if (!BotItemMap.ContainsKey(mySteamID)) { // Adding for complete attendance of all active bots, no need for inventory. BotItemMap.Add(mySteamID, null); Admins.Add(mySteamID); } Log.Info("[Main] SteamID: " + mySteamID + " checking in."); MainUHIsRunning = true; MainSID = Bot.SteamUser.SteamID; }
public async Task list_admins() { Init(); Admins.Add(item_with_valid_data, db); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "ca/manage/list"); request.Content = new StringContent("", Encoding.UTF8, "application/json"); var response = await _client.SendAsync(request); response.EnsureSuccessStatusCode(); }
public async Task disabling_admin() { Init(); Admins.Add(item_enabled, db); RequestData requestData = new RequestData(); requestData.Add("email", item_disabled.Email); StringContent content = new StringContent(requestData.Serialize(), Encoding.UTF8, "application/json"); var response = await _client.PatchAsync("ca/manage/shutdown", content); response.EnsureSuccessStatusCode(); }
public async Task delete_admin() { Init(); Admins.Add(item_with_valid_data, db); RequestData requestData = new RequestData(); requestData.Add("email", item_with_valid_data.Email); StringContent content = new StringContent(requestData.Serialize(), Encoding.UTF8, "application/json"); var response = await _client.PostAsync("ca/manage/delete", content); response.EnsureSuccessStatusCode(); }
public void list_items() { Init(); try { Admins.Add(item_with_valid_data); } catch (Exception ex) { Assert.Fail($"Failed TEST: add_good_item_to_db: {ex}"); } List <Admins> items = Admins.All(); Assert.AreEqual(items.Count, 1); Assert.IsTrue(items[0].Equals(item_with_valid_data)); }
private void GetMembers(JToken json) { Members = new List <string>(); foreach (var m in json["members"]) { Members.Add(m["nickname"].ToString()); try { if (m["admin"].ToString() == "true") { Admins.Add(m["nickname"].ToString()); } } catch { } } }
public override void OnLoginCompleted() { if (!BotItemMap.ContainsKey(mySteamID)) { // Adding for complete attendance of all active bots, no need for inventory. BotItemMap.Add(mySteamID, null); Admins.Add(mySteamID); } Log.Info("[Receiving] SteamID: " + mySteamID + " checking in."); switch (BotMode) { case (int)Actions.DoNothing: Log.Info("Bot Mode DoNothing Loaded. Commencing the doing of nothing. (Use commands for custom actions)"); break; case (int)Actions.NormalHarvest: Log.Info("Bot Mode NormalHarvest Loaded. Starting sequence..."); BeginHarvesting(); break; case (int)Actions.CrateManager: Log.Info("Bot Mode CrateManager Loaded. Managing crates..."); if (ManageCrates) { DeleteSelectedCrates(DeleteCrates); if (CrateUHIsRunning) { Log.Info("Sending Crates to CUH"); BeginNextTrade(CrateSID); } else { Log.Error("CrateUserHandler not found, cannot handle crates."); } } break; default: Log.Warn("Unkown Bot Mode Loaded: " + BotMode); Log.Warn("Doing nothing instead..."); break; } }
public override void OnLoginCompleted() { List <Inventory.Item> itemsToTrade = new List <Inventory.Item>(); // Optional Crafting if (AutoCraftWeps) { AutoCraftAll(); // Inventory must be up-to-date before trade Thread.Sleep(300); } // Must get inventory here Log.Info("Getting Inventory"); Bot.GetInventory(); if (ManageCrates) { Bot.SetGamePlaying(440); DeleteSelectedCrates(DeleteCrates); Bot.SetGamePlaying(0); } itemsToTrade = GetTradeItems(Bot.MyInventory, 0); if (!BotItemMap.ContainsKey(mySteamID)) { BotItemMap.Add(mySteamID, itemsToTrade); Admins.Add(mySteamID); } Log.Info("[Crate] " + Bot.DisplayName + " checking in. " + BotItemMap.Count + " of " + NumberOfBots + " Bots."); CrateUHIsRunning = true; if (BotItemMap[mySteamID].Count > 0) { Log.Info(Bot.DisplayName + " has items. Added to list." + TradeReadyBots.Count + " Bots waiting to trade."); } else { Log.Warn(Bot.DisplayName + " did not have an item to trade."); } Log.Info("Waiting for Receiving to finish."); }
public void disable_admin() { Init(); try { Admins.Add(item_enabled); Admins.Disable(item_enabled.Email); } catch (Exception ex) { Assert.Fail($"Failed TEST: add_good_item_to_db: {ex}"); } List <Admins> items = Admins.All(); Assert.AreEqual(items.Count, 1); Assert.AreEqual(items[0].IsActive, false); }
public static Admins GetAdmins(string admin) { Admins admins = new Admins(); using (DataSet set = provider.GetGroupAdmins(admin)) { if (Util.CheckDataSet(set)) { foreach (DataRow reader in set.Tables[0].Rows) { Admin adm = new Admin(); adm.AdminId = Util.ConvertToInt(reader["id"].ToString()); adm.AdminName = reader["adminname"].ToString(); admins.Add(adm); } } } return(admins); }
public void Register(string name, string login, int pasword, string type) { if (IsInList(login)) { // A user with this login already exists. return; } if (type == "Admin") { Admin admin = new Admin(name, login, pasword); Admins.Add(admin); adminsDao.Save(Admins); } else { Guest guest = new Guest(name, login, pasword); Guests.Add(guest); guestsDao.Save(Guests); } }
//---------------------------------------------------------------------------------- public List <Admin> AdminXMLDeSerialize() { FileInfo fi = new FileInfo(AdminPath); if (fi.Exists) { XmlSerializer formatter = new XmlSerializer(typeof(List <Admin>)); using (FileStream fs = new FileStream(AdminPath, FileMode.OpenOrCreate)) { Admins = (List <Admin>)formatter.Deserialize(fs); //Console.WriteLine("DeSerial OK!"); } return(Admins); } else { Admin tempAdmin = new Admin(); Admins.Add(tempAdmin); } return(Admins); }
public void AddAdmin(string status) { string key = Encryption.GetUniqueKey(8); string flag = Encryption.GetUniqueKey(16); string sol = Encryption.GetUniqueKey(12); Admins.Add(new Admin() { Title = status, Key = key, Sol = sol, Flag = flag }); SaveChanges(); if (Accounts.Count() != 0 && Admins.Count() != 1) { var account = Accounts.ToList(); var admin = Admins.ToList(); for (int i = 0; i < account.Count(); i++) { var flags = admin[0].Flag; var logins = account[i].Login; var pass = Passwords.FirstOrDefault(c => c.Flag == flags && c.AccountID == Accounts.FirstOrDefault(a => a.Login == logins).AccountID).Passwords; var keyA = admin[0].Key; var solA = admin[0].Sol; Password password = new Password() { PasswordID = account.Count() + 1, AccountID = account[i].AccountID, Flag = flag, Passwords = Encryption.Encrypt(Encryption.Decrypt(pass, keyA, solA), key, sol) }; account[i].Passwords.Add(password); Passwords.Add(password); SaveChanges(); } } }
/// <summary> /// This method creates a new user. /// </summary> /// <param name="name">user name</param> /// <param name="login">unique user login</param> /// <param name="password">user password</param> /// <param name="isAdmin">boolean variable, if the user is registered as an administrator, the variable is equal to true, if as a guest - false</param> /// <returns>If data was entered incorrectly method returns false, otherwise returns false.</returns> public bool Register(string name, string login, string password, bool isAdmin) { int passwordHash = password.GetHashCode(); if (IsInList(login)) { return(false); } if (isAdmin) { Admin admin = new Admin(name, login, passwordHash); CurrentUser = admin; Admins.Add(admin); adminsDao.Save(Admins); } else { Guest guest = new Guest(name, login, passwordHash); CurrentUser = guest; Guests.Add(guest); guestsDao.Save(Guests); } return(true); }
public JsonResult create([FromBody] string content) { try { JsonResult result = null; Logger.Trace("AdminsController.Creater IN"); HttpRequest Request = ControllerContext.HttpContext.Request; PathString st = Request.PathBase; if (!Request.ContentType.Contains("application/json")) { result = new JsonResult(ResponseData.CONFLICT_409("Wrong content type. Content type must be 'application/json'")); result.StatusCode = (int)System.Net.HttpStatusCode.Conflict; return(result); } if (Request.Body.Length > 1024) { result = new JsonResult(ResponseData.CONFLICT_409("Wrong content type. Content type must be 'application/json'")); result.StatusCode = (int)System.Net.HttpStatusCode.Conflict; return(result); } RequestData requestData = RequestData.Deserialize(Request.Body); string Email = requestData.GetValue("email") as string; string Comment = requestData.GetValue("comment") as string; string FullName = requestData.GetValue("full_name") as string; string passwordHash = requestData.GetValue("password_hash") as string; Logger.Debug($"AdminsController.Creater Email = {Email}"); Logger.Debug($"AdminsController.Creater FullName = {FullName}"); Logger.Debug($"AdminsController.Creater Comment = {Comment}"); Admins item = new Admins() { Email = Email, Comment = Comment, FullName = FullName, PasswordHash = passwordHash }; Admins.Add(item, db); Logger.Debug("AdminsController.Creater Inserted"); return(new JsonResult(ResponseData.CREATED_201("Created", "")) { StatusCode = (int)System.Net.HttpStatusCode.Created }); } catch (ValidationException ex) { Logger.Error(ex, "Error in Admins.create: ValidateError"); return(new JsonResult(ResponseData.CONFLICT_409(ex.Message)) { StatusCode = (int)System.Net.HttpStatusCode.Conflict }); } catch (Exception ex) { Logger.Error(ex, "Error in Admins.create"); return(new JsonResult(ResponseData.INTERNAL_SERVER_ERROR_500()) { StatusCode = (int)System.Net.HttpStatusCode.InternalServerError }); } finally { Logger.Trace("AdminsController.Creater OUT"); } }
/// <summary> /// Creates admins /// </summary> private void CreateAdmins() { Admins.Add(new Admin("Ney York", GetID(), "Harald Denon")); Admins.Add(new Admin("Eden", GetID(), "Evan Almighty")); Admins.Add(new Admin("Hässleholm", GetID(), "Christian Zaar")); }
public void FillTestData(int n) { //Admins for (int i = 1; i <= n; i++) { Admin newA = new Admin() { Name = $"Admin_{i}", Password = "******", }; Admins.Add(newA); } // Cars Cars.Clear(); for (int i = 0; i < n; i++) { Cars.Add(new Car() { Features = "nope", ID = i + 1, MaksSpeed = (i * 10) % 180 + 100 + 5 * (i % 2), Price = (i * 1000) % 20000 + 6000, ProdCountry = coun[i % coun.Length], Model = mar[i % mar.Length], TechState = (3 * i + 20) % 100 + 1, YearOfIssue = 2000 + i % 20 }); } // Buyers for (int i = 1; i <= n; i++) { int numb = 80042900 + i % 100000; Buyer newB = new Buyer() { Contacts = $"+{numb}", FinancialOpp = ((i * i + 1) * 1000) % 50000 + 7000, MaksSpeedRequired = (i * 10) % 140 + 60, ModelRequired = mar[(i + 3) % mar.Length], Name = $"Buyer_{i}", Password = "******", PerfomanceRequired = i % 100 + 1 }; if (i % 5 == 0) { newB.ModelRequired = "nope"; } Buyers.Add(newB); } // Reports int div = 2;//сколько в каждом отчете машин for (int t = 0; t < n / div; t++) { var ps = new List <Car>(); for (int j = 0; j < div; j++) { ps.Add(new Car { Features = Cars[t * div + j].Features, ID = Cars[t * div + j].ID, MaksSpeed = Cars[t * div + j].MaksSpeed, Model = Cars[t * div + j].Model, Price = Cars[t * div + j].Price, ProdCountry = Cars[t * div + j].ProdCountry, TechState = Cars[t * div + j].TechState, YearOfIssue = Cars[t * div + j].YearOfIssue }); } Reports.Add(new Report(ps, Buyers[t].Name, DateTime.Now + TimeSpan.FromDays(t))); } }