public void add(string stock, string prce, string quant, string dte)
        {
            if (dte != "")
            {
                DateTime process = DateTime.Parse(dte);

                dte = process.ToString("yyyy-MM-dd HH:mm:ss");
            }
            else
            {
                dte = MYSQLEngine.timenow();
            }

            CSVValue[] newvalues = new CSVValue[this.values.Length];

            short ii = 0;

            foreach (CSVValue old in this.values)
            {
                newvalues[ii] = new CSVValue(old.stock, old.current_value, old.quantity, old.write_date);
                ii++;
            }

            this.values = new CSVValue[this.values.Length + 1];

            ii = 0;

            foreach (CSVValue newv in newvalues)
            {
                this.values[ii] = new CSVValue(newv.stock, newv.current_value, newv.quantity, newv.write_date);
                ii++;
            }

            this.values[ii] = new CSVValue(stock, prce, quant, dte);
        }
Exemple #2
0
        public void ComputeBuyList()
        {
            if (this.isstillgood == true)
            {
                this.buylist.SetBuyList(MYSQLEngine.ReadBuyList(this.eq));
            }

            foreach (Buy b in this.buylist.buys)
            {
                Console.WriteLine(b.ToString());
            }
        }
Exemple #3
0
        public bool BuildReadValues()
        {
            if (this.has_csv_file == true)
            {
                try
                {
                    this.readvalues = new CSVValues(this.csv_filepath);

                    File.Delete(this.csv_filepath);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    return(false);
                }
            }
            else
            {
                Console.WriteLine("\n\nNo CSV file was found, building portfolio values from database.");
                this.readvalues = MYSQLEngine.ReadSource(this.eq);
            }

            return(true);
        }
Exemple #4
0
        private File_Status_Is ProcessYCAValue()  //   BUY LIST IS INITIALLY CONSTRUCTED HERE, BUT NOT POPULATED
        {
            short ii = 0;

            if (this.has_yca_file == true)
            {
                foreach (string line in File.ReadLines(this.yearly_contribution_filepath))
                {
                    if (ii == 0)
                    {
                        string instr = CSVValues.parse_decimal_str(line), parsedstr = "";

                        int sii = (instr.Length - 2);

                        foreach (char c in instr)
                        {
                            if (sii > 0)
                            {
                                parsedstr = parsedstr + c;
                            }

                            sii--;
                        }

                        try
                        {
                            int ycaint = Int32.Parse(parsedstr);

                            this.buylist = new BuyList(ycaint);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Failed to construct buylist from file " + this.yearly_contribution_filepath + " exception message: " + ex.Message);
                            return(File_Status_Is.File_Found_but_Parse_Failed);
                        }

                        try
                        {
                            MYSQLEngine.WriteYCA(this.eq, parsedstr);

                            return(File_Status_Is.File_Found_and_Parsed);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);

                            return(File_Status_Is.Failed);
                        }
                    }

                    ii++;
                }

                return(File_Status_Is.Failed);
            }
            else
            {
                this.buylist = new BuyList(Int32.Parse(MYSQLEngine.ReadYCA(this.eq)));

                return(File_Status_Is.No_File_Found);
            }
        }
Exemple #5
0
        static void Main(string[] args)
        {
            string dir;

            if (args.Length == 0)
            {
                Console.WriteLine("No arguments were supplied.\n");
                dir = ImprovedGetAssembly();
            }
            else
            {
                dir = args[0];
            }

            if (valdir(dir) == false)
            {
                Console.WriteLine("First argument needs to be a valid directory.");
                return;
            }
            else
            {
                EngineQuery eq = new EngineQuery();
                eq.server = "167.71.172.36";
                eq.user   = "******";

                bool goodpw = false;

                int pwii = 0;

                while (goodpw == false)
                {
                    if (pwii != 0)
                    {
                        if (pwii > 5 || eq.password.Equals("x"))
                        {
                            string close = "C";

                            if (eq.password != "x")
                            {
                                close = "Five or more bad passwords, c";
                            }

                            Console.WriteLine("\n" + close + "losing now.");
                            Console.ReadLine();
                            return;
                        }

                        Console.WriteLine("\nBad Password. Enter 'x' to exit.");
                    }

                    eq.password = GetPassword();

                    goodpw = MYSQLEngine.CheckPW(eq);

                    pwii++;
                }

                Parser _parser = new Parser(dir, eq);

                _parser.Initialize();

                if (_parser.isstillgood == true)
                {
                    MYSQLEngine.WriteManifest(_parser);

                    MYSQLEngine.WriteSource(_parser);

                    Console.WriteLine("");

                    for (int ii = 0; ii < 3; ii++)
                    {
                        Thread.Sleep(1000);

                        Console.WriteLine("" + (ii + 1) + "...");
                    }

                    Console.WriteLine("");

                    _parser.ComputeBuyList();
                }

                Console.ReadLine();
            }
        }