edit: проект старый, и приведенный ниже код представляет собой один класс, который обрабатывает xml.
Есть вопрос, чтобы получить xsd из старого унаследованного приложения, но все, что он, похоже, делает: xmlReader.ParseXml (fileName, outputFile); в методе ProcessXml ().
using System;
using System.IO;
using System.Configuration;
using Utilities;
namespace JobProcessor
{
public class XmlJob : Job
{
#region variables
private string ftpServer;
private string ftpUserName;
private string ftpPassWord;
private string ftpDestination;
///<summary>The xml reader used to get validation information from the xmp parsing</summary>
protected XmlReader xmlReader = new XmlReader();
private string outputFile;
public XmlJob(string fileName, string type) : base(fileName, type){
ftpServer = ConfigurationManager.AppSettings[type + "-ftp"];
ftpUserName = ConfigurationManager.AppSettings[type + "-ftpUser"];
ftpPassWord = ConfigurationManager.AppSettings[type + "-ftpPass"];
ftpDestination = ConfigurationManager.AppSettings[type + "-ftpDest"];
}
protected bool ConfigureXmlReader(){
int recType = 0;
try{
//set up the record types (i.e. the elements that trigger a new record in the output
while(ConfigurationManager.AppSettings[type + "-RecordType" + recType.ToString("00")] != null){
xmlReader.AddRecordType(ConfigurationManager.AppSettings[type + "-RecordType" + recType.ToString("00")],recType.ToString("00"));
recType++;
}
//store the number of types
xmlReader.SetNoRecordTypes(recType);
}catch(Exception e){
HandleError("Error loading record types\r\n" + e.ToString() + "\r\n" + e.StackTrace + "\r\n");
return(false);
}
try{
//set up the fields which make up each record type
for(int i=0;i<recType;i++){
xmlReader.AddFieldsList(i,ConfigurationManager.AppSettings[type + "-" + i.ToString("00") + "Fields"]);
}
}catch(Exception e){
HandleError("Error loading field list\r\n" + e.ToString() + "\r\n" + e.StackTrace + "\r\n");
return(false);
}
return(true);
}
public override void RunJob(){
outputFile = Path.Combine(destinationDirectory, Path.GetFileNameWithoutExtension(fileName) + ".flat");
if(!ConfigureXmlReader()){
return;
}
if(!CheckInputFile()){
return;
}
if(!ProcessXml()){
return;
}
if(!Validate()){
return;
}
if(ftpServer!=null && ftpUserName!=null && ftpPassWord!=null && ftpDestination!=null){
if(!FtpFile()){
return;
}
}
MoveOriginalFile();
}
protected virtual bool Validate(){
return(true);
}
protected bool ProcessXml(){
/*
* Process the xml file into a delimited format
*/
try{
xmlReader.ParseXml(fileName,outputFile);
}catch(Exception e){
HandleError("Error parsing XML file\r\n" + e.ToString() + "\r\n" + e.StackTrace + "\r\n");
return(false);
}
return(true);
}
protected bool FtpFile(){
try{
FtpMethods.UploadFile(ftpServer,ftpUserName,ftpPassWord,outputFile,ftpDestination);
}catch(Exception e){
HandleError("Error FTPing file\r\n" + e.ToString() + "\r\n" + e.StackTrace + "\r\n");
return(false);
}
return(true);
}
#endregion
}
}
Что именно делает эта команда? F1 ничего не находит, и поиск в Google приводит меня ко многим xmlTextReaders.