예제 #1
0
        public List <OfficerTaskDTO> GetOfficerHistoricalTasksFromDate(string officerMilitaryId, DateTime fromDate)
        {
            try
            {
                operationalDataContext = new STCOperationalDataContext();

                var         lstCompleted     = operationalDataContext.OfficerTaskStatus.Where(x => x.TaskStatusId != 1 && x.TaskStatusId != 2 && x.TaskStatusId != 3).ToList();
                List <long> completedTaskIDs = new List <long>();

                if (lstCompleted != null && lstCompleted.Count > 0)
                {
                    completedTaskIDs = lstCompleted.Select(x => x.OfficerTaskId ?? 0).ToList();
                }

                var lstChanged = operationalDataContext.OfficerTask.Where(x => x.OfficerMilitaryId == officerMilitaryId && x.CreateDate >= fromDate && !completedTaskIDs.Contains(x.OfficerTaskId)).Select(x => new OfficerTaskDTO()
                {
                    OfficerMilitaryId = x.OfficerMilitaryId,
                    Latitude          = x.Latitude ?? 0,
                    Longitude         = x.Longitude ?? 0,
                    OfficerTaskId     = x.OfficerTaskId,
                    TaskMessage       = x.TaskMessage,
                    TaskTime          = x.TaskTime ?? DateTime.Now,
                    UserId            = x.UserId ?? 0
                }).ToList();

                return(lstChanged);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
예제 #2
0
        public bool UpdateThreshold(int threshold)
        {
            try
            {
                operationalContext = new STCOperationalDataContext();

                var output = operationalContext.AssetStatusThresholds.FirstOrDefault();

                if (output == null)
                {
                    operationalContext.AssetStatusThresholds.Add(new AssetStatusThreshold {
                        Threshold = threshold
                    });
                }
                else
                {
                    output.Threshold = threshold;
                }

                return(operationalContext.SaveChanges() > 0);
            }
            catch
            {
                return(false);
            }
        }
예제 #3
0
        private List <OfficerTaskDTO> GetUpdated()
        {
            try
            {
                _operationDB = new STCOperationalDataContext();

                var lstChanged = _operationDB.OfficerTask.Where(x => x.IsNoticed == false).Select(x => new OfficerTaskDTO()
                {
                    OfficerMilitaryId = x.OfficerMilitaryId,
                    Latitude          = x.Latitude.HasValue ? x.Latitude.Value : 0,
                    Longitude         = x.Longitude.HasValue ? x.Longitude.Value : 0,
                    OfficerTaskId     = x.OfficerTaskId,
                    TaskMessage       = x.TaskMessage,
                    TaskTime          = x.TaskTime.HasValue ? x.TaskTime.Value : DateTime.Now,
                    UserId            = x.UserId.HasValue ? x.UserId.Value : 0
                }).ToList();

                return(lstChanged);
            }
            catch (Exception ex)
            {
            }

            return(null);
        }
 public void UpdateNoticed(List <UserUserControlDTO> changed)
 {
     _operationDB = new STCOperationalDataContext();
     foreach (var item in changed)
     {
         var entity = _operationDB.UsersUserControls.FirstOrDefault(x => x.UserUserControlsID == item.UserUserControlsID);
         entity.IsNoticed = true;
     }
     _operationDB.SaveChanges();
 }
예제 #5
0
 public void UpdateNoticed(List <ViolationNotificationDTO> changed)
 {
     _operationDB = new STCOperationalDataContext();
     foreach (var item in changed)
     {
         var entity = _operationDB.ViolationNotifications.FirstOrDefault(x => x.ViolationNotificationId == item.ViolationNotificationId);
         entity.IsNoticed = true;
     }
     _operationDB.SaveChanges();
 }
        public void UpdateChanged(List <AssetLastStatusDTO> changed)
        {
            _operationDB = new STCOperationalDataContext();

            foreach (var item in changed)
            {
                var entity = _operationDB.AssetLastStatus.FirstOrDefault(x => x.AssetLastStatusId == item.AssetLastStatusId);
                entity.IsNoticed = true;
            }
            _operationDB.SaveChanges();
        }
        public void UpdateChanged(List <VehicleLiveTrackingDTO> changed)
        {
            _operationDB = new STCOperationalDataContext();

            foreach (var item in changed)
            {
                var entity = _operationDB.VehicleLiveTrackings.FirstOrDefault(x => x.Id == item.Id);
                entity.IsNoticed = true;
            }
            _operationDB.SaveChanges();
        }
예제 #8
0
        public int GetThreshold()
        {
            try
            {
                operationalContext = new STCOperationalDataContext();

                var threshold = operationalContext.AssetStatusThresholds.Select(x => x.Threshold).FirstOrDefault();

                return(threshold ?? 24);
            }
            catch
            {
                return(24);
            }
        }
예제 #9
0
        public bool UpdateVitronicStatus()
        {
            try
            {
                operationalContext = new STCOperationalDataContext();
                string baseURL   = ConfigurationManager.AppSettings["VitronicPath"];
                int    threshold = GetThreshold();

                var ourDevices = operationalContext.Assets.Where(x => x.AssetTypeId == 3).ToList();
                var devices    = Directory.GetDirectories(baseURL);

                if (devices != null && devices.Length > 0 && ourDevices != null && ourDevices.Count > 0)
                {
                    var devicesList = devices.ToList();
                    foreach (var ourDevice in ourDevices)
                    {
                        var device = devicesList.FirstOrDefault(x => x.Split('\\').Last() == ourDevice.SerialNo.Trim());

                        if (device != null)
                        {
                            DateTime lastUpdate = Directory.GetLastWriteTime(device);
                            ourDevice.LastUpdated = lastUpdate;

                            if (lastUpdate.AddHours(threshold) < DateTime.Now)
                            {
                                ourDevice.AssetStatusId = 2;
                            }
                            else
                            {
                                ourDevice.AssetStatusId = 1;
                            }
                        }
                        else
                        {
                            ourDevice.AssetStatusId = 2;
                        }

                        operationalContext.SaveChanges();
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
예제 #10
0
        public void UpdateChanged(List <IncidentsDTO> changed)
        {
            try
            {
                _operationDB = new STCOperationalDataContext();

                foreach (var item in changed)
                {
                    var entity = _operationDB.Incident.FirstOrDefault(x => x.IncidentId == item.IncidentId);
                    entity.IsNoticed = true;
                }
                _operationDB.SaveChanges();
            }
            catch (Exception ex)
            {
            }
        }
예제 #11
0
        public bool UpdatePatrolCurrentTask(Guid patrolOriginalId, long taskId)
        {
            try
            {
                operationalContext = new STCOperationalDataContext();

                var patrol = operationalContext.Patrols.Where(p => p.PatrolOriginalId == patrolOriginalId).FirstOrDefault();

                if (patrol != null)
                {
                    patrol.CurrentTaskId = taskId;
                }

                return(operationalContext.SaveChanges() > 0);
            }
            catch (Exception ex)
            {
                Utility.WriteLog(ex);
                return(false);
            }
        }
예제 #12
0
        public void UpdateChanged(List <OfficerTaskDTO> changed)
        {
            try
            {
                _operationDB = new STCOperationalDataContext();

                foreach (var item in changed)
                {
                    var entity = _operationDB.OfficerTask.FirstOrDefault(x => x.OfficerTaskId == item.OfficerTaskId);

                    if (entity != null)
                    {
                        entity.IsNoticed = true;
                    }
                }

                _operationDB.SaveChanges();
            }
            catch (Exception ex)
            {
            }
        }
예제 #13
0
        private List <SmartOfficerNewsDTO> GetUpdated()
        {
            try
            {
                _operationDB = new STCOperationalDataContext();

                var lstChanged = _operationDB.SmartOfficerNews.Where(x => x.IsNoticed == false).Select(x => new SmartOfficerNewsDTO()
                {
                    OfficerNewsId        = x.OfficerNewsId,
                    OfficerNewsText      = x.OfficerNewsText,
                    OfficerNewsImage     = x.OfficerNewsImage,
                    OfficerNewsDate      = x.OfficerNewsDate ?? DateTime.Now,
                    OfficerNewsCreatedBy = x.OfficerNewsCreatedBy ?? 0,
                    IsNoticed            = x.IsNoticed ?? false
                }).ToList();

                return(lstChanged);
            }
            catch (Exception ex)
            {
                Utility.WriteLog(ex);
                return(null);
            }
        }
예제 #14
0
        public List <OfficerTaskDTO> GetOfficerPendingTasks(string officerMilitaryId)
        {
            try
            {
                operationalDataContext = new STCOperationalDataContext();

                var lstChanged = operationalDataContext.OfficerTask.Where(x => x.OfficerMilitaryId == officerMilitaryId && x.IsNoticed == false).Select(x => new OfficerTaskDTO()
                {
                    OfficerMilitaryId = x.OfficerMilitaryId,
                    Latitude          = x.Latitude ?? 0,
                    Longitude         = x.Longitude ?? 0,
                    OfficerTaskId     = x.OfficerTaskId,
                    TaskMessage       = x.TaskMessage,
                    TaskTime          = x.TaskTime ?? DateTime.Now,
                    UserId            = x.UserId ?? 0
                }).ToList();

                return(lstChanged);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        public bool SaveUserControl(string xmlToSend, List <string> usernames)
        {
            var db        = new STCOperationalDataContext();
            var userEvent = new UsersUserControl
            {
                XML                  = xmlToSend,
                IsNoticed            = false,
                UserUserControlUsers = new List <UserUserControlUser>()
            };

            foreach (var item in usernames)
            {
                var user = db.Users.Where(x => x.UserName == item).FirstOrDefault();
                if (user != null)
                {
                    userEvent.UserUserControlUsers.Add(new UserUserControlUser()
                    {
                        UserId = user.UserId
                    });
                }
            }
            db.UsersUserControls.Add(userEvent);
            return(db.SaveChanges() > 0);
        }
예제 #16
0
 public MobileDAL()
 {
     _dBContext = new STCOperationalDataContext();
 }
예제 #17
0
 public TokenDAL()
 {
     _dBContext = new STCOperationalDataContext();
 }
예제 #18
0
        //private CDSAssetsDataContext cdsAssetsDataContext = new CDSAssetsDataContext();


        public UsersDAL()
        {
            operationalDataContext = new STCOperationalDataContext();
        }