private void btCompare_Click(object sender, EventArgs e) { if (this.lsFilesA.Items.Count == 0){ MessageBox.Show("Selection A is empty ! ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (this.lsFilesB.Items.Count == 0){ MessageBox.Show("Selection B is empty ! ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //put files path in array string[] lstA = new string[this.lsFilesA.Items.Count]; this.lsFilesA.Items.CopyTo(lstA, 0); string[] lstB = new string[this.lsFilesB.Items.Count]; this.lsFilesB.Items.CopyTo(lstB, 0); Compare compare = new Compare(); FrmProgress progress = new FrmProgress( (MethodInvoker)delegate() { compare.Stop(); }, (MethodInvoker)delegate() { compare.OpenFolder(); }, (MethodInvoker)delegate() { compare.ShowReportHTML(); }, (MethodInvoker)delegate() { compare.ShowReportXML(); } ); compare.WbProgressEvent += new ProgressUpdateEventHandler(progress.UpdateWbProgress); compare.WsProgressEvent += new ProgressUpdateEventHandler(progress.UpdateWsProgress); compare.InfoEvent += new InfoUpdateEventHandler(progress.UpdateInfo); compare.OnCompleteEvent += new OnCompleteEventHandler(progress.UpdateFinished); compare.CompareFiles(lstA, lstB, @".*", this.ctrlFolder.Text, this.cbOptValue.Checked, this.cbOptStyle.Checked, this.cbOptShape.Checked, false); progress.ShowDialog(); }
static int Main(string[] args) { Console.WriteLine(""); if (args.Length != 2){ Console.WriteLine("Error: Number of argument is invalid !"); PrintHelper(); return (int)ExitCode.InvalidArguments; } string xmlFIlePath = args[0]; string logFIlePath = args[1]; if(!File.Exists(xmlFIlePath)){ Console.WriteLine("Error: Xml file argument doesn't exist !"); PrintHelper(); return (int)ExitCode.InvalidArguments; } if(!Directory.Exists(Path.GetDirectoryName(logFIlePath))){ Console.WriteLine("Error: The directory of the log file argument doesn't exist !"); PrintHelper(); return (int)ExitCode.InvalidArguments; } Logger logger=null; try{ try{ logger = new Logger(args[1]); }catch(Exception ex){ Console.WriteLine("Failed to create log file: " + ex.Message); return (int)ExitCode.InvalidArguments; } RunnerPlan data; try{ logger.Log("Parse xml file to get the compare plan (" + xmlFIlePath + ")"); data = RunnerPlan.ParseFromXml(xmlFIlePath); logger.Log("\tCleanRegEx : " + data.CleanRegEx); logger.Log("\tCompShape : " + data.CompShape); logger.Log("\tCompStyle : " + data.CompStyle); logger.Log("\tCompValue : " + data.CompValue); }catch(Exception ex){ logger.Log("Failed to parse Xml file: " + ex.Message); return (int)ExitCode.FailedToParsePlan; } Compare compare; try{ compare = new Compare(); compare.InfoEvent += new InfoUpdateEventHandler(logger.Log); compare.CompareFiles(data.FilesA, data.FilesB, data.CleanRegEx, data.ReportFolder, data.CompValue, data.CompStyle, data.CompStyle, true); }catch(Exception ex){ logger.Log("Failed to compare files: " + ex.Message); return (int)ExitCode.FailedToCompare; } logger.Log("End of comparison."); return (int)ExitCode.Succeed; }catch(Exception){ return (int)ExitCode.UnknownError; }finally{ logger.Close(); } }