本文整理汇总了C#中System.Xml.XmlNode.InsertAfter方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNode.InsertAfter方法的具体用法?C# XmlNode.InsertAfter怎么用?C# XmlNode.InsertAfter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlNode
的用法示例。
在下文中一共展示了XmlNode.InsertAfter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExcelPicture
internal ExcelPicture(ExcelDrawings drawings, XmlNode node, Image image)
: base(drawings, node, "xdr:pic/xdr:nvPicPr/xdr:cNvPr/@name")
{
XmlElement picNode = node.OwnerDocument.CreateElement("xdr", "pic", ExcelPackage.schemaSheetDrawings);
node.InsertAfter(picNode,node.SelectSingleNode("xdr:to",NameSpaceManager));
picNode.InnerXml = PicStartXml();
node.InsertAfter(node.OwnerDocument.CreateElement("xdr", "clientData", ExcelPackage.schemaSheetDrawings), picNode);
Package package = drawings.Worksheet.xlPackage.Package;
//Get the picture if it exists or save it if not.
_image = image;
string relID = SavePicture(image);
//Create relationship
node.SelectSingleNode("xdr:pic/xdr:blipFill/a:blip/@r:embed", NameSpaceManager).Value = relID;
SetPosDefaults(image);
package.Flush();
}
示例2: SortNodes
/// <summary>
/// Sorts the children of the parentNode that match the xpath selector
/// </summary>
/// <param name="parentNode"></param>
/// <param name="childXPathSelector">An xpath expression used to select child nodes of the XmlElement</param>
/// <param name="childSelector">An expression that returns true if the XElement passed in is a valid child node to be sorted</param>
/// <param name="orderByValue">The value to order the results by</param>
internal static void SortNodes(
XmlNode parentNode,
string childXPathSelector,
Func<XElement, bool> childSelector,
Func<XElement, object> orderByValue)
{
var xElement = parentNode.ToXElement();
var children = xElement.Elements().Where(x => childSelector(x)).ToArray(); //(DONT conver to method group, the build server doesn't like it)
var data = children
.OrderByDescending(orderByValue) //order by the sort order desc
.Select(x => children.IndexOf(x)) //store the current item's index (DONT conver to method group, the build server doesn't like it)
.ToList();
//get the minimum index that a content node exists in the parent
var minElementIndex = xElement.Elements()
.TakeWhile(x => childSelector(x) == false)
.Count();
//if the minimum index is zero, then it is the very first node inside the parent,
// if it is not, we need to store the child property node that exists just before the
// first content node found so we can insert elements after it when we're sorting.
var insertAfter = minElementIndex == 0 ? null : parentNode.ChildNodes[minElementIndex - 1];
var selectedChildren = parentNode.SelectNodes(childXPathSelector);
if (selectedChildren == null)
{
throw new InvalidOperationException(string.Format("The childXPathSelector value did not return any results {0}", childXPathSelector));
}
var childElements = selectedChildren.Cast<XmlElement>().ToArray();
//iterate over the ndoes starting with the node with the highest sort order.
//then we insert this node at the begginning of the parent so that by the end
//of the iteration the node with the least sort order will be at the top.
foreach (var node in data.Select(index => childElements[index]))
{
if (insertAfter == null)
{
parentNode.PrependChild(node);
}
else
{
parentNode.InsertAfter(node, insertAfter);
}
}
}
示例3: checkAndCalculateProtectedID
private void checkAndCalculateProtectedID(XmlDocument message, XmlNode invoice)
{
// field ProtectedID is mandatory, but if it is not suplied it is going to be calculated!
XmlNodeList protectedIDs = (invoice as XmlElement).GetElementsByTagName("fu:ProtectedID");
if (protectedIDs.Count == 0)
{
ProtectiveMark pm = new ProtectiveMark();
string protectedIDValue = pm.Calculate(invoice as XmlElement, Settings.CryptoProvider);
// ProtectedID is not the last element in XML Schema, so we must put it in the right spot
// we are going from bottom up, searching for the right spot
XmlNode protectedIDNode = XmlHelperFunctions.CreateElement(message, this.Settings.FursXmlNamespace, "ProtectedID", protectedIDValue);
XmlNode currentNode = invoice.LastChild;
while ((currentNode != null) && (this.isNodeAfterProtectedID(currentNode)))
currentNode = currentNode.PreviousSibling;
if (currentNode != null)
invoice.InsertAfter(protectedIDNode, currentNode);
}
}
示例4: ToVersion32
/// <summary>
/// Make sure soil nodes have a ASC_Order and ASC_Sub-order nodes.
/// </summary>
private static void ToVersion32(XmlNode Node)
{
if (Node.Name.ToLower() == "soil")
{
if (XmlUtilities.FindByType(Node, "ASC_Order") == null)
{
XmlNode NewNode = XmlUtilities.EnsureNodeExists(Node, "ASC_Order");
XmlUtilities.SetAttribute(NewNode, "description", "Australian Soil Classification Order");
NewNode.ParentNode.InsertBefore(NewNode, NewNode.FirstChild);
}
if (XmlUtilities.FindByType(Node, "ASC_Sub-order") == null)
{
XmlNode NewNode = XmlUtilities.EnsureNodeExists(Node, "ASC_Sub-order");
XmlUtilities.SetAttribute(NewNode, "description", "Australian Soil Classification Sub-Order");
Node.InsertAfter(NewNode, XmlUtilities.FindByType(Node, "ASC_Order"));
}
XmlNode SoilType = XmlUtilities.EnsureNodeExists(Node, "SoilType");
XmlUtilities.SetAttribute(SoilType, "description", "Soil description");
Node.InsertAfter(SoilType, XmlUtilities.FindByType(Node, "ASC_Sub-order"));
Node.InsertAfter(XmlUtilities.EnsureNodeExists(Node, "LocalName"), XmlUtilities.FindByType(Node, "SoilType"));
Node.InsertAfter(XmlUtilities.EnsureNodeExists(Node, "Site"), XmlUtilities.FindByType(Node, "LocalName"));
Node.InsertAfter(XmlUtilities.EnsureNodeExists(Node, "NearestTown"), XmlUtilities.FindByType(Node, "Site"));
Node.InsertAfter(XmlUtilities.EnsureNodeExists(Node, "Region"), XmlUtilities.FindByType(Node, "NearestTown"));
Node.InsertAfter(XmlUtilities.EnsureNodeExists(Node, "State"), XmlUtilities.FindByType(Node, "Region"));
Node.InsertAfter(XmlUtilities.EnsureNodeExists(Node, "Country"), XmlUtilities.FindByType(Node, "State"));
Node.InsertAfter(XmlUtilities.EnsureNodeExists(Node, "NaturalVegetation"), XmlUtilities.FindByType(Node, "Country"));
Node.InsertAfter(XmlUtilities.EnsureNodeExists(Node, "ApsoilNumber"), XmlUtilities.FindByType(Node, "NaturalVegetation"));
Node.InsertAfter(XmlUtilities.EnsureNodeExists(Node, "Latitude"), XmlUtilities.FindByType(Node, "ApsoilNumber"));
Node.InsertAfter(XmlUtilities.EnsureNodeExists(Node, "Longitude"), XmlUtilities.FindByType(Node, "Latitude"));
Node.InsertAfter(XmlUtilities.EnsureNodeExists(Node, "LocationAccuracy"), XmlUtilities.FindByType(Node, "Longitude"));
Node.InsertAfter(XmlUtilities.EnsureNodeExists(Node, "DataSource"), XmlUtilities.FindByType(Node, "LocationAccuracy"));
Node.InsertAfter(XmlUtilities.EnsureNodeExists(Node, "Comments"), XmlUtilities.FindByType(Node, "DataSource"));
}
}
示例5: InsertClickOnceDependency
private static void InsertClickOnceDependency(EnvConfig envConfig, XmlNode dependencyList, XmlNode lastPrerequisite, string file, XmlNamespaceManager nsmgr)
{
var deployTarget = Path.Combine(GetClickOnceOutputPath(envConfig), file);
var doc = dependencyList.OwnerDocument;
// avoid the pseudo/testing resource assemblies, as clickonce client dies on unknown cultures
if (file.ToLowerInvariant().EndsWith(".resources.dll") || file.ToLowerInvariant().EndsWith(".resources.dll.deploy") || file.ToLowerInvariant().EndsWith(".resources.exe") || file.ToLowerInvariant().EndsWith(".resources.exe.deploy"))
{
if (file.ToLowerInvariant().Contains("x-zb-"))
{
Program.LogDetail("Skipping pseudo culture file: [{0}]", file);
return;
}
}
if (file.EndsWith(".dll") || file.EndsWith(".dll.deploy") || file.EndsWith(".exe") || file.EndsWith(".exe.deploy"))
{
// TODO: do not deploy fallback to client and remove this.
if (file.Contains("Fallback")) return;
var dependency = doc.CreateNode(XmlNodeType.Element, "dependency", ASMv2_NS);
var dependentAssembly = doc.CreateNode(XmlNodeType.Element, "dependentAssembly", ASMv2_NS);
SetOrReplaceAttribute(dependentAssembly, "dependencyType", null, "install");
SetOrReplaceAttribute(dependentAssembly, "allowDelayedBinding", null, "true");
SetOrReplaceAttribute(dependentAssembly, "codebase", null, file.Replace('/', '\\'));
SetOrReplaceAttribute(dependentAssembly, "size", null, string.Format(CultureInfo.InvariantCulture, "{0}", new FileInfo(file).Length));
var assemblyIdentity = doc.CreateNode(XmlNodeType.Element, "assemblyIdentity", ASMv2_NS);
FillClickOnceAssemblyId(System.Reflection.Assembly.ReflectionOnlyLoadFrom(file), assemblyIdentity);
dependentAssembly.AppendChild(assemblyIdentity);
var hash = CreateHashNode(file, nsmgr, doc);
dependentAssembly.AppendChild(hash);
dependency.AppendChild(dependentAssembly);
dependencyList.InsertAfter(dependency, lastPrerequisite);
deployTarget += ".deploy";
}
else if (file.EndsWith(".manifest"))
{
var dependency = doc.CreateNode(XmlNodeType.Element, "dependency", ASMv2_NS);
var dependentAssembly = doc.CreateNode(XmlNodeType.Element, "dependentAssembly", ASMv2_NS);
SetOrReplaceAttribute(dependentAssembly, "dependencyType", null, "install");
SetOrReplaceAttribute(dependentAssembly, "codebase", null, file.Replace('/', '\\'));
SetOrReplaceAttribute(dependentAssembly, "size", null, string.Format(CultureInfo.InvariantCulture, "{0}", new FileInfo(file).Length));
var manifest = new XmlDocument();
manifest.Load(file);
var manifestNsmgr = CreateDefaultXmlNsmgr(manifest);
var srcAssemblyId = manifest.SelectSingleNode("/asmv1:assembly/asmv1:assemblyIdentity", manifestNsmgr);
var assemblyIdentity = doc.CreateNode(XmlNodeType.Element, "assemblyIdentity", ASMv2_NS);
foreach (var attrName in new[] { "name", "version", "language", "processorArchitecture", "publicKeyToken", "type" })
{
SetOrReplaceAttribute(assemblyIdentity, attrName, null, srcAssemblyId.Attributes[attrName].Value);
}
dependentAssembly.AppendChild(assemblyIdentity);
var hash = CreateHashNode(file, nsmgr, doc);
dependentAssembly.AppendChild(hash);
dependency.AppendChild(dependentAssembly);
dependencyList.InsertAfter(dependency, lastPrerequisite);
}
else
{
var fileNode = doc.CreateNode(XmlNodeType.Element, "file", ASMv2_NS);
SetOrReplaceAttribute(fileNode, "name", null, file.Replace('/', '\\'));
SetOrReplaceAttribute(fileNode, "size", null, string.Format(CultureInfo.InvariantCulture, "{0}", new FileInfo(file).Length));
var hash = doc.CreateNode(XmlNodeType.Element, "hash", ASMv2_NS);
var transforms = doc.CreateNode(XmlNodeType.Element, "Transforms", XMLDSIG_NS);
var transform = doc.CreateNode(XmlNodeType.Element, "Transform", XMLDSIG_NS);
SetOrReplaceAttribute(transform, "Algorithm", null, XMLDSIG_IDENTITY);
transforms.AppendChild(transform);
hash.AppendChild(transforms);
var digestMethod = doc.CreateNode(XmlNodeType.Element, "DigestMethod", XMLDSIG_NS);
hash.AppendChild(digestMethod);
var digestValue = doc.CreateNode(XmlNodeType.Element, "DigestValue", XMLDSIG_NS);
hash.AppendChild(digestValue);
UpdateSha1(hash, file, nsmgr);
fileNode.AppendChild(hash);
dependencyList.InsertAfter(fileNode, lastPrerequisite);
deployTarget += ".deploy";
}
Directory.CreateDirectory(Path.GetDirectoryName(deployTarget));
File.Copy(file, deployTarget, true);
}
示例6: Apply
// Methods
internal override void Apply( XmlNode parent, ref XmlNode currentPosition )
{
XmlDocument doc = parent.OwnerDocument;
IEnumerator enumerator = _nodes.GetEnumerator();
while ( enumerator.MoveNext() )
{
XmlNode newNode = doc.ImportNode( (XmlNode)enumerator.Current, true );
parent.InsertAfter( newNode, currentPosition );
currentPosition = newNode;
}
}
示例7: ExcelPicture
internal ExcelPicture(ExcelDrawings drawings, XmlNode node, FileInfo imageFile, Uri hyperlink)
: base(drawings, node, "xdr:pic/xdr:nvPicPr/xdr:cNvPr/@name")
{
XmlElement picNode = node.OwnerDocument.CreateElement("xdr", "pic", ExcelPackage.schemaSheetDrawings);
node.InsertAfter(picNode, node.SelectSingleNode("xdr:to", NameSpaceManager));
_hyperlink = hyperlink;
picNode.InnerXml = PicStartXml();
node.InsertAfter(node.OwnerDocument.CreateElement("xdr", "clientData", ExcelPackage.schemaSheetDrawings), picNode);
//Changed to stream 2/4-13 (issue 14834). Thnx SClause
var package = drawings.Worksheet._package.Package;
ContentType = GetContentType(imageFile.Extension);
var imagestream = new FileStream(imageFile.FullName, FileMode.Open, FileAccess.Read);
_image = Image.FromStream(imagestream);
ImageConverter ic = new ImageConverter();
var img = (byte[])ic.ConvertTo(_image, typeof(byte[]));
imagestream.Close();
UriPic = GetNewUri(package, "/xl/media/{0}" + imageFile.Name);
var ii = _drawings._package.AddImage(img, UriPic, ContentType);
string relID;
if(!drawings._hashes.ContainsKey(ii.Hash))
{
Part = ii.Part;
RelPic = drawings.Part.CreateRelationship(UriHelper.GetRelativeUri(drawings.UriDrawing, ii.Uri), Packaging.TargetMode.Internal, ExcelPackage.schemaRelationships + "/image");
relID = RelPic.Id;
_drawings._hashes.Add(ii.Hash, relID);
AddNewPicture(img, relID);
}
else
{
relID = drawings._hashes[ii.Hash];
var rel = _drawings.Part.GetRelationship(relID);
UriPic = UriHelper.ResolvePartUri(rel.SourceUri, rel.TargetUri);
}
ImageHash = ii.Hash;
_height = Image.Height;
_width = Image.Width;
SetPosDefaults(Image);
//Create relationship
node.SelectSingleNode("xdr:pic/xdr:blipFill/a:blip/@r:embed", NameSpaceManager).Value = relID;
package.Flush();
}
示例8: MergeComponent
//.........这里部分代码省略.........
{
replaceId = position.TypeName;
matchingNodes = rootNode.SelectNodes("component[@type='" + replaceId + "']");
}
// If replacing another component, search for that by ID or
// type and replace it if found.
if(position.Place == ComponentPosition.Placement.Replace)
{
if(matchingNodes.Count < position.AdjustedInstance)
{
this.ReportProgress(" Could not find configuration '{0}' (instance {1}) to replace with " +
"configuration for '{2}' so it will be omitted.", replaceId, position.AdjustedInstance, id);
// If it's a dependency, that's a problem
if(mergeStack.Count != 0)
throw new BuilderException("BE0024", "Unable to add dependent configuration: " + id);
return;
}
rootNode.ReplaceChild(configNode, matchingNodes[position.AdjustedInstance - 1]);
this.ReportProgress(" Replaced configuration for '{0}' (instance {1}) with configuration " +
"for '{2}'", replaceId, position.AdjustedInstance, id);
// Adjust instance values on matching components
foreach(BuildComponentInfo component in BuildComponentManager.BuildComponents.Values)
if(!isConceptualConfig)
{
if(((!String.IsNullOrEmpty(component.ReferenceBuildPosition.Id) &&
component.ReferenceBuildPosition.Id == replaceId) ||
(String.IsNullOrEmpty(component.ReferenceBuildPosition.Id) &&
component.ReferenceBuildPosition.TypeName == replaceId)) &&
component.ReferenceBuildPosition.AdjustedInstance >
position.AdjustedInstance)
component.ReferenceBuildPosition.AdjustedInstance--;
}
else
if(((!String.IsNullOrEmpty(component.ConceptualBuildPosition.Id) &&
component.ConceptualBuildPosition.Id == replaceId) ||
(String.IsNullOrEmpty(component.ConceptualBuildPosition.Id) &&
component.ConceptualBuildPosition.TypeName == replaceId)) &&
component.ConceptualBuildPosition.AdjustedInstance >
position.AdjustedInstance)
component.ConceptualBuildPosition.AdjustedInstance--;
return;
}
// See if the configuration already exists. If so, replace it.
// We'll assume it's already in the correct location.
node = rootNode.SelectSingleNode("component[@id='" + id + "']");
if(node != null)
{
this.ReportProgress(" Replacing default configuration for '{0}' with the custom configuration", id);
rootNode.ReplaceChild(configNode, node);
return;
}
// Create the node and add it in the correct location
switch(position.Place)
{
case ComponentPosition.Placement.Start:
rootNode.InsertBefore(configNode, rootNode.ChildNodes[0]);
this.ReportProgress(" Added configuration for '{0}' to the start of the configuration file", id);
break;
case ComponentPosition.Placement.End:
rootNode.InsertAfter(configNode,
rootNode.ChildNodes[rootNode.ChildNodes.Count - 1]);
this.ReportProgress(" Added configuration for '{0}' to the end of the configuration file", id);
break;
case ComponentPosition.Placement.Before:
if(matchingNodes.Count < position.AdjustedInstance)
this.ReportProgress(" Could not find configuration '{0}' (instance {1}) to add " +
"configuration for '{2}' so it will be omitted.", replaceId, position.AdjustedInstance, id);
else
{
rootNode.InsertBefore(configNode, matchingNodes[position.AdjustedInstance - 1]);
this.ReportProgress(" Added configuration for '{0}' before '{1}' (instance {2})",
id, replaceId, position.AdjustedInstance);
}
break;
default: // After
if(matchingNodes.Count < position.AdjustedInstance)
this.ReportProgress(" Could not find configuration '{0}' (instance {1}) to add " +
"configuration for '{2}' so it will be omitted.", replaceId, position.AdjustedInstance, id);
else
{
rootNode.InsertAfter(configNode, matchingNodes[position.AdjustedInstance - 1]);
this.ReportProgress(" Added configuration for '{0}' after '{1}' (instance {2})",
id, replaceId, position.AdjustedInstance);
}
break;
}
}
示例9: DeleteProject
//.........这里部分代码省略.........
if (bWarning == true)
{
string strText = "系统发现,源代码文件 "
+ strCodeFileName
+ " 除了被您即将删除的方案 "+
strProjectNamePath
+" 使用外,还被下列方案引用:\r\n---\r\n";
for(int i=0;i<aFound.Count;i++)
{
strText += GetNodePathName((XmlNode)aFound[i]) + "\r\n";
}
strText += "---\r\n\r\n这意味着,如果删除这个源代码文件,上述方案将不能正常运行。\r\n\r\n请问,在删除方案" +strProjectNamePath+ "时,是否保留源代码文件 " + strCodeFileName + "?";
DialogResult msgResult = MessageBox.Show(//this,
strText,
"script",
MessageBoxButtons.YesNoCancel,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1);
if (msgResult == DialogResult.Yes)
bDeleteCodeFile = false;
if (msgResult == DialogResult.Cancel)
return 2; // cancel
}
else
{
bDeleteCodeFile = false; // 自动采用最保险的方式
}
}
}
// 从Dom上删除节点
parentXmlNode = nodeThis.ParentNode;
parentXmlNode.RemoveChild(nodeThis);
if (bDeleteCodeFile == true
&& strCodeFileName != "")
File.Delete(strCodeFileName);
m_bChanged = true;
return 1;
}
*/
// 上下移动节点
// return:
// 0 not found
// 1 found and moved
// 2 cant move
public int MoveNode(string strNodeNamePath,
bool bUp,
out XmlNode parentXmlNode)
{
parentXmlNode = null;
XmlNode nodeThis = LocateAnyNode(strNodeNamePath);
if (nodeThis == null)
return 0;
XmlNode nodeInsert = null;
if (bUp == true)
{
nodeInsert = nodeThis.PreviousSibling;
if (nodeInsert == null)
return 2;
}
else
{
nodeInsert = nodeThis.NextSibling;
if (nodeInsert == null)
return 2;
}
// 从Dom上删除节点
parentXmlNode = nodeThis.ParentNode;
parentXmlNode.RemoveChild(nodeThis);
// 插入到特定位置
if (bUp == true)
{
parentXmlNode.InsertBefore(nodeThis, nodeInsert);
}
else
{
parentXmlNode.InsertAfter(nodeThis, nodeInsert);
}
m_bChanged = true;
return 1;
}
示例10: InsertNodeUsingDefinedOrder
public static void InsertNodeUsingDefinedOrder(XmlNode parent, XmlNode newChild, IComparer<XmlNode> nodeOrderComparer)
{
if (newChild.NodeType == XmlNodeType.Attribute)
{
XmlAttribute insertAfterNode = null;
foreach (XmlAttribute childNode in parent.Attributes)
{
if (nodeOrderComparer.Compare(newChild, childNode) < 0)
{
break;
}
insertAfterNode = childNode;
}
parent.Attributes.InsertAfter((XmlAttribute)newChild, insertAfterNode);
}
else
{
XmlNode insertAfterNode = null;
foreach (XmlNode childNode in parent.ChildNodes)
{
if (nodeOrderComparer.Compare(newChild, childNode) < 0)
{
break;
}
insertAfterNode = childNode;
}
parent.InsertAfter(newChild, insertAfterNode);
}
}
示例11: XmlDocument
public void añadir(List<Premios> premios)
{
documento = new XmlDocument();
if (File.Exists(this.nombreFichero))
{
documento.Load(this.nombreFichero);
raiz = documento.DocumentElement;
XmlNodeList tmp = documento.GetElementsByTagName("Resultados");
if (tmp.Count < 1)
{
raiz.InsertAfter(crearNodo(premios),documento.GetElementsByTagName("Recaudacion")[0]);
documento.Save(this.nombreFichero);
}
}
}
示例12: SetField
private static void SetField(
XmlNode parentNode, ref XmlNode previousSibling,
string tagName, string tagValue, string nspace)
{
// obtain a pointer to the XmlDocument object. This is used
// in a few places in this method.
XmlDocument doc = parentNode.OwnerDocument;
// create an XmlText object to hold the field's value.
XmlText text = doc.CreateTextNode(tagValue);
// look for the field.
XmlNode node = GetNode(doc, tagName, nspace);
// if the field does not exist,...
if (node == null)
{
// create an element for it and inside this element,
// insert the XmlText object we created earlier.
node = doc.CreateElement(tagName, nspace);
node.AppendChild(text);
// if there is a previous sibling, insert the new node
// after it.
if (previousSibling != null)
{
parentNode.InsertAfter(node, previousSibling);
}
// else, the new node becomes the first child.
else
{
parentNode.PrependChild(node);
}
}
// else, if the field already exists, replace its value.
else
{
// if the field does have a value, replace it with
// the XmlText object we created earlier.
if (node.HasChildNodes)
{
node.ReplaceChild(text, node.ChildNodes[0]);
}
// else, if it's empty, append the XmlText object
// we created earlier.
else
{
node.AppendChild(text);
}
}
// the next node to be added will be after this node. So, we
// set previousSibling to this node.
previousSibling = node;
}
示例13: SetStains
private XmlNode SetStains(XmlNode tableNodeSS,
XmlNode rowStainHeaderNode,
XmlNode rowTestHeaderNode,
XmlNode insertAfterRowSS,
XmlNode rowSpecialStainNode,
SurgicalSpecimen surgicalSpecimen,
YellowstonePathology.Business.SpecialStain.StainResultItemCollection stainResultCollection)
{
XmlNode rowStainHeaderNodeClone = rowStainHeaderNode.Clone();
tableNodeSS.InsertAfter(rowStainHeaderNodeClone, insertAfterRowSS);
insertAfterRowSS = rowStainHeaderNodeClone;
XmlNode rowTestHeaderNodeClone = rowTestHeaderNode.Clone();
tableNodeSS.InsertAfter(rowTestHeaderNodeClone, insertAfterRowSS);
insertAfterRowSS = rowTestHeaderNodeClone;
foreach (YellowstonePathology.Business.SpecialStain.StainResultItem stainResultItem in stainResultCollection)
{
XmlNode rowSpecialStainClone = rowSpecialStainNode.Clone();
string stainDescription = stainResultItem.ProcedureName;
string stainResult = stainResultItem.Result;
if (string.IsNullOrEmpty(stainResult) == true)
{
stainResult = "Pending";
}
else if (stainResult.ToUpper() == "SEE COMMENT")
{
stainResult = stainResultItem.ReportComment;
}
else
{
string specialStainReportComment = stainResultItem.ReportComment;
if (!string.IsNullOrEmpty(specialStainReportComment))
{
stainResult += " - " + specialStainReportComment;
}
}
rowSpecialStainClone.SelectSingleNode("descendant::w:r[w:t='stain_description']/w:t", this.m_NameSpaceManager).InnerText = stainDescription;
rowSpecialStainClone.SelectSingleNode("descendant::w:r[w:t='stain_result']/w:t", this.m_NameSpaceManager).InnerText = stainResult;
string block = surgicalSpecimen.GetBlockFromTestOrderId(stainResultItem.TestOrderId);
rowSpecialStainClone.SelectSingleNode("descendant::w:r[w:t='block_description']/w:t", this.m_NameSpaceManager).InnerText = block;
tableNodeSS.InsertAfter(rowSpecialStainClone, insertAfterRowSS);
insertAfterRowSS = rowSpecialStainClone;
}
return insertAfterRowSS;
}
示例14: MergeComponent
//.........这里部分代码省略.........
mergeStack.Pop();
}
}
position = (!isConceptualConfig) ? factory.ReferenceBuildPlacement : factory.ConceptualBuildPlacement;
// Find all matching components by ID
replaceId = position.Id;
matchingNodes = rootNode.SelectNodes("component[@id='" + replaceId + "']");
// If replacing another component, search for that by ID and replace it if found
if(position.Placement == PlacementAction.Replace)
{
if(matchingNodes.Count < position.AdjustedInstance)
{
this.ReportProgress(" Could not find configuration '{0}' (instance {1}) to replace with " +
"configuration for '{2}' so it will be omitted.", replaceId, position.AdjustedInstance, id);
// If it's a dependency, that's a problem
if(mergeStack.Count != 0)
throw new BuilderException("BE0024", "Unable to add dependent configuration: " + id);
return;
}
rootNode.ReplaceChild(configNode, matchingNodes[position.AdjustedInstance - 1]);
this.ReportProgress(" Replaced configuration for '{0}' (instance {1}) with configuration " +
"for '{2}'", replaceId, position.AdjustedInstance, id);
// Adjust instance values on matching components
foreach(var component in buildComponents.Values)
if(!isConceptualConfig)
{
if(component.ReferenceBuildPlacement.Id == replaceId &&
component.ReferenceBuildPlacement.AdjustedInstance > position.AdjustedInstance)
{
component.ReferenceBuildPlacement.AdjustedInstance--;
}
}
else
if(component.ConceptualBuildPlacement.Id == replaceId &&
component.ConceptualBuildPlacement.AdjustedInstance > position.AdjustedInstance)
{
component.ConceptualBuildPlacement.AdjustedInstance--;
}
return;
}
// See if the configuration already exists. If so, replace it.
// We'll assume it's already in the correct location.
node = rootNode.SelectSingleNode("component[@id='" + id + "']");
if(node != null)
{
this.ReportProgress(" Replacing default configuration for '{0}' with the custom configuration", id);
rootNode.ReplaceChild(configNode, node);
return;
}
// Create the node and add it in the correct location
switch(position.Placement)
{
case PlacementAction.Start:
rootNode.InsertBefore(configNode, rootNode.ChildNodes[0]);
this.ReportProgress(" Added configuration for '{0}' to the start of the configuration file", id);
break;
case PlacementAction.End:
rootNode.InsertAfter(configNode,
rootNode.ChildNodes[rootNode.ChildNodes.Count - 1]);
this.ReportProgress(" Added configuration for '{0}' to the end of the configuration file", id);
break;
case PlacementAction.Before:
if(matchingNodes.Count < position.AdjustedInstance)
this.ReportProgress(" Could not find configuration '{0}' (instance {1}) to add " +
"configuration for '{2}' so it will be omitted.", replaceId, position.AdjustedInstance, id);
else
{
rootNode.InsertBefore(configNode, matchingNodes[position.AdjustedInstance - 1]);
this.ReportProgress(" Added configuration for '{0}' before '{1}' (instance {2})",
id, replaceId, position.AdjustedInstance);
}
break;
default: // After
if(matchingNodes.Count < position.AdjustedInstance)
this.ReportProgress(" Could not find configuration '{0}' (instance {1}) to add " +
"configuration for '{2}' so it will be omitted.", replaceId, position.AdjustedInstance, id);
else
{
rootNode.InsertAfter(configNode, matchingNodes[position.AdjustedInstance - 1]);
this.ReportProgress(" Added configuration for '{0}' after '{1}' (instance {2})",
id, replaceId, position.AdjustedInstance);
}
break;
}
}
示例15: ExcelPicture
internal ExcelPicture(ExcelDrawings drawings, XmlNode node, FileInfo imageFile, Uri hyperlink) :
base(drawings, node, "xdr:pic/xdr:nvPicPr/xdr:cNvPr/@name")
{
XmlElement picNode = node.OwnerDocument.CreateElement("xdr", "pic", ExcelPackage.schemaSheetDrawings);
node.InsertAfter(picNode, node.SelectSingleNode("xdr:to", NameSpaceManager));
_hyperlink = hyperlink;
picNode.InnerXml = PicStartXml();
node.InsertAfter(node.OwnerDocument.CreateElement("xdr", "clientData", ExcelPackage.schemaSheetDrawings), picNode);
Package package = drawings.Worksheet._package.Package;
ContentType = GetContentType(imageFile.Extension);
_image = Image.FromFile(imageFile.FullName);
ImageConverter ic = new ImageConverter();
byte[] img = (byte[])ic.ConvertTo(_image, typeof(byte[]));
UriPic = GetNewUri(package, "/xl/media/{0}" + imageFile.Name);
var ii = _drawings._package.AddImage(img, UriPic, ContentType);
//string relID = GetPictureRelID(img);
//if (relID == "")
string relID;
if(!drawings._hashes.ContainsKey(ii.Hash))
{
//UriPic = GetNewUri(package, "/xl/media/image{0}" + imageFile.Extension);
//Part = package.CreatePart(UriPic, ContentType, CompressionOption.NotCompressed);
////Save the picture to package.
//byte[] file = File.ReadAllBytes(imageFile.FullName);
//var strm = Part.GetStream(FileMode.Create, FileAccess.Write);
//strm.Write(file, 0, file.Length);
Part = ii.Part;
RelPic = drawings.Part.CreateRelationship(PackUriHelper.GetRelativeUri(drawings.UriDrawing, ii.Uri), TargetMode.Internal, ExcelPackage.schemaRelationships + "/image");
relID = RelPic.Id;
_drawings._hashes.Add(ii.Hash, relID);
AddNewPicture(img, relID);
}
else
{
relID = drawings._hashes[ii.Hash];
var rel = _drawings.Part.GetRelationship(relID);
UriPic = PackUriHelper.ResolvePartUri(rel.SourceUri, rel.TargetUri);
}
SetPosDefaults(Image);
//Create relationship
node.SelectSingleNode("xdr:pic/xdr:blipFill/a:blip/@r:embed", NameSpaceManager).Value = relID;
package.Flush();
}