No announcement yet.

.Net component Batch Process

  • Filter
  • Time
  • Show
Clear All
new posts

  • .Net component Batch Process

    Hi everyone,

    Here is ma challenge

    I need to compare lots of files in a .Net batch process. My batch process is a .Net component. He will be launch from a scheduler program.

    The job of the batch component is :
    • Reading informations from a Database/Table to build a list of compare to do.
    Informations are :
    • The path/name of the file1, file2, result report.
    • The type of file to compare
    • The exclusions to apply

    • Finaly, the batch component will launch the process to compare all the occurrences (in command line).

    Here is what I needs (or think I need…) :
    1. It’s clear, I don’t use the UI at all. I use command line to start a compare process. So please don’t refer me to a UI fonctionnality

    2. The batch process execute a tons of compare process. He don’t wait the completion of the first execute and launch the second, the third, …

    3. Each process need to be isolated and don’t affect others process. I presume, I need to use the « /solo » switch

    4. The compare process is going to be done on a server. UI is not permit. I presume, I need to use the « /silent » switch

    5. I want to compare file by file. No folders compare

    6. I need to specify a type of file for each compare process (script file @)

    7. I need to specify a type of exclusion per compare process. The exclusion is not preset, it can be specify on the fly by the Database data from the batch process. Did I have to use : Workspace in association with a configFile ? And finaly specify the workspace in the command line?
    (script file @ vs Workspace ???)

    8. I need to create a repport ONLY if there is a difference. Normaly, on a command/batch file « .bat », we use « BCOMP /quickcompare » first. And we don’t use the BComp (full compare) if he don’t detect a difference. But In a .Net Program how I do this ? I need to catch the errorlevel !

    I need help on points 6, 7 and 8. I read a lot of post. But I need all parts together. Please keep in mind I’m in a VB.Net context

    The following is only what we do in a batch file Proof Of Concept « .Bat » :
    Command line for Quick compare :
    "C:\Program Files (x86)\Beyond Compare 3\" /quickcompare /solo
    C:\Temp\file1.xml C:\Temp\file2.xml

    Error level tell me if there is a difference:
    if errorlevel = 2

    Execute a command line compare:
    "C:\Program Files (x86)\Beyond Compare 3\bcomp.exe" /silent /solo
    @C:\Temp\Detail.txt C:\Temp\file1.xml C:\Temp\file2.xml C:\Temp\NewReport1.html


    Last edited by [email protected]; 30-Jul-2013, 11:10 AM. Reason: Change file name for /Quickcompare

  • #2

    If you can only generate the report on a file, and cannot load the folder, your current Proof of Concept .bat solution (/qc then @script if needed) is the method to use.

    Without modification, this would compare the files using the default session settings, then generate the report using the same defaults.

    Could you clarify what you mean by "specify the exclusion" in point 7? Do you mean you must be able to define the File Format or Importance on the fly? BC3 does not currently support this behavior. We do have a workaround, but this would require altering the BCSessions.xml or BCFileFormat.xml with script before the call is made (to alter the default behavior) or use @scripting to load a folder level compare (which can be configured to use only certain formats) and then have filters set to show only the file pair you are attempting to compare. If you are dealing with VB Scripting, and your file paths or file names are highly variable, I would recommend altering the BCSetting .xmls. You can have a Portable Install of BC3 setup for this specific purpose.
    Aaron P Scooter Software


    • #3
      Hi Aaron,

      I dig a bit on my case and I have some questions.

      Here is more context:

      I have only 2 types of file to manage in my case (Text-Text and Text-XML). I think I don't have to specify the type in the BCompare, your application detect it.

      At the question "What I need for doing a compare ?" I build my structure:
      • FileName1 As String 'It's trivial
      • FileName2 As String 'It's trivial
      • ReportName As String 'It's trivial
      • FileType As myFileType 'It's triviall (flatFile or XML) [may not be use]
      • mExclusion As String '-> Ignore some data in the compare process
      - FlatFile = Exclusions base on colomn (3;9-15) = [Column 3 and columns 9 to 15]
      - XML = Exclusions base on Tags ex: (IdElement) = [ignore the value of this tag]
      Now I have my structure. If I organise this in a CompareCollection (FileElementsColl), I have my data to process all my compare after filling it.

      Here is the main code:
      Public Sub BatchProcessSimulation()
              FillCompareCollection() ' Filling the collection with Data from the Database
              PrepareBeyondCompare() ' Prepare online command to be execute
      	' process each occurrence
              For Each MyFileInfoElement As FileInfosElement In mFileElementsColl
                  'Check if there is differences
                  If Not IsDiff(MyFileInfoElement) Then
                      'Compare all and report
                  End If
              Next MyFileInfoElement
          End Sub
      Ok prepare is:
          Public Sub PrepareBeyondCompare()
              mBCompare = New ProcessStartInfo(PathBCompare)
              mBCompare.WorkingDirectory = "SomeDirectory"
              mBCompare.UseShellExecute = False
              mBCompare.RedirectStandardError = True
              mBCompare.RedirectStandardOutput = True
          End Sub
      The IsDiff function call the BCompare with "/quickcompare" and I'm ok with the ExitCode

      The Problem is in My ExecuteBCompare Method for a full compare:
          Public Sub ExecuteBCompare(ByVal mElement As FileInfosElement)
              Dim myExitCode As Integer
              Dim myOutput As String
              Dim myError As String
      [B][U]'HERE OVERWRITE BCFileFormat.xml and BCSessions.xml for a specific exclusion ???[/U][/B]
              ' Set the arguments for the full Compare
              mBCompare.Arguments = _
                          "/silent /solo @[B][U]C:\Temp\Detail.txt[/U][/B]" & _
                          mElement.FileName1 & " " & _
                          mElement.FileName2 & " " & _
              'Start The process
              myProcess = Process.Start(mBCompare)
              'Specify to wait for the response...
      So what I presume:
      • Detail.txt is my script file
      • BCSessions.xml Active or inactive exclusions
      • BCFileFormat.xml Contain my exclusions

      If I have to create an exclusion on the fly, did I have to overwrite the BCFileFormat.xml and BCSessions.xml before each "Process.Start(mBCompare)" ?




      • #4
        Hello Frankie,

        I think that while it may be possible to script this eventually, we should start with the graphical interface. This would allow us to make sure that BC3 can 'exclude' the data you are trying to have be unimportant to the comparison.

        Once the interface is working with a pair of files, we can then view those settings and their configuration in the graphical interface and how they are represented in our Setting.xml files. You can then see how the .xmls are stored, and what settings would need to be modified on the fly in order to build this into an overall larger process.

        BC3 does not support a series of command lines to do this, and our out of the box support does not have a method to do this, but because our Settings are stored in plain .xml, it is possible to 'hack' them before an automated call, altering them right before BC3 is executed.

        We have a KB article on defining Unimportance here:
        Beyond Compare is a multi-platform utility that combines directory compare and file compare functions in one package. Use it to manage source code, keep directories in sync, compare program output, etc.

        This goes into defining it for a specific pair of files, which can then be propagated as Session Defaults for all future comparisons, which can then be viewed as raw data in our Setting.xmls.
        Aaron P Scooter Software