protected override void OnSubModuleLoad() { FireLordConfig.Init(); FileDatabase.Initialise(ModuleName); BannerlordConfig.Initialize(); if (BannerlordConfig.Language == "简体中文") { _fireLordSettings = FileDatabase.Get <FireLordSettings>(FireLordSettings.InstanceID); if (_fireLordSettings == null) { _fireLordSettings = new FireLordSettings(); } ((FireLordSettings)_fireLordSettings).Init(); SettingsDatabase.RegisterSettings(_fireLordSettings); } else { _fireLordSettings = FileDatabase.Get <FireLordSettingsEnglish>(FireLordSettings.InstanceID); if (_fireLordSettings == null) { _fireLordSettings = new FireLordSettingsEnglish(); } ((FireLordSettingsEnglish)_fireLordSettings).Init(); SettingsDatabase.RegisterSettings(_fireLordSettings); } }
public ActionResult Index() { var model = new Maintenance(); model.FinishedDrafts = FileDatabase.GetSavedFilenames(); return(this.View("Index", model)); }
public CustomSort(FileDatabase database) { this.InitializeComponent(); this.database = database; this.SortTerm1 = new SortTerm(); this.SortTerm2 = new SortTerm(); }
protected override void OnSubModuleLoad() { if (File.Exists(System.IO.Path.Combine(TaleWorlds.Engine.Utilities.GetConfigsPath(), ModuleFolderName, "Logs"))) { File.Delete(System.IO.Path.Combine(TaleWorlds.Engine.Utilities.GetConfigsPath(), ModuleFolderName, "Logs")); } string logpath = System.IO.Path.Combine(TaleWorlds.Engine.Utilities.GetConfigsPath(), ModuleFolderName, "Logs", "logfile.txt"); if (!Directory.Exists(System.IO.Path.GetDirectoryName(logpath))) { Directory.CreateDirectory(System.IO.Path.GetDirectoryName(logpath)); } ErrorLog.LogPath = logpath; try { FileDatabase.Initialise(ModuleFolderName); BMRandomTweaksConfiguration settings = FileDatabase.Get <BMRandomTweaksConfiguration>(BMRandomTweaksConfiguration.InstanceID); if (settings == null) { settings = new BMRandomTweaksConfiguration(); } SettingsDatabase.RegisterSettings(settings); } catch (Exception ex) { ErrorLog.Log("TournamentsXPanded failed to initialize settings data.\n\n" + ex.ToStringFull()); } }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new IdentityUser { UserName = model.Username, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { //await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); FileDatabase.UpdateUserfile(model.Username, model.Password); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public PopulateFieldsWithMetadata(Window owner, FileDatabase fileDatabase, string filePath, bool useDateMetadataOnly) : base(owner) { InitializeComponent(); this.FilePath = filePath; this.FileDatabase = fileDatabase; this.useDateMetadataOnly = useDateMetadataOnly; }
public DataEntryHandler(FileDatabase fileDatabase) { this.disposed = false; this.ImageCache = new ImageCache(fileDatabase); this.FileDatabase = fileDatabase; // We need a reference to the database if we are going to update it. this.IsProgrammaticControlUpdate = false; }
public void TestFilePathCaseOnWindows() { if (!Mono.Addins.Database.Util.IsWindows) { return; } var rootPath = Path.Combine(TempDir, nameof(TestFilePathCaseOnWindows)); Directory.CreateDirectory(rootPath); var fileDatabase = new FileDatabase(rootPath); try { var folder = Path.Combine(rootPath, "Folder"); Directory.CreateDirectory(folder); folder = char.ToUpperInvariant(folder[0]) + folder.Substring(1); var addinScanFolderInfo = new AddinScanFolderInfo(folder); addinScanFolderInfo.Write(fileDatabase, folder); folder = char.ToLowerInvariant(folder[0]) + folder.Substring(1); var actual = AddinScanFolderInfo.Read(fileDatabase, folder, folder); Assert.NotNull(actual); Assert.AreEqual(1, Directory.GetFiles(folder).Length); } finally { Directory.Delete(rootPath, recursive: true); } }
public DateTimeSetTimeZone(FileDatabase fileDatabase, ImageRow imageToCorrect, Window owner) { // Check the arguments for null ThrowIf.IsNullArgument(fileDatabase, nameof(fileDatabase)); ThrowIf.IsNullArgument(imageToCorrect, nameof(imageToCorrect)); this.InitializeComponent(); this.displayingPreview = false; this.fileDatabase = fileDatabase; this.Owner = owner; // get the image's current time DateTimeOffset currentDateTime = imageToCorrect.DateTimeIncorporatingOffset; this.originalDate.Content = DateTimeHandler.ToStringDisplayDateTimeUtcOffset(currentDateTime); // get the image filename and display it this.FileName.Content = imageToCorrect.File; this.FileName.ToolTip = this.FileName.Content; // display the image this.image.Source = imageToCorrect.LoadBitmap(this.fileDatabase.FolderPath, out bool isCorruptOrMissing); // configure timezone picker TimeZoneInfo imageSetTimeZone = this.fileDatabase.ImageSet.GetSystemTimeZone(); this.TimeZones.SelectedItem = imageSetTimeZone.DisplayName; this.TimeZones.SelectionChanged += this.TimeZones_SelectionChanged; }
bool CheckFile(string fileName) { if (fileName.Length > 0) { if (user.IsLogged) { if (FileDatabase.FileExists(fileName, (int)user.Id)) { user.FileStatus = Account.FileCode.file_exists; return(true); } else { user.FileStatus = Account.FileCode.file_does_not_exist; } } else { user.FileStatus = Account.FileCode.must_be_logged; } } else { user.FileStatus = Account.FileCode.inv_file_name; } return(false); }
private void InitBankRead() { try { database = new FileDatabase(); this.accounts = database.GetAccounts(); this.dataGridView1.DataSource = accounts; dataGridView1.Columns["Balance"].DefaultCellStyle.Format = "C"; foreach (DataGridViewColumn column in dataGridView1.Columns) { dataGridView1.Columns[column.Name].SortMode = DataGridViewColumnSortMode.Automatic; } } catch (Exception e) { this.lblErrors.Text = e.ToString(); MessageBox.Show(e.ToString()); } finally { } }
public PopulateFieldsWithMetadataOnLoad(Window owner, FileDatabase fileDatabase, string filePath) { InitializeComponent(); this.FilePath = filePath; this.FileDatabase = fileDatabase; this.Owner = owner; }
private IList <DataGridCellInfo> selectedRowTuple; // Will contain the tuple of the row corresponding to the selected cell #endregion #region Constructor, Loaded and AutoGeneratedColumns public MissingImageLocateRelativePaths(Window owner, FileDatabase fileDatabase, string relativePath, string fileName, Dictionary <string, List <string> > candidates) { // Keeps the tooltip open until the user moves off the data row //ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(Int32.MaxValue)); InitializeComponent(); if (fileDatabase == null || candidates == null || candidates.Count == 0) { // Nothing to do. Abort this.DialogResult = false; return; } this.Owner = owner; this.FileDatabase = fileDatabase; this.FolderPath = this.FileDatabase.FolderPath; this.RelativePath = relativePath; this.FileName = fileName; // Show the file name and its full relative path in the UI this.RunImageName.Text = this.FileName; this.RunRelativePath.Text = this.RelativePath; // Create a collection comprising: relative path to the found image, number of other missing images found in that relative path, and whether or not that relative path should be used. // Then display it by binding it to the data grid this.observableCollection = new ObservableCollection <Tuple <string, string, bool> >(); int i = 0; foreach (KeyValuePair <string, List <string> > candidate in candidates) { this.observableCollection.Add(new Tuple <string, string, bool>(Path.Combine(candidate.Key, fileName), candidate.Value.Count.ToString(), i++ == 0)); } this.DataGrid.ItemsSource = observableCollection; }
public void Pick(string name, string id, int packnro) { var context = GlobalHost.ConnectionManager.GetHubContext <DraftHub>(); var pack = SessionData.DraftContainer.Packs.FirstOrDefault(x => x.Packnumber == packnro); var player = SessionData.DraftContainer.Players.FirstOrDefault(x => x.Name == name); var pick = pack.Cards.FirstOrDefault(x => x.Id == id); player.Picks.Add(pick); pack.Cards.Remove(pick); pack.EnableForPick = false; if (pack.Cards.Count == 0) { SessionData.DraftContainer.NextPack(); } if (SessionData.DraftContainer.Players.All(x => x.Picks.Count == SessionData.DraftContainer.Picknumber)) { SessionData.DraftContainer.NextPick(); if (SessionData.DraftContainer.State == Enums.Draftstate.Finished) { context.Clients.All.refreshStatus(); FileDatabase.SaveDraftFile(SessionData.DraftContainer); context.Clients.All.refreshDraft(); SessionData.DraftContainer = null; return; } context.Clients.All.refreshDraft(); } }
/// <summary> /// Inserts a new user in the Users table /// </summary> /// <param name="user"></param> /// <returns></returns> public int Insert(TUser user) { var existinguser = userFile.Users.FirstOrDefault(x => x.Id == user.Id); if (existinguser != null) { return(0); } var dbuser = new HsUser(); dbuser.Id = user.Id; dbuser.PasswordHash = user.PasswordHash; dbuser.UserName = user.UserName; dbuser.Email = user.Email; dbuser.SecurityStamp = user.SecurityStamp; dbuser.EmailConfirmed = user.EmailConfirmed; dbuser.Phonenumber = user.PhoneNumber; dbuser.PhonenumberConfirmed = user.PhoneNumberConfirmed; dbuser.AccessFailedCount = user.AccessFailedCount; dbuser.LockoutEnabled = user.LockoutEnabled; dbuser.LockoutEndDateUtc = user.LockoutEndDateUtc; dbuser.TwoFactorEnabled = user.TwoFactorEnabled; userFile.Users.Add(dbuser); userFile = FileDatabase.UpdateUserDb(userFile); return(1); }
public void DeleteCar(Car car) { FileDatabase fileDatabase = new FileDatabase("data"); int i = _cars.FindIndex(x => car == x); _cars.RemoveAt(i); fileDatabase.SaveToDatabase(_cars.ToArray()); }
void WriteFiles() { var writing = Stopwatch.StartNew(); var dataUpdate = new UpdatePackage("data"); var jsout = new JsOutput(dataUpdate); jsout.Write(); // Has to be after everything else because partials are modified here. var searchUpdate = new UpdatePackage("search"); var sqlout = new SearchOutput(jsout, searchUpdate); sqlout.Write(); if (dataUpdate.Rows.Count > 0) { DatabaseBuilder.PrintLine($"Updating {dataUpdate.Rows.Count} data rows."); dataUpdate.Write(); } if (searchUpdate.Rows.Count > 0) { DatabaseBuilder.PrintLine($"Updating {searchUpdate.Rows.Count} data rows."); searchUpdate.Write(); } FileDatabase.WriteHashUpdates(); writing.Stop(); DatabaseBuilder.PrintLine($"Writing elapsed: {writing.Elapsed}"); }
public Sprite getSprite(FileDatabase database) { Sprite icon = new Sprite(); bool sucess = database.UI_Database.TryGetValue(this.image_name, out icon); if (sucess) { return(icon); } else { if (database.UI_Database.Count > 0) { foreach (var item in database.UI_Database) { icon = item.Value; break; } return(icon); } else { return(null); } } }
public QuickPasteEditor(QuickPasteEntry quickPasteEntry, FileDatabase fileDatabase, DataEntryControls dataEntryControls) { this.InitializeComponent(); this.QuickPasteEntry = quickPasteEntry; this.fileDatabase = fileDatabase; this.dataEntryControls = dataEntryControls; }
public PopulateFieldWithEpisodeData(Window owner, FileDatabase fileDatabase) : base(owner) { ThrowIf.IsNullArgument(fileDatabase, nameof(fileDatabase)); this.dataLabelByLabel = new Dictionary <string, string>(); this.fileDatabase = fileDatabase; this.InitializeComponent(); }
public CarService() { FileDatabase requestsFromDatabase = new FileDatabase("data"); Car[] cars = requestsFromDatabase.GetFromDatabase<Car>(); Rent[] rentedCars = requestsFromDatabase.GetFromDatabase<Rent>(); _cars = cars.Length == 0 ? _cars = InitializeCars() : cars; _rentedCars = rentedCars.ToList(); }
/// <summary> /// Deletes all Logins from a user in the UserLogins table /// </summary> /// <param name="userId">The user's id</param> /// <returns></returns> public int Delete(string userId) { var userlogin = loginFile.Logins.FirstOrDefault(x => x.UserId == userId); loginFile.Logins.Remove(userlogin); loginFile = FileDatabase.UpdateLoginDb(loginFile); return(1); }
// Create the interface public DateTimeLinearCorrection(Window owner, FileDatabase fileDatabase) : base(owner) { // Check the arguments for null ThrowIf.IsNullArgument(fileDatabase, nameof(fileDatabase)); this.InitializeComponent(); this.fileDatabase = fileDatabase; }
public IntegrityAnalyzer(Volume volume, FileDatabase database) { this.volume = volume; this.database = database; // Now that we have registered them, let's update the cluster map UpdateClusterMap(); }
/// <summary> /// Deletes a login from a user in the UserLogins table /// </summary> /// <param name="user">User to have login deleted</param> /// <param name="login">Login to be deleted from user</param> /// <returns></returns> public int Delete(IdentityUser user, UserLoginInfo login) { var userlogin = loginFile.Logins.FirstOrDefault(x => x.UserId == user.Id && x.LoginProvider == login.LoginProvider && x.ProviderKey == login.ProviderKey); loginFile.Logins.Remove(userlogin); loginFile = FileDatabase.UpdateLoginDb(loginFile); return(1); }
/// <summary> /// Saves the settings instance to file. /// </summary> /// <param name="settingsInstance">Instance of the settings object to save to file.</param> /// <returns>Return true if the settings object was saved successfully. Returns false if it failed to save.</returns> internal static bool SaveSettings(SettingsBase settingsInstance) { if (settingsInstance == null) { throw new ArgumentNullException(nameof(settingsInstance)); } return(FileDatabase.SaveToFile(settingsInstance.ModuleFolderName, settingsInstance, FileDatabase.Location.Configs)); }
public static string GetFullPath(FileDatabase fileDatabase, ImageRow imageRow) { if (fileDatabase == null || imageRow == null) { return(String.Empty); } return(Path.Combine(fileDatabase.FolderPath, imageRow.RelativePath, imageRow.File)); }
public ActionResult DraftHistory() { var player = User.Identity.Name; var model = FileDatabase.GetHistoryDbForPlayer(player); model.AllCards = FileDatabase.GetAllCards(); return(this.View("Drafthistory", model)); }
public void DeleteRent(Rent rent) { FileDatabase fileDatabase = new FileDatabase("data"); Predicate<Rent> predicate = x => x.Car == rent.Car && x.RentName == rent.RentName; int i = _rents.FindIndex(predicate); _rents.RemoveAt(i); fileDatabase.SaveToDatabase(_rents.ToArray()); }
public void ChangeLogin(string login, string password) { FileDatabase changeLogin = new FileDatabase("data"); login = MasterHashForPW.GetHashString(login); password = MasterHashForPW.GetHashString(password); UserProfile newAdminProfile = new UserProfile(login, password); changeLogin.SaveToDatabase(new[] { newAdminProfile }); }
public Server(string folder_path, int port_num = ServerPortNumber) { path = folder_path; IPAddr = ServerIPAddress; Port = port_num; listener = null; FileDB = new FileDatabase(folder_path); }
public void ChangeRent(Rent rent, Rent newRent) { FileDatabase fileDatabase = new FileDatabase("data"); Predicate<Rent> predicate = x => x.Car == rent.Car && x.RentName == rent.RentName; int i = _rents.FindIndex(predicate); _rents[i] = newRent; fileDatabase.SaveToDatabase(_rents.ToArray()); }
private void MakeAnOrderButton_Click(object sender, System.EventArgs e) { FileDatabase rent_base = new FileDatabase(@"C:\holymosh\DBase"); var rent_dates = rent_base.GetFromDatabase<Rent>(); Array.Resize(ref rent_dates, rent_dates.Length + 1); rent_dates[rent_dates.Length-1]= new Rent(dateTimePicker1.Value, dateTimePicker2.Value, name_selected_car); rent_base.SaveToDatabase<Rent>(rent_dates); reloadCar(); }
private UserProfile InitSettings() { FileDatabase initOfAdmin = new FileDatabase("data"); string login = MasterHashForPW.GetHashString("admin"); string password = MasterHashForPW.GetHashString("1234"); UserProfile newAdminProfile = new UserProfile(login, password); initOfAdmin.SaveToDatabase(new [] {newAdminProfile}); return newAdminProfile; }
public ActionResult Index() { var model = new Maintenance(); var fullHistory = FileDatabase.GetHistoryDb(); model.Users = FileDatabase.GetUserfile(); model.FinishedDrafts = fullHistory; return(this.View("Index", model)); }
internal void SaveBinary(FileDatabase fdb) { if (!canWrite) { throw new InvalidOperationException("Can't write incomplete description."); } fdb.WriteSharedObject(AddinFile, FileName, typeMap, this); // BinaryXmlReader.DumpFile (configFile); }
// Given a list of duplicates and their common relative path, update the corresponding duplicates in the database // We do this by getting the IDs of duplicates in the database, where we update each database by ID to a duplicate. // If there is a mismatch in the number of duplicates in the database vs. in the CSV file, we just update whatever does match. private static string UpdateDuplicatesInDatabase(FileDatabase fileDatabase, List <Dictionary <string, string> > duplicatesDictionaryList, string relativePath, string file) { List <ColumnTuplesWithWhere> imagesToUpdate = new List <ColumnTuplesWithWhere>(); string errorMessage = String.Empty; // Find THE IDs of ImageRows with those RelativePath / File values List <long> duplicateIDS = fileDatabase.SelectFilesByRelativePathAndFileName(relativePath, file); if (duplicateIDS.Count != duplicatesDictionaryList.Count) { string dbEntry = duplicateIDS.Count == 1 ? "entry" : "entries"; string csvEntry = duplicatesDictionaryList.Count == 1 ? "entry" : "entries"; errorMessage = String.Format("duplicate entry mismatch for {0}: {1} database {2} vs. {3} CSV {4}.", Path.Combine(relativePath, file), duplicateIDS.Count, dbEntry, duplicatesDictionaryList.Count, csvEntry); } int idIndex = 0; foreach (Dictionary <string, string> rowDict in duplicatesDictionaryList) { if (idIndex >= duplicateIDS.Count) { break; } // Process each row ColumnTuplesWithWhere imageToUpdate = new ColumnTuplesWithWhere(); foreach (string header in rowDict.Keys) { ControlRow controlRow = fileDatabase.GetControlFromTemplateTable(header); // process each column but only if its off the specific type if (controlRow.Type == Constant.Control.Flag || controlRow.Type != Constant.DatabaseColumn.DeleteFlag || controlRow.Type == Constant.Control.Counter || controlRow.Type == Constant.Control.FixedChoice || controlRow.Type == Constant.DatabaseColumn.ImageQuality ) { imageToUpdate.Columns.Add(new ColumnTuple(header, rowDict[header])); } } // Add to the query only if there are columns to add! if (imageToUpdate.Columns.Count > 0) { imageToUpdate.SetWhere(duplicateIDS[idIndex]); imagesToUpdate.Add(imageToUpdate); } idIndex++; } if (imagesToUpdate.Count > 0) { fileDatabase.UpdateFiles(imagesToUpdate); } return(errorMessage); }
public void StoreFileinFileDatabase() { var f = new FileDatabase(@"\data\testfiledb.fdb"); var info = f.StoreFile(@"C:\Windows\win.ini"); var info1 = f.Search(info.ID); if (info1 == null) throw new Exception(); Assert.AreEqual(info.FileLength, info1.FileLength); Assert.AreEqual(info.MimeType, info1.MimeType); Assert.AreEqual(info.FileName, info1.FileName); }
public void RentOfCar(DateTime fromTime, DateTime toTime, Car currentCar) { Rent newRentedCar; FileDatabase addingRent = new FileDatabase("data"); fromTime = ConvertToDate(fromTime); toTime = ConvertToDate(toTime); newRentedCar = new Rent(currentCar, fromTime, toTime); _rentedCars.Add(newRentedCar); addingRent.SaveToDatabase(_rentedCars.ToArray()); }
private void CarRent_Load(object sender, System.EventArgs e) { FileDatabase car_base = new FileDatabase(@"C:\holymosh\DBase"); var all_cars = car_base.GetFromDatabase<Car>(); FileDatabase rent_base = new FileDatabase(@"C:\holymosh\DBase"); var rent_dates = rent_base.GetFromDatabase<Rent>(); CarService service = new CarService(all_cars, rent_dates); service.getAvailableCars(dateTimePicker1.Value, dateTimePicker2.Value); Car[] available_cars = new Car[service.getCountOfCars]; available_cars = service.available_cars; CarList.Items.AddRange(available_cars); }
private void reloadCar() { FileDatabase fbase = new FileDatabase(@"C:\holymosh\DBase"); var all_cars = fbase.GetFromDatabase<Car>(); FileDatabase rent_base = new FileDatabase(@"C:\holymosh\DBase"); var rent_dates = rent_base.GetFromDatabase<Rent>(); CarService service = new CarService(all_cars, rent_dates); service.getAvailableCars(dateTimePicker1.Value, dateTimePicker2.Value); Car[] available_cars = new Car[service.getCountOfCars]; available_cars = service.available_cars; CarList.Items.Clear(); CarList.Items.AddRange(available_cars); }
private Car[] InitializeCars() { Car[] cars; FileDatabase initializingCars = new FileDatabase("data"); cars = new Car[] { new Car("BMW", "Very good"), new Car("GovnoTesla", "Faster than shit"), new Car("Benz", "Boring car"), new Car("Ziguli", "Don't DO IT!!!"), new Car("Assudi", "Expensive as f**k") }; initializingCars.SaveToDatabase(cars); return cars; }
public void ChangeCar(int index, Car newCar) { FileDatabase fileDatabase = new FileDatabase("data"); _cars[index] = newCar; fileDatabase.SaveToDatabase(_cars.ToArray()); }
public AdminForCars() { FileDatabase fileDatabase = new FileDatabase("data"); _cars = fileDatabase.GetFromDatabase<Car>().ToList(); }
private void SyncCars() { FileDatabase requestsFromDatabase = new FileDatabase("data"); _cars = requestsFromDatabase.GetFromDatabase<Car>(); }
public CarService() { db = new FileDatabase("C:\\CarRent"); PreventiveDB = db.GetFromDatabase<Rent>(); }
public AdminForRent() { FileDatabase fileDatabase = new FileDatabase("data"); List<Rent> rents = fileDatabase.GetFromDatabase<Rent>().ToList(); _rents = rents; }
public LogInSystem() { FileDatabase getAdmin = new FileDatabase("data"); UserProfile[] profiles = getAdmin.GetFromDatabase<UserProfile>(); admin = profiles.Length == 0 ? InitSettings() : profiles[0]; }
public void AddCar(Car car) { FileDatabase fileDatabase = new FileDatabase("data"); _cars.Add(car); fileDatabase.SaveToDatabase(_cars.ToArray()); }