Exemplo n.º 1
0
        public static void AddSubscription(LoginUser loginUser, int userID, ReferenceType refType, int refID)
        {
            if (IsUserSubscribed(loginUser, userID, refType, refID))
            {
                return;
            }
            Subscriptions subscriptions = new Subscriptions(loginUser);

            using (SqlCommand command = new SqlCommand())
            {
                command.CommandText = "INSERT INTO Subscriptions (RefType, RefID, UserID, DateCreated, DateModified, CreatorID, ModifierID) VALUES (@RefType, @RefID, @UserID, @DateCreated, @DateModified, @CreatorID, @ModifierID)";
                command.CommandType = CommandType.Text;
                command.Parameters.AddWithValue("@UserID", userID);
                command.Parameters.AddWithValue("@RefID", refID);
                command.Parameters.AddWithValue("@RefType", (int)refType);
                command.Parameters.AddWithValue("@DateCreated", DateTime.UtcNow);
                command.Parameters.AddWithValue("@DateModified", DateTime.UtcNow);
                command.Parameters.AddWithValue("@CreatorID", loginUser.UserID);
                command.Parameters.AddWithValue("@ModifierID", loginUser.UserID);
                subscriptions.ExecuteNonQuery(command, "Subscriptions,Tickets,Users");
            }

            string description = "Subscribed '" + Users.GetUserFullName(loginUser, userID) + "' to ";

            if (refType == ReferenceType.Tickets)
            {
                Ticket ticket = (Ticket)Tickets.GetTicket(loginUser, refID);
                description = description + Tickets.GetTicketLink(ticket);
            }

            ActionLogs.AddActionLog(loginUser, ActionLogType.Insert, refType, refID, description);
            ActionLogs.AddActionLog(loginUser, ActionLogType.Insert, ReferenceType.Users, userID, description);
        }
Exemplo n.º 2
0
        partial void BeforeRowDelete(int actionID)
        {
            Action action      = (Action)Actions.GetAction(LoginUser, actionID);
            string description = "Deleted action '" + action.Name + "' from " + Tickets.GetTicketLink(LoginUser, action.TicketID);

            ActionLogs.AddActionLog(LoginUser, ActionLogType.Delete, ReferenceType.Tickets, action.TicketID, description);
        }
Exemplo n.º 3
0
        public static void RemoveSubscription(LoginUser loginUser, int userID, ReferenceType refType, int refID)
        {
            Subscriptions subscriptions = new Subscriptions(loginUser);

            using (SqlCommand command = new SqlCommand())
            {
                command.CommandText = "DELETE FROM Subscriptions WHERE (RefType = @RefType) AND (RefID = @RefID) AND (UserID = @UserID)";
                command.CommandType = CommandType.Text;
                command.Parameters.AddWithValue("@UserID", userID);
                command.Parameters.AddWithValue("@RefType", (int)refType);
                command.Parameters.AddWithValue("@RefID", refID);
                subscriptions.ExecuteNonQuery(command, "Subscriptions,Tickets,Users");
            }


            string description = "Unsubscribed '" + Users.GetUserFullName(loginUser, userID) + "' from ";

            if (refType == ReferenceType.Tickets)
            {
                Ticket ticket = (Ticket)Tickets.GetTicket(loginUser, refID);
                description = description + Tickets.GetTicketLink(ticket);
            }
            ActionLogs.AddActionLog(loginUser, ActionLogType.Delete, refType, refID, description);
            ActionLogs.AddActionLog(loginUser, ActionLogType.Delete, ReferenceType.Users, userID, description);
        }
Exemplo n.º 4
0
        partial void BeforeRowEdit(Action action)
        {
            var oldAction = (Action)Actions.GetActionByID(LoginUser, action.ActionID);

            action.Description = HtmlUtility.FixScreenRFrame((action.Row["Description"] == DBNull.Value) ? string.Empty : action.Description);
            string actionNumber = GetActionNumber(action.TicketID, action.ActionID);
            string description  = "Modified action #" + actionNumber + " on " + Tickets.GetTicketLink(LoginUser, action.TicketID) + (oldAction.IsVisibleOnPortal != action.IsVisibleOnPortal ? " - action changed is visible to = " + action.IsVisibleOnPortal : "");

            if (!this.isAdminClean)
            {
                ActionLogs.AddActionLog(LoginUser, ActionLogType.Update, ReferenceType.Tickets, action.TicketID, description);
            }
        }
Exemplo n.º 5
0
        partial void AfterRowInsert(Action action)
        {
            string description = string.Format("Added {0} action ", action.IsVisibleOnPortal ? "public" : "private");

            if (_actionLogInstantMessage != null)
            {
                description = _actionLogInstantMessage;
            }
            ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Tickets, action.TicketID, description + action.Name + " to " + Tickets.GetTicketLink(LoginUser, action.TicketID));
            if (_updateChildTickets)
            {
                AddChildActions(action);
            }
        }