Exemplo n.º 1
0
        /// <summary>
        ///  Map a DataTable's Rows to a List of MsgReceiver Entity.
        /// </summary>
        /// <returns></returns>
        public static IList <MsgReceiver> Row2Entity(System.Data.DataTable dt)
        {
            IList <MsgReceiver> list = null;

            if (dt != null && dt.Rows.Count > 0)
            {
                list = new List <MsgReceiver>(dt.Rows.Count);
                foreach (System.Data.DataRow row in dt.Rows)
                {
                    MsgReceiver entity = Row2Entity(row);
                    if (entity != null)
                    {
                        list.Add(entity);
                    }
                }
            }
            return(list);
        }
Exemplo n.º 2
0
        /// <summary>
        ///  Map a DataRow to a MsgReceiver Entity.
        /// </summary>
        /// <returns></returns>
        public static MsgReceiver Row2Entity(System.Data.DataRow row)
        {
            if (row == null)
            {
                return(null);
            }

            MsgReceiver entity = new MsgReceiver();

            entity._receiverId     = Cast.Int(row["MSG_RCV_ID"]);
            entity._messageId      = Cast.Int(row["MSG_ID"]);
            entity._userId         = Cast.Int(row["USR_ID"]);
            entity._subscriberType = Cast.Bool(row["MSG_RCV_TYPE"]);
            entity._sendTime       = Cast.DateTime(row["MSG_RCV_SEND_TIME"]);
            entity._receiveTime    = Cast.DateTime(row["MSG_RCV_TIME"]);
            entity._expireTime     = Cast.DateTime(row["MSG_RCV_EXPIRE_TIME"]);
            entity._readStatus     = Cast.Enum <MessageReadStatus>(row["MSG_RCV_STATUS"]);
            entity._note           = Cast.String(row["MSG_RCV_NOTE"]);

            return(entity);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 发送新消息
        /// </summary>
        /// <param name="session"></param>
        public static void SendNewMessage(ISession session)
        {
            IList <Message> newMsgs = session.CreateEntityQuery <Message>().And(Exp.Eq("Status", MessageStatus.New)).List <Message>();

            if (newMsgs != null && newMsgs.Count > 0)
            {
                ((Session)session).BeginTransaction();
                try
                {
                    foreach (Message msg in newMsgs)
                    {
                        IList <User> sendingUsers = MsgSubscriber.GetSendingUser4Subscriber(session, msg.TmplCode);
                        foreach (User user in sendingUsers)
                        {
                            MsgReceiver msgrev = new MsgReceiver();
                            msgrev.MessageId      = msg.MessageId;
                            msgrev.ReadStatus     = MessageReadStatus.Unread;
                            msgrev.SendTime       = msg.SendTime;
                            msgrev.SubscriberType = true;
                            msgrev.UserId         = user.UserId;
                            msgrev.ReceiveTime    = DateTime.Now;
                            msgrev.ExpireTime     = msg.ExpireTime;
                            msgrev.Create(session);
                        }
                        msg.Status = MessageStatus.Sent;
                        msg.Update(session, "Status");
                    }

                    ((Session)session).Commit();
                }
                catch
                {
                    ((Session)session).Rollback();
                    throw;
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 发送新消息
        /// </summary>
        /// <param name="session"></param>
        public static void SendNewMessage(ISession session)
        {
            IList<Message> newMsgs = session.CreateEntityQuery<Message>().And(Exp.Eq("Status", MessageStatus.New)).List<Message>();

            if (newMsgs != null && newMsgs.Count > 0)
            {

                ((Session)session).BeginTransaction();
                try
                {
                    foreach (Message msg in newMsgs)
                    {
                        IList<User> sendingUsers = MsgSubscriber.GetSendingUser4Subscriber(session, msg.TmplCode);
                        foreach (User user in sendingUsers)
                        {
                            MsgReceiver msgrev = new MsgReceiver();
                            msgrev.MessageId = msg.MessageId;
                            msgrev.ReadStatus = MessageReadStatus.Unread;
                            msgrev.SendTime = msg.SendTime;
                            msgrev.SubscriberType = true;
                            msgrev.UserId = user.UserId;
                            msgrev.ReceiveTime = DateTime.Now;
                            msgrev.ExpireTime = msg.ExpireTime;
                            msgrev.Create(session);
                        }
                        msg.Status = MessageStatus.Sent;
                        msg.Update(session, "Status");
                    }

                    ((Session)session).Commit();
                }
                catch
                {
                    ((Session)session).Rollback();
                    throw;
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///  Map a DataRow to a MsgReceiver Entity.
        /// </summary>
        /// <returns></returns>
        public static MsgReceiver Row2Entity(System.Data.DataRow row)
        {
            if(row == null) return null;

            MsgReceiver entity = new MsgReceiver();

            entity._receiverId= Cast.Int(row["MSG_RCV_ID"]);
            entity._messageId= Cast.Int(row["MSG_ID"]);
            entity._userId= Cast.Int(row["USR_ID"]);
            entity._subscriberType= Cast.Bool(row["MSG_RCV_TYPE"]);
            entity._sendTime= Cast.DateTime(row["MSG_RCV_SEND_TIME"]);
            entity._receiveTime= Cast.DateTime(row["MSG_RCV_TIME"]);
            entity._expireTime= Cast.DateTime(row["MSG_RCV_EXPIRE_TIME"]);
            entity._readStatus= Cast.Enum<MessageReadStatus>(row["MSG_RCV_STATUS"]);
            entity._note= Cast.String(row["MSG_RCV_NOTE"]);

               return entity;
        }