コード例 #1
0
        //******************************************************************************************************
        public static void ReadConfigData( )
        // Here we read our data from disk and then
        // update the variables in our application.
        //******************************************************************************************************
        {
            string fpath = "CustomerConfig.dat";

            string[] datain;
            try
            {
                if (File.Exists(fpath))
                {
                    datain = System.IO.File.ReadAllLines(fpath);
                    if (datain.Count( ) > 0)
                    {
                        if (datain[0].Length > 0 && datain[1].Length > 0 && datain[2].Length > 0 && datain[3].Length > 0 && datain[4].Length > 0 && datain[5].Length > 0)
                        {
                            //now reset the variables in the class so we are READY TO START PROCESSING
                            Customer.SetCustomerNumberSeed(Convert.ToInt32(datain[0]));
                            BankAccount.SetBankAccountNumberSeed(Convert.ToInt32(datain[1]));
                            BankAccount.SetTotalBanks(Convert.ToInt16(datain[2]));
                            Logger.SetLastDate(datain[3]);
                        }
                    }
                    else
                    {
                        RegenerateConfigData( );
                    }                                                            // this return a stirng[] containing CORRECT config data
                }
                else
                {
                    RegenerateConfigData( );
                }
            }
            catch
            { throw new Exception("Failed to recreate config data file, line 50 in saveconfig.cs"); }
        }