public Notification[] GetNotifications(string notificationStateName, string startDateRangeString, string endDateRangeString)
        {
            //CheckHTTPBasicAuth();
            _Trace.TraceEvent(TraceEventType.Verbose, -1, "GetNotifications");

            string queryString = string.Format("it.State = '{0}'", notificationStateName);

            if (!string.IsNullOrEmpty(startDateRangeString))
            {
                DateTime startDateRange = DateTime.Parse(startDateRangeString);
                queryString += string.Format(" AND it.CreationTime > DATETIME'{0}'", startDateRange.ToString("yyyy-MM-dd hh:mm"));
            }
            if (!string.IsNullOrEmpty(endDateRangeString))
            {
                DateTime endDateRange = DateTime.Parse(endDateRangeString);
                queryString += string.Format(" AND it.CreationTime < DATETIME'{0}'", endDateRange.ToString("yyyy-MM-dd hh:mm"));
            }

            NotificationEntity[] entities = new CriticalResultsEntityManager().QueryNotificationEntity(queryString, null, null);
            List<Notification> results = new List<Notification>();

            foreach (NotificationEntity entity in entities)
            {
                Notification n = new Notification(entity);
                n.ResolveResult();
                n.Result.ResolveSender();
                n.ResolveUserTransport();
                n.UserTransport.ResolveTransport();
                n.UserTransport.ResolveUser();
                results.Add(n);
            }
            return results.ToArray() ;
        }
        public Notification[] GetResultNotifications(string resultUuid)
        {
            _Trace.TraceEvent(TraceEventType.Verbose, -1, "GetResultNotifications");

            Guid guid = new Guid(resultUuid);
            NotificationEntity[] entities = new CriticalResultsEntityManager().GetResultNotifications(guid);
            List<Notification> notifications = new List<Notification>();
            foreach (NotificationEntity entity in entities)
            {
                Notification n = new Notification(entity);
                n.ResolveUserTransport();
                n.UserTransport.ResolveTransport();
                notifications.Add(n);
            }
            return notifications.ToArray();
        }
 public Notification CreateResultNotification_Json(Notification notification, string selectedTransport)
 {
     return CreateResultNotification(notification, selectedTransport);
 }
        public Notification CreateResultNotification(Notification notification, string selectedTransport)
        {
            _Trace.TraceEvent(TraceEventType.Verbose, -1, "CreateResultNotification");

            CriticalResultsEntityManager crm = new CriticalResultsEntityManager();
            NotificationEntity e = new NotificationEntity();
            e.Notes = notification.Notes;
            e.CreationTime = DateTime.Now;
            e.State = notification.State;
            e.Result = crm.GetResultEntity(notification.Result.Uuid);
            e.UserTransport = crm.GetUserTransport(notification.Result.Receiver.UserName, selectedTransport);
            NotificationEntity ne = crm.CreateResultNotification(e);
            return new Notification(ne);
        }
        public Notification UpdateNotification(string notificationUuid, string state, string notes)
        {
            _Trace.TraceEvent(TraceEventType.Verbose, -1, "UpdateNotification");

            NotificationEntity e = new CriticalResultsEntityManager().UpdateNotificationEntity(new Guid(notificationUuid), state, notes);
            Notification n = new Notification(e);
            return n;
        }
 public Notification[] QueryNotifications(string queryString, int? pageSize, int? pageNumber)
 {
     NotificationEntity[] entities = new CriticalResultsEntityManager().QueryNotificationEntity(queryString, pageSize, pageNumber);
     List<Notification> results = new List<Notification>();
     foreach (NotificationEntity e in entities)
     {
         Notification n = new Notification(e);
     }
     return results.ToArray();
 }
        public bool ResolveNotifications()
        {
            if (_Entity == null)
                return false;
            if (_Entity.Notifications != null)
                return false;

            _Notifications = new List<Notification>();
            foreach (NotificationEntity e in _Entity.Notifications)
            {
                Notification notification = new Notification(e);
                _Notifications.Add(notification);
            }
            return true;
        }