Example #1
0
        public List <FencesModel> GetAllFances()
        {
            var lstFences = new List <FencesModel>();
            var getFences = FencesManager.GetByUserId(Membership.GetUser().ProviderUserKey.ToString());

            foreach (var item in getFences)
            {
                lstFences.Add(new FencesModel
                {
                    //FencesTypeId= item.TypeId?? 0,
                    FencesId         = item.FencesId,
                    FencesName       = item.FencesName,
                    FencesCoordinate = item.FencesCoordinate,
                    IsPublic         = item.IsPublic,
                    Details          = item.Details,
                    Status           = item.Status,
                    Zoom             = item.Zoom,
                    CreatedBy        = item.CreatedBy,
                    CreatedDate      = item.CreatedDate,
                    UpdatedBy        = item.UpdatedBy,
                    UpdatedDate      = item.UpdatedDate,
                });
            }
            return(lstFences);//FencesManager.GetByUserName(User.Identity.Name);
        }
Example #2
0
        public void DeleteFences(int id)
        {
            var item = FencesManager.GetById(id);

            item.Status    = false;
            item.UpdatedBy = Membership.GetUser().ProviderUserKey.ToString();
            FencesManager.Save(item);
        }
Example #3
0
        public int AddFence(GeoFence fence)
        {
            var f = FencesManager.GetById(fence.FencesId);

            f.FencesName       = fence.FencesName;
            f.FencesCoordinate = fence.FencesCoordinate;

            //f.GeoFenceTypes = FencesManager.GetFencesTypeById(Convert.ToInt32(fence.TempTypeId)) ;
            f.Details  = fence.Details;
            f.IsPublic = fence.IsPublic;
            f.Zoom     = fence.Zoom;
            if (f.FencesId == 0)
            {
                f.CreatedBy = Membership.GetUser().ProviderUserKey.ToString();
                f.Status    = true;
            }

            f.UpdatedBy = Membership.GetUser().ProviderUserKey.ToString();
            FencesManager.Save(f);
            return(f.FencesId); //????
        }
Example #4
0
        private void timer_Elapsed(object sender, EventArgs e)
        {
            timer.Stop();

            var logs = LocationMessageAlertsManager.GetLogs();

            foreach (var log in logs) //Lopp through then each location log
            {
                var fences = FencesManager.GetAll();
                foreach (var fence in fences)
                {
                    var a = fence.FencesId;

                    //var jsons = "{lat:28.589611097714087, lg:77.11919783963822},{lat:28.600161714673284, lg:77.1233177126851},{lat:28.604683083437216, lg:77.13155745877884},{lat:28.596695200206437, lg:77.14614867581986},{lat:28.59368074686057, lg:77.1562766970601},{lat:28.59111839354537, lg:77.16297149076127},{lat:28.58508908056065, lg:77.14992522611283},{lat:28.584184653792438, lg:77.13636397733353},{lat:28.584033915241474, lg:77.12675094022416}";
                    var jsons = fence.FencesCoordinate;

                    var latMatchCol = Regex.Matches(jsons, latExp);
                    var lgMatchCol  = Regex.Matches(jsons, lgExp);

                    var locs = new List <Loc>();
                    for (int i = 0; i < latMatchCol.Count; i++)
                    {
                        var l = latMatchCol[i].Value.Split(':')[1];
                        var g = lgMatchCol[i].Value.Split(':')[1];
                        locs.Add(new Loc {
                            Lt = Convert.ToDouble(l), Lg = Convert.ToDouble(g)
                        });
                    }

                    for (int i = 0; i < lgMatchCol.Count; i++)
                    {
                        var l = lgMatchCol[i].Value.Split(':')[1];
                        var g = lgMatchCol[i].Value.Split(':')[1];
                        locs.Add(new Loc {
                            Lt = Convert.ToDouble(l), Lg = Convert.ToDouble(g)
                        });
                    }

                    var IsPointInPolygon = ServiceHelper.IsPointInPolygon(locs, new Loc {
                        Lt = (double)log.Lat, Lg = (double)log.Lang
                    });

                    if (IsPointInPolygon == true)
                    {
                        //If already entered then go for next fences
                        if (AlertFiredManager.IsAlreadyEnterdInFences(log.TrackerId))
                        {
                            continue;
                        }
                        var groupAlert = GroupAlertManager.GetAllByFencesId(fence.FencesId);
                        foreach (var item in groupAlert)
                        {
                            var alert = AlertManager.GetById(item.AlertId);

                            if (alert.AlertOnGeofenceEnter ?? false)
                            {
                                //Get all user details and send mail
                                alertName = alert.AlertName;
                                message   = alert.Message;
                                SendAlertAndSaveInAlertLogTbl(fence.FencesId, log.MessageAlertId, item.AlertId, "onEnter");
                            }
                        }
                        //now inserting value in fired update table
                        var alrtFired = new AlertFired
                        {
                            TrackerId         = log.TrackerId,
                            MessageAlertId    = log.MessageAlertId,
                            LocationMessageId = log.LocationMessageId,
                            IsEnter           = true,
                            IsExit            = false,
                            Active            = true, //??????,
                            FenceId           = fence.FencesId
                        };
                        AlertFiredManager.Save(alrtFired);
                    }

                    else       //Ispointinpolygon==false
                    {
                        //var fired = AlertFiredManager.GetActiveEnterByTrackerId(log.TrackerId,Convert.ToInt32(log.LocationMessageId));
                        var fired = AlertFiredManager.GetActiveEnterByTrackerId(log.TrackerId);
                        if (fired == null)
                        {
                            continue;
                        }

                        var groupAlert = GroupAlertManager.GetAllByFencesId(fence.FencesId);
                        foreach (var item in groupAlert)
                        {
                            var alert = AlertManager.GetById(item.AlertId);

                            if (alert.AlertOnGeofenceLeave == true)
                            {
                                //get user details and send msg
                                alertName = alert.AlertName;
                                message   = alert.Message;
                                SendAlertAndSaveInAlertLogTbl(fence.FencesId, log.MessageAlertId, item.AlertId, "onExit");
                            }
                        }
                        //update values Active to false and is isexit and isenter to true in alertFired table;
                        AlertFiredManager.ProcessedAlertExitFired(fired.Id);
                    }
                }
                //update IsProccessed to true in LocationMessageAlert table.
                LocationMessageAlertsManager.UpdateByTrackerId(log.TrackerId);
            }
            timer.Start();
        }
        public void DoBindFances()
        {
            var Geo_Fance = FencesManager.GetAll();

            CollectionHelper.PopulateListControl(ddGeoFences, "FencesId", "FencesName", Geo_Fance);
        }
Example #6
0
        public void FencesBind()
        {
            var fences = FencesManager.GetByUserId(Membership.GetUser().ProviderUserKey.ToString());

            CollectionHelper.PopulateListControl(dlFences, "FencesId", "FencesName", fences);
        }
Example #7
0
        public void FencesBind()
        {
            var fences = FencesManager.GetAll();

            CollectionHelper.PopulateListControl(dlFences, "FencesId", "FencesName", fences);
        }
Example #8
0
 public GeoFence GetById(int id)
 {
     return(FencesManager.GetById(id));
 }