Esempio n. 1
0
        //private void newMultipleFile()
        //{
        //    string newFilePath = getFilePath();

        //    if (newFilePath == null) return;

        //    CreateMultipleChampionshipFile(newFilePath);

        //    openFile ( newFilePath);
        //}

        /// <summary>
        /// Opens the championship file. There is a background worker for the really hard stuff.
        /// I.e. loading the events data.
        /// </summary>
        /// <param name="FilePath"></param>
        internal void openFile(string FilePath)
        {
            BackgroundWorker worker = new BackgroundWorker();

            Stopwatch watch = new Stopwatch();

            if (!System.IO.File.Exists(FilePath))
            {
                return;
            }

            if (FilePath.ToLower( ).Contains("appdata"))
            {
                MessageBoxResult msg = MessageBox.Show("The file you are trying to open is stored in a temporary location. " +
                                                       "\nWe strongly recommend that you move this file to your Desktop or your Documents directory before opening it." +
                                                       "\nDo you wish to continue to open this file? ",
                                                       "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);

                if (msg == MessageBoxResult.No)
                {
                    return; // abort the load process
                }
            }

            if (FilePath.ToLower( ).Contains(".zip") || FilePath.ToLower( ).Contains(".rar"))
            {
                MessageBoxResult msg = MessageBox.Show("The file you are trying to open is inside a compressed archive." +
                                                       "\nWe strongly recommend that you extract the file to your Desktop or your Documents directory before opening it." +
                                                       "\nDo you wish to continue? ",
                                                       "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);

                if (msg == MessageBoxResult.No)
                {
                    return; // abort the load process
                }
            }


            watch.Start( );

            ChampionshipSolutions.MainWindow.BusyIndicator.IsBusy = true;

            if (FConnFile.OpenFile(FilePath))
            {
                if (mruManager != null)
                {
                    Dispatcher.Invoke(new Action(() =>
                    {
                        mruManager.AddRecentFile(FilePath);
                        mruManager.IsEnabled = false;
                    }), null);
                }

                controls.Clear( );

                ((App)App.Current).CurrentChampionship = new ChampionshipVM( );
                //CurrentChampionship.Championship.database = GetFileDetails ( ).IO;
                this.EventPage = new EventsPage( );


                worker.DoWork += (o, a) =>
                {
                    Console.WriteLine("Loading Events");

                    this.EventPage.ReloadPage( );
                    Dispatcher.Invoke(new Action(() =>
                    {
                    }), null);
                };


                worker.RunWorkerCompleted += (o, a) =>
                {
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Championship", isEnabled = true, DisplayPage = new ChampionshipPage( )
                    });
                    Console.WriteLine("Loading Teams");
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Teams", isEnabled = true, DisplayPage = new TeamsPage( )
                    });
                    Console.WriteLine("Loading Schools");
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Schools & Clubs", isEnabled = true, DisplayPage = new SchoolsPage( )
                    });
                    Console.WriteLine("Loading Athletes");
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Athletes", isEnabled = true, DisplayPage = new AthltesPage( )
                    });
                    Console.WriteLine("Loading Groups");
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Groups", isEnabled = true, DisplayPage = new GroupsPage( )
                    });
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Events", isEnabled = true, DisplayPage = EventPage
                    });
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Import Results", isEnabled = !IsEntryForm( ), DisplayPage = new ImportResultsPage( )
                    });
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Scan Results", isEnabled = !IsEntryForm( ), DisplayPage = new ScannerPage( )
                    });
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Reports", isEnabled = true, DisplayPage = new ReportsPage( )
                    });
                    //controls.Add ( new MainPageControl ( ) { Content = "Exports" , isEnabled = false , DisplayPage = new ExportsPage ( ) } );
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Web Server", isEnabled = !IsEntryForm( ), DisplayPage = new WebServerPage( )
                    });
                    //controls.Add ( new MainPageControl ( ) { Content = "Scripts" , isEnabled = false , DisplayPage = new ScriptsPage ( ) } );
                    Console.WriteLine("Loading Templates");
                    controls.Add(new MainPageControl( )
                    {
                        Content = "Templates", isEnabled = !IsEntryForm( ), DisplayPage = new TemplatesPage( )
                    });


                    ReportLibrary = CSReportLibrary.getLibrary( );


                    ChampionshipSolutions.MainWindow.Frame.Navigate(new OpenedPage( ));
                    watch.Stop( );

                    ChampionshipSolutions.MainWindow.BusyIndicator.IsBusy = false;

                    Console.WriteLine("**************************");
                    Console.WriteLine("*****Loading complete*****");
                    Console.WriteLine("*File open took " + watch.Elapsed.TotalSeconds + " seconds.**");
                    Console.WriteLine("********DB Reads = " + GetFileDetails().IO.DBReadCounter + "*****");
                    Console.WriteLine("*****Cache Reads = " + GetFileDetails().IO.CacheReadCounter + "***");
                    Console.WriteLine("**************************");

                    ChampionshipSolutions.Diag.Diagnostics.LogLine("Opened File at " + FilePath + " in " + watch.Elapsed.TotalSeconds + " seconds.", ChampionshipSolutions.Diag.MessagePriority.Infomation);
                };

                worker.RunWorkerAsync( );
            }
            else
            {
                ChampionshipSolutions.MainWindow.BusyIndicator.IsBusy = false;
            }
        }
Esempio n. 2
0
 private bool canOpenFile()
 {
     return(!FConnFile.isFileOpen());
 }
Esempio n. 3
0
 private bool canCloseFile()
 {
     return(FConnFile.isFileOpen());
 }
Esempio n. 4
0
        internal void openFileSync(string FilePath)
        {
            if (!System.IO.File.Exists(FilePath))
            {
                return;
            }

            Stopwatch watch = new Stopwatch();

            watch.Start( );

            ChampionshipSolutions.MainWindow.BusyIndicator.IsBusy = true;

            if (FConnFile.OpenFile(FilePath))
            {
                if (mruManager != null)
                {
                    mruManager.AddRecentFile(FilePath);
                    mruManager.IsEnabled = false;
                }

                controls.Clear( );

                ((App)App.Current).CurrentChampionship = new ChampionshipVM( );
                //CurrentChampionship.Championship.database = GetFileDetails ( ).IO;

                Console.WriteLine("Loading Events");

                this.EventPage = new EventsPage( );
                this.EventPage.ReloadPage( );

                controls.Add(new MainPageControl( )
                {
                    Content = "Championship", isEnabled = true, DisplayPage = new ChampionshipPage( )
                });
                Console.WriteLine("Loading Teams");
                controls.Add(new MainPageControl( )
                {
                    Content = "Teams", isEnabled = true, DisplayPage = new TeamsPage( )
                });
                Console.WriteLine("Loading Schools");
                controls.Add(new MainPageControl( )
                {
                    Content = "Schools & Clubs", isEnabled = true, DisplayPage = new SchoolsPage( )
                });
                Console.WriteLine("Loading Athletes");
                controls.Add(new MainPageControl( )
                {
                    Content = "Athletes", isEnabled = true, DisplayPage = new AthltesPage( )
                });
                Console.WriteLine("Loading Groups");
                controls.Add(new MainPageControl( )
                {
                    Content = "Groups", isEnabled = true, DisplayPage = new GroupsPage( )
                });
                controls.Add(new MainPageControl( )
                {
                    Content = "Events", isEnabled = true, DisplayPage = EventPage
                });
                controls.Add(new MainPageControl( )
                {
                    Content = "Import Results", isEnabled = true, DisplayPage = new ImportResultsPage( )
                });
                controls.Add(new MainPageControl( )
                {
                    Content = "Web Server", isEnabled = true, DisplayPage = new WebServerPage( )
                });
                controls.Add(new MainPageControl( )
                {
                    Content = "Reports", isEnabled = true, DisplayPage = new ReportsPage( )
                });
                controls.Add(new MainPageControl( )
                {
                    Content = "Exports", isEnabled = true, DisplayPage = new ExportsPage( )
                });
                controls.Add(new MainPageControl( )
                {
                    Content = "Scanner", isEnabled = true, DisplayPage = new ScannerPage( )
                });
                Console.WriteLine("Loading Templates");
                controls.Add(new MainPageControl( )
                {
                    Content = "Templates", isEnabled = true, DisplayPage = new TemplatesPage( )
                });


                ReportLibrary = CSReportLibrary.getLibrary( );
                ChampionshipSolutions.MainWindow.Frame.Navigate(new OpenedPage( ));
                ChampionshipSolutions.MainWindow.BusyIndicator.IsBusy = false;
            }

            watch.Stop( );

#if ( DEBUG )
            MessageBox.Show("File open took " + watch.Elapsed.TotalSeconds + " seconds.");
#endif
        }