コード例 #1
0
        public Boolean exportData( String[] inTableName, String[] inSelectStmt, String inFullFileName )
        {
            Boolean returnStatus = false;
            StreamWriter outBuffer = File.CreateText( inFullFileName );
            StringBuilder inReturnMessage = new StringBuilder( "" );

            if (outBuffer != null) {
                myProgressInfo = new ProgressWindow();
                myProgressInfo.setProgessMsg( "Exporting selected data for " + inTableName.Length + " data types" );
                myProgressInfo.Show();
                myProgressInfo.Refresh();
                myProgressInfo.setProgressMax( inTableName.Length );

                for ( int idx = 0; idx < inTableName.Length; idx++ ) {
                    returnStatus = exportData( inTableName[idx], inSelectStmt[idx], outBuffer, false, inReturnMessage );

                    myProgressInfo.setProgressValue( idx + 1 );
                    myProgressInfo.Refresh();
                }

                outBuffer.Close();
                myProgressInfo.Close();
                if (inReturnMessage.Length > 1) {
                    MessageBox.Show( inReturnMessage.ToString() );
                }
            }
            return returnStatus;
        }
コード例 #2
0
        protected override void RemoveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (dgResults.SelectedItems.Count == 0 || dgResults.SelectedItem == null)
            {
                return;
            }

            OnReloading = true;

            var logs = dgResults.SelectedItems.OfType <Log>().ToList();

            if (logs.Count > 0)
            {
                var failed       = false;
                var removedCount = 0;
                if (Global.DeleteQuestion(this))
                {
                    var progressForm = new ProgressWindow(logs.Count);
                    progressForm.Show(this);
                    foreach (var log in logs)
                    {
                        if (!LogsService.Default.Remove(log.LogID))
                        {
                            failed = true;
                            Global.DeletionFailed(this);
                        }
                        else
                        {
                            removedCount++;
                        }
                        progressForm.IncreaseProgress();
                    }
                    progressForm.Close();
                    if (logs.Count > 1 && failed)
                    {
                        Global.DeletionSuceededWithSomeFailures(this);
                    }
                    else if (removedCount > 0 & !failed)
                    {
                        Global.DeletionSuceeded(this);
                    }
                    ResetFields();
                    TryToLoad();
                }
            }

            aiLoader.Visibility = Visibility.Collapsed;
        }
コード例 #3
0
        private async void ShowHideDetails(object sender, System.Windows.RoutedEventArgs e)
        {
            Dokumentacija doc          = DataGrid.SelectedItem as Dokumentacija;
            var           dataProvider = new EFCoreDataProvider();

            if (await dataProvider.DokumentImaPDFFajl(doc.IDDokumenta))  // Otvori taj fajl, da li je StatusDokumenta isto kao i to Da li ima pdf fajl??? za sad jeste
            {
                string filename = "temp.pdf";
                File.WriteAllBytes(filename, (await dataProvider.GetPDFAsync(doc.IDDokumenta)).PDFFajl); //ovo kreira lokalni pdf fajl od bajtova
                System.Diagnostics.Process.Start(filename);                                              // Otvara ga u default pdf vieweru
            }
            else // Prilozi pdf fajl
            {
                byte[]         a;
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter = "PDF dokument | *.pdf";

                if (dlg.ShowDialog() == true)
                {
                    // Kreira se i prikazu progressWindows sa porukom dok se vrsi slanje dokumenta na server
                    var progressWindow = new ProgressWindow("Upload PDF dokumenta");
                    progressWindow.Show();

                    string path = dlg.FileName.ToString();
                    a = File.ReadAllBytes(path); //ovo pretvara izabrani fajl u bajtove
                    // Dodavanje novog PDF u tabelu
                    await dataProvider.AddPDFAsync(new PDF
                    {
                        IDDokumenta = doc.IDDokumenta,
                        PDFFajl     = a
                    }, Helper.TrenutniKorisnik);

                    //Update dokumenta
                    doc.StatusDokumenta = true;
                    doc.Datum           = DateTime.Now.ToString();
                    await dataProvider.UpdateDokumentAsync(doc);

                    // ProgressWindow moze da se zatvori
                    progressWindow.Close();

                    // Update podataka koji se prikazuju u dataGridu
                    ProveriKojiDokumentiImajuUslov();
                    UpdateDataGrid();
                }
            }
        }
コード例 #4
0
        private void btnInstallNow_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var localInstallerPath = App.AppTempPath + "Setup.exe";
                var pw = new ProgressWindow("Please wait while the installer is being downloaded...\n" + _installerURL);
                pw.Show();
                var webClient = new WebClient();
                webClient.DownloadProgressChanged +=
                    delegate(object o, DownloadProgressChangedEventArgs args) { pw.SetProgressBarValue(args.ProgressPercentage); };
                webClient.DownloadFileCompleted += delegate
                {
                    pw.CanClose = true;
                    pw.Close();
                    if (
                        MessageBox.Show(
                            "NBA Stats Tracker will now close to install the latest version and then restart.\n\nAre you sure you want to continue?",
                            "NBA Stats Tracker",
                            MessageBoxButton.YesNo,
                            MessageBoxImage.Question,
                            MessageBoxResult.Yes) != MessageBoxResult.Yes)
                    {
                        return;
                    }

                    var newUpdaterPath = App.AppTempPath + "\\Updater.exe";
                    try
                    {
                        File.Copy(
                            Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Updater.exe", newUpdaterPath, true);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Couldn't run the Updater. " + ex.Message);
                        return;
                    }
                    Process.Start(newUpdaterPath, "\"" + localInstallerPath + "\"");
                    Environment.Exit(0);
                };
                webClient.DownloadFileAsync(new Uri(_installerURL), localInstallerPath);
            }
            catch (Exception ex)
            {
                MessageBox.Show("The changelog couldn't be downloaded at this time. Please try again later.\n\n" + ex.Message);
            }
        }
コード例 #5
0
ファイル: ViewModelBase.cs プロジェクト: m-sadegh-sh/Phoenix
        protected virtual void Delete()
        {
            Frozen = true;
            if (Global.DeleteQuestion(null))
            {
                var failed         = false;
                var removedCount   = 0;
                var shallowCopy    = SelectedItems.ToList();
                var progressWindow = new ProgressWindow(SelectedItems.Count);
                progressWindow.Show(ModelWindow);
                foreach (var item in shallowCopy)
                {
                    if (!ModelService.Remove(item))
                    {
                        failed = true;
                        Global.DeletionFailed(null);
                    }
                    else
                    {
                        removedCount++;
                        SelectedItems.Remove(item);
                        ModelItems.Remove(item);
                    }
                    progressWindow.IncreaseProgress();
                }
                progressWindow.Close();
                Reset();

                if (removedCount > 0)
                {
                    if (failed)
                    {
                        Global.DeletionSuceededWithSomeFailures(null);
                    }
                    else if (removedCount > 0)
                    {
                        Global.DeletionSuceeded(null);
                    }
                }
            }
            Frozen = false;
        }
コード例 #6
0
ファイル: App.xaml.cs プロジェクト: alexousky/Formots
        private static void InitializeApplicationViewModelsAndLaunch()
        {
            var main = new MainWindow();

            Current.MainWindow = main;

            Action <string, string> exec = (s, s1) =>
            {
                formulaireBaseViewModel           = FormulaireBaseViewModel.Instance;
                usersListFormViewModel            = UsersListFormViewModel.Instance;
                medecinAppelantsListFormViewModel = MedecinAppelantsListFormViewModel.Instance;
                dossiersListFormViewModel         = DossiersListFormViewModel.Instance;
                dashboardPageViewModel            = DashboardPageViewModel.Instance;
                //Attention: Ne pas appeler le ChartsListFormViewModel qui update la vue directement.

                dossiersListFormViewModel.SynchroneUpdateList();
                usersListFormViewModel.SynchroneUpdateList();
                medecinAppelantsListFormViewModel.SynchroneUpdateList();
            };

            var progressWindow = new ProgressWindow();

            progressWindow.SetTitle("Chargement en cours");
            var backgroundWorker = new BackgroundWorker();

            // set the worker to call your long-running method
            backgroundWorker.DoWork += (object sender, DoWorkEventArgs e) =>
            {
                exec.Invoke("path", "parameters");
            };

            // set the worker to close your progress form when it's completed
            backgroundWorker.RunWorkerCompleted += (object sender, RunWorkerCompletedEventArgs e) =>
            {
                progressWindow.Close();
                main.Show();
                MainWindowViewModel.Instance.OpenDashboardPageCommand.Execute(null);
            };
            progressWindow.Show();
            backgroundWorker.RunWorkerAsync();
        }
コード例 #7
0
        protected override void SaveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            var propIDs = (IList <Guid>)e.Result;

            if (propIDs != null && propIDs.Count > 0)
            {
                var progressResources = new ProgressWindow(propIDs.Count);
                progressResources.Show(this);
                foreach (var propId in propIDs)
                {
                    LabPropsService.Instanse.Insert(new LabProp {
                        LabID = (Guid)cmbLabs.SelectedValue, PropID = propId
                    });
                    progressResources.IncreaseProgress();
                }
                progressResources.Close();
                TryToLoad(cmbLabs.SelectedValue);
            }
            aiLoader.Visibility = Visibility.Collapsed;
            OnSaving            = false;
        }
        private async void Potvrdi_Click(object sender, RoutedEventArgs e)
        {
            var dataProvider = new EFCoreDataProvider();

            // Dodavanje podataka za trenutni projekat
            ZapocetiProjekat.DatumPocetka   = dpDatumPocetkaProjekta.DisplayDate.ToShortDateString();
            ZapocetiProjekat.StanjeProjekta = "Aktivan";

            // Kreiranje i prikazivanje progress windowa
            var progressWindow = new ProgressWindow("Kreiranje projekta u toku...");

            progressWindow.Show();

            // U bazi se kreira novi projekat i za njega se kreiraju odgovarajuca dokumenta
            var listaDokumenata = GetListuDokumenata(ZapocetiProjekat.VrstaProjekta);
            await dataProvider.KreirajProjekatIDodajDokumenta(ZapocetiProjekat, listaDokumenata);

            // Unose se generalni troskovi - neka default vrednosti, 1 uplata, ukupnonovca = 100
            await dataProvider.AddGeneralniTrosakAsync(new GeneralniTrosak { IDProjekta = ZapocetiProjekat.IDProjekta, BrojUplata = 1, Procenti = "100", UkupnoNovca = 100 });

            // TODO: Ovde mogu i ostali atributi informaicje o lokaciji da se unose

            if (informacijaOLokaciji != null) // Ako je vec uneta informacija o lokaciji onda se ona pamti u bazi pri kreiranju projekta
            {
                await dataProvider.AddPDFAsync(new PDF {
                    IDDokumenta = listaDokumenata[0].IDDokumenta,
                    PDFFajl     = informacijaOLokaciji
                }, Helper.TrenutniKorisnik);
            }

            // Zatvaranja ProgressWindow-a
            progressWindow.Close();

            // Prelazak na ClanoviProjektaPage
            var parent = (Parent as MainWindow);

            Helper.TrenutniProjekat = ZapocetiProjekat;
            parent.Content          = new ClanoviProjektaPage();
        }
コード例 #9
0
        public static void OpenAsynchroneStatisticsPage(ChartsListFormViewModel chartsListFormViewModel)
        {
            Action <string, string> exec = (s, s1) =>
            {
                chartsListFormViewModel.ChartsDtoList = StatistiquesBLL.Current.GetChartsDtoList();
            };

            var progressWindow = new ProgressWindow();

            progressWindow.SetTitle("Chargement en cours");
            var backgroundWorker = new BackgroundWorker();

            // set the worker to call your long-running method
            backgroundWorker.DoWork += (object sender2, DoWorkEventArgs e) => { exec.Invoke("path", "parameters"); };

            // set the worker to close your progress form when it's completed
            backgroundWorker.RunWorkerCompleted += (object sender2, RunWorkerCompletedEventArgs e) =>
            {
                progressWindow.Close();
            };
            progressWindow.Show();
            backgroundWorker.RunWorkerAsync();
        }
コード例 #10
0
 protected override void SaveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (Global.ShowQuestion(this))
     {
         var count          = PropsService.CountOfNotNotifiable() + MaterialsService.CountOfNotNotifiable();
         var progressWindow = new ProgressWindow(count);
         progressWindow.Show(this);
         foreach (var propID in PropsService.GetAllNotNotifiables())
         {
             PropsService.ChangeNotifiable(propID, true);
             progressWindow.IncreaseProgress();
         }
         foreach (var materialID in MaterialsService.GetAllNotNotifiables())
         {
             MaterialsService.ChangeNotifiable(materialID, true);
             progressWindow.IncreaseProgress();
         }
         progressWindow.Close();
         Global.ShowSuceeded(this);
         TryToLoad();
     }
     aiLoader.Visibility = Visibility.Collapsed;
     OnSaving            = false;
 }
コード例 #11
0
        private void CoverMediaService_ConvertMediaCompleted()
        {
            Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate
            {
                progressWindow.Status = "Converted all media";
                progressWindow.AddToOutput("Converted all media");

                try
                {
                    // close the progress window
                    progressWindow.Close();
                }
                catch (Exception) { }

                try
                {
                    // eject the disc
                    dvdTrayService.OpenDiscTray(ripDVDService.DriveLetter);
                }
                catch (Exception exp)
                {
                }
            }));
        }
コード例 #12
0
        private async void _backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            _progressWindow.Close();

            if (e.Cancelled || e.Error is OperationCanceledException)
            {
                MessageBox.Show("Import cancelled.\n\nNo candidates imported", "Import cancelled", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else if (e.Error != null || e.Result is Exception)
            {
                var exception = e.Error ?? e.Result as Exception;
                MessageBox.Show($"{ exception.GetBaseException().Message } \n\n { "No candidates imported" }", "Import error", MessageBoxButton.OK, MessageBoxImage.Stop);
            }
            else
            {
                await _maintenanceWindow.LoadCandidatesAsync();

                var count = e.Result as Tuple <int, int>;
                if (count.Item1 > 0)
                {
                    var messageBuilder = new StringBuilder($"Successfully imported { "candidate".ToQuantity(count.Item1) }");
                    if (count.Item2 > 0)
                    {
                        messageBuilder.Append($" ({ "blank row".ToQuantity(count.Item2) })");
                    }

                    MessageBox.Show(messageBuilder.ToString(), "Import successful", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    MessageBox.Show("No candidates imported", "No data", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }

            _backgroundWorker.Dispose();
        }
コード例 #13
0
        public Boolean ExportScorebookPublishFmtData()
        {
            String        curMethodName = "ExportScorebookPublishFmtData";
            Boolean       returnStatus = false;
            StringBuilder outLine = new StringBuilder("");
            String        curMsg = "", curMemberId = "", curAgeGroup = "", prevAgeGroup = "";
            String        curFileFilter = "TXT files (*.txt)|*.txt|All files (*.*)|*.*";
            Int16         curRound = 0, curOverallPlcmt = 0;
            DataRow       prevRow = null;

            DataRow[] curScoreSlalomRows = null, curScoreTrickRows = null, curScoreJumpRows = null;

            try {
                curMsg = "Exporting Scorebook Publish Data";
                Log.WriteFile(curMethodName + ":begin: " + curMsg);
                String       curFilename = mySanctionNum.Trim() + "-publish.txt";
                StreamWriter outBuffer   = getExportFile(curFileFilter, curFilename);

                if (outBuffer == null)
                {
                    curMsg = "Output file not available";
                }
                else
                {
                    String curPlcmtMethod = "score"
                    , curPlcmtOverallOrg  = "agegroup"
                    , curDataType         = "best"
                    , curPointsMethod     = "nops"
                    , curPlcmtOrg         = "div";

                    myProgressInfo = new ProgressWindow();
                    myProgressInfo.setProgessMsg("Processing Scorebook Publish Data");
                    myProgressInfo.Show();
                    myProgressInfo.Refresh();
                    myProgressInfo.setProgressMax(10);

                    CalcScoreSummary curCalcSummary    = new CalcScoreSummary();
                    DataTable        mySlalomDataTable = curCalcSummary.getSlalomSummary(myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod);
                    myProgressInfo.setProgressValue(1);
                    myProgressInfo.Refresh();
                    DataTable myTrickDataTable = curCalcSummary.getTrickSummary(myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod);
                    myProgressInfo.setProgressValue(2);
                    myProgressInfo.Refresh();
                    DataTable myJumpDataTable = curCalcSummary.getJumpSummary(myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod);
                    myProgressInfo.setProgressValue(3);
                    myProgressInfo.Refresh();
                    DataTable mySummaryDataTable = curCalcSummary.buildOverallSummary(myTourRow, mySlalomDataTable, myTrickDataTable, myJumpDataTable, curDataType, curPlcmtOverallOrg);
                    foreach (DataRow curRow in mySummaryDataTable.Rows)
                    {
                        if (((String)curRow["QualifyOverall"]).ToUpper().Equals("YES"))
                        {
                        }
                        else
                        {
                            curRow["ScoreOverall"] = 0;
                        }
                    }
                    myProgressInfo.setProgressValue(4);
                    myProgressInfo.Refresh();

                    mySummaryDataTable.DefaultView.Sort = "AgeGroup ASC, QualifyOverall Desc, ScoreOverall Desc, SkierName ASC";
                    DataTable curSummaryDataTable = mySummaryDataTable.DefaultView.ToTable();

                    myProgressInfo.setProgressMax(mySummaryDataTable.Rows.Count);
                    myProgressInfo.Refresh();

                    //Build file header line and write to file
                    writeHeader(outBuffer);

                    int curRowCount = 0;
                    foreach (DataRow curRow in curSummaryDataTable.Rows)
                    {
                        curRowCount++;
                        myProgressInfo.setProgressValue(curRowCount);
                        myProgressInfo.Refresh();

                        curMemberId = curRow["MemberId"].ToString();
                        curAgeGroup = curRow["AgeGroup"].ToString();
                        if (curAgeGroup != prevAgeGroup)
                        {
                            if (prevAgeGroup.Length > 0)
                            {
                                outBuffer.WriteLine("");
                                curOverallPlcmt = 0;
                            }

                            //Write skier identification information
                            outLine = new StringBuilder("");
                            outLine.Append(writeDivisionHeader(outBuffer, curAgeGroup));
                        }

                        curScoreSlalomRows = mySlalomDataTable.Select("MemberId = '" + curMemberId + "' AND AgeGroup = '" + curAgeGroup + "'");
                        curScoreTrickRows  = myTrickDataTable.Select("MemberId = '" + curMemberId + "' AND AgeGroup = '" + curAgeGroup + "'");
                        curScoreJumpRows   = myJumpDataTable.Select("MemberId = '" + curMemberId + "' AND AgeGroup = '" + curAgeGroup + "'");

                        //Initialize control fields
                        prevAgeGroup = curAgeGroup;

                        //Initialize output buffer
                        outLine = new StringBuilder("");

                        //Write skier identification information
                        outLine.Append(writeSkierInfo(curRow, curRound));

                        //Write skier performance summary information
                        outLine.Append(writeSkierSlalomScore(curRow, curScoreSlalomRows));

                        outLine.Append(writeSkierTrickScore(curRow, curScoreTrickRows));

                        outLine.Append(writeSkierJumpScore(curRow, curScoreJumpRows));

                        curOverallPlcmt++;
                        outLine.Append(writeSkierOverallScore(curRow, curOverallPlcmt));
                        //Write output line to file
                        outBuffer.WriteLine(outLine.ToString());
                    }

                    //Build file footer and write to file
                    outLine = new StringBuilder("");
                    outBuffer.WriteLine(outLine.ToString());

                    returnStatus = true;
                    outBuffer.Close();

                    myProgressInfo.Close();
                    if (mySummaryDataTable.Rows.Count > 0)
                    {
                        curMsg = mySummaryDataTable.Rows.Count + " skiers found and written";
                    }
                    else
                    {
                        curMsg = "No rows found";
                    }
                }
                MessageBox.Show(curMsg);
                Log.WriteFile(curMethodName + ":conplete: " + curMsg);
            } catch (Exception ex) {
                MessageBox.Show("Error:" + curMethodName + " Could not write file from data input\n\nError: " + ex.Message);
                curMsg = curMethodName + ":Exception=" + ex.Message;
                Log.WriteFile(curMsg);
                returnStatus = false;
            }

            return(returnStatus);
        }
コード例 #14
0
        private bool updateSchema(String inFileRef)
        {
            bool curReturnValue = true;
            int curDelimIdx;
            String inputBuffer, curSqlStmt = "";
            StringBuilder curInputCmd = new StringBuilder( "" );
            ImportData curImportData = new ImportData();
            StreamReader myReader;
            myProgressInfo = new ProgressWindow();

            try {
                #region Process all commands in the input file
                myReader = getImportFile( inFileRef );
                if ( myReader != null ) {
                    int curInputLineCount = 0;
                    try {
                        MessageBox.Show( "Your database is about to be upgraded.  Please click OK or continue to any dialogs." );

                        while ( ( inputBuffer = myReader.ReadLine() ) != null ) {
                            curInputLineCount++;
                            myProgressInfo.setProgressValue( curInputLineCount );

                            if ( inputBuffer.TrimStart( ' ' ).StartsWith( "//" ) ) {
                            } else {
                                curDelimIdx = inputBuffer.IndexOf( ';' );
                                if ( curDelimIdx >= 0 ) {
                                    if ( curDelimIdx > 0 ) {
                                        curInputCmd.Append( inputBuffer.Substring( 0, curDelimIdx ) );
                                    }
                                    curSqlStmt = curInputCmd.ToString();
                                    curSqlStmt.TrimStart( ' ' );
                                    if ( curSqlStmt.Trim().ToUpper().StartsWith( "DROP " ) ) {
                                        execDropTable( replaceLinefeed(curSqlStmt) );
                                    } else if ( curSqlStmt.Trim().ToUpper().StartsWith( "CREATE " ) ) {
                                        execCreateTable( replaceLinefeed(curSqlStmt) );
                                        curInputCmd = new StringBuilder( "" );
                                    } else {
                                        execSchemaCmd( replaceLinefeed(curSqlStmt) );
                                    }
                                    curInputCmd = new StringBuilder( "" );

                                } else {
                                    curInputCmd.Append( inputBuffer );
                                }
                            }

                        }
                        curSqlStmt = "";
                        System.Data.SqlServerCe.SqlCeEngine mySqlEngine = new SqlCeEngine();
                        mySqlEngine.LocalConnectionString = Properties.Settings.Default.waterskiConnectionStringApp;
                        mySqlEngine.Shrink();

                    } catch ( Exception ex ) {
                        curReturnValue = false;
                        String ExcpMsg = ex.Message;
                        if ( mySqlStmt != null ) {
                            ExcpMsg += "\n" + curSqlStmt;
                        }
                        MessageBox.Show( "Error attempting to update database schema" + "\n\nError: " + ExcpMsg );
                    }
                }
                #endregion

            } catch ( Exception ex ) {
                curReturnValue = false;
                String ExcpMsg = ex.Message;
                if ( mySqlStmt != null ) {
                    ExcpMsg += "\n" + mySqlStmt.CommandText;
                }
                MessageBox.Show( "Error attempting to update database schema" + "\n\nError: " + ExcpMsg );
            }
            myProgressInfo.Close();

            return curReturnValue;
        }
コード例 #15
0
        public Boolean exportBoatTimes( String inSanctionId )
        {
            Boolean returnStatus = false, curActiveTour = false;
            char DoubleQuote = '"';
            String curMemberId = "", curEventDateOut = "";
            StringBuilder outLine = new StringBuilder( "" );
            StreamWriter outBuffer = null;
            myProgressInfo = new ProgressWindow();

            DataTable curTourDataTable = getTourData( inSanctionId );
            if ( curTourDataTable != null ) {
                if ( curTourDataTable.Rows.Count > 0 ) {
                    curActiveTour = true;
                    myTourRow = curTourDataTable.Rows[0];
                    myTourClass = myTourRow["Class"].ToString().ToUpper();
                    String curFilename = inSanctionId.Trim() + "ST.csv";
                    outBuffer = getExportFile( curFilename );

                    curEventDateOut = myTourRow["EventDates"].ToString();
                    if ( curEventDateOut.Length > 7 ) {
                        try {
                            DateTime curEventDate = Convert.ToDateTime( curEventDateOut );
                            curEventDateOut = curEventDate.ToString( "yyyyMMdd" );
                        } catch {
                            curEventDateOut = "";
                        }
                    } else {
                        curEventDateOut = "";
                    }
                }
            }

            if ( curActiveTour ) {
                StringBuilder curSqlStmt = new StringBuilder( "" );
                curSqlStmt.Append( "SELECT ListCode, ListCodeNum, SortSeq, CodeValue, MinValue, MaxValue, CodeDesc ");
                curSqlStmt.Append( "FROM CodeValueList WHERE ListName = 'SlalomBoatTime' ORDER BY SortSeq" );
                myTimesDataTable = getData( curSqlStmt.ToString() );

                mySkierClassList = new ListSkierClass();
                mySkierClassList.ListSkierClassLoad();
                myClassCRow = mySkierClassList.SkierClassDataTable.Select("ListCode = 'C'")[0];
                myClassERow = mySkierClassList.SkierClassDataTable.Select("ListCode = 'E'")[0];

                DataTable curSpeedByPassDataTable;
                Int16 curMaxSpeed, curPassNum, curRound;
                Decimal curBoatTime, curScore, curSpeed, curActualTime;
                String curSpeedDesc, curTimeKey, curTimeKeyScore, curEventClass, curRunTime;
                DataRow[] curTimeRowsFound;
                if ( outBuffer != null ) {
                    outLine.Append( "Sanction" );
                    outLine.Append( ", Skier Class" );
                    outLine.Append( ", Boat" );
                    outLine.Append( ", EventDate" );
                    outLine.Append( ", Time" );
                    outLine.Append( ", SkierName" );
                    outLine.Append( ", Div" );
                    outLine.Append( ", MaxSpeed" );
                    outLine.Append( ", Round" );
                    outLine.Append( ", PassNum" );
                    outLine.Append( ", PassDesc" );
                    outLine.Append( ", PassScore" );
                    outLine.Append( ", BoatTime" );
                    outLine.Append( ", ActualTime" );

                    //Write output line to file
                    outBuffer.WriteLine( outLine.ToString() );
                    outLine = new StringBuilder( "" );

                    myProgressInfo.setProgessMsg( "Export slalom boat times " );
                    myProgressInfo.Show();
                    myProgressInfo.Refresh();
                    int curRowCount = 0;

                    DataTable curBoatTimeResults = getBoatTimeResults( inSanctionId );
                    if ( curBoatTimeResults != null ) {
                        myProgressInfo.setProgressMax( curBoatTimeResults.Rows.Count );
                        foreach (DataRow curRow in curBoatTimeResults.Rows) {
                            curRowCount++;
                            myProgressInfo.setProgressValue( curRowCount );
                            myProgressInfo.Refresh();

                            try {
                                curBoatTime = (Decimal)curRow["BoatTime"];
                            } catch {
                                curBoatTime = 0;
                            }
                            try {
                                curScore = ( (Decimal)curRow["PassScore"] );
                            } catch {
                                curScore = 0;
                            }
                            try {
                                curRound = ( (Byte)curRow["Round"] );
                            } catch {
                                curRound = 0;
                            }
                            try {
                                curPassNum = ( (Byte)curRow["PassNum"] );
                            } catch {
                                curPassNum = 0;
                            }
                            try {
                                curEventClass = ( (String)curRow["EventClass"] );
                            } catch {
                                curEventClass = "";
                            }
                            try {
                                curRunTime = ( (DateTime)curRow["LastUpdateDate"] ).ToString( "hhmm" );
                            } catch {
                                curRunTime = "0000";
                            }
                            try {
                                curMaxSpeed = ( (Byte)curRow["MaxSpeed"] );
                                curSpeedByPassDataTable = getSpeedByPass( curMaxSpeed, curPassNum );
                                if ( curSpeedByPassDataTable.Rows.Count > 0 ) {
                                    curSpeedDesc = (String)curSpeedByPassDataTable.Rows[0]["CodeValue"];
                                    curSpeed = (Decimal)curSpeedByPassDataTable.Rows[0]["MaxValue"];
                                    curTimeKeyScore = curScore.ToString( "0.00" );
                                    curTimeKey = curSpeed.ToString( "00" ) + "-" + getTimeClass( curEventClass ) + "-" + curTimeKeyScore.Substring( 0, 1 );
                                    curTimeRowsFound = myTimesDataTable.Select( "ListCode = '" + curTimeKey + "'" );
                                    if ( curTimeRowsFound.Length > 0 ) {
                                        myTimeRow = curTimeRowsFound[0];
                                    } else {
                                        myTimeRow = null;
                                    }
                                    curActualTime = Convert.ToDecimal( (String)myTimeRow["CodeValue"] );
                                } else {
                                    curSpeed = 0;
                                    curActualTime = 0;
                                    curSpeedDesc = "";
                                    myTimeRow = null;
                                }

                            } catch {
                                curActualTime = 0;
                                curSpeed = 0;
                                curMaxSpeed = 0;
                                curSpeedDesc = "";
                                myTimeRow = null;
                            }

                            outLine.Append( DoubleQuote.ToString() + inSanctionId + myTourClass + DoubleQuote.ToString() ); // 1. (7) SanctionId with class
                            outLine.Append( "," + DoubleQuote.ToString() + curRow["EventClass"].ToString() + DoubleQuote.ToString() ); // 2. (1) Skier Class
                            outLine.Append( "," + DoubleQuote.ToString() + curRow["Boat"].ToString().PadRight( 11, ' ' ) + DoubleQuote.ToString() ); // 3. (11) Boat
                            outLine.Append( "," + DoubleQuote.ToString() + curEventDateOut + DoubleQuote.ToString() ); // 4. (8) Date YYYYMMDD
                            outLine.Append( "," + DoubleQuote.ToString() + curRunTime + DoubleQuote.ToString() ); // 5. (4) Time HHMM
                            outLine.Append( "," + DoubleQuote.ToString() + curRow["SkierName"].ToString().PadRight( 22, ' ' ) + DoubleQuote.ToString() ); // 6. (22) Skier Name
                            outLine.Append( "," + DoubleQuote.ToString() + curRow["AgeGroup"].ToString() + DoubleQuote.ToString() ); // 7. (2) Age Division
                            outLine.Append( "," + DoubleQuote.ToString() + curMaxSpeed.ToString( "#0" ).PadLeft( 2, ' ' ) + DoubleQuote.ToString() ); // 8. (2) Max Speed for division
                            outLine.Append( "," + DoubleQuote.ToString() + curRound.ToString( "#0" ).PadLeft( 2, ' ' ) + DoubleQuote.ToString() ); // 9. (2) Round
                            outLine.Append( "," + DoubleQuote.ToString() + curPassNum.ToString( "#0" ).PadLeft( 2, ' ' ) + DoubleQuote.ToString() ); // 10. (2) Pass Number
                            outLine.Append( "," + DoubleQuote.ToString() + curSpeedDesc.PadRight( 28, ' ' ) + DoubleQuote.ToString() ); // 11. (28) Boat Speed Desc
                            outLine.Append( "," + DoubleQuote.ToString() + curScore.ToString( "#.00" ).PadLeft( 4, ' ' ) + DoubleQuote.ToString() ); //10. (4) Score for Pass
                            outLine.Append( "," + curBoatTime.ToString( "##.00" ) ); //12. (5 Num) Boat Time
                            outLine.Append( "," + curActualTime.ToString( "##.00" ) ); //13. (5 Num) Actual Time

                            //Write output line to file
                            outBuffer.WriteLine( outLine.ToString() );

                            //Initialize output buffer
                            outLine = new StringBuilder( "" );
                        }
                        myProgressInfo.Close();
                    }

                    returnStatus = true;
                    outBuffer.Close();

                    if ( curBoatTimeResults.Rows.Count > 0 ) {
                        MessageBox.Show( curBoatTimeResults.Rows.Count + " rows found and written" );
                    } else {
                        MessageBox.Show( "No rows found" );
                    }
                }
            }

            return returnStatus;
        }
コード例 #16
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            String curMethodName = "OkButton_Click";
            String curApiKey = "36924f60689e082b2626ae7da73d0404";
            String curApiKeyName = "SproutVideo-Api-Key";
            String curFileFormName = "source_video";
            DataGridViewRow curViewRow = null; ;
            NameValueCollection curFormData = null;
            NameValueCollection curHeaderParams = null;

            if (ExportLiveWeb.LiveWebLocation.Length > 1) {
                myProgressInfo = new ProgressWindow();
                try {
                    if (mySkierVideoList != null && mySkierVideoList.Count > 0) {
                        myProgressInfo.setProgessMsg( "Uploading " + mySkierVideoList.Count + " trick video files" );
                        myProgressInfo.setProgressMax( mySkierVideoList.Count );
                        myProgressInfo.Show();
                        int curProcessCount = 0, curViewIdx = 0;
                        foreach (SkierVideoEntry curSkierVideoEntry in mySkierVideoList) {
                            curProcessCount++;
                            myProgressInfo.setProgressValue( curProcessCount );
                            myProgressInfo.setProgessMsg( "Processing file " + Path.GetFileName( curSkierVideoEntry.VideoFileName ) );
                            myProgressInfo.Refresh();
                            myProgressInfo.Show();

                            curViewRow = selectedFileDataGridView.Rows[curViewIdx];

                            curFormData = new NameValueCollection();
                            curFormData.Add( "title", curSkierVideoEntry.SkierName + " " + curSkierVideoEntry.AgeGroup + " Round " + curSkierVideoEntry.Round + " Pass " + curSkierVideoEntry.Pass );
                            curFormData.Add( "description", curSkierVideoEntry.SkierName + " " + curSkierVideoEntry.AgeGroup + " Round: " + curSkierVideoEntry.Round + " Pass: "******"privacy", "2" );

                            int curIdx = 0;
                            foreach (String curEntry in TagsListBox.CheckedItems) {
                                curFormData.Add( "tag_names[" + curIdx + "]", curEntry );
                                curIdx++;
                            }
                            curFormData.Add( "tag_names[" + curIdx + "]", mySanctionNum );
                            curIdx++;
                            curFormData.Add( "tag_names[" + curIdx + "]", curSkierVideoEntry.AgeGroup );
                            curIdx++;
                            curFormData.Add( "tag_names[" + curIdx + "]", "Tricks" );
                            curIdx++;
                            curFormData.Add( "tag_names[" + curIdx + "]", "Round " + curSkierVideoEntry.Round );
                            curIdx++;
                            curFormData.Add( "tag_names[" + curIdx + "]", "Pass " + curSkierVideoEntry.Pass );
                            curIdx++;

                            curHeaderParams = new NameValueCollection();
                            curHeaderParams.Add( curApiKeyName, curApiKey );

                            //List<KeyValuePair<String, String>> curResponseDataList = SendMessageHttp.sendMessagePostFileUpload( myVideoLoadUrl, curSkierVideoEntry.VideoFileName, curFileFormName, curHeaderParams, curFormData, null, null );
                            Dictionary<string, object> curResponseDataList = SendMessageHttp.sendMessagePostFileUpload( myVideoLoadUrl, curSkierVideoEntry.VideoFileName, curFileFormName, curHeaderParams, curFormData, null, null );

                            if ( curResponseDataList == null ) {
                                curViewRow.Cells["SelectedLoadStatus"].Value = "Video load failed";
                            } else {
                                if ( curResponseDataList != null && curResponseDataList.Count > 0 ) {
                                    if ( curResponseDataList.ContainsKey("embed_code") ) {
                                        foreach ( KeyValuePair<String, object> curEntry in curResponseDataList ) {
                                            if ( curEntry.Key.Equals("embed_code") ) {
                                                bool curResults = updateSkierScoreVideoUrl(curSkierVideoEntry, (String) curEntry.Value);
                                                if ( curResults) {
                                                    curViewRow.Cells["SelectedLoadStatus"].Value = "Video load complete";
                                                } else {
                                                    curViewRow.Cells["SelectedLoadStatus"].Value = "Error encountered attaching video URL to skier";
                                                }
                                            } else {
                                                curViewRow.Cells["SelectedLoadStatus"].Value = "Video load failed, API response not recognized";
                                            }
                                        }
                                    } else if ( curResponseDataList.ContainsKey("Error") ) {
                                        curViewRow.Cells["SelectedLoadStatus"].Value = curResponseDataList["Error"].ToString();
                                    }
                                } else {
                                    curViewRow.Cells["SelectedLoadStatus"].Value = "Video load failed";
                                }
                            }

                            curViewIdx++;
                        }
                        myProgressInfo.Close();
                    } else {
                        myProgressInfo.Close();
                    }
                } catch (Exception ex) {
                    //MessageBox.Show( curMethodName + ":Error encountered\n\nError: " + ex.Message );
                    String curMsg = curMethodName + ":Exception=" + ex.Message;
                    Log.WriteFile( curMsg );
                    myProgressInfo.Close();
                }
            } else {
                MessageBox.Show( curMethodName + ":Live Web must be activated to load videos" );
            }
        }
コード例 #17
0
ファイル: MainPage.xaml.cs プロジェクト: jaccus/CitySimulator
        private void ExportBtnClick(object sender, RoutedEventArgs e)
        {
            var exportMethod = exportTypeComboBox.Text;

            var selectedTables = tableListComboBox.SelectedItems.Cast<string>();

            _progressDialog = new ProgressWindow();

            var worker = new BackgroundWorker { WorkerSupportsCancellation = true };
            worker.DoWork +=
                delegate(object s, DoWorkEventArgs args)
                {
                    _progressDialog.Args = args;
                    ExportTables(selectedTables, exportMethod, ";", _progressDialog);

                };
            worker.RunWorkerCompleted += delegate { _progressDialog.Close(); };
            worker.RunWorkerAsync();

            _progressDialog.Worker = worker;
            _progressDialog.ShowDialog();
        }
コード例 #18
0
        public bool readLoadDataFromLog()
        {
            bool curReturnValue = true;
            String inputBuffer = "";
            String curSlalomDelim = "Slalom:ScoreEntry:saveScore";
            String curTrickDelim = "Trick:ScoreCalc:saveTrick";
            String curJumpDelim = "Jump:ScoreEntrySeg3:saveScore";
            StreamReader myReader;
            myProgressInfo = new ProgressWindow();

            try {
                mySanctionNum = Properties.Settings.Default.AppSanctionNum;
                if (mySanctionNum == null) {
                    mySanctionNum = "";
                } else {
                    if (mySanctionNum.Length < 6) {
                        mySanctionNum = "";
                    }
                }
            } catch {
                mySanctionNum = "";
            }

            myReader = getFile();
            if (myReader != null) {
                int curInputLineCount = 0;
                int curDelimPos = 0;
                try {
                    myDbConn = new global::System.Data.SqlServerCe.SqlCeConnection();
                    myDbConn.ConnectionString = Properties.Settings.Default.waterskiConnectionStringApp;

                    DataTable curCountDataTable = buildCountDataTable();
                    while (( inputBuffer = myReader.ReadLine() ) != null) {
                        curInputLineCount++;
                        myProgressInfo.setProgressValue( curInputLineCount );

                        if (inputBuffer.IndexOf( curSlalomDelim ) > 0) {
                            findAndExecRequests( inputBuffer, inputBuffer.IndexOf( curSlalomDelim ), curCountDataTable );
                        } else if (inputBuffer.IndexOf( curTrickDelim ) > 0) {
                            findAndExecRequests( inputBuffer, inputBuffer.IndexOf( curTrickDelim ), curCountDataTable );
                        } else if (inputBuffer.IndexOf( curJumpDelim ) > 0) {
                            findAndExecRequests( inputBuffer, inputBuffer.IndexOf( curJumpDelim ), curCountDataTable );
                        }
                    }

                    StringBuilder curMsg = new StringBuilder( "" );
                    foreach (DataRow curRow in curCountDataTable.Rows) {
                        curMsg.Append( (String)curRow["Table"] + " " + (String)curRow["Command"] + " " + ( (Int32)curRow["Count"] ).ToString() + "\n" );
                    }
                    curCountDataTable.DefaultView.Sort = "Table ASC, Command ASC";
                    curCountDataTable = curCountDataTable.DefaultView.ToTable();
                    MessageBox.Show( curMsg.ToString() );

                } catch (Exception ex) {
                    String ExcpMsg = ex.Message;
                    MessageBox.Show( "Error: Performing SQL operations"
                        + "\n\nError: " + ExcpMsg
                        );
                } finally {
                    myReader.Close();
                    myReader.Dispose();
                }
                myProgressInfo.Close();
            }

            return curReturnValue;
        }
コード例 #19
0
        private Int16 exportBoatTimesSlalom( String inSanctionId, StreamWriter outBuffer )
        {
            String curMethodName = "exportBoatTimesSlalom";
            Int16 curRowCount = 0, curNumRounds = 0, curRowRoundCount = 0, curSkierCount = 0, curRerideCount = 0;
            String curTourClass = "", curEventDateOut = "", prevSkierName = "";
            StringBuilder outLine = new StringBuilder( "" );
            DataTable curSummaryTable, curStatsTable;
            myProgressInfo = new ProgressWindow();

            try {
                curTourClass = myTourRow["Class"].ToString().Trim();
                curEventDateOut = myTourRow["EventDates"].ToString();
                if ( curEventDateOut.Length > 7 ) {
                    try {
                        DateTime curEventDate = Convert.ToDateTime( curEventDateOut );
                        curEventDateOut = curEventDate.ToString( "yyyyMMdd" );
                    } catch {
                        curEventDateOut = "";
                    }
                } else {
                    curEventDateOut = "";
                }

                curNumRounds = Convert.ToInt16( (byte)myTourRow["SlalomRounds"] );
                if ( curNumRounds > 0 ) {
                    StringBuilder curSqlStmt = new StringBuilder( "" );
                    curSqlStmt.Append( "SELECT ListCode, ListCodeNum, SortSeq, CodeValue, MinValue, MaxValue, CodeDesc " );
                    curSqlStmt.Append( "FROM CodeValueList WHERE ListName = 'SlalomBoatTime' ORDER BY SortSeq" );
                    myTimesDataTable = getData( curSqlStmt.ToString() );

                    DataTable curSpeedByPassDataTable, curBoatTimeResults;
                    Int16 curMaxSpeed, curPassNum;
                    Decimal curBoatTime, curScore, curSpeed, curActualTime;
                    String curSkierName, curSpeedDesc, curTimeKey, curTimeKeyScore, curEventClass, curRunTime;
                    DataRow[] curTimeRowsFound;

                    for ( byte curRound = 1; curRound <= curNumRounds; curRound++ ) {
                        curSummaryTable = buildSummaryTable();
                        curStatsTable = buildStatsTable();
                        if ( curRound > 1 ) {
                            outLine = new StringBuilder( Environment.NewLine );
                            outBuffer.WriteLine( outLine.ToString() );
                        }

                        outLine = new StringBuilder( "" );
                        outLine.Append( inSanctionId + curTourClass + "    " + myTourRow["Name"].ToString() + " Slalom  Round " + curRound.ToString() );
                        outBuffer.WriteLine( outLine.ToString() );
                        outLine = new StringBuilder( "" );
                        outLine.Append( "TIME                STANDARD TIMING  ------ Pass Time ------" );
                        outBuffer.WriteLine( outLine.ToString() );
                        outLine = new StringBuilder( "" );
                        outLine.Append( "HHMM SKIER NAME      # SP CL SCORE   -1    5    |    5    1+ " );
                        outBuffer.WriteLine( outLine.ToString() );

                        //Initialize output buffer
                        outLine = new StringBuilder( "" );

                        curSkierCount = 0;
                        curRerideCount = 0;
                        curBoatTimeResults = getSlalomBoatTimeResults( inSanctionId, curRound );
                        if ( curBoatTimeResults != null ) {
                            myProgressInfo.setProgessMsg( "Export slalom boat times " );
                            myProgressInfo.Show();
                            myProgressInfo.Refresh();
                            myProgressInfo.setProgressMax( curBoatTimeResults.Rows.Count );
                            curRowRoundCount = 0;

                            foreach (DataRow curRow in curBoatTimeResults.Rows) {
                                curRowCount++;
                                curRowRoundCount++;
                                myProgressInfo.setProgressValue( curRowRoundCount );
                                myProgressInfo.Refresh();

                                curSkierName = curRow["SkierName"].ToString();
                                if ( curSkierName.Length > 15 ) {
                                    curSkierName = curSkierName.Substring( 0, 15 );
                                }
                                try {
                                    curBoatTime = (Decimal)curRow["BoatTime"];
                                } catch {
                                    curBoatTime = 0;
                                }
                                try {
                                    curScore = ( (Decimal)curRow["PassScore"] );
                                } catch {
                                    curScore = 0;
                                }
                                try {
                                    curPassNum = ( (Byte)curRow["PassNum"] );
                                } catch {
                                    curPassNum = 0;
                                }
                                try {
                                    curEventClass = ( (String)curRow["EventClass"] );
                                } catch {
                                    curEventClass = "";
                                }
                                try {
                                    curRunTime = ((DateTime)curRow["LastUpdateDate"]).ToString( "hhmm" );
                                } catch {
                                    curRunTime = "0000";
                                }
                                try {
                                    if ( curRow["Reride"].ToString().Equals( "Y" ) ) {
                                        curRerideCount++;
                                    }
                                } catch {
                                }
                                try {
                                    curMaxSpeed = ( (Byte)curRow["MaxSpeed"] );
                                    curSpeedByPassDataTable = getSpeedByPass( curMaxSpeed, curPassNum );
                                    if ( curSpeedByPassDataTable.Rows.Count > 0 ) {
                                        curSpeedDesc = (String)curSpeedByPassDataTable.Rows[0]["CodeValue"];
                                        curSpeed = (Decimal)curSpeedByPassDataTable.Rows[0]["MaxValue"];
                                        curTimeKeyScore = curScore.ToString( "0.00" );
                                        curTimeKey = curSpeed.ToString( "00" ) + "-" + getTimeClass(curEventClass) + "-" + curTimeKeyScore.Substring( 0, 1 );
                                        curTimeRowsFound = myTimesDataTable.Select( "ListCode = '" + curTimeKey + "'" );
                                        if ( curTimeRowsFound.Length > 0 ) {
                                            myTimeRow = curTimeRowsFound[0];
                                        } else {
                                            myTimeRow = null;
                                        }
                                        curActualTime = Convert.ToDecimal( (String)myTimeRow["CodeValue"] );
                                    } else {
                                        curSpeed = 0;
                                        curActualTime = 0;
                                        curSpeedDesc = "";
                                        myTimeRow = null;
                                    }

                                } catch {
                                    curActualTime = 0;
                                    curSpeed = 0;
                                    curMaxSpeed = 0;
                                    curSpeedDesc = "";
                                    myTimeRow = null;
                                }

                                if ( prevSkierName == curSkierName ) {
                                    outLine.Append( "".PadRight( 4, ' ' ) ); //Time HHMM (4)
                                    outLine.Append( " " + "".PadRight( 15, ' ' ) ); //Skier Name (15)
                                } else {
                                    curSkierCount++;
                                    outLine.Append( curRunTime ); //Time HHMM (4)
                                    outLine.Append( " " + curSkierName.PadRight( 15, ' ' ) ); //Skier Name (15)
                                }
                                outLine.Append( curPassNum.ToString( "#0" ).PadLeft( 2, ' ' ) ); //Pass Number (2)
                                outLine.Append( " " + curSpeed.ToString( "00" ) ); //Boat Speed KM (2)
                                outLine.Append( " " + curEventClass.PadRight(2, ' ') ); //Skier Event Class (2)
                                outLine.Append( " " + curScore.ToString( "#.00" ).PadLeft( 5, ' ' ) ); //Score for Pass (4)
                                outLine.Append( " " + graphTimeDiff( "1", curBoatTime, curActualTime, curSummaryTable, curStatsTable, curScore.ToString( "#" ) ) );

                                //Write output line to file
                                outBuffer.WriteLine( outLine.ToString() );

                                //Initialize output buffer
                                outLine = new StringBuilder( "" );

                                prevSkierName = curSkierName;
                            }
                            writeSummarySlalom( curSummaryTable, curStatsTable, curBoatTimeResults, curSkierCount, curRerideCount, outBuffer );
                        }
                    }
                }
            } catch ( Exception ex ) {
                MessageBox.Show( "Error: " + curMethodName
                    + "\n\nException: " + ex.Message
                );
            }

            myProgressInfo.Close();
            return curRowCount;
        }
コード例 #20
0
        protected override void RemoveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (dgResults.SelectedItems.Count == 0 || dgResults.SelectedItem == null)
            {
                return;
            }

            OnReloading = true;

            var labs = dgResults.SelectedItems.OfType <Lab>().ToList();

            if (labs.Count > 0)
            {
                var failed       = false;
                var removedCount = 0;
                if (Global.DeleteQuestion(this))
                {
                    var progressResources = new ProgressWindow(labs.Count);
                    progressResources.Show(this);
                    foreach (var lab in labs)
                    {
                        if (LabsService.Instanse.ReferencedToOther(lab.LabID))
                        {
                            if (Global.ReferenceFound(this, LabsResources.Referenced) == MessageBoxResult.Yes)
                            {
                                if (!LabsService.Instanse.Remove(lab))
                                {
                                    failed = true;
                                    Global.DeletionFailed(this);
                                }
                                else
                                {
                                    removedCount++;
                                }
                            }
                        }
                        else if (!LabsService.Instanse.Remove(lab))
                        {
                            failed = true;
                            Global.DeletionFailed(this);
                        }
                        else
                        {
                            removedCount++;
                        }
                        progressResources.IncreaseProgress();
                    }
                    progressResources.Close();
                    if (labs.Count > 1 && failed)
                    {
                        Global.DeletionSuceededWithSomeFailures(this);
                    }
                    else if (removedCount > 0 & !failed)
                    {
                        Global.DeletionSuceeded(this);
                    }
                    ResetFields();
                    TryToLoad();
                }
            }

            OnReloading = false;
        }
コード例 #21
0
        public Boolean ExportData()
        {
            String curMethodName = "ExportData";
            StringBuilder outLine = new StringBuilder( "" );
            bool returnStatus = true;
            int curRowCount = 0, curEntriesWritten = 0 ;
            String curMsg = "";
            String tabDelim = "\t";
            String curValue = "";
            String[] curValueSplit = null;
            DataRow[] curFindRows = null;

            try {
                curMsg = "Exporting boat use data";
                Log.WriteFile( curMethodName + ":begin export" );

                DataTable curAprvManuDataTable = getApprovedManufacturers();
                DataTable curDataTable = getTourBoatUseData();

                String curDateString = DateTime.Now.ToString( "yyyyMMdd HH:MM" );
                String curDateOut = curDateString.Substring( 0, 8 );
                String curTimeOut = curDateString.Substring( 9, 5 );
                String curEventDateOut = (String)myTourRow["EventDates"];
                try {
                    DateTime curEventDate = Convert.ToDateTime( curEventDateOut );
                    curEventDateOut = curEventDate.ToString( "MM/dd/yyyy" );
                } catch {
                    MessageBox.Show( "The event date of " + curEventDateOut + " is not a valid date and must corrected" );
                    curEventDateOut = myTourRow["EventDates"].ToString();
                }

                String curState = "", curCity = "", curSiteName = "";
                try {
                    String[] curEventLocation = ((String)myTourRow["EventLocation"]).Split( ',' );
                    if (curEventLocation.Length == 3) {
                        curSiteName = curEventLocation[0];
                        curCity = curEventLocation[1];
                        curState = curEventLocation[2];
                    } else {
                        MessageBox.Show( "An event location is required."
                            + "\nPlease enter this information on the tournament window in the following format:\n"
                            + "\nSite Name followed by a comma, then the city, followed by a comma, then the 2 character state abbreviation"
                            );
                    }
                } catch {
                    MessageBox.Show( "An event location is required."
                        + "\nPlease enter this information on the tournament window in the following format:\n"
                        + "\nSite Name followed by a comma, then the city, followed by a comma, then the 2 character state abbreviation"
                        );
                }

                Cursor.Current = Cursors.WaitCursor;
                StreamWriter outBuffer = null;

                String curFilename = mySanctionNum + "TU" + ".txt";
                String curReportTitle = "Boat Use data for " + mySanctionNum + " - " + (String)myTourRow["Name"];
                outBuffer = getExportFile( curFilename );

                if (outBuffer == null) {
                    curMsg = "Output file not available";
                } else {
                    Log.WriteFile( "Export boat use data file begin: " + curFilename );
                    myProgressInfo = new ProgressWindow();
                    myProgressInfo.setProgessMsg( "Processing boat use data" );
                    myProgressInfo.Show();
                    myProgressInfo.Refresh();
                    myProgressInfo.setProgressMax( curDataTable.Rows.Count );

                    //Write file header
                    outLine = new StringBuilder( "" );
                    outLine.Append( "SkiYear" + tabDelim );
                    outLine.Append( "SanctionNum" + tabDelim );
                    outLine.Append( "Regions" + tabDelim );
                    outLine.Append( "Tournament Name" + tabDelim );
                    outLine.Append( "Class" + tabDelim );
                    outLine.Append( "City" + tabDelim );
                    outLine.Append( "State" + tabDelim );
                    outLine.Append( "Start Date" + tabDelim );
                    outLine.Append( "Division" + tabDelim );

                    outLine.Append( "Manufacturers" + tabDelim );
                    outLine.Append( "Boat Model" + tabDelim );
                    outLine.Append( "Year" + tabDelim );
                    outLine.Append( "SL" + tabDelim );
                    outLine.Append( "TR" + tabDelim );
                    outLine.Append( "JU" + tabDelim );
                    outLine.Append( "Credit" + tabDelim );
                    outBuffer.WriteLine( outLine.ToString() );

                    //Write available data
                    if (curDataTable.Rows.Count > 0) {
                        String curBoatCode = "", prevBoatCode = "";
                        String curSlalomCredit = "", curTrickCredit = "", curJumpCredit = "", curCredit = "";
                        foreach (DataRow curRow in curDataTable.Rows) {
                            curRowCount++;
                            if ( isObjectEmpty(curRow["HullId"])) {
                                MessageBox.Show( "Towboat data must be updated.  Please open the Boat Use Report and force a data save.  Then you may regenerate this report." );
                            } else {
                                curBoatCode = (String)curRow["HullId"];
                            }

                            if (curBoatCode != prevBoatCode) {
                                if (curRowCount > 1) {
                                    outLine.Append( curSlalomCredit + tabDelim + curTrickCredit + tabDelim + curJumpCredit + tabDelim + curCredit );
                                    outBuffer.WriteLine( outLine.ToString() );
                                    curEntriesWritten++;
                                }

                                curSlalomCredit = "FALSE";
                                curTrickCredit = "FALSE";
                                curJumpCredit = "FALSE";
                                curCredit = "FALSE";

                                outLine = new StringBuilder( "" );
                                outLine.Append( "20" + mySanctionNum.Substring( 0, 2 ) + tabDelim );
                                outLine.Append( "\"" + mySanctionNum + "\"" + tabDelim );
                                curValue = mySanctionNum.Substring( 2, 1 );
                                if (curValue.ToUpper().Equals( "E" )) {
                                    outLine.Append( "EAST" + tabDelim );
                                } else if (curValue.ToUpper().Equals( "W" )) {
                                    outLine.Append( "WEST" + tabDelim );
                                } else if (curValue.ToUpper().Equals( "S" )) {
                                    outLine.Append( "SOUTH" + tabDelim );
                                } else if (curValue.ToUpper().Equals( "C" )) {
                                    outLine.Append( "SOUTHCENTRAL" + tabDelim );
                                } else if (curValue.ToUpper().Equals( "M" )) {
                                    outLine.Append( "MIDWEST" + tabDelim );
                                } else {
                                    outLine.Append( curValue + tabDelim );
                                }
                                outLine.Append( (String)myTourRow["Name"] + tabDelim );
                                outLine.Append( (String)myTourRow["Class"] + tabDelim );
                                outLine.Append( curCity + tabDelim );
                                outLine.Append( curState + tabDelim );
                                outLine.Append( curEventDateOut + tabDelim );
                                outLine.Append( ((String)myTourRow["Rules"]).ToUpper() + tabDelim );

                                curValue = curRow["HullId"].ToString();
                                curFindRows = curAprvManuDataTable.Select( "ListCode = '" + curValue.Substring( 0, 2 ).ToUpper() + "'" );
                                if (curFindRows.Length > 0) {
                                    curValue = (String)curFindRows[0]["CodeValue"];
                                } else {
                                    curValue = curRow["BoatModel"].ToString();
                                    if (curValue.Length > 0) {
                                        curValueSplit = curValue.Split( ' ' );
                                        if (curValueSplit.Length > 0) {
                                            curValue = curValueSplit[0];
                                            if (curValue.ToLower().Equals( "correct" )) {
                                                curValue = "Correct Craft";
                                            } else if (curValue.ToLower().Equals( "master" )) {
                                                curValue = "MasterCraft";
                                            }
                                        } else {
                                            curValue = "Unlisted";
                                        }
                                    } else {
                                        curValue = "Unlisted";
                                    }
                                }
                                outLine.Append( curValue + tabDelim );
                                outLine.Append( curRow["BoatModel"].ToString() + tabDelim );
                                outLine.Append( curRow["ModelYear"].ToString() + tabDelim );
                            }

                            curValue = curRow["slalomCredit"].ToString();
                            if (curValue.Equals( "Y" )) {
                                curSlalomCredit = "TRUE";
                                curCredit = "TRUE";
                            }
                            curValue = curRow["trickCredit"].ToString();
                            if (curValue.Equals( "Y" )) {
                                curTrickCredit = "TRUE";
                                curCredit = "TRUE";
                            }
                            curValue = curRow["jumpCredit"].ToString();
                            if (curValue.Equals( "Y" )) {
                                curJumpCredit = "TRUE";
                                curCredit = "TRUE";
                            }
                            prevBoatCode = curBoatCode;
                            myProgressInfo.setProgressValue( curRowCount );
                            myProgressInfo.Refresh();
                        }
                        if (curRowCount > 0) {
                            outLine.Append( curSlalomCredit + tabDelim + curTrickCredit + tabDelim + curJumpCredit + tabDelim + curCredit );
                            outBuffer.WriteLine( outLine.ToString() );
                            curEntriesWritten++;
                        }
                    }

                    outBuffer.Close();
                    myProgressInfo.Close();
                    if (curDataTable.Rows.Count > 0) {
                        curMsg = curDataTable.Rows.Count + " entries found, " + curEntriesWritten.ToString() + " unique entries selected and written";
                    } else {
                        curMsg = "No rows found";
                    }
                }
                MessageBox.Show( curMsg );
                Log.WriteFile( curMethodName + ":conplete: " + curMsg );
            } catch (Exception ex) {
                MessageBox.Show( "Error:" + curMethodName + " Could not write to file\n\nError: " + ex.Message );
                curMsg = curMethodName + ":Exception=" + ex.Message;
                Log.WriteFile( curMsg );
                returnStatus = false;
            }

            return returnStatus;
        }
コード例 #22
0
        public Boolean exportScoreBookData()
        {
            String curMethodName = "exportScoreBookHtml";
            Boolean returnStatus = false;
            StringBuilder outLine = new StringBuilder( "" );
            String curMsg = "", curMemberId = "", curAgeGroup = "", prevMemberId = "", prevAgeGroup = "", curReadyToSki = "";
            String curFileFilter = "HTML files (*.htm)|*.htm|All files (*.*)|*.*";
            Int16 curRound = 0;
            DataRow prevRow = null;
            DataRow[] curScoreSlalomRows = null, curScoreTrickRows = null, curScoreJumpRows = null;
            myTourProperties = TourProperties.Instance;

            ExportScorebookTypeDialogForm curDialogForm = new ExportScorebookTypeDialogForm();
            curDialogForm.ShowDialog();
            if ( curDialogForm.DialogResult == DialogResult.OK ) {
                String curReportFormat = curDialogForm.ReportFormat;
                if ( curReportFormat.Equals( "Magazine" ) ) {
                    Tools.ExportScorebookPublishFmt myExportDataReport = new ExportScorebookPublishFmt();
                    myExportDataReport.ExportScorebookPublishFmtData();
                    returnStatus = true;
                } else {
                    try {
                        curMsg = "Exporting Scorebook Html";
                        Log.WriteFile( curMethodName + ":begin: " + curMsg );

                        mySkierClassList = new ListSkierClass();
                        mySkierClassList.ListSkierClassLoad();

                        String curFilename = mySanctionNum.Trim() + "CS.HTM";
                        StreamWriter outBuffer = getExportFile( curFileFilter, curFilename );

                        if ( outBuffer == null ) {
                            curMsg = "Output file not available";
                        } else {
                            String curPlcmtMethod = "score", curPlcmtOverallOrg = "agegroup";
                            String curDataType = myTourProperties.MasterSummaryDataType;
                            //String curDataType = Properties.Settings.Default.MasterSummaryV2DataType;
                            if ( curDataType.ToLower().Equals( "total" )
                                || curDataType.ToLower().Equals( "best" )
                                || curDataType.ToLower().Equals( "final" )
                                || curDataType.ToLower().Equals( "first" ) ) {
                            } else {
                                curDataType = "best";
                            }
                            String curPointsMethod = myTourProperties.MasterSummaryPointsMethod;
                            //String curPointsMethod = Properties.Settings.Default.MasterSummaryV2PointsMethod;
                            if (curPointsMethod.ToLower().Equals( "nops" )
                                || curPointsMethod.ToLower().Equals( "plcmt" )
                                || curPointsMethod.ToLower().Equals( "kbase" )
                                || curPointsMethod.ToLower().Equals( "ratio" )) {
                            } else {
                                curPointsMethod = "nops";
                            }

                            String curPlcmtOrg = myTourProperties.MasterSummaryPlcmtOrg;
                            //String curPlcmtOrg = Properties.Settings.Default.MasterSummaryV2PlcmtOrg;
                            if ( curPlcmtOrg.ToLower().Equals( "div" ) ) {
                                curPlcmtOverallOrg = "agegroup";
                            } else if ( curPlcmtOrg.ToLower().Equals( "divgr" ) ) {
                                curPlcmtOverallOrg = "agegroupgroup";
                            } else {
                                curPlcmtOverallOrg = "agegroup";
                                curPlcmtOrg = "div";
                            }

                            myProgressInfo = new ProgressWindow();
                            myProgressInfo.setProgessMsg( "Processing Scorebook HTML" );
                            myProgressInfo.Show();
                            myProgressInfo.Refresh();
                            myProgressInfo.setProgressMax( 10 );
                            CalcScoreSummary curCalcSummary = new CalcScoreSummary();

                            DataTable mySlalomDataTable = curCalcSummary.getSlalomSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod );
                            myProgressInfo.setProgressValue( 1 );
                            myProgressInfo.Refresh();
                            DataTable myTrickDataTable = curCalcSummary.getTrickSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod );
                            myProgressInfo.setProgressValue( 2 );
                            myProgressInfo.Refresh();
                            DataTable myJumpDataTable = curCalcSummary.getJumpSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod );
                            myProgressInfo.setProgressValue( 3 );
                            myProgressInfo.Refresh();
                            DataTable myOverallDataTable = curCalcSummary.buildOverallSummary( myTourRow, mySlalomDataTable, myTrickDataTable, myJumpDataTable, curDataType, curPlcmtOverallOrg );
                            myProgressInfo.setProgressValue( 4 );
                            myProgressInfo.Refresh();

                            DataTable myMemberData = curCalcSummary.getMemberData( mySanctionNum );
                            myProgressInfo.setProgressValue( 5 );
                            myProgressInfo.Refresh();

                            DataTable mySlalomDetail = curCalcSummary.getSlalomScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                            myProgressInfo.setProgressValue( 6 );
                            myProgressInfo.Refresh();
                            DataTable myTrickDetail = curCalcSummary.getTrickScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                            myProgressInfo.setProgressValue( 7 );
                            myProgressInfo.Refresh();
                            DataTable myJumpDetail = curCalcSummary.getJumpScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                            myProgressInfo.setProgressValue( 8 );
                            myProgressInfo.Refresh();

                            DataTable mySummaryDataTable = curCalcSummary.buildTourScorebook( mySanctionNum, myTourRow, myMemberData, myOverallDataTable, mySlalomDetail, myTrickDetail, myJumpDetail );
                            myProgressInfo.setProgressValue( 9 );
                            myProgressInfo.Refresh();

                            myProgressInfo.setProgressMax( mySummaryDataTable.Rows.Count );
                            myProgressInfo.Refresh();

                            //Build file header line and write to file
                            writeHeader( outBuffer, curPlcmtOrg );

                            if ( curReportFormat.Equals( "Index" ) ) {
                                //Build index header
                                writeIndexHeader( outBuffer, curPlcmtOrg, mySlalomDataTable, myTrickDataTable, myJumpDataTable, myOverallDataTable );
                            }
                            //Build master summary header
                            writeMasterSummaryHeader( outBuffer, curPlcmtOrg );
                            int curRowCount = 0;
                            foreach ( DataRow curRow in mySummaryDataTable.Rows ) {
                                curRowCount++;
                                myProgressInfo.setProgressValue( curRowCount );
                                myProgressInfo.Refresh();

                                curMemberId = curRow["MemberId"].ToString();
                                curAgeGroup = curRow["AgeGroup"].ToString();
                                curReadyToSki = curRow["ReadyToSki"].ToString();
                                if ( curMemberId != prevMemberId || curAgeGroup != prevAgeGroup ) {
                                    curScoreSlalomRows = mySlalomDataTable.Select( "MemberId = '" + curMemberId + "' AND AgeGroup = '" + curAgeGroup + "'" );
                                    curScoreTrickRows = myTrickDataTable.Select( "MemberId = '" + curMemberId + "' AND AgeGroup = '" + curAgeGroup + "'" );
                                    curScoreJumpRows = myJumpDataTable.Select( "MemberId = '" + curMemberId + "' AND AgeGroup = '" + curAgeGroup + "'" );
                                }

                                //Initialize control fields
                                prevMemberId = curMemberId;
                                prevAgeGroup = curAgeGroup;
                                curRound = (Int16)curRow["Round"];

                                //Initialize output buffer
                                outLine = new StringBuilder( "<tr>" );

                                //Write skier identification information
                                writeSkierInfo( curRow, curRound, outBuffer );

                                //Write skier performance summary information
                                writeSkierSlalomScore( curRow, curScoreSlalomRows, curPlcmtOrg, outBuffer );

                                writeSkierTrickScore( curRow, curScoreTrickRows, curPlcmtOrg, outBuffer );

                                writeSkierJumpScore( curRow, curScoreJumpRows, curPlcmtOrg, outBuffer );

                                writeSkierOverallScore( curRow, outBuffer );

                                //Write output line to file
                                outLine = new StringBuilder( "</tr>" );
                                outBuffer.WriteLine( outLine.ToString() );
                            }
                            outLine = new StringBuilder( "</table>" );
                            outBuffer.WriteLine( outLine.ToString() );

                            if ( curReportFormat.Equals( "Index" ) ) {
                                outLine = new StringBuilder( "<br/><br/><a href=#PageTop>Return to Index</a><br/></div>" );
                                outBuffer.WriteLine( outLine.ToString() );

                                writeIndexSlalomResults( curPlcmtOrg, mySlalomDataTable, outBuffer );
                                writeIndexTrickResults( curPlcmtOrg, myTrickDataTable, outBuffer );
                                writeIndexJumpResults( curPlcmtOrg, myJumpDataTable, outBuffer );
                                writeIndexOverallResults( curPlcmtOrg, myOverallDataTable, outBuffer );

                                Boolean curTeamsAvailble = isTeamAvailable();
                                //if ( this.myTourClass.Equals("B") || this.myTourClass.Equals("A") ) {
                                //    curTeamsAvailble = false;
                                //}

                                if ( curTeamsAvailble ) {
                                    Int16 myNumPerTeam = Convert.ToInt16( myTourProperties.TeamSummary_NumPerTeam);
                                    String curTeamPlcmtOrg = myTourProperties.TeamSummaryPlcmtOrg;
                                    //String curTeamPlcmtOrg = Properties.Settings.Default.TeamSummaryPlcmtOrg;
                                    if (curTeamPlcmtOrg.ToLower().Equals( "tour" )
                                        || curTeamPlcmtOrg.ToLower().Equals( "div" )) {
                                    } else {
                                        curTeamPlcmtOrg = "tour";
                                    }
                                    String curTeamPlcmtMethod = "points";
                                    String curTeamDataType = myTourProperties.TeamSummaryDataType;
                                    //String curTeamDataType = Properties.Settings.Default.TeamSummaryDataType;
                                    if (curTeamDataType.ToLower().Equals( "total" )
                                        || curTeamDataType.ToLower().Equals( "best" )
                                        || curTeamDataType.ToLower().Equals( "final" )
                                        || curTeamDataType.ToLower().Equals( "first" )) {
                                    } else {
                                        curTeamDataType = "best";
                                    }
                                    String curTeamPointsMethod = myTourProperties.TeamSummaryPointsMethod;
                                    //String curTeamPointsMethod = Properties.Settings.Default.MasterSummaryV2PointsMethod;
                                    if (curTeamPointsMethod.ToLower().Equals( "nops" )
                                        || curTeamPointsMethod.ToLower().Equals( "plcmt" )
                                        || curTeamPointsMethod.ToLower().Equals( "kbase" )
                                        || curTeamPointsMethod.ToLower().Equals( "ratio" )) {
                                    } else {
                                        curTeamPointsMethod = "nops";
                                    }

                                    if ( this.myTourClass.Equals("B") || this.myTourClass.Equals("A") ) {
                                        curTeamPointsMethod = "nops";
                                        curTeamDataType = "best";
                                        curTeamPlcmtOrg = "awsa";
                                        curTeamPlcmtMethod = "points";
                                        myNumPerTeam = 4;
                                    }

                                    String curGroupValue = "all";
                                    mySlalomDataTable = curCalcSummary.getSlalomSummary(myTourRow, curTeamDataType, curTeamPlcmtMethod, curTeamPlcmtOrg, curTeamPointsMethod, "Team", curGroupValue);
                                    myTrickDataTable = curCalcSummary.getTrickSummary(myTourRow, curTeamDataType, curTeamPlcmtMethod, curTeamPlcmtOrg, curTeamPointsMethod, "Team", curGroupValue);
                                    myJumpDataTable = curCalcSummary.getJumpSummary(myTourRow, curTeamDataType, curTeamPlcmtMethod, curTeamPlcmtOrg, curTeamPointsMethod, "Team", curGroupValue);

                                    DataTable myTeamDataTable = null;
                                    myTeamDataTable = curCalcSummary.getSlalomSummaryTeam(mySlalomDataTable, myTourRow, myNumPerTeam, curTeamDataType, curTeamPlcmtMethod, curTeamPlcmtOrg, curTeamPointsMethod);
                                    myTeamDataTable = curCalcSummary.getTrickSummaryTeam(myTeamDataTable, myTrickDataTable, myTourRow, myNumPerTeam, curTeamDataType, curTeamPlcmtMethod, curTeamPlcmtOrg, curTeamPointsMethod);
                                    myTeamDataTable = curCalcSummary.getJumpSummaryTeam(myTeamDataTable, myJumpDataTable, myTourRow, myNumPerTeam, curTeamDataType, curTeamPlcmtMethod, curTeamPlcmtOrg, curTeamPointsMethod);
                                    if ( curTeamPlcmtOrg.ToLower().Equals("tour") ) {
                                        myTeamDataTable = curCalcSummary.CalcTeamCombinedSummary(myTourRow, mySlalomDataTable, myTrickDataTable, myJumpDataTable, myNumPerTeam);
                                    }

                                    if ( myTourClass.Equals("B") || myTourClass.Equals("A") ) {
                                        mySlalomDataTable = curCalcSummary.CalcTeamAwsaEventPoints(mySlalomDataTable, "Slalom");
                                        myTrickDataTable = curCalcSummary.CalcTeamAwsaEventPoints(myTrickDataTable, "Trick");
                                        myJumpDataTable = curCalcSummary.CalcTeamAwsaEventPoints(myJumpDataTable, "Jump");
                                        myTeamDataTable = curCalcSummary.CalcTeamAwsaCombinedSummary(myTourRow, mySlalomDataTable, myTrickDataTable, myJumpDataTable, myNumPerTeam);
                                        writeIndexTeamResults(myTeamDataTable, myNumPerTeam, curTeamPlcmtOrg, outBuffer);
                                        writeIndexTeamDetailResults(mySlalomDataTable, myTrickDataTable, myJumpDataTable, myNumPerTeam, curTeamPlcmtOrg, outBuffer);
                                    } else {
                                        writeIndexTeamResults(myTeamDataTable, myNumPerTeam, curTeamPlcmtOrg, outBuffer);
                                    }
                                }
                            } else {
                                outLine = new StringBuilder( "</div>" );
                                outBuffer.WriteLine( outLine.ToString() );
                            }

                            //Build file footer and write to file
                            writeFooter( outBuffer );
                            outLine = new StringBuilder( "" );
                            outBuffer.WriteLine( outLine.ToString() );

                            returnStatus = true;
                            outBuffer.Close();

                            myProgressInfo.Close();
                            if ( mySummaryDataTable.Rows.Count > 0 ) {
                                curMsg = mySummaryDataTable.Rows.Count + " skiers found and written";
                            } else {
                                curMsg = "No rows found";
                            }
                        }
                        MessageBox.Show( curMsg );
                        Log.WriteFile( curMethodName + ":conplete: " + curMsg );
                    } catch ( Exception ex ) {
                        MessageBox.Show( "Error:" + curMethodName + " Error writing scorebook html file\n\nError: " + ex.Message );
                        curMsg = curMethodName + ":Exception=" + ex.Message;
                        Log.WriteFile( curMsg );
                        returnStatus = false;
                    }
                }
            } else {
                returnStatus = false;
            }

            return returnStatus;
        }
コード例 #23
0
        public Boolean exportScoreBookData()
        {
            String curMethodName = "exportScoreBookData";
            Boolean returnStatus = false;
            StringBuilder outLine = new StringBuilder( "" );
            String curMsg = "", curMemberId = "", curAgeGroup = "", prevMemberId = "", prevAgeGroup = "", curReadyToSki = "";
            String curFileFilter = "SBK files (*.sbk)|*.sbk|All files (*.*)|*.*";
            Int16 curRound = 0;
            DataRow prevRow = null;
            DataRow[] curScoreRows = null;
            myTourProperties = TourProperties.Instance;

            try {
                curMsg = "Exporting Scorebook";
                Log.WriteFile( curMethodName + ":begin: " + curMsg );
                String curFilename = mySanctionNum.Trim() + myTourClass + ".sbk";
                StreamWriter outBuffer = getExportFile( curFileFilter, curFilename );

                if (outBuffer == null) {
                    curMsg = "Output file not available";
                } else {
                    String curPlcmtMethod = "score", curPlcmtOverallOrg = "agegroup";
                    String curDataType = myTourProperties.MasterSummaryDataType;
                    //String curDataType = Properties.Settings.Default.MasterSummaryV2DataType;
                    if ( curDataType.ToLower().Equals( "total" )
                        || curDataType.ToLower().Equals( "best" )
                        || curDataType.ToLower().Equals( "final" )
                        || curDataType.ToLower().Equals( "first" ) ) {
                    } else {
                        curDataType = "best";
                    }
                    String curPointsMethod = myTourProperties.MasterSummaryPointsMethod;
                    //String curPointsMethod = Properties.Settings.Default.MasterSummaryV2PointsMethod;
                    if ( curPointsMethod.ToLower().Equals( "nops" )
                        || curPointsMethod.ToLower().Equals( "plcmt" )
                        || curPointsMethod.ToLower().Equals( "kbase" )
                        || curPointsMethod.ToLower().Equals( "ratio" ) ) {
                    } else {
                        curPointsMethod = "nops";
                    }
                    String curPlcmtOrg = myTourProperties.MasterSummaryPlcmtOrg;
                    //String curPlcmtOrg = Properties.Settings.Default.MasterSummaryV2PlcmtOrg;
                    if ( curPlcmtOrg.ToLower().Equals( "div" ) ) {
                        curPlcmtOverallOrg = "agegroup";
                    } else if ( curPlcmtOrg.ToLower().Equals( "divgr" ) ) {
                        curPlcmtOverallOrg = "agegroupgroup";
                    } else {
                        curPlcmtOverallOrg = "agegroup";
                        curPlcmtOrg = "div";
                    }

                    myProgressInfo = new ProgressWindow();
                    myProgressInfo.setProgessMsg( "Processing Scorebook" );
                    myProgressInfo.Show();
                    myProgressInfo.Refresh();
                    myProgressInfo.setProgressMax( 10 );

                    CalcScoreSummary curCalcSummary = new CalcScoreSummary();
                    mySummaryDataTable = null;

                    DataTable myMemberData = curCalcSummary.getMemberData( mySanctionNum );
                    myProgressInfo.setProgressValue( 1 );
                    myProgressInfo.Refresh();

                    if (myTourRules.ToLower().Equals( "iwwf" )) {
                        mySummaryDataTable = curCalcSummary.CalcIwwfEventPlcmts( myTourRow, mySanctionNum, "Scorebook", myTourRules, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                        myProgressInfo.setProgressValue( 2 );
                        myProgressInfo.Refresh();

                        DataTable mySlalomDetail = curCalcSummary.getSlalomScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                        myProgressInfo.setProgressValue( 6 );
                        myProgressInfo.Refresh();
                        DataTable myTrickDetail = curCalcSummary.getTrickScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                        myProgressInfo.setProgressValue( 7 );
                        myProgressInfo.Refresh();
                        DataTable myJumpDetail = curCalcSummary.getJumpScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                        myProgressInfo.setProgressValue( 8 );
                        myProgressInfo.Refresh();
                        DataTable newSummaryDataTable = curCalcSummary.buildTourScorebook( mySanctionNum, myTourRow, myMemberData, mySummaryDataTable, mySlalomDetail, myTrickDetail, myJumpDetail );
                        mySummaryDataTable = newSummaryDataTable;
                        myProgressInfo.setProgressValue( 9 );
                        myProgressInfo.Refresh();

                    } else {
                        DataTable mySlalomDataTable = curCalcSummary.getSlalomSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod );
                        myProgressInfo.setProgressValue( 1 );
                        myProgressInfo.Refresh();
                        DataTable myTrickDataTable = curCalcSummary.getTrickSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod );
                        myProgressInfo.setProgressValue( 2 );
                        myProgressInfo.Refresh();
                        DataTable myJumpDataTable = curCalcSummary.getJumpSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod );
                        myProgressInfo.setProgressValue( 3 );
                        myProgressInfo.Refresh();
                        mySummaryDataTable = curCalcSummary.buildOverallSummary( myTourRow, mySlalomDataTable, myTrickDataTable, myJumpDataTable, curDataType, curPlcmtOverallOrg );
                        myProgressInfo.setProgressValue( 4 );
                        myProgressInfo.Refresh();

                        DataTable mySlalomDetail = curCalcSummary.getSlalomScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                        myProgressInfo.setProgressValue( 6 );
                        myProgressInfo.Refresh();
                        DataTable myTrickDetail = curCalcSummary.getTrickScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                        myProgressInfo.setProgressValue( 7 );
                        myProgressInfo.Refresh();
                        DataTable myJumpDetail = curCalcSummary.getJumpScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                        myProgressInfo.setProgressValue( 8 );
                        myProgressInfo.Refresh();

                        mySummaryDataTable = curCalcSummary.buildTourScorebook( mySanctionNum, myTourRow, myMemberData, mySummaryDataTable, mySlalomDetail, myTrickDetail, myJumpDetail );
                        myProgressInfo.setProgressValue( 9 );
                        myProgressInfo.Refresh();
                    }

                    myProgressInfo.setProgressMax( mySummaryDataTable.Rows.Count );
                    myProgressInfo.Refresh();

                    //Build file header line and write to file
                    writeHeader( outBuffer );

                    int curRowCount = 0;
                    foreach ( DataRow curRow in mySummaryDataTable.Rows ) {
                        curRowCount++;
                        myProgressInfo.setProgressValue( curRowCount );
                        myProgressInfo.Refresh();

                        curMemberId = curRow["MemberId"].ToString();
                        curAgeGroup = curRow["AgeGroup"].ToString();
                        curReadyToSki = curRow["ReadyToSki"].ToString();
                        if ( curMemberId != prevMemberId || curAgeGroup != prevAgeGroup ) {
                            outLine = new StringBuilder( "" );
                            outBuffer.WriteLine( outLine.ToString() );
                            curScoreRows = mySummaryDataTable.Select( "MemberId = '" + curMemberId + "' AND AgeGroup = '" + curAgeGroup + "'" );
                        }

                        //Initialize control fields
                        prevMemberId = curMemberId;
                        prevAgeGroup = curAgeGroup;
                        curRound = (Int16)curRow["RoundOverall"];

                        //Initialize output buffer
                        outLine = new StringBuilder( "" );

                        //Write skier identification information
                        outLine.Append( writeSkierInfo( curRow, curRound ) );

                        //Write skier performance summary information
                        outLine.Append( writeSkierSlalomScore( curRow, curScoreRows ) );

                        outLine.Append( writeSkierTrickScore( curRow, curScoreRows ) );

                        outLine.Append( writeSkierJumpScore( curRow, curScoreRows ) );

                        outLine.Append( writeSkierOverallScore( curRow ) );
                        //Write output line to file
                        outBuffer.WriteLine( outLine.ToString() );
                    }

                    //Build file footer and write to file
                    outLine = new StringBuilder( "" );
                    outBuffer.WriteLine( outLine.ToString() );
                    outLine.Append( writeFooter() );
                    outBuffer.WriteLine( outLine.ToString() );

                    returnStatus = true;
                    outBuffer.Close();

                    myProgressInfo.Close();
                    if ( mySummaryDataTable.Rows.Count > 0 ) {
                        curMsg = mySummaryDataTable.Rows.Count + " skiers found and written";
                    } else {
                        curMsg = "No rows found";
                    }
                }
                MessageBox.Show( curMsg );
                Log.WriteFile( curMethodName + ":complete: " + curMsg );
            } catch ( Exception ex ) {
                MessageBox.Show( "Error:" + curMethodName + " Could not write file from DataGridView\n\nError: " + ex.Message );
                curMsg = curMethodName + ":Exception=" + ex.Message;
                Log.WriteFile( curMsg );
                returnStatus = false;
            }

            return returnStatus;
        }
コード例 #24
0
        public static void ZipFiles( string inputFolderPath, string outputPathAndFile, string password, ArrayList inFileFilterList )
        {
            /* ------------------------------------------------------
             ------------------------------------------------------ */
            // generate file list
            ArrayList curFileList = GenerateFileList( inputFolderPath );

            // find number of chars to remove from orginal file path
            //int TrimLength = ( Directory.GetParent( inputFolderPath ) ).ToString().Length;
            int TrimLength = inputFolderPath.Length;
            if ( !(inputFolderPath.Substring( inputFolderPath.Length - 1 ).Equals( "\\" )) ) {
                TrimLength++;
            }
            //TrimLength += 1; //remove '\'

            FileStream curOutputStream;
            byte[] curOutputBuffer;
            string outPath = inputFolderPath + @"\" + outputPathAndFile;

            // create zip stream
            ZipOutputStream curOutputZipStream = new ZipOutputStream( File.Create( outPath ) );
            if ( password != null && password != String.Empty )
                curOutputZipStream.Password = password;

            // maximum compression
            curOutputZipStream.SetLevel( 9 );
            ZipEntry oZipEntry;
            //oZipEntry.ExternalFileAttributes;
            //oZipEntry.

            ProgressWindow curProgressInfo = new ProgressWindow();
            curProgressInfo.setProgressMin( 1 );
            curProgressInfo.setProgressMax( curFileList.Count );
            int curFileCount = 0;
            int curFileIndex = 0;
            String curFileNameOnly, curIwwfHomFileName = "";

            // for each file, generate a zipentry
            foreach (string curFileFilter in inFileFilterList) {
                curFileIndex = 1;
                if (curFileFilter.EndsWith( "hd.txt" )) {
                    curIwwfHomFileName = curFileFilter.ToUpper();
                }
                foreach (string curFileName in curFileList) {
                    curFileNameOnly = curFileName.Remove( 0, TrimLength );

                    if (System.Text.RegularExpressions.Regex.IsMatch( curFileNameOnly, curFileFilter, System.Text.RegularExpressions.RegexOptions.IgnoreCase )) {
                        //MessageBox.Show( "Index=" + curFileIndex + ", FileName=" + curFileNameOnly + ", File Filter=" + curFileFilter );
                        if (curFileFilter.Equals( ".hom$" )) {
                            curFileNameOnly = curIwwfHomFileName;
                        }

                        curFileCount++;
                        curProgressInfo.setProgessMsg( "Processing " + curFileName );
                        curProgressInfo.setProgressValue( curFileCount );
                        curProgressInfo.Show();
                        curProgressInfo.Refresh();

                        oZipEntry = new ZipEntry( ( curFileNameOnly ) );
                        oZipEntry.DateTime = File.GetLastWriteTime( curFileName );
                        curOutputZipStream.PutNextEntry( oZipEntry );

                        // if a file ends with '/' its a directory
                        if (!curFileName.EndsWith( @"/" )) {
                            try {
                                curOutputStream = File.OpenRead( curFileName );
                                curOutputBuffer = new byte[curOutputStream.Length];
                                curOutputStream.Read( curOutputBuffer, 0, curOutputBuffer.Length );
                                curOutputZipStream.Write( curOutputBuffer, 0, curOutputBuffer.Length );
                                curOutputStream.Close();
                            } catch (Exception ex) {
                                curProgressInfo.setProgessMsg( "Bypassing busy file " + curFileName );
                                curProgressInfo.Show();
                                curProgressInfo.Refresh();
                            }
                        }
                    }
                    curFileIndex++;
                }
            }

            curOutputZipStream.Finish();
            curOutputZipStream.Close();
            curProgressInfo.Close();
        }
コード例 #25
0
        public Boolean exportBoatTimes(String inSanctionId)
        {
            Boolean       returnStatus = false, curActiveTour = false;
            char          DoubleQuote = '"';
            String        curMemberId = "", curEventDateOut = "";
            StringBuilder outLine   = new StringBuilder("");
            StreamWriter  outBuffer = null;

            myProgressInfo = new ProgressWindow();

            DataTable curTourDataTable = getTourData(inSanctionId);

            if (curTourDataTable != null)
            {
                if (curTourDataTable.Rows.Count > 0)
                {
                    curActiveTour = true;
                    myTourRow     = curTourDataTable.Rows[0];
                    myTourClass   = myTourRow["Class"].ToString().ToUpper();
                    String curFilename = inSanctionId.Trim() + "ST.csv";
                    outBuffer = getExportFile(curFilename);

                    curEventDateOut = myTourRow["EventDates"].ToString();
                    if (curEventDateOut.Length > 7)
                    {
                        try {
                            DateTime curEventDate = Convert.ToDateTime(curEventDateOut);
                            curEventDateOut = curEventDate.ToString("yyyyMMdd");
                        } catch {
                            curEventDateOut = "";
                        }
                    }
                    else
                    {
                        curEventDateOut = "";
                    }
                }
            }

            if (curActiveTour)
            {
                StringBuilder curSqlStmt = new StringBuilder("");
                curSqlStmt.Append("SELECT ListCode, ListCodeNum, SortSeq, CodeValue, MinValue, MaxValue, CodeDesc ");
                curSqlStmt.Append("FROM CodeValueList WHERE ListName = 'SlalomBoatTime' ORDER BY SortSeq");
                myTimesDataTable = getData(curSqlStmt.ToString());

                mySkierClassList = new ListSkierClass();
                mySkierClassList.ListSkierClassLoad();
                myClassCRow = mySkierClassList.SkierClassDataTable.Select("ListCode = 'C'")[0];
                myClassERow = mySkierClassList.SkierClassDataTable.Select("ListCode = 'E'")[0];

                DataTable curSpeedByPassDataTable;
                Int16     curMaxSpeed, curPassNum, curRound;
                Decimal   curBoatTime, curScore, curSpeed, curActualTime;
                String    curSpeedDesc, curTimeKey, curTimeKeyScore, curEventClass, curRunTime;
                DataRow[] curTimeRowsFound;
                if (outBuffer != null)
                {
                    outLine.Append("Sanction");
                    outLine.Append(", Skier Class");
                    outLine.Append(", Boat");
                    outLine.Append(", EventDate");
                    outLine.Append(", Time");
                    outLine.Append(", SkierName");
                    outLine.Append(", Div");
                    outLine.Append(", MaxSpeed");
                    outLine.Append(", Round");
                    outLine.Append(", PassNum");
                    outLine.Append(", PassDesc");
                    outLine.Append(", PassScore");
                    outLine.Append(", BoatTime");
                    outLine.Append(", ActualTime");

                    //Write output line to file
                    outBuffer.WriteLine(outLine.ToString());
                    outLine = new StringBuilder("");

                    myProgressInfo.setProgessMsg("Export slalom boat times ");
                    myProgressInfo.Show();
                    myProgressInfo.Refresh();
                    int curRowCount = 0;

                    DataTable curBoatTimeResults = getBoatTimeResults(inSanctionId);
                    if (curBoatTimeResults != null)
                    {
                        myProgressInfo.setProgressMax(curBoatTimeResults.Rows.Count);
                        foreach (DataRow curRow in curBoatTimeResults.Rows)
                        {
                            curRowCount++;
                            myProgressInfo.setProgressValue(curRowCount);
                            myProgressInfo.Refresh();

                            try {
                                curBoatTime = (Decimal)curRow["BoatTime"];
                            } catch {
                                curBoatTime = 0;
                            }
                            try {
                                curScore = ((Decimal)curRow["PassScore"]);
                            } catch {
                                curScore = 0;
                            }
                            try {
                                curRound = ((Byte)curRow["Round"]);
                            } catch {
                                curRound = 0;
                            }
                            try {
                                curPassNum = ((Byte)curRow["PassNum"]);
                            } catch {
                                curPassNum = 0;
                            }
                            try {
                                curEventClass = ((String)curRow["EventClass"]);
                            } catch {
                                curEventClass = "";
                            }
                            try {
                                curRunTime = ((DateTime)curRow["LastUpdateDate"]).ToString("hhmm");
                            } catch {
                                curRunTime = "0000";
                            }
                            try {
                                curMaxSpeed             = ((Byte)curRow["MaxSpeed"]);
                                curSpeedByPassDataTable = getSpeedByPass(curMaxSpeed, curPassNum);
                                if (curSpeedByPassDataTable.Rows.Count > 0)
                                {
                                    curSpeedDesc     = (String)curSpeedByPassDataTable.Rows[0]["CodeValue"];
                                    curSpeed         = (Decimal)curSpeedByPassDataTable.Rows[0]["MaxValue"];
                                    curTimeKeyScore  = curScore.ToString("0.00");
                                    curTimeKey       = curSpeed.ToString("00") + "-" + getTimeClass(curEventClass) + "-" + curTimeKeyScore.Substring(0, 1);
                                    curTimeRowsFound = myTimesDataTable.Select("ListCode = '" + curTimeKey + "'");
                                    if (curTimeRowsFound.Length > 0)
                                    {
                                        myTimeRow = curTimeRowsFound[0];
                                    }
                                    else
                                    {
                                        myTimeRow = null;
                                    }
                                    curActualTime = Convert.ToDecimal((String)myTimeRow["CodeValue"]);
                                }
                                else
                                {
                                    curSpeed      = 0;
                                    curActualTime = 0;
                                    curSpeedDesc  = "";
                                    myTimeRow     = null;
                                }
                            } catch {
                                curActualTime = 0;
                                curSpeed      = 0;
                                curMaxSpeed   = 0;
                                curSpeedDesc  = "";
                                myTimeRow     = null;
                            }

                            outLine.Append(DoubleQuote.ToString() + inSanctionId + myTourClass + DoubleQuote.ToString());                             // 1. (7) SanctionId with class
                            outLine.Append("," + DoubleQuote.ToString() + curRow["EventClass"].ToString() + DoubleQuote.ToString());                  // 2. (1) Skier Class
                            outLine.Append("," + DoubleQuote.ToString() + curRow["Boat"].ToString().PadRight(11, ' ') + DoubleQuote.ToString());      // 3. (11) Boat
                            outLine.Append("," + DoubleQuote.ToString() + curEventDateOut + DoubleQuote.ToString());                                  // 4. (8) Date YYYYMMDD
                            outLine.Append("," + DoubleQuote.ToString() + curRunTime + DoubleQuote.ToString());                                       // 5. (4) Time HHMM
                            outLine.Append("," + DoubleQuote.ToString() + curRow["SkierName"].ToString().PadRight(22, ' ') + DoubleQuote.ToString()); // 6. (22) Skier Name
                            outLine.Append("," + DoubleQuote.ToString() + curRow["AgeGroup"].ToString() + DoubleQuote.ToString());                    // 7. (2) Age Division
                            outLine.Append("," + DoubleQuote.ToString() + curMaxSpeed.ToString("#0").PadLeft(2, ' ') + DoubleQuote.ToString());       // 8. (2) Max Speed for division
                            outLine.Append("," + DoubleQuote.ToString() + curRound.ToString("#0").PadLeft(2, ' ') + DoubleQuote.ToString());          // 9. (2) Round
                            outLine.Append("," + DoubleQuote.ToString() + curPassNum.ToString("#0").PadLeft(2, ' ') + DoubleQuote.ToString());        // 10. (2) Pass Number
                            outLine.Append("," + DoubleQuote.ToString() + curSpeedDesc.PadRight(28, ' ') + DoubleQuote.ToString());                   // 11. (28) Boat Speed Desc
                            outLine.Append("," + DoubleQuote.ToString() + curScore.ToString("#.00").PadLeft(4, ' ') + DoubleQuote.ToString());        //10. (4) Score for Pass
                            outLine.Append("," + curBoatTime.ToString("##.00"));                                                                      //12. (5 Num) Boat Time
                            outLine.Append("," + curActualTime.ToString("##.00"));                                                                    //13. (5 Num) Actual Time

                            //Write output line to file
                            outBuffer.WriteLine(outLine.ToString());

                            //Initialize output buffer
                            outLine = new StringBuilder("");
                        }
                        myProgressInfo.Close();
                    }

                    returnStatus = true;
                    outBuffer.Close();

                    if (curBoatTimeResults.Rows.Count > 0)
                    {
                        MessageBox.Show(curBoatTimeResults.Rows.Count + " rows found and written");
                    }
                    else
                    {
                        MessageBox.Show("No rows found");
                    }
                }
            }

            return(returnStatus);
        }
コード例 #26
0
        public Boolean exportBoatTimes( String inSanctionId )
        {
            Boolean returnStatus = false;
            Int16 curSanctionYear = 0;
            char DoubleQuote = '"';
            String curMemberId = "", curTourClass = "", curEventDateOut = "", curRunTime = "";
            StringBuilder outLine = new StringBuilder( "" );
            StreamWriter outBuffer = null;
            myProgressInfo = new ProgressWindow();

            DataTable curTourDataTable = getTourData( inSanctionId );
            if ( curTourDataTable != null ) {
                if ( curTourDataTable.Rows.Count > 0 ) {
                    curSanctionYear = Convert.ToInt16( inSanctionId.Substring( 0, 2 ) );
                    myTourRow = curTourDataTable.Rows[0];
                    curTourClass = myTourRow["Class"].ToString().Trim();
                    String curFilename = inSanctionId.Trim() + "JT.csv";
                    outBuffer = getExportFile( curFilename );

                    curEventDateOut = myTourRow["EventDates"].ToString();
                    if ( curEventDateOut.Length > 7 ) {
                        try {
                            DateTime curEventDate = Convert.ToDateTime( curEventDateOut );
                            curEventDateOut = curEventDate.ToString( "yyyyMMdd" );
                        } catch {
                            curEventDateOut = "";
                        }
                    } else {
                        curEventDateOut = "";
                    }
                    mySkierClassList = new ListSkierClass();
                    mySkierClassList.ListSkierClassLoad();
                    myTourClass = myTourRow["Class"].ToString().ToUpper();
                    myClassCRow = mySkierClassList.SkierClassDataTable.Select( "ListCode = 'C'" )[0];
                    myClassERow = mySkierClassList.SkierClassDataTable.Select( "ListCode = 'E'" )[0];
                }
            }
            Decimal curSplitTime30M, curSplitTime52M, curSplitTime82M, curBoatEndTime, curScoreMeters, curScoreFeet;
            Decimal curActualSeg52m, curActualSeg30m, curActualSeg41m, curActualSeg82m;
            String curResults, curTimeClass;
            if ( outBuffer != null ) {
                outLine.Append( "Sanction" );
                outLine.Append( ", Skier Class" );
                outLine.Append( ", Boat" );
                outLine.Append( ", EventDate" );
                outLine.Append( ", Time" );
                outLine.Append( ", SkierName" );
                outLine.Append( ", Div" );
                outLine.Append( ", Pass" );
                outLine.Append( ", Speed" );
                outLine.Append( ", Meters" );
                outLine.Append( ", Feet" );
                outLine.Append( ", Time30M" );
                outLine.Append( ", Time52M" );
                outLine.Append( ", Time82M" );
                outLine.Append( ", Time41M" );
                outLine.Append( ", Actual30M" );
                outLine.Append( ", Actual52M" );
                outLine.Append( ", Actual82M" );
                outLine.Append( ", Actual41M" );

                //Write output line to file
                outBuffer.WriteLine( outLine.ToString() );
                outLine = new StringBuilder( "" );

                myProgressInfo.setProgessMsg( "Export jump boat times " );
                myProgressInfo.Show();
                myProgressInfo.Refresh();
                int curRowCount = 0;

                DataTable curBoatTimeResults = getBoatTimeResults( inSanctionId );
                myProgressInfo.setProgressMax( curBoatTimeResults.Rows.Count );
                if (curBoatTimeResults != null) {
                    foreach ( DataRow curRow in curBoatTimeResults.Rows ) {
                        curRowCount++;
                        myProgressInfo.setProgressValue( curRowCount );
                        myProgressInfo.Refresh();

                        curTimeClass = getTimeClass( (String)curRow["EventClass"] );
                        curResults = (String)curRow["Results"];
                        try {
                            curSplitTime52M = (Decimal)curRow["BoatSplitTime"];
                        } catch {
                            curSplitTime52M = 0;
                        }
                        try {
                            curSplitTime82M = (Decimal)curRow["BoatSplitTime2"];
                        } catch {
                            curSplitTime82M = 0;
                        }
                        try {
                            curSplitTime30M = curSplitTime82M - curSplitTime52M;
                        } catch {
                            curSplitTime30M = 0;
                        }
                        try {
                            curBoatEndTime = ((Decimal)curRow["BoatEndTime"]);
                        } catch {
                            curBoatEndTime = 0;
                        }
                        try {
                            curScoreMeters= ((Decimal)curRow["ScoreMeters"]);
                        } catch {
                            curScoreMeters = 0;
                        }
                        try {
                            curScoreFeet = ((Decimal)curRow["ScoreFeet"]);
                        } catch {
                            curScoreFeet = 0;
                        }
                        if (curTimeClass.Equals( "R" )) {
                            try {
                                curActualSeg52m = Convert.ToDecimal( (String)curRow["ActualTime52mSeg"] );
                            } catch {
                                curActualSeg52m = 0;
                            }
                            try {
                                curActualSeg41m = Convert.ToDecimal( (String)curRow["ActualTime41mSeg"] );
                            } catch {
                                curActualSeg41m = 0;
                            }
                            try {
                                curActualSeg82m = Convert.ToDecimal( (String)curRow["ActualTime82mSeg"] );
                            } catch {
                                curActualSeg82m = 0;
                            }
                        } else {
                            try {
                                curActualSeg52m = Convert.ToDecimal( (String)curRow["ActualTime52mSegR"] );
                            } catch {
                                curActualSeg52m = 0;
                            }
                            try {
                                curActualSeg41m = Convert.ToDecimal( (String)curRow["ActualTime41mSegR"] );
                            } catch {
                                curActualSeg41m = 0;
                            }
                            try {
                                curActualSeg82m = Convert.ToDecimal( (String)curRow["ActualTime82mSegR"] );
                            } catch {
                                curActualSeg82m = 0;
                            }
                        }
                        try {
                            curActualSeg30m = curActualSeg82m - curActualSeg52m;
                        } catch {
                            curActualSeg30m = 0;
                        }
                        try {
                            curRunTime = ((DateTime)curRow["LastUpdateDate"]).ToString( "hhmm" );
                        } catch {
                            curRunTime = "0000";
                        }

                        outLine.Append( DoubleQuote.ToString() + inSanctionId + curTourClass + DoubleQuote.ToString() ); // 1. (7) SanctionId with class
                        outLine.Append( "," + DoubleQuote.ToString() + curRow["EventClass"].ToString() + DoubleQuote.ToString() ); // 2. (1) Skier Class
                        outLine.Append( "," + DoubleQuote.ToString() + curRow["Boat"].ToString().PadRight( 11, ' ' ) + DoubleQuote.ToString() ); // 3. (11) Boat
                        outLine.Append( "," + DoubleQuote.ToString() + curEventDateOut + DoubleQuote.ToString() ); // 4. (8) Date YYYYMMDD
                        outLine.Append( "," + DoubleQuote.ToString() + curRunTime + DoubleQuote.ToString() ); // 5. (4) Time HHMM
                        outLine.Append( "," + DoubleQuote.ToString() + curRow["SkierName"].ToString().PadRight( 22, ' ') + DoubleQuote.ToString() ); // 6. (22) Skier Name
                        outLine.Append( "," + DoubleQuote.ToString() + curRow["AgeGroup"].ToString() + DoubleQuote.ToString() ); // 7. (2) Age Division
                        outLine.Append( "," + DoubleQuote.ToString() + ((byte)curRow["PassNum"]).ToString("#0").PadLeft(2, ' ') + DoubleQuote.ToString() ); // 8. (2) Pass Number
                        outLine.Append( "," + DoubleQuote.ToString() + ((byte)curRow["BoatSpeed"]).ToString( "00" ) + DoubleQuote.ToString() ); // 9. (2) Boat Speed KM
                        if ( curResults.ToUpper().Equals( "JUMP" ) ) {
                            outLine.Append( "," + DoubleQuote.ToString() + curScoreMeters.ToString( "#0.0" ).PadLeft( 4, ' ' ) + DoubleQuote.ToString() ); //10. (4) Distance in Meters
                            outLine.Append( "," + DoubleQuote.ToString() + curScoreFeet.ToString( "#00" ).PadLeft( 3, ' ' ) + DoubleQuote.ToString() ); //11. (3) Distance in Feet
                        } else {
                            outLine.Append( "," + DoubleQuote.ToString() + curResults.ToUpper() + DoubleQuote.ToString() ); //10. (4) Distance in Meters
                            outLine.Append( "," + DoubleQuote.ToString() + "   " + DoubleQuote.ToString() ); //11. (3) Distance in Feet
                        }
                        outLine.Append( ", " + curSplitTime30M.ToString( "0.00" ) ); //12. (4 Num) 1st segment 30M Time
                        outLine.Append( ", " + curSplitTime52M.ToString( "0.00" ) ); //13. (4 Num) 2nd segment 52M Time
                        outLine.Append( ", " + curSplitTime82M.ToString( "0.00" ) ); //14. (4 Num) 1st & 2nd segment 82M Time
                        outLine.Append( ", " + curBoatEndTime.ToString( "0.00" ) ); //15. (4 Num) 3rd segment 41M Time

                        outLine.Append( ", " + curActualSeg52m.ToString( "0.00" ) ); //16. (4 Num) 1st segment 30M Actual
                        outLine.Append( ", " + curActualSeg30m.ToString( "0.00" ) ); //17. (4 Num) 2nd segment 52M Actual
                        outLine.Append( ", " + curActualSeg82m.ToString( "0.00" ) ); //18. (4 Num) 1st & 2nd segment 82M Actual
                        outLine.Append( ", " + curActualSeg41m.ToString( "0.00" ) ); //19. (4 Num) 3rd segment 41M Actual

                        //Write output line to file
                        outBuffer.WriteLine( outLine.ToString() );

                        //Initialize output buffer
                        outLine = new StringBuilder( "" );
                    }
                    myProgressInfo.Close();
                }

                returnStatus = true;
                outBuffer.Close();

                if ( curBoatTimeResults.Rows.Count > 0 ) {
                    MessageBox.Show( curBoatTimeResults.Rows.Count + " rows found and written" );
                } else {
                    MessageBox.Show( "No rows found" );
                }
            }

            return returnStatus;
        }
コード例 #27
0
        private void loadRecoveredData()
        {
            String       inputBuffer, curSqlStmt = "";
            int          rowsProc = 0, curInputLineCount = 0;
            StreamReader myReader = null;

            myProgressInfo = new ProgressWindow();

            #region Process all commands in the input file

            myReader = new StreamReader(myLogRecoveryCmdFileName);

            if (myReader != null)
            {
                try {
                    myProgressInfo.setProgessMsg("File selected " + myLogRecoveryCmdFileName);
                    myProgressInfo.Show();
                    myProgressInfo.Refresh();

                    curInputLineCount = 0;
                    myReader          = new StreamReader(myLogRecoveryCmdFileName);
                    while ((inputBuffer = myReader.ReadLine()) != null)
                    {
                        curInputLineCount++;
                    }
                    myReader.Close();
                    myProgressInfo.setProgressMin(1);
                    myProgressInfo.setProgressMax(curInputLineCount);
                } catch (Exception ex) {
                    MessageBox.Show("Error: Could not read file" + myLogRecoveryCmdFileName + "\n\nError: " + ex.Message);
                    return;
                } finally {
                    myProgressInfo.Close();
                    if (myReader != null)
                    {
                        myReader.Close();
                        myReader.Dispose();
                    }
                }


                curInputLineCount = 0;
                try {
                    myReader = new StreamReader(myLogRecoveryCmdFileName);
                    while ((inputBuffer = myReader.ReadLine()) != null)
                    {
                        curInputLineCount++;
                        myProgressInfo.setProgressValue(curInputLineCount);

                        try {
                            curSqlStmt = inputBuffer;
                            if (curSqlStmt.IndexOf("Where PK =") <= 0)
                            {
                                rowsProc = DataAccess.ExecuteCommand(curSqlStmt);
                            }
                        } catch (Exception ex) {
                            String ExcpMsg = ex.Message;
                            if (curSqlStmt != null)
                            {
                                ExcpMsg += "\n" + curSqlStmt;
                            }
                            MessageBox.Show("Error attempting to execute statement" + "\n\nError: " + ExcpMsg);
                        }
                    }
                } catch (Exception ex) {
                    MessageBox.Show("Error attempting to execute statement" + "\n\nError: " + ex.Message);
                } finally {
                    myProgressInfo.Close();
                    myReader.Close();
                    myReader.Dispose();
                }
            }
            #endregion
        }
コード例 #28
0
        private bool readLoadDataFromLog()
        {
            bool   curReturnValue = true;
            String inputBuffer    = "";

            /*
             * For data cleanup
             * Delete TourReg Where SanctionId = '17E042'
             * Delete EventReg Where SanctionId = '17E042'
             * Delete OfficialWork Where SanctionId = '17E042'
             *
             * Delete SlalomScore Where SanctionId = '17E042'
             * Delete SlalomRecap Where SanctionId = '17E042'
             *
             * Delete TrickScore Where SanctionId = '17E042'
             * Delete TrickPass Where SanctionId = '17E042'
             *
             * Delete JumpScore Where SanctionId = '17E042'
             * Delete JumpRecap Where SanctionId = '17E042'
             */
            String curTourRegUpdateDelim = "Tournament:Registration:navSave_Click";
            String curTourRegDelim       = "Tournament:TourEventReg:addTourReg";
            String curEventRegDelim      = "Tournament:TourEventReg:addEvent";
            String curEventOfficialDelim = "Tournament:TourEventReg:addEventOfficial";
            String curRunningOrderDelim  = "Tournament:RunningOrderTour:navSave";

            String curSlalomScoreDelim      = "Slalom:ScoreEntry:saveScore";
            String curDeleteSlalomPassDelim = "ScoreEntry:deletePassButton";
            String curSlalomForceCompDelim  = "Slalom:ScoreEntry:ForceCompButton_Click";
            String curSlalomEventClassDelim = "Slalom:ScoreEntry:scoreEventClass_Validating";
            String curSlalomBoatSelectDelim = "Slalom:ScoreEntry:updateBoatSelect";

            String curTrickScoreDelim      = "Trick:ScoreCalc:saveTrickScore";
            String curTrickPassDelim       = "Trick:ScoreCalc:saveTrickPassEntry";
            String curDeleteTrickPassDelim = "Trick:ScoreCalc:deleteTrickPass";
            String curTrickForceCompDelim  = "Trick:ScoreCalc:ForceCompButton_Click";
            String curTrickEventClassDelim = "Trick:ScoreCalc:scoreEventClass_Validating";
            String curTrickBoatSelectDelim = "Trick:ScoreCalc:updateBoatSelect";

            String curJumpScoreDelim      = "Jump:ScoreEntrySeg3:saveScore";
            String curDeleteJumpPassDelim = "Jump:ScoreEntrySeg3:deletePassButton";
            String curJumpForceCompDelim  = "Jump:ScoreEntrySeg3:ForceCompButton_Click";
            String curJumpEventClassDelim = "Jump:ScoreEntrySeg3:scoreEventClass_Validating";
            String curJumpBoatSelectDelim = "Jump:ScoreEntrySeg3:updateBoatSelect";

            //StringBuilder stmtSelect = new StringBuilder( "" );
            //StringBuilder stmtWhere = new StringBuilder( "" );
            //StringBuilder stmtInsert = new StringBuilder( "" );
            //StringBuilder stmtData = new StringBuilder( "" );

            outBuffer = getExportFile(null, "LogLoadStatements.txt");

            StreamReader myReader;

            myProgressInfo = new ProgressWindow();

            myReader = getInputLogFile();
            if (myReader != null)
            {
                int curInputLineCount = 0;
                int curDelimPos       = 0;
                try {
                    while ((inputBuffer = myReader.ReadLine()) != null)
                    {
                        curInputLineCount++;
                        myProgressInfo.setProgressValue(curInputLineCount);

                        if (inputBuffer.IndexOf(curTourRegDelim) > 0)
                        {
                            extractTourEventRegData(inputBuffer, inputBuffer.IndexOf(curTourRegDelim));
                        }
                        else if (inputBuffer.IndexOf(curTourRegUpdateDelim) > 0)
                        {
                            extractTourEventRegData(inputBuffer, inputBuffer.IndexOf(curTourRegUpdateDelim));
                        }
                        else if (inputBuffer.IndexOf(curEventRegDelim) > 0)
                        {
                            extractTourEventRegData(inputBuffer, inputBuffer.IndexOf(curEventRegDelim));
                        }
                        else if (inputBuffer.IndexOf(curEventOfficialDelim) > 0)
                        {
                            extractEventOfficialData(inputBuffer, inputBuffer.IndexOf(curEventOfficialDelim));
                        }
                        else if (inputBuffer.IndexOf(curRunningOrderDelim) > 0)
                        {
                            extractTourEventRegData(inputBuffer, inputBuffer.IndexOf(curRunningOrderDelim));
                        }
                        else if (inputBuffer.IndexOf(curSlalomScoreDelim) > 0)
                        {
                            extractSlalomScoreData(inputBuffer, inputBuffer.IndexOf(curSlalomScoreDelim));
                        }
                        else if (inputBuffer.IndexOf(curDeleteSlalomPassDelim) > 0)
                        {
                            extractDeleteSlalomPassData(inputBuffer, inputBuffer.IndexOf(curDeleteSlalomPassDelim));
                        }
                        else if (inputBuffer.IndexOf(curSlalomForceCompDelim) > 0)
                        {
                            extractSlalomForceCompData(inputBuffer, inputBuffer.IndexOf(curSlalomForceCompDelim));
                        }
                        else if (inputBuffer.IndexOf(curSlalomEventClassDelim) > 0)
                        {
                            extractSlalomEventClassData(inputBuffer, inputBuffer.IndexOf(curSlalomEventClassDelim));
                        }
                        else if (inputBuffer.IndexOf(curSlalomBoatSelectDelim) > 0)
                        {
                            extractBoatSelectionData(inputBuffer, inputBuffer.IndexOf(curSlalomBoatSelectDelim));
                        }
                        else if (inputBuffer.IndexOf(curTrickScoreDelim) > 0)
                        {
                            extractTrickScoreData(inputBuffer, inputBuffer.IndexOf(curTrickScoreDelim));
                        }
                        else if (inputBuffer.IndexOf(curTrickPassDelim) > 0)
                        {
                            extractTrickScoreData(inputBuffer, inputBuffer.IndexOf(curTrickPassDelim));
                        }
                        else if (inputBuffer.IndexOf(curDeleteTrickPassDelim) > 0)
                        {
                            extractTrickScoreData(inputBuffer, inputBuffer.IndexOf(curDeleteTrickPassDelim));
                        }
                        else if (inputBuffer.IndexOf(curTrickForceCompDelim) > 0)
                        {
                            extractTrickForceCompData(inputBuffer, inputBuffer.IndexOf(curTrickForceCompDelim));
                        }
                        else if (inputBuffer.IndexOf(curTrickEventClassDelim) > 0)
                        {
                            extractTrickEventClassData(inputBuffer, inputBuffer.IndexOf(curTrickEventClassDelim));
                        }
                        else if (inputBuffer.IndexOf(curTrickBoatSelectDelim) > 0)
                        {
                            extractBoatSelectionData(inputBuffer, inputBuffer.IndexOf(curTrickBoatSelectDelim));
                        }
                        else if (inputBuffer.IndexOf(curJumpScoreDelim) > 0)
                        {
                            extractJumpScoreData(inputBuffer, inputBuffer.IndexOf(curJumpScoreDelim));
                        }
                        else if (inputBuffer.IndexOf(curDeleteJumpPassDelim) > 0)
                        {
                            extractJumpScoreData(inputBuffer, inputBuffer.IndexOf(curDeleteJumpPassDelim));
                        }
                        else if (inputBuffer.IndexOf(curJumpForceCompDelim) > 0)
                        {
                            extractJumpForceCompData(inputBuffer, inputBuffer.IndexOf(curJumpForceCompDelim));
                        }
                        else if (inputBuffer.IndexOf(curJumpEventClassDelim) > 0)
                        {
                            extractJumpEventClassData(inputBuffer, inputBuffer.IndexOf(curJumpEventClassDelim));
                        }
                        else if (inputBuffer.IndexOf(curJumpBoatSelectDelim) > 0)
                        {
                            extractBoatSelectionData(inputBuffer, inputBuffer.IndexOf(curJumpBoatSelectDelim));
                        }
                        else
                        {
                            SaveUnselectedStatements(inputBuffer);
                        }
                    }
                } catch (Exception ex) {
                    String ExcpMsg = ex.Message;
                    MessageBox.Show("Error: Performing SQL operations"
                                    + "\n\nError: " + ExcpMsg
                                    );
                } finally {
                    myReader.Close();
                    myReader.Dispose();

                    outBuffer.Close();
                    outBuffer.Dispose();
                    outDiscardBuffer.Close();
                    outDiscardBuffer.Dispose();
                }

                myProgressInfo.Close();
            }

            return(curReturnValue);
        }
コード例 #29
0
        private void btnExport_Click(object sender, RoutedEventArgs e)
        {
            List <Model.TB_StandardInfo> checkedStandList = GetCheckedStand();

            if (checkedStandList.Count == 0)
            {
                DSJL.Tools.MessageBoxTool.ShowConfirmMsgBox("请选择要导出的测试参考值!");
                return;
            }
            if (DSJL.Tools.ShowFileDialogTool.ShowSaveFileDialog(out exportPath, "", "dsf", "等速肌力参考值导出") == false)
            {
                return;
            }
            exportPath = exportPath.Substring(0, exportPath.LastIndexOf("\\") + 1);
            Console.WriteLine("export path is:{0}", exportPath);

            ProgressWindow window = new ProgressWindow();

            window.WindowTilte   = "导出参考值进度";
            window.MaxValue      = checkedStandList.Count;
            window.MinValue      = 0;
            window.CancleMessage = "确定取消导出吗?";
            window.onCancling   += Window_onCancling;
            window.Owner         = this;

            Task task = new Task(() => {
                int progress = 0;
                foreach (var item in checkedStandList)
                {
                    if (isCancleExport)
                    {
                        break;
                    }
                    //1、查询测试信息
                    List <Model.TestInfoModel> testInfoModelList = Caches.Util.AthTestInfoModelUtil.AthTestUtil(refeBLL.GetStandTestInfoModelList(item.ID));
                    if (testInfoModelList.Count == 0)
                    {
                        continue;
                    }
                    Model.TestInfoModel avgTestInfoModel = GetAvgTestInfoModel(testInfoModelList);
                    string testInfoModelJson             = Newtonsoft.Json.JsonConvert.SerializeObject(avgTestInfoModel);
                    // Console.WriteLine(testInfoModelJson);
                    //2、计算平均值
                    List <List <XElement> > paramList = DSJL.Export.GenerateCompareResportXml.ComputeAvg(testInfoModelList);
                    string paramJson = Newtonsoft.Json.JsonConvert.SerializeObject(paramList);
                    // Console.WriteLine(paramJson);
                    Dictionary <DataPointsType, List <List <double> > > dataPointsDict = StandardChartCache.GetStandardDataPoints(item, testInfoModelList);
                    List <List <double> > oddavgsd  = dataPointsDict[DataPointsType.ODDAvgSD];
                    List <List <double> > evenavgsd = dataPointsDict[DataPointsType.EVENAVGSD];
                    string oddavgsdjson             = Newtonsoft.Json.JsonConvert.SerializeObject(oddavgsd);
                    string evenavgsdjson            = Newtonsoft.Json.JsonConvert.SerializeObject(evenavgsd);
                    // Console.WriteLine(oddavgsdjson);
                    // Console.WriteLine(evenavgsdjson);
                    //3、写入文件
                    Model.TB_StandardInfo parentStandModel  = standList.Find(x => x.ID == item.Stand_ParentID);
                    Model.ExportStandModel exportStandModel = new Model.ExportStandModel();
                    exportStandModel.ParentName             = parentStandModel.Stand_Name;
                    exportStandModel.StandName = item.Stand_Name;
                    exportStandModel.TestModel = avgTestInfoModel;
                    exportStandModel.ParamList = paramList;
                    exportStandModel.OddAvgSD  = oddavgsd;
                    exportStandModel.EvenAvgSD = evenavgsd;
                    string standJson           = Newtonsoft.Json.JsonConvert.SerializeObject(exportStandModel);
                    standJson       = DSJL.Tools.DES.Encrypt(standJson, "cissdsjl");
                    string filename = string.Format("{0}{1}.dsf", exportPath, item.Stand_Name);
                    StreamWriter sw = new StreamWriter(filename);
                    sw.Write(standJson);
                    sw.Close();
                    progress++;
                    Dispatcher.BeginInvoke(new Action(() => {
                        window.CurrentValue = progress;
                    }));
                }
                DSJL.Tools.MessageBoxTool.ShowConfirmMsgBox("导出完成!");
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    window.Close();
                    this.Close();
                }));
            });

            task.Start();
            window.ShowDialog();
        }
コード例 #30
0
        /// <summary>
        ///     Handles the Click event of the btnSearch control. Implements the searching algorithm by accumulating the criteria and
        ///     filtering the available players based on those criteria.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">
        ///     The <see cref="RoutedEventArgs" /> instance containing the event data.
        /// </param>
        private async void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            dgvPlayerStats.ItemsSource = null;
            var pst = MainWindow.PST;
            var filteredPST = pst.AsEnumerable();

            if (!String.IsNullOrWhiteSpace(txtLastName.Text))
            {
                filteredPST = cmbLastNameSetting.SelectedItem.ToString() == "Contains"
                                  ? filteredPST.Where(pair => pair.Value.LastName.Contains(txtLastName.Text))
                                  : filteredPST.Where(pair => pair.Value.LastName == txtLastName.Text);
            }

            if (!String.IsNullOrWhiteSpace(txtFirstName.Text))
            {
                filteredPST = cmbFirstNameSetting.SelectedItem.ToString() == "Contains"
                                  ? filteredPST.Where(pair => pair.Value.FirstName.Contains(txtFirstName.Text))
                                  : filteredPST.Where(pair => pair.Value.FirstName == txtFirstName.Text);
            }

            if (cmbPosition1.SelectedIndex != -1 && cmbPosition1.SelectedItem.ToString() != "Any")
            {
                filteredPST = filteredPST.Where(pair => pair.Value.Position1S == cmbPosition1.SelectedItem.ToString());
            }

            if (cmbPosition2.SelectedIndex != -1 && cmbPosition2.SelectedItem.ToString() != "Any")
            {
                filteredPST = filteredPST.Where(pair => pair.Value.Position2S == cmbPosition2.SelectedItem.ToString());
            }

            if (cmbContractOpt.SelectedIndex != -1 && cmbContractOpt.SelectedItem.ToString() != "Any")
            {
                filteredPST = filteredPST.Where(
                    pair => pair.Value.Contract.Option.ToString() == cmbContractOpt.SelectedItem.ToString());
            }

            if (chkIsActive.IsChecked.GetValueOrDefault())
            {
                filteredPST = filteredPST.Where(pair => pair.Value.IsSigned);
            }
            else if (chkIsActive.IsChecked != null)
            {
                filteredPST = filteredPST.Where(pair => !pair.Value.IsSigned);
            }

            if (chkIsInjured.IsChecked.GetValueOrDefault())
            {
                filteredPST = filteredPST.Where(pair => pair.Value.Injury.IsInjured);
            }
            else if (chkIsInjured.IsChecked != null)
            {
                filteredPST = filteredPST.Where(pair => !pair.Value.Injury.IsInjured);
            }

            if (chkIsAllStar.IsChecked.GetValueOrDefault())
            {
                filteredPST = filteredPST.Where(pair => pair.Value.IsAllStar);
            }
            else if (chkIsAllStar.IsChecked != null)
            {
                filteredPST = filteredPST.Where(pair => !pair.Value.IsAllStar);
            }

            if (chkIsChampion.IsChecked.GetValueOrDefault())
            {
                filteredPST = filteredPST.Where(pair => pair.Value.IsNBAChampion);
            }
            else if (chkIsChampion.IsChecked != null)
            {
                filteredPST = filteredPST.Where(pair => !pair.Value.IsNBAChampion);
            }

            if (cmbTeam.SelectedItem != null && !String.IsNullOrEmpty(cmbTeam.SelectedItem.ToString())
                && chkIsActive.IsChecked.GetValueOrDefault() && cmbTeam.SelectedItem.ToString() != "- Any -")
            {
                filteredPST = filteredPST.Where(pair => pair.Value.TeamF == GetTeamIDFromDisplayName(cmbTeam.SelectedItem.ToString()));
            }

            var pstDict = filteredPST.ToDictionary(ps => ps.Value.ID, ps => ps.Value);
            _psrListSea = pstDict.Values.AsParallel().Select(ps => new PlayerStatsRow(ps)).ToList();
            _psrListPl = pstDict.Values.AsParallel().Select(ps => new PlayerStatsRow(ps, true)).ToList();
            var tsrListSea = MainWindow.TST.Values.Select(ts => new TeamStatsRow(ts)).ToList();
            var tsrListPl = MainWindow.TST.Values.Select(ts => new TeamStatsRow(ts, true)).ToList();
            var tsrOppListSea = MainWindow.TSTOpp.Values.Select(ts => new TeamStatsRow(ts)).ToList();
            var tsrOppListPl = MainWindow.TSTOpp.Values.Select(ts => new TeamStatsRow(ts, true)).ToList();

            #region Custom Expressions parsing

            _customMetricNames.Clear();

            dgvPlayerStats.Columns.SkipWhile(col => col.Header.ToString() != "Custom")
                          .Skip(1)
                          .ToList()
                          .ForEach(col => dgvPlayerStats.Columns.Remove(col));

            dgvPlayoffStats.Columns.SkipWhile(col => col.Header.ToString() != "Custom")
                           .Skip(1)
                           .ToList()
                           .ForEach(col => dgvPlayoffStats.Columns.Remove(col));

            var includedIDs = pstDict.Keys.ToList();
            var context = new ExpressionContext();
            var j = 0;
            var message = "";
            foreach (var itemS in _customExpressions)
            {
                var expByPlayer = includedIDs.ToDictionary(id => id, id => "");
                var plExpByPlayer = includedIDs.ToDictionary(id => id, id => "");
                var itemSParts = itemS.Split(new[] { ": " }, StringSplitOptions.None);
                var name = itemSParts[0];
                var item = itemSParts[1];
                var decimalPoints = itemSParts[3];
                var parts = item.Split(_splitOn.ToArray(), StringSplitOptions.RemoveEmptyEntries);
                var k = 0;
                PlayerStatsRow curPSR;
                PlayerStatsRow curPSRPl;

                var ignoredIDs = new List<int>();
                var ignoredPlIDs = new List<int>();
                for (var i = 0; i < item.Length; i++)
                {
                    var c1 = item[i];
                    if (_numericOperators.Contains(c1.ToString()))
                    {
                        foreach (var id in includedIDs)
                        {
                            if (!ignoredIDs.Contains(id))
                            {
                                expByPlayer[id] += c1;
                            }
                            if (!ignoredPlIDs.Contains(id))
                            {
                                plExpByPlayer[id] += c1;
                            }
                        }
                    }
                    else if (c1 == '$')
                    {
                        try
                        {
                            char c2;
                            try
                            {
                                c2 = item[i + 1];
                            }
                            catch (IndexOutOfRangeException)
                            {
                                MessageBox.Show("Encountered '$' at end of custom expression.");
                                return;
                            }
                            bool isPlayer;
                            bool? isOwnTeam = null;
                            string part;
                            if (c2 != '$')
                            {
                                part = parts[k++].Substring(1);
                                isPlayer = true;
                            }
                            else
                            {
                                part = parts[k++].Substring(3);
                                isPlayer = false;
                                if (item[i + 2] == 't')
                                {
                                    isOwnTeam = true;
                                }
                                else if (item[i + 2] == 'o')
                                {
                                    isOwnTeam = false;
                                }
                                else
                                {
                                    MessageBox.Show("Encountered unknown/malformed parameter: " + parts[k - 1]);
                                    return;
                                }
                            }
                            part = part.Replace("3P", "TP");
                            part = part.Replace("TO", "TOS");
                            part = part.Replace("%", "p");
                            foreach (var id in includedIDs)
                            {
                                if (!ignoredIDs.Contains(id))
                                {
                                    string val;
                                    curPSR = _psrListSea.Single(psr => psr.ID == id);
                                    if (isPlayer)
                                    {
                                        val =
                                            Convert.ToDouble(typeof(PlayerStatsRow).GetProperty(part).GetValue(curPSR, null))
                                                   .ToString(".0###############");
                                    }
                                    else
                                    {
                                        if (curPSR.TeamF == -1)
                                        {
                                            val = "NaN";
                                        }
                                        else
                                        {
                                            var curTSR = isOwnTeam == true
                                                             ? tsrListSea.Single(tsr => tsr.ID == curPSR.TeamF)
                                                             : tsrOppListSea.Single(tsr => tsr.ID == curPSR.TeamF);
                                            val =
                                                Convert.ToDouble(typeof(TeamStatsRow).GetProperty(part).GetValue(curTSR, null))
                                                       .ToString(".0###############");
                                        }
                                    }
                                    if (val != "NaN")
                                    {
                                        expByPlayer[id] += val;
                                    }
                                    else
                                    {
                                        ignoredIDs.Add(id);
                                        expByPlayer[id] = "$$INVALID";
                                    }
                                }
                                if (!ignoredPlIDs.Contains(id))
                                {
                                    string plVal;
                                    curPSRPl = _psrListPl.Single(psr => psr.ID == id);
                                    if (isPlayer)
                                    {
                                        plVal =
                                            Convert.ToDouble(typeof(PlayerStatsRow).GetProperty(part).GetValue(curPSRPl, null))
                                                   .ToString(".0###############");
                                    }
                                    else
                                    {
                                        if (curPSRPl.TeamF == -1)
                                        {
                                            plVal = "NaN";
                                        }
                                        else
                                        {
                                            var curTSRPl = isOwnTeam == true
                                                               ? tsrListPl.Single(tsr => tsr.ID == curPSRPl.TeamF)
                                                               : tsrOppListPl.Single(tsr => tsr.ID == curPSRPl.TeamF);
                                            plVal =
                                                Convert.ToDouble(typeof(TeamStatsRow).GetProperty(part).GetValue(curTSRPl, null))
                                                       .ToString(".0###############");
                                        }
                                    }
                                    if (plVal != "NaN")
                                    {
                                        plExpByPlayer[id] += plVal;
                                    }
                                    else
                                    {
                                        ignoredPlIDs.Add(id);
                                        plExpByPlayer[id] = "$$INVALID";
                                    }
                                }
                            }
                            if (isPlayer)
                            {
                                i += part.Length; // should be Length-1 but we're using Substring(1) in part's initialization
                            }
                            else
                            {
                                i += part.Length + 2; // we're using Substring(3)
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Error encountered while trying to evaluate custom expression parameter.\n\n" + ex.Message);
                            return;
                        }
                    }
                    else if (Tools.IsNumeric(parts[k]))
                    {
                        var part = parts[k++];
                        foreach (var id in includedIDs)
                        {
                            if (!ignoredIDs.Contains(id))
                            {
                                expByPlayer[id] += part;
                            }
                            if (!ignoredPlIDs.Contains(id))
                            {
                                plExpByPlayer[id] += part;
                            }
                        }
                        i += part.Length - 1;
                    }
                }
                foreach (var id in includedIDs)
                {
                    curPSR = _psrListSea.Single(psr => psr.ID == id);
                    curPSRPl = _psrListPl.Single(psr => psr.ID == id);
                    if (!ignoredIDs.Contains(id))
                    {
                        try
                        {
                            var compiled = context.CompileGeneric<double>(expByPlayer[id]);
                            curPSR.Custom.Add(compiled.Evaluate());
                        }
                        catch (Exception ex)
                        {
                            message = string.Format(
                                "Expression {0}:\n{1}\nevaluated to\n{2}\n\nError: {3}", (j + 1), item, expByPlayer[id], ex.Message);
                            curPSR.Custom.Add(double.NaN);
                        }
                    }
                    else
                    {
                        curPSR.Custom.Add(double.NaN);
                    }
                    if (!ignoredPlIDs.Contains(id))
                    {
                        try
                        {
                            var compiled = context.CompileGeneric<double>(plExpByPlayer[id]);
                            curPSRPl.Custom.Add(compiled.Evaluate());
                        }
                        catch (Exception ex)
                        {
                            message = string.Format(
                                "Expression {0}:\n{1}\nevaluated to\n{2}\n\nError: {3}", (j + 1), item, plExpByPlayer[id], ex.Message);
                            curPSRPl.Custom.Add(double.NaN);
                        }
                    }
                    else
                    {
                        curPSRPl.Custom.Add(double.NaN);
                    }
                }
                dgvPlayerStats.Columns.Add(
                    new DataGridTextColumn
                        {
                            Header = name,
                            Binding =
                                new Binding
                                    {
                                        Path = new PropertyPath(string.Format("Custom[{0}]", j)),
                                        Mode = BindingMode.OneWay,
                                        StringFormat = "{0:F" + decimalPoints + "}"
                                    }
                        });
                dgvPlayoffStats.Columns.Add(
                    new DataGridTextColumn
                        {
                            Header = name,
                            Binding =
                                new Binding
                                    {
                                        Path = new PropertyPath(string.Format("Custom[{0}]", j)),
                                        Mode = BindingMode.OneWay,
                                        StringFormat = "{0:F" + decimalPoints + "}"
                                    }
                        });
                _customMetricNames.Add(name);
                j++;
            }

            populateSituationalsCombo();

            #endregion Custom Expressions parsing

            IsEnabled = false;
            var pw = new ProgressWindow("Please wait while players are filtered...", false, false);
            pw.Show();

            _yearsProVal = txtYearsProVal.Text;
            _yearsProOp = cmbYearsProOp.SelectedItem.ToString();
            _yobVal = txtYOBVal.Text;
            _yobOp = cmbYOBOp.SelectedItem.ToString();
            _heightVal = txtHeightVal.Text;
            _heightOp = cmbHeightOp.SelectedItem.ToString();
            _weightVal = txtWeightVal.Text;
            _weightOp = cmbWeightOp.SelectedItem.ToString();
            _contractYearsLeftVal = txtContractYLeftVal.Text;
            _contractYearsLeftOp = cmbContractYLeftOp.SelectedItem.ToString();
            _contractYears = lstContract.Items.Cast<string>();
            _totalsFilters = lstTotals.Items.Cast<string>();
            _pgFilters = lstAvg.Items.Cast<string>();
            _metricFilters = lstMetrics.Items.Cast<string>();

            _psrViewSea = CollectionViewSource.GetDefaultView(_psrListSea);
            await Task.Run(() => _psrViewSea.Filter = filter);

            _psrViewPl = CollectionViewSource.GetDefaultView(_psrListPl);
            await Task.Run(() => _psrViewPl.Filter = filter);

            dgvPlayerStats.ItemsSource = _psrViewSea;
            dgvPlayoffStats.ItemsSource = _psrViewPl;

            string sortColumn;
            foreach (var item in lstMetrics.Items.Cast<string>())
            {
                sortColumn = item.Split(' ')[0];
                sortColumn = sortColumn.Replace("%", "p");
                _psrViewSea.SortDescriptions.Add(new SortDescription(sortColumn, ListSortDirection.Descending));
                _psrViewPl.SortDescriptions.Add(new SortDescription(sortColumn, ListSortDirection.Descending));
            }
            foreach (var item in lstAvg.Items.Cast<string>())
            {
                sortColumn = item.Split(' ')[0];
                sortColumn = sortColumn.Replace("3P", "TP");
                sortColumn = sortColumn.Replace("%", "p");
                _psrViewSea.SortDescriptions.Add(new SortDescription(sortColumn, ListSortDirection.Descending));
                _psrViewPl.SortDescriptions.Add(new SortDescription(sortColumn, ListSortDirection.Descending));
            }
            foreach (var item in lstTotals.Items.Cast<string>())
            {
                sortColumn = item.Split(' ')[0];
                sortColumn = sortColumn.Replace("3P", "TP");
                sortColumn = sortColumn.Replace("TO", "TOS");
                _psrViewSea.SortDescriptions.Add(new SortDescription(sortColumn, ListSortDirection.Descending));
                _psrViewPl.SortDescriptions.Add(new SortDescription(sortColumn, ListSortDirection.Descending));
            }

            if (_psrViewSea.SortDescriptions.Count == 0)
            {
                dgvPlayerStats.Columns.Single(col => col.Header.ToString() == "GmSc").SortDirection = ListSortDirection.Descending;
                dgvPlayoffStats.Columns.Single(col => col.Header.ToString() == "GmSc").SortDirection = ListSortDirection.Descending;
                _psrViewSea.SortDescriptions.Add(new SortDescription("GmSc", ListSortDirection.Descending));
                _psrViewPl.SortDescriptions.Add(new SortDescription("GmSc", ListSortDirection.Descending));
            }

            tbcPlayerSearch.SelectedItem = tabResults;

            _lastPropertyUsed = "";

            await prepareSituationalSeason();
            await prepareSituationalPlayoffs();

            IsEnabled = true;
            pw.CanClose = true;
            pw.Close();

            if (!String.IsNullOrWhiteSpace(message))
            {
                const string warning = "An error occurred while trying to evaluate one or more of the custom column expressions:\n\n";
                const string contact =
                    "\n\nIf you believe your expression is correct and that you shouldn't be getting this error, contact the developer "
                    + "and give them this information.";
                var cmw = new CopyableMessageWindow(warning + message + contact, "Error while evaluating expression", beep: true);
                cmw.ShowDialog();
            }
        }
コード例 #31
0
        public static Boolean exportCurrentSkiers(String inEvent, String inSanctionId, byte inRound, String inEventGroup)
        {
            String         curMethodName  = "exportCurrentSlalomSkiers";
            StringBuilder  curSqlStmt     = new StringBuilder("");
            String         curMsg         = "";
            Boolean        returnStatus   = false;
            int            curLineCount   = 0;
            DataTable      curDataTable   = new DataTable();
            ProgressWindow myProgressInfo = new ProgressWindow();

            try {
                if (inEvent.Equals("TrickVideo"))
                {
                    curSqlStmt.Append("Select S.SanctionId, S.MemberId, TR.SkierName, S.AgeGroup, S.Round ");
                    curSqlStmt.Append("From TrickVideo S ");
                    curSqlStmt.Append("Inner Join TourReg TR on TR.SanctionId = S.SanctionId AND TR.MemberId = S.MemberId AND TR.AgeGroup = S.AgeGroup ");
                    curSqlStmt.Append("Inner Join EventReg ER on ER.SanctionId = S.SanctionId AND ER.MemberId = S.MemberId ");
                    curSqlStmt.Append("      AND ER.AgeGroup = S.AgeGroup AND ER.Event = 'Trick' ");
                    curSqlStmt.Append("Where S.SanctionId = '" + inSanctionId + "' ");
                    curSqlStmt.Append("AND (LEN(Pass1VideoUrl) > 1 or LEN(Pass2VideoUrl) > 1)");
                    curSqlStmt.Append("Order by S.SanctionId, S.Round, S.AgeGroup, S.MemberId");
                    curDataTable = getData(curSqlStmt.ToString());
                }
                else
                {
                    curSqlStmt.Append("Select S.SanctionId, S.MemberId, TR.SkierName, S.AgeGroup, S.Round, ER.EventGroup ");
                    curSqlStmt.Append("From " + inEvent + "Score S ");
                    curSqlStmt.Append("Inner Join TourReg TR on TR.SanctionId = S.SanctionId AND TR.MemberId = S.MemberId AND TR.AgeGroup = S.AgeGroup ");
                    curSqlStmt.Append("Inner Join EventReg ER on ER.SanctionId = S.SanctionId AND ER.MemberId = S.MemberId ");
                    curSqlStmt.Append("      AND ER.AgeGroup = S.AgeGroup AND ER.Event = '" + inEvent + "' ");
                    curSqlStmt.Append("Where S.SanctionId = '" + inSanctionId + "' ");
                    curSqlStmt.Append("AND S.Round = " + inRound + " ");
                    if (inEventGroup != null)
                    {
                        if (inEventGroup.Equals("All"))
                        {
                        }
                        else if (inEventGroup.ToUpper().Equals("MEN A"))
                        {
                            curSqlStmt.Append("And ER.AgeGroup = 'CM' ");
                        }
                        else if (inEventGroup.ToUpper().Equals("WOMEN A"))
                        {
                            curSqlStmt.Append("And ER.AgeGroup = 'CW' ");
                        }
                        else if (inEventGroup.ToUpper().Equals("MEN B"))
                        {
                            curSqlStmt.Append("And ER.AgeGroup = 'BM' ");
                        }
                        else if (inEventGroup.ToUpper().Equals("WOMEN B"))
                        {
                            curSqlStmt.Append("And ER.AgeGroup = 'BW' ");
                        }
                        else if (inEventGroup.ToUpper().Equals("NON TEAM"))
                        {
                            curSqlStmt.Append("And ER.AgeGroup not in ('CM', 'CW', 'BM', 'BW') ");
                        }
                        else
                        {
                            curSqlStmt.Append("AND ER.EventGroup = '" + inEventGroup + "' ");
                        }
                    }
                    curSqlStmt.Append("Order by S.SanctionId, S.Round, ER.EventGroup, S.MemberId, S.AgeGroup");
                    curDataTable = getData(curSqlStmt.ToString());
                }

                myProgressInfo.setProgressMin(1);
                myProgressInfo.setProgressMax(curDataTable.Rows.Count);

                String curMemberId = "", curAgeGroup = "", curSkierName = "";
                byte   curRound = 0;
                foreach (DataRow curRow in curDataTable.Rows)
                {
                    curMemberId  = (String)curRow["MemberId"];
                    curAgeGroup  = (String)curRow["AgeGroup"];
                    curSkierName = (String)curRow["SkierName"];
                    curRound     = (Byte)curRow["Round"];

                    curLineCount++;
                    myProgressInfo.setProgressValue(curLineCount);
                    myProgressInfo.setProgessMsg("Processing " + curSkierName);
                    myProgressInfo.Show();
                    myProgressInfo.Refresh();

                    if (inEvent.Equals("Slalom"))
                    {
                        exportCurrentSkierSlalom(inSanctionId, curMemberId, curAgeGroup, curRound, 0, inEvent);
                    }
                    else if (inEvent.Equals("Trick"))
                    {
                        exportCurrentSkierTrick(inSanctionId, curMemberId, curAgeGroup, curRound, 0, inEvent);
                    }
                    else if (inEvent.Equals("Jump"))
                    {
                        exportCurrentSkierJump(inSanctionId, curMemberId, curAgeGroup, curRound, 0, inEvent);
                    }
                    else if (inEvent.Equals("TrickVideo"))
                    {
                        ExportLiveWeb.exportCurrentSkierTrickVideo(inSanctionId, curMemberId, curAgeGroup, curRound);
                    }
                }

                myProgressInfo.Close();
            } catch (Exception ex) {
                //MessageBox.Show( "Error encountered trying to send data to web location \n\nError: " + ex.Message );
                curMsg = curMethodName + ":Exception=" + ex.Message;
                Log.WriteFile(curMsg);
            }

            return(returnStatus);
        }
コード例 #32
0
 private bool importMemberDataDialog( bool inNcwsa )
 {
     bool curReturn = true;
     myProgressInfo = new ProgressWindow();
     try {
         mySanctionNum = Properties.Settings.Default.AppSanctionNum;
         if ( mySanctionNum == null ) {
             curReturn = false;
             MessageBox.Show( "An active tournament must be selected from the Administration menu Tournament List option" );
         } else {
             if ( mySanctionNum.Length < 6 ) {
                 curReturn = false;
                 MessageBox.Show( "An active tournament must be selected from the Administration menu Tournament List option" );
             } else {
                 curReturn = true;
             }
         }
     } catch {
         curReturn = false;
         MessageBox.Show( "An active tournament must be selected from the Administration menu Tournament List option" );
     }
     if ( curReturn ) {
         try {
             curReturn = importMemberData( inNcwsa );
         } catch ( Exception excp ) {
             MessageBox.Show( "Error attempting to import member data \n" + excp.Message );
         }
     }
     myProgressInfo.Close();
     return curReturn;
 }
コード例 #33
0
        private Int16 exportBoatTimesJump( String inSanctionId, StreamWriter outBuffer )
        {
            String curMethodName = "exportBoatTimesJump";
            Int16 curRowCount = 0, curNumRounds = 0, curRowRoundCount = 0, curSkierCount = 0, curRerideCount = 0, curSanctionYear = 0;
            String curResults, curSkierName, prevSkierName = "", curTourClass = "", curSkierClass = "", curBoatSpeed = "", curEventDateOut = "", curRunTime = "";
            Decimal curScoreMeters, curScoreFeet;
            Decimal curSplitTime52M, curSplitTime82M, curSplitTime41M;
            Decimal curActualSeg52m, curActualSeg82m, curActualSeg41m;
            StringBuilder outLine = new StringBuilder( "" );
            DataTable curSummaryTable, curStatsTable, curJumpTimes;
            myProgressInfo = new ProgressWindow();

            try {
                curSanctionYear = Convert.ToInt16( inSanctionId.Substring( 0, 2 ) );
                curTourClass = myTourRow["Class"].ToString().Trim();
                curEventDateOut = myTourRow["EventDates"].ToString();
                if ( curEventDateOut.Length > 7 ) {
                    try {
                        DateTime curEventDate = Convert.ToDateTime( curEventDateOut );
                        curEventDateOut = curEventDate.ToString( "yyyyMMdd" );
                    } catch {
                        curEventDateOut = "";
                    }
                } else {
                    curEventDateOut = "";
                }

                curNumRounds = Convert.ToInt16( (byte)myTourRow["JumpRounds"] );
                for ( byte curRound = 1; curRound <= curNumRounds; curRound++ ) {
                    curSummaryTable = buildSummaryTable();
                    curStatsTable = buildStatsTable();
                    if ( curRound > 1 ) {
                        outLine = new StringBuilder( Environment.NewLine );
                        outBuffer.WriteLine( outLine.ToString() );
                    }

                    outLine = new StringBuilder( "" );
                    outLine.Append( inSanctionId + curTourClass + "    " + myTourRow["Name"].ToString() + " JUMP  Round " + curRound.ToString() );
                    outBuffer.WriteLine( outLine.ToString() );
                    outLine = new StringBuilder( "" );
                    outLine.Append( "TIME                STANDARD TIMING  ------- 1ST SEG -------   ------- 2ND SEG -------   ------- 3rd SEG ------- " );
                    outBuffer.WriteLine( outLine.ToString() );
                    outLine = new StringBuilder( "" );
                    outLine.Append( "HHMM SKIER NAME      # SP DISTANCE   -1    5    |    5    1+   -1    5    |    5    1+   -1    5    |    5    1+ " );
                    outBuffer.WriteLine( outLine.ToString() );

                    //Initialize output buffer
                    outLine = new StringBuilder( "" );

                    curSkierCount = 0;
                    curRerideCount = 0;
                    DataTable curBoatTimeResults = getJumpBoatTimeResults( inSanctionId, curRound );
                    if ( curBoatTimeResults != null ) {
                        myProgressInfo.setProgessMsg( "Export jump boat times " );
                        myProgressInfo.Show();
                        myProgressInfo.setProgressMax( curBoatTimeResults.Rows.Count );
                        myProgressInfo.Refresh();
                        curRowRoundCount = 0;

                        foreach (DataRow curRow in curBoatTimeResults.Rows) {
                            curRowCount++;
                            curRowRoundCount++;
                            myProgressInfo.setProgressValue( curRowRoundCount );
                            myProgressInfo.Refresh();

                            curResults = (String)curRow["Results"];
                            if ( curResults.Length > 4 ) {
                                curResults = curResults.Substring( 0, 4 );
                            }
                            curSkierName = curRow["SkierName"].ToString();
                            if ( curSkierName.Length > 15 ) {
                                curSkierName = curSkierName.Substring( 0, 15 );
                            }
                            try {
                                curSplitTime52M = (Decimal)curRow["BoatSplitTime"];
                            } catch {
                                curSplitTime52M = 0;
                            }
                            try {
                                curSplitTime82M = (Decimal)curRow["BoatSplitTime2"];
                            } catch {
                                curSplitTime82M = 0;
                            }
                            try {
                                curSplitTime41M = ( (Decimal)curRow["BoatEndTime"] );
                            } catch {
                                curSplitTime41M = 0;
                            }
                            try {
                                curScoreMeters = ( (Decimal)curRow["ScoreMeters"] );
                            } catch {
                                curScoreMeters = 0;
                            }
                            try {
                                curScoreFeet = ( (Decimal)curRow["ScoreFeet"] );
                            } catch {
                                curScoreFeet = 0;
                            }

                            try {
                                curBoatSpeed = ( (byte)curRow["BoatSpeed"] ).ToString( "00" );
                                curSkierClass = (String)curRow["EventClass"];
                                curJumpTimes = getJumpTimes( curBoatSpeed, curSkierClass );
                                if ( curJumpTimes.Rows.Count > 0 ) {
                                    try {
                                        curActualSeg52m = Convert.ToDecimal( (String)curJumpTimes.Rows[0]["ActualTime52mSeg"] );
                                    } catch {
                                        curActualSeg52m = 0;
                                    }
                                    try {
                                        curActualSeg82m = Convert.ToDecimal( (String)curJumpTimes.Rows[0]["ActualTime82mSeg"] );
                                    } catch {
                                        curActualSeg82m = 0;
                                    }
                                    try {
                                        curActualSeg41m = Convert.ToDecimal( (String)curJumpTimes.Rows[0]["ActualTime41mSeg"] );
                                    } catch {
                                        curActualSeg41m = 0;
                                    }
                                } else {
                                    curActualSeg52m = 0;
                                    curActualSeg82m = 0;
                                    curActualSeg41m = 0;
                                }
                            } catch {
                                curActualSeg52m = 0;
                                curActualSeg82m = 0;
                                curActualSeg41m = 0;
                            }
                            try {
                                curRunTime = ((DateTime)curRow["LastUpdateDate"]).ToString( "hhmm" );
                            } catch {
                                curRunTime = "0000";
                            }
                            try {
                                if ( curRow["Reride"].ToString().Equals("Y") ) {
                                    curRerideCount++;
                                }
                            } catch {
                            }

                            if ( prevSkierName == curSkierName ) {
                                outLine.Append( "".PadRight( 4, ' ' ) ); //Time HHMM (4)
                                outLine.Append( " " + "".PadRight( 15, ' ' ) ); //Skier Name (15)
                            } else {
                                curSkierCount++;
                                outLine.Append( curRunTime ); //Time HHMM (4)
                                outLine.Append( " " + curSkierName.PadRight( 15, ' ' ) ); //Skier Name (15)
                            }
                            outLine.Append( ( (byte)curRow["PassNum"] ).ToString( "#0" ).PadLeft( 2, ' ' ) ); //Pass Number (2)
                            outLine.Append( " " + ( (byte)curRow["BoatSpeed"] ).ToString( "00" ) ); //Boat Speed KM (2)
                            if ( curResults.ToUpper().Equals( "JUMP" ) || curResults.ToUpper().Equals( "FALL" ) ) {
                                outLine.Append( " " + curScoreFeet.ToString( "#00" ).PadLeft( 3, ' ' ) ); //Distance in Feet (3)
                                outLine.Append( " " + curScoreMeters.ToString( "#0.0" ).PadLeft( 4, ' ' ) ); //Distance in Meters (4)

                                outLine.Append( " " + graphTimeDiff( "1", curSplitTime52M, curActualSeg52m, curSummaryTable, curStatsTable, null ) );
                                outLine.Append( " " + graphTimeDiff( "2", curSplitTime82M, curActualSeg82m, curSummaryTable, curStatsTable, null ) );
                                outLine.Append( " " + graphTimeDiff( "3", curSplitTime41M, curActualSeg41m, curSummaryTable, curStatsTable, null ) );

                            } else {
                                outLine.Append( "     " + curResults.ToUpper().PadLeft( 4, ' ' ) );
                                outLine.Append( " " + graphTimeDiff( "1", curSplitTime52M, curActualSeg52m, curSummaryTable, curStatsTable, null ) );
                                outLine.Append( " " + graphTimeDiff( "2", curSplitTime82M, curActualSeg82m, curSummaryTable, curStatsTable, null ) );
                                outLine.Append( " " + graphTimeDiff( "|", 0, 0, curSummaryTable, curStatsTable, null ) );
                            }

                            //Write output line to file
                            outBuffer.WriteLine( outLine.ToString() );

                            //Initialize output buffer
                            outLine = new StringBuilder( "" );

                            prevSkierName = curSkierName;
                        }
                        writeSummaryJump( curSummaryTable, curStatsTable, curBoatTimeResults, curSkierCount, curRerideCount, outBuffer );
                    }
                }
            } catch ( Exception ex ) {
                MessageBox.Show( "Error: " + curMethodName
                    + "\n\nException: " + ex.Message
                );
            }
            myProgressInfo.Close();
            return curRowCount;
        }
コード例 #34
0
        public void GenerateHistogram(ChartDto chartDto)
        {
            if (chartDto == null)
            {
                return;
            }

            currentChartDto = chartDto;

            Action <string, string> exec = (s, s1) =>
            {
                ChartsListFormViewModel.Instance.ChartsDtoList = StatistiquesBLL.Current.GetChartsDtoList(); //Permet de remettre à jour le graphique
            };

            var progressWindow = new ProgressWindow();

            progressWindow.SetTitle("Chargement en cours");
            var backgroundWorker = new BackgroundWorker();

            // set the worker to call your long-running method
            backgroundWorker.DoWork += (object sender, DoWorkEventArgs e) =>
            {
                exec.Invoke("path", "parameters");
            };

            // set the worker to close your progress form when it's completed
            backgroundWorker.RunWorkerCompleted += (object sender, RunWorkerCompletedEventArgs e) =>
            {
                progressWindow.Close();
            };
            progressWindow.Show();
            backgroundWorker.RunWorkerAsync();

            SeriesCollection = chartDto.SeriesCollection;

            ChartTitle = chartDto.ChartTitle;
            TitleXAxis = chartDto.TitleXAxis;
            TitleYAxis = chartDto.TitleYAxis;
            Labels     = chartDto.Labels.ToArray();
            Formatter  = value => value.ToString("N");

            SeriesCollection = new SeriesCollection();
            foreach (var chartDtoValue in chartDto.Values)
            {
                if (chartDtoValue.Counts != null && chartDtoValue.Counts.Any())
                {
                    SeriesCollection.Add(new ColumnSeries
                    {
                        Title  = chartDtoValue.SerieTitle,
                        Values = new ChartValues <int>(chartDtoValue.Counts)
                    });
                }
                else if (chartDtoValue.DoubleCounts != null && chartDtoValue.DoubleCounts.Any())
                {
                    SeriesCollection.Add(new ColumnSeries
                    {
                        Title  = chartDtoValue.SerieTitle,
                        Values = new ChartValues <double>(chartDtoValue.DoubleCounts)
                    });
                }
            }
        }
コード例 #35
0
        public Boolean exportBoatTimes(String inSanctionId)
        {
            Boolean       returnStatus = false;
            Int16         curSanctionYear = 0;
            char          DoubleQuote = '"';
            String        curMemberId = "", curTourClass = "", curEventDateOut = "", curRunTime = "";
            StringBuilder outLine   = new StringBuilder("");
            StreamWriter  outBuffer = null;

            myProgressInfo = new ProgressWindow();

            DataTable curTourDataTable = getTourData(inSanctionId);

            if (curTourDataTable != null)
            {
                if (curTourDataTable.Rows.Count > 0)
                {
                    curSanctionYear = Convert.ToInt16(inSanctionId.Substring(0, 2));
                    myTourRow       = curTourDataTable.Rows[0];
                    curTourClass    = myTourRow["Class"].ToString().Trim();
                    String curFilename = inSanctionId.Trim() + "JT.csv";
                    outBuffer = getExportFile(curFilename);

                    curEventDateOut = myTourRow["EventDates"].ToString();
                    if (curEventDateOut.Length > 7)
                    {
                        try {
                            DateTime curEventDate = Convert.ToDateTime(curEventDateOut);
                            curEventDateOut = curEventDate.ToString("yyyyMMdd");
                        } catch {
                            curEventDateOut = "";
                        }
                    }
                    else
                    {
                        curEventDateOut = "";
                    }
                    mySkierClassList = new ListSkierClass();
                    mySkierClassList.ListSkierClassLoad();
                    myTourClass = myTourRow["Class"].ToString().ToUpper();
                    myClassCRow = mySkierClassList.SkierClassDataTable.Select("ListCode = 'C'")[0];
                    myClassERow = mySkierClassList.SkierClassDataTable.Select("ListCode = 'E'")[0];
                }
            }
            Decimal curSplitTime30M, curSplitTime52M, curSplitTime82M, curBoatEndTime, curScoreMeters, curScoreFeet;
            Decimal curActualSeg52m, curActualSeg30m, curActualSeg41m, curActualSeg82m;
            String  curResults, curTimeClass;

            if (outBuffer != null)
            {
                outLine.Append("Sanction");
                outLine.Append(", Skier Class");
                outLine.Append(", Boat");
                outLine.Append(", EventDate");
                outLine.Append(", Time");
                outLine.Append(", SkierName");
                outLine.Append(", Div");
                outLine.Append(", Pass");
                outLine.Append(", Speed");
                outLine.Append(", Meters");
                outLine.Append(", Feet");
                outLine.Append(", Time30M");
                outLine.Append(", Time52M");
                outLine.Append(", Time82M");
                outLine.Append(", Time41M");
                outLine.Append(", Actual30M");
                outLine.Append(", Actual52M");
                outLine.Append(", Actual82M");
                outLine.Append(", Actual41M");

                //Write output line to file
                outBuffer.WriteLine(outLine.ToString());
                outLine = new StringBuilder("");


                myProgressInfo.setProgessMsg("Export jump boat times ");
                myProgressInfo.Show();
                myProgressInfo.Refresh();
                int curRowCount = 0;

                DataTable curBoatTimeResults = getBoatTimeResults(inSanctionId);
                myProgressInfo.setProgressMax(curBoatTimeResults.Rows.Count);
                if (curBoatTimeResults != null)
                {
                    foreach (DataRow curRow in curBoatTimeResults.Rows)
                    {
                        curRowCount++;
                        myProgressInfo.setProgressValue(curRowCount);
                        myProgressInfo.Refresh();

                        curTimeClass = getTimeClass((String)curRow["EventClass"]);
                        curResults   = (String)curRow["Results"];
                        try {
                            curSplitTime52M = (Decimal)curRow["BoatSplitTime"];
                        } catch {
                            curSplitTime52M = 0;
                        }
                        try {
                            curSplitTime82M = (Decimal)curRow["BoatSplitTime2"];
                        } catch {
                            curSplitTime82M = 0;
                        }
                        try {
                            curSplitTime30M = curSplitTime82M - curSplitTime52M;
                        } catch {
                            curSplitTime30M = 0;
                        }
                        try {
                            curBoatEndTime = ((Decimal)curRow["BoatEndTime"]);
                        } catch {
                            curBoatEndTime = 0;
                        }
                        try {
                            curScoreMeters = ((Decimal)curRow["ScoreMeters"]);
                        } catch {
                            curScoreMeters = 0;
                        }
                        try {
                            curScoreFeet = ((Decimal)curRow["ScoreFeet"]);
                        } catch {
                            curScoreFeet = 0;
                        }
                        if (curTimeClass.Equals("R"))
                        {
                            try {
                                curActualSeg52m = Convert.ToDecimal((String)curRow["ActualTime52mSeg"]);
                            } catch {
                                curActualSeg52m = 0;
                            }
                            try {
                                curActualSeg41m = Convert.ToDecimal((String)curRow["ActualTime41mSeg"]);
                            } catch {
                                curActualSeg41m = 0;
                            }
                            try {
                                curActualSeg82m = Convert.ToDecimal((String)curRow["ActualTime82mSeg"]);
                            } catch {
                                curActualSeg82m = 0;
                            }
                        }
                        else
                        {
                            try {
                                curActualSeg52m = Convert.ToDecimal((String)curRow["ActualTime52mSegR"]);
                            } catch {
                                curActualSeg52m = 0;
                            }
                            try {
                                curActualSeg41m = Convert.ToDecimal((String)curRow["ActualTime41mSegR"]);
                            } catch {
                                curActualSeg41m = 0;
                            }
                            try {
                                curActualSeg82m = Convert.ToDecimal((String)curRow["ActualTime82mSegR"]);
                            } catch {
                                curActualSeg82m = 0;
                            }
                        }
                        try {
                            curActualSeg30m = curActualSeg82m - curActualSeg52m;
                        } catch {
                            curActualSeg30m = 0;
                        }
                        try {
                            curRunTime = ((DateTime)curRow["LastUpdateDate"]).ToString("hhmm");
                        } catch {
                            curRunTime = "0000";
                        }

                        outLine.Append(DoubleQuote.ToString() + inSanctionId + curTourClass + DoubleQuote.ToString());                                    // 1. (7) SanctionId with class
                        outLine.Append("," + DoubleQuote.ToString() + curRow["EventClass"].ToString() + DoubleQuote.ToString());                          // 2. (1) Skier Class
                        outLine.Append("," + DoubleQuote.ToString() + curRow["Boat"].ToString().PadRight(11, ' ') + DoubleQuote.ToString());              // 3. (11) Boat
                        outLine.Append("," + DoubleQuote.ToString() + curEventDateOut + DoubleQuote.ToString());                                          // 4. (8) Date YYYYMMDD
                        outLine.Append("," + DoubleQuote.ToString() + curRunTime + DoubleQuote.ToString());                                               // 5. (4) Time HHMM
                        outLine.Append("," + DoubleQuote.ToString() + curRow["SkierName"].ToString().PadRight(22, ' ') + DoubleQuote.ToString());         // 6. (22) Skier Name
                        outLine.Append("," + DoubleQuote.ToString() + curRow["AgeGroup"].ToString() + DoubleQuote.ToString());                            // 7. (2) Age Division
                        outLine.Append("," + DoubleQuote.ToString() + ((byte)curRow["PassNum"]).ToString("#0").PadLeft(2, ' ') + DoubleQuote.ToString()); // 8. (2) Pass Number
                        outLine.Append("," + DoubleQuote.ToString() + ((byte)curRow["BoatSpeed"]).ToString("00") + DoubleQuote.ToString());               // 9. (2) Boat Speed KM
                        if (curResults.ToUpper().Equals("JUMP"))
                        {
                            outLine.Append("," + DoubleQuote.ToString() + curScoreMeters.ToString("#0.0").PadLeft(4, ' ') + DoubleQuote.ToString());    //10. (4) Distance in Meters
                            outLine.Append("," + DoubleQuote.ToString() + curScoreFeet.ToString("#00").PadLeft(3, ' ') + DoubleQuote.ToString());       //11. (3) Distance in Feet
                        }
                        else
                        {
                            outLine.Append("," + DoubleQuote.ToString() + curResults.ToUpper() + DoubleQuote.ToString()); //10. (4) Distance in Meters
                            outLine.Append("," + DoubleQuote.ToString() + "   " + DoubleQuote.ToString());                //11. (3) Distance in Feet
                        }
                        outLine.Append(", " + curSplitTime30M.ToString("0.00"));                                          //12. (4 Num) 1st segment 30M Time
                        outLine.Append(", " + curSplitTime52M.ToString("0.00"));                                          //13. (4 Num) 2nd segment 52M Time
                        outLine.Append(", " + curSplitTime82M.ToString("0.00"));                                          //14. (4 Num) 1st & 2nd segment 82M Time
                        outLine.Append(", " + curBoatEndTime.ToString("0.00"));                                           //15. (4 Num) 3rd segment 41M Time

                        outLine.Append(", " + curActualSeg52m.ToString("0.00"));                                          //16. (4 Num) 1st segment 30M Actual
                        outLine.Append(", " + curActualSeg30m.ToString("0.00"));                                          //17. (4 Num) 2nd segment 52M Actual
                        outLine.Append(", " + curActualSeg82m.ToString("0.00"));                                          //18. (4 Num) 1st & 2nd segment 82M Actual
                        outLine.Append(", " + curActualSeg41m.ToString("0.00"));                                          //19. (4 Num) 3rd segment 41M Actual

                        //Write output line to file
                        outBuffer.WriteLine(outLine.ToString());

                        //Initialize output buffer
                        outLine = new StringBuilder("");
                    }
                    myProgressInfo.Close();
                }

                returnStatus = true;
                outBuffer.Close();

                if (curBoatTimeResults.Rows.Count > 0)
                {
                    MessageBox.Show(curBoatTimeResults.Rows.Count + " rows found and written");
                }
                else
                {
                    MessageBox.Show("No rows found");
                }
            }

            return(returnStatus);
        }
コード例 #36
0
        public Boolean ExportData()
        {
            String        curMethodName = "ExportData";
            StringBuilder outLine = new StringBuilder("");
            bool          returnStatus = true;
            int           curRowCount = 0, curEntriesWritten = 0;
            String        curMsg   = "";
            String        tabDelim = "\t";
            String        curValue = "";

            String[]  curValueSplit = null;
            DataRow[] curFindRows   = null;

            try {
                curMsg = "Exporting boat use data";
                Log.WriteFile(curMethodName + ":begin export");

                DataTable curAprvManuDataTable = getApprovedManufacturers();
                DataTable curDataTable         = getTourBoatUseData();

                String curDateString   = DateTime.Now.ToString("yyyyMMdd HH:MM");
                String curDateOut      = curDateString.Substring(0, 8);
                String curTimeOut      = curDateString.Substring(9, 5);
                String curEventDateOut = (String)myTourRow["EventDates"];
                try {
                    DateTime curEventDate = Convert.ToDateTime(curEventDateOut);
                    curEventDateOut = curEventDate.ToString("MM/dd/yyyy");
                } catch {
                    MessageBox.Show("The event date of " + curEventDateOut + " is not a valid date and must corrected");
                    curEventDateOut = myTourRow["EventDates"].ToString();
                }

                String curState = "", curCity = "", curSiteName = "";
                try {
                    String[] curEventLocation = ((String)myTourRow["EventLocation"]).Split(',');
                    if (curEventLocation.Length == 3)
                    {
                        curSiteName = curEventLocation[0];
                        curCity     = curEventLocation[1];
                        curState    = curEventLocation[2];
                    }
                    else
                    {
                        MessageBox.Show("An event location is required."
                                        + "\nPlease enter this information on the tournament window in the following format:\n"
                                        + "\nSite Name followed by a comma, then the city, followed by a comma, then the 2 character state abbreviation"
                                        );
                    }
                } catch {
                    MessageBox.Show("An event location is required."
                                    + "\nPlease enter this information on the tournament window in the following format:\n"
                                    + "\nSite Name followed by a comma, then the city, followed by a comma, then the 2 character state abbreviation"
                                    );
                }

                Cursor.Current = Cursors.WaitCursor;
                StreamWriter outBuffer = null;

                String curFilename    = mySanctionNum + "TU" + ".txt";
                String curReportTitle = "Boat Use data for " + mySanctionNum + " - " + (String)myTourRow["Name"];
                outBuffer = getExportFile(curFilename);


                if (outBuffer == null)
                {
                    curMsg = "Output file not available";
                }
                else
                {
                    Log.WriteFile("Export boat use data file begin: " + curFilename);
                    myProgressInfo = new ProgressWindow();
                    myProgressInfo.setProgessMsg("Processing boat use data");
                    myProgressInfo.Show();
                    myProgressInfo.Refresh();
                    myProgressInfo.setProgressMax(curDataTable.Rows.Count);

                    //Write file header
                    outLine = new StringBuilder("");
                    outLine.Append("SkiYear" + tabDelim);
                    outLine.Append("SanctionNum" + tabDelim);
                    outLine.Append("Regions" + tabDelim);
                    outLine.Append("Tournament Name" + tabDelim);
                    outLine.Append("Class" + tabDelim);
                    outLine.Append("City" + tabDelim);
                    outLine.Append("State" + tabDelim);
                    outLine.Append("Start Date" + tabDelim);
                    outLine.Append("Division" + tabDelim);

                    outLine.Append("Manufacturers" + tabDelim);
                    outLine.Append("Boat Model" + tabDelim);
                    outLine.Append("Year" + tabDelim);
                    outLine.Append("SL" + tabDelim);
                    outLine.Append("TR" + tabDelim);
                    outLine.Append("JU" + tabDelim);
                    outLine.Append("Credit" + tabDelim);
                    outBuffer.WriteLine(outLine.ToString());

                    //Write available data
                    if (curDataTable.Rows.Count > 0)
                    {
                        String curBoatCode = "", prevBoatCode = "";
                        String curSlalomCredit = "", curTrickCredit = "", curJumpCredit = "", curCredit = "";
                        foreach (DataRow curRow in curDataTable.Rows)
                        {
                            curRowCount++;
                            if (isObjectEmpty(curRow["HullId"]))
                            {
                                MessageBox.Show("Towboat data must be updated.  Please open the Boat Use Report and force a data save.  Then you may regenerate this report.");
                            }
                            else
                            {
                                curBoatCode = (String)curRow["HullId"];
                            }

                            if (curBoatCode != prevBoatCode)
                            {
                                if (curRowCount > 1)
                                {
                                    outLine.Append(curSlalomCredit + tabDelim + curTrickCredit + tabDelim + curJumpCredit + tabDelim + curCredit);
                                    outBuffer.WriteLine(outLine.ToString());
                                    curEntriesWritten++;
                                }

                                curSlalomCredit = "FALSE";
                                curTrickCredit  = "FALSE";
                                curJumpCredit   = "FALSE";
                                curCredit       = "FALSE";

                                outLine = new StringBuilder("");
                                outLine.Append("20" + mySanctionNum.Substring(0, 2) + tabDelim);
                                outLine.Append("\"" + mySanctionNum + "\"" + tabDelim);
                                curValue = mySanctionNum.Substring(2, 1);
                                if (curValue.ToUpper().Equals("E"))
                                {
                                    outLine.Append("EAST" + tabDelim);
                                }
                                else if (curValue.ToUpper().Equals("W"))
                                {
                                    outLine.Append("WEST" + tabDelim);
                                }
                                else if (curValue.ToUpper().Equals("S"))
                                {
                                    outLine.Append("SOUTH" + tabDelim);
                                }
                                else if (curValue.ToUpper().Equals("C"))
                                {
                                    outLine.Append("SOUTHCENTRAL" + tabDelim);
                                }
                                else if (curValue.ToUpper().Equals("M"))
                                {
                                    outLine.Append("MIDWEST" + tabDelim);
                                }
                                else
                                {
                                    outLine.Append(curValue + tabDelim);
                                }
                                outLine.Append((String)myTourRow["Name"] + tabDelim);
                                outLine.Append((String)myTourRow["Class"] + tabDelim);
                                outLine.Append(curCity + tabDelim);
                                outLine.Append(curState + tabDelim);
                                outLine.Append(curEventDateOut + tabDelim);
                                outLine.Append(((String)myTourRow["Rules"]).ToUpper() + tabDelim);

                                curValue    = curRow["HullId"].ToString();
                                curFindRows = curAprvManuDataTable.Select("ListCode = '" + curValue.Substring(0, 2).ToUpper() + "'");
                                if (curFindRows.Length > 0)
                                {
                                    curValue = (String)curFindRows[0]["CodeValue"];
                                }
                                else
                                {
                                    curValue = curRow["BoatModel"].ToString();
                                    if (curValue.Length > 0)
                                    {
                                        curValueSplit = curValue.Split(' ');
                                        if (curValueSplit.Length > 0)
                                        {
                                            curValue = curValueSplit[0];
                                            if (curValue.ToLower().Equals("correct"))
                                            {
                                                curValue = "Correct Craft";
                                            }
                                            else if (curValue.ToLower().Equals("master"))
                                            {
                                                curValue = "MasterCraft";
                                            }
                                        }
                                        else
                                        {
                                            curValue = "Unlisted";
                                        }
                                    }
                                    else
                                    {
                                        curValue = "Unlisted";
                                    }
                                }
                                outLine.Append(curValue + tabDelim);
                                outLine.Append(curRow["BoatModel"].ToString() + tabDelim);
                                outLine.Append(curRow["ModelYear"].ToString() + tabDelim);
                            }

                            curValue = curRow["slalomCredit"].ToString();
                            if (curValue.Equals("Y"))
                            {
                                curSlalomCredit = "TRUE";
                                curCredit       = "TRUE";
                            }
                            curValue = curRow["trickCredit"].ToString();
                            if (curValue.Equals("Y"))
                            {
                                curTrickCredit = "TRUE";
                                curCredit      = "TRUE";
                            }
                            curValue = curRow["jumpCredit"].ToString();
                            if (curValue.Equals("Y"))
                            {
                                curJumpCredit = "TRUE";
                                curCredit     = "TRUE";
                            }
                            prevBoatCode = curBoatCode;
                            myProgressInfo.setProgressValue(curRowCount);
                            myProgressInfo.Refresh();
                        }
                        if (curRowCount > 0)
                        {
                            outLine.Append(curSlalomCredit + tabDelim + curTrickCredit + tabDelim + curJumpCredit + tabDelim + curCredit);
                            outBuffer.WriteLine(outLine.ToString());
                            curEntriesWritten++;
                        }
                    }

                    outBuffer.Close();
                    myProgressInfo.Close();
                    if (curDataTable.Rows.Count > 0)
                    {
                        curMsg = curDataTable.Rows.Count + " entries found, " + curEntriesWritten.ToString() + " unique entries selected and written";
                    }
                    else
                    {
                        curMsg = "No rows found";
                    }
                }
                MessageBox.Show(curMsg);
                Log.WriteFile(curMethodName + ":conplete: " + curMsg);
            } catch (Exception ex) {
                MessageBox.Show("Error:" + curMethodName + " Could not write to file\n\nError: " + ex.Message);
                curMsg = curMethodName + ":Exception=" + ex.Message;
                Log.WriteFile(curMsg);
                returnStatus = false;
            }

            return(returnStatus);
        }
コード例 #37
0
ファイル: MainPage.xaml.cs プロジェクト: jaccus/CitySimulator
        private static void RunThread(string cfgName, Action<string, ProgressWindow> action)
        {
            _progressDialog = new ProgressWindow();

            var worker = new BackgroundWorker { WorkerSupportsCancellation = true };
            worker.DoWork +=
                delegate(object s, DoWorkEventArgs args)
                {
                    _progressDialog.Args = args;
                    action.Invoke(cfgName, _progressDialog);

                };
            worker.RunWorkerCompleted += delegate { _progressDialog.Close(); };
            worker.RunWorkerAsync();

            _progressDialog.Worker = worker;
            _progressDialog.ShowDialog();
        }
コード例 #38
0
        protected override void RemoveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (dgResults.SelectedItems.Count == 0 || dgResults.SelectedItem == null)
            {
                return;
            }

            OnReloading = true;

            var materials = dgResults.SelectedItems.OfType <Material>().ToList();

            if (materials.Count > 0)
            {
                var failed       = false;
                var removedCount = 0;
                if (Global.DeleteQuestion(this))
                {
                    var progressResources = new ProgressWindow(materials.Count);
                    progressResources.Show(this);
                    foreach (var material in materials)
                    {
                        var id           = material;
                        var temp         = MaterialsService.Instanse.GetAll().Where(m => m.MaterialID == id.MaterialID).First();
                        var dialogResult = temp.CurrentAmount > 0
                                               ? Global.ReferenceFound(this,
                                                                       string.Format(MaterialsResources.Referenced,
                                                                                     new[] {
                            temp.Name,
                            temp.StringCurrentAmount,
                            temp.StringUnit
                        }))
                                               : MessageBoxResult.Yes;
                        if (dialogResult == MessageBoxResult.Yes)
                        {
                            if (!MaterialsService.Instanse.Remove(material))
                            {
                                failed = true;
                                Global.DeletionFailed(this);
                            }
                            else
                            {
                                removedCount++;
                            }
                        }
                        progressResources.IncreaseProgress();
                    }
                    progressResources.Close();
                    if (materials.Count > 1 && failed)
                    {
                        Global.DeletionSuceededWithSomeFailures(this);
                    }
                    else if (removedCount > 0 & !failed)
                    {
                        Global.DeletionSuceeded(this);
                    }
                    ResetFields();
                    TryToLoad();
                }
            }

            OnReloading = false;
        }
コード例 #39
0
        protected override void RemoveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (dgResults.SelectedItems.Count == 0 || dgResults.SelectedItem == null)
            {
                return;
            }

            OnReloading = true;
            if (_materials)
            {
                var repositoryMaterials = dgResults.SelectedItems.OfType <RepositoryMaterial>().ToList();
                if (repositoryMaterials.Count > 0)
                {
                    var failed       = false;
                    var removedCount = 0;
                    if (Global.DeleteQuestion(this))
                    {
                        var progressResources = new ProgressWindow(repositoryMaterials.Count);
                        progressResources.Show(this);
                        foreach (var repositoryMaterial in repositoryMaterials)
                        {
                            if (!RepositoryMaterialsService.Instanse.Remove(repositoryMaterial))
                            {
                                failed = true;
                                Global.DeletionFailed(this);
                            }
                            else
                            {
                                removedCount++;
                            }
                            progressResources.IncreaseProgress();
                        }
                        progressResources.Close();
                        if (repositoryMaterials.Count > 1 && failed)
                        {
                            Global.DeletionSuceededWithSomeFailures(this);
                        }
                        else if (removedCount > 0 & !failed)
                        {
                            Global.DeletionSuceeded(this);
                        }
                        ResetFields();
                        TryToLoad(cmbFilterBy.SelectedIndex);
                    }
                }
            }
            else
            {
                var repositoryItems = dgResults.SelectedItems.OfType <RepositoryItem>().ToList();
                if (repositoryItems.Count > 0)
                {
                    var failed       = false;
                    var removedCount = 0;
                    if (Global.DeleteQuestion(this))
                    {
                        var progressResources = new ProgressWindow(repositoryItems.Count);
                        progressResources.Show(this);
                        foreach (var repositoryItem in repositoryItems)
                        {
                            if (!RepositoryItemsService.Instanse.Remove(repositoryItem))
                            {
                                failed = true;
                                Global.DeletionFailed(this);
                            }
                            else
                            {
                                removedCount++;
                            }
                            progressResources.IncreaseProgress();
                        }
                        progressResources.Close();
                        if (repositoryItems.Count > 1 && failed)
                        {
                            Global.DeletionSuceededWithSomeFailures(this);
                        }
                        else if (removedCount > 0 & !failed)
                        {
                            Global.DeletionSuceeded(this);
                        }
                        ResetFields();
                        TryToLoad(cmbFilterBy.SelectedIndex);
                    }
                }
            }

            OnReloading = false;
        }
コード例 #40
0
        public bool execCommandFile()
        {
            bool curReturn = true;
            int curDelimIdx;
            decimal curDatabaseVersion = 9999.00M;
            String inputBuffer, curSqlStmt = "";
            StringBuilder curInputCmd = new StringBuilder( "" );
            ImportData curImportData = new ImportData();
            StreamReader myReader;
            myProgressInfo = new ProgressWindow();

            #region Process all commands in the input file
            myReader = getImportFile();
            if ( myReader != null ) {
                int curInputLineCount = 0;
                try {
                    while ( ( inputBuffer = myReader.ReadLine() ) != null ) {
                        curInputLineCount++;
                        myProgressInfo.setProgressValue( curInputLineCount );

                        if ( inputBuffer.TrimStart( ' ' ).StartsWith( "## " ) ) {
                            curDatabaseVersion = Convert.ToDecimal( inputBuffer.Substring( 4 ) );
                        }
                        if ( inputBuffer.TrimStart( ' ' ).StartsWith( "//" ) || inputBuffer.TrimStart( ' ' ).StartsWith( "##" ) ) {
                        } else {
                            if ( curDatabaseVersion > myDatabaseVersion ) {
                                curDelimIdx = inputBuffer.IndexOf( ';' );
                                if ( curDelimIdx >= 0 ) {
                                    if ( curDelimIdx > 0 ) {
                                        curInputCmd.Append( inputBuffer.Substring( 0, curDelimIdx ) );
                                    }
                                    curSqlStmt = curInputCmd.ToString();
                                    curSqlStmt.TrimStart( ' ' );
                                    if ( curSqlStmt.Trim().ToUpper().StartsWith( "DROP " ) ) {
                                        execDropTable( replaceLinefeed( curSqlStmt ) );
                                    } else if ( curSqlStmt.Trim().ToUpper().StartsWith( "CREATE " ) ) {
                                        execCreateTable( replaceLinefeed( curSqlStmt ) );
                                        curInputCmd = new StringBuilder( "" );
                                    } else {
                                        execSchemaCmd( replaceLinefeed( curSqlStmt ) );
                                    }
                                    curInputCmd = new StringBuilder( "" );

                                } else {
                                    curInputCmd.Append( inputBuffer );
                                }
                            }
                        }
                    }
                    curSqlStmt = "";
                    System.Data.SqlServerCe.SqlCeEngine mySqlEngine = new SqlCeEngine();
                    mySqlEngine.LocalConnectionString = Properties.Settings.Default.waterskiConnectionStringApp;
                    mySqlEngine.Shrink();

                } catch ( Exception ex ) {
                    curReturn = false;
                    String ExcpMsg = ex.Message;
                    if ( mySqlStmt != null ) {
                        ExcpMsg += "\n" + curSqlStmt;
                    }
                    MessageBox.Show( "Error attempting to update database schema" + "\n\nError: " + ExcpMsg );
                }
            }
            #endregion

            myProgressInfo.Close();
            return curReturn;
        }
コード例 #41
0
        public static Boolean exportCurrentSkiersRunOrder(String inEvent, String inSanctionId, byte inRound, String inEventGroup)
        {
            String         curMethodName  = "exportCurrentSkiersRunOrder";
            StringBuilder  curSqlStmt     = new StringBuilder("");
            StringBuilder  curXml         = new StringBuilder("");
            String         curMsg         = "";
            Boolean        returnStatus   = false;
            int            curLineCount   = 0;
            DataTable      curDataTable   = new DataTable();
            ProgressWindow myProgressInfo = new ProgressWindow();

            try {
                curSqlStmt.Append("Select TR.SanctionId, TR.MemberId, TR.SkierName, TR.AgeGroup, ER.EventGroup, " + inRound + " as Round ");
                curSqlStmt.Append("From TourReg TR ");
                curSqlStmt.Append("Inner Join EventReg ER on ER.SanctionId = TR.SanctionId AND ER.MemberId = TR.MemberId ");
                curSqlStmt.Append("      AND TR.AgeGroup = ER.AgeGroup AND ER.Event = '" + inEvent + "' ");
                if (inRound > 0)
                {
                    curSqlStmt.Append("Inner Join EventRunOrder RO on RO.SanctionId = TR.SanctionId AND RO.MemberId = TR.MemberId ");
                    curSqlStmt.Append("      AND RO.AgeGroup = TR.AgeGroup AND RO.Event = ER.Event AND RO.Round = " + inRound + " ");
                }
                curSqlStmt.Append("Where TR.SanctionId = '" + inSanctionId + "' ");
                if (inEventGroup != null)
                {
                    if (inEventGroup.Equals("All"))
                    {
                    }
                    else if (inEventGroup.ToUpper().Equals("MEN A"))
                    {
                        curSqlStmt.Append("And ER.AgeGroup = 'CM' ");
                    }
                    else if (inEventGroup.ToUpper().Equals("WOMEN A"))
                    {
                        curSqlStmt.Append("And ER.AgeGroup = 'CW' ");
                    }
                    else if (inEventGroup.ToUpper().Equals("MEN B"))
                    {
                        curSqlStmt.Append("And ER.AgeGroup = 'BM' ");
                    }
                    else if (inEventGroup.ToUpper().Equals("WOMEN B"))
                    {
                        curSqlStmt.Append("And ER.AgeGroup = 'BW' ");
                    }
                    else if (inEventGroup.ToUpper().Equals("NON TEAM"))
                    {
                        curSqlStmt.Append("And ER.AgeGroup not in ('CM', 'CW', 'BM', 'BW') ");
                    }
                    else
                    {
                        curSqlStmt.Append("AND ER.EventGroup = '" + inEventGroup + "' ");
                    }
                }
                curSqlStmt.Append("Order by TR.SanctionId, ER.EventGroup, TR.MemberId, TR.AgeGroup");
                curDataTable = getData(curSqlStmt.ToString());

                myProgressInfo.setProgressMin(1);
                myProgressInfo.setProgressMax(curDataTable.Rows.Count);

                String curMemberId = "", curAgeGroup = "", curSkierName = "";
                byte   curRound = 0;
                foreach (DataRow curRow in curDataTable.Rows)
                {
                    curMemberId  = (String)curRow["MemberId"];
                    curAgeGroup  = (String)curRow["AgeGroup"];
                    curSkierName = (String)curRow["SkierName"];
                    curRound     = (byte)((int)curRow["Round"]);

                    curLineCount++;
                    myProgressInfo.setProgressValue(curLineCount);
                    myProgressInfo.setProgessMsg("Processing " + curSkierName);
                    myProgressInfo.Show();
                    myProgressInfo.Refresh();

                    curXml = new StringBuilder("");
                    curXml.Append("<LiveWebRequest>");

                    curSqlStmt = new StringBuilder("");
                    curSqlStmt.Append("SELECT * FROM TourReg ");
                    curSqlStmt.Append("Where SanctionId = '" + inSanctionId + "' And MemberId = '" + curMemberId + "' And AgeGroup = '" + curAgeGroup + "' ");
                    curXml.Append(exportData("TourReg", new String[] { "SanctionId", "MemberId", "AgeGroup" }, curSqlStmt.ToString(), "Update"));

                    curSqlStmt = new StringBuilder("");
                    curSqlStmt.Append("Select * from EventReg ");
                    curSqlStmt.Append("Where SanctionId = '" + inSanctionId + "' And MemberId = '" + curMemberId + "' And AgeGroup = '" + curAgeGroup + "' ");
                    curSqlStmt.Append("And Event = '" + inEvent + "' ");
                    curXml.Append(exportData("EventReg", new String[] { "SanctionId", "MemberId", "AgeGroup", "Event" }, curSqlStmt.ToString(), "Update"));

                    if (inRound > 0)
                    {
                        curSqlStmt = new StringBuilder("");
                        curSqlStmt.Append("Select * from EventRunOrder ");
                        curSqlStmt.Append("Where SanctionId = '" + inSanctionId + "' And MemberId = '" + curMemberId + "' And AgeGroup = '" + curAgeGroup + "' ");
                        curSqlStmt.Append("And Event = '" + inEvent + "' And Round = " + inRound);
                        curXml.Append(exportData("EventRunOrder", new String[] { "SanctionId", "MemberId", "AgeGroup", "Event", "Round" }, curSqlStmt.ToString(), "Update"));
                    }

                    curXml.Append("</LiveWebRequest>");
                    SendMessageHttp.sendMessagePostXml(LiveWebLocation, curXml.ToString());
                    returnStatus = true;
                }

                myProgressInfo.Close();
            } catch (Exception ex) {
                //MessageBox.Show( "Error encountered trying to send data to web location \n\nError: " + ex.Message );
                curMsg = curMethodName + ":Exception=" + ex.Message;
                Log.WriteFile(curMsg);
            }

            return(returnStatus);
        }
コード例 #42
0
 private void closeProgressWindow()
 {
     _progressWindow?.Close();
 }
コード例 #43
0
        public void importData(String inFileName)
        {
            string inputBuffer, colValue, MatchCommand = "", curMatchCommand = "", curLastUpdateDateIn = "";
            string[] inputCols = null, inputColNames = null, inputKeys = null, curImportDataMatchMsg = { "", "", "", "" };
            char[] tabDelim = new char[] { '\t' };
            char[] singleQuoteDelim = new char[] { '\'' };
            DateTime curLastUpdateDate = new DateTime(), curDateValue = new DateTime();
            Boolean rowFound = false;
            bool curImportConfirmMsg = true;
            int curInputLineCount = 0;
            int idx = 0, rowsRead = 0, rowsfound = 0, rowsAdded = 0, rowsUpdated = 0, rowsSkipped = 0;
            StringBuilder stmtSelect = new StringBuilder( "" );
            StringBuilder stmtWhere = new StringBuilder( "" );
            StringBuilder stmtInsert = new StringBuilder( "" );
            StringBuilder stmtData = new StringBuilder( "" );
            StreamReader myReader = null;
            SqlCeCommand sqlStmt = null;
            SqlCeConnection myDbConn = null;

            DataTable curDataTable = null;
            myProgressInfo = new ProgressWindow();
            ArrayList curFileList = new ArrayList();

            if ( inFileName == null ) {
                curFileList = getImportFileList();
                try {
                    mySanctionNum = Properties.Settings.Default.AppSanctionNum;
                    if ( mySanctionNum == null ) {
                        mySanctionNum = "";
                    } else {
                        if ( mySanctionNum.Length < 6 ) {
                            mySanctionNum = "";
                        }
                    }
                } catch {
                    mySanctionNum = "";
                }
            } else {
                curFileList.Add( inFileName );
                mySanctionNum = "";
            }

            if (curFileList.Count > 0) {
                DialogResult msgResp =
                    MessageBox.Show( "Do you want a confirmation dialog for each successful data type imported?", "Confirmation",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Warning,
                        MessageBoxDefaultButton.Button1 );
                if (msgResp == DialogResult.Yes) {
                    curImportConfirmMsg = true;
                } else {
                    curImportConfirmMsg = false;
                }

                try {
                    myDbConn = new global::System.Data.SqlServerCe.SqlCeConnection();
                    myDbConn.ConnectionString = Properties.Settings.Default.waterskiConnectionStringApp;
                    myDbConn.Open();

                    foreach (String curFileName in curFileList) {
                        myReader = getImportFile( curFileName );
                        if (myReader != null) {
                            curInputLineCount = 0;

                            while (( inputBuffer = myReader.ReadLine() ) != null) {
                                curInputLineCount++;
                                myProgressInfo.setProgressValue( curInputLineCount );

                                rowFound = false;
                                inputCols = inputBuffer.Split( tabDelim );

                                if (inputCols[0].ToLower().Equals( "table:" ) || inputCols[0].ToLower().Equals( "tablename:" )) {
                                    //Display statistics when another table entry is found
                                    if (myTableName != null) {
                                        if (curImportConfirmMsg) {
                                            MessageBox.Show( "Info: Import data processed for " + myTableName
                                                + "\nRows Read: " + rowsRead
                                                + "\nRows Added: " + rowsAdded
                                                + "\nRows Matched: " + rowsfound
                                                + "\nRows Updated: " + rowsUpdated
                                                + "\nRows Skipped: " + rowsSkipped
                                                );
                                            rowsRead = 0;
                                            rowsfound = 0;
                                            rowsAdded = 0;
                                            rowsUpdated = 0;
                                            rowsSkipped = 0;
                                        }
                                    }
                                    //Check for table name and assume all subsequent records are for this table
                                    TableName = inputCols[1];
                                    myProgressInfo.setProgessMsg( "Processing " + TableName );
                                    myProgressInfo.Refresh();

                                    inputColNames = null;
                                    inputKeys = getTableKeys( TableName );
                                } else if (inputColNames == null) {
                                    //Column names are required and must preceed the data rows
                                    inputColNames = new string[inputCols.Length];
                                    for (idx = 0; idx < inputCols.Length; idx++) {
                                        inputColNames[idx] = inputCols[idx];
                                    }
                                } else {
                                    #region Process data rows for table and columns on input file
                                    //Process data rows.  Table name and column names are required
                                    //before data rows can be processed
                                    if (myTableName == null) {
                                        MessageBox.Show( "Error: Table name not provide.  Unable to process import file." );
                                        break;
                                    } else if (inputColNames == null) {
                                        MessageBox.Show( "Error: Column definitions not provide.  Unable to process import file." );
                                        break;
                                    } else {
                                        rowsRead++;
                                        stmtSelect = new StringBuilder( "" );
                                        stmtWhere = new StringBuilder( "" );
                                        sqlStmt = myDbConn.CreateCommand();

                                        if (inputKeys != null) {
                                            //Use update date if available
                                            curLastUpdateDateIn = findColValue( "LastUpdateDate", inputColNames, inputCols );
                                            if (curLastUpdateDateIn == null) curLastUpdateDateIn = "";

                                            #region Identify key columns if available
                                            //Use key column data items to see if input row already exists on database
                                            foreach (string keyName in inputKeys) {
                                                colValue = findColValue( keyName, inputColNames, inputCols );
                                                if (colValue == null) colValue = "";
                                                if (stmtSelect.Length > 1) {
                                                    stmtSelect.Append( ", " + keyName );
                                                    stmtWhere.Append( " AND " + keyName + " = '" + colValue + "'" );
                                                } else {
                                                    stmtSelect.Append( "Select " );
                                                    if (curLastUpdateDateIn.Length > 0) {
                                                        stmtSelect.Append( "LastUpdateDate, " );
                                                    }
                                                    stmtSelect.Append( keyName );
                                                    stmtWhere.Append( " Where  " + keyName + " = '" + colValue + "'" );
                                                }
                                            }

                                            try {
                                                curMatchCommand = "";
                                                curDataTable = getData( stmtSelect.ToString() + " From " + myTableName + stmtWhere.ToString() );
                                                if (curDataTable.Rows.Count > 0) {
                                                    rowFound = true;
                                                    rowsfound++;
                                                    if (!( MatchCommand.ToLower().Equals( "skipall" ) )) {
                                                        if (curLastUpdateDateIn.Length > 0) {
                                                            try {
                                                                curLastUpdateDate = (DateTime)curDataTable.Rows[0]["LastUpdateDate"];
                                                                curDateValue = Convert.ToDateTime( curLastUpdateDateIn );
                                                                if (curDateValue > curLastUpdateDate) {
                                                                    curMatchCommand = "Update";
                                                                } else {
                                                                    curMatchCommand = "Skip";
                                                                }
                                                            } catch {
                                                                curMatchCommand = "Update";
                                                                curLastUpdateDate = Convert.ToDateTime( "01/01/2000" );
                                                            }
                                                        }
                                                    }
                                                }
                                            } catch (Exception ex) {
                                                String ExcpMsg = ex.Message;
                                                MessageBox.Show( "Error: Checking " + myTableName + " for import data"
                                                    + "\n\nError: " + ExcpMsg
                                                    );
                                                return;
                                            }
                                            #endregion
                                        }

                                        stmtInsert = new StringBuilder( "" );
                                        stmtData = new StringBuilder( "" );

                                        if (rowFound) {
                                            #region Show information if input data found on database
                                            //Show information if input data found on database
                                            //Skip display if previoius display specfied to process all records the same
                                            if (MatchCommand.Length < 2) {
                                                if (curMatchCommand.Equals( "" ) || curMatchCommand.ToLower().Equals( "update" )) {
                                                    curImportDataMatchMsg[0] = "Table: " + myTableName;
                                                    curImportDataMatchMsg[1] = stmtWhere.ToString();
                                                    if (curMatchCommand.ToLower().Equals( "update" )) {
                                                        curImportDataMatchMsg[2] = "Current record date = " + curLastUpdateDate.ToString();
                                                        curImportDataMatchMsg[3] = " Import record date = " + curLastUpdateDateIn;
                                                    } else {
                                                        curImportDataMatchMsg[2] = "";
                                                        curImportDataMatchMsg[3] = "";
                                                    }
                                                    MatchDialog.ImportKeyDataMultiLine = curImportDataMatchMsg;
                                                    MatchDialog.MatchCommand = MatchCommand;
                                                    if (MatchDialog.ShowDialog() == DialogResult.OK) {
                                                        MatchCommand = MatchDialog.MatchCommand;
                                                    }
                                                }
                                            }

                                            if (curMatchCommand.Equals( "skip" )) {
                                                rowsSkipped++;
                                                //Re-initialize dialog response unless specified to process rows
                                                if (MatchCommand.ToLower().Equals( "skip" )) {
                                                    MatchCommand = "";
                                                }
                                            } else {
                                                if (MatchCommand.ToLower().Equals( "update" )
                                                    || MatchCommand.ToLower().Equals( "updateall" )) {
                                                    //Build update command with input record if specified
                                                    idx = 0;
                                                    foreach (string colName in inputColNames) {
                                                        if (inputKeys.Contains( colName ) || colName.ToLower().Equals( "pk" )) {
                                                        } else if (colName.Equals( "TimeInTol1" )
                                                                || colName.Equals( "TimeInTol2" )
                                                                || colName.Equals( "TimeInTol3" )
                                                                || colName.Equals( "BoatSplitTimeTol" )
                                                                || colName.Equals( "BoatSplitTime2Tol" )
                                                                || colName.Equals( "BoatEndTimeTol" )
                                                                || ( colName.Equals( "Pass1VideoUrl" ) && myTableName.Equals( "TrickScore" ) )
                                                                || ( colName.Equals( "Pass2VideoUrl" ) && myTableName.Equals( "TrickScore" ) )
                                                                ) {
                                                        } else {
                                                            if (stmtData.Length > 1) {
                                                                stmtData.Append( ", [" + colName + "] = " );
                                                            } else {
                                                                stmtData.Append( "[" + colName + "] = " );
                                                            }
                                                            if (inputCols[idx].Length > 0) {
                                                                String tempValue = stringReplace( inputCols[idx], singleQuoteDelim, "''" );
                                                                stmtData.Append( "'" + tempValue + "'" );
                                                            } else {
                                                                if (inputKeys.Contains( colName )) {
                                                                    stmtData.Append( " ''" );
                                                                } else {
                                                                    stmtData.Append( " null" );
                                                                }
                                                            }
                                                        }
                                                        idx++;
                                                    }
                                                    try {
                                                        //Update database with input record if specified
                                                        //Delete detail if event scores which assumes the detail will also be imported
                                                        if (myTableName.ToLower().Equals( "slalomscore" )) {
                                                            sqlStmt.CommandText = "Delete SlalomRecap " + stmtWhere.ToString();
                                                            int rowsDeleted = sqlStmt.ExecuteNonQuery();
                                                        } else if (myTableName.ToLower().Equals( "trickscore" )) {
                                                            sqlStmt.CommandText = "Delete TrickPass " + stmtWhere.ToString();
                                                            int rowsDeleted = sqlStmt.ExecuteNonQuery();
                                                        } else if (myTableName.ToLower().Equals( "jumpscore" )) {
                                                            sqlStmt.CommandText = "Delete JumpRecap " + stmtWhere.ToString();
                                                            int rowsDeleted = sqlStmt.ExecuteNonQuery();
                                                        }
                                                        sqlStmt.CommandText = "Update "
                                                            + myTableName
                                                            + " set " + stmtData.ToString()
                                                            + stmtWhere.ToString();
                                                        int rowsProc = sqlStmt.ExecuteNonQuery();
                                                        rowsUpdated++;
                                                    } catch (Exception ex) {
                                                        String ExcpMsg = ex.Message;
                                                        if (sqlStmt != null) {
                                                            ExcpMsg += "\n" + sqlStmt.CommandText;
                                                        }
                                                        MessageBox.Show( "Error: Adding import data to " + myTableName
                                                            + "\n\nError: " + ExcpMsg
                                                            );
                                                        return;
                                                    }
                                                    //Re-initialize dialog response unless specified to process rows
                                                    if (MatchCommand.ToLower().Equals( "update" )) {
                                                        MatchCommand = "";
                                                    }

                                                } else {
                                                    rowsSkipped++;
                                                    //Re-initialize dialog response unless specified to process rows
                                                    if (MatchCommand.ToLower().Equals( "skip" )) {
                                                        MatchCommand = "";
                                                    }
                                                }
                                            }
                                            #endregion
                                        } else {
                                            #region New data identified and will be added
                                            //Database record does not exist therefore data is added to database
                                            //Build insert command
                                            idx = 0;
                                            foreach (string colName in inputColNames) {
                                                if (colName.ToLower().Equals( "pk" )
                                                    || colName.Equals( "TimeInTol1" )
                                                    || colName.Equals( "TimeInTol2" )
                                                    || colName.Equals( "TimeInTol3" )
                                                    || colName.Equals( "BoatSplitTimeTol" )
                                                    || colName.Equals( "BoatSplitTime2Tol" )
                                                    || colName.Equals( "BoatEndTimeTol" )
                                                    || ( colName.Equals( "Pass1VideoUrl" ) && myTableName.Equals( "TrickScore" ) )
                                                    || ( colName.Equals( "Pass2VideoUrl" ) && myTableName.Equals( "TrickScore" ) )
                                                    ) {
                                                } else {
                                                    if (stmtInsert.Length > 1) {
                                                        stmtInsert.Append( ", [" + colName + "]" );
                                                        if (inputCols[idx].Length > 0) {
                                                            String tempValue = stringReplace( inputCols[idx], singleQuoteDelim, "''" );
                                                            stmtData.Append( ", '" + tempValue + "'" );
                                                        } else {
                                                            if (inputKeys.Contains( colName )) {
                                                                stmtData.Append( ", ''" );
                                                            } else {
                                                                stmtData.Append( ", null" );
                                                            }
                                                        }
                                                    } else {
                                                        stmtInsert.Append( "[" + colName + "]" );
                                                        if (inputCols[idx].Length > 0) {
                                                            String tempValue = stringReplace( inputCols[idx], singleQuoteDelim, "''" );
                                                            stmtData.Append( "'" + tempValue + "'" );
                                                        } else {
                                                            if (inputKeys.Contains( colName )) {
                                                                stmtData.Append( "''" );
                                                            } else {
                                                                stmtData.Append( "null" );
                                                            }
                                                        }
                                                    }
                                                }
                                                idx++;
                                            }
                                            try {
                                                sqlStmt.CommandText = "Insert "
                                                    + myTableName + " (" + stmtInsert.ToString()
                                                    + ") Values (" + stmtData.ToString() + ")";
                                                int rowsProc = sqlStmt.ExecuteNonQuery();
                                                rowsAdded++;
                                            } catch (Exception ex) {
                                                rowsSkipped++;
                                                String ExcpMsg = ex.Message;
                                                if (sqlStmt != null) {
                                                    ExcpMsg += "\n" + sqlStmt.CommandText;
                                                }
                                                MessageBox.Show( "Error: Adding import data to " + myTableName
                                                    + "\n\nError: " + ExcpMsg
                                                    );
                                            }
                                            #endregion
                                        }
                                    }
                                    #endregion
                                }
                            }

                            if (inFileName == null) {
                                if (curImportConfirmMsg) {
                                    MessageBox.Show( "Info: Import data processed for " + myTableName
                                        + "\nRows Read: " + rowsRead
                                        + "\nRows Added: " + rowsAdded
                                        + "\nRows Matched: " + rowsfound
                                        + "\nRows Updated: " + rowsUpdated
                                        + "\nRows Skipped: " + rowsSkipped
                                        );
                                } else {
                                    MessageBox.Show( "Info: Total import data processed"
                                        + "\nRows Read: " + rowsRead
                                        + "\nRows Added: " + rowsAdded
                                        + "\nRows Matched: " + rowsfound
                                        + "\nRows Updated: " + rowsUpdated
                                        + "\nRows Skipped: " + rowsSkipped
                                        );
                                }
                                rowsRead = 0;
                                rowsAdded = 0;
                                rowsfound = 0;
                                rowsUpdated = 0;
                                rowsSkipped = 0;
                            }
                        }
                    }

                } catch (Exception ex) {
                    String ExcpMsg = ex.Message;
                    if (sqlStmt != null) {
                        ExcpMsg += "\n" + sqlStmt.CommandText;
                    }
                    MessageBox.Show( "Error: Performing SQL operations" + "\n\nError: " + ExcpMsg );
                } finally {
                    myDbConn.Close();
                    myReader.Close();
                    myReader.Dispose();
                }
                myProgressInfo.Close();
            }
        }
コード例 #44
0
        /// <summary>
        ///     Entry point of the map loading thread.
        /// </summary>
        private void LoadMapThread()
        {
            ProgressWindow window = new ProgressWindow("Loading map", "Loading map");
            window.Show();

            while (_mapLoaded == false)
            {
                window.Progress = Engine.Engine.GlobalInstance.Map.LoadingProgress;
                Application.DoEvents();
                Thread.Sleep(0);
            }

            window.Close();
        }
コード例 #45
0
        public static void ZipFiles(string inputFolderPath, string outputPathAndFile, string password, ArrayList inFileFilterList)
        {
            /* ------------------------------------------------------
            *  ------------------------------------------------------ */
            // generate file list
            ArrayList curFileList = GenerateFileList(inputFolderPath);

            // find number of chars to remove from orginal file path
            //int TrimLength = ( Directory.GetParent( inputFolderPath ) ).ToString().Length;
            int TrimLength = inputFolderPath.Length;

            if (!(inputFolderPath.Substring(inputFolderPath.Length - 1).Equals("\\")))
            {
                TrimLength++;
            }
            //TrimLength += 1; //remove '\'

            FileStream curOutputStream;

            byte[] curOutputBuffer;
            string outPath = inputFolderPath + @"\" + outputPathAndFile;

            // create zip stream
            ZipOutputStream curOutputZipStream = new ZipOutputStream(File.Create(outPath));

            if (password != null && password != String.Empty)
            {
                curOutputZipStream.Password = password;
            }

            // maximum compression
            curOutputZipStream.SetLevel(9);
            ZipEntry oZipEntry;
            //oZipEntry.ExternalFileAttributes;
            //oZipEntry.

            ProgressWindow curProgressInfo = new ProgressWindow();

            curProgressInfo.setProgressMin(1);
            curProgressInfo.setProgressMax(curFileList.Count);
            int    curFileCount = 0;
            int    curFileIndex = 0;
            String curFileNameOnly, curIwwfHomFileName = "";

            // for each file, generate a zipentry
            foreach (string curFileFilter in inFileFilterList)
            {
                curFileIndex = 1;
                if (curFileFilter.EndsWith("hd.txt"))
                {
                    curIwwfHomFileName = curFileFilter.ToUpper();
                }
                foreach (string curFileName in curFileList)
                {
                    curFileNameOnly = curFileName.Remove(0, TrimLength);

                    if (System.Text.RegularExpressions.Regex.IsMatch(curFileNameOnly, curFileFilter, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                    {
                        //MessageBox.Show( "Index=" + curFileIndex + ", FileName=" + curFileNameOnly + ", File Filter=" + curFileFilter );
                        if (curFileFilter.Equals(".hom$"))
                        {
                            curFileNameOnly = curIwwfHomFileName;
                        }

                        curFileCount++;
                        curProgressInfo.setProgessMsg("Processing " + curFileName);
                        curProgressInfo.setProgressValue(curFileCount);
                        curProgressInfo.Show();
                        curProgressInfo.Refresh();

                        oZipEntry          = new ZipEntry((curFileNameOnly));
                        oZipEntry.DateTime = File.GetLastWriteTime(curFileName);
                        curOutputZipStream.PutNextEntry(oZipEntry);

                        // if a file ends with '/' its a directory
                        if (!curFileName.EndsWith(@"/"))
                        {
                            try {
                                curOutputStream = File.OpenRead(curFileName);
                                curOutputBuffer = new byte[curOutputStream.Length];
                                curOutputStream.Read(curOutputBuffer, 0, curOutputBuffer.Length);
                                curOutputZipStream.Write(curOutputBuffer, 0, curOutputBuffer.Length);
                                curOutputStream.Close();
                            } catch (Exception ex) {
                                curProgressInfo.setProgessMsg("Bypassing busy file " + curFileName);
                                curProgressInfo.Show();
                                curProgressInfo.Refresh();
                            }
                        }
                    }
                    curFileIndex++;
                }
            }

            curOutputZipStream.Finish();
            curOutputZipStream.Close();
            curProgressInfo.Close();
        }
コード例 #46
0
        /// <summary>
        ///		Saves the current map to a given url.
        /// </summary>
        /// <param name="url">Url of file to save map to.</param>
        public void SaveMap(object url)
        {
            if (File.Exists(url.ToString()))
                File.Copy(url.ToString(), url.ToString() + ".bk", true);

            _mapUrl = url as string;
            _mapThread = new Thread(new ThreadStart(SaveMapThread));
            _mapThread.IsBackground = true;
            _mapThread.Start();

            ProgressWindow window = new ProgressWindow("Saving map", "Saving map");
            window.Marquee = true;
            window.Show(this);

            while (_mapThread != null && _mapThread.IsAlive == true)
                Application.DoEvents();

            window.Close();
            _mapThread = null;

            _mapFileUrl = url;
            Text = "Fusion Editor - " + Path.GetFileName((string)_mapFileUrl);
            _mapChangedSinceSave = false;
        }
コード例 #47
0
    /// <summary>Updates the templates.</summary>
    private void UpdateTemplates()
    {
      var window = new ProgressWindow();
      try
      {
        int maxTemplates;
        if (!int.TryParse(this.MaxTemplates.Text, out maxTemplates))
        {
          MessageBox.Show("Max Suggestions must be a number.");
          return;
        }

        int occurances;
        if (!int.TryParse(this.Occurances.Text, out occurances))
        {
          MessageBox.Show("Occurances must be a number.");
          return;
        }

        int minPercentage;
        if (!int.TryParse(this.MinPercentage.Text, out minPercentage))
        {
          MessageBox.Show("Minimum Percentage must be a number.");
          return;
        }

        window.Show();

        var builder = new AutoTemplateBuilder();
        builder.Process(window.ProgressIndicator, maxTemplates, occurances, minPercentage);

        AutoTemplateManager.Invalidate();

        this.RefreshInfo();
      }
      finally
      {
        if (window.Visible)
        {
          window.Close();
        }
      }
    }
コード例 #48
0
        private bool updateSchema(String inFileRef)
        {
            bool          curReturnValue = true;
            int           curDelimIdx;
            String        inputBuffer, curSqlStmt = "";
            StringBuilder curInputCmd   = new StringBuilder("");
            ImportData    curImportData = new ImportData();
            StreamReader  myReader;

            myProgressInfo = new ProgressWindow();

            try {
                #region Process all commands in the input file
                myReader = getImportFile(inFileRef);
                if (myReader != null)
                {
                    int curInputLineCount = 0;
                    try {
                        MessageBox.Show("Your database is about to be upgraded.  Please click OK or continue to any dialogs.");

                        while ((inputBuffer = myReader.ReadLine()) != null)
                        {
                            curInputLineCount++;
                            myProgressInfo.setProgressValue(curInputLineCount);

                            if (inputBuffer.TrimStart(' ').StartsWith("//"))
                            {
                            }
                            else
                            {
                                curDelimIdx = inputBuffer.IndexOf(';');
                                if (curDelimIdx >= 0)
                                {
                                    if (curDelimIdx > 0)
                                    {
                                        curInputCmd.Append(inputBuffer.Substring(0, curDelimIdx));
                                    }
                                    curSqlStmt = curInputCmd.ToString();
                                    curSqlStmt.TrimStart(' ');
                                    if (curSqlStmt.Trim().ToUpper().StartsWith("DROP "))
                                    {
                                        execDropTable(replaceLinefeed(curSqlStmt));
                                    }
                                    else if (curSqlStmt.Trim().ToUpper().StartsWith("CREATE "))
                                    {
                                        execCreateTable(replaceLinefeed(curSqlStmt));
                                        curInputCmd = new StringBuilder("");
                                    }
                                    else
                                    {
                                        execSchemaCmd(replaceLinefeed(curSqlStmt));
                                    }
                                    curInputCmd = new StringBuilder("");
                                }
                                else
                                {
                                    curInputCmd.Append(inputBuffer);
                                }
                            }
                        }
                        curSqlStmt = "";
                        System.Data.SqlServerCe.SqlCeEngine mySqlEngine = new SqlCeEngine();
                        mySqlEngine.LocalConnectionString = Properties.Settings.Default.waterskiConnectionStringApp;
                        mySqlEngine.Shrink();
                    } catch (Exception ex) {
                        curReturnValue = false;
                        String ExcpMsg = ex.Message;
                        if (mySqlStmt != null)
                        {
                            ExcpMsg += "\n" + curSqlStmt;
                        }
                        MessageBox.Show("Error attempting to update database schema" + "\n\nError: " + ExcpMsg);
                    }
                }
                #endregion
            } catch (Exception ex) {
                curReturnValue = false;
                String ExcpMsg = ex.Message;
                if (mySqlStmt != null)
                {
                    ExcpMsg += "\n" + mySqlStmt.CommandText;
                }
                MessageBox.Show("Error attempting to update database schema" + "\n\nError: " + ExcpMsg);
            }
            myProgressInfo.Close();

            return(curReturnValue);
        }
コード例 #49
0
        private void btnInstallNow_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string localInstallerPath = App.AppTempPath + "Setup.exe";
                var pw = new ProgressWindow("Please wait while the installer is being downloaded...\n" + _installerURL);
                pw.Show();
                var webClient = new WebClient();
                webClient.DownloadProgressChanged += delegate(object o, DownloadProgressChangedEventArgs args)
                    {
                        pw.SetProgressBarValue(args.ProgressPercentage);
                    };
                webClient.DownloadFileCompleted += delegate
                    {
                        pw.CanClose = true;
                        pw.Close();
                        if (
                            MessageBox.Show(
                                "NBA Stats Tracker will now close to install the latest version and then restart.\n\nAre you sure you want to continue?",
                                "NBA Stats Tracker", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) !=
                            MessageBoxResult.Yes)
                        {
                            return;
                        }

                        string newUpdaterPath = App.AppTempPath + "\\Updater.exe";
                        try
                        {
                            File.Copy(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Updater.exe", newUpdaterPath,
                                      true);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Couldn't run the Updater. " + ex.Message);
                            return;
                        }
                        Process.Start(newUpdaterPath, "\"" + localInstallerPath + "\"");
                        Environment.Exit(0);
                    };
                webClient.DownloadFileAsync(new Uri(_installerURL), localInstallerPath);
            }
            catch (Exception ex)
            {
                MessageBox.Show("The changelog couldn't be downloaded at this time. Please try again later.\n\n" + ex.Message);
            }
        }
コード例 #50
0
        public void deleteQuota()
        {
            if (isCompleted())
            {
                string txtServerPath = this.txtServer.Text;
                if (txtServerPath.Length > 0)
                {
                    if (txtServerPath.ElementAt(txtServerPath.Length - 1).ToString() != "\\")
                    {
                        txtServerPath += "\\";
                    }
                }

                QuotaControl q = new QuotaControl();
                DialogResult cont = DialogResult.Abort;
                if (this.txtServer.Text != "")
                {
                    q.FILESHAREVOLUME1 = txtServerPath + this.cboShares.Items
                        [this.cboShares.SelectedIndex].ToString() + "\\";
                }

                try
                {
                    q.GetQuota(lstUsers.SelectedItems[0].ToString());
                    cont = DialogResult.Yes;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("The user selected doesn't have a quota on this share");
                }

                if (cont == DialogResult.Yes)
                {
                    int i = 0;
                    ProgressWindow pgWindow = new ProgressWindow("Deleting Users...", lstUsers.SelectedItems.Count);
                    pgWindow.Show();
                    pgWindow.SetPercentDone(i);
                    foreach (string cn in lstUsers.SelectedItems)
                    {

                        pgWindow.SetPercentDone(i);
                        i++;

                        if (txtServer.Text != "")
                        {
                            try
                            {
                                string domain = this.cboDC.Items[cboDC.SelectedIndex].ToString();
                                domain = domain.Substring(0, domain.IndexOf("."));
                                q.Remove(domain + cn);
                            }
                            catch (Exception ex)
                            {
                                //User already knows that the quota won't be deleted,
                                //no need to display error message here.
                            }
                        }
                    }

                    pgWindow.Close();
                    //Delete users in active directory

                }
            }
            else
            {
                MessageBox.Show(ec.getMsg());
            }
        }
コード例 #51
0
        /// <summary>
        ///Function: go through an populates an arrayList containing all writable user attributes.
        /// </summary>
        private void createWriteableAttribList()
        {
            //First, get schemea of properties, both single and multivalued
            //Get current server
            string ADServer = Environment.GetEnvironmentVariable("LOGONSERVER");
            //Remove the "//"
            ADServer = ADServer.Substring(2);
            //Get the selected domain
            string domainName = cboDC.Text.ToString();
            //Concatenate to make full server name
            string fullServerName = ADServer + "." + domainName;
            //MessageBox.Show("The directory context is: " + fullServerName);
            //Specify server stuff                                                                ex. "prjdc.project.com"
            DirectoryContext adamContext = new DirectoryContext(DirectoryContextType.DirectoryServer, fullServerName);
            //MessageBox.Show(adamContext.Name);

            //Get schema for that servers active directory
            ActiveDirectorySchema schema = ActiveDirectorySchema.GetSchema(adamContext);

            /*
            // Test for getting all classes
            foreach (ActiveDirectorySchemaClass schemaClass in schema.FindAllClasses())
            {
                MessageBox.Show(schemaClass.GetAllProperties().ToString());
            }
            */

            //Get the user schema class
            ActiveDirectorySchemaClass schemaClass = schema.FindClass("user");

            //Now that we have the correct class, GET ALL PROPERTIES in that class (these properties themselves are readonly because we don't want to alter them)
            ReadOnlyActiveDirectorySchemaPropertyCollection adPropertyCollection = schemaClass.GetAllProperties(); //There are 342

            //http://stackoverflow.com/questions/4931982/how-can-i-check-if-a-user-has-write-rights-in-active-directory-using-c

            //Find the current logged on user that will be modfying user properties
            string userName = Environment.UserName;
            //Get the users domain
            string userDomainName = Environment.UserDomainName;
            //MessageBox.Show("The domain name which the user is in: " + userDomainName);

            DirectoryEntry de = new DirectoryEntry();
            de.Path = "LDAP://" + userDomainName;
            de.AuthenticationType = AuthenticationTypes.Secure;

            DirectorySearcher deSearch = new DirectorySearcher();

            deSearch.SearchRoot = de;
            deSearch.Filter = "(&(objectClass=user) (cn=" + userName + "))";

            SearchResult result = deSearch.FindOne();

            DirectoryEntry deUser = new DirectoryEntry(result.Path);

            //Refresh Cache to get the values, I guess?
            deUser.RefreshCache(new string[] { "allowedAttributesEffective" });

            // Proof this is the user
            //MessageBox.Show("About to show the username: "******"cn"].Value.ToString());
            //MessageBox.Show("About to show the users distinguished name: " + deUser.Properties["distinguishedName"].Value.ToString());

            //Now get the property["allowedAttributesEffective"] of the user

            //Test on a property that did not have to refresh cache for, just to ensure enumeration was working
            //string propertyName = deUser.Properties["otherHomePhone"].PropertyName;

            string propertyName = deUser.Properties["allowedAttributesEffective"].PropertyName;

            //MessageBox.Show("About to loop through the multi-valued property: " + deUser.Properties["allowedAttributesEffective"].PropertyName);
            //MessageBox.Show("About to loop through the multi-valued property: " + propertyName);
            //MessageBox.Show("Number of elements: " + deUser.Properties[propertyName].Count);

            alWritableProperties.Clear();
            //Go through all the elements of that multi-valued property
            IEnumerator propEnumerator = deUser.Properties[propertyName].GetEnumerator(); //Getting the Enumerator

            propEnumerator.Reset(); //Position at the Beginning

            //Loading Bar for writable properties
            int i = 0;
            ProgressWindow pwBar = new ProgressWindow("Finding Writable User Properties", deUser.Properties[propertyName].Count);
            pwBar.Show();
            pwBar.SetPercentDone(i);

            while (propEnumerator.MoveNext()) //while there is a next one to move to
            {
                //MessageBox.Show("" + propEnumerator.Current.ToString());
                try
                {
                    ActiveDirectorySchemaProperty propertyToTest = new ActiveDirectorySchemaProperty(adamContext, propEnumerator.Current.ToString());
                    //See if property is writable
                    //is property single valued
                    if (adPropertyCollection[adPropertyCollection.IndexOf(propertyToTest)].IsSingleValued == true)
                    {
                        //Single valued comparison
                        deUser.Properties[propEnumerator.Current.ToString()].Value = deUser.Properties[propEnumerator.Current.ToString()].Value;
                    }
                    else
                    {
                        //Multi-valued comparison (Not implemented)

                        //http://stackoverflow.com/questions/5067363/active-directory-unable-to-add-multiple-email-addresses-in-multi-valued-propert

                        //MessageBox.Show("Dealing with multivalued property: " + propEnumerator.Current.ToString());

                        //deUser.Properties[propEnumerator.Current.ToString()].Clear();
                        //deUser.Properties[propEnumerator.Current.ToString()].Count;
                        //MessageBox.Show("Number of elements: " + deUser.Properties[propEnumerator.Current.ToString()].Count.ToString());
                        //deUser.Properties[propEnumerator.Current.ToString()].Value = deUser.Properties[propEnumerator.Current.ToString()].Value;
                        /*
                        if (propEnumerator.Current.ToString().Equals("departmentNumber"))
                        {
                            MessageBox.Show("Number of elements before: " + deUser.Properties[propEnumerator.Current.ToString()].Count.ToString());
                            deUser.Properties[propEnumerator.Current.ToString()].Add("9");
                            MessageBox.Show("Number of elements after: " + deUser.Properties[propEnumerator.Current.ToString()].Count.ToString());
                            //MessageBox.Show("Number of elements before: " + deUser.Properties[propEnumerator.Current.ToString()].Count.ToString());
                            //object tempObject = deUser.Properties[propEnumerator.Current.ToString()].Value;
                            //deUser.Properties[propEnumerator.Current.ToString()].Clear();
                            //MessageBox.Show("Number of elements now cleared: " + deUser.Properties[propEnumerator.Current.ToString()].Count.ToString());
                            //deUser.Properties[propEnumerator.Current.ToString()].Value = tempObject;
                            //MessageBox.Show("Number of elements after: " + deUser.Properties[propEnumerator.Current.ToString()].Count.ToString());
                        }
                        */
                    }

                    deUser.CommitChanges();

                    //Add to array since it is writable
                    alWritableProperties.Add(propEnumerator.Current.ToString());
                }
                catch (Exception e)
                {
                    //MessageBox.Show(propEnumerator.Current.ToString() + " can only be viewed" + e.Message);
                }
                pwBar.SetPercentDone(i++);
            }
            deUser.Close();
            //MessageBox.Show("Number of actual writable properties: " + alWritableProperties.Count);

            //End loading bar
            pwBar.Close();

            // OLD STUFF BELOW

            // http://msdn.microsoft.com/en-us/library/ms180940(v=vs.80).aspx
            //ActiveDirectorySchemaClass
            // http://stackoverflow.com/questions/3290730/how-can-i-read-the-active-directory-schema-programmatically

            // http://msdn.microsoft.com/en-us/library/bb267453.aspx#sdsadintro_topic3_manageschema

            /*
            //Get current server
            string ADServer = Environment.GetEnvironmentVariable("LOGONSERVER");
            //Remove the "//"
            ADServer = ADServer.Substring(2);
            //Get the selected domain
            string domainName = cboDC.Text.ToString();
            //Concatenate to make full server name
            string fullServerName = ADServer + "." + domainName;
            MessageBox.Show("The directory context is: " + fullServerName);
            //Specify server stuff                                                                ex. "prjdc.project.com"
            DirectoryContext adamContext = new DirectoryContext(DirectoryContextType.DirectoryServer, fullServerName);
            MessageBox.Show(adamContext.Name);

            //Get schema for that servers active directory
            ActiveDirectorySchema schema = ActiveDirectorySchema.GetSchema(adamContext);
            */
            /*
            // Test for getting all classes
            foreach (ActiveDirectorySchemaClass schemaClass in schema.FindAllClasses())
            {
                MessageBox.Show(schemaClass.GetAllProperties().ToString());
            }
            */
            /*
            //Get the user schema class
            ActiveDirectorySchemaClass schemaClass = schema.FindClass("user");

            //Now that we have the correct class, GET ALL PROPERTIES in that class (these properties themselves are readonly because we don't want to alter them)
            ReadOnlyActiveDirectorySchemaPropertyCollection adPropertyCollection = schemaClass.GetAllProperties(); //There are 342
            //ActiveDirectorySchemaPropertyCollection adPropertyCollection = schemaClass.OptionalProperties; //There are 335
            //ActiveDirectorySchemaPropertyCollection adPropertyCollection = schemaClass.MandatoryProperties;  //There are 7
            */

            /*
            foreach (ActiveDirectorySchemaProperty schemaProperty in adPropertyCollection)
            {

                // http://msdn.microsoft.com/en-us/library/system.reflection.propertyattributes.aspx
                // Final test with "systemOnly" attribute, if this doesn't work, it won't ever...

                // Get the PropertyAttributes enumeration of the property.
                // Get the type.
                TypeAttributes schemaPropertyAttributes = schemaProperty.GetType().Attributes;
                // Get the property attributes.
                //PropertyInfo schemaPropertyInfo = schemaPropertyType.GetProperty("systemOnly");
                //PropertyAttributes propAttributes = schemaPropertyInfo.Attributes;
                //Display the property attributes value.
                MessageBox.Show("Property: " + schemaProperty.CommonName.ToString() + " has attributes: " + s;

            }
            */

            //Have a fake read-only property
            //ActiveDirectorySchemaProperty fakeProperty = new ActiveDirectorySchemaProperty(adamContext, "cn");
            //AttributeCollection fakePropertyAttributes = TypeDescriptor.GetAttributes(fakeProperty);
            //DirectoryServicesPermissionAttribute a = new DirectoryServicesPermissionAttribute(

            /*
            MessageBox.Show("Does fake property contain read-write attribute: " + fakePropertyAttributes.Contains(ReadOnlyAttribute.No).ToString());

            if (a)
            {
                MessageBox.Show("READ ONLY");
            }
            else
            {
                //Can't be, when try to go fakeProperty.Name = "MEGADEATH" it says can't because prop is read-only
                MessageBox.Show("READ AND WRITE");
            }
            */

            //http://technet.microsoft.com/en-us/library/cc773309(WS.10).aspx

            // CURRENT PROBLEM:
            // Can get all properties, but cannot seem to separate writable from read-only
            // have heard of attributeSchema but no luck
            // now thinking of using systemOnly flag, but no idea how to check for that http://msdn.microsoft.com/en-us/library/aa772300.aspx
            /*
            // Test value of flags using bitwise AND.
            bool test = (meetingDays & Days2.Thursday) == Days2.Thursday; // true
            Console.WriteLine("Thursday {0} a meeting day.", test == true ? "is" : "is not");
            // Output: Thursday is a meeting day.
             *
             */

            /*
            Type type = typeof(ActiveDirectorySchemaProperty);
            object[] ac = type.GetCustomAttributes(true);

            //Test for what's in collection
            MessageBox.Show("Now Testing what is in ReadOnlyActiveDirectorySchemaPropertyCollection");
            int actualNumber = 0;
            foreach (ActiveDirectorySchemaProperty adProperty in adPropertyCollection)
            {
                actualNumber++;

                //MessageBox.Show("Property: " + adProperty.Name + " // Common Name: " + adProperty.CommonName);
                // http://msdn.microsoft.com/en-us/library/system.componentmodel.attributecollection.aspx //
                //Get attributes of that property (ex. is a string, is read only, is writable, etc)
                AttributeCollection attributes = TypeDescriptor.GetAttributes(adProperty);

                //List of systemOnly of the property
                MessageBox.Show("Now showing attributes in current property");

                //attributes.Contains(Attribute.GetCustomAttribute(AssemblyFlagsAttribute"systemOnly",typeof(FlagsAttribute)));
                AssemblyName a = new AssemblyName();
                //https://connid.googlecode.com/svn-history/r169/bundles/ad/trunk/src/main/java/org/connid/ad/schema/ADSchemaBuilder.java

                //AssemblyNameFlags aName = new AssemblyNameFlags();
                //AssemblyFlagsAttribute afa = new AssemblyFlagsAttribute(aName);

                //See if the attributes collection isn't writable
                //if (attributes.Contains(ReadOnlyAttribute.No) == false)
                //if(attributes.Contains(Attribute.GetCustomAttribute(typeof(ActiveDirectorySchemaProperty),"systemOnly")))

                // More freaking testing
                // http://stackoverflow.com/questions/2051065/check-if-property-has-attribute //
                //http://msdn.microsoft.com/en-us/library/cc220922(v=prot.10).aspx

                //Go through all attributes and see if systemOnly is false, if it is then add the property to the array

                //Go through all attributes and see if systemOnly is false, if it is then add the property to the array
                foreach (Attribute currentattribute in attributes)
                {
                    MessageBox.Show(currentattribute.TypeId.ToString());
                }

                /*
                if ()
                {
                    //Cannot read and write
                }
                else
                {
                    //Our property is read/write!
                    //Add the name of the property to our alWritableProperties array list
                    alWritableProperties.Add(adProperty.Name.ToString());
                }
                */

            /*
            }
            MessageBox.Show("Now Seeing what has been added to the writable properties list");
            MessageBox.Show("Number of Properties: " + actualNumber.ToString() + "\nNumber of Writable Properties: " + alWritableProperties.Count);
            */

            /*
            #region Properties of the schema
            /*
            // This will get the properties of the schema class
            PropertyInfo[] aPropertyInfo = schemaClass.GetType().GetProperties();

            //For each property
            foreach (PropertyInfo property in aPropertyInfo)
            {

                MessageBox.Show("Property: " + property.Name);
                /*
                if (property.PropertyType.Assembly == schemaClass.GetType().Assembly)
                {
                    //Show just property
                    MessageBox.Show("Property: " + property.Name);
                }
                else
                {
                    MessageBox.Show("Property: " + property.Name + " Value: " + propValue);
                }
                */
            /*
            }
            */
            /*
            #endregion
            */
            /* http://msdn.microsoft.com/en-us/library/windows/desktop/ms677167(v=vs.85).aspx */
            //IDEA: We get do foreach madatory, and a foreach optional property, put all into huge property array
            //      Then for each property, we do the whole type thing
            //http://stackoverflow.com/questions/6196413/how-to-recursively-print-the-values-of-an-objects-properties-using-reflection

            /*
            //foreach (ActiveDirectorySchemaProperty schemaProperty in schemaClass.MandatoryProperties)
            //ActiveDirectorySchemaPropertyCollection
            //ActiveDirectorySchemaPropertyCollection[] properties = schemaClass.GetType().GetProperties();
            foreach(ActiveDirectorySchemaProperty schemaProperty in schemaClass.MandatoryProperties)
            {
                PropertyInfo[] properties = schemaProperty.GetType().GetProperties();

                //findAttrValue

                //See what we have in the properties MessageBox.Show(properties.GetEnumerator().ToString());

                /*
                http://msdn.microsoft.com/en-us/library/system.componentmodel.defaultvalueattribute(v=vs.71).aspx
                 */
            //[C#]
            // Gets the attributes for the property.
            //AttributeCollection attributes = TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;
            //AttributeCollection attributes = TypeDescriptor.GetProperties(this)[schemaProperty.Name].Attributes;
            //AttributeCollection attributes = [schemaProperty.Name].Attributes;

            //Prints the default value by retrieving the DefaultValueAttribute
            //from the AttributeCollection.
            //DefaultValueAttribute myAttribute = (DefaultValueAttribute)attributes[typeof(DefaultValueAttribute)];
            //MessageBox.Show("The default value is: " + myAttribute.Value.ToString());
            /*
            // Checks to see whether the value of the ReadOnlyAttribute is Yes.
            if (attributes[typeof(ReadOnlyAttribute)].Equals(ReadOnlyAttribute.Yes))
            {
                // Insert code here.
                MessageBox.Show("The Property " + schemaProperty.Name + " is read-only");
            }
            */

            //AttributeCollection attributes = TypeDescriptor.GetProperties(schemaProperty)[schemaProperty.Name].Attributes;
            //Attribute a = attributes[schemaProperty].

            /*
                foreach (PropertyInfo property in properties)
                {
                    MessageBox.Show("Property: " + property.Name);
                }

            }
            */

            /*

            //Find all mandatory properties for the schemaClass
            foreach (ActiveDirectorySchemaProperty schemaProperty in schemaClass.MandatoryProperties)
            {
                MessageBox.Show("Property: " + schemaProperty.ToString());
                MessageBox.Show("Name(what we write to): " + schemaProperty.Name + ", Common Name(Display Name to show on datagridview): " + schemaProperty.CommonName);

                //Determine if it is a writable property

                //To get the CanWrite property, first get the class Type.
                //Type propertyType = Type.GetType(schemaProperty.Name);
                Type propertyType = schemaProperty.GetType();
                //Type propertyType = schemaProperty.Name.GetType();
                //Type propertyType = Type.GetType(schemaProperty.Name);
                //From the Type, get the PropertyInfo. From the PropertyInfo, get the CanWrite value.

                MessageBox.Show("Made it past Type: " + propertyType.ToString());

                PropertyInfo[] properties = propertyType.GetProperties();

                foreach (PropertyInfo property in properties)
                {
                    object propValue = property.GetValue(schemaProperty, null);
                    if (property.PropertyType.Assembly == propertyType.Assembly)
                    {
                        MessageBox.Show("Property: " + property.Name);
                    }
                    else
                    {
                        MessageBox.Show("Property: " + property.Name + " Value: " + propValue);
                    }
                }

                /*
                PropertyInfo propInfo = propertyType.GetProperty(schemaProperty.ToString());

                PropertyAttributes pAttributes = propInfo.Attributes;

                MessageBox.Show("Attributes: " + pAttributes.ToString());
                */
            /*
            //MessageBox.Show("Made it past Info! " + propInfo.CanWrite);

            if (propInfo.CanWrite == true)
            {
                MessageBox.Show("We CAN write to this mofo!");
            }
            else
            {
                MessageBox.Show("We CANNOT write to this mofo!");
            }
            */

            //MessageBox.Show("Can we write to this mofo?  " + propInfo.CanWrite.ToString());

            //Old
            //PropertyInfo[] propInfo = propertyType.GetProperties(BindingFlags.Public | BindingFlags.Instance);

            /* http://msdn.microsoft.com/en-us/library/system.reflection.propertyinfo.canwrite.aspx */

            //using reflection
            /* http://www.codersource.net/microsoft-net/c-basics-tutorials/reflection-in-c.aspx */
            /*
            for (int i = 0; i < propInfo.Length ;i++)
            {
                MessageBox.Show(propInfo[0].ToString());
            }
            */
            /*
            if(propertyType)
            {
                //Since this is a writable property, add it to the array

            }
            */
            /*
            }
            */
        }
コード例 #52
0
        protected override void RemoveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (dgResults.SelectedItems.Count == 0 || dgResults.SelectedItem == null)
            {
                return;
            }

            OnReloading = true;

            var props = dgResults.SelectedItems.OfType <Prop>().ToList();

            if (props.Count > 0)
            {
                var failed       = false;
                var removedCount = 0;
                if (Global.DeleteQuestion(this))
                {
                    var progressResources = new ProgressWindow(props.Count);
                    progressResources.Show(this);
                    foreach (var prop in props)
                    {
                        string labName;
                        if (PropsService.ReferencedToOther(prop.PropID, out labName))
                        {
                            var temp = prop;
                            if (
                                Global.ReferenceFound(this,
                                                      string.Format(PropsResources.Referenced,
                                                                    new[] { temp.Name, temp.PropNo.ToString(), labName })) ==
                                MessageBoxResult.Yes)
                            {
                                if (!PropsService.Instanse.Remove(prop))
                                {
                                    failed = true;
                                    Global.DeletionFailed(this);
                                }
                                else
                                {
                                    removedCount++;
                                }
                            }
                        }
                        else if (!PropsService.Instanse.Remove(prop))
                        {
                            failed = true;
                            Global.DeletionFailed(this);
                        }
                        else
                        {
                            removedCount++;
                        }
                        progressResources.IncreaseProgress();
                    }
                    progressResources.Close();
                    if (props.Count > 1 && failed)
                    {
                        Global.DeletionSuceededWithSomeFailures(this);
                    }
                    else if (removedCount > 0 & !failed)
                    {
                        Global.DeletionSuceeded(this);
                    }
                    ResetFields();
                    TryToLoad();
                }
            }

            OnReloading = false;
        }
コード例 #53
0
        /// <summary>
        /// Using the share path picked by the user and the users selected,
        /// delete all files in that share owned by the user selected.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDeleteFiles_Click(object sender, EventArgs e)
        {
            if (ServerPath.Text == "" || cboShares.SelectedIndex < 0)
            {
                MessageBox.Show("Please enter a server path and select a share");
            }
            else
            {
                if (lstUsers.SelectedItems.Count == 0)
                {
                    MessageBox.Show("Please select a user to delete their files");
                }
                else
                {

                    ProgressWindow pwBar = new ProgressWindow("Deleting Files");
                    pwBar.Show();
                    pwBar.Refresh();
                    Thread thProgress = new Thread(new ThreadStart(pwBar.Draw));
                    thProgress.Start();
                    foreach (string cn in lstUsers.SelectedItems)
                    {
                        try
                        {
                            RunScript(cn);
                        }
                        catch (Exception exp)
                        {
                            MessageBox.Show("There was an error running the delete files script.\n " +
                                "Seems like there was no files in the selected share");
                        }
                    }
                    thProgress.Abort();
                    pwBar.Close();
                }
            }
        }
コード例 #54
0
        public Boolean exportScoreBookData()
        {
            String curMethodName = "ExportScoreBookHtmlIwwf";
            Boolean returnStatus = false;
            StringBuilder outLine = new StringBuilder( "" );
            String curMsg = "", curMemberId = "", curAgeGroup = "", prevMemberId = "", prevAgeGroup = "", curReadyToSki = "";
            String curFileFilter = "HTML files (*.htm)|*.htm|All files (*.*)|*.*";
            Int16 curRound = 0;
            DataRow prevRow = null;
            myTourProperties = TourProperties.Instance;

            ExportScorebookTypeDialogForm curDialogForm = new ExportScorebookTypeDialogForm();
            curDialogForm.ShowDialog();
            if (curDialogForm.DialogResult == DialogResult.OK) {
                String curReportFormat = curDialogForm.ReportFormat;
                if (curReportFormat.Equals( "Magazine" )) {
                    MessageBox.Show( "This feature is not currently supported for IWWF tournaments" );
                } else {
                    try {
                        curMsg = "Exporting Scorebook Html";
                        Log.WriteFile( curMethodName + ":begin: " + curMsg );

                        String curFilename = mySanctionNum.Trim() + "CS.HTM";
                        StreamWriter outBuffer = getExportFile( curFileFilter, curFilename );

                        if (outBuffer == null) {
                            curMsg = "Output file not available";
                        } else {
                            String curPlcmtMethod = "score", curPlcmtOrg = "div", curPointsMethod = "kbase";
                            String curDataType = myTourProperties.MasterSummaryDataType;
                            //String curDataType = Properties.Settings.Default.MasterSummaryV2DataType;
                            if (curDataType.ToLower().Equals( "total" )
                                || curDataType.ToLower().Equals( "best" )
                                || curDataType.ToLower().Equals( "final" )
                                || curDataType.ToLower().Equals( "first" )) {
                            } else {
                                curDataType = "best";
                            }

                            myProgressInfo = new ProgressWindow();
                            myProgressInfo.setProgessMsg( "Processing Scorebook HTML" );
                            myProgressInfo.Show();
                            myProgressInfo.Refresh();
                            myProgressInfo.setProgressMax( 10 );
                            CalcScoreSummary curCalcSummary = new CalcScoreSummary();

                            DataTable myMemberData = curCalcSummary.getMemberData( mySanctionNum );
                            myProgressInfo.setProgressValue( 4 );
                            myProgressInfo.Refresh();

                            DataTable mySummaryDataTable = curCalcSummary.CalcIwwfEventPlcmts( myTourRow, mySanctionNum, "Scorebook", myTourRules, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                            myProgressInfo.setProgressValue( 5 );
                            myProgressInfo.Refresh();

                            DataTable mySlalomDetail = curCalcSummary.getSlalomScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                            myProgressInfo.setProgressValue( 6 );
                            myProgressInfo.Refresh();
                            DataTable myTrickDetail = curCalcSummary.getTrickScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                            myProgressInfo.setProgressValue( 7 );
                            myProgressInfo.Refresh();
                            DataTable myJumpDetail = curCalcSummary.getJumpScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                            myProgressInfo.setProgressValue( 8 );
                            myProgressInfo.Refresh();
                            DataTable newSummaryDataTable = curCalcSummary.buildTourScorebook( mySanctionNum, myTourRow, myMemberData, mySummaryDataTable, mySlalomDetail, myTrickDetail, myJumpDetail );
                            mySummaryDataTable = newSummaryDataTable;
                            myProgressInfo.setProgressValue( 9 );
                            myProgressInfo.Refresh();

                            myProgressInfo.setProgressMax( mySummaryDataTable.Rows.Count );
                            myProgressInfo.Refresh();

                            //Build file header line and write to file
                            writeHeader( outBuffer, curPlcmtOrg );

                            if (curReportFormat.Equals( "Index" )) {
                                //Build index header
                                writeIndexHeader( outBuffer, curPlcmtOrg, mySummaryDataTable );
                            }
                            //Build master summary header
                            writeMasterSummaryHeader( outBuffer, curPlcmtOrg, curReportFormat );
                            int curRowCount = 0;
                            foreach (DataRow curRow in mySummaryDataTable.Rows) {
                                curRowCount++;
                                myProgressInfo.setProgressValue( curRowCount );
                                myProgressInfo.Refresh();

                                curMemberId = curRow["MemberId"].ToString();
                                curAgeGroup = curRow["AgeGroup"].ToString();
                                curReadyToSki = curRow["ReadyToSki"].ToString();

                                //Initialize control fields
                                prevMemberId = curMemberId;
                                prevAgeGroup = curAgeGroup;
                                curRound = (Int16)curRow["RoundOverall"];

                                //Initialize output buffer
                                outLine = new StringBuilder( "<tr>" );

                                //Write skier identification information
                                writeSkierInfo( curRow, curRound, outBuffer );

                                //Write skier performance summary information
                                writeSkierSlalomScore( curRow, curPlcmtOrg, outBuffer );

                                writeSkierTrickScore( curRow, curPlcmtOrg, outBuffer );

                                writeSkierJumpScore( curRow, curPlcmtOrg, outBuffer );

                                writeSkierOverallScore( curRow, curReportFormat, outBuffer );

                                //Write output line to file
                                outLine = new StringBuilder( "</tr>" );
                                outBuffer.WriteLine( outLine.ToString() );
                            }
                            outLine = new StringBuilder( "</table>" );
                            outBuffer.WriteLine( outLine.ToString() );

                            if (curReportFormat.Equals( "Index" )) {
                                outLine = new StringBuilder( "<br/><br/><a href=#PageTop>Return to Index</a><br/></div>" );
                                outBuffer.WriteLine( outLine.ToString() );

                                DataTable mySlalomDataTable = curCalcSummary.CalcIwwfEventPlcmts( myTourRow, mySanctionNum, "Slalom", myTourRules, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                                writeIndexSlalomResults( curPlcmtOrg, mySlalomDataTable, outBuffer );

                                DataTable myTrickDataTable = curCalcSummary.CalcIwwfEventPlcmts( myTourRow, mySanctionNum, "Trick", myTourRules, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                                writeIndexTrickResults( curPlcmtOrg, myTrickDataTable, outBuffer );

                                DataTable myJumpDataTable = curCalcSummary.CalcIwwfEventPlcmts( myTourRow, mySanctionNum, "Jump", myTourRules, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                                writeIndexJumpResults( curPlcmtOrg, myJumpDataTable, outBuffer );

                                DataTable myOverallDataTable = curCalcSummary.CalcIwwfEventPlcmts( myTourRow, mySanctionNum, "Overall", myTourRules, "best", curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                                writeIndexOverallResults( curPlcmtOrg, myOverallDataTable, outBuffer );

                                if (isTeamAvailable()) {
                                    //Write team summary
                                    Int16 myNumPerTeam = Convert.ToInt16( myTourProperties.TeamSummary_NumPerTeam);
                                    String curTeamPlcmtOrg = myTourProperties.TeamSummaryPlcmtOrg;
                                    //Int16 myNumPerTeam = Properties.Settings.Default.TeamSummary_NumPerTeam;
                                    //String curTeamPlcmtOrg = Properties.Settings.Default.TeamSummaryPlcmtOrg;
                                    if (curTeamPlcmtOrg.ToLower().Equals( "tour" )
                                        || curTeamPlcmtOrg.ToLower().Equals( "div" )) {
                                    } else {
                                        curTeamPlcmtOrg = "tour";
                                    }
                                    String curTeamPlcmtMethod = "points";
                                    String curTeamDataType = myTourProperties.TeamSummaryDataType;
                                    //String curTeamDataType = Properties.Settings.Default.TeamSummaryDataType;
                                    if (curTeamDataType.ToLower().Equals( "total" )
                                        || curTeamDataType.ToLower().Equals( "best" )
                                        || curTeamDataType.ToLower().Equals( "final" )
                                        || curTeamDataType.ToLower().Equals( "first" )) {
                                    } else {
                                        curTeamDataType = "best";
                                    }
                                    String curTeamPointsMethod = myTourProperties.TeamSummaryPointsMethod;
                                    //String curTeamPointsMethod = Properties.Settings.Default.MasterSummaryV2PointsMethod;
                                    if (curTeamPointsMethod.ToLower().Equals( "nops" )
                                        || curTeamPointsMethod.ToLower().Equals( "plcmt" )
                                        || curTeamPointsMethod.ToLower().Equals( "kbase" )
                                        || curTeamPointsMethod.ToLower().Equals( "ratio" )) {
                                    } else {
                                        curTeamPointsMethod = "nops";
                                    }

                                    String curSortCmd = "";
                                    if (curTeamPlcmtOrg.ToLower().Equals( "div" )) {
                                        curSortCmd = "AgeGroup ASC, PointsSlalom DESC, SkierName ASC";
                                    } else {
                                        curSortCmd = "PointsSlalom DESC, SkierName ASC";
                                    }
                                    mySlalomDataTable.DefaultView.Sort = curSortCmd;
                                    mySlalomDataTable = mySlalomDataTable.DefaultView.ToTable();
                                    DataTable myTeamDataTable = curCalcSummary.getSlalomSummaryTeam( mySlalomDataTable, myTourRow, myNumPerTeam, curTeamDataType, curTeamPlcmtMethod, curTeamPlcmtOrg, curTeamPointsMethod );

                                    if (curTeamPlcmtOrg.ToLower().Equals( "div" )) {
                                        curSortCmd = "AgeGroup ASC, PointsTrick DESC, SkierName ASC";
                                    } else {
                                        curSortCmd = "PointsTrick DESC, SkierName ASC";
                                    }
                                    myTrickDataTable.DefaultView.Sort = curSortCmd;
                                    myTrickDataTable = myTrickDataTable.DefaultView.ToTable();
                                    myTeamDataTable = curCalcSummary.getTrickSummaryTeam( myTeamDataTable, myTrickDataTable, myTourRow, myNumPerTeam, curTeamDataType, curTeamPlcmtMethod, curTeamPlcmtOrg, curTeamPointsMethod );

                                    if (curTeamPlcmtOrg.ToLower().Equals( "div" )) {
                                        curSortCmd = "AgeGroup ASC, PointsJump DESC, SkierName ASC";
                                    } else {
                                        curSortCmd = "PointsJump DESC, SkierName ASC";
                                    }
                                    myJumpDataTable.DefaultView.Sort = curSortCmd;
                                    myJumpDataTable = myJumpDataTable.DefaultView.ToTable();
                                    myTeamDataTable = curCalcSummary.getJumpSummaryTeam( myTeamDataTable, myJumpDataTable, myTourRow, myNumPerTeam, curTeamDataType, curTeamPlcmtMethod, curTeamPlcmtOrg, curTeamPointsMethod );

                                    writeIndexTeamResults( myTeamDataTable, myNumPerTeam, curTeamPlcmtOrg, outBuffer );

                                }

                            } else {
                                outLine = new StringBuilder( "</div>" );
                                outBuffer.WriteLine( outLine.ToString() );
                            }

                            //Build file footer and write to file
                            writeFooter( outBuffer );
                            outLine = new StringBuilder( "" );
                            outBuffer.WriteLine( outLine.ToString() );

                            returnStatus = true;
                            outBuffer.Close();

                            myProgressInfo.Close();
                            if (mySummaryDataTable.Rows.Count > 0) {
                                curMsg = mySummaryDataTable.Rows.Count + " skiers found and written";
                            } else {
                                curMsg = "No rows found";
                            }
                        }
                        MessageBox.Show( curMsg );
                        Log.WriteFile( curMethodName + ":conplete: " + curMsg );
                    } catch (Exception ex) {
                        MessageBox.Show( "Error:" + curMethodName + " Error writing scorebook html file\n\nError: " + ex.Message );
                        curMsg = curMethodName + ":Exception=" + ex.Message;
                        Log.WriteFile( curMsg );
                        returnStatus = false;
                    }
                }
            } else {
                returnStatus = false;
            }

            return returnStatus;
        }
コード例 #55
0
 internal void Close()
 {
     progressWindow.Close();
 }
コード例 #56
0
        /// <summary>
        /// When the user clicks the Delete User button it will go through and 
        /// delete all the selected users
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDeleteUser_Click(object sender, EventArgs e)
        {
            if (isCompleted())
            {
                DialogResult result = MessageBox.Show("Are you sure you want to delete the selected users?",
                        "Delete Users", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {

                    int index = 0;
                    ArrayList alDelUsers = new ArrayList();
                    ArrayList userToDelete = new ArrayList();
                    //Create array list of profilepaths of each user we are about to delete
                    ArrayList alProfilePath = new ArrayList();

                        foreach (string cn in lstUsers.SelectedItems)
                        {
                            index = lstUsers.Items.IndexOf(cn);
                            string finish = aUserLDAPPaths[index].ToString();
                            DirectoryEntry de = new DirectoryEntry(finish);
                            alDelUsers.Add(de);
                            userToDelete.Add(cn);

                            alProfilePath.Add(de.Properties["homeDirectory"].Value.ToString());
                            alProfilePath.Add(de.Properties["profilePath"].Value.ToString());

                        }

                        // for each path delete the directory and everything inside
                        foreach (string profilepath in alProfilePath)
                        {
                            //MessageBox.Show(profilepath);
                            DeleteDirectory(profilepath);
                        }
                        int i = 0;
                        ProgressWindow pgWindow = new ProgressWindow("Deleting Users...", userToDelete.Count);
                        pgWindow.Show();
                        pgWindow.SetPercentDone(i);
                        // Remove users from list in our Project
                        foreach (string cn in userToDelete)
                        {
                            pgWindow.SetPercentDone(i);
                            i++;
                            index = lstUsers.Items.IndexOf(cn);
                            lstUsers.Items.Remove(cn);

                            aUserLDAPPaths.RemoveAt(index);

                        }
                        pgWindow.Close();
                        //Delete users in active directory
                        mgr.deleteUsers(alDelUsers);
                        lstUsers.Update();

                }
            }
            else
            {
                MessageBox.Show(ec.getMsg());
            }
        }
コード例 #57
0
 private void Close()
 {
     _window.Close();
 }
コード例 #58
0
        /// <summary>
        /// Method to create Active Directory Users
        /// </summary>
        /// <param name="cp">Reference to get information from Properties</param>
        public void createUsers(CrPanel cp)
        {
            setVariables(cp);
            users = new Queue<string>();
            ProgressWindow pwProgress = new ProgressWindow("Creating Users...", iNumUsers);

            try
            {
                crm.CreateButton.Enabled = false;
                string oGUID = string.Empty;
                string ldapPath = sUserOU;
                //Set hte connection prefix
                string connectionPrefix = ldapPath;
                //Get a directoryEntry object from the OU
                DirectoryEntry dirEntry = new DirectoryEntry(connectionPrefix);
                //Reset the output string
                this.output = "";

                //Creates a progress bar window for user to see how creation is progressing
                pwProgress.Show();
                pwProgress.SetPercentDone(0);

                //Foreach number of users defined
                for (int i = iFirstUser; i < (iFirstUser +  iNumUsers); i++)
                {
                    pwProgress.SetPercentDone(i-iFirstUser);
                    //Define the username
                    string userName = sUserPrefix + i;
                    //Define DirectoryEntry obejct for the new user
                    DirectoryEntry newUser = dirEntry.Children.Add
                        ("CN=" + userName, "user");
                    //Set the user's properties
                    setUserProperties(newUser, userName, i, "");
                }
                //close progress bar window
                pwProgress.Close();
                //Create the file and append the output to the file
                System.IO.StreamWriter file = new System.IO.StreamWriter(this.sUserPrefix + ".txt", false);
                file.WriteLine(output);
                users.Enqueue(output);
                //Close the file
                file.Close();
                //Write files to word doc, not included because server currently doesn't have Word
                //WriteUserDoc();
                MessageBox.Show("Users have been created Successfully");
            }
            catch (System.DirectoryServices.DirectoryServicesCOMException E)
            {
                MessageBox.Show(E.Message);
                //close progress bar window
                pwProgress.Close();

            }
        }
コード例 #59
0
        public Boolean exportTourPerfData( String inSanctionId )
        {
            Boolean returnStatus = false;
            String curMemberId = "", curReadyToSki = "", curAgeGroup = "";
            StringBuilder outLine = new StringBuilder( "" );
            StreamWriter outBuffer = null;
            String curFilename = "", curRules = "";
            myTourProperties = TourProperties.Instance;

            DataTable curTourDataTable = getTourData( inSanctionId );
            if ( curTourDataTable != null ) {
                if ( curTourDataTable.Rows.Count > 0 ) {
                    myTourRow = curTourDataTable.Rows[0];
                    curRules = (String)myTourRow["Rules"];

                    curFilename = inSanctionId.Trim() + myTourRow["Class"].ToString().Trim() + ".wsp";
                    outBuffer = getExportFile( curFilename );
                    if ( outBuffer != null ) {
                        Log.WriteFile( "Export performance data file begin: " + curFilename );

                        //Build file header line and write to file
                        outLine.Append( writeHeader( inSanctionId ) );
                        outBuffer.WriteLine( outLine.ToString() );

                        //Initialize output buffer
                        outLine = new StringBuilder( "" );
                    }
                }
            }
            if ( outBuffer != null ) {
                myProgressInfo = new ProgressWindow();
                myProgressInfo.setProgessMsg( "Processing Skier Performance Data File" );
                myProgressInfo.Show();
                myProgressInfo.Refresh();
                myProgressInfo.setProgressMax( 10 );

                DataTable curMemberDataTable = getMemberData( inSanctionId );
                if ( curMemberDataTable != null ) {
                    DataRow[] curScoreRows, curScoreSlalomRows, curScoreTrickRows, curScoreJumpRows;
                    String curPlcmtMethod = "score", curPlcmtOverallOrg = "agegroup";
                    String curDataType = myTourProperties.MasterSummaryDataType;
                    //String curDataType = Properties.Settings.Default.MasterSummaryV2DataType;
                    if ( curDataType.ToLower().Equals( "total" )
                        || curDataType.ToLower().Equals( "best" )
                        || curDataType.ToLower().Equals( "final" )
                        || curDataType.ToLower().Equals( "first" ) ) {
                    } else {
                        curDataType = "best";
                    }
                    String curPointsMethod = myTourProperties.MasterSummaryPointsMethod;
                    //String curPointsMethod = Properties.Settings.Default.MasterSummaryV2PointsMethod;
                    if ( curPointsMethod.ToLower().Equals( "nops" )
                        || curPointsMethod.ToLower().Equals( "plcmt" )
                        || curPointsMethod.ToLower().Equals( "kbase" )
                        || curPointsMethod.ToLower().Equals( "ratio" ) ) {
                    } else {
                        curPointsMethod = "nops";
                    }
                    String curPlcmtOrg = myTourProperties.MasterSummaryPlcmtOrg;
                    //String curPlcmtOrg = Properties.Settings.Default.MasterSummaryV2PlcmtOrg;
                    if ( curPlcmtOrg.ToLower().Equals("div") ) {
                        curPlcmtOverallOrg = "agegroup";
                    } else if ( curPlcmtOrg.ToLower().Equals( "divgr" ) ) {
                        curPlcmtOverallOrg = "agegroupgroup";
                    } else {
                        curPlcmtOverallOrg = "agegroup";
                        curPlcmtOrg = "div";
                    }

                    CalcScoreSummary curCalcSummary = new CalcScoreSummary();
                    DataTable mySummaryDataTable = null;

                    DataTable myMemberData = curCalcSummary.getMemberData( inSanctionId );
                    myProgressInfo.setProgressValue( 1 );
                    myProgressInfo.Refresh();

                    if (curRules.ToLower().Equals( "iwwf" ) && curPointsMethod.ToLower().Equals( "kbase" )) {
                        mySummaryDataTable = curCalcSummary.CalcIwwfEventPlcmts( myTourRow, inSanctionId, "Scorebook", curRules, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                        myProgressInfo.setProgressValue( 5 );
                        myProgressInfo.Refresh();

                        DataTable mySlalomDetail = curCalcSummary.getSlalomScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                        myProgressInfo.setProgressValue( 6 );
                        myProgressInfo.Refresh();
                        DataTable myTrickDetail = curCalcSummary.getTrickScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                        myProgressInfo.setProgressValue( 7 );
                        myProgressInfo.Refresh();
                        DataTable myJumpDetail = curCalcSummary.getJumpScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                        myProgressInfo.setProgressValue( 8 );
                        myProgressInfo.Refresh();
                        DataTable newSummaryDataTable = curCalcSummary.buildTourScorebook( inSanctionId, myTourRow, myMemberData, mySummaryDataTable, mySlalomDetail, myTrickDetail, myJumpDetail );
                        mySummaryDataTable = newSummaryDataTable;
                        myProgressInfo.setProgressValue( 9 );
                        myProgressInfo.Refresh();

                    } else {
                        DataTable mySlalomDataTable = curCalcSummary.getSlalomSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod );
                        myProgressInfo.setProgressValue( 2 );
                        myProgressInfo.Refresh();
                        DataTable myTrickDataTable = curCalcSummary.getTrickSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod );
                        myProgressInfo.setProgressValue( 3 );
                        myProgressInfo.Refresh();
                        DataTable myJumpDataTable = curCalcSummary.getJumpSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod );
                        myProgressInfo.setProgressValue( 4 );
                        myProgressInfo.Refresh();
                        mySummaryDataTable = curCalcSummary.buildOverallSummary( myTourRow, mySlalomDataTable, myTrickDataTable, myJumpDataTable, curDataType, curPlcmtOverallOrg );
                        myProgressInfo.setProgressValue( 5 );
                        myProgressInfo.Refresh();

                        DataTable mySlalomDetail = curCalcSummary.getSlalomScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                        myProgressInfo.setProgressValue( 6 );
                        myProgressInfo.Refresh();
                        DataTable myTrickDetail = curCalcSummary.getTrickScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                        myProgressInfo.setProgressValue( 7 );
                        myProgressInfo.Refresh();
                        DataTable myJumpDetail = curCalcSummary.getJumpScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null );
                        myProgressInfo.setProgressValue( 8 );
                        myProgressInfo.Refresh();
                        DataTable newSummaryDataTable = curCalcSummary.buildTourScorebook( inSanctionId, myTourRow, myMemberData, mySummaryDataTable, mySlalomDetail, myTrickDetail, myJumpDetail );
                        mySummaryDataTable = newSummaryDataTable;
                        myProgressInfo.setProgressValue( 9 );
                        myProgressInfo.Refresh();

                    }
                    mySkierClassList = new ListSkierClass();
                    mySkierClassList.ListSkierClassLoad();

                    int curRowCount = 0;
                    myProgressInfo.setProgressMax( curMemberDataTable.Rows.Count );
                    foreach ( DataRow curMemberRow in curMemberDataTable.Rows ) {
                        curRowCount++;
                        myProgressInfo.setProgressValue( curRowCount );
                        myProgressInfo.Refresh();

                        curMemberId = curMemberRow["MemberId"].ToString();
                        curAgeGroup = curMemberRow["AgeGroup"].ToString();
                        curReadyToSki = curMemberRow["ReadyToSki"].ToString();
                        curScoreRows = mySummaryDataTable.Select( "MemberId = '" + curMemberId + "' AND AgeGroup = '" + curAgeGroup + "'" );
                        //curScoreSlalomRows = mySlalomDataTable.Select( "MemberId = '" + curMemberId + "' AND AgeGroup = '" + curAgeGroup + "'" );
                        //curScoreTrickRows = myTrickDataTable.Select( "MemberId = '" + curMemberId + "' AND AgeGroup = '" + curAgeGroup + "'" );
                        //curScoreJumpRows = myJumpDataTable.Select( "MemberId = '" + curMemberId + "' AND AgeGroup = '" + curAgeGroup + "'" );

                        if ( curReadyToSki.Equals( "Y" ) ) {
                            if ( curScoreRows.Length > 0 ) {
                                //Write skier identification information
                                outLine.Append( writeSkierInfo( curMemberRow, inSanctionId, curRules, curAgeGroup ) );

                                //Write skier performance summary information
                                //outLine.Append( writeSkierPerfSmry( curMemberId, curAgeGroup, curDataType, curMemberRow, curScoreRows, curScoreSlalomRows, curScoreTrickRows, curScoreJumpRows ) );
                                outLine.Append( writeSkierPerfSmry( curMemberId, curAgeGroup, curDataType, curMemberRow, curScoreRows, curScoreRows, curScoreRows, curScoreRows ) );

                                //Write skier performance summary information
                                outLine.Append( writeSkierPerfData( curMemberId, curAgeGroup, curRules, curMemberRow, curScoreRows ) );

                                //Write output line to file
                                outBuffer.WriteLine( outLine.ToString() );
                            }
                        }

                        //Initialize output buffer
                        outLine = new StringBuilder( "" );
                    }
                    returnStatus = true;
                    outBuffer.Close();

                    myProgressInfo.Close();
                    if ( curMemberDataTable.Rows.Count > 0 ) {
                        MessageBox.Show( curMemberDataTable.Rows.Count + " rows found and written" );
                    } else {
                        MessageBox.Show( "No rows found" );
                    }
                    Log.WriteFile( "Export performance data file complete: " + curFilename );
                }
            }

            return returnStatus;
        }
コード例 #60
0
        private void btnExport_Click(object sender, RoutedEventArgs e)
        {
            List<Model.TB_StandardInfo> checkedStandList = GetCheckedStand();
            if (checkedStandList.Count==0)
            {
                DSJL.Tools.MessageBoxTool.ShowConfirmMsgBox("请选择要导出的测试参考值!");
                return;
            }
            if (DSJL.Tools.ShowFileDialogTool.ShowSaveFileDialog(out exportPath, "", "dsf", "等速肌力参考值导出") == false)
            {
                return;
            }
            exportPath = exportPath.Substring(0, exportPath.LastIndexOf("\\") + 1);
            Console.WriteLine("export path is:{0}",exportPath);

            ProgressWindow window = new ProgressWindow();
            window.WindowTilte = "导出参考值进度";
            window.MaxValue = checkedStandList.Count;
            window.MinValue = 0;
            window.CancleMessage = "确定取消导出吗?";
            window.onCancling += Window_onCancling;
            window.Owner = this;

            Task task = new Task(() => {
                int progress = 0;
                foreach (var item in checkedStandList)
                {
                    if (isCancleExport)
                    {
                        break;
                    }
                    //1、查询测试信息
                    List<Model.TestInfoModel> testInfoModelList = Caches.Util.AthTestInfoModelUtil.AthTestUtil(refeBLL.GetStandTestInfoModelList(item.ID));
                    if (testInfoModelList.Count==0)
                    {
                        continue;
                    }
                    Model.TestInfoModel avgTestInfoModel = GetAvgTestInfoModel(testInfoModelList);
                    string testInfoModelJson = Newtonsoft.Json.JsonConvert.SerializeObject(avgTestInfoModel);
                   // Console.WriteLine(testInfoModelJson);
                    //2、计算平均值
                    List<List<XElement>> paramList = DSJL.Export.GenerateCompareResportXml.ComputeAvg(testInfoModelList);
                    string paramJson = Newtonsoft.Json.JsonConvert.SerializeObject(paramList);
                   // Console.WriteLine(paramJson);
                    Dictionary<DataPointsType, List<List<double>>> dataPointsDict = StandardChartCache.GetStandardDataPoints(item, testInfoModelList);
                    List<List<double>> oddavgsd = dataPointsDict[DataPointsType.ODDAvgSD];
                    List<List<double>> evenavgsd = dataPointsDict[DataPointsType.EVENAVGSD];
                    string oddavgsdjson = Newtonsoft.Json.JsonConvert.SerializeObject(oddavgsd);
                    string evenavgsdjson = Newtonsoft.Json.JsonConvert.SerializeObject(evenavgsd);
                    // Console.WriteLine(oddavgsdjson);
                    // Console.WriteLine(evenavgsdjson);
                    //3、写入文件
                    Model.TB_StandardInfo parentStandModel = standList.Find(x => x.ID == item.Stand_ParentID);
                    Model.ExportStandModel exportStandModel = new Model.ExportStandModel();
                    exportStandModel.ParentName = parentStandModel.Stand_Name;
                    exportStandModel.StandName = item.Stand_Name;
                    exportStandModel.TestModel = avgTestInfoModel;
                    exportStandModel.ParamList = paramList;
                    exportStandModel.OddAvgSD = oddavgsd;
                    exportStandModel.EvenAvgSD = evenavgsd;
                    string standJson = Newtonsoft.Json.JsonConvert.SerializeObject(exportStandModel);
                    standJson= DSJL.Tools.DES.Encrypt(standJson, "cissdsjl");
                    string filename = string.Format("{0}{1}.dsf", exportPath, item.Stand_Name);
                    StreamWriter sw = new StreamWriter(filename);
                    sw.Write(standJson);
                    sw.Close();
                    progress++;
                    Dispatcher.BeginInvoke(new Action(()=> {
                        window.CurrentValue = progress;
                    }));
                }
                DSJL.Tools.MessageBoxTool.ShowConfirmMsgBox("导出完成!");
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    window.Close();
                    this.Close();
                }));
            });
            task.Start();
            window.ShowDialog();
        }