private bool updateSkierScoreVideoUrl(SkierVideoEntry inSkierVideoEntry, String inVideoUrl) { String curMethodName = "updateSkierScoreVideoUrl"; int rowsProc = 0; try { if (inSkierVideoEntry.SkierScorePK > 0 && inSkierVideoEntry.Pass > 0 ) { String curVideoUrl = inVideoUrl.Replace( "630", "410" ); curVideoUrl = curVideoUrl.Replace( "420", "273" ); //curVideoUrl = curVideoUrl.Replace( "354", "273" ); StringBuilder curSqlStmt = new StringBuilder( "Select count(*) From TrickVideo " ); curSqlStmt.Append( "Where SanctionId = '" + mySanctionNum + "' " ); curSqlStmt.Append( "AND MemberId = '" + inSkierVideoEntry.MemberId + "' " ); curSqlStmt.Append( "AND AgeGroup = '" + inSkierVideoEntry.AgeGroup + "' " ); curSqlStmt.Append( "AND Round = '" + inSkierVideoEntry.Round + "' " ); int curReadCount = (Int32)DataAccess.ExecuteScalarCommand( curSqlStmt.ToString() ); if (curReadCount == 0) { //If entry does not currently exist then add it curSqlStmt = new StringBuilder( "" ); curSqlStmt.Append( "Insert into TrickVideo (" ); curSqlStmt.Append( "SanctionId, MemberId, AgeGroup, Round, Pass1VideoUrl, Pass2VideoUrl, LastUpdateDate" ); curSqlStmt.Append( ") Values (" ); curSqlStmt.Append( "'" + mySanctionNum + "' " ); curSqlStmt.Append( ", '" + inSkierVideoEntry.MemberId + "' " ); curSqlStmt.Append( ",'" + inSkierVideoEntry.AgeGroup + "' " ); curSqlStmt.Append( ", " + inSkierVideoEntry.Round + ", '', '', GetDate() ) " ); rowsProc = DataAccess.ExecuteCommand( curSqlStmt.ToString() ); } curSqlStmt = new StringBuilder( "" ); curSqlStmt.Append( "Update TrickVideo set " ); if (inSkierVideoEntry.Pass == 1) { curSqlStmt.Append( "Pass1VideoUrl = '" + escapeString( curVideoUrl ) + "' " ); } else { curSqlStmt.Append( "Pass2VideoUrl = '" + escapeString( curVideoUrl ) + "' " ); } curSqlStmt.Append( ", LastUpdateDate = GetDate() " ); curSqlStmt.Append( "Where SanctionId = '" + mySanctionNum + "' " ); curSqlStmt.Append( "AND MemberId = '" + inSkierVideoEntry.MemberId + "' " ); curSqlStmt.Append( "AND AgeGroup = '" + inSkierVideoEntry.AgeGroup + "' " ); curSqlStmt.Append( "AND Round = '" + inSkierVideoEntry.Round + "' " ); rowsProc = DataAccess.ExecuteCommand( curSqlStmt.ToString() ); if (rowsProc > 0) { ExportLiveWeb.exportCurrentSkierTrickVideo( mySanctionNum, inSkierVideoEntry.MemberId, inSkierVideoEntry.AgeGroup, Convert.ToByte( inSkierVideoEntry.Round ) ); return true; } else { return false; } } else { return false; } } catch (Exception ex) { MessageBox.Show( curMethodName + ":Error encountered\n\nError: " + ex.Message ); String curMsg = curMethodName + ":Exception=" + ex.Message; Log.WriteFile( curMsg ); } return true; }
private void VideoFileSelectButton_Click(object sender, EventArgs e) { String curMethodName = "VideoFileSelectButton_Click"; try { myFileDialog = new OpenFileDialog(); myFileDialog.Multiselect = true; myFileDialog.InitialDirectory = VideoFolderLocTextbox.Text; myFileDialog.Filter = "Video files|*.avi;*.mkv;*.3g2;*.3gp;*.asf;*.asx;*.flv;*.mov;*.mp4;*.mpg;*.rm;*.swf;*.vob;*.wma;*.wmv;*.m2ts|All files (*.*)|*.*"; myFileDialog.FilterIndex = 9; if (myFileDialog.ShowDialog() == DialogResult.OK) { mySelectedFileList = new List<string>( myFileDialog.FileNames ); if (mySelectedFileList.Count > 0) { mySkierSelectDialog = new SkierVideoMatchDialogForm(); mySkierSelectDialog.TourRounds = myTrickRounds; mySkierVideoList = new List<SkierVideoEntry>(); DataGridViewRow curViewRow; int curViewIdx = 0; loadedVideoDataGridView.Visible = false; ReviewVideoMatchDataGridView.Visible = false; selectedFileDataGridView.Visible = true; selectedFileDataGridView.Rows.Clear(); //Get all avaialble trick skiers if filtered search found zero skiers StringBuilder curSqlStmt = new StringBuilder(""); curSqlStmt.Append("SELECT Distinct T.MemberId, T.SkierName, T.AgeGroup, T.AgeGroup as Div "); curSqlStmt.Append("FROM TourReg T "); curSqlStmt.Append(" INNER JOIN EventReg R ON T.SanctionId = R.SanctionId AND T.MemberId = R.MemberId AND T.AgeGroup = R.AgeGroup "); curSqlStmt.Append("INNER JOIN TrickScore S ON T.SanctionId = S.SanctionId AND T.MemberId = S.MemberId AND T.AgeGroup = S.AgeGroup "); curSqlStmt.Append("WHERE T.SanctionId = '" + mySanctionNum + "' AND R.Event = 'Trick' "); curSqlStmt.Append("Order by T.SkierName, T.AgeGroup "); myFullSkierDataTable = getData(curSqlStmt.ToString()); mySkierSelectDialog.FullSkierDataTable = myFullSkierDataTable; foreach ( String curVideoFileName in mySelectedFileList) { SkierVideoEntry curSkierVideoEntry = new SkierVideoEntry( curVideoFileName, "", "", "", 0, 0, 0 ); if (searchForMatchingSkier( curSkierVideoEntry )) { mySkierVideoList.Add( curSkierVideoEntry ); curViewIdx = selectedFileDataGridView.Rows.Add(); curViewRow = selectedFileDataGridView.Rows[curViewIdx]; curViewRow.Cells["SelectedFileName"].Value = Path.GetFileName(curVideoFileName); curViewRow.Cells["SelectedSkierName"].Value = curSkierVideoEntry.SkierName; curViewRow.Cells["SelectedMemberId"].Value = curSkierVideoEntry.MemberId; curViewRow.Cells["SelectedAgeGroup"].Value = curSkierVideoEntry.AgeGroup; curViewRow.Cells["SelectedRound"].Value = curSkierVideoEntry.Round; curViewRow.Cells["SelectedPass"].Value = curSkierVideoEntry.Pass; curViewRow.Cells["SelectedLoadStatus"].Value = ""; } } try { if (selectedFileDataGridView.Rows.Count > 0) { selectedFileDataGridView.CurrentCell = selectedFileDataGridView.Rows[0].Cells["SelectedFileName"]; int curRowPos = 1; RowStatusLabel.Text = "Row " + curRowPos.ToString() + " of " + selectedFileDataGridView.Rows.Count.ToString(); } else { RowStatusLabel.Text = ""; } } catch { RowStatusLabel.Text = ""; } } } } catch (Exception ex) { MessageBox.Show( curMethodName + ":Error encountered\n\nError: " + ex.Message ); String curMsg = curMethodName + ":Exception=" + ex.Message; Log.WriteFile( curMsg ); } }
private bool searchForMatchingSkier(SkierVideoEntry inSkierVideoEntry) { String curMethodName = "searchForMatchingSkier"; String curNumValue = ""; Int16 curPass = 0, curRound = 0; if (myTrickRounds == 1) curRound = myTrickRounds; int curDelimIdx = Path.GetFileName( inSkierVideoEntry.VideoFileName ).LastIndexOf( '.' ); DataRow[] curFindSkiers = null; String curFileName = Path.GetFileName( inSkierVideoEntry.VideoFileName).Substring( 0, curDelimIdx ); String curFileNameMod = Regex.Replace( curFileName, @"(\p{Lu})", " $1" ).TrimStart(); String[] curFileNameNodes = curFileNameMod.Split( myCharDelimLimit, StringSplitOptions.RemoveEmptyEntries ); if (curFileNameNodes.Length > 1) { /* * Search list of all skiers to determine if the parsed file name can be matched to a skier */ curFindSkiers = myFullSkierDataTable.Select(String.Format("SkierName like '%{0}%' AND SkierName like '%{0}%'", curFileNameNodes[0], curFileNameNodes[1])); /* * Parse file name in an attempt to identify the round and pass the video file represents */ int curIdx = 0; foreach (String curEntry in curFileNameNodes) { if (curIdx > 1) { if (curEntry.Substring( 0, 1 ).ToLower().Equals( "p" )) { try { curNumValue = Regex.Match( curEntry, @"\d+" ).Value; if (curNumValue.Length > 0) { curPass = Int16.Parse( curNumValue ); } else { curIdx++; if (curIdx <= curFileNameNodes.Length) { curNumValue = Regex.Match( curFileNameNodes[curIdx], @"\d+" ).Value; if (curNumValue.Length > 0) { curPass = Int16.Parse( curNumValue ); if (curPass > 2) { curPass = 0; } } else { curPass = 0; curIdx--; } } else { curPass = 0; curIdx--; } } } catch (Exception ex) { curPass = 0; MessageBox.Show( curMethodName + ":Error encountered\n\nError: " + ex.Message ); } } else { try { curNumValue = Regex.Match( curEntry, @"\d+" ).Value; if (curNumValue.Length > 0) { curPass = Int16.Parse( curNumValue ); } else { curIdx++; if (curIdx <= curFileNameNodes.Length) { curNumValue = Regex.Match( curFileNameNodes[curIdx], @"\d+" ).Value; if (curNumValue.Length > 0) { curPass = Int16.Parse( curNumValue ); if (curPass > 2) { curPass = 0; } } else { curPass = 0; curIdx--; } } else { curPass = 0; curIdx--; } } } catch (Exception ex) { curPass = 0; MessageBox.Show( curMethodName + ":Error encountered\n\nError: " + ex.Message ); } } if (curEntry.Substring( 0, 1 ).ToLower().Equals( "r" )) { try { curNumValue = Regex.Match( curEntry, @"\d+" ).Value; if (curNumValue.Length > 0) { curRound = Int16.Parse( curNumValue ); } else { curIdx++; if (curIdx <= curFileNameNodes.Length) { curNumValue = Regex.Match( curFileNameNodes[curIdx], @"\d+" ).Value; if (curNumValue.Length > 0) { curRound = Int16.Parse( curNumValue ); } else { curRound = 0; curIdx--; } } else { curRound = 0; curIdx--; } } } catch (Exception ex) { curRound = 0; MessageBox.Show( curMethodName + ":Error encountered\n\nError: " + ex.Message ); } } } curIdx++; } } if ( curFindSkiers != null && curFindSkiers.Length == 1 && curRound > 0 && curPass > 0 ) { //Use record found by filtered search inSkierVideoEntry.MemberId = (String) curFindSkiers[0]["MemberId"]; inSkierVideoEntry.SkierName = (String) curFindSkiers[0]["SkierName"]; inSkierVideoEntry.AgeGroup = (String) curFindSkiers[0]["AgeGroup"]; inSkierVideoEntry.Round = curRound; inSkierVideoEntry.Pass = curPass; } else { if ( curFindSkiers == null ) { mySkierSelectDialog.SkierMatchList = null; } else if ( curFindSkiers.Length > 1 ) { mySkierSelectDialog.SkierMatchList = curFindSkiers; } else { mySkierSelectDialog.SkierMatchList = null; } if ( curRound > 0 ) mySkierSelectDialog.SkierRound = curRound; if ( curPass > 0 ) mySkierSelectDialog.SkierPass = curPass; mySkierSelectDialog.FileName = Path.GetFileName(inSkierVideoEntry.VideoFileName); DialogResult curDialogResult = mySkierSelectDialog.ShowDialog(); if ( curDialogResult == DialogResult.OK ) { inSkierVideoEntry.MemberId = mySkierSelectDialog.SkierMemberId; inSkierVideoEntry.SkierName = mySkierSelectDialog.SkierNameSelected; inSkierVideoEntry.AgeGroup = mySkierSelectDialog.SkierAgeGroup; inSkierVideoEntry.Round = mySkierSelectDialog.SkierRound; inSkierVideoEntry.Pass = mySkierSelectDialog.SkierPass; } } if (inSkierVideoEntry.MemberId.Length > 0 ) { StringBuilder curSqlStmt = new StringBuilder( "" ); curSqlStmt.Append( "SELECT PK FROM TrickScore " ); curSqlStmt.Append( "WHERE SanctionId = '" + mySanctionNum + "' " ); curSqlStmt.Append( " AND MemberId = '" + inSkierVideoEntry.MemberId + "' " ); curSqlStmt.Append( " AND AgeGroup = '" + inSkierVideoEntry.AgeGroup + "' " ); curSqlStmt.Append( " AND Round = " + inSkierVideoEntry.Round + " " ); DataTable curDataTable = getData( curSqlStmt.ToString() ); if (curDataTable.Rows.Count == 1) { inSkierVideoEntry.SkierScorePK = (Int64)curDataTable.Rows[0]["PK"]; return true; } else { MessageBox.Show( "A matching skier, round and pass could not be identified for this video \n\n" + Path.GetFileName( inSkierVideoEntry.VideoFileName ) ); return false; } } else { //MessageBox.Show( "Skier, round and pass have not been selected for this video " + Path.GetFileName(inSkierVideoEntry.VideoFileName) ); return false; } }