/**********************************************************************************/

        private OadrPoll doPoll()
        {
            OadrPoll oadrPoll = null;

            lock (m_ven) { oadrPoll = m_ven.poll(); }

            m_callbacks.processPoll(oadrPoll);

            if (oadrPoll == null)
            {
                return(null);
            }

            m_serverOffsetSeconds = oadrPoll.serverOffset;

            if (oadrPoll.responseTypeIs(typeof(oadrDistributeEventType)))
            {
                processDistributeEvent(oadrPoll.getDistributeEventResponse());
            }

            else if (oadrPoll.responseTypeIs(typeof(oadrRegisterReportType)))
            {
                processRegisterReport(oadrPoll.getRegisterReportResponse());
            }

            else if (oadrPoll.responseTypeIs(typeof(oadrCreateReportType)))
            {
                processCreateReport(oadrPoll.getCreateReportResponse());
            }

            else if (oadrPoll.responseTypeIs(typeof(oadrCancelReportType)))
            {
                processCancelReport(oadrPoll.getCancelReportResponse());
            }

            else if (oadrPoll.responseTypeIs(typeof(oadrCancelPartyRegistrationType)))
            {
                processCancelRegistration(oadrPoll.getCancelPartyRegistrationResponse());
            }

            else if (oadrPoll.responseTypeIs(typeof(oadrRequestReregistrationType)))
            {
                handleRegistration(true);
            }

            return(oadrPoll);
        }
        public void R1_3010_TH_VTN_1()
        {
            VEN2b ven = new VEN2b(new HttpWebRequestWrapper(false, System.Net.SecurityProtocolType.Tls12), TestProperties.vtnURL, TestProperties.venName, "", TestProperties.venPassword);

            QueryRegistration queryRegistration = ven.queryRegistration();

            OadrPoll poll = ven.poll();

            poll.responseTypeIs(typeof(oadrCreateReportType));

            oadrCreateReportType createReport = poll.getCreateReportResponse();

            Console.Out.WriteLine(poll.responseBody);

            ReportDescription reportDescription = new ReportDescription();

            reportDescription.addReport(createReport.oadrReportRequest[0].reportSpecifier.reportSpecifierID, ReportName.TELEMETRY_STATUS, 0, DurationModifier.MINUTES);

            DateTime dtstart = DateTime.UtcNow;

            reportDescription.addIntervalResourceStatus(createReport.oadrReportRequest[0].reportSpecifier.reportSpecifierID, dtstart,
                                                        0, DurationModifier.SECONDS, "rid", 1, (float)1.0, DataQuality.qualityGoodNonSpecific, true, false, (float)1.0, (float)1.0, (float)1.0, (float)1.0,
                                                        (float)1.0, (float)1.0, (float)1.0, (float)1.0, (float)1.0, (float)1.0, (float)1.0, (float)1.0, (float)1.0, (float)1.0,
                                                        (float)1.0, (float)1.0);

            CreatedReport createdReport = ven.createdReport(createReport.requestID, 200, "OK");

            Assert.IsNotNull(createdReport.response);

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

            reportSpecifierIDs.Add(createReport.oadrReportRequest[0].reportSpecifier.reportSpecifierID);

            UpdateReport updateReport = ven.updateReport(createReport.requestID, reportDescription, reportSpecifierIDs, dtstart);

            Assert.IsNotNull(updateReport.response);
        }
        public void R1_3020_TH_VTN_1()
        {
            VEN2b ven = new VEN2b(new HttpWebRequestWrapper(false, System.Net.SecurityProtocolType.Tls12), TestProperties.vtnURL, TestProperties.venName, TestProperties.venID, TestProperties.venPassword);

            OadrPoll poll = ven.poll();

            poll.responseTypeIs(typeof(oadrCreateReportType));

            oadrCreateReportType createReport = poll.getCreateReportResponse();

            Console.Out.WriteLine(poll.responseBody);

            ReportDescription reportDescription = new ReportDescription();

            reportDescription.addReport(createReport.oadrReportRequest[0].reportSpecifier.reportSpecifierID, ReportName.TELEMETRY_STATUS, 0, DurationModifier.MINUTES);


            CreatedReport createdReport = ven.createdReport(createReport.requestID, 200, "OK");

            Assert.IsNotNull(createdReport.response);

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

            int sleepTime = (int)(createReport.oadrReportRequest[0].reportSpecifier.reportInterval.properties.dtstart.datetime - DateTime.UtcNow).TotalSeconds;

            if (sleepTime > 0)
            {
                System.Threading.Thread.Sleep(sleepTime * 1000);
            }

            reportSpecifierIDs.Add(createReport.oadrReportRequest[0].reportSpecifier.reportSpecifierID);

            DateTime endTime = createReport.oadrReportRequest[0].reportSpecifier.reportInterval.properties.dtstart.datetime +
                               System.Xml.XmlConvert.ToTimeSpan(createReport.oadrReportRequest[0].reportSpecifier.reportInterval.properties.duration.duration);

            // convert ISO8601 duration to timespan
            // http://stackoverflow.com/questions/62804/how-to-convert-iso-8601-duration-to-timespan-in-vb-net
            // http://msdn.microsoft.com/en-us/library/system.xml.xmlconvert.totimespan.aspx
            int sleepDelay = (int)System.Xml.XmlConvert.ToTimeSpan(createReport.oadrReportRequest[0].reportSpecifier.reportBackDuration.duration).TotalSeconds;

            // the test should continue until the end time has passed, but the test set exits after it receives 2 updates
            // while (DateTime.Now < endTime)
            for (int count = 0; count < 2; count++)
            {
                DateTime dtstart = DateTime.UtcNow;

                reportDescription.addIntervalResourceStatus(createReport.oadrReportRequest[0].reportSpecifier.reportSpecifierID, dtstart,
                                                            0, DurationModifier.SECONDS, "rid", 1, (float)1.0, DataQuality.qualityGoodNonSpecific, true, false, (float)1.0, (float)1.0, (float)1.0, (float)1.0,
                                                            (float)1.0, (float)1.0, (float)1.0, (float)1.0, (float)1.0, (float)1.0, (float)1.0, (float)1.0, (float)1.0, (float)1.0,
                                                            (float)1.0, (float)1.0);

                UpdateReport updateReport = ven.updateReport(createReport.requestID, reportDescription, reportSpecifierIDs, dtstart);

                Assert.IsNotNull(updateReport.response);

                if (count == 0)
                {
                    System.Threading.Thread.Sleep(sleepDelay * 1000);
                }
            }
        }