Пример #1
0
        /// <summary>
        /// Creates the entity object.
        /// </summary>
        /// <param name="metaClassName">Name of the meta class.</param>
        /// <param name="primaryKeyId">The primary key id.</param>
        /// <returns></returns>
        protected override EntityObject CreateEntityObject(string metaClassName, PrimaryKeyId?primaryKeyId)
        {
            if (metaClassName == IbnClientMessageEntity.ClassName)
            {
                IbnClientMessageEntity retVal = new IbnClientMessageEntity();
                retVal.PrimaryKeyId = primaryKeyId;
                return(retVal);
            }

            return(base.CreateEntityObject(metaClassName, primaryKeyId));
        }
Пример #2
0
        /// <summary>
        /// Creates the entity object.
        /// </summary>
        /// <param name="metaClassName">Name of the meta class.</param>
        /// <param name="primaryKeyId">The primary key id.</param>
        /// <returns></returns>
        protected override EntityObject CreateEntityObject(string metaClassName, PrimaryKeyId? primaryKeyId)
        {
            if (metaClassName == IbnClientMessageEntity.ClassName)
            {
                IbnClientMessageEntity retVal = new IbnClientMessageEntity();
                retVal.PrimaryKeyId = primaryKeyId;
                return retVal;
            }

            return base.CreateEntityObject(metaClassName, primaryKeyId);
        }
        /// <summary>
        /// Invokes this instance.
        /// </summary>
        public override void Invoke()
        {
            // Remove Expired
            RemoveExpiredMessages();

            //int maxDeliveryAttempts = 100; // TODO: Read From Config

            EntityObject[] elements = BusinessManager.List(OutgoingMessageQueueEntity.ClassName,
                                                           OutgoingMessageUtil.CreateIbnClientMessageDeliveryProviderFilters(),
                                                           new SortingElement[]
            {
                SortingElement.Ascending(OutgoingMessageQueueEntity.FieldCreated)
            });

            foreach (OutgoingMessageQueueEntity element in elements)
            {
                try
                {
                    // Load Ibn Message
                    IbnClientMessageEntity message = (IbnClientMessageEntity)BusinessManager.Load(IbnClientMessageEntity.ClassName, element.IbnClientMessageId.Value);

                    // Send
                    int toOriginalId   = DBUser.GetOriginalId(message.ToId);
                    int fromOriginalId = DBUser.GetOriginalId(message.FromId);

                    IMHelper.SendMessage(toOriginalId, fromOriginalId, message.HtmlBody);

                    element.Error = string.Empty;
                    element.DeliveryAttempts++;
                    element.IsDelivered = true;
                }
                catch (Exception ex)
                {
                    element.Error = ex.Message;
                    element.DeliveryAttempts++;

                    // TODO: Save Complete Error Stack || Complete Delivery Log
                }

                BusinessManager.Update(element);
            }

            //
        }