Ejemplo n.º 1
0
            /// <summary>
            /// Create a signed xml document. Add a signature alement to the specified document using the specified private key.
            /// </summary>
            /// <param name="xmlToSign"></param>
            /// <param name="keyPubPri">Private+public key</param>
            /// <returns></returns>
            public static System.Xml.XmlDocument CreateSignedDoc(System.Xml.XmlDocument xmlToSign, string keyPubPri)
            {
                System.Xml.XmlElement signature = CreateSignature(xmlToSign, keyPubPri);

                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.AppendChild(doc.ImportNode(xmlToSign.DocumentElement, true));

                //Append the signature tag to the root element
                doc.DocumentElement.PrependChild(doc.ImportNode(signature, true));

                return(doc);
            }
Ejemplo n.º 2
0
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();

            System.Xml.XmlNode propertiesNode = document.ChildNodes[1].ChildNodes[0];


            #region Properties

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "RelativeDateValue", RelativeDateValue.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "RelativeDateQualifierInt32", ((Int32)RelativeDateQualifier).ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "RelativeDateQualifier", RelativeDateQualifier.ToString());


            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "StatusInt32", ((Int32)Status).ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "Status", Status.ToString());

            #endregion


            #region Object Nodes

            if (Action != null)
            {
                document.LastChild.AppendChild(document.ImportNode(Action.XmlSerialize().LastChild, true));
            }

            #endregion


            return(document);
        }
Ejemplo n.º 3
0
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();

            System.Xml.XmlNode definitionsNode = document.CreateElement("Definitions");

            document.ChildNodes[1].AppendChild(definitionsNode);


            foreach (MedicalServices.Definitions.ServiceSingletonDefinition currentDefinition in definitions)
            {
                try {
                    currentDefinition.Application = base.application;

                    System.Xml.XmlNode definitionNode = currentDefinition.XmlSerialize().LastChild;

                    definitionsNode.AppendChild(document.ImportNode(definitionNode, true));
                }

                catch (Exception applicationException) {
                    System.Diagnostics.Debug.WriteLine(applicationException.Message);
                }
            }


            return(document);
        }
Ejemplo n.º 4
0
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();

            System.Xml.XmlNode propertiesNode = document.ChildNodes[1].ChildNodes[0];


            #region Properties

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ProblemDomainId", ProblemDomainId.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ProblemDomainName", ProblemDomainName);

            #endregion


            #region Object Nodes

            document.LastChild.AppendChild(document.ImportNode(ProblemDomain.XmlSerialize().LastChild, true));

            #endregion


            return(document);
        }
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();

            System.Xml.XmlNode propertiesNode = document.ChildNodes[1].ChildNodes[0];


            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ServiceId", serviceId.ToString());

            //CommonFunctions.XmlDocumentAppendPropertyNode (document, propertiesNode, "DefinitionServiceId", definitionServiceId.ToString ());

            //CommonFunctions.XmlDocumentAppendPropertyNode (document, propertiesNode, "DefinitionServiceName", application.CoreObjectGetNameById ("Service", definitionServiceId));

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "Enabled", Enabled.ToString());


            // TODO: UPDATE V2, ADD SERVICE DEFINITION AS CHILD PROPERTY


            System.Xml.XmlElement definitionServicePropertyNode = CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "DefinitionService", String.Empty);

            definitionServicePropertyNode.AppendChild(document.ImportNode(DefinitionService.XmlSerialize().ChildNodes[1], true));


            return(document);
        }
Ejemplo n.º 6
0
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();

            System.Xml.XmlNode propertiesNode = document.ChildNodes[1].ChildNodes[0];


            #region Properties

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "CareMeasureId", CareMeasureId.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "CareMeasureScaleId", CareMeasureScaleId.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "CareMeasureScaleName", CareMeasureScaleName);

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "Tag", Tag);

            #endregion


            #region Object Nodes

            document.LastChild.AppendChild(document.ImportNode(CareMeasureScale.XmlSerialize().LastChild, true));

            #endregion


            return(document);
        }
Ejemplo n.º 7
0
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();

            System.Xml.XmlNode propertiesNode = document.ChildNodes[1].ChildNodes[0];


            #region Properties

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "EventTypeInt32", ((Int32)EventType).ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "EventType", EventType.ToString());

            #endregion


            #region Object Nodes

            if (Service != null)
            {
                document.LastChild.AppendChild(document.ImportNode(Service.XmlSerialize().LastChild, true));
            }

            #endregion


            return(document);
        }
Ejemplo n.º 8
0
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();

            System.Xml.XmlNode coreObjectNode = document.ChildNodes[1];

            coreObjectNode.AppendChild(document.ImportNode(ExtendedPropertiesXml.ChildNodes[1], true));

            return(document);
        }
Ejemplo n.º 9
0
            /// <summary>
            /// Create a new XmlDocument from the specified signed document removing the signature element.
            /// </summary>
            /// <param name="signedDoc"></param>
            /// <returns></returns>
            public static System.Xml.XmlDocument CreateDocWithoutSignature(System.Xml.XmlDocument signedDoc)
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.AppendChild(doc.ImportNode(signedDoc.DocumentElement, true));

                System.Xml.XmlElement signature = GetSignatureFromSignedDoc(doc);
                signature.ParentNode.RemoveChild(signature);

                return(doc);
            }
Ejemplo n.º 10
0
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();

            System.Xml.XmlNode propertiesNode = document.ChildNodes[1].ChildNodes[0];


            #region Properties

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "CareMeasureDomainId", CareMeasureDomainId.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "CareMeasureDomainName", CareMeasureDomainName);

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "CareMeasureClassId", CareMeasureClassId.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "CareMeasureClassName", CareMeasureClassName);

            #endregion


            #region Components

            System.Xml.XmlNode componentsNode = document.CreateElement("Components");

            document.LastChild.AppendChild(componentsNode);

            foreach (CareMeasureComponent currentComponent in components)
            {
                componentsNode.AppendChild(document.ImportNode(currentComponent.XmlSerialize().LastChild, true));
            }

            #endregion


            #region Object Nodes

            document.LastChild.AppendChild(document.ImportNode(CareMeasureClass.XmlSerialize().LastChild, true));

            #endregion


            return(document);
        }
Ejemplo n.º 11
0
 internal static System.Xml.XmlDocument getParmAsComplexType(System.Xml.XmlDocument doc, String szName, int nodePosition)
 {
     System.Xml.XmlDocument xDoc     = new System.Xml.XmlDocument();
     System.Xml.XmlNodeList nodeList = doc.SelectNodes(stringHelper.AppendUrl("/methodCallResult/params/", szName, false));
     if (nodePosition != 0)
     {
         nodePosition--;
     }
     if (nodeList.Count > nodePosition)
     {
         xDoc.AppendChild(xDoc.ImportNode(nodeList[nodePosition], true));
     }
     return(xDoc);
 }
Ejemplo n.º 12
0
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();

            System.Xml.XmlNode propertiesNode = document.ChildNodes[1].ChildNodes[0];


            #region Properties

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ProblemDomainId", ProblemDomainId.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ProblemDomainName", ProblemDomainName);

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ProblemClassId", ProblemClassId.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ProblemClassName", ProblemClassName);


            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "DefiningCharacteristics", DefiningCharacteristics);

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "RelatedFactors", RelatedFactors);

            #endregion


            #region Object Nodes

            document.LastChild.AppendChild(document.ImportNode(ProblemClass.XmlSerialize().LastChild, true));

            document.LastChild.AppendChild(document.ImportNode(DefaultCarePlan.XmlSerialize().LastChild, true));

            #endregion


            return(document);
        }
Ejemplo n.º 13
0
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument workQueueTeamDocument = base.XmlSerialize();

            System.Xml.XmlElement workQueueTeamNode = workQueueTeamDocument.CreateElement("WorkQueueTeam");

            System.Xml.XmlElement propertiesNode;



            workQueueTeamDocument.AppendChild(workQueueTeamNode);

            workQueueTeamNode.SetAttribute("WorkQueueId", workTeamId.ToString());

            workQueueTeamNode.SetAttribute("WorkTeamId", workTeamId.ToString());

            workQueueTeamNode.SetAttribute("Name", workTeamName);

            propertiesNode = workQueueTeamDocument.CreateElement("Properties");

            workQueueTeamNode.AppendChild(propertiesNode);


            #region Population Properties

            CommonFunctions.XmlDocumentAppendPropertyNode(workQueueTeamDocument, propertiesNode, "WorkQueueId", workQueueId.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(workQueueTeamDocument, propertiesNode, "WorkTeamId", workTeamId.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(workQueueTeamDocument, propertiesNode, "WorkTeamName", workTeamName);

            CommonFunctions.XmlDocumentAppendPropertyNode(workQueueTeamDocument, propertiesNode, "Permission", ((Int32)permission).ToString());

            #endregion


            if (WorkTeam != null)
            {
                workQueueTeamNode.AppendChild(workQueueTeamDocument.ImportNode(WorkTeam.XmlSerialize().ChildNodes[1], true));
            }



            return(workQueueTeamDocument);
        }
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();

            System.Xml.XmlNode propertiesNode = document.ChildNodes[1].ChildNodes[0];


            #region Properties

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ScheduleTypeInt32", ((Int32)ScheduleType).ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ScheduleType", ScheduleType.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ScheduleValue", ScheduleValue.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ScheduleQualifierInt32", ((Int32)ScheduleQualifier).ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ScheduleQualifier", ScheduleQualifier.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "AnchorDateInt32", ((Int32)AnchorDate).ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "AnchorDate", AnchorDate.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "Reoccurring", Reoccurring.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "PerformActionDateTypeInt32", ((Int32)PerformActionDateType).ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "PerformActionDateType", PerformActionDateType.ToString());

            #endregion


            #region Object Nodes

            if (Action != null)
            {
                document.LastChild.AppendChild(document.ImportNode(Action.XmlSerialize().LastChild, true));
            }

            #endregion


            return(document);
        }
Ejemplo n.º 15
0
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();

            System.Xml.XmlNode propertiesNode = document.ChildNodes[1].ChildNodes[0];


            #region Properties

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "CorrespondenceContentPath", CorrespondenceContentPath);

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "CorrespondenceId", CorrespondenceId.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ContentSequence", ContentSequence.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ContentTypeInt32", ((Int32)ContentType).ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ContentType", ContentType.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ReportingServerId", ReportingServerId.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "AttachmentBase64", AttachmentBase64);

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "AttachmentXpsBase64", AttachmentXpsBase64);

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "IsAttachmentCompressed", IsAttachmentCompressed.ToString());

            #endregion


            #region Object Nodes

            if (ReportingServer != null)   // NOT ALL CONTENT HAS A REPORTING SERVER (I.E. ATTACHMENTS)

            {
                document.LastChild.AppendChild(document.ImportNode(ReportingServer.XmlSerialize().LastChild, true));
            }

            #endregion


            return(document);
        }
Ejemplo n.º 16
0
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();

            System.Xml.XmlNode propertiesNode = document.ChildNodes[1].ChildNodes[0];


            #region Properties

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "Version", Version.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "FormId", FormId.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "FormName", application.CoreObjectGetNameById("Form", formId));

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "StoreImage", StoreImage.ToString());

            #endregion


            #region Contents

            System.Xml.XmlNode componentsNode = document.CreateElement("Contents");

            document.LastChild.AppendChild(componentsNode);

            foreach (Int32 currentContentIndex in content.Keys)
            {
                componentsNode.AppendChild(document.ImportNode(content [currentContentIndex].XmlSerialize().LastChild, true));
            }

            #endregion


            return(document);
        }
Ejemplo n.º 17
0
 bool svgconcat(List<string> files, string output, uint delay, uint loop) {
     if (controller_ != null) controller_.appendOutput("TeX2img: Making animation svg...");
     try {
         var outxml = new System.Xml.XmlDocument();
         outxml.XmlResolver = null;
         outxml.AppendChild(outxml.CreateXmlDeclaration("1.0", "utf-8", "no"));
         outxml.AppendChild(outxml.CreateDocumentType("svg", "-//W3C//DTD SVG 1.1//EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd", null));
         var svg = outxml.CreateElement("svg", "http://www.w3.org/2000/svg");
         var attr = outxml.CreateAttribute("xmlns:xlink");
         attr.Value = "http://www.w3.org/1999/xlink";
         svg.Attributes.Append(attr);
         attr = outxml.CreateAttribute("version");
         attr.Value = "1.1";
         svg.Attributes.Append(attr);
         outxml.AppendChild(svg);
         var defs = outxml.CreateElement("defs", "http://www.w3.org/2000/svg");
         svg.AppendChild(defs);
         var idreg = new System.Text.RegularExpressions.Regex(@"(?<!\&)#");
         foreach (var f in files) {
             var id = Path.GetFileNameWithoutExtension(f);
             var xml = new System.Xml.XmlDocument();
             xml.XmlResolver = null;
             xml.Load(Path.Combine(workingDir, f));
             foreach (System.Xml.XmlNode tag in xml.GetElementsByTagName("*")) {
                 foreach (System.Xml.XmlAttribute a in tag.Attributes) {
                     if (a.Name.ToLower() == "id") a.Value = id + "-" + a.Value;
                     else a.Value = idreg.Replace(a.Value, "#" + id + "-");
                 }
             }
             foreach (System.Xml.XmlNode tag in xml.GetElementsByTagName("svg")) {
                 var idattr = xml.CreateAttribute("id");
                 idattr.Value = id;
                 tag.Attributes.Append(idattr);
             }
             foreach (System.Xml.XmlNode n in xml.ChildNodes) {
                 if (n.NodeType != System.Xml.XmlNodeType.DocumentType && n.NodeType != System.Xml.XmlNodeType.XmlDeclaration) {
                     defs.AppendChild(outxml.ImportNode(n, true));
                 }
             }
         }
         var use = outxml.CreateElement("use", "http://www.w3.org/2000/svg");
         svg.AppendChild(use);
         var animate = outxml.CreateElement("animate", "http://www.w3.org/2000/svg");
         use.AppendChild(animate);
         attr = outxml.CreateAttribute("attributeName");
         attr.Value = "xlink:href"; animate.Attributes.Append(attr);
         attr = outxml.CreateAttribute("begin");
         attr.Value = "0s"; animate.Attributes.Append(attr);
         attr = outxml.CreateAttribute("dur");
         attr.Value = ((decimal)(delay * files.Count) / 100).ToString() + "s";
         animate.Attributes.Append(attr);
         attr = outxml.CreateAttribute("repeatCount");
         attr.Value = loop > 0 ? loop.ToString() : "indefinite";
         animate.Attributes.Append(attr);
         attr = outxml.CreateAttribute("values");
         attr.Value = String.Join(";", files.Select(d => "#" + Path.GetFileNameWithoutExtension(d)).ToArray());
         animate.Attributes.Append(attr);
         outxml.Save(Path.Combine(workingDir, output));
         if (controller_ != null) controller_.appendOutput(" done\n");
         return true;
     }
     catch (Exception) { return false; }
 }
Ejemplo n.º 18
0
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();

            System.Xml.XmlNode propertiesNode = document.ChildNodes[1].ChildNodes[0];


            #region Properties

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "Framework", ((Int32)framework).ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "FrameworkName", (framework.ToString()));


            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "EntityType", ((Int32)entityType).ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "EntityTypeName", entityType.ToString());


            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ActionVerb", actionVerb);

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "AssemblyPath", assemblyPath);

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "AssemblyName", assemblyName);

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "AssemblyClassName", assemblyClassName);

            #endregion


            #region Workflow Parameters

            System.Xml.XmlElement parametersRoot = CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "WorkflowParameters", String.Empty);

            foreach (Action.ActionParameter currentParameter in workflowParameters.Values)
            {
                System.Xml.XmlElement parameterNode;


                parameterNode = document.CreateElement("WorkflowParameter");

                parameterNode.SetAttribute("Name", currentParameter.Name);

                parameterNode.SetAttribute("DataType", ((Int32)currentParameter.DataType).ToString());

                parameterNode.SetAttribute("AllowFixedValue", (currentParameter.AllowFixedValue.ToString()));

                parameterNode.SetAttribute("Required", (currentParameter.Required.ToString()));

                parameterNode.SetAttribute("ValueType", ((Int32)currentParameter.ValueType).ToString());

                parameterNode.SetAttribute("Description", currentParameter.ValueDescription);

                parameterNode.InnerText = currentParameter.Value;

                parametersRoot.AppendChild(parameterNode);
            }

            #endregion


            #region Workflow Permissions

            System.Xml.XmlElement workflowPermissionsNode = document.CreateElement("WorkflowPermissions");

            document.ChildNodes[1].AppendChild(workflowPermissionsNode);

            foreach (WorkflowPermission currentWorkflowPermission in permissions)
            {
                workflowPermissionsNode.AppendChild(document.ImportNode(currentWorkflowPermission.XmlSerialize().ChildNodes[1], true));
            }

            #endregion


            return(document);
        }
Ejemplo n.º 19
0
        /// <summary>The main method that gets called on application startup.</summary>
        /// <param name="args">
        ///  <para>Array of command line arguments provided to this application.</para>
        ///  <para>The first argument will be the path to this application's executable.</para>
        ///  <para>
        ///   The second argument is expected to be a path to the XML file providing this application settings
        ///   to build the project template.
        ///  </para>
        /// </param>
        private static void Main(string[] args)
        {
            // Do not continue if an argument was not provided.
            if ((args.Length < 1) || string.IsNullOrEmpty(args[0]))
            {
                System.Console.WriteLine("Usage: VisualStudio.ProjectTemplate.Builder <PathToXmlSettingsFile>");
                return;
            }

            // Fetch the path to the XML file which provides the settings this builder needs to create the project template.
            string settingsFilePath = args[0];

            if (System.IO.File.Exists(settingsFilePath) == false)
            {
                System.Console.WriteLine("File not found: " + settingsFilePath);
                System.Environment.ExitCode = -1;
                return;
            }

            // Set this application's current directory to where the XML file resides.
            // This allows the XML file to use relative paths to its project files.
            string settingsDirectoryPath = System.IO.Path.GetDirectoryName(settingsFilePath);

            if (string.IsNullOrEmpty(settingsDirectoryPath) == false)
            {
                System.Environment.CurrentDirectory = settingsDirectoryPath;
            }

            // Load the given XML file.
            System.Xml.XmlNode builderXmlNode = null;
            try
            {
                var xmlDocument = new System.Xml.XmlDocument();
                xmlDocument.Load(settingsFilePath);
                foreach (System.Xml.XmlNode nextXmlNode in xmlDocument.ChildNodes)
                {
                    if (nextXmlNode.Name == "VSProjectTemplateBuilder")
                    {
                        builderXmlNode = nextXmlNode;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
                System.Environment.ExitCode = -1;
                return;
            }
            if (builderXmlNode.Name == null)
            {
                System.Console.WriteLine("The given XML file must contain a 'VSProjectTemplateBuilder' node at its root.");
                System.Environment.ExitCode = -1;
                return;
            }

            // Fetch the "VSTemplate" node from the XML file.
            System.Xml.XmlNode vsTemplateXmlNode = null;
            foreach (System.Xml.XmlNode nextXmlNode in builderXmlNode.ChildNodes)
            {
                if (nextXmlNode.Name == "VSTemplate")
                {
                    vsTemplateXmlNode = nextXmlNode;
                    break;
                }
            }
            if (vsTemplateXmlNode == null)
            {
                System.Console.WriteLine(string.Format("XML file '{0}' is missing a 'VSTemplate' node.", settingsFilePath));
                System.Environment.ExitCode = -1;
                return;
            }

            // Fetch the "VSTemplate\TemplateContent\Project" node and its project file path from the XML file.
            System.Xml.XmlNode projectXmlNode  = null;
            string             projectFilePath = null;

            foreach (System.Xml.XmlNode outerXmlNode in vsTemplateXmlNode.ChildNodes)
            {
                if (outerXmlNode.Name == "TemplateContent")
                {
                    foreach (System.Xml.XmlNode innerXmlNode in outerXmlNode.ChildNodes)
                    {
                        if (innerXmlNode.Name == "Project")
                        {
                            projectXmlNode = innerXmlNode;
                            var attributeNode = innerXmlNode.Attributes.GetNamedItem("File");
                            if (attributeNode != null)
                            {
                                projectFilePath = attributeNode.Value;
                            }
                            break;
                        }
                    }
                    break;
                }
            }
            if (string.IsNullOrEmpty(projectFilePath))
            {
                string message =
                    "XML file '" + settingsFilePath +
                    "' does not provide a source project file path to turn into a template.";
                System.Console.WriteLine(message);
                System.Environment.ExitCode = -1;
                return;
            }
            if (System.IO.File.Exists(projectFilePath) == false)
            {
                string message =
                    "Project file '" + projectFilePath + "' referenced in XML file '" +
                    settingsFilePath + "' was not found.";
                System.Console.WriteLine(message);
                System.Environment.ExitCode = -1;
                return;
            }

            // Do not continue if the given Visual Studio project file is not supported by this application.
            // This application only supports C# and VB.NET project files.
            var projectFileExtensionName = System.IO.Path.GetExtension(projectFilePath);

            if (string.IsNullOrEmpty(projectFileExtensionName))
            {
                projectFileExtensionName = string.Empty;
            }
            projectFileExtensionName = projectFileExtensionName.ToLower();
            if (sSupportedProjectExtensions.Contains(projectFileExtensionName) == false)
            {
                string message =
                    "Project file '" + projectFilePath + "' is not supported by this project template builder." +
                    System.Environment.NewLine +
                    "This builder only supports C# and VB.NET projects.";
                System.Console.WriteLine(message);
                System.Environment.ExitCode = -1;
                return;
            }

            // Extract the project file's directory path.
            var projectDirectoryPath = System.IO.Path.GetDirectoryName(projectFilePath);

            if (string.IsNullOrEmpty(projectDirectoryPath))
            {
                projectDirectoryPath = System.IO.Directory.GetCurrentDirectory();
            }

            // Fetch the root namespace name from the project file.
            // This will be used a the template name and string replace it in all project files later.
            sProjectNamespaceName = FetchProjectRootNamespaceFrom(projectFilePath);
            if (string.IsNullOrEmpty(sProjectNamespaceName))
            {
                System.Console.WriteLine("Failed to find 'RootNamespace' element in project file '" + projectFilePath + "'.");
                System.Environment.ExitCode = -1;
                return;
            }

            // Extract the output settings from the given XML file.
            OutputSettings outputSettings = null;

            foreach (System.Xml.XmlNode nextXmlNode in builderXmlNode.ChildNodes)
            {
                if (nextXmlNode.Name == "Output")
                {
                    outputSettings = OutputSettings.From(nextXmlNode);
                    break;
                }
            }
            if (outputSettings == null)
            {
                string message = "XML file '" + settingsFilePath + "' is missing an 'Output' node.";
                System.Console.WriteLine(message);
                System.Environment.ExitCode = -1;
                return;
            }
            if (outputSettings.IntermediateFolderPath.Length <= 0)
            {
                string message = "XML file '" + settingsFilePath + "' must provide an 'IntermediateFolderPath'.";
                System.Console.WriteLine(message);
                System.Environment.ExitCode = -1;
                return;
            }
            if (outputSettings.FolderPaths.Count <= 0)
            {
                string message = "XML file '" + settingsFilePath + "' must provide at least 1 output folder path.";
                System.Console.WriteLine(message);
                System.Environment.ExitCode = -1;
                return;
            }

            // If an output file name was not provided, then use the project file's name.
            if (outputSettings.FileName.Length <= 0)
            {
                outputSettings.FileName = System.IO.Path.GetFileNameWithoutExtension(projectFilePath) + ".zip";
            }

            // Create and clean the intermedate directory.
            outputSettings.IntermediateFolderPath =
                System.IO.Path.Combine(outputSettings.IntermediateFolderPath,
                                       System.IO.Path.GetFileNameWithoutExtension(outputSettings.FileName));
            try
            {
                if (System.IO.Directory.Exists(outputSettings.IntermediateFolderPath))
                {
                    bool isRecursiveDelete = true;
                    System.IO.Directory.Delete(outputSettings.IntermediateFolderPath, isRecursiveDelete);
                }
                System.IO.Directory.CreateDirectory(outputSettings.IntermediateFolderPath);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
                System.Environment.ExitCode = -1;
                return;
            }

            // Traverse the XML project node, update its XML settings, and copy the project's files.
            try
            {
                foreach (System.Xml.XmlNode vsTemplateChildXmlNode in vsTemplateXmlNode.ChildNodes)
                {
                    if (vsTemplateChildXmlNode.Name == "TemplateData")
                    {
                        foreach (System.Xml.XmlNode templateDataChildXmlNode in vsTemplateChildXmlNode.ChildNodes)
                        {
                            if ((templateDataChildXmlNode.Name == "Icon") ||
                                (templateDataChildXmlNode.Name == "PreviewImage"))
                            {
                                // Fetch the image file path and verify the file actually exists.
                                string sourceImageFilePath = templateDataChildXmlNode.InnerText;
                                if (System.IO.File.Exists(sourceImageFilePath) == false)
                                {
                                    System.Console.WriteLine(string.Format(
                                                                 "'{0}' file '{1}' not found.",
                                                                 templateDataChildXmlNode.Name, sourceImageFilePath));
                                    System.Environment.ExitCode = -1;
                                    return;
                                }

                                // Copy the file to the template's intermediate directory.
                                string targetImageFileName = "__" + System.IO.Path.GetFileName(sourceImageFilePath);
                                string targetImageFilePath = System.IO.Path.Combine(
                                    outputSettings.IntermediateFolderPath, targetImageFileName);
                                System.IO.File.Copy(sourceImageFilePath, targetImageFilePath);

                                // Update the XML's image file path, to be used by the final template file.
                                templateDataChildXmlNode.InnerText = targetImageFileName;
                            }
                        }
                    }
                    else if (vsTemplateChildXmlNode.Name == "TemplateContent")
                    {
                        foreach (System.Xml.XmlNode templateContentChildXmlNode in vsTemplateChildXmlNode.ChildNodes)
                        {
                            if (templateContentChildXmlNode.Name == "Project")
                            {
                                // Replace the "Project" element's "File" attribute with a path to the template's project file.
                                var attribute = templateContentChildXmlNode.Attributes.GetNamedItem("File");
                                if (attribute != null)
                                {
                                    attribute.InnerText = System.IO.Path.GetFileName(projectFilePath);
                                }

                                // Remove all of the "Project" node's children, if any.
                                templateContentChildXmlNode.InnerXml = string.Empty;

                                // Copy all of the project's relevant files to a temporary template directory.
                                // This also replaces project names, namespaces, and GUIDs with template variables.
                                CopyProjectDirectoryFiles(
                                    templateContentChildXmlNode, projectDirectoryPath,
                                    outputSettings.IntermediateFolderPath);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
                System.Environment.ExitCode = -1;
                return;
            }

            // Create the *.vstemplate file using the updated "vsTemplateXmlNode" up above.
            try
            {
                string vsTemplateFilePath    = System.IO.Path.Combine(outputSettings.IntermediateFolderPath, "MyTemplate.vstemplate");
                var    vsTemplateXmlDocument = new System.Xml.XmlDocument();
                vsTemplateXmlDocument.AppendChild(vsTemplateXmlDocument.ImportNode(vsTemplateXmlNode, true));
                vsTemplateXmlDocument.Save(vsTemplateFilePath);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("Failed to create *.vstemplate file. Reason:");
                System.Console.WriteLine(ex.Message);
                System.Environment.ExitCode = -1;
                return;
            }

            // Zip up the project template folder.
            string intermediateZipFilePath = System.IO.Path.Combine(
                System.IO.Path.GetDirectoryName(outputSettings.IntermediateFolderPath), outputSettings.FileName);

            try
            {
                if (System.IO.File.Exists(intermediateZipFilePath))
                {
                    System.IO.File.Delete(intermediateZipFilePath);
                }
                bool isZippingBaseDirectory = false;
                System.IO.Compression.ZipFile.CreateFromDirectory(
                    outputSettings.IntermediateFolderPath, intermediateZipFilePath,
                    System.IO.Compression.CompressionLevel.NoCompression, isZippingBaseDirectory);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(
                    "Failed to create '" + intermediateZipFilePath + "' project template zip file. Reason:");
                System.Console.WriteLine(ex.Message);
                System.Environment.ExitCode = -1;
                return;
            }

            // Copy the zipped up project template to the given destination(s).
            try
            {
                foreach (string directoryPath in outputSettings.FolderPaths)
                {
                    if (System.IO.Directory.Exists(directoryPath) == false)
                    {
                        System.IO.Directory.CreateDirectory(directoryPath);
                    }
                    string outputFilePath = System.IO.Path.Combine(directoryPath, outputSettings.FileName);
                    System.IO.File.Copy(intermediateZipFilePath, outputFilePath, true);
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
                System.Environment.ExitCode = -1;
                return;
            }
        }
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();

            System.Xml.XmlNode propertiesNode = document.ChildNodes[1].ChildNodes[0];


            #region Properties

            if (Service != null)
            {
                CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ServiceId", Service.Id.ToString());

                CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ServiceName", Service.Name);
            }

            if (ExclusionService != null)
            {
                CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ExclusionServiceId", ExclusionService.Id.ToString());

                CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ExclusionServiceName", ExclusionService.Name);
            }



            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "AnchorDateInt32", ((Int32)AnchorDate).ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "AnchorDate", AnchorDate.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "AnchorDateValue", AnchorDateValue.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ScheduleDateValue", ScheduleDateValue.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ScheduleDateQualifierInt32", ((Int32)ScheduleDateQualifier).ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ScheduleDateQualifier", ScheduleDateQualifier.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "Reoccuring", Reoccurring.ToString());

            #endregion


            #region Thresholds

            System.Xml.XmlNode thresholdsNode = document.CreateElement("Thresholds");

            document.LastChild.AppendChild(thresholdsNode);

            foreach (PopulationServiceEventThreshold currentThreshold in Thresholds)
            {
                thresholdsNode.AppendChild(document.ImportNode(currentThreshold.XmlSerialize().LastChild, true));
            }

            #endregion


            #region Object Nodes

            System.Xml.XmlNode dependenciesNode = document.CreateElement("Dependencies");

            document.LastChild.InsertBefore(dependenciesNode, propertiesNode);

            if (Service != null)
            {
                dependenciesNode.AppendChild(document.ImportNode(Service.XmlSerialize().LastChild, true));
            }

            if (ExclusionService != null)
            {
                dependenciesNode.AppendChild(document.ImportNode(ExclusionService.XmlSerialize().LastChild, true));
            }

            #endregion


            return(document);
        }
Ejemplo n.º 21
0
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();

            System.Xml.XmlNode propertiesNode = document.ChildNodes[1].ChildNodes[0];


            #region Properties

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ConditionClassId", conditionClassId.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ConditionClassName", ((ConditionClass != null) ? ConditionClass.Name : String.Empty));

            #endregion


            #region Criteria

            System.Xml.XmlNode criteriaNode = document.CreateElement("ConditionCriteria");

            document.LastChild.AppendChild(criteriaNode);

            foreach (ConditionCriteria.ConditionCriteriaDemographic currentDemographicCriteria in demographicCriteria)
            {
                criteriaNode.AppendChild(document.ImportNode(currentDemographicCriteria.XmlSerialize().LastChild, true));
            }

            foreach (ConditionCriteria.ConditionCriteriaEvent currentEventCriteria in eventCriteria)
            {
                criteriaNode.AppendChild(document.ImportNode(currentEventCriteria.XmlSerialize().LastChild, true));
            }

            #endregion


            #region Condition Events

            System.Xml.XmlNode conditionEventNode = document.CreateElement("ConditionEvents");

            document.LastChild.AppendChild(conditionEventNode);

            foreach (String currentConditionEventName in events.Keys)
            {
                if (events[currentConditionEventName] != null)
                {
                    System.Xml.XmlNode conditionEventActionNode = document.CreateElement(currentConditionEventName);

                    conditionEventActionNode.AppendChild(document.ImportNode(events[currentConditionEventName].XmlSerialize().LastChild, true));

                    conditionEventNode.AppendChild(conditionEventActionNode);
                }
            }

            #endregion


            #region Dependencies Nodes

            System.Xml.XmlNode dependenciesNode = document.CreateElement("Dependencies");

            document.LastChild.InsertBefore(dependenciesNode, propertiesNode);

            if (ConditionClass != null)
            {
                dependenciesNode.AppendChild(document.ImportNode(ConditionClass.XmlSerialize().LastChild, true));
            }

            #endregion


            return(document);
        }
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();

            System.Xml.XmlNode propertiesNode = document.ChildNodes[1].ChildNodes[0];


            #region Properties

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "EventTypeInt32", ((Int32)EventType).ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "EventType", EventType.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "MetricTypeInt32", ((Int32)MetricType).ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "MetricType", MetricType.ToString());


            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "MetricMinimum", MetricMinimum.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "MetricMaximum", MetricMaximum.ToString());



            if (AuthorizedService != null)
            {
                CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "AuthorizedServiceId", AuthorizedService.Id.ToString());

                CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "AuthorizedServiceName", AuthorizedService.Name);
            }

            if (Service != null)
            {
                CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ServiceId", Service.Id.ToString());

                CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ServiceName", Service.Name);
            }

            if (Metric != null)
            {
                CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "MetricId", Metric.Id.ToString());

                CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "MetricName", Metric.Name);
            }


            if (ProblemStatement != null)
            {
                CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ProblemStatementId", ProblemStatement.Id.ToString());

                CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ProblemStatementName", ProblemStatement.Name);
            }

            #endregion


            #region Object Nodes

            if (Action != null)
            {
                document.LastChild.AppendChild(document.ImportNode(Action.XmlSerialize().LastChild, true));
            }

            #endregion


            #region Dependencies Nodes

            System.Xml.XmlNode dependenciesNode = document.CreateElement("Dependencies");

            document.LastChild.InsertBefore(dependenciesNode, propertiesNode);

            if (AuthorizedService != null)
            {
                dependenciesNode.AppendChild(document.ImportNode(AuthorizedService.XmlSerialize().LastChild, true));
            }

            if (Service != null)
            {
                dependenciesNode.AppendChild(document.ImportNode(Service.XmlSerialize().LastChild, true));
            }

            if (Metric != null)
            {
                dependenciesNode.AppendChild(document.ImportNode(Metric.XmlSerialize().LastChild, true));
            }

            if (ProblemStatement != null)
            {
                dependenciesNode.AppendChild(document.ImportNode(ProblemStatement.XmlSerialize().LastChild, true));
            }

            #endregion


            return(document);
        }
Ejemplo n.º 23
0
        }     // End Sub AddCustomDataSet

        public static void AddCustomDataSet(string strFilename, string strDataSetName, string strXmlFragment)
        {
            System.Xml.XmlDocument         doc   = XmlTools.File2XmlDocument(strFilename);
            System.Xml.XmlNamespaceManager nsmgr = GetReportNamespaceManager(doc);

            if (HasDataSet(doc, strDataSetName))
            {
                return;
            }

            string strReportName = System.IO.Path.GetFileNameWithoutExtension(strFilename);

            System.Xml.XmlNode xnDataSets = doc.SelectSingleNode("/dft:Report/dft:DataSets", nsmgr);

            if (xnDataSets != null)
            {
                System.Xml.XmlNode xnAppendAfterThis = null;

                // bool bFirst = StringComparer.OrdinalIgnoreCase.Equals(strAppendAfterParameter, "first");
                // bool bLast = StringComparer.OrdinalIgnoreCase.Equals(strAppendAfterParameter, "last");

                // bool bDoNotFechParameter = bFirst || bLast;

                // if (!bDoNotFechParameter)
                // xnAppendAfterThis = GetParameter(doc, strAppendAfterParameter);
                xnAppendAfterThis = xnDataSets;

                if (xnAppendAfterThis != null) // || bDoNotFechParameter)
                {
                    Logging.LogMessage("{0}\t{1}", strReportName, "Has DataSets");



                    System.Xml.XmlDocument doc2 = new System.Xml.XmlDocument();
                    doc2.LoadXml(CreateFragmentString(strFilename, strXmlFragment));
                    System.Xml.XmlNode fragmentToInsert = doc2.DocumentElement.FirstChild;
                    doc2 = null;

                    // System.Xml.XmlDocumentFragment xmlDocFrag = doc.CreateDocumentFragment();
                    // xmlDocFrag.InnerXml = strXmlFragment;
                    // // xmlDocFrag.AppendChild(doc.ImportNode(fragmentToInsert, true));


                    // employeeNode.AppendChild(employeeNode.OwnerDocument.ImportNode(otherXmlDocument.DocumentElement, true));
                    // xnAppendAfterThis.ParentNode.InsertAfter(fragmentToInsert, xnAppendAfterThis);
                    // xnAppendAfterThis.ParentNode.InsertAfter(doc.ImportNode(fragmentToInsert, true), xnAppendAfterThis);
                    xnAppendAfterThis.AppendChild(doc.ImportNode(fragmentToInsert, true));

                    // xnAppendAfterThis.ParentNode.InsertAfter(xmlDocFrag, xnAppendAfterThis);

                    //if (bDoNotFechParameter)
                    //{
                    //    if (bFirst)
                    //        xnDataSets.PrependChild(xmlDocFrag);
                    //    else
                    //        xnDataSets.AppendChild(xmlDocFrag);
                    //}
                    //else
                    //{
                    //    xnAppendAfterThis.ParentNode.InsertAfter(xmlDocFrag, xnAppendAfterThis);
                    //} // End else of if (bDoNotFechParameter)
                } // End if (xnAppendAfterThis != null || string.IsNullOrEmpty(strAppendAfterParameter))
                else
                {
                    Logging.LogMessage("{0}\tKeine Parameter in Report.", strReportName);
                }
            } // End if (xnParameters != null)

            XmlTools.SaveDocument(doc, strFilename, true);
            //XmlTools.SaveDocument(doc, strFilename, "<ReportParameter Name=\"proc\" xmlns=\"\">", "<ReportParameter Name=\"proc\">");
        } // End Sub AddCustomDataSet
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument routingRuleDefinitionDocument = base.XmlSerialize();

            System.Xml.XmlElement routingRuleDefinitionNode = routingRuleDefinitionDocument.CreateElement("RoutingRuleDefinition");

            System.Xml.XmlElement propertiesNode;

            System.Xml.XmlNode importedNode;


            routingRuleDefinitionDocument.AppendChild(routingRuleDefinitionNode);

            routingRuleDefinitionNode.SetAttribute("RoutingRuleId", routingRuleId.ToString());

            routingRuleDefinitionNode.SetAttribute("Sequence", sequence.ToString());

            propertiesNode = routingRuleDefinitionDocument.CreateElement("Properties");

            routingRuleDefinitionNode.AppendChild(propertiesNode);


            #region Routing Rule Definition Properties

            CommonFunctions.XmlDocumentAppendPropertyNode(routingRuleDefinitionDocument, propertiesNode, "InsurerName", application.CoreObjectGetNameById("Insurer", insurerId));

            CommonFunctions.XmlDocumentAppendPropertyNode(routingRuleDefinitionDocument, propertiesNode, "ProgramName", application.CoreObjectGetNameById("Program", programId));

            CommonFunctions.XmlDocumentAppendPropertyNode(routingRuleDefinitionDocument, propertiesNode, "BenefitPlanName", application.CoreObjectGetNameById("BenefitPlan", benefitPlanId));


            CommonFunctions.XmlDocumentAppendPropertyNode(routingRuleDefinitionDocument, propertiesNode, "Gender", ((Int32)gender).ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(routingRuleDefinitionDocument, propertiesNode, "GenderDescription", gender.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(routingRuleDefinitionDocument, propertiesNode, "UseAgeCriteria", useAgeCriteria.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(routingRuleDefinitionDocument, propertiesNode, "AgeMinimum", ageMinimum.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(routingRuleDefinitionDocument, propertiesNode, "AgeMaximum", ageMaximum.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(routingRuleDefinitionDocument, propertiesNode, "IsAgeInMonths", IsAgeInMonths.ToString());


            CommonFunctions.XmlDocumentAppendPropertyNode(routingRuleDefinitionDocument, propertiesNode, "EthnicityId", ethnicityId.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(routingRuleDefinitionDocument, propertiesNode, "LanguageId", languageId.ToString());


            CommonFunctions.XmlDocumentAppendPropertyNode(routingRuleDefinitionDocument, propertiesNode, "EthnicityName", application.CoreObjectGetNameById("Ethnicity", ethnicityId));

            CommonFunctions.XmlDocumentAppendPropertyNode(routingRuleDefinitionDocument, propertiesNode, "LanguageName", application.CoreObjectGetNameById("Language", languageId));

            CommonFunctions.XmlDocumentAppendPropertyNode(routingRuleDefinitionDocument, propertiesNode, "State", state);

            CommonFunctions.XmlDocumentAppendPropertyNode(routingRuleDefinitionDocument, propertiesNode, "City", city);

            CommonFunctions.XmlDocumentAppendPropertyNode(routingRuleDefinitionDocument, propertiesNode, "ZipCode", zipCode);

            CommonFunctions.XmlDocumentAppendPropertyNode(routingRuleDefinitionDocument, propertiesNode, "County", county);

            if (WorkQueue != null)
            {
                System.Xml.XmlElement WorkQueueNode = CommonFunctions.XmlDocumentAppendPropertyNode(routingRuleDefinitionDocument, propertiesNode, "WorkQueue", String.Empty);

                importedNode = routingRuleDefinitionDocument.ImportNode(WorkQueue.XmlSerialize().LastChild, true);

                WorkQueueNode.AppendChild(importedNode);
            }

            #endregion

            return(routingRuleDefinitionDocument);
        }
        /// <summary>
        /// Return a specific application log by Id.
        /// </summary>
        /// <param name="context">
        /// An System.Web.HttpContext object that provides references to the intrinsic server objects (for example, Request, Response, Session, and 
        /// Server) used to service HTTP requests.
        /// </param>
        /// <param name="itemId">Id of the application log to return.</param>
        private void ReturnApplicationLogItem(HttpContext context, int itemId)
        {
            var config = CoreWebConfiguration.Configuration.ApplicationLogRssFeed;
            var connectionStringName = config.ConnectionString.Name;

            if (string.IsNullOrWhiteSpace(connectionStringName))
            {
                connectionStringName = DefaultConnectionStringName;
            }

            var connectionString = ConfigurationManager.ConnectionStrings[connectionStringName];
            var applicationLogRepository = new ApplicationLogRepository(connectionString.ConnectionString);
            var log = applicationLogRepository.GetById(itemId);

            var xmlDocument = new System.Xml.XmlDocument();
            var xmlNavigator = xmlDocument.CreateNavigator();

            using (var writer = xmlNavigator.AppendChild())
            {
                var serializer = new DataContractSerializer(typeof(ApplicationLogDao));
                serializer.WriteObject(writer, log);
            }

            if (null != log.Data.FirstChild)
            {
                var dataElement = xmlDocument.CreateElement("Data", xmlDocument.FirstChild.NamespaceURI);
                var importedElement = xmlDocument.ImportNode(log.Data.FirstChild, true);
                dataElement.AppendChild(importedElement);
                xmlDocument.FirstChild.AppendChild(dataElement);
            }

            context.Response.ContentType = "text/xml";
            context.Response.Output.Write(xmlDocument.InnerXml);
            context.Response.StatusCode = (int) HttpStatusCode.OK;
            context.Response.Flush();
        }
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            CaptureManager lCaptureManager = null;

            try
            {
                lCaptureManager = new CaptureManager("CaptureManager.dll");
            }
            catch (System.Exception)
            {
                try
                {
                    lCaptureManager = new CaptureManager();
                }
                catch (System.Exception)
                {
                }
            }

            if (lCaptureManager == null)
            {
                return;
            }

            XmlDataProvider lXmlDataProvider = (XmlDataProvider)this.Resources["XmlLogProvider"];

            if (lXmlDataProvider == null)
            {
                return;
            }

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            string lxmldoc = await lCaptureManager.getCollectionOfSourcesAsync();

            doc.LoadXml(lxmldoc);

            var lDeviceLinkNodeList = doc.SelectNodes("Sources/Source/Source.Attributes/Attribute[@Name='CM_DEVICE_LINK']/SingleValue/@Value");

            List <string> lDeviceLinkList = new List <string>();

            for (int i = 0; i < lDeviceLinkNodeList.Count; i++)
            {
                if (!lDeviceLinkList.Contains(lDeviceLinkNodeList.Item(i).Value))
                {
                    lDeviceLinkList.Add(lDeviceLinkNodeList.Item(i).Value);
                }
            }

            System.Xml.XmlDocument groupDoc = new System.Xml.XmlDocument();

            var lroot = groupDoc.CreateElement("Sources");

            groupDoc.AppendChild(lroot);

            foreach (var item in lDeviceLinkList)
            {
                var ldevices = doc.SelectNodes("Sources/Source[Source.Attributes/Attribute[@Name='CM_DEVICE_LINK']/SingleValue[@Value='" + item + "']]");

                if (ldevices != null)
                {
                    var lgroup = groupDoc.CreateElement("DeviceGroup");

                    var lTitle = groupDoc.CreateAttribute("Title");

                    lTitle.Value = item;

                    lgroup.Attributes.Append(lTitle);

                    foreach (var node in ldevices)
                    {
                        var lSourceNode = groupDoc.ImportNode((node as System.Xml.XmlNode), true);

                        lgroup.AppendChild(lSourceNode);
                    }

                    lroot.AppendChild(lgroup);
                }
            }


            lXmlDataProvider.XPath = "Sources/DeviceGroup";

            lXmlDataProvider.Document = groupDoc;
        }
Ejemplo n.º 27
0
            /// <summary>
            /// Create a signed xml document. Add a signature alement to the specified document using the specified private key.
            /// </summary>
            /// <param name="xmlToSign"></param>
            /// <param name="keyPubPri">Private+public key</param>
            /// <returns></returns>
            public static System.Xml.XmlDocument CreateSignedDoc(System.Xml.XmlDocument xmlToSign, string keyPubPri)
            {
                System.Xml.XmlElement signature = CreateSignature(xmlToSign, keyPubPri);

                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.AppendChild(doc.ImportNode(xmlToSign.DocumentElement, true));

                //Append the signature tag to the root element
                doc.DocumentElement.PrependChild(doc.ImportNode(signature, true));

                return doc;
            }
Ejemplo n.º 28
0
            /// <summary>
            /// Create a new XmlDocument from the specified signed document removing the signature element.
            /// </summary>
            /// <param name="signedDoc"></param>
            /// <returns></returns>
            public static System.Xml.XmlDocument CreateDocWithoutSignature(System.Xml.XmlDocument signedDoc)
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.AppendChild(doc.ImportNode(signedDoc.DocumentElement, true));

                System.Xml.XmlElement signature = GetSignatureFromSignedDoc(doc);
                signature.ParentNode.RemoveChild(signature);

                return doc;
            }