/// <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);
            }

            //
        }
Beispiel #2
0
        public static void Hide(int stubId)
        {
            int userId = Security.CurrentUser.UserID;

            using (DbTransaction tran = DbTransaction.Begin())
            {
                DBWebStubs.Hide(stubId, userId);
                int imUserId = DBUser.GetOriginalId(userId);
                User.IncreaseStubsVersion(imUserId);

                try
                {
                    IMManager.UpdateUserWebStub(imUserId);
                }
                catch (IMHelperException)
                {
                }

                tran.Commit();
            }
        }
Beispiel #3
0
        public static void UpdateUserStub(
            int stubId
            , string abbreviation
            , string toolTip
            , string url
            , bool openInBrowser
            , int width
            , int height
            , byte[] icon
            , bool deleteIcon)
        {
            using (DbTransaction tran = DbTransaction.Begin())
            {
                DBWebStubs.Update(stubId, abbreviation, toolTip, url, openInBrowser, width, height);

                int imUserId = DBUser.GetOriginalId(Security.CurrentUser.UserID);
                User.IncreaseStubsVersion(imUserId);

                if (deleteIcon)
                {
                    DBWebStubs.UpdateStubIcon(stubId, null);
                }
                else if (icon != null)
                {
                    DBWebStubs.UpdateStubIcon(stubId, icon);
                }

                try
                {
                    IMManager.UpdateUserWebStub(imUserId);
                }
                catch (Exception)
                {
                }

                tran.Commit();
            }
        }
Beispiel #4
0
 /// <summary>
 /// Converts the principal id to original id.
 /// </summary>
 /// <param name="principalId">The principal id.</param>
 /// <returns></returns>
 private PrimaryKeyId ConvertPrincipalIdToOriginalId(PrimaryKeyId principalId)
 {
     return(DBUser.GetOriginalId((int)principalId));
 }
Beispiel #5
0
        public static void Delete(int stubId)
        {
            int       userId = -1;
            ArrayList users  = new ArrayList();
            ArrayList groups = new ArrayList();

            using (IDataReader reader = DBWebStubs.GetStub(stubId))
            {
                if (!reader.Read())
                {
                    return;
                }
                if (reader["UserId"] != DBNull.Value)
                {
                    userId = DBUser.GetOriginalId((int)reader["UserId"]);
                }
            }

            if (userId == -1)
            {
                using (IDataReader reader = DBWebStubs.GetListGroupsByStub(stubId))
                {
                    while (reader.Read())
                    {
                        groups.Add((int)reader["GroupId"]);
                    }
                }

                foreach (int groupId in groups)
                {
                    using (IDataReader reader = SecureGroup.GetListAllUsersInGroup(groupId))
                    {
                        while (reader.Read())
                        {
                            if (reader["OriginalId"] != DBNull.Value)
                            {
                                int imUserId = (int)reader["OriginalId"];
                                if (!users.Contains(imUserId))
                                {
                                    users.Add(imUserId);
                                }
                            }
                        }
                    }
                }
            }

            using (DbTransaction tran = DbTransaction.Begin())
            {
                DBWebStubs.Delete(stubId);

                if (userId > 0)                 // UserStub
                {
                    User.IncreaseStubsVersion(userId);

                    try
                    {
                        IMManager.UpdateUserWebStub(userId);
                    }
                    catch (Exception)
                    {
                    }
                }
                else
                {
                    foreach (int imUserId in users)
                    {
                        User.IncreaseStubsVersion(imUserId);
                    }

                    try
                    {
                        foreach (int imUserId in users)
                        {
                            IMManager.UpdateUserWebStub(imUserId);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }

                tran.Commit();
            }
        }