public void Destroy(int id
                            )
        {
            try
            {
                SessionInitializeTransaction();
                NotificationEN notificationEN = (NotificationEN)session.Load(typeof(NotificationEN), id);
                session.Delete(notificationEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is MoSIoTGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in NotificationCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
        public NotificationEN ReadOIDDefault(int id
                                             )
        {
            NotificationEN notificationEN = null;

            try
            {
                SessionInitializeTransaction();
                notificationEN = (NotificationEN)session.Get(typeof(NotificationEN), id);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is MoSIoTGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in NotificationCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(notificationEN);
        }
        public void Modify(NotificationEN notification)
        {
            try
            {
                SessionInitializeTransaction();
                NotificationEN notificationEN = (NotificationEN)session.Load(typeof(NotificationEN), notification.Id);

                notificationEN.Severity = notification.Severity;


                notificationEN.Message = notification.Message;


                notificationEN.SendDate = notification.SendDate;

                session.Update(notificationEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is MoSIoTGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in NotificationCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
        public int New_(NotificationEN notification)
        {
            try
            {
                SessionInitializeTransaction();

                session.Save(notification);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is MoSIoTGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in NotificationCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(notification.Id);
        }
        private void AssertNotificationExists(long receiverUserID, EntityEnums.NotificationTemplateEnum template)
        {
            DateTime             afewSecondsAgoDate  = DateTime.UtcNow.AddSeconds(-30);
            INotificationService notificationService = NotificationEN.GetService();
            FilterExpression     nFilter             = new FilterExpression();

            nFilter.AddFilter(new Filter(vNotification.ColumnNames.ReceiverUserID, receiverUserID));
            nFilter.AddFilter(new Filter(vNotification.ColumnNames.NotificationTemplateID, (int)template));
            nFilter.AddFilter(new Filter(vNotification.ColumnNames.InsertDate, afewSecondsAgoDate, FilterOperatorEnum.GreaterThan));
            List <Notification> notificationsList = (List <Notification>)notificationService.GetByFilter(new GetByFilterParameters(nFilter));

            Assert.IsTrue(notificationsList.Count > 0, "notificationsList.Count should be 1. One notification should be sent for emailing to user");
        }
        public void Modify(int p_Notification_OID, MoSIoTGenNHibernate.Enumerated.MosIoT.SeverityEventEnum p_severity, string p_message, Nullable <DateTime> p_sendDate)
        {
            NotificationEN notificationEN = null;

            //Initialized NotificationEN
            notificationEN          = new NotificationEN();
            notificationEN.Id       = p_Notification_OID;
            notificationEN.Severity = p_severity;
            notificationEN.Message  = p_message;
            notificationEN.SendDate = p_sendDate;
            //Call to NotificationCAD

            _INotificationCAD.Modify(notificationEN);
        }
        public int New_(MoSIoTGenNHibernate.Enumerated.MosIoT.SeverityEventEnum p_severity, string p_message, Nullable <DateTime> p_sendDate)
        {
            NotificationEN notificationEN = null;
            int            oid;

            //Initialized NotificationEN
            notificationEN          = new NotificationEN();
            notificationEN.Severity = p_severity;

            notificationEN.Message = p_message;

            notificationEN.SendDate = p_sendDate;

            //Call to NotificationCAD

            oid = _INotificationCAD.New_(notificationEN);
            return(oid);
        }
Esempio n. 8
0
        public static NotificationEN Convert(NotificationDTO dto)
        {
            NotificationEN newinstance = null;

            try
            {
                if (dto != null)
                {
                    newinstance = new NotificationEN();



                    newinstance.Severity = dto.Severity;
                    newinstance.Message  = dto.Message;
                    newinstance.SendDate = dto.SendDate;
                    if (dto.Receivers_oid != null)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IUserCAD userCAD = new MoSIoTGenNHibernate.CAD.MosIoT.UserCAD();

                        newinstance.Receivers = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.UserEN>();
                        foreach (string entry in dto.Receivers_oid)
                        {
                            newinstance.Receivers.Add(userCAD.ReadOIDDefault(entry));
                        }
                    }
                    if (dto.CarePlan_oid != -1)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.ICarePlanCAD carePlanCAD = new MoSIoTGenNHibernate.CAD.MosIoT.CarePlanCAD();

                        newinstance.CarePlan = carePlanCAD.ReadOIDDefault(dto.CarePlan_oid);
                    }
                    newinstance.Id = dto.Id;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(newinstance);
        }