/// <summary>
        /// Parse the given string to a HistoryEvent.
        /// </summary>
        /// <param name="s">Comma separated string representing a HistoryEvent.</param>
        /// <returns></returns>
        public static HistoryEvent EventFromString(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return null;
            }

            string[] ss = s.Split(new char[] {','});
            if (ss.Length < 3)
            {
                return null;
            }

            HistoryEvent he = new HistoryEvent();
            he.BeaconId = ss[0];

            try
            {
                he.EventTime = DateTimeOffset.FromUnixTimeMilliseconds(long.Parse(ss[1])).ToString(History.Timeformat);
            }
            catch (FormatException)
            {
                Debug.WriteLine("ERROR: parsing event: "+ s);
                return null;
            }

            he.Trigger = int.Parse(ss[2]);
            if (ss.Length > 3)
            {
                try
                {
                    he.Delivered = bool.Parse(ss[3]);
                }
                catch (FormatException)
                {
                    Debug.WriteLine("ERROR: parsing event: " + s);
                }
            }

            if (ss.Length > 4)
            {
                he.Location = ss[4];
            }
            return he;
        }
 protected bool Equals(HistoryEvent other)
 {
     return string.Equals(BeaconId, other.BeaconId) && string.Equals(EventTime, other.EventTime) && Trigger == other.Trigger && string.Equals(Location, other.Location) && Delivered == other.Delivered;
 }
 /// <summary>
 /// Creates from the given parameters a string.
 /// </summary>
 /// <param name="he">Historyevent to convert.</param>
 /// <returns>String representing the HistoryEvent.</returns>
 public static string EventToString(HistoryEvent he)
 {
     return(string.Format("{0},{1},{2},{3},{4}\n", he.BeaconId, DateTimeOffset.Parse(he.EventTime).ToUnixTimeMilliseconds(), he.Trigger, false, he.Location));
 }
Beispiel #4
0
 protected bool Equals(HistoryEvent other)
 {
     return(string.Equals(BeaconId, other.BeaconId) && string.Equals(EventTime, other.EventTime) && Trigger == other.Trigger && string.Equals(Location, other.Location) && Delivered == other.Delivered);
 }
 /// <summary>
 /// Creates from the given parameters a string.
 /// </summary>
 /// <param name="he">Historyevent to convert.</param>
 /// <returns>String representing the HistoryEvent.</returns>
 public static string EventToString(HistoryEvent he)
 {
     return string.Format("{0},{1},{2},{3},{4}\n", he.BeaconId, DateTimeOffset.Parse(he.EventTime).ToUnixTimeMilliseconds(), he.Trigger, false,he.Location);
 }
 public async Task<bool> SaveHistoryEvents(HistoryEvent he)
 {
     UndeliveredEvents.Add(he);
     return true;
 }