예제 #1
0
        private void TimeLine_Load(object sender, EventArgs e)
        {
            int index = 0;
            DataGridViewImageColumn status = new DataGridViewImageColumn();

            status.Name       = "image";
            status.HeaderText = "图片";
            status.Width      = 150;
            dataGridView1.Columns.Insert(2, status);

            int           a          = 0;
            ImageOP       imageOP    = new ImageOP();
            MessageDAO    messageDAO = new MessageDAO(new Database(Program.constr));
            List <MixMsg> arrayList  = messageDAO.GetData();

            int i = 0;

            while (i < arrayList.Count && a < 5)
            {
                index = this.dataGridView1.Rows.Add();
                MixMsg mx = arrayList[i];
                this.dataGridView1.Rows[index].Cells[0].Value = mx.Account;
                this.dataGridView1.Rows[index].Cells[1].Value = mx.Information;
                this.dataGridView1.Rows[index].Cells[2].Value = imageOP.GetImageByPath(mx.Image);
                this.dataGridView1.Rows[index].Cells[3].Value = mx.Time;
                i++;
                a++;
            }
            row   = a;
            lastn = a;
            dataGridView1.AllowUserToAddRows = false;
        }
예제 #2
0
        public static object GetNewMessages(int chatRoomId, int recieverId, int senderId)
        {
            var newMessages = MessageDAO.GetNewChatRoomMessages(chatRoomId, senderId);

            MessageDAO.SetMessageSeenStatus(chatRoomId, senderId);
            return(new { result = newMessages });
        }
예제 #3
0
        public async Task <MessageDAO> Create(MessageDAO MessageDAO)
        {
            MessageContext.Add(MessageDAO);
            await MessageContext.SaveChangesAsync();

            return(MessageDAO);
        }
 public MessageManager()
 {
     // NOTE: No errors with the methods even when I don't instantiate them. I think errors will happen when I run this without them.
     _dao            = new MessageDAO();
     _messageService = new MessageService();
     _errorHandler   = new ErrorController();
 }
예제 #5
0
        private void TimeLine_Load(object sender, EventArgs e)
        {
            int index = 0;
            DataGridViewImageColumn status = new DataGridViewImageColumn();

            status.Name       = "image";
            status.HeaderText = "图片";
            status.Width      = 150;
            dataGridView1.Columns.Insert(2, status);

            int           a          = 0;
            ImageOP       imageOP    = new ImageOP();
            Database      database   = new Database(Program.constr);
            MessageDAO    messageDAO = new MessageDAO(database);
            string        command    = "select account,information,image,time from infos natural join users order by time desc";
            IDataReader   reader     = database.GetReader(command);
            List <MixMsg> arrayList  = messageDAO.GetData(reader);

            int i = 0;

            while (i < arrayList.Count && a < 5)
            {
                index = this.dataGridView1.Rows.Add();
                MixMsg mx = arrayList[i];
                this.dataGridView1.Rows[index].Cells[0].Value = mx.Account;
                this.dataGridView1.Rows[index].Cells[1].Value = mx.Information;
                this.dataGridView1.Rows[index].Cells[2].Value = imageOP.GetImageByPath(mx.Image);
                this.dataGridView1.Rows[index].Cells[3].Value = mx.Time;
                i++;
                a++;
            }
            row   = a;
            lastn = a;
            dataGridView1.AllowUserToAddRows = false;
        }
예제 #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            string content = textBoxInput.Text.Trim();

            if (content == "")
            {
                MessageBox.Show("内容不能为空", "提示");
            }
            else
            {
                string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo);
                msg.Content = content;
                msg.Time    = time;
                MessageDAO messageDAO = new MessageDAO(new Database(Program.constr));
                if (messageDAO.InsertDataByUserAndMessage(Program.programUser, msg) == 1)
                {
                    MessageBox.Show("发表成功!", "提示");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("发表失败,请重新尝试!", "提示");
                }
            }
        }
        public void SendMessage(string inputText)
        {
            var channelId = SelectChannelService.SelectingChannelId;

            MessageDAO.SendMessage(inputText, channelId);
            ReadMessageService.RefleshMessageLog?.Invoke();
        }
        public void GetDataTest()
        {
            var    arrayList = new List <MixMsg>();
            MixMsg one       = new MixMsg();
            MixMsg two       = new MixMsg();
            MixMsg three     = new MixMsg();

            arrayList.Add(one);
            arrayList.Add(two);
            arrayList.Add(three);
            int count          = 0;
            var mockdb         = new Mock <IDatabase>();
            var messagedao     = new MessageDAO(mockdb.Object);
            var mockDatareader = new Mock <IDataReader>();

            mockDatareader.Setup(d => d.Read()).Returns(() => count < 3).Callback(() => count++);
            mockDatareader.Setup(r => r["user_id"]).Returns(() => arrayList[count - 1].Account);
            mockDatareader.Setup(r => r["information"]).Returns(() => arrayList[count - 1].Information);
            mockDatareader.Setup(r => r["image"]).Returns(() => arrayList[count - 1].Image);
            mockDatareader.Setup(r => r["time"]).Returns(() => arrayList[count - 1].Time);
            for (int i = 0; i < 3; i++)
            {
                //Assert.AreEqual(arrayList[i].Account, messagedao.GetData(mockDatareader.Object)[i].Account);
            }
        }
예제 #9
0
        public async Task <MessageDAO> Update(MessageDAO entity)
        {
            MessageContext.Update(entity);
            await MessageContext.SaveChangesAsync();

            return(entity);
        }
예제 #10
0
        public MessageDTO GetById(int id)
        {
            MessageDAO resultMessageDAO = MessageRepository.GetById(id).Result;
            MessageDTO resultMessageDTO = converter.fromDAOTodTO(resultMessageDAO);

            return(resultMessageDTO);
        }
예제 #11
0
        public MessageDTO Update(MessageDTO entity)
        {
            MessageDAO MessageDAO       = converter.fromDTOTodAO(entity);
            MessageDAO resultMessageDAO = MessageRepository.Update(MessageDAO).Result;
            MessageDTO resultMessageDTO = converter.fromDAOTodTO(resultMessageDAO);

            return(resultMessageDTO);
        }
예제 #12
0
        public static void Post(string text, User user, Channel channel, Message?parentMessage = null)
        {
            MessageDAO.Post(text, user.Id, channel.Id, parentMessage?.Id);

            onMessagesFetchedAsSubject.OnNext(Get(channel));

            onMessagePostedAsSubject.OnNext(Unit.Default);
        }
예제 #13
0
        public async Task <MessageDAO> Delete(int id)
        {
            MessageDAO MessageDAO = MessageContext.Messages.Find(id);

            MessageContext.Remove(id);
            await MessageContext.SaveChangesAsync();

            return(MessageDAO);
        }
예제 #14
0
 public ChatController(UserDAO _repos, ChatDAO _repos1, MessageDAO _repos3, IHubContext <ChatHub> hubContext, LogFactory _logFactory)
 {
     repos           = _repos;
     repos1          = _repos1;
     repos3          = _repos3;
     logFactory      = _logFactory;
     log             = logFactory.GetLogger();
     this.hubContext = hubContext;
 }
예제 #15
0
        public static IEnumerable <Message?> Get(Channel channel)
        {
            using var messageTable = MessageDAO.GetWithChannelId(channel.Id);

            var messages = messageTable.AsEnumerable()
                           .Select(x => MessageFactory.Create(x));

            return(messages);
        }
예제 #16
0
        public static int CountMessageUnread()
        {
            if (MessageDAO.getMessageUnread() == null)
            {
                return(0);
            }
            List <Messages> messages = MessageDAO.getMessageUnread().ToList();

            return(messages.Count);
        }
예제 #17
0
        public void getMessageById()
        {
            Message test = MessageDAO.getById(testId);

            Assert.NotNull(test);
            Assert.AreEqual(test.Id, testId);
            Assert.AreEqual(test.FromUserId, testInt);
            Assert.AreEqual(test.ToUserId, testInt);
            Assert.AreEqual(test.MessageContent, testStr);
            Assert.AreEqual(test.ItRead, testBool);
        }
 /// <summary>
 /// Retrieves the number of unew (nread) messages in an inbox
 /// </summary>
 /// <param name="receiverID"></param>
 /// <param name="isGeneral"></param>
 /// <returns></returns>
 public int GetNewCount(MessageDAO dao, int receiverID, bool isGeneral)
 {
     try
     {
         return(dao.GetCount(receiverID, isGeneral));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
예제 #19
0
        async private Task PeriodicRenewAsync()
        {
            while (true)
            {
                await Task.Delay(5000);

                if (MessageDAO.GetMaxMessageIdInChannel(SelectChannelService.SelectingChannelId) != MaxMessageId)
                {
                    ReadMessages(SelectChannelService.SelectingChannelId);
                }
            }
        }
 /// <summary>
 /// Retrieves the contents of a message. The contents consist of: previous message ID, sender ID, read status, sent date, and message body or invitation response (in this order)
 /// The receiver ID and message ID of a message are omitted from the query because those are already known. Read status is also omitted because it will always be true in this case.
 /// </summary>
 /// <param name="receiverID">ID of the user who is retrieving messages from their inbox</param>
 /// <param name="messageID">ID of a message</param>
 /// <param name="isGeneral">Boolean value indicating whether a message is a general message or not</param>
 /// <returns>Contents of a message</returns>
 public IList <string> ReadMessage(MessageDAO dao, int receiverID, int messageID, bool isGeneral)
 {
     try
     {
         List <string> messageContent = (List <string>)dao.ReadMessageFromDB(receiverID, messageID, isGeneral);
         return(messageContent);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
예제 #21
0
        public void RemoveMessageTest()
        {
            MessageDAO target = new MessageDAO();
            PlayerDAO  player = new PlayerDAO();

            Message message = CreateMessage();

            target.InsertMessage(message);
            List <Message> inserted = target.GetMessagesFrom(playerFrom.PlayerName);

            target.RemoveMessage(inserted[0].MessageId);
            Assert.IsNull(target.GetMessage(inserted[0].MessageId));
        }
예제 #22
0
        public void GetMessagesToPlayerTest()
        {
            MessageDAO target = new MessageDAO();
            PlayerDAO  player = new PlayerDAO();

            Message message = CreateMessage();

            target.InsertMessage(message);
            List <Message> inserted = target.GetMessagesToPlayer(playerTo.PlayerId);

            Assert.IsTrue(inserted.Count == 1);
            target.RemoveMessage(inserted[0].MessageId);
        }
예제 #23
0
        public static List <MessageDto> GetAllMessage()
        {
            List <MessageDto> MessDto = new List <MessageDto>();

            if (MessageDAO.getAllMessage() == null)
            {
                return(null);
            }
            List <Messages> messages = MessageDAO.getAllMessage().ToList();

            MessDto = Common.ConvertToMessageDto(messages);

            return(MessDto);
        }
        public override void Run()
        {
            object[]       d = (object[])data.Data;
            string         conversationId = (string)d[0];
            int            offset         = (int)d[1];
            int            limit          = (int)d[2];
            List <Message> list           = new MessageDAO().GetMessagesByConversationId(conversationId, offset, limit);

            if (list != null)
            {
                worker.send(new SocketData("MESSAGELIST", list));
                worker.From        = limit;
                worker.MessageList = new MessageDAO().GetAllMessagesByConversationId(conversationId);
            }
        }
예제 #25
0
    public void TestGetMessages()
    {
        MessageDAO messageDAO = new MessageDAO();
        messageDAO.AddMessage("pepe34", "pepe24", "aaaaaaa", true);
         	/*
        Entidades.Message message2 = messageDAO.AddMessage("pepe", "pepe2", "chau2", false);
        Entidades.Message message3 = messageDAO.AddMessage("pepe", "pepe2", "chau2", false);

        List<Entidades.Message> messagesTrue = MessageService.GetMessages("pepe2", true);
        List<Entidades.Message> messagesFalse = MessageService.GetMessages("pepe2", false);

        Assert.Equal(messagesTrue.Count, 1);
        Assert.Equal(messagesFalse.Count, 2);
        */
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    User sUser = (User)Session["user"];

                    if (sUser == null)
                    {
                        Response.Redirect("~/Login");
                        Context.ApplicationInstance.CompleteRequest();
                    }

                    string idstr = Request["Id"];

                    if (String.IsNullOrEmpty(idstr)) //new Message
                    {
                        btnBorrar.Visible = false;
                        lblId.Visible     = false;
                        boxID.Visible     = false;
                    }
                    else
                    {
                        Message msg = MessageDAO.GetMessage(int.Parse(idstr));

                        if (msg != null)
                        {
                            boxID.Enabled          = false;
                            boxID.Text             = idstr;
                            boxNombre.Text         = msg.Name;
                            boxEmail.Text          = msg.Email;
                            boxAsunto.Text         = msg.Subject;
                            boxContenido.InnerText = msg.Content;
                        }
                    }

                    Context.ApplicationInstance.CompleteRequest();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.StackTrace);
                Debug.WriteLine(ex.Message);
            }
        }
예제 #27
0
        public static void handleDatabaseTableCaller(SqlConnection connection,
                                                     SqlCommand command,
                                                     SqlTransaction transaction,
                                                     HL7Message hl7Message,
                                                     DatabaseTable databaseTable,
                                                     string hl7Input,
                                                     HL7Broker.Model.Socket socket,
                                                     out int identity)
        {
            // set to negative one
            identity = -1;

            switch (databaseTable.id)
            {
            case APP_MESSAGE_HEADER_INSTANCE:
                identity = MessageHeaderInstanceDAO.insertIntoMessageHeaderInstance(
                    connection,
                    command,
                    transaction);
                break;

            case APP_MESSAGE:
                identity = MessageDAO.insertIntoMessage(
                    connection,
                    command,
                    transaction);

                // get the type of log we are suppose to log
                MessageLogDAO.MessageLogType logType
                    = handleAcknowledgement(hl7Message, hl7Input, identity, socket);

                // pass it to the message log so we can log it
                handleMessageLog(hl7Message, hl7Input, identity, logType);

                // update the app broker stats
                handleUpdateBrokerStats(identity, socket);
                break;

            default:
                break;
            }
        }
예제 #28
0
        protected void btnEnviarMensaje_Click(object sender, EventArgs e)
        {
            try
            {
                Message msg = new Message();

                msg.Name    = (string)txtNombre.Text;
                msg.Email   = (string)txtEmail.Text;
                msg.Subject = (string)txtAsunto.Text;
                msg.Content = (string)txtContenido.InnerText;

                MessageDAO.AddMessage(msg);

                ltMsg.Text  = "<br/>";
                ltMsg.Text += "Mensaje enviado";
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.StackTrace);
                Debug.WriteLine(ex.Message);
            }
        }
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            string idstr = boxID.Text;

            Debug.WriteLine("ID AL wardar: " + idstr);

            try
            {
                if (String.IsNullOrEmpty(idstr)) //new
                {
                    Message msg = new Message();
                    msg.Name    = boxNombre.Text;
                    msg.Email   = boxEmail.Text;
                    msg.Subject = boxAsunto.Text;
                    msg.Content = boxContenido.InnerText;

                    MessageDAO.AddMessage(msg);
                }
                else //update
                {
                    Message msg = new Message();
                    msg.Id      = int.Parse(idstr);
                    msg.Name    = boxNombre.Text;
                    msg.Email   = boxEmail.Text;
                    msg.Subject = boxAsunto.Text;
                    msg.Content = boxContenido.InnerText;

                    MessageDAO.ModMessage(msg);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.StackTrace);
                Debug.WriteLine(ex.Message);
            }

            Response.Redirect("~/MessageList");
            Context.ApplicationInstance.CompleteRequest();
        }
예제 #30
0
        public static void SendMessage(string?text)
        {
            var message = new Message();

            var currentChannel = ChannelService.CurrentChannel;

            if (currentChannel == null && text == "")
            {
                return;
            }

            message.ChannelId         = currentChannel.Id;
            message.User              = LoginService.LoginService.LoginUser;
            message.Text              = text;
            message.Time              = DateTime.Now;
            message.ParentMessageId   = ReplyMessage.Id;
            message.DisplaysToChannel = true;

            MessageDAO.SendMessage(message);

            MessageSent?.Invoke();
        }
예제 #31
0
        public static Message?Create(DataRow dataRow)
        {
            var channelDataRows = ChannelDAO.Get(dataRow.Field <int>("channel_id")).Rows;

            if (channelDataRows.Count is 0)
            {
                return(null);
            }

            var userDataRows = UserDAO.GetWithId(dataRow.Field <int>("user_id")).Rows;

            if (userDataRows.Count is 0)
            {
                return(null);
            }

            var parentMessageId = dataRow.Field <object>("parent_message_id");

            Message?parentMessage = null;

            if (parentMessageId != null)
            {
                var MessageDataRows = MessageDAO.GetWithId((int)parentMessageId).Rows;
                if (MessageDataRows.Count is 0)
                {
                    return(null);
                }

                parentMessage = Create(MessageDataRows[0]);
            }

            return(new Message(
                       dataRow.Field <int>("id"),
                       ChannelFactory.Create(channelDataRows[0]),
                       UserFactory.Create(userDataRows[0]),
                       dataRow.Field <string>("text"),
                       dataRow.Field <DateTime>("time"),
                       parentMessage));
        }
예제 #32
0
 public static List<Entidades.Message> GetMessages(string username, bool isPrivate)
 {
     MessageDAO messageDAO = new MessageDAO();
     List<Entidades.Message> messages = messageDAO.GetMessages(username, isPrivate);
     return messages;
 }
예제 #33
0
 public static void AddMessage(Entidades.Message message)
 {
     MessageDAO messageDAO = new MessageDAO();
     messageDAO.AddMessage(message);
 }
예제 #34
0
 public static Entidades.Message GetMessageById(int Id)
 {
     MessageDAO messageDAO = new MessageDAO();
     return messageDAO.GetMessageById(Id);
 }
예제 #35
0
 public static void DeleteMessageById(int id)
 {
     MessageDAO messageDAO = new MessageDAO();
     messageDAO.DeleteMessageById(id);
 }
예제 #36
0
 public static void DeleteMessage(Entidades.Message message)
 {
     MessageDAO messageDAO = new MessageDAO();
     messageDAO.DeleteMessage(message);
 }
예제 #37
0
 public static Entidades.Message AddMessage(string sender, string receiver, string messageText, bool isPrivate)
 {
     MessageDAO messageDAO = new MessageDAO();
     return messageDAO.AddMessage(sender, receiver, messageText, isPrivate);
 }