public override void LoadFile(Stream stream)
        {
            string p = AnnotationPlugIn.GenerateDataRecordPath();
            // t|1|OrderDetails,_Annotation_Attachment20091219164153Z|10248|11
            Match          m        = Regex.Match(this.Value, "_Annotation_Attachment(\\w+)\\|");
            string         fileName = Path.Combine(p, (m.Groups[1].Value + ".xml"));
            XPathNavigator nav      = new XPathDocument(fileName).CreateNavigator().SelectSingleNode("/*");

            fileName = Path.Combine(p, ((Path.GetFileNameWithoutExtension(fileName) + "_")
                                        + Path.GetExtension(nav.GetAttribute("fileName", String.Empty))));
            if (!(this.Value.StartsWith("t|")))
            {
                this.ContentType = nav.GetAttribute("contentLength", String.Empty);
                HttpContext.Current.Response.ContentType = this.ContentType;
            }
            this.FileName = nav.GetAttribute("fileName", String.Empty);
            Stream input = File.OpenRead(fileName);

            try
            {
                byte[] buffer    = new byte[(1024 * 64)];
                long   offset    = 0;
                long   bytesRead = input.Read(buffer, 0, buffer.Length);
                while (bytesRead > 0)
                {
                    stream.Write(buffer, 0, Convert.ToInt32(bytesRead));
                    offset    = (offset + bytesRead);
                    bytesRead = input.Read(buffer, 0, buffer.Length);
                }
            }
            finally
            {
                input.Close();
            }
        }
        private D900CdrDefinitionProvider(string xmlURI)
        {
            _schemaList    = new List <D900CdrDefinitionSchema>();
            _defaultSchema = -1;
            _xmlVersion    = String.Empty;

            bool def;

#if FW35
            XElement cdrXML = XDocument
                              .Load(xmlURI, LoadOptions.None)
                              .Element("D900Cdr");

            __xmlVersion = cdrXML.Attribute("Version").Value;

            foreach (XElement schXML in cdrXML.Elements("Schema"))
            {
                D900CdrDefinitionSchema sch = new D900CdrDefinitionSchema(schXML.Attribute("Name").Value);
                ReadDefinitions(sch.Definitions, schXML, String.Empty);
                _schemaList.Add(sch);
                Boolean.TryParse(schXML.Attribute("Default").Value, out def);
                if (def)
                {
                    _defaultSchema = _schemaList.Count - 1;
                }
            }
#else
            XPathNavigator cdrXML = new XPathDocument(xmlURI)
                                    .CreateNavigator()
                                    .SelectSingleNode("D900Cdr");

            _xmlVersion = cdrXML.GetAttribute("Version", String.Empty);

            foreach (XPathNavigator schXML in cdrXML.Select("Schema"))
            {
                D900CdrDefinitionSchema sch = new D900CdrDefinitionSchema(schXML.GetAttribute("Name", String.Empty));
                ReadDefinitions(sch.Definitions, schXML, String.Empty);
                _schemaList.Add(sch);
                if (Boolean.TryParse(schXML.GetAttribute("Default", String.Empty), out def) && def)
                {
                    _defaultSchema = _schemaList.Count - 1;
                }
            }
#endif
            if ((_defaultSchema < 0) && (_schemaList.Count > 0))
            {
                _defaultSchema = 0;
            }
            _currentSchema = _defaultSchema;
        }
示例#3
0
        private CdrDefinitionProvider(string xmlURI)
        {
            _signatures    = new List <byte>();
            _schemaList    = new List <CdrDefinitionSchema>();
            _defaultSchema = -1;
            _xmlVersion    = String.Empty;

            bool def;

#if FW35
            XElement cdrXML;
            try
            {
                cdrXML = XDocument
                         .Load(xmlURI, LoadOptions.None)
                         .Element("CDRDefinition");
            }
            catch
            {
                _currentSchema = -1;
                return;
            }

            __xmlVersion = cdrXML.Attribute("Version").Value;

            foreach (XElement schXML in cdrXML.Elements("Schema"))
            {
                CdrDefinitionSchema sch = new CdrDefinitionSchema(schXML.Attribute("Name").Value);
                ReadDefinitions(sch.Definitions, schXML, String.Empty);
                _schemaList.Add(sch);
                Boolean.TryParse(schXML.Attribute("Default").Value, out def);
                if (def)
                {
                    _defaultSchema = _schemaList.Count - 1;
                }
            }
#else
            XPathNavigator cdrXML;
            try
            {
                cdrXML = new XPathDocument(xmlURI)
                         .CreateNavigator()
                         .SelectSingleNode("CDRDefinition");
            }
            catch
            {
                _currentSchema = -1;
                return;
            }

            _xmlVersion = cdrXML.GetAttribute("Version", String.Empty);
            _type       = cdrXML.GetAttribute("Type", String.Empty);

            foreach (XPathNavigator sgn in cdrXML.Select("Signature/HexSignature"))
            {
                _signatures.Add(Convert.ToByte(sgn.Value, 16));
            }

            foreach (XPathNavigator schXML in cdrXML.Select("Schema"))
            {
                CdrDefinitionSchema sch = new CdrDefinitionSchema(schXML.GetAttribute("Name", String.Empty));
                ReadDefinitions(sch.Definitions, schXML, String.Empty);
                _schemaList.Add(sch);
                if (Boolean.TryParse(schXML.GetAttribute("Default", String.Empty), out def) && def)
                {
                    _defaultSchema = _schemaList.Count - 1;
                }
            }
#endif
            if ((_defaultSchema < 0) && (_schemaList.Count > 0))
            {
                _defaultSchema = 0;
            }
            _currentSchema = _defaultSchema;
        }