本文整理匯總了C#中System.Xml.XmlTextReader.Dispose方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlTextReader.Dispose方法的具體用法?C# XmlTextReader.Dispose怎麽用?C# XmlTextReader.Dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XmlTextReader
的用法示例。
在下文中一共展示了XmlTextReader.Dispose方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Table_GetAll
public List<object> Table_GetAll()
{
var returnValue = new List<object>();
try
{
var allTables = base.GetAllFiles(this._tableDirectoryPath);
foreach (var table in allTables)
{
var fileStream = base.GetFileReadStream(table.Value);
var xmlTextReader = new XmlTextReader(fileStream);
returnValue.Add(Serializer.Deserialize(xmlTextReader));
fileStream.Close();
fileStream.Dispose();
xmlTextReader.Close();
xmlTextReader.Dispose();
}
}
catch (Exception ex)
{
if (this._logger != null)
{
this._logger.Log(ex.Message, Category.Exception, Priority.High);
}
}
return returnValue;
}
示例2: VerifyTest
public static void VerifyTest(string actResult, string expResult)
{
XmlDiff.XmlDiff diff = new XmlDiff.XmlDiff();
diff.Option = XmlDiffOption.IgnoreEmptyElement | XmlDiffOption.IgnoreAttributeOrder;
XmlTextReader xrActual = new XmlTextReader(new StringReader(actResult));
XmlTextReader xrExpected = new XmlTextReader(new StringReader(expResult));
bool bResult = false;
try
{
bResult = diff.Compare(xrActual, xrExpected);
}
catch (Exception e)
{
bResult = false;
s_output.WriteLine("Exception thrown in XmlDiff compare!");
s_output.WriteLine(e.ToString());
}
finally
{
if (xrActual != null) xrActual.Dispose();
if (xrExpected != null) xrExpected.Dispose();
}
s_output.WriteLine("Expected : " + expResult);
s_output.WriteLine("Actual : " + actResult);
if (bResult)
return;
else
Assert.True(false);
}
示例3: Table_GetByID
public object Table_GetByID(Guid tableId)
{
object returnValue = null;
try
{
var fileStream = base.GetFileReadStream(Path.Combine(this._tableDirectoryPath, tableId.ToString() + ".xml"));
var xmlTextReader = new XmlTextReader(fileStream);
returnValue = Serializer.Deserialize(xmlTextReader);
fileStream.Close();
fileStream.Dispose();
xmlTextReader.Close();
xmlTextReader.Dispose();
}
catch (Exception ex)
{
if (this._logger != null)
{
this._logger.Log(ex.Message, Category.Exception, Priority.High);
}
}
return returnValue;
}
示例4: import
public void import(String filename)
{
WindowTitle = "Importing Tags";
XmlTextReader inFile = null;
try
{
inFile = new XmlTextReader(filename);
Type[] knownTypes = new Type[] { typeof(TagDTO), typeof(TagCategoryDTO) };
DataContractSerializer tagSerializer = new DataContractSerializer(typeof(List<TagDTO>), knownTypes);
List<Tag> tags = new List<Tag>();
List<TagDTO> tagDTOs = (List<TagDTO>)tagSerializer.ReadObject(inFile);
foreach (TagDTO tagDTO in tagDTOs)
{
var tag = Mapper.Map<TagDTO, Tag>(tagDTO, new Tag());
tags.Add(tag);
}
TotalProgressMax = tags.Count;
TotalProgress = 0;
using (TagDbCommands tagCommands = new TagDbCommands())
{
foreach (Tag tag in tags)
{
if (CancellationToken.IsCancellationRequested == true) return;
ItemInfo = "Merging: " + tag.Name;
ItemProgress = 0;
tagCommands.merge(tag);
ItemProgress = 100;
TotalProgress++;
InfoMessages.Add("Merged: " + tag.Name);
}
}
}
catch (Exception e)
{
InfoMessages.Add("Error importing tags " + e.Message);
}
finally
{
operationFinished();
if (inFile != null)
{
inFile.Dispose();
}
}
}
示例5: FullFilePath
// --------------------------------------------------------------------------------------------------------------
// LoadXSL_Resolver_Evidence
// -------------------------------------------------------------------------------------------------------------
/*public int LoadXSL_Resolver_Evidence(String _strXslFile, XmlResolver xr, Evidence e)
{
_strXslFile = FullFilePath(_strXslFile);
xslt = new XslCompiledTransform();
switch (_nInputXsl)
{
case XslInputType.Reader:
switch (_readerType)
{
case ReaderType.XmlTextReader:
XmlReader trTemp = XmlReader.Create(_strXslFile);
try
{
_output.WriteLine("Loading style sheet as XmlTextReader " + _strXslFile);
//xslt.Load(trTemp, xr, e); //Evidence is not supported on V2 XSLT Load
xslt.Load(trTemp, XsltSettings.TrustedXslt, xr);
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (trTemp != null)
trTemp.Dispose();
}
break;
case ReaderType.XmlNodeReader:
XmlDocument docTemp = new XmlDocument();
docTemp.Load(_strXslFile);
XmlNodeReader nrTemp = new XmlNodeReader(docTemp);
try
{
_output.WriteLine("Loading style sheet as XmlNodeReader " + _strXslFile);
//xslt.Load(nrTemp, xr, e); Evidence is not supported in V2 XSLT Load
xslt.Load(nrTemp, XsltSettings.TrustedXslt, xr);
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (nrTemp != null)
nrTemp.Dispose();
}
break;
case ReaderType.XmlValidatingReader:
default:
XmlReaderSettings xrs = new XmlReaderSettings();
#pragma warning disable 0618
xrs.ProhibitDtd = false;
#pragma warning restore 0618
XmlReader vrTemp = null;
try
{
vrTemp = XmlReader.Create(_strXslFile, xrs);
_output.WriteLine("Loading style sheet as XmlValidatingReader " + _strXslFile);
//xslt.Load(vrTemp, xr, e); Evidence is not supported in V2 XSLT Load
xslt.Load(vrTemp, XsltSettings.TrustedXslt, xr);
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (vrTemp != null)
vrTemp.Dispose();
}
break;
}
break;
case XslInputType.Navigator:
XmlReader xrLoad = XmlReader.Create(_strXslFile);
XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
xrLoad.Dispose();
_output.WriteLine("Loading style sheet as Navigator " + _strXslFile);
xslt.Load(xdTemp.CreateNavigator(), XsltSettings.TrustedXslt, xr);
break;
}
return 1;
}*/
//VerifyResult
public void VerifyResult(string expectedValue)
{
XmlDiff.XmlDiff xmldiff = new XmlDiff.XmlDiff();
xmldiff.Option = XmlDiffOption.InfosetComparison | XmlDiffOption.IgnoreEmptyElement;
StreamReader sr = new StreamReader(new FileStream("out.xml", FileMode.Open, FileAccess.Read));
string actualValue = sr.ReadToEnd();
sr.Dispose();
//.........這裏部分代碼省略.........
示例6: LoadXSL_Resolver
// --------------------------------------------------------------------------------------------------------------
// LoadXSL_Resolver
// -------------------------------------------------------------------------------------------------------------
public int LoadXSL_Resolver(String _strXslFile, XmlResolver xr)
{
_strXslFile = FullFilePath(_strXslFile);
xslt = new XslCompiledTransform();
XmlReaderSettings xrs = null;
switch (_nInputXsl)
{
case XslInputType.URI:
_output.WriteLine("Loading style sheet as URI " + _strXslFile);
xslt.Load(_strXslFile, XsltSettings.TrustedXslt, xr);
break;
case XslInputType.Reader:
switch (_readerType)
{
case ReaderType.XmlTextReader:
XmlTextReader trTemp = new XmlTextReader(_strXslFile);
try
{
_output.WriteLine("Loading style sheet as XmlTextReader " + _strXslFile);
xslt.Load(trTemp, XsltSettings.TrustedXslt, xr);
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (trTemp != null)
trTemp.Dispose();
}
break;
case ReaderType.XmlNodeReader:
XmlDocument docTemp = new XmlDocument();
docTemp.Load(_strXslFile);
XmlNodeReader nrTemp = new XmlNodeReader(docTemp);
try
{
_output.WriteLine("Loading style sheet as XmlNodeReader " + _strXslFile);
xslt.Load(nrTemp, XsltSettings.TrustedXslt, xr);
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (nrTemp != null)
nrTemp.Dispose();
}
break;
case ReaderType.XmlValidatingReader:
default:
xrs = new XmlReaderSettings();
#pragma warning disable 0618
xrs.ProhibitDtd = false;
#pragma warning restore 0618
XmlReader vrTemp = XmlReader.Create(_strXslFile, xrs);
try
{
_output.WriteLine("Loading style sheet as XmlValidatingReader " + _strXslFile);
xslt.Load(vrTemp, XsltSettings.TrustedXslt, xr);
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (vrTemp != null)
vrTemp.Dispose();
}
break;
}
break;
case XslInputType.Navigator:
xrs = new XmlReaderSettings();
#pragma warning disable 0618
xrs.ProhibitDtd = false;
#pragma warning restore 0618
XmlReader xrLoad = XmlReader.Create(_strXslFile, xrs);
XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
xrLoad.Dispose();
_output.WriteLine("Loading style sheet as Navigator " + _strXslFile);
xslt.Load(xdTemp, XsltSettings.TrustedXslt, xr);
break;
}
return 1;
}
示例7: GetSavedVersion
// TODO : ADDED FOR PS5
/// <summary>
/// Returns the version information of the spreadsheet saved in the named file.
/// If there are any problems opening, reading, or closing the file, the method
/// should throw a SpreadsheetReadWriteException with an explanatory message.
/// </summary>
public override string GetSavedVersion(string filename)
{
string vers = "";
XmlTextReader xmlReader = null;
try
{
xmlReader = new XmlTextReader(filename);
}
catch (Exception)
{
xmlReader.Dispose();
throw new SpreadsheetReadWriteException("File could not be opened using XmlTextReader");
}
// Attempts to read the spreadsheet version from the XML file.
if (!xmlReader.ReadToFollowing("spreadsheet") || !xmlReader.MoveToFirstAttribute())
throw new SpreadsheetReadWriteException("Spreadsheet version could not be found");
vers = xmlReader.Value;
// Attemtps to close the XML reader.
try
{
xmlReader.Close();
}
catch (Exception)
{
xmlReader.Dispose();
throw new SpreadsheetReadWriteException("File could not be closed.");
}
return vers;
}
示例8: Spreadsheet
/// <summary>
/// Provides a four argument constructor for a spreadsheet.
/// This constructor will use the provided Validator and Normalizer, and will set the version to be the provided version string.
/// This constructor will also construct cells based on an XMl spreadsheet representation of a spreadsheet.
/// If the version passed into the constructor does not match the version in the XML file, an exception is thrown.
/// </summary>
public Spreadsheet(string filePath, Func<string, bool> isValid, Func<string, string> normalize, string version)
: base(isValid, normalize, version)
{
cells = new Dictionary<string, Cell>();
dependencies = new DependencyGraph();
if (GetSavedVersion(filePath) != version)
throw new SpreadsheetReadWriteException("The saved version of the XML file does not match the version provided to the constructor.");
// Constructs an XML reader object.
XmlTextReader xmlReader = null;
try
{
xmlReader = new XmlTextReader(filePath);
}
catch (Exception)
{
xmlReader.Dispose();
throw new SpreadsheetReadWriteException("File could not be opened using XmlTextReader");
}
// Reads cells from XML spreadsheet.
while (xmlReader.Read())
{
string name = "";
string contents = "";
if (xmlReader.ReadToFollowing("name"))
{
name = xmlReader.ReadElementContentAsString();
if (!xmlReader.ReadToFollowing("contents"))
throw new SpreadsheetReadWriteException("No contents found associated with name: " + name);
contents = xmlReader.ReadElementContentAsString();
this.SetContentsOfCell(name, contents);
}
}
IsValid = isValid;
Normalize = normalize;
hasChanged = false;
}
示例9: LoadXSL_Resolver
// --------------------------------------------------------------------------------------------------------------
// LoadXSL_Resolver
// -------------------------------------------------------------------------------------------------------------
public int LoadXSL_Resolver(String _strXslFile, XmlResolver xr)
{
_strXslFile = FullFilePath(_strXslFile);
#pragma warning disable 0618
xslt = new XslTransform();
#pragma warning restore 0618
switch (_nInput)
{
case InputType.URI:
_output.WriteLine("Loading style sheet as URI {0}", _strXslFile);
xslt.Load(_strXslFile, xr);
break;
case InputType.Reader:
switch (_readerType)
{
case ReaderType.XmlTextReader:
XmlTextReader trTemp = new XmlTextReader(_strXslFile);
try
{
_output.WriteLine("Loading style sheet as XmlTextReader {0}", _strXslFile);
xslt.Load(trTemp, xr);
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (trTemp != null)
trTemp.Dispose();
}
break;
case ReaderType.XmlNodeReader:
XmlDocument docTemp = new XmlDocument();
docTemp.Load(_strXslFile);
XmlNodeReader nrTemp = new XmlNodeReader(docTemp);
try
{
_output.WriteLine("Loading style sheet as XmlNodeReader {0}", _strXslFile);
xslt.Load(nrTemp, xr);
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (nrTemp != null)
nrTemp.Dispose();
}
break;
case ReaderType.XmlValidatingReader:
default:
#pragma warning disable 0618
XmlValidatingReader vrTemp = new XmlValidatingReader(new XmlTextReader(_strXslFile));
#pragma warning restore 0618
vrTemp.ValidationType = ValidationType.None;
vrTemp.EntityHandling = EntityHandling.ExpandEntities;
try
{
_output.WriteLine("Loading style sheet as XmlValidatingReader {0}", _strXslFile);
xslt.Load(vrTemp, xr);
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (vrTemp != null)
vrTemp.Dispose();
}
break;
}
break;
case InputType.Navigator:
#pragma warning disable 0618
XmlValidatingReader xrLoad = new XmlValidatingReader(new XmlTextReader(_strXslFile));
#pragma warning restore 0618
XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
xrLoad.Dispose();
_output.WriteLine("Loading style sheet as Navigator {0}", _strXslFile);
xslt.Load(xdTemp, xr);
break;
}
return 1;
}
示例10: TransformStrStrResolver1
public void TransformStrStrResolver1()
{
String szFullFilename = FullFilePath("fruits.xml");
try
{
if (LoadXSL("xmlResolver_main.xsl", new XmlUrlResolver()) == 1)
{
XmlTextReader xr = new XmlTextReader(szFullFilename);
XmlTextWriter xw = new XmlTextWriter("out.xml", Encoding.Unicode);
xslt.Transform(xr, null, xw, null);
xr.Dispose();
xw.Dispose();
if (CheckResult(403.7784431795) == 1)
return;
else
Assert.True(false);
}
}
catch (Exception e)
{
_output.WriteLine(e.ToString());
Assert.True(false);
}
Assert.True(false);
}
示例11: TransformStrStrResolver1
public void TransformStrStrResolver1()
{
String szFullFilename = FullFilePath("fruits.xml");
string expected = @"<result>
<fruit>Apple</fruit>
<fruit>orange</fruit>
</result>";
if (LoadXSL("XmlResolver_Main.xsl", new XmlUrlResolver()) == 1)
{
XmlTextReader xr = new XmlTextReader(szFullFilename);
XmlTextWriter xw = new XmlTextWriter("out.xml", Encoding.Unicode);
xslt.Transform(xr, null, xw, null);
xr.Dispose();
xw.Dispose();
VerifyResult(expected);
return;
}
Assert.True(false);
}
示例12: ProcessClientBigRequest
public static void ProcessClientBigRequest(string ConnString, Stream requestStream, Stream responseStream, bool dispose, FlushDelegate flushDelegate, TaskLoggingHelper log)
{
XmlTextReader xr = new XmlTextReader(requestStream);
XmlTextWriter xw = new XmlTextWriter(responseStream, Encoding.UTF8);
xw.WriteStartDocument();
xw.WriteStartElement("table");
bool first = true;
//using (xr)
//{
xr.Read();
xr.Read();
xr.ReadStartElement("request");
while (xr.Name == "id")
{
int serviceTableID = Convert.ToInt32(xr.ReadElementString("id"));
ServiceTable st = DAO.GetServiceTable(ConnString, serviceTableID);
if (first)
{
if (log != null)
log.LogMessage("Processing ID " + serviceTableID.ToString() + " response " + st.ServiceTableID.ToString());
first = false;
}
xw.WriteStartElement("record");
xw.WriteElementString("ServiceTableID", st.ServiceTableID.ToString());
xw.WriteElementString("DescServiceTable", st.DescServiceTable);
xw.WriteElementString("Value", st.Value.ToString("0.00"));
xw.WriteElementString("CreationDate", st.CreationDate.ToString("dd/MM/yyyy hh:mm:ss"));
xw.WriteElementString("StringField1", st.StringField1);
xw.WriteElementString("StringField2", st.StringField2);
xw.WriteEndElement();
if (flushDelegate != null)
flushDelegate();
}
xr.ReadEndElement();
//}
xr.Dispose();
xw.WriteEndElement();
xw.Flush();
if (dispose)
xw.Close();
}
示例13: ProcessWspFile
//.........這裏部分代碼省略.........
XmlNodeList xmlFieldRefList = fieldRefs.ChildNodes;
for (int j = 0; j < xmlFieldRefList.Count; j++)
{
try
{
string fieldRefId = xmlFieldRefList[j].Attributes["ID"].Value;
if (lstCustomFieldIDs.Where(c => fieldRefId.Equals(c)).Any())
{
isCustomSiteColumn = true;
Logger.LogInfoMessage("[DownloadAndModifySiteTemplate: ProcessWspFile] Customized Site Column associated with Content Type Found for: " + objSiteCustOutput.SiteTemplateName, true);
break;
}
}
catch (Exception ex)
{
Logger.LogErrorMessage("[DownloadAndModifySiteTemplate: ProcessWspFile]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading Site Columns tag in content types", true);
ExceptionCsv.WriteException(objSiteCustOutput.WebApplication, objSiteCustOutput.SiteCollection, Constants.NotApplicable, "SiteTemplate", ex.Message, ex.ToString(),
"ProcessWspFile", ex.GetType().ToString(), "Exception while reading Site Columns tag in content types. SolutionName: " + solFileName + ", FileName: " + contentTypesXml);
}
}
}
}
catch (Exception ex)
{
Logger.LogErrorMessage("[DownloadAndModifySiteTemplate: ProcessWspFile]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading Site Columns tag in content types", true);
ExceptionCsv.WriteException(objSiteCustOutput.WebApplication, objSiteCustOutput.SiteCollection, Constants.NotApplicable, "SiteTemplate", ex.Message, ex.ToString(),
"ProcessWspFile", ex.GetType().ToString(), "Exception while reading Site Columns tag in content types. SolutionName: " + solFileName + ", FileName: " + contentTypesXml);
}
}
}
#endregion
reader.Dispose();
}
//Reading ElementContentTypes.xml for Searching Custom Fields
if (list.ElementAt(0).EndsWith(@"\"))
customFieldsTypesXml = list.ElementAt(0) + "ElementsFields.xml";
else
customFieldsTypesXml = list.ElementAt(0) + @"\" + "ElementsFields.xml";
if (!isCustomSiteColumn && System.IO.File.Exists(customFieldsTypesXml) && !isCustomSiteColumn)
{
Logger.LogInfoMessage("[DownloadAndModifySiteTemplate: ProcessWspFile] Searching for customized Site Columns in List in: " + customFieldsTypesXml, true);
var reader = new XmlTextReader(customFieldsTypesXml);
reader.Namespaces = false;
reader.Read();
XmlDocument doc3 = new XmlDocument();
doc3.Load(reader);
XmlNodeList xmlFields = doc3.SelectNodes("/Elements/Field");
#region Custom Fields
if (lstCustomFieldIDs != null && lstCustomFieldIDs.Count > 0)
{
for (int i = 0; i < xmlFields.Count; i++)
{
try
{
var fieldList = xmlFields[i].Attributes["ID"].Value;
//Remove contenttype tag if ContentTypeId present in custom ContentTypes file ContentTypes.csv
if (lstCustomFieldIDs.Where(c => fieldList.Equals(c)).Any())
{
isCustomSiteColumn = true;
Logger.LogInfoMessage("[DownloadAndModifySiteTemplate: ProcessWspFile] Customized Site Column Found for: " + objSiteCustOutput.SiteTemplateName, true);
示例14: CheckCustomEventReceiver
public static void CheckCustomEventReceiver(string xmlFilePath, string erNodePath, ref bool isCustomEventReceiver, string siteTemplateName)
{
string xml;
if (System.IO.File.Exists(xmlFilePath))
{
Logger.LogInfoMessage("[DownloadAndModifySiteTemplate: ProcessWspFile] Searching for customized Web/Site Event Receivers in: " + xmlFilePath, true);
var reader = new XmlTextReader(xmlFilePath);
try
{
using (TextReader txtreader = new StreamReader(xmlFilePath))
{
xml = txtreader.ReadToEnd();
}
xml = CommonUtility.SanitizeXmlString(xml);
reader.Namespaces = false;
reader.Read();
XmlDocument doc = new XmlDocument();
try
{
doc = CommonUtility.GetXmlDocumentFromString(xml);
}
catch (Exception ex)
{
Logger.LogErrorMessage("[DownloadAndModifySiteTemplate: CheckCustomEventReceiver]. Exception Message: " + ex.Message
+ ", Exception Comments: Exception while loading the XML File. XML File Path: " + xmlFilePath + ". SiteTemplateName: " + siteTemplateName, true);
ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "SiteTemplate", ex.Message, ex.ToString(), "CheckCustomEventReceiver",
ex.GetType().ToString(), "Exception while loading the XML File. XML File Path: " + xmlFilePath + ". SiteTemplateName: " + siteTemplateName);
}
//reader.Namespaces = false;
//reader.Read();
//XmlDocument doc = new XmlDocument();
//doc.Load(reader);
//Initiallizing all the nodes required to check
XmlNodeList receiverNodes = doc.SelectNodes(erNodePath);
//Chcecking for Custom Event Receivers
if (receiverNodes != null && receiverNodes.Count > 0)
{
for (int i = 0; i < receiverNodes.Count; i++)
{
XmlNodeList receiverChilds = receiverNodes[i].ChildNodes;
for (int j = 0; j < receiverChilds.Count; j++)
{
try
{
if (receiverChilds[j].HasChildNodes)
{
string assemblyValue = receiverChilds[j]["Assembly"].InnerText;
if (lstCustomErs.Where(c => assemblyValue.Equals(c, StringComparison.CurrentCultureIgnoreCase)).Any())
{
isCustomEventReceiver = true;
Logger.LogInfoMessage("[DownloadAndModifySiteTemplate: CheckCustomEventReceiver] Customized Web/Site/List Event Receiver Found for: " + siteTemplateName, true);
break;
}
}
}
catch (Exception ex)
{
Logger.LogErrorMessage("[DownloadAndModifySiteTemplate: CheckCustomEventReceiver]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading Web/Site Receivers tag", true);
ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "SiteTemplate", ex.Message, ex.ToString(),
"CheckCustomEventReceiver", ex.GetType().ToString(), "Exception while reading Web/Site Receivers tag");
}
}
}
}
}
catch (Exception ex)
{
Logger.LogErrorMessage("[DownloadAndModifySiteTemplate: CheckCustomEventReceiver]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading Features tag", true);
ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "SiteTemplate", ex.Message, ex.ToString(),
"CheckCustomEventReceiver", ex.GetType().ToString(), "Exception while reading Web/Site Receivers tag");
}
finally
{
reader.Dispose();
}
}
}
示例15: CheckCustomFeature
public static void CheckCustomFeature(string xmlFilePath, string featureNodePath, ref bool isCustomFeature, string siteTemplateName)
{
string featureID = string.Empty;
string xml;
if (System.IO.File.Exists(xmlFilePath))
{
var reader = new XmlTextReader(xmlFilePath);
try
{
using (TextReader txtreader = new StreamReader(xmlFilePath))
{
xml = txtreader.ReadToEnd();
}
xml = CommonUtility.SanitizeXmlString(xml);
reader.Namespaces = false;
reader.Read();
XmlDocument doc = new XmlDocument();
try
{
doc = CommonUtility.GetXmlDocumentFromString(xml);
}
catch (Exception ex)
{
Logger.LogErrorMessage("[DownloadAndModifySiteTemplate: CheckCustomFeature]. Exception Message: " + ex.Message
+ ", Exception Comments: Exception while loading the XML File. XML File Path: " + xmlFilePath + ". SiteTemplateName: " + siteTemplateName, true);
ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "SiteTemplate", ex.Message, ex.ToString(), "CheckCustomFeature",
ex.GetType().ToString(), "Exception while loading the XML File. XML File Path: " + xmlFilePath + ". SiteTemplateName: " + siteTemplateName);
}
//reader.Namespaces = false;
//reader.Read();
//XmlDocument doc = new XmlDocument();
////doc.Load(reader);
//Initiallizing all the nodes required to check
XmlNodeList siteFeatureNodes = doc.SelectNodes(featureNodePath);
for (int j = 0; j < siteFeatureNodes.Count; j++)
{
try
{
try
{
featureID = siteFeatureNodes[j].Attributes["ID"].Value;
}
catch { }
if (string.IsNullOrEmpty(featureID))
{
featureID = siteFeatureNodes[j].Attributes["Id"].Value;
}
if (featureID.StartsWith("{"))
{
featureID = featureID.TrimStart('{');
featureID = featureID.TrimEnd('}');
}
if (lstCustomFeatureIDs.Where(c => c.Contains(featureID.ToLower())).Any())
{
isCustomFeature = true;
Logger.LogInfoMessage("[DownloadAndModifySiteTemplate: CheckCustomFeature] Customized Feature Found for: " + siteTemplateName, true);
break;
}
}
catch (Exception ex)
{
Logger.LogErrorMessage("[DownloadAndModifySiteTemplate: CheckCustomFeature]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading Features tag", true);
ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "SiteTemplate", ex.Message, ex.ToString(),
"CheckCustomFeature", ex.GetType().ToString(), "Exception while reading Features tag");
}
}
}
catch (Exception ex)
{
Logger.LogErrorMessage("[DownloadAndModifySiteTemplate: CheckCustomFeature]. Exception Message: " + ex.Message + ", Exception Comments: Exception while reading Features tag", true);
ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "SiteTemplate", ex.Message, ex.ToString(),
"CheckCustomFeature", ex.GetType().ToString(), "Exception while reading Features tag");
}
finally
{
reader.Dispose();
}
}
}