コード例 #1
0
        public static bool TestUsernameAndPassword(string Username, string Password)
        {
            bool returnValue = false;

            if (Username == string.Empty && Password == string.Empty)
            {
                Console.Write("Please enter your username: "******"username", "salt");
                Console.Write("Please enter your password: "******"password", "salt");
                Properties.Settings.Default.Username = Username;
                Properties.Settings.Default.Password = Password;
                Properties.Settings.Default.Save();
            }
            driver = RiverLinkLogic.GetNewDriver();
            RiverLinkLogic worker = new RiverLinkLogic("https://riverlink.com/", 2000, 1000, driver);

            worker.StatusChanged += Worker_StatusChanged;

            if (worker.Login(RijndaelSimple.Decrypt <RijndaelManaged>(Username, "username", "salt"), RijndaelSimple.Decrypt <RijndaelManaged>(Password, "password", "salt")))
            {
                Console.WriteLine("Operation Successful");
                test = true;
                driver.Close();
            }
            else
            {
                Console.WriteLine("Operation failed");
                test = false;
                driver.Close();
            }
            return(returnValue);
        }
コード例 #2
0
        private void LoadVehiclePaymentGrid()
        {
            List <Transaction> Payments = RiverLinkLogic.GetPayments();

            bsPayment.DataSource = Payments;
            List <Vehicle> Vehicles = RiverLinkLogic.GetVehicles();

            bsVehicle.DataSource = Vehicles;
        }
コード例 #3
0
        private void LoadGridData()
        {
            List <Transaction> Transactions = RiverLinkLogic.GetTransactions();

            bsTransaction.DataSource = Transactions;
            List <BankTransaction> bankTransactions = RiverLinkLogic.GetBankTransactions();

            bsBankTransactions.DataSource = bankTransactions;
        }
コード例 #4
0
        private void btnBankTrans_Click(object sender, EventArgs e)
        {
            frmBank bank = new frmBank();

            bank.ShowDialog();
            bsBankTransactions.DataSource = null;
            List <BankTransaction> bankTransactions = RiverLinkLogic.GetBankTransactions();

            bsBankTransactions.DataSource = bankTransactions;
        }
コード例 #5
0
 private static void closeBrowser()
 {
     if (driver != null)
     {
         driver.Close();
     }
     foreach (var process in RiverLinkLogic.DriverProcessIds)
     {
         RiverLinkLogic.KillById(process);
     }
 }
コード例 #6
0
        private void dgVehicles_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            List <Vehicle> Vehicles = RiverLinkLogic.GetVehicles();

            if (sortAscending)
            {
                dgVehicles.DataSource = Vehicles.OrderBy(dgVehicles.Columns[e.ColumnIndex].DataPropertyName).ToList();
            }
            else
            {
                dgVehicles.DataSource = Vehicles.OrderBy(dgVehicles.Columns[e.ColumnIndex].DataPropertyName).Reverse().ToList();
            }
            sortAscending = !sortAscending;
        }
コード例 #7
0
        private void dgPayments_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            List <Transaction> Payments = RiverLinkLogic.GetPayments();

            if (sortAscending)
            {
                dgPayments.DataSource = Payments.OrderBy(dgPayments.Columns[e.ColumnIndex].DataPropertyName).ToList();
            }
            else
            {
                dgPayments.DataSource = Payments.OrderBy(dgPayments.Columns[e.ColumnIndex].DataPropertyName).Reverse().ToList();
            }
            sortAscending = !sortAscending;
        }
コード例 #8
0
        private void SetDataSources(string Month, string Year, string TransponderNumber)
        {
            shouldFireYear              = false;
            shouldFireMonth             = false;
            shouldFireTransponderNumber = false;
            //Clears all existing data sources
            bsYear.DataSource  = null;
            bsMonth.DataSource = null;

            RiverLinkLogic.year              = ParseSelectedValue(Year);
            RiverLinkLogic.month             = ParseSelectedValue(Month);
            RiverLinkLogic.transponderNumber = ParseSelectedValue(TransponderNumber);

            //Populate Year Data source
            List <string> Years = RiverLinkLogic.GetYears();

            bsYear.DataSource = Years;

            //Reset the selected Year inside combobox
            cmbYear.SelectedIndex = Years.IndexOf(Year);

            //Populate Month data source
            List <string> Months = RiverLinkLogic.GetMonths();

            bsMonth.DataSource = Months;

            //Reset the selected Month inside combobox
            cmbMonth.SelectedIndex = Months.IndexOf(Month);

            //Populate Transpondernumber data source
            List <string> TransponderNumbers = RiverLinkLogic.GetTransponderNumbers();

            bsTransponderNumber.DataSource = TransponderNumbers;

            //Reset the selected Transponder inside combobox
            cmbTransponder.SelectedIndex = TransponderNumbers.IndexOf(TransponderNumber);

            //Reload grid data based on selected options
            LoadGridData();
            shouldFireFormLoad          = true;
            shouldFireYear              = true;
            shouldFireMonth             = true;
            shouldFireTransponderNumber = true;
        }
コード例 #9
0
        private static void HandleCommandLine(ProgramOptions options)
        {
            if (options.Username != null)
            {
                Automate.username = options.Username;
            }

            if (options.Password != null)
            {
                Automate.password = options.Password;
            }

            if (options.Headless != null)
            {
                RiverLinkLogic.runHeadless = true;
            }

            if (options.Operation == "run")
            {
                driver = RiverLinkLogic.GetNewDriver();
                runProgram();
            }
        }
コード例 #10
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            driver = RiverLinkLogic.GetNewDriver();
            RiverLinkLogic Logic = new RiverLinkLogic("https://riverlink.com/", 2000, 1000, driver);

            Logic.PrimaryStatusChanged   += Logic_PrimaryStatusChanged;
            Logic.SecondaryStatusChanged += Logic_SecondaryStatusChanged;
            if (onProgressEvent != null)
            {
                onProgressEvent(this, new ProgressEventArgs($"Working on item 1", $"Working on sub item 1"));
                Logic.Login(decryptedUsername, decryptedPassword);
                backgroundWorker1.ReportProgress(25);

                onProgressEvent(this, new ProgressEventArgs($"Working on item 2", $"Working on sub item 1"));
                Logic.GetData();
                backgroundWorker1.ReportProgress(75);

                onProgressEvent(this, new ProgressEventArgs($"Working on item 3", $"Working on sub item 1"));
                Logic.InsertData();
                backgroundWorker1.ReportProgress(100);
                System.Threading.Thread.Sleep(1000);
            }
        }
コード例 #11
0
        private static void runProgram()
        {
            try
            {
                RiverLinkLogic Logic = new RiverLinkLogic("https://riverlink.com/", 2000, 1000, driver);
                Logic.PrimaryStatusChanged   += Logic_PrimaryStatusChanged;
                Logic.SecondaryStatusChanged += Logic_SecondaryStatusChanged;
                Logic.Login(Automate.username, Automate.password);
                Logic.GetData();
                Logic.InsertData();
                driver.Close();
                appExit();
            }
            catch (Exception)
            {
                closeBrowser();

                throw;
            }
            finally
            {
                closeBrowser();
            }
        }
コード例 #12
0
        public static void Main(string[] args)
        {
            try
            {
                int userInput = 0;
                if (args.Any())
                {
                    var cmdOptions = Parser.Default.ParseArguments <ProgramOptions>(args);
                    cmdOptions.WithParsed(
                        options => {
                        HandleCommandLine(options);
                    });
                    Console.ReadLine();
                }
                else
                {
                    do
                    {
                        userInput = DisplayMenu();
                        switch (userInput)
                        {
                        case 1:
                            TestUsernameAndPassword(string.Empty, string.Empty);
                            break;

                        case 2:
                            Console.WriteLine("Would you like to run chrome in headless mode Y/N?");
                            if (Console.ReadLine().ToLower() == "y")
                            {
                                RiverLinkLogic.runHeadless = true;
                            }
                            if (Properties.Settings.Default.Username != "" || Properties.Settings.Default.Password != "")
                            {
                                var spinner = new Spinner(10, 10);
                                spinner.Start();

                                driver = RiverLinkLogic.GetNewDriver();
                                RiverLinkLogic Logic = new RiverLinkLogic("https://riverlink.com/", 2000, 1000, driver);
                                Logic.Login(RijndaelSimple.Decrypt <RijndaelManaged>(Properties.Settings.Default.Username, "username", "salt"), RijndaelSimple.Decrypt <RijndaelManaged>(Properties.Settings.Default.Password, "password", "salt"));
                                Logic.GetData();

                                spinner.Stop();
                            }
                            else
                            {
                                Console.WriteLine("Please run option 1 to set and test your username and password first.");
                            }
                            break;

                        case 3:
                            RiverLinkLogic Insert = new RiverLinkLogic("https://riverlink.com/", 2000, 1000, driver);
                            Insert.InsertData();
                            break;

                        case 4:
                            Application.Exit();
                            break;
                        }
                    } while (userInput != 4);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"{methodName} unexpected error: {e}");
                throw new Exception($"{methodName} unexpected error: {e}");
            }
        }