private void LoginButton_Click(object sender, EventArgs e) { try { LoggingIn.Invoke(); showMenuFormAndUpdateMainForm(); } catch (Exception exception) { MessageBox.Show("Couldn't login please try again", exception.Message); } }
public static void Add(IQueueTask item) { EnsureObject obj = new EnsureObject(); obj.ModelType = item.GetType().FullName; obj.Json = Lib.Helper.JsonHelper.Serialize(item); GlobalDb.Ensurance.AddOrUpdate(obj); // add log string log = obj.ModelType + ":\r\n"; log += obj.Json; LoggingIn.Write(log); }
public async void LoggingIn() { StorageFolder MainFolder = ApplicationData.Current.LocalFolder; StorageFile OutputNamesfile = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"OutputNames.xml"); // Path is file path StorageFile Settingsfile = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"SettingsData.xml"); // Path is file path StorageFile profileFile = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"profile.jpg"); // Path is file path if (await FileExistAsync(OutputNamesfile.Name) == false) { await OutputNamesfile.CopyAsync(MainFolder, OutputNamesfile.Name, NameCollisionOption.GenerateUniqueName); // Weather theWeather = new Weather("Beirut", true); } if (await FileExistAsync(Settingsfile.Name) == false) { await Settingsfile.CopyAsync(MainFolder, Settingsfile.Name, NameCollisionOption.GenerateUniqueName); } if (await FileExistAsync(profileFile.Name) == false) { await profileFile.CopyAsync(MainFolder, profileFile.Name, NameCollisionOption.GenerateUniqueName); } LoggingIn theLogin; theLogin = new LoggingIn("test", "theTest."); theLogin.ConnectAndGetLatest(); for (int i = 0; i < 15; i++) { await Task.Delay(1000); if (theLogin.isConnected) { Assert.IsTrue(theLogin.isConnected); break; } } }
private void HandleNewCons() { string[] Log = new string[2]; while (Running) { SockEventarg = new SocketAsyncEventArgs(); LogBool = false; Socket LoggingIn; listeningSocket.AcceptAsync(SockEventarg); SockEventarg.Completed += SockEventarg_Completed; while (Running && !LogBool) { } if (!Running) { break; } //Login LoggingIn = SockEventarg.AcceptSocket; string[] Recieved = new string[4]; Recieved = Recieve(LoggingIn).Split('\a'); if (Recieved[0] == "LOG") { if (Recieved[1] == "New") { string[] UAP = new string[3]; UAP = Recieved[2].Split(';'); Log = Login(false, UAP[0], Decrypt(UAP[1]), LoggingIn, UAP[2], UAP[3]).Split(';'); if (Log[0] == "True") { //Logged In Clients[ClientCount, 0] = UAP[0]; //Username Clients[ClientCount, 1] = UAP[2]; //DisplayName Clients[ClientCount, 2] = LoggingIn.RemoteEndPoint.ToString(); // IP if (FreeClientSockInd.Count == 0) { Clients[ClientCount, 3] = ClientCount.ToString(); } //Index in Socket Array else { Clients[ClientCount, 3] = FreeClientSockInd.Pop(); } ClientSocks[int.Parse(Clients[ClientCount, 3])] = LoggingIn; Logins[Accounts, 0] = UAP[0]; Logins[Accounts, 1] = Decrypt(UAP[1]); Logins[Accounts, 2] = true.ToString(); Logins[Accounts, 3] = UAP[2]; Logins[Accounts, 4] = UAP[3]; ClientCount++; Accounts++; //Expand Client Array string[,] ClientsBU = Clients; Clients = new string[ClientCount + 1, 4]; for (int c = 0; c < ClientCount; c++) { for (int k = 0; k < 4; k++) { Clients[c, k] = ClientsBU[c, k]; } } //Expand Login Array string[,] LoginsBU = Logins; Logins = new string[Accounts + 1, 5]; for (int c = 0; c < Accounts; c++) { for (int k = 0; k < 5; k++) { Logins[c, k] = LoginsBU[c, k]; } } Array.Resize(ref ClientSocks, ClientCount + 1 + FreeClientSockInd.Count); Array.Resize(ref HeldMSGs, Accounts); HeldMSGs[HeldMSGs.Length - 1] = new StackObject(); UpdateLoginsFile(); ClientListUpdate(); lbReqUpdate = true; } else { LoggingIn.Close(); } } else if (Recieved[1] == "Old") { string[] UAP = new string[2]; UAP = Recieved[2].Split(';'); Log = Login(true, UAP[0], Decrypt(UAP[1]), LoggingIn).Split(';'); if (Log[0] == "True") { //Logged In Clients[ClientCount, 0] = UAP[0]; //Username Clients[ClientCount, 1] = Logins[int.Parse(Log[1]), 3]; //DisplayName Clients[ClientCount, 2] = LoggingIn.RemoteEndPoint.ToString(); // IP if (FreeClientSockInd.Count == 0) { Clients[ClientCount, 3] = ClientCount.ToString(); } //Index in Socket Array else { Clients[ClientCount, 3] = FreeClientSockInd.Pop(); } ClientSocks[int.Parse(Clients[ClientCount, 3])] = LoggingIn; Logins[int.Parse(Log[1]), 2] = true.ToString(); ClientCount++; //Expand Client Array string[,] ClientsBU = Clients; Clients = new string[ClientCount + 1, 4]; for (int c = 0; c < ClientCount; c++) { for (int k = 0; k < 4; k++) { Clients[c, k] = ClientsBU[c, k]; } } Array.Resize(ref ClientSocks, ClientCount + 1 + FreeClientSockInd.Count); ClientListUpdate(); lbReqUpdate = true; while (HeldMSGs[int.Parse(Log[1])].Count > 0) { string[] Split = HeldMSGs[int.Parse(Log[1])].Pop().Split('\v'); Send(Split[0], Split[1], Split[2], ClientSocks[ClientCount - 1]); } } else { LoggingIn.Close(); } } } } SockEventarg.Dispose(); }
protected virtual void OnLoggingIn() => LoggingIn?.Invoke();
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { string[] Log = new string[2]; if (Running) { Socket LoggingIn; LoggingIn = listeningSocket.Accept(); Thread NewThread = new Thread(new ParameterizedThreadStart(HandleClient)); //Login string[] Recieved = new string[4]; Recieved = Recieve(LoggingIn).Split('\n'); if (Recieved[0] == "LOG") { if (Recieved[1] == "New") { string[] UAP = new string[3]; UAP = Recieved[2].Split(';'); Log = Login(false, UAP[0], Decrypt(UAP[1]), LoggingIn, UAP[2]).Split(';'); if (Log[0] == "True") { //Logged In Clients[ClientCount, 0] = UAP[0]; //Username Clients[ClientCount, 1] = UAP[2]; //DisplayName Clients[ClientCount, 2] = LoggingIn.RemoteEndPoint.ToString(); // IP Clients[ClientCount, 3] = ClientCount.ToString(); //Index in Socket Array ClientSocks[ClientCount] = LoggingIn; Logins[Accounts, 0] = UAP[0]; Logins[Accounts, 1] = Decrypt(UAP[1]); Logins[Accounts, 2] = true.ToString(); Logins[Accounts, 3] = UAP[2]; ClientCount++; Accounts++; //Expand Client Array string[,] ClientsBU = Clients; Clients = new string[ClientCount + 1, 4]; for (int c = 0; c < ClientCount; c++) { for (int k = 0; k < 4; k++) { Clients[c, k] = ClientsBU[c, k]; } } //Expand Login Array string[,] LoginsBU = Logins; Logins = new string[Accounts + 1, 4]; for (int c = 0; c < Accounts; c++) { for (int k = 0; k < 4; k++) { Logins[c, k] = LoginsBU[c, k]; } } Array.Resize(ref ClientSocks, ClientCount + 1); UpdateLoginsFile(); lbReqUpdate = true; NewThread.Start(ClientCount - 1); } else { LoggingIn.Close(); } } else if (Recieved[1] == "Old") { string[] UAP = new string[2]; UAP = Recieved[2].Split(';'); Log = Login(true, UAP[0], Decrypt(UAP[1]), LoggingIn).Split(';'); if (Log[0] == "True") { //Logged In Clients[ClientCount, 0] = UAP[0]; //Username Clients[ClientCount, 1] = Logins[int.Parse(Log[1]), 3]; //DisplayName Clients[ClientCount, 2] = LoggingIn.RemoteEndPoint.ToString(); // IP Clients[ClientCount, 3] = ClientCount.ToString(); //Index in Socket Array ClientSocks[ClientCount] = LoggingIn; Logins[int.Parse(Log[1]), 2] = true.ToString(); ClientCount++; //Expand Client Array string[,] ClientsBU = Clients; Clients = new string[ClientCount + 2, 4]; for (int c = 0; c < ClientCount; c++) { for (int k = 0; k < 4; k++) { Clients[c, k] = ClientsBU[c, k]; } } Array.Resize(ref ClientSocks, ClientCount + 1); lbReqUpdate = true; NewThread.Start(ClientCount - 1); } else { LoggingIn.Close(); } } } } }
public void GoToLogginIn(AuthorizationStructure author) { logIN = new LoggingIn(this, author); _NavigationFrame.Navigate(logIN); }
private async void AppBarButton_Click(object sender, RoutedEventArgs e) { var vault = new Windows.Security.Credentials.PasswordVault(); LogInButton.IsEnabled = false; TextBoxUsername.IsEnabled = false; PassBoxLoginPass.IsEnabled = false; CheckBoxRememberMe.IsEnabled = false; TSMainHub.IsEnabled = false; StatusText.Text = ""; theLogin = new LoggingIn(TextBoxUsername.Text, PassBoxLoginPass.Password); theLogin.ConnectAndGetLatest(); if (CheckBoxRememberMe.IsChecked == true) { SaveCredential(TextBoxUsername.Text, PassBoxLoginPass.Password); } else if (CheckBoxRememberMe.IsChecked == false) { RemoveCredential(TextBoxUsername.Text); } for (int i = 0; i < 30; i++) { await Task.Delay(1000); if (theLogin.isConnected) { break; } } if (theLogin.isConnected) { await Task.Delay(2000); (App.Current as App).isFirstLogin = false; (App.Current as App).Email = TextBoxUsername.Text; (App.Current as App).Password = PassBoxLoginPass.Password; if (TSMainHub.IsOn) { this.Frame.Navigate(typeof(AutomatedPage)); } else if (!TSMainHub.IsOn) { this.Frame.Navigate(typeof(MainPage)); } } else { LogInButton.IsEnabled = true; TextBoxUsername.IsEnabled = true; PassBoxLoginPass.IsEnabled = true; CheckBoxRememberMe.IsEnabled = true; TSMainHub.IsEnabled = true; StatusText.Text = "Something Went Wrong and We Couldn't\n Log You In"; } }