Exemplo n.º 1
0
        private IDocumentPlug CreateEDIDocumentPlug(int currentTransactionSetType, string[] ISARecordFields)
        {
            string        path, targetNamespace, name;
            IDocumentPlug documentPlug = null;

            switch (currentTransactionSetType)
            {
            case 850:
                name            = "X12_00401_850";
                targetNamespace = @"http://schemas.microsoft.com/BizTalk/EDI/X12/2006";

                if (SchemaCache.ContainsKey(name))
                {
                    documentPlug = SchemaCache[name];
                }
                break;

            case 277:
                name            = "X12_005010X214_277B3";
                targetNamespace = @"urn:x12:schemas:005:010:277B3:HealthCareInformationStatusNotification";

                if (SchemaCache.ContainsKey(name))
                {
                    documentPlug = SchemaCache[name];
                }
                break;

            default:
                throw new PlugDataModelException(string.Format("{0} schema not found", currentTransactionSetType));
            }

            if (documentPlug == null)
            {
                string    docType      = string.Format("{0}#{1}", targetNamespace, name);
                Stream    schemaStream = FPManager.RetrieveSchema(docType);
                XmlReader reader       = new XmlTextReader(schemaStream);

                //Stream schemaStream = FatPipeManager.RetrieveSchema(rootNodeName);
                //XmlReader reader = new XmlTextReader(schemaStream);

                XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
                schemaCollection.Add(targetNamespace, reader);

                documentPlug = DocumentPlugFactory.CreateDocumentPlugFromXmlSchema(schemaCollection, targetNamespace, name);

                SchemaCache[name] = documentPlug;
            }

            return(documentPlug);
        }
        private void GenerateDocumentPlug(string schema)
        {
            if (string.IsNullOrWhiteSpace(schema))
            {
                throw new ArgumentNullException("schema");
            }

            using (Stream schemaStream = GenerateStreamFromString(schema))
            {
                IDocumentPlug documentPlug = DocumentPlugFactory.CreateDocumentPlugFromXmlSchema(schemaStream);

                XElement schemaXml = documentPlug.SerializeToXml();
                schemaXml.Save(Path.Combine(OutputDirName, Path.ChangeExtension(TreeReference, "xml")));

                DocumentPlug = documentPlug;
            }
        }