private void lstFiles_DoubleClick(object sender, EventArgs e) { if (lstFiles.SelectedItems.Count == 0) { return; } FileCompareResults results = (FileCompareResults)lstFiles.SelectedItems[0].Tag; if (results.UnifiedDiffText.Length > 0) { this.linkedBoxes.BringToFront(); this.linkedBoxes.UnifiedDiffText = results.UnifiedDiffText; this.linkedBoxes.LeftFileName = Path.Combine(leftTempFilePath, results.LeftScriptRow.FileName); this.linkedBoxes.RightFileName = Path.Combine(rightTempFilePath, results.RightScriptRow.FileName); this.linkedBoxes.SplitUnifiedDiffText(); return; } this.pnlSingleResults.BringToFront(); if (results.LeftScriptText.Length > 0) { rtbResultsHighlight.Text = results.LeftScriptText; //lstFiles.SelectedItems[0].Tag.ToString(); } else { rtbResultsHighlight.Text = results.RightSciptText; } rtbResultsHighlight.HighlightType = SqlSync.Highlighting.SyntaxHightlightType.Sql; }
private void removeSelectedScriptsFromTheLeftFileToolStripMenuItem_Click(object sender, EventArgs e) { //TODO: finish real delete! if (lstFiles.SelectedItems.Count == 0) { return; } this.Cursor = Cursors.WaitCursor; StringBuilder sb = new StringBuilder("Are you sure you want to remove the follow file(s)?\r\n\r\n");; for (int i = 0; i < lstFiles.SelectedItems.Count; i++) { sb.Append(" " + ((FileCompareResults)lstFiles.SelectedItems[i].Tag).LeftScriptRow.FileName + "\r\n"); } if (DialogResult.No == MessageBox.Show(sb.ToString(), "Delete Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) { this.Cursor = Cursors.Default; return; } //Get list of rows to remove then remove them. SqlSyncBuildData.ScriptRow[] rows = new SqlSyncBuildData.ScriptRow[lstFiles.SelectedItems.Count]; for (int i = 0; i < lstFiles.SelectedItems.Count; i++) { FileCompareResults results = (FileCompareResults)lstFiles.SelectedItems[i].Tag; rows[i] = results.LeftScriptRow; } //TODO: Check for delete from an SBX file if (!SqlBuildFileHelper.RemoveScriptFilesFromBuild(ref this.buildData, Path.Combine(this.leftTempFilePath, XmlFileNames.MainProjectFile), this.leftZipFilePath, rows, true)) { MessageBox.Show("Unable to remove file from list. Please try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (lstFiles.SelectedItems.Count > 0) { this.refreshProjectList = true; } btnCompare_Click(null, EventArgs.Empty); this.Cursor = Cursors.Default; }
public ConfigurationCompare(FileCompareResults compare) : this() { this.compare = compare; }
static bool CompareFiles( string sourceFilePath, string destFilePath, out FileCompareResults result ) { result.TestSucceeded = false; result.ContentResult = eContentCompareResult.SAME; result.DateResult = eDateCompareResult.SAME_TIME; System.IO.FileInfo sourceFileInfo = null; System.IO.FileInfo destFileInfo = null; DateTime sourceFileTime; DateTime destFileTime; long sourceFileLen; long destFileLen; try { sourceFileInfo = new System.IO.FileInfo( sourceFilePath ); if ( !sourceFileInfo.Exists ) { return false; // if no source, fail } sourceFileTime = sourceFileInfo.LastWriteTimeUtc; sourceFileLen = sourceFileInfo.Length; destFileInfo = new System.IO.FileInfo( destFilePath ); if ( !destFileInfo.Exists ) { result.TestSucceeded = true; result.DateResult = eDateCompareResult.SOURCE_NEWER; // if no dest, consider source newer return false; } destFileTime = destFileInfo.LastWriteTimeUtc; destFileLen = destFileInfo.Length; } catch ( System.IO.IOException ) { return false; // error testing file times } result.TestSucceeded = true; if ( sourceFileTime > destFileTime ) { result.DateResult = eDateCompareResult.SOURCE_NEWER; return false; } else if ( destFileTime > sourceFileTime ) { result.DateResult = eDateCompareResult.DEST_NEWER; return false; } if ( sourceFileLen != destFileLen ) { result.ContentResult = eContentCompareResult.DIFFERENT; return false; } // times and lengths are the same so compare the file contents byte[] sourceFile = null; byte[] destFile = null; try { sourceFile = System.IO.File.ReadAllBytes( sourceFilePath ); destFile = System.IO.File.ReadAllBytes( destFilePath ); } catch ( Exception ) { return false; } if ( sourceFile.Length != destFile.Length ) { // this shouldn't happen since we check the length above! Debug.LogError( "File lengths should be the same!" ); result.ContentResult = eContentCompareResult.DIFFERENT; return false; } for ( int i = 0; i < sourceFile.Length; ++i ) { if ( sourceFile[i] != destFile[i] ) { result.ContentResult = eContentCompareResult.DIFFERENT; return false; } } return true; }
static bool CompareFiles(string sourceFilePath, string destFilePath, out FileCompareResults result) { result.TestSucceeded = false; result.ContentResult = eContentCompareResult.SAME; result.DateResult = eDateCompareResult.SAME_TIME; System.IO.FileInfo sourceFileInfo = null; System.IO.FileInfo destFileInfo = null; DateTime sourceFileTime; DateTime destFileTime; long sourceFileLen; long destFileLen; try { sourceFileInfo = new System.IO.FileInfo(sourceFilePath); if (!sourceFileInfo.Exists) { return(false); // if no source, fail } sourceFileTime = sourceFileInfo.LastWriteTimeUtc; sourceFileLen = sourceFileInfo.Length; destFileInfo = new System.IO.FileInfo(destFilePath); if (!destFileInfo.Exists) { result.TestSucceeded = true; result.DateResult = eDateCompareResult.SOURCE_NEWER; // if no dest, consider source newer return(false); } destFileTime = destFileInfo.LastWriteTimeUtc; destFileLen = destFileInfo.Length; } catch (System.IO.IOException) { return(false); // error testing file times } result.TestSucceeded = true; if (sourceFileTime > destFileTime) { result.DateResult = eDateCompareResult.SOURCE_NEWER; return(false); } else if (destFileTime > sourceFileTime) { result.DateResult = eDateCompareResult.DEST_NEWER; return(false); } if (sourceFileLen != destFileLen) { result.ContentResult = eContentCompareResult.DIFFERENT; return(false); } // times and lengths are the same so compare the file contents byte[] sourceFile = null; byte[] destFile = null; try { sourceFile = System.IO.File.ReadAllBytes(sourceFilePath); destFile = System.IO.File.ReadAllBytes(destFilePath); } catch (Exception) { return(false); } if (sourceFile.Length != destFile.Length) { // this shouldn't happen since we check the length above! Debug.LogError("File lengths should be the same!"); result.ContentResult = eContentCompareResult.DIFFERENT; return(false); } for (int i = 0; i < sourceFile.Length; ++i) { if (sourceFile[i] != destFile[i]) { result.ContentResult = eContentCompareResult.DIFFERENT; return(false); } } return(true); }
public SimpleDiffForm(FileCompareResults results, string objectName, string databaseName, string serverName) : this() { this.results = results; this.Text = String.Format(this.Text, System.IO.Path.GetFileName(results.LeftScriptPath), serverName, databaseName, objectName); }