Пример #1
0
 /// <summary>
 /// Creates a message container
 /// </summary>
 /// <param name="msg">message data</param>
 public Message(NewsletterServer.Message msg, NewsletterEntities context)
 {
     Content = msg;
     objectContext = context;
     MessageDelivered += this.OnDelivery;
 }
 /// <summary>
 /// Create a new Message object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="date">Initial value of the date property.</param>
 /// <param name="newsletter">Initial value of the newsletter property.</param>
 /// <param name="subject">Initial value of the subject property.</param>
 /// <param name="text">Initial value of the text property.</param>
 /// <param name="clean_text">Initial value of the clean_text property.</param>
 /// <param name="status">Initial value of the status property.</param>
 public static Message CreateMessage(global::System.Int32 id, global::System.DateTime date, global::System.Int32 newsletter, global::System.String subject, global::System.String text, global::System.String clean_text, global::System.Byte status)
 {
     Message message = new Message();
     message.id = id;
     message.date = date;
     message.newsletter = newsletter;
     message.subject = subject;
     message.text = text;
     message.clean_text = clean_text;
     message.status = status;
     return message;
 }
        /// <inheritdoc />
        public bool QueueMessage(string subject, string body, string clean_body, string authKey)
        {
            if (!IsAuthenticatedKey(authKey)) {
                return false;
            }

            // Create a message entity and store it
            using (var context = new NewsletterEntities()) {

                var sessions = new SessionManager(context);
                var message = new Message();
                message.status = 3; // TODO DeliveryServer.TransferAgent.Message.StatusWaiting;
                message.text = body;
                message.clean_text = clean_body;
                message.subject = subject;
                message.newsletter = sessions.GetSession(authKey).NewsletterId;
                message.date = DateTime.Now;

                context.Messages.AddObject(message);

                // Persist changes
                context.SaveChanges();
            }

            return true;
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Messages EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMessages(Message message)
 {
     base.AddObject("Messages", message);
 }