Пример #1
0
        private static Entry BuildEntry(
            NavigationTimingWrapper.NavTiming timing,
            string URL,
            IList <string> pathArgumentList)
        {
            EntryBuilder eb = new EntryBuilder(pathArgumentList);

            eb.Unit  = "Milliseconds";
            eb.Value = timing.Value;
            eb.Url   = URL;

            return(eb.Build());
        }
Пример #2
0
        public static Entry FromProperties(IDictionary <string, object> entryProperties)
        {
            const bool     isRequired   = true;
            IList <string> path         = getPath(entryProperties, isRequired);
            long           timestamp    = getTimestamp(entryProperties, isRequired);
            EntryBuilder   entryBuilder = new EntryBuilder(path, timestamp);

            object objectValue = entryProperties[Value];

            if (objectValue != null)
            {
                try
                {
                    double value = Convert.ToDouble(objectValue.ToString());
                    entryBuilder.Value = value;
                }
                catch (System.FormatException nfe)
                {
                    throw new NeotysAPIException(NeotysAPIException.ErrorType.NL_API_INVALID_ARGUMENT, "Invalid entry value: " + objectValue, nfe);
                }
            }

            object objectUrl = entryProperties[Url];

            if (objectUrl != null)
            {
                entryBuilder.Url = objectUrl.ToString();
            }
            object objectUnit = entryProperties[Unit];

            if (objectUnit != null)
            {
                entryBuilder.Unit = Escaper.Escape(objectUnit.ToString());
            }
            object objectStatus = entryProperties[Statuses.ElementName];

            if (objectStatus != null)
            {
                if (!(objectStatus is IDictionary <string, object>))
                {
                    throw new NeotysAPIException(NeotysAPIException.ErrorType.NL_API_INVALID_ARGUMENT, "Invalid entry status: " + objectStatus);
                }
                Status status = Statuses.FromProperties((IDictionary <string, object>)objectStatus);
                if (status != null)
                {
                    entryBuilder.Status = status;
                }
            }
            return(entryBuilder.Build());
        }
        private static Entry newEntry(IList <string> parentPath, long timestamp, string text)
        {
            EntryBuilder entryBuilder = new EntryBuilder(parentPath, timestamp);

            try
            {
                double?value = double.Parse(text);
                entryBuilder.Value = value;
            }
            catch (System.Exception e)
            {
                StatusBuilder sb = new StatusBuilder();
                sb.Message          = text;
                entryBuilder.Status = sb.Build();
            }
            return(entryBuilder.Build());
        }
        void SendData(string currentURL, string pageTitle, string methodName, IDictionary <string, long> advancedValues)
        {
            // set the data.
            List <string> entryPath = CreatePath(currentURL, pageTitle, conf);
            EntryBuilder  ebNormal  = new EntryBuilder(entryPath, startTime);

            ebNormal.Url = currentURL;

            ebNormal.Status = Statuses.NewStatus(methodName, exception);
            double value = Time.CurrentTimeMillis() - startTime;

            ebNormal.Value = value;
            ebNormal.Unit  = TimerBuilder.DefaultUnit;

            List <Entry> entriesToSend = new List <Entry>();

            entriesToSend.Add(ebNormal.Build());

            foreach (KeyValuePair <string, long> pair in advancedValues.ToList())
            {
                List <string> advancedPath = new List <string>(entryPath);

                string[] pathEntries = pair.Key.Split('/');
                advancedPath.AddRange(pathEntries);

                EntryBuilder ebAdv = new EntryBuilder(advancedPath, startTime);
                ebAdv.Url    = currentURL;
                ebAdv.Status = Statuses.NewStatus(methodName, exception);
                ebAdv.Value  = value;
                ebAdv.Unit   = TimerBuilder.DefaultUnit;
                ebAdv.Value  = pair.Value;

                entriesToSend.Add(ebAdv.Build());
            }

            if (isDebug)
            {
                foreach (Entry entry in entriesToSend)
                {
                    Logger.GetLogger().DebugMessage("Sending entry. URL: " + currentURL + ", Title: " + pageTitle + ", Entry: " + entry);
                }
            }

            // send the data.
            dataExchangeAPIClient.AddEntries(entriesToSend);
        }
Пример #5
0
        /// <summary>
        /// Create a new entry based on the old entry and adjust the timestamp value by the difference amount. </summary>
        /// <param name="difference"> </param>
        /// <param name="entry">
        /// @return </param>
        public static Entry Shift(Entry entry, long difference)
        {
            EntryBuilder eb = new EntryBuilder(entry.Path, entry.Timestamp + difference);

            if (entry.Status != null)
            {
                eb.Status = entry.Status;
            }
            if (entry.Unit != null)
            {
                eb.Unit = entry.Unit;
            }
            if (entry.Url != null)
            {
                eb.Url = entry.Url;
            }
            if (entry.Value != null)
            {
                eb.Value = entry.Value;
            }
            return(eb.Build());
        }