public MainForm() { this.InitializeComponent(); this.InitExterns = false; this.InitExterns = this.InitializeExternals(); RegistryData registryData = new RegistryData(); Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(registryData.LCID); InputConfiguration value = new InputConfiguration(); this.TabWindow.TabPages[0].Controls.Add(value); GraphicsConfiguration value2 = new GraphicsConfiguration(); this.TabWindow.TabPages[1].Controls.Add(value2); StatsConfiguration value3 = new StatsConfiguration(); this.TabWindow.TabPages[2].Controls.Add(value3); AudioConfiguration value4 = new AudioConfiguration(); this.TabWindow.TabPages[3].Controls.Add(value4); FileHandler fileHandler = new FileHandler(); fileHandler.LoadGraphicsFile(); if (!fileHandler.LoadAudioConfiguration()) { GlobalDefs.OutputAudio.description = "Default"; GlobalDefs.OutputAudio.AudioGuid = new Guid("FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"); } this.TabWindow.SelectedIndex = 3; }
public RegistryData() { this.mLCID = 1033; this.mSaveLocation = ""; RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Sega\\Sonic Generations"); if (registryKey != null) { object value = registryKey.GetValue("locale"); if (value != null) { string a; if ((a = value.ToString()) != null && (a == "1033" || a == "1040" || a == "1036" || a == "1031" || a == "3082")) { this.mLCID = int.Parse(value.ToString()); } else { this.mLCID = 1033; } } StringBuilder stringBuilder = new StringBuilder(260); object value2 = registryKey.GetValue("SaveLocation"); if (value2 != null) { RegistryData.SHGetSpecialFolderPathW(IntPtr.Zero, stringBuilder, 5, false); stringBuilder.Insert(stringBuilder.Length, "\\"); stringBuilder.Insert(stringBuilder.Length, value2.ToString()); this.mSaveLocation = stringBuilder.ToString(); } } }
private void buttLogin_Click(object sender, EventArgs e) { if (tbEmail.Text == "") { MessageBox.Show("Email is required"); return; } if (tbPassword.Text == "") { MessageBox.Show("Username is required"); return; } MessageResponse result = AuthRequests.postLogin(tbEmail.Text, tbPassword.Text); if (result.message == "Login successful!") { lblError.Text = ""; GlobalVariables.bIsLoggedIn = true; GlobalVariables.userPanel = new Forms.UserForm(); GlobalVariables.userPanel.Show(); if (GlobalVariables.user.public_key != "") { Functions.RSA.setPrivateKey(RegistryData.getRegistryPrivateKey()); } this.Hide(); } else { lblError.Text = result.message; } }
public void ValidateInput(string username, string password, string confirmedPassword) { if (string.IsNullOrWhiteSpace(username) || username.Length < Constants.MinUsernameLenght || username.Length > Constants.MaxUsernameLenght) { throw new InvalidNameLenghtException(string.Format(GlobalMessages.InvalidUsernameLenght , Constants.MinUsernameLenght , Constants.MaxUsernameLenght)); } if (!Regex.IsMatch(username, Constants.UsernameValidationPattern)) { throw new InvalidUsernameException(GlobalMessages.InvalidUsername); } if (RegistryData.GetUsernames().Contains(username)) { throw new UsernameAlreadyUsedException(GlobalMessages.AlreadyTaken); } if (password != confirmedPassword) { throw new PasswordMismatchException(GlobalMessages.PasswordsMismatch); } if (string.IsNullOrWhiteSpace(password) || password.Length < Constants.MinPasswordLenght) { throw new InvalidPasswordLenghtException(string.Format(GlobalMessages.InvalidPasswordLenght , Constants.MinPasswordLenght , Constants.MaxPasswordLenght)); } }
public static Registry Find(Guid id) { try { if (id == null || Equals(id, Guid.Empty)) { throw new Exception("Parâmetro inválido"); } Registry item = null; using (Entities db = new Entities()) { RegistryData row = db.RegistryData.FirstOrDefault(x => x.IdRegistry == id); if (row == null) { throw new Exception("Matrícula não encontrada"); } item = Convert(row); } return(item); } catch (Exception e) { string notes = LogHelper.Notes(id, e.Message); Log.Add(Log.TYPE_ERROR, "SistemaMatricula.DAO.RegistryDAO.Find", notes); } return(null); }
public override void Execute() { Envelope e; if (myConversation.envelopeQueue.Count > 0) { if (myConversation.envelopeQueue.TryTake(out e)) { if (e.message.MessageType == Message.ACK) { RegistryData.GameInfo gameInfo = new RegistryData.GameInfo(); gameInfo.GameActive = false; gameInfo.GameId = RegistryData.GetNextGameId(); gameInfo.Players = 1; gameInfo.RemoteEndPoint = e.remoteEndPoint; if (((RegistryAppWorker)myConversation.commFacility.myAppWorker).RegistryData.AddGame(gameInfo)) { ((JoinGameConversation)myConversation).SendGameInfoMessage(gameInfo); } else { Logger.Error("Registry was unable to add game to dictionary"); } myConversation.Stop(); } else { Logger.Error("Join Game Conversation Expected an Ack message but received message type " + e.message.MessageType); } } } }
public static bool Delete(Guid id) { try { if (id == null || Equals(id, Guid.Empty)) { throw new Exception("Parâmetro inválido"); } using (Entities db = new Entities()) { RegistryData row = db.RegistryData.FirstOrDefault(x => x.IdRegistry == id); if (row == null) { throw new Exception("Matrícula não encontrada"); } row.DeleteDate = DateTime.Now; row.DeleteBy = User.Logged.IdUser; db.SaveChanges(); } return(true); } catch (Exception e) { string notes = LogHelper.Notes(id, e.Message); Log.Add(Log.TYPE_ERROR, "SistemaMatricula.DAO.RegistryDAO.Delete", notes); } return(false); }
public void UserApp_StartGameConversation_Test() { //--------------SET UP VARIABLES-------------------// RegistryData registryData = new RegistryData(); RegistryData.GameInfo gameInfo = new RegistryData.GameInfo(); TestAppWorker testAppWorker = new TestAppWorker(registryData); testAppWorker.StartTest(); var gameManager = new UdpCommunicator() { MinPort = 10000, MaxPort = 10999, Timeout = 1000, EnvelopeHandler = ProcessEnvelope1 }; gameManager.Start(); IPEndPoint registryEp = new IPEndPoint(IPAddress.Loopback, testAppWorker.commFacility.udpCommunicator.Port); IPEndPoint gameManagerEp = new IPEndPoint(IPAddress.Loopback, gameManager.Port); gameInfo.RemoteEndPoint = gameManagerEp; gameInfo.GameActive = false; Assert.IsTrue(registryData.AddGame(gameInfo)); StartGameMessage msg1 = new StartGameMessage(1); Envelope env1 = new Envelope(msg1, registryEp); //--------------TEST INITIAL SET UP AND SEND INITIAL MESSAGE-------------------// Assert.IsNull(testAppWorker.commFacility.convDictionary.GetConv(msg1.convId)); Assert.IsFalse(gameInfo.GameActive); gameManager.Send(env1); Thread.Sleep(1000); //--------------TEST OUTCOME-------------------// Assert.AreNotSame(msg1, _lastIncomingEnvelope1); // Make sure received message isn't null Assert.IsNotNull(_lastIncomingEnvelope1); Assert.IsNotNull(_lastIncomingEnvelope1.message); // Make sure received message is AckMessage Assert.AreEqual(msg1.convId, _lastIncomingEnvelope1.message.convId); AckMessage msg2 = _lastIncomingEnvelope1.message as AckMessage; Assert.IsNotNull(msg2); Assert.IsTrue(gameInfo.GameActive); Assert.IsNull(testAppWorker.commFacility.convDictionary.GetConv(msg1.convId)); //--------------CLOSE EVERYTHING-------------------// testAppWorker.StopTest(); gameManager.Stop(); }
public static bool Add(Registry item) { try { if (item == null) { throw new Exception("Parâmetro vazio"); } RegistryData row = new RegistryData { IdRegistry = Guid.NewGuid(), IdGrid = item.Grid.IdGrid, IdStudent = item.Student.IdStudent, Alternative = item.Alternative, RegisterDate = DateTime.Now, RegisterBy = User.Logged.IdUser }; using (Entities db = new Entities()) { db.RegistryData.Add(row); db.SaveChanges(); } return(true); } catch (Exception e) { string notes = LogHelper.Notes(item, e.Message); Log.Add(Log.TYPE_ERROR, "SistemaMatricula.DAO.RegistryDAO.Add", notes); } return(false); }
public static void postPublicKey() { Functions.RSA.generateRSAKeys(); RegistryData.setRegistryPrivateKey(Functions.RSA.getPrivateKey()); try { var request = (HttpWebRequest)WebRequest.Create(ENDPOINT + "postPublicKey?deviceName="); var postData = "client_id=" + GlobalVariables.user.id + "&public_key=" + Functions.RSA.getPublicKey(); var data = Encoding.ASCII.GetBytes(postData); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = data.Length; using (var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); stream.Close(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { // Dispose managed resources here. if (m_regData != null) { m_regData.RestoreRegistryData(); } Unpacker.RemoveParatextTestProjects(); } // Dispose unmanaged resources here, whether disposing is true or false. m_regData = null; base.Dispose(disposing); }
public RegistryAppWorker() : base(new RegistryConversationFactory()) { RegistryData = new RegistryData(); StartUpState = new StartUpState(this); currentState = StartUpState; }
public override void FixtureSetup() { CheckDisposed(); base.FixtureSetup(); Unpacker.UnPackParatextTestProjects(); m_regData = Unpacker.PrepareRegistryForPTData(); }
public void TestDllRegistryPath() { CheckDisposed(); string regPath1 = RegistryData.GetRegisteredDLLPath("ECObjects.ECProject"); string regPath2 = RegistryData.GetRegisteredDLLPath("ECObjects.ECProject.1"); Assert.AreEqual(regPath1, regPath2, "The Registered Paths aren't equal."); }
public void Register(string username, string password) { string hashedPass = HashUtilities.HashPassword(password); byte[] key = HashUtilities.HashKey(password); string encryptedData = CryptographicUtilities.Encrypt(string.Empty, key); RegistryData.CreateUser(username, hashedPass, encryptedData); }
public override void FixtureSetup() { base.FixtureSetup(); Unpacker.UnPackParatextTestProjects(); m_regData = Unpacker.PrepareRegistryForPTData(); m_fdoCache = FdoCache.Create("TestLangProj"); m_scr = (Scripture)m_fdoCache.LangProject.TranslatedScriptureOA; ScrReferenceTests.InitializeScrReferenceForTests(); }
public void AddPS4(PS4 ps4) { if (!Regex.IsMatch(ps4.IPAddress, IP_REGEX)) { System.Windows.Forms.MessageBox.Show("Ip Not valid"); return; } RegistryData rd = registryData.CreateSubKey(ps4.Name); rd.Add("IPAddress", ps4.IPAddress); rd.Add("Firmware", ps4.Firmware); }
IVsTemplate IVsTemplatesService.GetTemplate(string templateFileName) { if (this.Components[templateFileName] == null) { RegistryData regData = GetTemplateRegistryData(templateFileName); this.Add( new TemplateMetaData( templateFileName, regData.CommandID, regData.PackageName, this.currentVsRegistryKey), templateFileName); } return((IVsTemplate)this.Components[templateFileName]); }
private bool SavePadConfigurations() { RegistryData registryData = new RegistryData(); string text = registryData.ReadSaveLocationFromRegistry; if (text == "") { return(false); } if (!File.Exists(text)) { Directory.CreateDirectory(text); } text += "\\PlayerInput.cfg"; List <string> list = new List <string>(); GlobalDefs globalDefs = new GlobalDefs(); foreach (OutputConfig outputConfig in GlobalDefs.OutputConfigList) { if (!(outputConfig.mProductGuid == globalDefs.ZERO_GUID)) { list.Add(outputConfig.mProductName.ToString()); string text2 = "$G:"; text2 += outputConfig.mProductGuid.ToString(); string text3 = ""; for (int i = 0; i < outputConfig.mButtonMap.Length; i++) { text3 += outputConfig.mButtonMap[i].ToString(); text3 += " "; } text3 += outputConfig.mMovementType; text2 += "$B:"; text2 += text3; string text4 = ""; for (int j = 0; j < outputConfig.mAxisMap.Length; j++) { text4 += outputConfig.mAxisMap[j].ToString(); text4 += " "; } text2 += "$A:"; text2 += text4; text2 += "$D:"; text2 += outputConfig.mDeadZone.ToString(); text2 += "$"; list.Add(text2); } } File.WriteAllLines(text, list.ToArray()); return(true); }
public void storageOperation(string Operation, string Calculation) { var headerValue = chekTrackingId(); if (headerValue != null) { if (RegistryData.byId(headerValue) == null) { RegistryData.addRegistry(headerValue); } RegistryData.addOperation(headerValue, Operation, Calculation); } }
public void Registry_JoinGameConversation_Test() { IPEndPoint registryEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 11000); RegistryData registryData = new RegistryData(); TestAppWorker testAppWorker = new TestAppWorker(registryData, registryEndPoint); testAppWorker.StartTest(); var comm1 = new UdpCommunicator() { MinPort = 10000, MaxPort = 10999, Timeout = 1000, EnvelopeHandler = ProcessEnvelope1 }; comm1.Start(); Message msg1 = new RequestGameMessage(); Envelope env = new Envelope(msg1, registryEndPoint); Assert.IsNull(testAppWorker.commFacility.convDictionary.GetConv(msg1.convId)); Assert.IsNull(registryData.GetAvailableGameManager()); comm1.Send(env); Thread.Sleep(1000); /* * //The conversation happens to fast. After the sleep, the conv is already gone * Assert.IsNotNull(testAppWorker.commFacility.convDictionary.GetConv(msg1.convId)); */ Assert.AreNotSame(msg1, _lastIncomingEnvelope1); Assert.IsNotNull(_lastIncomingEnvelope1); Assert.IsNotNull(_lastIncomingEnvelope1.message); Assert.AreEqual(msg1.convId, _lastIncomingEnvelope1.message.convId); GameInfoMessage msg2 = _lastIncomingEnvelope1.message as GameInfoMessage; Assert.IsNotNull(msg2); Assert.IsNotNull(registryData.GetAvailableGameManager()); Assert.IsNull(testAppWorker.commFacility.convDictionary.GetConv(msg1.convId)); //-------------STOPPING------------// testAppWorker.StopTest(); comm1.Stop(); }
public void ValidateInput(string username, string password) { if (!RegistryData.GetUsernames().Contains(username)) { throw new InvalidUsernameException(GlobalMessages.NonExistingUser); } string hashedPassword = RegistryData.GetUserPassword(username); string currentPasswordHash = HashUtilities.HashPassword(password); if (hashedPassword != currentPasswordHash) { throw new InvalidPasswordLenghtException(GlobalMessages.IncorectPassword); } }
public void GetData() { _registryData = RegistryManager.GetData(); cbSiteSlug.EditValue = _registryData.DefaultSiteSlug; cbSiteSlug_EditValueChanged(null, null); cbSiteSlug.Properties.DataSource = _registryData.List.FindAll(x => x.Deleted == false); cbSiteSlug.Properties.DisplayMember = "SiteSlug"; cbSiteSlug.Properties.ValueMember = "Code"; if (cbSiteSlug.Properties.Columns.Count == 0) { cbSiteSlug.Properties.Columns.Add(new LookUpColumnInfo("Code", 0, "")); cbSiteSlug.Properties.Columns.Add(new LookUpColumnInfo("SiteSlug", 50, "SiteSlug")); } }
public override void FixtureSetup() { CheckDisposed(); base.FixtureSetup(); Unpacker.UnPackParatextTestProjects(); m_regData = Unpacker.PrepareRegistryForPTData(); // TeApp derives from FwApp m_testTeApp = new TestTeApp(new string[] { "-c", m_sSvrName, // ComputerName (aka the SQL server) "-proj", m_ProjName, // ProjectName "-db", m_sDbName }); // DatabaseName m_fMainWindowOpened = m_testTeApp.OpenMainWindow(); }
private void changeButton_Click(object sender, EventArgs e) { this.oldPassLabel.Visible = false; this.newPassLabel.Visible = false; string currentPassword = this.oldPasswordTextBox.Text; string currentPasswordHash = HashUtilities.HashPassword(currentPassword); string hashedPassword = RegistryData.GetUserPassword(this.User.Username); if (currentPasswordHash == hashedPassword) { try { ValidateNewPassword(this.newPassTextBox.Text, this.confirmNewPassTextBox.Text); string oldEncryptedData = RegistryData.GetUserData(this.User.Username); string oldDecryptedData = CryptographicUtilities.Decrypt(oldEncryptedData, this.User.Key); string newPassword = HashUtilities.HashPassword(this.newPassTextBox.Text); byte[] newKey = HashUtilities.HashKey(this.newPassTextBox.Text); string newData = CryptographicUtilities.Encrypt(oldDecryptedData, newKey); RegistryData.SetNewPassword(this.User.Username, newPassword); RegistryData.SetUserData(this.User.Username, newData); this.User.SetNewKey(newKey); MetroMessageBox.Show(this.MainForm, string.Empty, GlobalMessages.PasswordChanged , MessageBoxButtons.OK, MessageBoxIcon.Information, 80); this.Swipe(false); } catch (InvalidPasswordLenghtException ipe) { this.newPassLabel.Text = ipe.Message; this.newPassLabel.Visible = true; } catch (PasswordMismatchException pme) { this.newPassLabel.Text = pme.Message; this.newPassLabel.Visible = true; } } else { this.oldPassLabel.Text = GlobalMessages.InvalidPassword; this.oldPassLabel.Visible = true; } }
public IHttpActionResult Query(JournalRequest request) { if (request == null || request.Id == null) { logger.Debug($"Bad Request in Journal: {request}, ID: {request?.Id}"); return(Content(HttpStatusCode.BadRequest, ErrorList.e400)); } var response = RegistryData.byId(request.Id); if (response == null) { logger.Debug($"No Journal Found For The Id: {request?.Id}"); return(Content(HttpStatusCode.NotFound, ErrorList.e500)); } return(Ok(response.Operations)); }
private void backupButton_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(this.backupTextBox.Text)) { string[] data = RegistryData.GetDataForBackup(this.User.Username); string path = this.backupTextBox.Text + "\\" + string.Format(Constants.BackupFileName, this.User.Username); File.WriteAllLines(path, data); MetroMessageBox.Show(this , string.Empty , GlobalMessages.BackupComplete , MessageBoxButtons.OK , MessageBoxIcon.Information , 80); this.Swipe(false); } }
public static Registry Convert(RegistryData item) { try { if (item == null) { throw new Exception("Parâmetro vazio"); } var grid = GridDAO.Find(item.IdGrid); if (grid == null) { throw new Exception("Grade não encontrado"); } var student = StudentDAO.Find(item.IdStudent); if (student == null) { throw new Exception("Aluno não encontrado"); } return(new Registry { IdRegistry = item.IdRegistry, Grid = grid, Student = student, Alternative = item.Alternative, RegisterDate = item.RegisterDate, RegisterBy = item.RegisterBy, DeleteDate = item.DeleteDate, DeleteBy = item.DeleteBy }); } catch (Exception e) { string notes = LogHelper.Notes(item, e.Message); Log.Add(Log.TYPE_ERROR, "SistemaMatricula.DAO.RegistryDAO.Convert", notes); } return(null); }
private void deleteButton_Click(object sender, EventArgs e) { this.passwordLabel.Visible = false; if (!string.IsNullOrWhiteSpace(this.passwordTextBox.Text)) { string hashedPass = HashUtilities.HashPassword(this.passwordTextBox.Text); if (hashedPass == RegistryData.GetUserPassword(this.User.Username)) { RegistryData.DeleteAccout(this.User.Username); MetroMessageBox.Show(this.MainForm, string.Empty, GlobalMessages.AccountDeleted , MessageBoxButtons.OK, MessageBoxIcon.Information, 80); this.Swipe(false); this.userPanel.Logout(); } else { this.passwordLabel.Visible = true; } } }
public void Test_LoadECObjectForSO() { CheckDisposed(); RegistryData rootDir = null; try { rootDir = new RegistryData(Registry.LocalMachine, @"SOFTWARE\SIL\FieldWorks", "rootDir", Unpacker.RootDir); } finally { if (rootDir != null) { rootDir.RestoreRegistryData(); } } }