/// <summary> /// If user clicks close, disconnect and set values to cache /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (tss != null) { tss.disconnect(); tss.removeSession(); tss = null; logger.Info("Logging Out"); Thread.Sleep(1500); } set.username = myUsername.Text; set.password = myPassword.Text; set.connection = myConnection.Text; set.typeofdata = myTypeOfData.Text; set.timeinterval = myTimeInterval.Text; set.outputpath = myOutputDirectory.Text; set.startdate = myStartDate.Text; set.starttime = myStartTime.Text; set.enddate = myEndDate.Text; set.endtime = myEndTime.Text; set.currency = myCurrency.Text; set.Save(); logger.Debug("Closing Application"); GC.Collect(); GC.WaitForPendingFinalizers(); Application.Exit(); }
public DataSetup(DateTime sDate, DateTime eDate, TradingSession tradingSession, bool isAl, int maxIter, long initialTicks, string typeOfData, string timeInterval, string fileFormat, string outputDirectory, string delimiter, string dateFormat, string extension, string currency) { startDate = sDate; endDate = eDate; tss = tradingSession; isAlive = isAl; maxIterations = maxIter; initialTotalTicks = initialTicks; sw = Stopwatch.StartNew(); variableChanged = true; this.typeOfData = typeOfData; this.timeInterval = timeInterval; this.fileFormat = fileFormat; this.outputDirectory = outputDirectory; this.delimiter = delimiter; this.dateFormat = dateFormat; this.extension = extension; this.currency = currency; }
public DataSetup(DateTime sDate, DateTime eDate, TradingSession tradingSession) { startDate = sDate; endDate = eDate; tss = tradingSession; variableChanged = true; }
public static void setTradingSession(TradingSession tradingSession) { tss = tradingSession; }
private void loginLogoutButton_Click(object sender, EventArgs e) { //Validate username and password if (usernameDropdownList.Text.Trim().Equals("")) { MessageBox.Show("Please enter a valid username!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else if (passwordTextbox.Text.Trim().Equals("")) { MessageBox.Show("Please enter a valid password!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } //Instantiate trading session and try to login tss = new TradingSession(); tss.login(usernameDropdownList.Text, passwordTextbox.Text, "http://www.fxcorporate.com/Hosts.jsp", accountTypeDropdownList.Text); //Log.logMessageToFile("Login","Login method called"); logger.Debug("Login method was called"); //Wait for 5000 milliseconds to make sure the application logged in Stopwatch timer = new Stopwatch(); timer.Start(); while (tss.ConnectionStatus != O2GSessionStatusCode.Connected) { Thread.Sleep(1000); if (tss.ConnectionStatus == O2GSessionStatusCode.Unknown) { logger.Error("Connection Status is unknown"); MessageBox.Show("Please check user credentials", "Error logging in"); return; } if (timer.Elapsed.TotalSeconds > 90 && tss.ConnectionStatus != O2GSessionStatusCode.Connected) { logger.Error("Login is taking longer than 20 seconds!"); MessageBox.Show("Please check user credentials", "Error logging in"); return; } } timer.Stop(); //Check if any login errors occurred, if exist return and throw error. if (tss.Error.Length != 0) { MessageBox.Show("Please check user credentials", "Error logging in"); return; } //this.Invoke((MethodInvoker)delegate () { //}); this.Hide(); fillRatesGrid(); logger.Debug("Starting HDD Basic"); HddMainFormBasic.setPassword(passwordTextbox.Text); HddMainFormBasic.setUsername(usernameDropdownList.Text); HddMainFormBasic.setAccountType(accountTypeDropdownList.Text); HddMainFormBasic.setTradingSession(tss); HddMainFormBasic.setStatusLabel("Connected"); HddMainFormBasic.setCurrencyList(temp, templist); HddMainFormBasic.setVersionLabel(mVersionLabel.Text); hddBasic = new HddMainFormBasic(); hddBasic.Show(); if (saveLoginButton.Checked) { set.username = usernameDropdownList.Text; set.connection = accountTypeDropdownList.Text; set.saveMe = saveLoginButton.Checked; set.Save(); } //Save the user information into SQL lite fillTable(usernameDropdownList.Text.Trim(), accountTypeDropdownList.SelectedItem.ToString()); }