Esempio n. 1
0
 public bool Delete(int AISTrackId)
 {
     try
     {
         using (AISTrackRepository aisTrackRepo = new AISTrackRepository())
         {
             var AISTrackExisting = aisTrackRepo.Get <AISTrack>(AISTrackId);
             if (AISTrackExisting == null)
             {
                 return(false);
             }
             else
             {
                 aisTrackRepo.Delete <AISTrack>(AISTrackId);
                 if (MemCache.IsIncache("AllAISTracksKey"))
                 {
                     MemCache.GetFromCache <List <AISTrack> >("AllAISTracksKey").Remove(AISTrackExisting);
                 }
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 2
0
 public AISTrack Add(AISTrack AISTrackModel)
 {
     try
     {
         using (AISTrackRepository aisTrackRepo = new AISTrackRepository())
         {
             // Validate and Map data over here
             if (AISTrackModel != null)
             {
                 var rowId = aisTrackRepo.Insert <AISTrack>(AISTrackModel);
                 AISTrackModel.AISTrackId = rowId;
             }
             if (MemCache.IsIncache("AllAISTracksKey"))
             {
                 MemCache.GetFromCache <List <AISTrack> >("AllAISTracksKey").Add(AISTrackModel);
             }
             else
             {
                 List <AISTrack> tracks = new List <AISTrack>();
                 tracks.Add(AISTrackModel);
                 MemCache.AddToCache("AllAISTracksKey", tracks);
             }
             return(AISTrackModel);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 3
0
        public bool Update(AISTrack AISTrackModel)
        {
            try
            {
                using (AISTrackRepository aisTrackRepo = new AISTrackRepository())
                {
                    if (MemCache.IsIncache("AllAISTracksKey"))
                    {
                        List <AISTrack> aISTracks = MemCache.GetFromCache <List <AISTrack> >("AllStakeholdersKey");
                        if (aISTracks.Count > 0)
                        {
                            aISTracks.Remove(aISTracks.Find(x => x.AISTrackId == AISTrackModel.AISTrackId));
                        }
                    }

                    aisTrackRepo.Update <AISTrack>(AISTrackModel);
                    if (MemCache.IsIncache("AllStakeholdersKey"))
                    {
                        MemCache.GetFromCache <List <AISTrack> >("AllStakeholdersKey").Add(AISTrackModel);
                    }
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
        public List <AISTrack> List(Dictionary <string, string> dic = null)
        {
            try
            {
                List <AISTrack> lstAISTracks = new List <AISTrack>();
                if (MemCache.IsIncache("AllAISTracksKey"))
                {
                    return(MemCache.GetFromCache <List <AISTrack> >("AllAISTracksKey"));
                }
                else
                {
                    if (dic == null)
                    {
                        dic = new Dictionary <string, string>();
                    }

                    dic.Add("orderby", "MMSI");
                    dic.Add("offset", "1");
                    dic.Add("limit", "200");

                    var parameters = this.ParseParameters(dic);
                    using (AISTrackRepository aisTrackRepo = new AISTrackRepository())
                    {
                        lstAISTracks = aisTrackRepo.GetListPaged <AISTrack>(Convert.ToInt32(dic["offset"]), Convert.ToInt32(dic["limit"]), parameters, dic["orderby"]).ToList();
                        return(lstAISTracks);
                    }
                }
            }
            catch (Exception ex)
            {
                //_trace.Error("Error Retrieving Data", exception: ex);
                throw ex;
            }
        }
        public void Post(AISTrackRequest aisTrackRequest)
        {
            using (AISTrackRepository aisTrackRepo = new AISTrackRepository())
            {
                AISTrack model = aisTrackRequest.Adapt <AISTrack>();
                //aisTrackRepo.Insert<AISTrack>(model);
                //_hubContext.Clients.All.PushAISTrackNew(model);

                Ship shipModel = GetShipDetails(Convert.ToString(aisTrackRequest.TRACK_NUMBER), Convert.ToString(aisTrackRequest.IMO));
                if (shipModel != null && shipModel.ShipId != 0)
                {
                    aisTrackRequest.IsLloydInfoPresent = true;
                    aisTrackRequest.LloydInfo          = shipModel;
                }
                else
                {
                    aisTrackRequest.IsLloydInfoPresent = false;
                }
            }

            //Console.WriteLine(aisTrackRequest.IMO);
            //TrackHub trackHub = new TrackHub();
            //_ = trackHub.Send(aisTrackRequest.MMSI, aisTrackRequest.LAT, aisTrackRequest.LON, aisTrackRequest.SPEED, aisTrackRequest.HEADING, aisTrackRequest.COURSE, aisTrackRequest.STATUS, aisTrackRequest.ROT, aisTrackRequest.FLAG);
            _hubContext.Clients.All.PushAISTrack(aisTrackRequest); //aisTrackRequest.TRACK_TYPE, aisTrackRequest.TRACK_SOURCE);
        }
Esempio n. 6
0
 public void Post(AISTrackRequest aisTrackRequest)
 {
     using (AISTrackRepository aisTrackRepo = new AISTrackRepository())
     {
         AISTrack model = aisTrackRequest.Adapt <AISTrack>();
         //aisTrackRepo.Insert<AISTrack>(model);
         //_hubContext.Clients.All.PushAISTrackNew(model);
     }
     //Console.WriteLine(aisTrackRequest.IMO);
     //TrackHub trackHub = new TrackHub();
     //_ = trackHub.Send(aisTrackRequest.MMSI, aisTrackRequest.LAT, aisTrackRequest.LON, aisTrackRequest.SPEED, aisTrackRequest.HEADING, aisTrackRequest.COURSE, aisTrackRequest.STATUS, aisTrackRequest.ROT, aisTrackRequest.FLAG);
     _hubContext.Clients.All.PushAISTrack(aisTrackRequest); //aisTrackRequest.TRACK_TYPE, aisTrackRequest.TRACK_SOURCE);
 }
 public void Put(int mmsi, AISTrackRequest aisTrackRequest)
 {
     try
     {
         using (AISTrackRepository aisTrackRepo = new AISTrackRepository())
         {
             AISTrack model = aisTrackRequest.Adapt <AISTrack>();
             //aisTrackRepo.Insert<AISTrack>(model);
             _hubContext.Clients.All.PushAISTrackUpdate(aisTrackRequest);
         }
     }
     catch (Exception ex)
     {
     }
 }
Esempio n. 8
0
 public AISTrack GetById(int AISTrackId)
 {
     try
     {
         if (MemCache.IsIncache("AllAISTracksKey"))
         {
             return(MemCache.GetFromCache <List <AISTrack> >("AllAISTracksKey").Where <AISTrack>(x => x.AISTrackId == AISTrackId).FirstOrDefault());
         }
         using (AISTrackRepository aisTrackRepo = new AISTrackRepository())
         {
             AISTrack AISTrackModel = new AISTrack();
             {
                 AISTrackModel = aisTrackRepo.Get <AISTrack>(AISTrackId);
                 return(AISTrackModel);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }