示例#1
0
        private void GenerateBasedOnYear()
        {
            int fa_startingIndex= 30;
            string fa_str = System.Configuration.ConfigurationSettings.AppSettings["FreeAgentStartingIndex"];
            if( fa_str != null )
            {
                try
                {
                    fa_startingIndex = Int32.Parse(fa_str);
                }
                catch{}
            }

            int year = 0;
            string s_year = mYearTextBox.Text;
            string test = MainClass.LeagueFolder+Path.DirectorySeparatorChar+ s_year;
            if( Directory.Exists(test) )
            {
                year = Int32.Parse( s_year);
                Season s = new Season(year);

                string season = s.GenerateSeason();
                string fileName = "tmpSeasonGen.csv";
                if( MainClass.GenerateFreeAgents )
                {
                    test = MainClass.LeagueFolder+Path.DirectorySeparatorChar+ (year-1);
                    if( Directory.Exists(test) )
                    {
                        string nextSeason = "";
                        if( Directory.Exists( MainClass.LeagueFolder+Path.DirectorySeparatorChar+ (year+1)))
                        {
                            Season ns = new Season(year+1);
                            nextSeason = ns.GenerateSeason();
                        }
                        Season previousSeason = new Season(year -1);
                        previousSeason.PlayerIndexToStartAt = fa_startingIndex;
                        string previousPlayers = previousSeason.GenerateSeason();
                        string freeAgents = FreeAgentHelper.GetFreeAgents(season, previousPlayers, nextSeason);
                        season += freeAgents;
                    }
                    else
                    {
                        season += "\r\n# Free Agents not available for this year";
                    }
                }
                if (mGenerateDepthChartCheckBox.Checked)
                {
                    string depthChart = s.GetDepthChart();
                    string depthChartFile = "tmpDepthChart.csv";
                    ShowResults(depthChart, depthChartFile); // show Depth Chart
                }
                ShowResults(season,fileName);
            }
            else
            {
                MessageBox.Show(string.Format("Invalid year {0}",s_year));
                mYearTextBox.Focus();
                mYearTextBox.SelectAll();
            }
        }