コード例 #1
0
        public static PTMessage AddMessage(PTMessage message, byte[] imageData)
        {
            try
            {
                // add the message to the db, set message.ID, and return the message
                //TODO: default return values
                //TODO: handle video...
                using (PTLinkDatabaseDataContext db = new PTLinkDatabaseDataContext())
                {
                    Message dbMessage = new Message();
                    dbMessage.ContentTypeId = (from c in db.ContentTypes
                                               where c.Name == message.type
                                               select c.Id).SingleOrDefault();
                    dbMessage.ExerciseId = message.exerciseID;
                    dbMessage.PersonId = message.senderID;
                    dbMessage.ProtocolId = message.protocolID;
                    dbMessage.Timestamp = (long)message.timestamp;

                    if (imageData != null)
                    {
                        //TODO: handle images and video and such
                        dbMessage.Value = message.imageName;
                    }
                    else
                    {
                        dbMessage.Value = message.text;
                    }

                    db.Messages.InsertOnSubmit(dbMessage);
                    db.SubmitChanges();
                    message.ID = dbMessage.Id;
                }
                return message;
            }
            catch
            {
                return null;
            }
        }
コード例 #2
0
		private void detach_Messages(Message entity)
		{
			this.SendPropertyChanging();
			entity.ContentType = null;
		}
コード例 #3
0
 partial void UpdateMessage(Message instance);
コード例 #4
0
 partial void DeleteMessage(Message instance);
コード例 #5
0
 partial void InsertMessage(Message instance);
コード例 #6
0
		private void detach_Messages(Message entity)
		{
			this.SendPropertyChanging();
			entity.Protocol = null;
		}
コード例 #7
0
		private void attach_Messages(Message entity)
		{
			this.SendPropertyChanging();
			entity.Protocol = this;
		}
コード例 #8
0
		private void detach_Messages(Message entity)
		{
			this.SendPropertyChanging();
			entity.Exercise = null;
		}
コード例 #9
0
		private void attach_Messages(Message entity)
		{
			this.SendPropertyChanging();
			entity.Exercise = this;
		}