Exemplo n.º 1
0
        public static Position[] GetPositions(Tracker tracker, int? maxNumberOfPositions, DateTime? validFrom, DateTime? validUntil)
        {
            var positionsQuery = DataHandler.GetContext().Position.OrderByDescending(p => p.CreationDate).Where(p => p.TrackerId == tracker.Id);

            if(validFrom.HasValue) positionsQuery = positionsQuery.Where(p => p.CreationDate >= validFrom);
            if(validUntil.HasValue) positionsQuery = positionsQuery.Where(p => p.CreationDate <= validUntil);

            if(maxNumberOfPositions.HasValue) positionsQuery = positionsQuery.Take(maxNumberOfPositions.Value);

            return positionsQuery.ToArray();
        }
Exemplo n.º 2
0
 public static void SetTrackerOffLine(Tracker tracker)
 {
     try
     {
         tracker.IsOnline = false;
         DataHandler.GetContext().SaveChanges();
     }
     catch (Exception ex)
     {
         Debug.WriteLine("StealME.Exception:" + ex.Message);
     }
 }
Exemplo n.º 3
0
        public static bool DeleteTracker(Tracker t)
        {
            try
            {
                var context = DataHandler.GetContext();
                context.Tracker.DeleteObject(t);
                context.SaveChanges();
            }
            catch (Exception ex)
            { return false; }

            return true;
        }
Exemplo n.º 4
0
 public static void CreateLicence(User currentUser, Tracker newTracker, DateTime dateTime)
 {
     Licence l = new Licence
         {
             UserId = currentUser.Id,
             TrackerId = newTracker.Id,
             CreationDate = DateTime.Now,
             ValidFrom = DateTime.Now,
             ValidUntil = dateTime,
             Id = Guid.NewGuid()
         };
     var context = DataHandler.GetContext();
     context.Licence.AddObject(l);
     context.SaveChanges();
 }
Exemplo n.º 5
0
        public static Tracker CreateTracker(string imei, string name, string description)
        {
            var context = DataHandler.GetContext();
            Tracker result = new Tracker
                {
                    Id = Guid.NewGuid(),
                    CreationDate = DateTime.Now,
                    IMEI = imei,
                    Name = name,
                    Description = description
                };
            context.Tracker.AddObject(result);
            context.SaveChanges();

            return result;
        }
Exemplo n.º 6
0
        public static void InsertPosition(Tracker tracker, Position position)
        {
            try
            {
                position.TrackerId = new Guid("5B9BA752-284E-4B85-BB80-992D610CD806");
                position.Id = Guid.NewGuid();
                position.CreationDate = DateTime.Now;

                var context = DataHandler.GetContext();
                context.Position.AddObject(position);
                context.SaveChanges();

                SMLogger.LogThis("Position inserted.");
            }
            catch (Exception ex)
            {
                Debug.WriteLine("StealME.MessageType:" + ex.Message);
            }
        }
Exemplo n.º 7
0
 public void GetTracker()
 {
     _testTracker = null;
     _testTracker = TrackerLogic.GetTracker(DEMO_TRACKER_IMEI);
     Assert.IsNotNull(_testTracker);
 }
Exemplo n.º 8
0
 public void CreateTracker()
 {
     _testTracker = TrackerLogic.CreateTracker(DEMO_TRACKER_IMEI, "Demo tracker", "demo description");
     Assert.IsNotNull(_testTracker);
 }
Exemplo n.º 9
0
        public void Terminate()
        {
            // todo: mark Tracker OffLine in DB

            if(_msgProc != null)
                _msgProc.MessageReceived -= msgProc_MessageReceived;

            Channel.TerminateChannel();
            _msgProc = null;
            _channel = null;
            _protocol = null;
            _tracker = null;
        }
Exemplo n.º 10
0
 partial void DeleteTracker(Tracker instance);
Exemplo n.º 11
0
 partial void UpdateTracker(Tracker instance);
Exemplo n.º 12
0
 partial void InsertTracker(Tracker instance);
Exemplo n.º 13
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Tracker EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTracker(Tracker tracker)
 {
     base.AddObject("Tracker", tracker);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Create a new Tracker object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="iMEI">Initial value of the IMEI property.</param>
 /// <param name="creationDate">Initial value of the CreationDate property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="description">Initial value of the Description property.</param>
 public static Tracker CreateTracker(global::System.Guid id, global::System.String iMEI, global::System.DateTime creationDate, global::System.String name, global::System.String description)
 {
     Tracker tracker = new Tracker();
     tracker.Id = id;
     tracker.IMEI = iMEI;
     tracker.CreationDate = creationDate;
     tracker.Name = name;
     tracker.Description = description;
     return tracker;
 }
Exemplo n.º 15
0
 public void onMessage(Networking.Protocol.Message status, object o)
 {
     switch (status)
     {
         case Networking.Protocol.Message.IMEI:
             this.Tracker = TrackerLogic.GetTracker((string)o);
             if (this.IsAuthenticated())
             {
                 this.OnAuthenticated(new EventArgs());
                 SMLogger.LogThis("Client Authenticated.");
                 TrackerLogic.SetTrackerOnLine(this.Tracker);
                 this.StartMessagePolling();
             }
             break;
         case Networking.Protocol.Message.TcpLoc:
             this.InsertPosition((TcpLoc)o);
             break;
     }
 }
Exemplo n.º 16
0
 public static Position[] GetPositions(Tracker tracker)
 {
     return DataHandler.GetContext().Position.Where(p => p.TrackerId == tracker.Id).ToArray();
 }