Click here to Skip to main content
16,004,919 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Dear all
I have this report generated from one of our servers. Basically, the file consists of a number of "profiles" each profile is having a number of applications, each application has a number of functions and some functions have permissions.
The problem is that the file in its present format does not enable us to do any queries, like how many profiles have "SWIFT FIN USER MT:+1%".

The following is a sample of the file containing a number of profiles.

<pre lang="css">Profile = EG_OPER_MT12479               

 
Application = Access Control            
Application = Correspondent Info        
Application = Mesg Creation             
Application = Mesg Modification         
Application = Message File              
Application = Access Control 
     Function = Signon                  
                Permissions =
                Start time:0001
                End time:2357
                Start time:2358
                End time:2359
                 
Application = Correspondent Info 
     Function = Open/Print Alias        
     Function = Open/Print Corr Dets    
     Function = Open/Print Country      
     Function = Open/Print Currency     
Application = Mesg Creation 
     Function = Add/Mod/Rem Template    
     Function = Create Message          
                Permissions =
                List of Own-Destination:+NSGBEGCX
                Can create broadcasting:N
                CCY/Amount:-
                Swift FIN User MT:+1%
                2%
                4%
                7%
                9%
                Swift FIN System MT:+
                Swift APC System MT:+
                Multiple Retrieval Allowed
                for FIN System mesg.:N
                Multiple Retrieval Allowed
                 for APC System mesg.:N
                FIN-Copy Allowed.:Y
                Create free format text Telex msg:N
                Create free format financial Telex msg:N
                 
     Function = Route Message           
Application = Mesg Modification 
     Function = Complete Message        
     Function = Modify Message          
                Permissions =
                Own destination:+NSGBEGCX
                Mod. in Text_modification:Y
                Mod. in Emission_security:N
                Mod. in Transmission_modif:N
                Mod. in modif_after_recept:N
                Mod. in Reception_security:N
                CCY/Amount:-
                Swift FIN User MT:+1%
                2%
                4%
                7%
                9%
                Swift FIN System MT:+
                Swift APC System MT:+
                Multiple Retrieval Allowed
                for FIN System mesg.:N
                Multiple Retrieval Allowed
                for APC System mesg.:N
                FIN-Copy Allowed.:Y
                 
     Function = Route Message           
Application = Message File 
     Function = Complete Instance       
     Function = Search                  
                Permissions =
                Completely hide messages of other units:Y
                 
      
Profile = EG_OPER_MT1249                

 
Application = Access Control            
Application = Correspondent Info        
Application = Mesg Creation             
Application = Mesg Modification         
Application = Message File              
Application = Access Control 
     Function = Signon                  
                Permissions =
                Start time:0001
                End time:2357
                Start time:2358
                End time:2359
                 
Application = Correspondent Info 
     Function = Open/Print Alias        
     Function = Open/Print Corr Dets    
     Function = Open/Print Country      
     Function = Open/Print Currency     
Application = Mesg Creation 
     Function = Add/Mod/Rem Template    
     Function = Create Message          
                Permissions =
                List of Own-Destination:+NSGBEGCX
                Can create broadcasting:N
                CCY/Amount:-
                Swift FIN User MT:+1%
                2%
                4%
                9%
                Swift FIN System MT:+
                Swift APC System MT:+
                Multiple Retrieval Allowed
                for FIN System mesg.:N
                Multiple Retrieval Allowed
                 for APC System mesg.:N
                FIN-Copy Allowed.:Y
                Create free format text Telex msg:N
                Create free format financial Telex msg:N
                 
     Function = Route Message           
Application = Mesg Modification 
     Function = Complete Message        
     Function = Modify Message          
                Permissions =
                Own destination:+NSGBEGCX
                Mod. in Text_modification:Y
                Mod. in Emission_security:N
                Mod. in Transmission_modif:N
                Mod. in modif_after_recept:N
                Mod. in Reception_security:N
                CCY/Amount:-
                Swift FIN User MT:+1%
                2%
                4%
                9%
                Swift FIN System MT:+
                Swift APC System MT:+
                Multiple Retrieval Allowed
                for FIN System mesg.:N
                Multiple Retrieval Allowed
                for APC System mesg.:N
                FIN-Copy Allowed.:Y
                 
     Function = Route Message           
Application = Message File 
     Function = Complete Instance       
     Function = Search                  
                Permissions =
                Completely hide messages of other units:Y
                 
      
Profile = EG_OPER_MT125                 

 
Application = Access Control            
Application = Correspondent Info        
Application = Mesg Creation             
Application = Mesg Modification         
Application = Message File              
Application = Access Control 
     Function = Signon                  
                Permissions =
                Start time:0001
                End time:2357
                Start time:2358
                End time:2359
                 
Application = Correspondent Info 
     Function = Open/Print Alias        
     Function = Open/Print Corr Dets    
     Function = Open/Print Country      
     Function = Open/Print Currency     
Application = Mesg Creation 
     Function = Add/Mod/Rem Template    
     Function = Create Message          
                Permissions =
                List of Own-Destination:+NSGBEGCX
                Can create broadcasting:N
                CCY/Amount:-
                Swift FIN User MT:+198
                298
                535
                Swift FIN System MT:+
                Swift APC System MT:+
                Multiple Retrieval Allowed
                for FIN System mesg.:N
                Multiple Retrieval Allowed
                 for APC System mesg.:N
                FIN-Copy Allowed.:Y
                Create free format text Telex msg:N
                Create free format financial Telex msg:N
                 
     Function = Route Message           
Application = Mesg Modification 
     Function = Complete Message        
     Function = Modify Message          
                Permissions =
                Own destination:+NSGBEGCX
                Mod. in Text_modification:Y
                Mod. in Emission_security:N
                Mod. in Transmission_modif:N
                Mod. in modif_after_recept:N
                Mod. in Reception_security:N
                CCY/Amount:-
                Swift FIN User MT:+198
                298
                535
                Swift FIN System MT:+
                Swift APC System MT:+
                Multiple Retrieval Allowed
                for FIN System mesg.:N
                Multiple Retrieval Allowed
                for APC System mesg.:N
                FIN-Copy Allowed.:Y
                 
     Function = Route Message           
Application = Message File 
     Function = Complete Instance       
     Function = Search                  
                Permissions =
                Completely hide messages of other units:Y
                 
      
Profile = EG_OPER_MT1279                

 
Application = Access Control            
Application = Correspondent Info        
Application = Mesg Creation             
Application = Mesg Modification         
Application = Message File              
Application = Access Control 
     Function = Signon                  
                Permissions =
                Start time:0001
                End time:2357
                Start time:2358
                End time:2359
                 
Application = Correspondent Info 
     Function = Open/Print Alias        
     Function = Open/Print Corr Dets    
     Function = Open/Print Country      
     Function = Open/Print Currency     
Application = Mesg Creation 
     Function = Add/Mod/Rem Template    
     Function = Create Message          
                Permissions =
                List of Own-Destination:+NSGBEGCX
                Can create broadcasting:N
                CCY/Amount:-
                Swift FIN User MT:+1%
                2%
                7%
                9%
                Swift FIN System MT:+
                Swift APC System MT:+
                Multiple Retrieval Allowed
                for FIN System mesg.:N
                Multiple Retrieval Allowed
                 for APC System mesg.:N
                FIN-Copy Allowed.:Y
                Create free format text Telex msg:N
                Create free format financial Telex msg:N
                 
     Function = Route Message           
Application = Mesg Modification 
     Function = Complete Message        
     Function = Modify Message          
                Permissions =
                Own destination:+NSGBEGCX
                Mod. in Text_modification:Y
                Mod. in Emission_security:N
                Mod. in Transmission_modif:N
                Mod. in modif_after_recept:N
                Mod. in Reception_security:N
                CCY/Amount:-
                Swift FIN User MT:+1%
                2%
                7%
                9%
                Swift FIN System MT:+
                Swift APC System MT:+
                Multiple Retrieval Allowed
                for FIN System mesg.:N
                Multiple Retrieval Allowed
                for APC System mesg.:N
                FIN-Copy Allowed.:Y
                 
     Function = Route Message           
Application = Message File 
     Function = Complete Instance       
     Function = Search                  
                Permissions =
                Completely hide messages of other units:Y



I thought of converting it to an XML file, i also thought of running regular expressions on it with C# and storing the results in a database but i failed in both.
What do you think is the most efficient way to do the task at hand ?
Any help would be greatly appreciated.

Thanks for the reply. The problem (whether using the XML approach or the RegEx approach) is that i want to parse the document on the fly. I need a way to read the document and store the different parts in fields so that they can be queried.
Posted
Updated 14-Feb-10 9:16am
v2

1 solution

I would go for the xml using XDocument.

I would also create a Class that holds the profile Data.
One for the Application.
One for the Function(s).
And one class or enum for the permision of the function(s).

So the final class would look something like this:

public class Profile{
     List<Application> apps = new List&lt;Application&gt;;
     
     //a list of Function for application. In the function class
     //put an Application field to make the link wich func belongs
     //to wich app.
     
     //and finally permison(s)
}


So the xml would be something like this:
<Profiles>
  <Profile>
   <Application>"myApp"
      <Funtion>
         <Permision></Permision>
      </Function>
   </Application>   
  </Profile>
</Profiles>


So you could use XLINQ to get the datas. Ex to get all the functions of a given Application:

XDocument xdoc = XDocument.Load("YourFileName");
           var myAppFunction = xdoc.Elements("Profiles").Elements("Profile").
               Elements("Application").
               Where(n=>n.Value=="myApp").Elements("Function");                


You said that it failed. How? Why? What?
 
Share this answer
 
v11

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900