Example #1
0
        private void ExportWorkerHours()
        {
            try
            {
                XmlDocument xmlDocument = (XmlDocument)exportHoursDocumentBase.Clone();

                MongoCursor <BsonDocument> cursor = GetUnexportedWorkerHours();

                if (cursor.Count() > 0)
                {
                    logger.LogInfo("Exporting found unexported timesheet entries", cursor.Count());
                    StartBatch(xmlDocument, "EfiAifBuffProjJournalTable");
                }
                else
                {
                    logger.LogFineTrace("No unexported timesheet entries found.");
                    return;
                }

                List <TimesheetEntryFragment> timesheetEntryFragments = IntegrationHelpers.GetTimesheetFragments(cursor, MinTimeFragmentSize, database, logger, failedExports, succeededExports);

                IntegrationHelpers.RemoveUnexportedFragmentTypes(timesheetEntryFragments, logger);

                logger.LogInfo(cursor.Count() + " timesheet entries produced " + timesheetEntryFragments.Count + " fragments.");

                int exportedFragments = ExportTimesheetFragmentsToXml(timesheetEntryFragments, xmlDocument);
                if (exportedFragments > 0)
                {
                    logger.LogInfo("Saving exported fragments to disk.", exportedFragments);
                    WriteExportedDataToDisk(xmlDocument, FilePrefixHourData);

                    WorkerTimesheetEntryFragmentsExported += exportedFragments;
                    WorkerTimesheetEntryFilesCreated++;
                }
                else
                {
                    logger.LogInfo("No valid timesheet entry fragments found to export. Not saving XML document.");
                }

                MarkEntriesAsExported(cursor, "timesheetentry");
            }
            catch (Exception ex)
            {
                logger.LogError("Exporting hours failed.", ex);
                WorkerTimesheetEntryExportsFailed++;
            }
            finally
            {
                EndBatch();
            }
        }
        public void Process(XmlNode n)
        {
            // First, Get Prompt and Declaration
            var _prompt      = n["Prompt"].InnerText;
            var _declaration = n["Declaration"] != null ? n["Declaration"].InnerText : "";

            this.Id           = -999;
            this.PropertyType = "BoolPropertyGroup";
            this.Prompt       = _prompt;
            this.Declaration  = _declaration;



            XmlDocument xdoc = new XmlDocument();

            xdoc.LoadXml(n.OuterXml);
            XmlNode newNode = xdoc.Clone();



            XmlNodeList boolProperties = newNode.SelectNodes("/BoolPropertyGroup/BoolProperty");

            Utilities.WriteToOutput(this.ToString());
            foreach (XmlNode bp in boolProperties)
            {
                BoolProperty prop = new BoolProperty();
                prop.Process(bp);
                Utilities.WriteToOutput(Utilities.tab1 + prop.ToString(), @Program._OUTPUTFILEPATH);

                BoolProperties.Add(prop);
            }
        }
Example #3
0
        public static void GetURL_lst(List <URL_list> URL_List_)
        {
            XmlDocument       xmlDoc   = new XmlDocument();
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.IgnoreComments = true;//忽略文档里面的注释
            XmlReader reader = XmlReader.Create(@"..\..\XMLFile1.xml", settings);

            xmlDoc.Load(reader);
            reader.Close();
            // 得到根节点bookstore
            XmlNode xn = xmlDoc.SelectSingleNode("bookstore");
            // 得到根节点的所有子节点
            XmlNodeList xnl = xn.ChildNodes;

            foreach (XmlNode xn1 in xnl)
            {
                #region MyRegion
                URL_list uls = new URL_list();
                // 将节点转换为元素,便于得到节点的属性值
                XmlElement xe = (XmlElement)xn1;
                // 得到Type和ISBN两个属性的属性值
                uls.ID   = xe.GetAttribute("ID").ToString();
                uls.Name = xe.GetAttribute("Type").ToString();
                // 得到Book节点的所有子节点
                XmlNodeList xnl0 = xe.ChildNodes;
                uls.Href = xnl0.Item(0).InnerText;
                URL_List_.Add(uls);
                #endregion
            }


            xmlDoc.Clone();
        }
        public static XmlDocument RemoveEmptyDirectories(XmlDocument xDoc)
        {
            XmlDocument xDoc1 = (XmlDocument)xDoc.Clone();

            CleanDocument(xDoc1.DocumentElement, false, true);
            return(xDoc1);
        }
Example #5
0
        public static void SplitItem(List <XmlNode> nodeList, string xmlString)
        {
            if (nodeList == null)
            {
                return;
            }

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(xmlString);

            XmlNodeList itemNodeList = xmlDoc.SelectNodes(ITEM);

            if (itemNodeList == null || itemNodeList.Count < 2)
            {
                nodeList.Add(xmlDoc);
            }
            else
            {
                for (int i = 0; i < itemNodeList.Count; i++)
                {
                    XmlNode newDoc     = xmlDoc.Clone();
                    XmlNode newXimNode = newDoc.SelectSingleNode(XIM);
                    for (int j = 0; j < newXimNode.ChildNodes.Count; j++)
                    {
                        if (i == j)
                        {
                            continue;
                        }
                        newXimNode.RemoveChild(newXimNode.ChildNodes[j]);
                    }
                    nodeList.Add(newDoc);
                }
            }
        }
Example #6
0
        private void SetContentEveloping(SignatureDocument sigDocument, XmlDocument xmlDocument)
        {
            _refContent = new Reference();
            sigDocument.XadesSignature = new XadesSignedXml();
            XmlDocument xmlDocument2 = (XmlDocument)xmlDocument.Clone();

            xmlDocument2.PreserveWhitespace = true;
            if (xmlDocument2.ChildNodes[0].NodeType == XmlNodeType.XmlDeclaration)
            {
                xmlDocument2.RemoveChild(xmlDocument2.ChildNodes[0]);
            }
            Guid       guid       = Guid.NewGuid();
            string     text       = "DataObject-" + guid.ToString();
            DataObject dataObject = new DataObject();

            dataObject.Data = xmlDocument2.ChildNodes;
            dataObject.Id   = text;
            sigDocument.XadesSignature.AddObject(dataObject);
            Reference refContent = _refContent;

            guid             = Guid.NewGuid();
            refContent.Id    = "Reference-" + guid.ToString();
            _refContent.Uri  = "#" + text;
            _refContent.Type = "http://www.w3.org/2000/09/xmldsig#Object";
            XmlDsigC14NTransform transform = new XmlDsigC14NTransform();

            _refContent.AddTransform(transform);
            _mimeType = "text/xml";
            _encoding = "UTF-8";
            sigDocument.XadesSignature.AddReference(_refContent);
        }
Example #7
0
        /// <summary>
        /// Inserta un contenido XML para generar una firma enveloped.
        /// </summary>
        /// <param name="xmlDocument"></param>
        public void SetContentEnveloped(XmlDocument xmlDocument)
        {
            _document = (XmlDocument)xmlDocument.Clone();
            _document.PreserveWhitespace = true;

            CreateEnvelopedDocument();
        }
Example #8
0
        // Copy the provided document to the internal DOM representation
        private void CopyIn(XmlDocument Doc)
        {
            XmlDocument TmpDoc = new XmlDocument();

            TmpDoc.AppendChild(Doc.Clone());
            m_Doc = TmpDoc;
        }
Example #9
0
        /// <summary>
        /// Carga el documento XML especificado y establece para firmar el elemento especificado en elementId
        /// </summary>
        /// <param name="xmlDocument"></param>
        /// <param name="elementId"></param>
        /// <param name="mimeType"></param>
        public void SetContentInternallyDetached(XmlDocument xmlDocument, string elementId, string mimeType)
        {
            _document = (XmlDocument)xmlDocument.Clone();
            _document.PreserveWhitespace = true;

            Reference reference = new Reference();

            reference.Uri = "#" + elementId;
            reference.Id  = "Reference-" + Guid.NewGuid().ToString();

            _objectReference = reference.Id;
            _mimeType        = mimeType;

            if (mimeType == "text/xml")
            {
                XmlDsigC14NTransform transform = new XmlDsigC14NTransform();
                reference.AddTransform(transform);
            }
            else
            {
                XmlDsigBase64Transform transform = new XmlDsigBase64Transform();
                reference.AddTransform(transform);
            }

            _xadesSignedXml = new XadesSignedXml(_document);

            _xadesSignedXml.AddReference(reference);
        }
        /// <summary>
        /// Carga un archivo de firma.
        /// </summary>
        /// <param name="xmlDocument"></param>
        public SignatureDocument[] Load(XmlDocument xmlDocument)
        {
            XmlNodeList signatureNodeList = xmlDocument.GetElementsByTagName("Signature", SignedXml.XmlDsigNamespaceUrl);

            if (signatureNodeList.Count == 0)
            {
                throw new Exception("No signature found");
            }

            List <SignatureDocument> firmas = new List <SignatureDocument>();

            foreach (var signatureNode in signatureNodeList)
            {
                SignatureDocument sigDocument = new SignatureDocument
                {
                    Document = (XmlDocument)xmlDocument.Clone()
                };
                sigDocument.Document.PreserveWhitespace = true;
                sigDocument.XadesSignature = new XadesSignedXml(sigDocument.Document);
                sigDocument.XadesSignature.LoadXml((XmlElement)signatureNode);

                firmas.Add(sigDocument);
            }

            return(firmas.ToArray());
        }
Example #11
0
        public static XmlDocument GetSearchableXmlDoc(XmlDocument sourceDoc)
        {
            XmlDocument outputDoc = (XmlDocument)sourceDoc.Clone();

            MakeNodeSearchable(outputDoc.DocumentElement);
            return(outputDoc);
        }
Example #12
0
        public bool CreateXmlFile()
        {
            if (!String.IsNullOrEmpty(FileName))
            {
                XmlFilePath = XmlDirPath + @"\" + FileName + XmlSuf;
            }

            if (File.Exists(XmlFilePath))
            {
                return(false);
            }

            XmlDocument    xmlDoc = new XmlDocument();
            XmlDeclaration xmlDec = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", null);

            xmlDoc.AppendChild(xmlDec);

            XmlElement root = xmlDoc.CreateElement(NodesName);

            root.SetAttribute(NodeName, FileName);
            xmlDoc.AppendChild(root);
            xmlDoc.Save(XmlFilePath);
            xmlDoc.Clone();
            xmlDoc = null;

            return(true);
        }
Example #13
0
        private void updateFilteredXmlfromUnfiltered(bool copy)
        {
            if (copy)
            {
                // copy XML from unfiltered XML
                itemXMLFilteredDoc = (XmlDocument)itemXMLDoc.Clone();
            }

            // filter out system nodes
            for (int i = 0; i < systemNodes.Length; i++)
            {
                XmlNodeList nodesToRemove = itemXMLFilteredDoc.SelectNodes(systemNodes[i]);
                for (int j = 0; j < nodesToRemove.Count; j++)
                {
                    if (nodesToRemove[j].NodeType == XmlNodeType.Attribute)
                    {
                        ((XmlAttribute)nodesToRemove[j]).OwnerElement.RemoveAttribute(nodesToRemove[j].Name);
                    }
                    else
                    {
                        nodesToRemove[j].ParentNode.RemoveChild(nodesToRemove[j]);
                    }

                    // trim <item> if it has no child nodes
                    XmlNode itemNode = itemXMLFilteredDoc.SelectSingleNode("/xml/item");
                    if (itemNode != null)
                    {
                        if (itemNode.ChildNodes.Count == 0)
                        {
                            itemNode.ParentNode.RemoveChild(itemNode);
                        }
                    }
                }
            }
        }
Example #14
0
        /// <summary>
        /// 修改版本
        /// </summary>
        public static void ModifyEdition(string varPath, string varRoot, XmlDocument verXml, string varVersion)
        {
            XmlNodeList tempFileXnl = verXml.GetElementsByTagName("file");
            XmlNode     tempXn      = null;

            foreach (XmlNode v in tempFileXnl)
            {
                if (varPath.IndexOf(v.Attributes["name"].InnerText) != -1)
                {
                    tempXn = v;
                    FileInfo fileInfo = new FileInfo(varPath);
                    tempXn.Attributes["size"].InnerText    = fileInfo.Length.ToString();
                    tempXn.Attributes["version"].InnerText = varVersion;
                    break;
                }
            }
            if (tempXn == null)
            {
                FileInfo   fileInfo = new FileInfo(varPath);
                XmlElement item     = verXml.CreateElement("file");
                item.SetAttribute("name", varPath.Remove(0, varRoot.Length + 1));
                item.SetAttribute("size", fileInfo.Length.ToString());
                item.SetAttribute("version", varVersion);
                item.SetAttribute("path", "Upload/PineappleAR/");
                verXml.GetElementsByTagName("root")[0].AppendChild(item);
            }
            verXml.Save(varRoot + "/Version.xml");
            verXml.Clone();
            Debug.Log(varRoot + "/Version.xml");
            new Task(UploadFile(varRoot + "/Version.xml"));
        }
Example #15
0
        private void updateUnfilteredXmlfromFiltered()
        {
            updateFilteredXmlfromUnfiltered(false);
            XmlDocument itemXMLTempDoc = (XmlDocument)itemXMLFilteredDoc.Clone();
            XmlNode     itemTempNode;

            // get item node or append one if it does not exist
            itemTempNode = itemXMLTempDoc.FirstChild.SelectSingleNode("/xml/item");
            if (itemTempNode == null)
            {
                itemTempNode = itemXMLTempDoc.FirstChild.AppendChild(itemXMLTempDoc.CreateElement("item"));
            }

            // copy system nodes from unfiltered item XML into filtered XML
            for (int i = 0; i < systemNodes.Length; i++)
            {
                XmlNode nodeToClone = itemXMLDoc.SelectSingleNode(systemNodes[i]);
                if (nodeToClone != null)
                {
                    // import node and append to temp XML (parent should always be /xml/item)
                    if (nodeToClone.NodeType == XmlNodeType.Element)
                    {
                        itemTempNode.AppendChild(itemXMLTempDoc.ImportNode(nodeToClone, true));
                    }
                    if (nodeToClone.NodeType == XmlNodeType.Attribute)
                    {
                        itemTempNode.Attributes.Append((XmlAttribute)itemXMLTempDoc.ImportNode(nodeToClone, true));
                    }
                }
            }
            // clone itemXMLTempDoc to itemXMLDoc
            itemXMLDoc = (XmlDocument)itemXMLTempDoc.Clone();
        }
Example #16
0
        /// <summary>
        /// Create a new XmlDocument with values replaced for tokens
        /// </summary>
        /// <returns>XmlDocument with tokens</returns>
        public XmlDocument GetXMLTokenized()
        {
            _documentTokenized = (XmlDocument)_document.Clone();
            ReadAllElements(_documentTokenized);

            return(_documentTokenized);
        }
Example #17
0
        public override void Apply(XmlDocument document, string key)
        {
            try
            {
                // Process the various branches, if available, with the cloned document...
                int itemCount = _listBranches == null ? 0 : _listBranches.Count;
                for (int i = 0; i < itemCount; i++)
                {
                    IList <BuildComponent> components     = _listBranches[i];
                    XmlDocument            clonedDocument = (XmlDocument)document.Clone();
                    for (int j = 0; j < components.Count; j++)
                    {
                        BuildComponent component = components[j];
                        component.Apply(clonedDocument, key);
                    }
                }

                // Process the default branch, with the original document...
                itemCount = _defaultBranch == null ? 0 : _defaultBranch.Count;
                for (int k = 0; k < itemCount; k++)
                {
                    BuildComponent component = _defaultBranch[k];
                    component.Apply(document, key);
                }
            }
            catch (Exception ex)
            {
                this.WriteMessage(MessageLevel.Error, ex);
            }
        }
Example #18
0
#pragma warning disable CS0108 // “XmlModuleHelper.CreateXmlFile()”隐藏继承的成员“XmlHelperBase.CreateXmlFile()”。如果是有意隐藏,请使用关键字 new。
        public static bool CreateXmlFile()
#pragma warning restore CS0108 // “XmlModuleHelper.CreateXmlFile()”隐藏继承的成员“XmlHelperBase.CreateXmlFile()”。如果是有意隐藏,请使用关键字 new。
        {
            if (String.IsNullOrEmpty(ModuleName))
            {
                XmlFilePath = XmlDirPath + ModuleName + XmlSuffix;
            }

            if (File.Exists(XmlFilePath))
            {
                return(false);
            }

            XmlDocument    xmlDoc = new XmlDocument();
            XmlDeclaration xmlDec = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", null);

            xmlDoc.AppendChild(xmlDec);

            XmlElement root = xmlDoc.CreateElement("Module");

            root.SetAttribute("Name", ModuleName);
            xmlDoc.AppendChild(root);
            xmlDoc.Save(XmlFilePath);
            xmlDoc.Clone();
            xmlDoc = null;

            return(true);
        }
        static void ExpandMatrixApplyPatchValues(ForEachItem fe, XmlDocument source, List <object> matrix)
        {
            foreach (string value in fe.Values)
            {
                XmlNode src = source.SelectSingleNode(fe.Target);
                if (src != null)
                {
                    if (src.NodeType == XmlNodeType.Element)
                    {
                        if (src.SelectNodes("*").Count > 0)
                        {
                            src.InnerXml = RegexReplaceOrValue(src.InnerXml, value, fe);
                        }
                        else
                        {
                            src.InnerText = RegexReplaceOrValue(src.InnerText, value, fe);
                        }
                    }
                    else
                    {
                        src.Value = RegexReplaceOrValue(src.Value, value, fe);
                    }
                }

                if (fe.HasChild)
                {
                    ExpandMatrixApplyPatchValues(fe.Child, source, matrix);
                }
                else
                {
                    matrix.Add((XmlDocument)source.Clone());
                }
            }
        }
        /// <summary>
        /// Inserta un contenido XML para generar una firma enveloping.
        /// </summary>
        /// <param name="xmlDocument"></param>
        private void SetContentEveloping(SignatureDocument sigDocument, XmlDocument xmlDocument)
        {
            _refContent = new Reference();

            sigDocument.XadesSignature = new XadesSignedXml();

            XmlDocument doc = (XmlDocument)xmlDocument.Clone();

            doc.PreserveWhitespace = true;

            if (doc.ChildNodes[0].NodeType == XmlNodeType.XmlDeclaration)
            {
                doc.RemoveChild(doc.ChildNodes[0]);
            }

            //Add an object
            string dataObjectId = "DataObject-" + Guid.NewGuid().ToString();

            System.Security.Cryptography.Xml.DataObject dataObject = new System.Security.Cryptography.Xml.DataObject();
            dataObject.Data = doc.ChildNodes;
            dataObject.Id   = dataObjectId;
            sigDocument.XadesSignature.AddObject(dataObject);

            _refContent.Id   = "Reference-" + Guid.NewGuid().ToString();
            _refContent.Uri  = "#" + dataObjectId;
            _refContent.Type = XadesSignedXml.XmlDsigObjectType;

            XmlDsigC14NTransform transform = new XmlDsigC14NTransform();

            _refContent.AddTransform(transform);

            sigDocument.XadesSignature.AddReference(_refContent);
        }
Example #21
0
    private void ReadFile(string s, string p)
    {
        System.Diagnostics.Debug.Write(s);
        XmlDocument xDoc = new XmlDocument();

        xDoc.Load(p + "\\" + s);

        XmlNodeList FileType = xDoc.GetElementsByTagName("FileType");
        XmlNodeList id       = xDoc.GetElementsByTagName("id");

        XmlNodeList pwd       = xDoc.GetElementsByTagName("pwd");
        XmlNodeList pwdhintid = xDoc.GetElementsByTagName("pwdhintid");

        XmlNodeList pwdanswer = xDoc.GetElementsByTagName("pwdanswer");

        // ustatus 影響使用者是否為網域登入
        //XmlNodeList ustatus= xDoc.GetElementsByTagName("ustatus");



        XmlNodeList modifyuid = xDoc.GetElementsByTagName("modifyuid");



        //------------------------------------------------------------------
        xDoc.Clone();

        Response.Write(FileType[0].InnerXml);


        UpdateModel(id[0].InnerXml, pwd[0].InnerXml, pwdhintid[0].InnerXml, pwdanswer[0].InnerXml,
                    modifyuid[0].InnerXml);
    }
Example #22
0
        private static string GenerateCustomProject(string path, string content, params string[] links)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(content);

            var newDoc = doc.Clone() as XmlDocument;

            var rootNode = newDoc.GetElementsByTagName("Project")[0];

            XmlElement itemGroup = newDoc.CreateElement("ItemGroup", newDoc.DocumentElement.NamespaceURI);

            foreach (var s in links)
            {
                string[]   ss      = s.Split(' ');
                string     p       = ss[0];
                string     linkStr = ss[1];
                XmlElement compile = newDoc.CreateElement("Compile", newDoc.DocumentElement.NamespaceURI);
                XmlElement link    = newDoc.CreateElement("Link", newDoc.DocumentElement.NamespaceURI);
                link.InnerText = linkStr;
                compile.AppendChild(link);
                compile.SetAttribute("Include", p);
                itemGroup.AppendChild(compile);
            }

            var projectReference = newDoc.CreateElement("ProjectReference", newDoc.DocumentElement.NamespaceURI);

            projectReference.SetAttribute("Include", @"..\Share\Analyzer\Share.Analyzer.csproj");
            projectReference.SetAttribute("OutputItemType", @"Analyzer");
            projectReference.SetAttribute("ReferenceOutputAssembly", @"false");

            var project = newDoc.CreateElement("Project", newDoc.DocumentElement.NamespaceURI);

            project.InnerText = @"{d1f2986b-b296-4a2d-8f12-be9f470014c3}";
            projectReference.AppendChild(project);

            var name = newDoc.CreateElement("Name", newDoc.DocumentElement.NamespaceURI);

            name.InnerText = "Analyzer";
            projectReference.AppendChild(project);

            itemGroup.AppendChild(projectReference);

            rootNode.AppendChild(itemGroup);

            using (StringWriter sw = new StringWriter())
            {
                using (XmlTextWriter tx = new XmlTextWriter(sw))
                {
                    tx.Formatting = Formatting.Indented;
                    newDoc.WriteTo(tx);
                    tx.Flush();
                    return(sw.GetStringBuilder().ToString());
                }
            }
        }
Example #23
0
        //--- Class Methods ---
        private static void Test(string name, XmlRender xmlRender, CaseFolding caseFolding, string doctype, bool format)
        {
            string source;
            string expected;

            ReadTest(name, out source, out expected);
            expected = expected.Trim().Replace("\r", "");
            string actual;

            // determine how the document should be written back
            XmlReaderTestCallback callback;

            switch (xmlRender)
            {
            case XmlRender.Doc:

                // test writing sgml reader using xml document load
                callback = (reader, writer) =>
                {
                    var doc = new XmlDocument();
                    doc.Load(reader);
                    doc.WriteTo(writer);
                };
                break;

            case XmlRender.DocClone:

                // test writing sgml reader using xml document load and clone
                callback = (reader, writer) =>
                {
                    var doc = new XmlDocument();
                    doc.Load(reader);
                    var clone = doc.Clone();
                    clone.WriteTo(writer);
                };
                break;

            case XmlRender.Passthrough:

                // test writing sgml reader directly to xml writer
                callback = (reader, writer) =>
                {
                    reader.Read();
                    while (!reader.EOF)
                    {
                        writer.WriteNode(reader, true);
                    }
                };
                break;

            default:
                throw new ArgumentException("unknown value", "xmlRender");
            }
            actual = RunTest(caseFolding, doctype, format, source, callback);
            Assert.AreEqual(expected, actual);
        }
Example #24
0
        public XWPFPicture AddPicture(Stream pictureData, int pictureType, string filename, int width, int height)
        {
            XWPFDocument    document     = this.paragraph.GetDocument();
            string          id           = document.AddPictureData(pictureData, pictureType);
            XWPFPictureData relationById = (XWPFPictureData)document.GetRelationById(id);

            try
            {
                CT_Inline  ctInline = this.run.AddNewDrawing().AddNewInline();
                XmlElement element  = new XmlDocument().CreateElement("pic", "pic", "http://schemas.openxmlformats.org/drawingml/2006/picture");
                ctInline.graphic             = new CT_GraphicalObject();
                ctInline.graphic.graphicData = new CT_GraphicalObjectData();
                ctInline.graphic.graphicData.AddPicElement((XmlElement)element.Clone());
                ctInline.distT = 0U;
                ctInline.distR = 0U;
                ctInline.distB = 0U;
                ctInline.distL = 0U;
                CT_NonVisualDrawingProps visualDrawingProps1 = ctInline.AddNewDocPr();
                long num = this.GetParagraph().GetDocument().GetDrawingIdManager().ReserveNew();
                visualDrawingProps1.id    = (uint)num;
                visualDrawingProps1.name  = "Drawing " + (object)num;
                visualDrawingProps1.descr = filename;
                CT_PositiveSize2D ctPositiveSize2D1 = ctInline.AddNewExtent();
                ctPositiveSize2D1.cx = (long)width;
                ctPositiveSize2D1.cy = (long)height;
                NPOI.OpenXmlFormats.Dml.Picture.CT_Picture ctPicture = this.GetCTPictures((object)ctInline.graphic.graphicData)[0];
                CT_PictureNonVisual      pictureNonVisual            = ctPicture.AddNewNvPicPr();
                CT_NonVisualDrawingProps visualDrawingProps2         = pictureNonVisual.AddNewCNvPr();
                visualDrawingProps2.id    = 0U;
                visualDrawingProps2.name  = "Picture " + (object)num;
                visualDrawingProps2.descr = filename;
                pictureNonVisual.AddNewCNvPicPr().AddNewPicLocks().noChangeAspect = true;
                CT_BlipFillProperties blipFillProperties = ctPicture.AddNewBlipFill();
                blipFillProperties.AddNewBlip().embed    = relationById.GetPackageRelationship().Id;
                blipFillProperties.AddNewStretch().AddNewFillRect();
                CT_ShapeProperties ctShapeProperties = ctPicture.AddNewSpPr();
                CT_Transform2D     ctTransform2D     = ctShapeProperties.AddNewXfrm();
                CT_Point2D         ctPoint2D         = ctTransform2D.AddNewOff();
                ctPoint2D.x = 0L;
                ctPoint2D.y = 0L;
                CT_PositiveSize2D ctPositiveSize2D2 = ctTransform2D.AddNewExt();
                ctPositiveSize2D2.cx = (long)width;
                ctPositiveSize2D2.cy = (long)height;
                CT_PresetGeometry2D presetGeometry2D = ctShapeProperties.AddNewPrstGeom();
                presetGeometry2D.prst = ST_ShapeType.rect;
                presetGeometry2D.AddNewAvLst();
                XWPFPicture xwpfPicture = new XWPFPicture(ctPicture, this);
                this.pictures.Add(xwpfPicture);
                return(xwpfPicture);
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("", ex);
            }
        }
Example #25
0
 public override void Apply(XmlDocument document, string key)
 {
     foreach (IEnumerable <BuildComponent> branch in branches)
     {
         XmlDocument subdocument = document.Clone() as XmlDocument;
         foreach (BuildComponent component in branch)
         {
             component.Apply(subdocument, key);
         }
     }
 }
Example #26
0
        private HTTPResult HTTPResultConfig()
        {
            XmlDocument GCXMLResultConfig = (XmlDocument)GCXMLConfig.Clone();

            GCXMLResultConfig.SelectSingleNode("/Configs/WebServer/Login").InnerText    = "***************";
            GCXMLResultConfig.SelectSingleNode("/Configs/WebServer/Password").InnerText = "***************";
            HTTPResult result = new HTTPResult("application/xml", GCXMLResultConfig.OuterXml);

            GCXMLResultConfig = null;
            return(result);
        }
Example #27
0
        //<SNIPPET2>
        public static void CheckSignatureWithEncryptedGrant(string fileName, IRelDecryptor decryptor)
        {
            // Create a new XML document.
            XmlDocument         xmlDocument = new XmlDocument();
            XmlNamespaceManager nsManager   = new XmlNamespaceManager(xmlDocument.NameTable);

            // Format using white spaces.
            xmlDocument.PreserveWhitespace = true;

            // Load the passed XML file into the document.
            xmlDocument.Load(fileName);
            nsManager.AddNamespace("dsig", SignedXml.XmlDsigNamespaceUrl);

            // Find the "Signature" node and create a new XmlNodeList object.
            XmlNodeList nodeList = xmlDocument.SelectNodes("//dsig:Signature", nsManager);

            for (int i = 0, count = nodeList.Count; i < count; i++)
            {
                XmlDocument clone      = xmlDocument.Clone() as XmlDocument;
                XmlNodeList signatures = clone.SelectNodes("//dsig:Signature", nsManager);

                // Create a new SignedXml object and pass into it the XML document clone.
                SignedXml signedXml = new SignedXml(clone);

                // Load the signature node.
                signedXml.LoadXml((XmlElement)signatures[i]);

                // Set the context for license transform
                Transform trans = ((Reference)signedXml.SignedInfo.References[0]).TransformChain[0];

                if (trans is XmlLicenseTransform)
                {
                    // Decryptor is used to decrypt encryptedGrant elements.
                    if (decryptor != null)
                    {
                        (trans as XmlLicenseTransform).Decryptor = decryptor;
                    }
                }

                // Check the signature and display the result.
                bool result = signedXml.CheckSignature();

                if (result)
                {
                    Console.WriteLine("SUCCESS: CheckSignatureWithEncryptedGrant - issuer index #" +
                                      i.ToString());
                }
                else
                {
                    Console.WriteLine("FAILURE: CheckSignatureWithEncryptedGrant - issuer index #" +
                                      i.ToString());
                }
            }
        }
Example #28
0
        /// <inheritdoc />
        public override void Apply(XmlDocument document, string key)
        {
            foreach (var branch in branches)
            {
                XmlDocument subdocument = (XmlDocument)document.Clone();

                foreach (var component in branch)
                {
                    component.Apply(subdocument, key);
                }
            }
        }
Example #29
0
        /// <summary>
        /// 保存模板文件
        /// </summary>
        /// <param name="dic"></param>
        /// <returns></returns>
        public static bool SaveModuleFile(Dictionary <string, string> dic)
        {
            if (!Directory.Exists(XmlDirPath))
            {
                CreateXmlDir();
            }

            if (!File.Exists(XmlFilePath))
            {
                CreateXmlFile();
            }

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(XmlFilePath);
                XmlNode root = doc.SelectSingleNode("Module");
                root.Attributes["Name"].Value = ModuleName;
                if (root != null)
                {
                    XmlNodeList list = root.ChildNodes;
                    foreach (var item in dic)
                    {
                        bool isExitKey = false;
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (Convert.ToString(list[i].Attributes["key"].Value) == item.Key)
                            {
                                list[i].Attributes["value"].Value = Convert.ToString(item.Value);
                                isExitKey = true;
                            }
                        }
                        if (!isExitKey)
                        {
                            XmlElement xe = doc.CreateElement("Item");
                            xe.SetAttribute("key", item.Key);
                            xe.SetAttribute("value", item.Value);
                            root.AppendChild(xe);
                        }
                    }
                }
                doc.Save(XmlFilePath);
                doc.Clone();
                doc = null;
            }
            catch (Exception ex)
            {
                Program.LogNet.WriteError("异常", ex.Message);
                return(false);
            }
            return(true);
        }
 public static Manifest LoadManifestFromFile(string path)
 {
     Manifest m = new Manifest();
     System.IO.StreamReader reader = new System.IO.StreamReader(path);
     string xmldata = reader.ReadToEnd();
     reader.Close();
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(xmldata);
     XmlNode manifest = doc.GetElementsByTagName(Manifest.Element.Manifest)[0];
     m.Read(manifest);
     doc.Clone();
     return m;
 }
Example #31
0
        /// <summary>
        /// Decrypts the specified x document.
        /// </summary>
        /// <param name="xDoc">The x document.</param>
        /// <param name="algo">The algo.</param>
        /// <param name="keyName">Name of the key.</param>
        /// <returns></returns>
        public static XmlDocument Decrypt(XmlDocument xDoc, RSA algo, string keyName)
        {
            var dDoc = (XmlDocument)xDoc.Clone();

            dDoc.PreserveWhitespace = xDoc.PreserveWhitespace;

            var exml = new EncryptedXml(dDoc);

            exml.AddKeyNameMapping(keyName, algo);
            exml.DecryptDocument();

            return(dDoc);
        }
 public static AgentSetVersion LoadVersionFromFile(string path)
 {
     AgentSetVersion av = new AgentSetVersion();
     System.IO.StreamReader reader = new System.IO.StreamReader(path);
     string xmldata = reader.ReadToEnd();
     reader.Close();
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(xmldata);
     XmlNode agent = doc.GetElementsByTagName(AgentDependency.Element.AgentSet)[0];
     av.Read(agent);
     doc.Clone();
     return av;
 }