private DataTable GetEventResults(long eventId)
        {
            DataTable results = new DataTable();

            using (EventRegistrationManager erManager = new EventRegistrationManager())
            {
                List <EventRegistration> eventRegistrations = erManager.GetAllRegistrationsByEvent(eventId);

                if (eventRegistrations.Count != 0)
                {
                    XmlNodeReader xmlNodeReader = new XmlNodeReader(eventRegistrations[0].Data);
                    results = CreateDataTableColums(results, XElement.Load(xmlNodeReader));
                    xmlNodeReader.Dispose();
                }

                foreach (EventRegistration er in eventRegistrations)
                {
                    XmlNodeReader xmlNodeReader = new XmlNodeReader(er.Data);
                    results.Rows.Add(AddDataRow(XElement.Load(xmlNodeReader), results));
                    xmlNodeReader.Dispose();
                }
            }

            return(results);
        }
 public void Dispose()
 {
     _disposed        = true;
     _getItemsInvoked = true;
     _xmlReader?.Dispose();
     _xmlReader = null;
     _responseMessage?.Dispose();
     _responseMessage = null;
     _childEngine?.Dispose();
     _childEngine = null;
 }
        private DataTable GetEventRegistration(long eventId, XDocument data)
        {
            DataTable results = new DataTable();

            using (EventRegistrationManager erManager = new EventRegistrationManager())
            {
                XmlNodeReader xmlNodeReader = new XmlNodeReader(XmlMetadataWriter.ToXmlDocument(data));
                results = CreateDataTableColums(results, XElement.Load(xmlNodeReader));
                results.Rows.Add(AddDataRow(XElement.Load(xmlNodeReader), results));
                xmlNodeReader.Dispose();
            }
            return(results);
        }
Ejemplo n.º 4
0
        protected override void Dispose(bool disposing)
        {
            if (IsXmlDataNode)
            {
                _xmlNodeReader.Dispose();
            }
            else
            {
                Reset();
                _readState = ReadState.Closed;
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="document"></param>
        /// <returns></returns>
        SqlXml XmlDocumentToSqlXml(XmlDocument document)
        {
            var _sqlXml = (SqlXml)null;

            if (document.HasChildNodes)
            {
                using (var _reader = new XmlNodeReader(document))
                {
                    if (!_reader.IsEmptyElement)
                    {
                        _sqlXml = new SqlXml(_reader);
                    }

                    _reader.Close();
                    _reader.Dispose();
                }
            }

            return(_sqlXml);
        }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="source"></param>
        /// <param name="propertyDescriptors"></param>
        /// <param name="destination"></param>
        /// <returns></returns>
        public object Deserialize(XmlDocument source, DbQueryPropertyDescriptors propertyDescriptors, object destination)
        {
            if (null != source && null != destination)
            {
                using (var _reader = new XmlNodeReader(source.FirstChild))
                {
                    //Fisrt node should be skipped.
                    _reader.Skip();

                    Deserialize(_reader, propertyDescriptors, destination);

                    _reader.Close();
                    _reader.Dispose();
                }

                return(destination);
            }

            return(null);
        }
Ejemplo n.º 7
0
        public static ApplicationProfile Load_ApplicationProfile()
        {
            try
            {
                XmlDocument myXmlDocument = new XmlDocument();
                myXmlDocument.Load(String.Format(@"{0}\{1}", System.AppDomain.CurrentDomain.BaseDirectory, "Profile.set"));

                XmlNodeReader      reader = new XmlNodeReader(myXmlDocument.DocumentElement);
                XmlSerializer      ser    = new XmlSerializer(typeof(ApplicationProfile));
                ApplicationProfile obj    = (ApplicationProfile)ser.Deserialize(reader);

                reader.Dispose();

                return(obj);
            }
            catch (Exception)
            {
                Save_ApplicationProfile(new ApplicationProfile());  // Tworzymy nowy domyslny profil
                return(new ApplicationProfile());                   // Zwracamy calkiem domyslne ustawienia
            }
        }
Ejemplo n.º 8
0
        // --------------------------------------------------------------------------------------------------------------
        //  LoadXSL_Resolver
        //  -------------------------------------------------------------------------------------------------------------
        public int LoadXSL_Resolver(String _strXslFile, XmlResolver xr)
        {
            _strXslFile = FullFilePath(_strXslFile);
            xslt        = new XslCompiledTransform();
            XmlReaderSettings xrs = null;

            switch (_nInputXsl)
            {
            case XslInputType.URI:
                _output.WriteLine("Loading style sheet as URI " + _strXslFile);
                xslt.Load(_strXslFile, XsltSettings.TrustedXslt, xr);
                break;

            case XslInputType.Reader:
                switch (_readerType)
                {
                case ReaderType.XmlTextReader:
                    XmlTextReader trTemp = new XmlTextReader(_strXslFile);
                    try
                    {
                        _output.WriteLine("Loading style sheet as XmlTextReader " + _strXslFile);
                        xslt.Load(trTemp, XsltSettings.TrustedXslt, xr);
                    }
                    finally
                    {
                        if (trTemp != null)
                        {
                            trTemp.Dispose();
                        }
                    }
                    break;

                case ReaderType.XmlNodeReader:
                    XmlDocument docTemp = new XmlDocument();
                    docTemp.Load(_strXslFile);
                    XmlNodeReader nrTemp = new XmlNodeReader(docTemp);
                    try
                    {
                        _output.WriteLine("Loading style sheet as XmlNodeReader " + _strXslFile);
                        xslt.Load(nrTemp, XsltSettings.TrustedXslt, xr);
                    }
                    finally
                    {
                        if (nrTemp != null)
                        {
                            nrTemp.Dispose();
                        }
                    }
                    break;

                case ReaderType.XmlValidatingReader:
                default:
                    xrs = new XmlReaderSettings();
#pragma warning disable 0618
                    xrs.ProhibitDtd = false;
#pragma warning restore 0618
                    XmlReader vrTemp = XmlReader.Create(_strXslFile, xrs);
                    try
                    {
                        _output.WriteLine("Loading style sheet as XmlValidatingReader " + _strXslFile);
                        xslt.Load(vrTemp, XsltSettings.TrustedXslt, xr);
                    }
                    finally
                    {
                        if (vrTemp != null)
                        {
                            vrTemp.Dispose();
                        }
                    }
                    break;
                }
                break;

            case XslInputType.Navigator:
                xrs = new XmlReaderSettings();
#pragma warning disable 0618
                xrs.ProhibitDtd = false;
#pragma warning restore 0618
                XmlReader xrLoad = XmlReader.Create(_strXslFile, xrs);

                XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
                xrLoad.Dispose();
                _output.WriteLine("Loading style sheet as Navigator " + _strXslFile);
                xslt.Load(xdTemp, XsltSettings.TrustedXslt, xr);
                break;
            }
            return(1);
        }
Ejemplo n.º 9
0
        // --------------------------------------------------------------------------------------------------------------
        //  LoadXSL_Resolver
        //  -------------------------------------------------------------------------------------------------------------
        public int LoadXSL_Resolver(string _strXslFile, XmlResolver xr, InputType inputType, ReaderType readerType)
        {
            _strXslFile = FullFilePath(_strXslFile);
#pragma warning disable 0618
            xslt = new XslTransform();
#pragma warning restore 0618

            switch (inputType)
            {
            case InputType.URI:
                _output.WriteLine("Loading style sheet as URI {0}", _strXslFile);
                xslt.Load(_strXslFile, xr);
                break;

            case InputType.Reader:
                switch (readerType)
                {
                case ReaderType.XmlTextReader:
                    XmlTextReader trTemp = new XmlTextReader(_strXslFile);
                    try
                    {
                        _output.WriteLine("Loading style sheet as XmlTextReader {0}", _strXslFile);
                        xslt.Load(trTemp, xr);
                    }
                    catch (Exception ex)
                    {
                        throw (ex);
                    }
                    finally
                    {
                        if (trTemp != null)
                        {
                            trTemp.Dispose();
                        }
                    }
                    break;

                case ReaderType.XmlNodeReader:
                    XmlDocument docTemp = new XmlDocument();
                    docTemp.Load(_strXslFile);
                    XmlNodeReader nrTemp = new XmlNodeReader(docTemp);
                    try
                    {
                        _output.WriteLine("Loading style sheet as XmlNodeReader {0}", _strXslFile);
                        xslt.Load(nrTemp, xr);
                    }
                    catch (Exception ex)
                    {
                        throw (ex);
                    }
                    finally
                    {
                        if (nrTemp != null)
                        {
                            nrTemp.Dispose();
                        }
                    }
                    break;

                case ReaderType.XmlValidatingReader:
                default:
#pragma warning disable 0618
                    XmlValidatingReader vrTemp = new XmlValidatingReader(new XmlTextReader(_strXslFile));
#pragma warning restore 0618
                    vrTemp.ValidationType = ValidationType.None;
                    vrTemp.EntityHandling = EntityHandling.ExpandEntities;
                    try
                    {
                        _output.WriteLine("Loading style sheet as XmlValidatingReader {0}", _strXslFile);
                        xslt.Load(vrTemp, xr);
                    }
                    catch (Exception ex)
                    {
                        throw (ex);
                    }
                    finally
                    {
                        if (vrTemp != null)
                        {
                            vrTemp.Dispose();
                        }
                    }
                    break;
                }
                break;

            case InputType.Navigator:
#pragma warning disable 0618
                XmlValidatingReader xrLoad = new XmlValidatingReader(new XmlTextReader(_strXslFile));
#pragma warning restore 0618
                XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
                xrLoad.Dispose();
                _output.WriteLine("Loading style sheet as Navigator {0}", _strXslFile);
                xslt.Load(xdTemp, xr);
                break;
            }
            return(1);
        }