//Backgroundworker - Verify User and Load PB private void backgroundWorkerOpenSerialPort_DoWork(object sender, DoWorkEventArgs e) { System.Threading.Thread.Sleep(500); Structs.VerifyRemoteUser VerifyUser = new Structs.VerifyRemoteUser(); //object[] Result = new object[3]; if (GlobalVariables.WriteToRemoteServer == true) { try { string VerifyUserResult; SelectedUser.Weight = 70; SelectedUser.Password = tbCode.Text; VerifyUser.IsSuccess = DataClasses.AccessorUsers.VerifyRemoteUser(SelectedUser, out VerifyUserResult); VerifyUser.ResultString = VerifyUserResult; if (VerifyUser.IsSuccess == true) { GlobalVariables.CustomProgramPB = DataClasses.AccessorCustomProgram.GetCustomProgramRemotePB(SelectedUser.id); GlobalVariables.FTP_PB = DataClasses.AccessorMuscleFunctionTests.GetFTP_RemotePB(SelectedUser.id); GlobalVariables.VO2MaxTestConcForwPB = DataClasses.AccessorMuscleFunctionTests.GetVO2MaxConcForwRemotePB(SelectedUser.id); GlobalVariables.VO2MaxProgram1PB = DataClasses.AccessorHighPerformancePrograms.GetVO2MaxProgram1PB(0); GlobalVariables.VO2MaxProgram2PB = DataClasses.AccessorHighPerformancePrograms.GetVO2MaxProgram2PB(0); GlobalVariables.VO2MaxProgram3PB = DataClasses.AccessorHighPerformancePrograms.GetVO2MaxProgram3PB(0); GlobalVariables.VO2MaxProgram4PB = DataClasses.AccessorHighPerformancePrograms.GetVO2MaxProgram4PB(0); GlobalVariables.RehabProgramPB = DataClasses.AccessorRehabPrograms.GetRehabProgramBilateralRemotePB(SelectedUser.id); GlobalVariables.RehabProgramLeftPB = DataClasses.AccessorRehabPrograms.GetRehabProgramLeftPB(0); GlobalVariables.RehabProgramRightPB = DataClasses.AccessorRehabPrograms.GetRehabProgramRightPB(0); GlobalVariables.CPMProgramPB = DataClasses.AccessorRehabPrograms.GetCPMProgramPB(0); GlobalVariables.PropriocenptionProgramPB = DataClasses.AccessorProprioceptionPrograms.GetProprioceptionProgramPB(0); GlobalVariables.StaticStrengthPB = DataClasses.AccessorMuscleFunctionTests.GetStaticStrengthRemotePB(SelectedUser.id); GlobalVariables.DynamicStrengthTestPB = DataClasses.AccessorMuscleFunctionTests.GetDynamicStrengthRemotePB(SelectedUser.id); GlobalVariables.RssString = RSS.RssManager.GetRssFeed(); } } catch (Exception Ex) { MessageBox.Show(Ex.Message); VerifyUser.IsSuccess = false; } } else { VerifyUser.IsSuccess = VerifyLocalUser(); VerifyUser.ResultString = ""; if (VerifyUser.IsSuccess == true) { GlobalVariables.CustomProgramPB = DataClasses.AccessorCustomProgram.GetCustomProgramLocalPB(Convert.ToInt32(GlobalVariables.LoggedInUser.id)); GlobalVariables.FTP_PB = DataClasses.AccessorMuscleFunctionTests.GetFTP_PB(Convert.ToInt32(GlobalVariables.LoggedInUser.id)); GlobalVariables.VO2MaxTestConcForwPB = DataClasses.AccessorMuscleFunctionTests.GetVO2MaxConcForwPB(Convert.ToInt32(GlobalVariables.LoggedInUser.id)); GlobalVariables.VO2MaxProgram1PB = DataClasses.AccessorHighPerformancePrograms.GetVO2MaxProgram1PB(Convert.ToInt32(GlobalVariables.LoggedInUser.id)); GlobalVariables.VO2MaxProgram2PB = DataClasses.AccessorHighPerformancePrograms.GetVO2MaxProgram2PB(Convert.ToInt32(GlobalVariables.LoggedInUser.id)); GlobalVariables.VO2MaxProgram3PB = DataClasses.AccessorHighPerformancePrograms.GetVO2MaxProgram3PB(Convert.ToInt32(GlobalVariables.LoggedInUser.id)); GlobalVariables.VO2MaxProgram4PB = DataClasses.AccessorHighPerformancePrograms.GetVO2MaxProgram4PB(Convert.ToInt32(GlobalVariables.LoggedInUser.id)); GlobalVariables.RehabProgramPB = DataClasses.AccessorRehabPrograms.GetRehabProgramBilateralPB(Convert.ToInt32(GlobalVariables.LoggedInUser.id)); GlobalVariables.RehabProgramLeftPB = DataClasses.AccessorRehabPrograms.GetRehabProgramLeftPB(Convert.ToInt32(GlobalVariables.LoggedInUser.id)); GlobalVariables.RehabProgramRightPB = DataClasses.AccessorRehabPrograms.GetRehabProgramRightPB(Convert.ToInt32(GlobalVariables.LoggedInUser.id)); GlobalVariables.CPMProgramPB = DataClasses.AccessorRehabPrograms.GetCPMProgramPB(Convert.ToInt32(GlobalVariables.LoggedInUser.id)); GlobalVariables.PropriocenptionProgramPB = DataClasses.AccessorProprioceptionPrograms.GetProprioceptionProgramPB(Convert.ToInt32(GlobalVariables.LoggedInUser.id)); GlobalVariables.StaticStrengthPB = DataClasses.AccessorMuscleFunctionTests.GetStaticStrengthPB(Convert.ToInt32(GlobalVariables.LoggedInUser.id)); GlobalVariables.DynamicStrengthTestPB = DataClasses.AccessorMuscleFunctionTests.GetDynamicStrengthPB(Convert.ToInt32(GlobalVariables.LoggedInUser.id)); } } if (VerifyUser.IsSuccess == true) { #if TEST Result[2] = true; #else ThreadOpenSerialPort threadOpenSerialPort = new ThreadOpenSerialPort(GlobalVariables.leftSerialPort, "UserLoadProfile"); VerifyUser.IsSerialPortOpenSuccess = threadOpenSerialPort.OpenSerialPort(); #endif } else VerifyUser.IsSerialPortOpenSuccess = false; e.Result = VerifyUser; if (backgroundWorkerOpenSerialPort.CancellationPending == true) { e.Cancel = true; if (GlobalVariables.leftSerialPort.IsOpen == true) { SerialPortFunctions.TryCloseSerialPort(GlobalVariables.leftSerialPort, ""); } GlobalFunctions.UserLogOff(); } }
private void backgroundWorkerOpenSerialPort_DoWork(object sender, DoWorkEventArgs e) { GlobalVariables.WriteToRemoteServer = false; Structs.VerifyRemoteUser VerifyUser = new Structs.VerifyRemoteUser(); GlobalVariables.LoggedInUser = new DataClasses.UserProfile(); GlobalVariables.LoggedInUser.Weight = 70; DataClasses.AccessorUsers.SetToZeroPB(); //Set all PB Values to Zero #if TEST Result[2] = true; #else if (SerialPortFunctions.TryOpenSerialPort(GlobalVariables.leftSerialPort, "Quick Start - Left Port") == true) { if (SerialPortFunctions.TryOpenSerialPort(GlobalVariables.rightSerialPort, "Quick Start - Right Port") == true) { VerifyUser.IsSerialPortOpenSuccess = true; } else VerifyUser.IsSerialPortOpenSuccess = false; } else { VerifyUser.IsSerialPortOpenSuccess = false; } //ThreadOpenSerialPort threadOpenSerialPort = new ThreadOpenSerialPort(GlobalVariables.leftSerialPort, "UserLoadProfile"); //VerifyUser.IsSerialPortOpenSuccess = threadOpenSerialPort.OpenSerialPort(); #endif e.Result = VerifyUser; if (backgroundWorkerOpenSerialPort.CancellationPending == true) { e.Cancel = true; if (GlobalVariables.leftSerialPort.IsOpen == true) { SerialPortFunctions.TryCloseSerialPort(GlobalVariables.leftSerialPort, ""); } if (GlobalVariables.rightSerialPort.IsOpen == true) { SerialPortFunctions.TryCloseSerialPort(GlobalVariables.rightSerialPort, ""); } GlobalFunctions.UserLogOff(); } }