Exemplo n.º 1
0
        internal void SetReferences(Schema schema, BizTalkArtifacts artifacts, Microsoft.BizTalk.ExplorerOM.Schema omSchema)
        {
            schema.Application = artifacts.Applications[omSchema.Application.Id()];
            schema.ParentAssembly = artifacts.Assemblies[omSchema.BtsAssembly.Id()];

            if (_schema == null || _schema.Name == null || !_schema.Name.Equals(schema.Name, StringComparison.Ordinal))
            {
                var source = new XmlDocument();
                source.LoadXml(omSchema.GetXmlContent());

                var mgr = new XmlNamespaceManager(source.NameTable);
                mgr.AddNamespace("b", "http://schemas.microsoft.com/BizTalk/2003");
                mgr.AddNamespace("x", "http://www.w3.org/2001/XMLSchema");

                SetSchemaType(schema, source, mgr);
                SetSchemaImports(schema, source, mgr, artifacts);

                if (omSchema.Properties != null)
                {
                    foreach (DictionaryEntry property in omSchema.Properties)
                    {
                        schema.Properties.Add(new KeyValuePair<string, string>(property.Key.ToString(),
                                                                               property.Value.ToString()));
                    }
                }

                _schema = schema;
            }
            else
            {
                schema.Properties = _schema.Properties;
                schema.SchemaType = _schema.SchemaType;
                schema.ReferencedSchemas = _schema.ReferencedSchemas;
            }
        }
Exemplo n.º 2
0
        internal static void SetReferences(Transform transform, BizTalkArtifacts artifacts, Microsoft.BizTalk.ExplorerOM.Transform omTransform)
        {
            transform.Application = artifacts.Applications[omTransform.Application.Id()];
            transform.ParentAssembly = artifacts.Assemblies[omTransform.BtsAssembly.Id()];

            //As it's possible to exclude application we don't always have all schemas. Only add source schema if we have.
            if (artifacts.Schemas.ContainsKey(omTransform.SourceSchema.Id()))
            {
                transform.SourceSchema = artifacts.Schemas[omTransform.SourceSchema.Id()]; ;
            }

            //As it's possible to exclude application we don't always have all schemas. Only add target schema if we have.
            if (artifacts.Schemas.ContainsKey(omTransform.TargetSchema.Id()))
            {
                transform.TargetSchema = artifacts.Schemas[omTransform.TargetSchema.Id()];
            }

            transform.ReceivePorts.AddRange(
                artifacts.ReceivePorts.Where(rp => rp.Value.InboundTransforms.Select(t => t.Id).Contains(transform.Id)).Select(
                    rp => rp.Value));

            transform.SendPorts.AddRange(
            artifacts.SendPorts.Where(rp => rp.Value.OutboundTransforms.Select(t => t.Id).Contains(transform.Id)).Select(
                rp => rp.Value));
        }
Exemplo n.º 3
0
        internal static void SetReferences(ReceivePort receivePort, BizTalkArtifacts artifacts, Microsoft.BizTalk.ExplorerOM.ReceivePort omReceivePort)
        {
            receivePort.Application = artifacts.Applications[omReceivePort.Application.Id()];

            foreach (Microsoft.BizTalk.ExplorerOM.ReceiveLocation omReceiveLocation in omReceivePort.ReceiveLocations)
            {
                var receiveLocation = ReceiveLocationModelTransformer.TransforModel(omReceiveLocation);

                receiveLocation.ReceivePort = receivePort;

                //We simplyfied our model a bit and skipped ReceiveHandler as it doens't add any value
                receiveLocation.Host = artifacts.Hosts[omReceiveLocation.ReceiveHandler.Host.Id()];
                var receivePipeline = omReceiveLocation.ReceivePipeline != null ? artifacts.Pipelines[omReceiveLocation.ReceivePipeline.Id()] : null;
                var sendPipeline = omReceiveLocation.SendPipeline != null ? artifacts.Pipelines[omReceiveLocation.SendPipeline.Id()] : null;
                ReceiveLocationModelTransformer.SetReferences(receiveLocation, receivePipeline, sendPipeline);

                receivePort.ReceiveLocations.Add(receiveLocation);
            }

            if (omReceivePort.InboundTransforms != null)
            {
                var inboundIds = omReceivePort.InboundTransforms.Cast<Microsoft.BizTalk.ExplorerOM.Transform>().Select(s => s.Id());
                receivePort.InboundTransforms.AddRange(artifacts.Transforms.Where(t => inboundIds.Contains(t.Key)).Select(s => s.Value));
            }

            if (omReceivePort.OutboundTransforms != null)
            {
                var outboundIds = omReceivePort.OutboundTransforms.Cast<Microsoft.BizTalk.ExplorerOM.Transform>().Select(s => s.Id());
                receivePort.OutboundTransforms.AddRange(artifacts.Transforms.Where(t => outboundIds.Contains(t.Key)).Select(t => t.Value));
            }

            receivePort.BoundOrchestrations.AddRange(artifacts.Orchestrations.Where(o => o.Value.Ports.Where(p => p.SendPort != null).Select(p => p.SendPort.Id).Contains(omReceivePort.Id())).Select(o => o.Value));
        }
 internal static void SetReferences(OrchestrationPort port, BizTalkArtifacts artifacts, Microsoft.BizTalk.ExplorerOM.OrchestrationPort omPort)
 {
     if (omPort != null)
     {
         if (omPort.ReceivePort != null && artifacts.ReceivePorts.ContainsKey(omPort.ReceivePort.Id()))
         {
             port.ReceivePort = artifacts.ReceivePorts[omPort.ReceivePort.Id()];
         }
         else if (omPort.SendPort != null && artifacts.SendPorts.ContainsKey(omPort.SendPort.Id()))
         {
             port.SendPort = artifacts.SendPorts[omPort.SendPort.Id()];
         }
     }
 }
Exemplo n.º 5
0
        private static void SetSchemaImports(Schema schema, XmlDocument schemaDoc, XmlNamespaceManager mgr, BizTalkArtifacts artifacts)
        {
            XmlNodeList importedSchemaNodes = schemaDoc.SelectNodes("//x:appinfo/b:imports/b:namespace", mgr);
            foreach (XmlNode importedSchemaNode in importedSchemaNodes)
            {
                var refSchema = new Schema
                {
                    Name = importedSchemaNode.Attributes.GetNamedItem("location").Value,
                    TargetNamespace = importedSchemaNode.Attributes.GetNamedItem("uri").Value
                };

                Schema s;
                if (artifacts.Schemas.TryGetValue(refSchema.Id, out s))
                    schema.ReferencedSchemas.Add(s);

                //string importedPrefix = importedSchemaNode.Attributes.GetNamedItem("prefix").Value;

                // Select properties used by this schema that are declared in the property schema
                //XmlNodeList importedPropertyNodes = schemaDoc.SelectNodes("//x:appinfo/b:properties/b:property", mgr);
                //foreach (XmlNode importedPropertyNode in importedPropertyNodes)
                //{
                //    XmlAttribute nameAttribute = importedPropertyNode.Attributes.GetNamedItem("name") as XmlAttribute;

                //    if (nameAttribute == null)
                //    {
                //        nameAttribute = importedPropertyNode.Attributes.GetNamedItem("distinguished") as XmlAttribute;
                //    }

                //    if (nameAttribute != null)
                //    {
                //        string propertyName = nameAttribute.Value;

                //        if (propertyName.StartsWith(importedPrefix))
                //        {
                //            string[] nameParts = propertyName.Split(new char[] { ':' });

                //            if (nameParts.Length > 0)
                //            {
                //                propertyName = nameParts[1];
                //                // importedSchemaObj.Properties.Add(propertyName);
                //            }
                //        }
                //    }
                //}
            }
        }
        internal static void SetReferences(Orchestration orchestration, BizTalkArtifacts artifacts, Microsoft.BizTalk.ExplorerOM.BtsOrchestration omOrchestration)
        {
            //As it's possible to exclude application we don't always have all. Only add application we have.
            if (artifacts.Applications.ContainsKey(omOrchestration.Application.Id()))
            {
                orchestration.Application = artifacts.Applications[omOrchestration.Application.Id()];
            }

            //As it's possible to exclude application we don't always have all assemblies. Only add assemblies we have.
            if (artifacts.Assemblies.ContainsKey(omOrchestration.BtsAssembly.Id()))
            {
                orchestration.ParentAssembly = artifacts.Assemblies[omOrchestration.BtsAssembly.Id()];
            }

            if (omOrchestration.Host != null)
            {
                orchestration.Host = artifacts.Hosts[omOrchestration.Host.Id()];
            }

            foreach (var port in orchestration.Ports)
            {
                OrchestrationPortModelTransformer.SetReferences(port, artifacts, omOrchestration.Ports.Cast<Microsoft.BizTalk.ExplorerOM.OrchestrationPort>().Where(o => o.Name == port.Name).SingleOrDefault());
            }
        }
        internal static void SetReferences(BizTalkAssembly assembly, BizTalkArtifacts artifacts, Microsoft.BizTalk.ExplorerOM.BtsAssembly omAssembly)
        {
            assembly.Application = artifacts.Applications[omAssembly.Application.Id()];

            foreach (Microsoft.BizTalk.ExplorerOM.BtsOrchestration omOrchestration in omAssembly.Orchestrations)
            {
                assembly.Orchestrations.Add(artifacts.Orchestrations[omOrchestration.Id()]);
            }

            foreach (Microsoft.BizTalk.ExplorerOM.Schema omSchema in omAssembly.Schemas)
            {
                assembly.Schemas.Add(artifacts.Schemas[omSchema.Id()]);
            }

            foreach (Microsoft.BizTalk.ExplorerOM.Transform omTransform in omAssembly.Transforms)
            {
                assembly.Transforms.Add(artifacts.Transforms[omTransform.Id()]);
            }

            foreach (Microsoft.BizTalk.ExplorerOM.Pipeline omPipeline in omAssembly.Pipelines)
            {
                assembly.Pipelines.Add(artifacts.Pipelines[omPipeline.Id()]);
            }
        }
Exemplo n.º 8
0
        private static void SetSchemaImports(Schema schema, XmlDocument schemaDoc, XmlNamespaceManager mgr, BizTalkArtifacts artifacts)
        {
            XmlNodeList importedSchemaNodes = schemaDoc.SelectNodes("//x:appinfo/b:imports/b:namespace", mgr);

            foreach (XmlNode importedSchemaNode in importedSchemaNodes)
            {
                var refSchema = new Schema
                {
                    Name            = importedSchemaNode.Attributes.GetNamedItem("location").Value,
                    TargetNamespace = importedSchemaNode.Attributes.GetNamedItem("uri").Value
                };

                Schema s;
                if (artifacts.Schemas.TryGetValue(refSchema.Id, out s))
                {
                    schema.ReferencedSchemas.Add(s);
                }

                //string importedPrefix = importedSchemaNode.Attributes.GetNamedItem("prefix").Value;

                // Select properties used by this schema that are declared in the property schema
                //XmlNodeList importedPropertyNodes = schemaDoc.SelectNodes("//x:appinfo/b:properties/b:property", mgr);
                //foreach (XmlNode importedPropertyNode in importedPropertyNodes)
                //{
                //    XmlAttribute nameAttribute = importedPropertyNode.Attributes.GetNamedItem("name") as XmlAttribute;

                //    if (nameAttribute == null)
                //    {
                //        nameAttribute = importedPropertyNode.Attributes.GetNamedItem("distinguished") as XmlAttribute;
                //    }

                //    if (nameAttribute != null)
                //    {
                //        string propertyName = nameAttribute.Value;

                //        if (propertyName.StartsWith(importedPrefix))
                //        {
                //            string[] nameParts = propertyName.Split(new char[] { ':' });

                //            if (nameParts.Length > 0)
                //            {
                //                propertyName = nameParts[1];
                //                // importedSchemaObj.Properties.Add(propertyName);
                //            }
                //        }
                //    }
                //}
            }
        }
Exemplo n.º 9
0
 internal static void SetReferences(Pipeline pipeline, BizTalkArtifacts artifacts, Microsoft.BizTalk.ExplorerOM.Pipeline omPipeline)
 {
     pipeline.Application = artifacts.Applications[omPipeline.Application.Id()];
     pipeline.ParentAssembly = artifacts.Assemblies[omPipeline.BtsAssembly.Id()];
 }