/// <summary>
 /// Whether or not the present entity is identitical to <paramref name="other" />, in the sense that they have the same (set of) intrinsic identifiers.
 /// </summary>
 /// <param name="other">The entity to be compared to.</param>
 /// <returns>
 ///   The result of comparison.
 /// </returns>
 public bool IsEntityTheSame(SignalRMessage other)
 {
     if (other == null)
     {
         return(false);
     }
     else
     {
         return(TimeStamp == other.TimeStamp);
     }
 }
 /// <summary>
 /// Whether or not the present entity is identitical to <paramref name="other" />, in the sense that they have the same (set of) primary key(s).
 /// </summary>
 /// <param name="other">The entity to be compared to.</param>
 /// <returns>
 ///   The result of comparison.
 /// </returns>
 public bool IsEntityIdentical(SignalRMessage other)
 {
     if (other == null)
     {
         return(false);
     }
     if (ID != other.ID)
     {
         return(false);
     }
     return(true);
 }
 /// <summary>
 /// Merge changes inside entity <paramref name="from" /> to the entity <paramref name="to" />. Any changes in <paramref name="from" /> that is not changed in <paramref name="to" /> is updated inside <paramref name="to" />.
 /// </summary>
 /// <param name="from">The "old" entity acting as merging source.</param>
 /// <param name="to">The "new" entity which inherits changes made in <paramref name="from" />.</param>
 /// <returns>
 /// </returns>
 public static void MergeChanges(SignalRMessage from, SignalRMessage to)
 {
     if (to.IsPersisted)
     {
     }
     else
     {
         to.IsPersisted   = from.IsPersisted;
         to.ID            = from.ID;
         to.MesssageData  = from.MesssageData;
         to.TimeStamp     = from.TimeStamp;
         to.ApplicationID = from.ApplicationID;
     }
 }
        /// <summary>
        /// Internal use
        /// </summary>
        public SignalRMessage ShallowCopy(bool allData = false, bool preserveState = false, bool checkLoadState = false)
        {
            SignalRMessage e = new SignalRMessage();

            e.StartAutoUpdating = false;
            e.ID             = ID;
            e.MesssageData   = MesssageData;
            e.TimeStamp      = TimeStamp;
            e.ApplicationID  = ApplicationID;
            e.DistinctString = GetDistinctString(true);
            e.IsPersisted    = IsPersisted;
            if (preserveState)
            {
                e.IsEntityChanged = IsEntityChanged;
            }
            else
            {
                e.IsEntityChanged = false;
            }
            e.StartAutoUpdating = true;
            return(e);
        }
        private void SendMessageThread()
        {
            IList<Message> msgs;
            var cntx = Cntx;
            var set = new SignalRMessageSet();
            var msgsvc = new SignalRMessageServiceProxy();
            while (!CancelSendOperation.IsCancellationRequested)
            {
                msgs = MessageQueue.Take(CancelSendOperation);
                if (msgs != null && !CancelSendOperation.IsCancellationRequested)
                {
                    SignalRMessage entity = new SignalRMessage
                    {
                        ApplicationID = config.App.ID,
                        TimeStamp = DateTime.UtcNow.Ticks,
                        MesssageData = (new ScaleoutMessage(msgs)).ToBytes()
                    };
                    try
                    {
                        msgsvc.AddOrUpdateEntities(cntx, set, new SignalRMessage[] { entity });
                        lastSent = DateTime.Now;
                    }
                    catch
                    {

                    }
                }
            }
        }
 /// <summary>
 /// Internal use
 /// </summary>
 public SignalRMessage ShallowCopy(bool allData = false, bool preserveState = false)
 {
     SignalRMessage e = new SignalRMessage();
     e.StartAutoUpdating = false;
     e.ID = ID;
     e.MesssageData = MesssageData;
     e.TimeStamp = TimeStamp;
     e.ApplicationID = ApplicationID;
     e.DistinctString = GetDistinctString(true);
     e.IsPersisted = IsPersisted;
     if (preserveState)
         e.IsEntityChanged = IsEntityChanged;
     else
         e.IsEntityChanged = false;
     e.StartAutoUpdating = true;
     return e;
 }
 /// <summary>
 /// Update changes to the current entity compared to an input <paramref name="newdata" /> and set the entity to a proper state for updating.
 /// </summary>
 /// <param name="newdata">The "new" entity acting as the source of the changes, if any.</param>
 /// <returns>
 /// </returns>
 public void UpdateChanges(SignalRMessage newdata)
 {
     int cnt = 0;
     IsEntityChanged = cnt > 0;
 }
 /// <summary>
 /// Merge changes inside entity <paramref name="from" /> to the entity <paramref name="to" />. Any changes in <paramref name="from" /> that is not changed in <paramref name="to" /> is updated inside <paramref name="to" />.
 /// </summary>
 /// <param name="from">The "old" entity acting as merging source.</param>
 /// <param name="to">The "new" entity which inherits changes made in <paramref name="from" />.</param>
 /// <returns>
 /// </returns>
 public static void MergeChanges(SignalRMessage from, SignalRMessage to)
 {
     if (to.IsPersisted)
     {
     }
     else
     {
         to.IsPersisted = from.IsPersisted;
         to.ID = from.ID;
         to.MesssageData = from.MesssageData;
         to.TimeStamp = from.TimeStamp;
         to.ApplicationID = from.ApplicationID;
     }
 }
 /// <summary>
 /// Whether or not the present entity is identitical to <paramref name="other" />, in the sense that they have the same (set of) intrinsic identifiers.
 /// </summary>
 /// <param name="other">The entity to be compared to.</param>
 /// <returns>
 ///   The result of comparison.
 /// </returns>
 public bool IsEntityTheSame(SignalRMessage other)
 {
     if (other == null)
         return false;
     else
         return TimeStamp == other.TimeStamp;
 }              
 /// <summary>
 /// Whether or not the present entity is identitical to <paramref name="other" />, in the sense that they have the same (set of) primary key(s).
 /// </summary>
 /// <param name="other">The entity to be compared to.</param>
 /// <returns>
 ///   The result of comparison.
 /// </returns>
 public bool IsEntityIdentical(SignalRMessage other)
 {
     if (other == null)
         return false;
     if (ID != other.ID)
         return false;
     return true;
 }              
        /// <summary>
        /// Update changes to the current entity compared to an input <paramref name="newdata" /> and set the entity to a proper state for updating.
        /// </summary>
        /// <param name="newdata">The "new" entity acting as the source of the changes, if any.</param>
        /// <returns>
        /// </returns>
        public void UpdateChanges(SignalRMessage newdata)
        {
            int cnt = 0;

            IsEntityChanged = cnt > 0;
        }