Exemplo n.º 1
0
    // =================================================================================================================
    // === public interface ============================================================================================
    public void FetchMessages(bool inSkipTimeOutCheck = false)
    {
        // ...................................
        // check preconditions...
        if (m_MessageFetchInProggres == true)
        {
            return;
        }

        if (CloudUser.instance.isUserAuthenticated == false)
        {
            Debug.LogError("sender is not authenticated, this message can't be send");
            return;
        }

        if (inSkipTimeOutCheck == false)
        {
            if (Mathf.Abs((float)(m_LastSyncTime - CloudDateTime.UtcNow).TotalMinutes) < SKIP_UPDATE_TIMEOUT)
            {
                return;                 // don't update mailbox from cloud
            }
        }

        // ...................................
        // OK we can fetch new messages...
        m_LastSyncTime           = CloudDateTime.UtcNow;
        m_MessageFetchInProggres = true;

        StartCoroutine(FetchAllMessages_Corutine());
    }
        private void processMessage(Message msg)
        {
            Element data    = msg.GetElement(BAR_DATA).GetElement(BAR_TICK_DATA);
            int     numBars = data.NumValues;

            System.Console.WriteLine("Response contains " + numBars + " bars");
            System.Console.WriteLine("Datetime\t\tOpen\t\tHigh\t\tLow\t\tClose" +
                                     "\t\tNumEvents\tVolume");
            for (int i = 0; i < numBars; ++i)
            {
                Element         bar         = data.GetValueAsElement(i);
                Datetime        time        = bar.GetElementAsDate(TIME);
                double          open        = bar.GetElementAsFloat64(OPEN);
                double          high        = bar.GetElementAsFloat64(HIGH);
                double          low         = bar.GetElementAsFloat64(LOW);
                double          close       = bar.GetElementAsFloat64(CLOSE);
                int             numEvents   = bar.GetElementAsInt32(NUM_EVENTS);
                long            volume      = bar.GetElementAsInt64(VOLUME);
                System.DateTime sysDatetime = time.ToSystemDateTime();
                System.Console.WriteLine(
                    sysDatetime.ToString("s") + "\t" +
                    open.ToString("C") + "\t\t" +
                    high.ToString("C") + "\t\t" +
                    low.ToString("C") + "\t\t" +
                    close.ToString("C") + "\t\t" +
                    numEvents + "\t\t" +
                    volume);
            }
        }
        private void processMessage(Message msg)
        {
            Element data     = msg.GetElement(TICK_DATA).GetElement(TICK_DATA);;
            int     numItems = data.NumValues;

            System.Console.WriteLine("TIME\t\t\tTYPE\tVALUE\t\tSIZE\tCC");
            System.Console.WriteLine("----\t\t\t----\t-----\t\t----\t--");
            for (int i = 0; i < numItems; ++i)
            {
                Element  item  = data.GetValueAsElement(i);
                Datetime time  = item.GetElementAsDate(TIME);
                string   type  = item.GetElementAsString(TYPE);
                double   value = item.GetElementAsFloat64(VALUE);
                int      size  = item.GetElementAsInt32(SIZE);
                string   cc    = "";
                if (item.HasElement(COND_CODE))
                {
                    cc = item.GetElementAsString(COND_CODE);
                }

                System.DateTime sysDatetime =
                    new System.DateTime(time.Year, time.Month, time.DayOfMonth,
                                        time.Hour, time.Minute, time.Second, time.MilliSecond);
                System.Console.WriteLine(
                    sysDatetime.ToString("s") + "\t" +
                    type + "\t" +
                    value.ToString("C") + "\t\t" +
                    size + "\t" +
                    cc);
            }
        }
Exemplo n.º 4
0
        protected MediaAttributes[] GetMediaAttributes(string token, System.DateTime T)
        {
            MediaAttributes[] r = null;
            RunStep(() => r = Client.GetMediaAttributes(new[] { token }, T),
                    string.Format("Get Media Attributes with RecordingTokens = '{0}' and Time = '{1}'", token, T));

            return(r ?? new MediaAttributes[0]);
        }
        protected string RangeClock(System.DateTime startTime, System.DateTime?endTime, bool exactTime)
        {
            Func <System.DateTime, string> funcFormat = (time) =>
            {
                return(time.ToString("yyyyMMdd") + "T" + time.ToString("HHmmss.fff") + "Z");
            };
            string startTimeStr = funcFormat(startTime);
            string endTimeStr   = endTime.HasValue ? funcFormat(endTime.Value) : string.Empty;

            return(string.Format("Range: clock={0}{1}{2}", startTimeStr, exactTime ? "" : "-", endTimeStr));
        }
Exemplo n.º 6
0
 void OnUserAuthenticationChanged(bool state)
 {
     if (state == true)
     {
         m_PrimaryKey = CloudUser.instance.primaryKey;
         Load();
     }
     else
     {
         m_PrimaryKey   = string.Empty;
         m_LastSyncTime = new System.DateTime();
     }
 }
Exemplo n.º 7
0
        public static EndpointReferenceType CreatePullPointSubscription(this IEventService s, FilterType Filter, string InitialTerminationTime, CreatePullPointSubscriptionSubscriptionPolicy SubscriptionPolicy, ref System.Xml.XmlElement[] Any, out System.DateTime CurrentTime, out DateTime?TerminationTime)
        {
            s.InitializeGuard();

            EndpointReferenceType r = null;

            XmlElement[]    localAny             = Any;
            System.DateTime localCurrentTime     = System.DateTime.MinValue;
            System.DateTime?localTerminationTime = null;

            s.Test.RunStep(() => r = s.ServiceClient.Port.CreatePullPointSubscription(Filter, InitialTerminationTime, SubscriptionPolicy, ref localAny, out localCurrentTime, out localTerminationTime), "Get Service Capabilities(Event)");
            CurrentTime            = localCurrentTime;
            TerminationTime        = localTerminationTime;

            return(r);
        }
Exemplo n.º 8
0
        protected void ValidateOrder <T>(IList <T> results,
                                         Func <T, System.DateTime> timeSelector,
                                         System.DateTime start, System.DateTime end)
        {
            bool ok;
            bool ascending = start < end;

            ok = true;
            for (int i = 1; i < results.Count; i++)
            {
                if (timeSelector(results[i - 1]) == timeSelector(results[i]))
                {
                    continue;
                }
                if (timeSelector(results[i - 1]) <= timeSelector(results[i]) != ascending)
                {
                    ok = false;
                }
            }

            Assert(ok, "Results order is broken", string.Format("Check that results are ordered {0}", ascending ? "ascending" : "descending"));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Checks if DateTime structure represents valid date and time.
        /// </summary>
        /// <param name="serverDateTime">Date and time gone from the DUT</param>
        /// <param name="fieldName">Field name (for generation failure reason)</param>
        /// <param name="reason">Failure reason.</param>
        /// <returns></returns>
        public static bool IsValidDateTime(this Proxies.Onvif.DateTime serverDateTime, string fieldName, out string reason)
        {
            bool bDateTimeValid = true;

            reason = string.Empty;

            if (serverDateTime.Date == null)
            {
                reason = "Date is null";
            }
            else if (serverDateTime.Time == null)
            {
                reason = "Time is null";
            }
            else
            {
                try
                {
                    System.DateTime dt = new System.DateTime(serverDateTime.Date.Year,
                                                             serverDateTime.Date.Month,
                                                             serverDateTime.Date.Day,
                                                             serverDateTime.Time.Hour,
                                                             serverDateTime.Time.Minute,
                                                             serverDateTime.Time.Second);
                }
                catch (Exception)
                {
                    bDateTimeValid = false;
                    reason         =
                        string.Format(
                            "{0} is invalid (Year: {1}, Month: {2}, Day: {3}, Hour: {4}, Minute: {5}, Seconds: {6})",
                            fieldName,
                            serverDateTime.Date.Year, serverDateTime.Date.Month, serverDateTime.Date.Day,
                            serverDateTime.Time.Hour, serverDateTime.Time.Minute, serverDateTime.Time.Second);
                }
            }
            return(bDateTimeValid);
        }
 protected string RangeClockExact(System.DateTime startTime)
 {
     // fix by AR for https://wush.net/trac/onvif-ext/ticket/197
     return(RangeClock(startTime, null, false));
     //return RangeClock(startTime, null, true);
 }
 protected string RangeClock(System.DateTime startTime)
 {
     return(RangeClock(startTime, null, false));
 }
 private string RangeClockExact(System.DateTime startTime)
 {
     return(RangeClock(startTime, null, true));
 }
 private string RangeClock(System.DateTime startTime, System.DateTime endTime)
 {
     return(RangeClock(startTime, endTime, false));
 }