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);
        }
        partial void AfterRowInsert(ProductVersion productVersion)
        {
            Product product     = (Product)Products.GetProduct(LoginUser, productVersion.ProductID);
            string  description = "Created new version '" + productVersion.VersionNumber + "' for product '" + product.Name + "'";

            ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.ProductVersions, productVersion.ProductVersionID, description);
        }
Esempio n. 3
0
        partial void BeforeRowDelete(int productID)
        {
            Product product     = (Product)Products.GetProduct(LoginUser, productID);
            string  description = "Deleted product '" + product.Name + "'";

            ActionLogs.AddActionLog(LoginUser, ActionLogType.Delete, ReferenceType.Products, productID, description);
        }
Esempio n. 4
0
        public void AddCustomer(int organizationID, int productID)
        {
            using (SqlCommand command = new SqlCommand())
            {
                command.CommandText = @"INSERT INTO 
          OrganizationProducts 
          (OrganizationID, ProductID, IsVisibleOnPortal, DateCreated, DateModified, CreatorID, ModifierID) 
          VALUES 
          (@OrganizationID, @ProductID, 1, @DateCreated, @DateModified, @CreatorID, @ModifierID)";
                command.CommandType = CommandType.Text;
                command.Parameters.AddWithValue("@OrganizationID", organizationID);
                command.Parameters.AddWithValue("@ProductID", productID);
                command.Parameters.AddWithValue("@DateCreated", DateTime.UtcNow);
                command.Parameters.AddWithValue("@DateModified", DateTime.UtcNow);
                command.Parameters.AddWithValue("@CreatorID", LoginUser.UserID);
                command.Parameters.AddWithValue("@ModifierID", LoginUser.UserID);
                ExecuteNonQuery(command, "OrganizationProducts");
            }

            string organizationName = ((Organization)Organizations.GetOrganization(LoginUser, organizationID)).Name;
            string productName      = ((Product)Products.GetProduct(LoginUser, productID)).Name;

            string description = "Added product '" + productName + "' to customer '" + organizationName + "'";

            ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Products, productID, description);
            ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Organizations, organizationID, description);
        }
        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);
        }
Esempio n. 6
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);
        }
        partial void BeforeRowDelete(int productVersionID)
        {
            ProductVersion version     = (ProductVersion)ProductVersions.GetProductVersion(LoginUser, productVersionID);
            Product        product     = (Product)Products.GetProduct(LoginUser, version.ProductID);
            string         description = "Deleted version '" + version.VersionNumber + "' for product '" + product.Name + "'";

            ActionLogs.AddActionLog(LoginUser, ActionLogType.Delete, ReferenceType.ProductVersions, productVersionID, description);
        }
Esempio n. 8
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);
            }
        }
        partial void BeforeRowEdit(CustomValue newValue)
        {
            CustomValue oldValue = CustomValues.GetCustomValue(LoginUser, newValue.CustomValueID);

            newValue.OrganizationID = LoginUser.OrganizationID;
            if (oldValue.Value == newValue.Value)
            {
                return;
            }
            CustomField customField = CustomFields.GetCustomField(LoginUser, newValue.CustomFieldID);
            string      format      = "Changed {0} from '{1}' to '{2}'.";

            ActionLogs.AddActionLog(LoginUser, ActionLogType.Update, customField.RefType, newValue.RefID, string.Format(format, customField.Name, oldValue.Value, newValue.Value));
        }
Esempio n. 10
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);
            }
        }
Esempio n. 11
0
        public void RemoveCustomer(int organizationID, int productID)
        {
            using (SqlCommand command = new SqlCommand())
            {
                command.CommandText = "DELETE FROM OrganizationProducts WHERE (ProductID = @ProductID) AND (OrganizationID = @OrganizationID)";
                command.CommandType = CommandType.Text;
                command.Parameters.AddWithValue("@OrganizationID", organizationID);
                command.Parameters.AddWithValue("@ProductID", productID);
                ExecuteNonQuery(command, "OrganizationProducts");
            }
            Organization org         = (Organization)Organizations.GetOrganization(LoginUser, organizationID);
            Product      product     = (Product)Products.GetProduct(LoginUser, productID);
            string       description = "Removed '" + product.Name + "' from the customer " + org.Name;

            ActionLogs.AddActionLog(LoginUser, ActionLogType.Delete, ReferenceType.Products, productID, description);
            ActionLogs.AddActionLog(LoginUser, ActionLogType.Delete, ReferenceType.Organizations, organizationID, description);
        }
Esempio n. 12
0
        public void DeleteGroupUser(int groupID, int userID)
        {
            using (SqlCommand command = new SqlCommand())
            {
                command.CommandText = "DELETE FROM GroupUsers WHERE (UserID = @UserID) AND (GroupID = @GroupID)";
                command.CommandType = CommandType.Text;
                command.Parameters.AddWithValue("@UserID", userID);
                command.Parameters.AddWithValue("@GroupID", groupID);
                ExecuteNonQuery(command, "GroupUsers");
            }
            User   user        = (User)Users.GetUser(LoginUser, userID);
            Group  group       = (Group)Groups.GetGroup(LoginUser, groupID);
            string description = "Removed '" + user.FirstName + " " + user.LastName + "' from group '" + group.Name + "'";

            ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Groups, groupID, description);
            ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Users, userID, description);
        }
Esempio n. 13
0
        partial void BeforeRowEdit(Product product)
        {
            string description;

            Product oldProduct = (Product)Products.GetProduct(LoginUser, product.ProductID);

            if (oldProduct.Description != product.Description)
            {
                description = "Changed description for product '" + product.Description + "'";
                ActionLogs.AddActionLog(LoginUser, ActionLogType.Update, ReferenceType.Products, product.ProductID, description);
            }

            if (oldProduct.Name != product.Name)
            {
                description = "Changed product name '" + oldProduct.Description + "' to '" + product.Name + "'";
                ActionLogs.AddActionLog(LoginUser, ActionLogType.Update, ReferenceType.Products, product.ProductID, description);
            }
        }
        partial void BeforeRowEdit(ProductVersion productVersion)
        {
            Product        product          = (Product)Products.GetProduct(LoginUser, productVersion.ProductID);
            ProductVersion oldVersion       = (ProductVersion)GetProductVersion(LoginUser, productVersion.ProductVersionID);
            string         description      = "";
            string         oldVersionString = oldVersion.ReleaseDate == null ? "empty" : ((DateTime)oldVersion.ReleaseDate).ToString(GetDateFormatNormal())
            ;

            if (oldVersion.Description != productVersion.Description)
            {
                description = "Changed description for version '" + productVersion.VersionNumber + "' on product '" + product.Name + "'";
                ActionLogs.AddActionLog(LoginUser, ActionLogType.Update, ReferenceType.ProductVersions, productVersion.ProductVersionID, description);
            }

            if (oldVersion.IsReleased != productVersion.IsReleased)
            {
                description = "Changed release status for version '" + productVersion.VersionNumber + "' on product '" + product.Name + "' to " + productVersion.IsReleased.ToString();
                ActionLogs.AddActionLog(LoginUser, ActionLogType.Update, ReferenceType.ProductVersions, productVersion.ProductVersionID, description);
            }

            if (oldVersion.ReleaseDate != productVersion.ReleaseDate)
            {
                description = "Changed the release date for version '" + productVersion.VersionNumber + "' on product '" + product.Name + "' from " + oldVersionString + "' to '" + ((DateTime)productVersion.ReleaseDate).ToString(GetDateFormatNormal()) + "'";
                ActionLogs.AddActionLog(LoginUser, ActionLogType.Update, ReferenceType.ProductVersions, productVersion.ProductVersionID, description);
            }

            if (oldVersion.VersionNumber != productVersion.VersionNumber)
            {
                description = "Changed the version number for version '" + productVersion.VersionNumber + "' on product '" + product.Name + "' to '" + productVersion.VersionNumber + "'";
                ActionLogs.AddActionLog(LoginUser, ActionLogType.Update, ReferenceType.ProductVersions, productVersion.ProductVersionID, description);
            }

            if (oldVersion.ProductVersionStatusID != productVersion.ProductVersionStatusID)
            {
                string oldStatus = ((ProductVersionStatus)ProductVersionStatuses.GetProductVersionStatus(LoginUser, oldVersion.ProductVersionStatusID)).Name;
                string newStatus = ((ProductVersionStatus)ProductVersionStatuses.GetProductVersionStatus(LoginUser, productVersion.ProductVersionStatusID)).Name;
                description = "Changed the status for version '" + productVersion.VersionNumber + "' on product '" + product.Name + "' from " + oldStatus + "' to '" + newStatus + "'";
                ActionLogs.AddActionLog(LoginUser, ActionLogType.Update, ReferenceType.ProductVersions, productVersion.ProductVersionID, description);
            }
        }
Esempio n. 15
0
        public void AddGroupUser(int userID, int groupID)
        {
            using (SqlCommand command = new SqlCommand())
            {
                command.CommandText = "INSERT INTO GroupUsers (GroupID, UserID, DateCreated, DateModified, CreatorID, ModifierID) VALUES (@GroupID, @UserID, @DateCreated, @DateModified, @CreatorID, @ModifierID)";
                command.CommandType = CommandType.Text;
                command.Parameters.AddWithValue("@GroupID", groupID);
                command.Parameters.AddWithValue("@UserID", userID);
                command.Parameters.AddWithValue("@DateCreated", DateTime.UtcNow);
                command.Parameters.AddWithValue("@DateModified", DateTime.UtcNow);
                command.Parameters.AddWithValue("@CreatorID", LoginUser.UserID);
                command.Parameters.AddWithValue("@ModifierID", LoginUser.UserID);
                ExecuteNonQuery(command, "GroupUsers");
            }

            User   user        = (User)Users.GetUser(LoginUser, userID);
            Group  group       = (Group)Groups.GetGroup(LoginUser, groupID);
            string description = "Added '" + user.FirstName + " " + user.LastName + "' to group '" + group.Name + "'";

            ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Groups, groupID, description);
            ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Users, userID, description);
        }
Esempio n. 16
0
        public void RemoveCustomer(int organizationProductID)
        {
            OrganizationProducts organizationProducts = new OrganizationProducts(LoginUser);

            organizationProducts.LoadItemInfo(organizationProductID);
            if (organizationProducts.IsEmpty)
            {
                return;
            }
            OrganizationProduct organizationProduct = organizationProducts[0];

            /*using (SqlCommand command = new SqlCommand())
             * {
             * command.CommandText = "DELETE FROM OrganizationProducts WHERE (OrganizationProductID = @OrganizationProductID)";
             * command.CommandType = CommandType.Text;
             * command.Parameters.AddWithValue("@OrganizationProductID", organizationProductID);
             * ExecuteNonQuery(command, "OrganizationProducts");
             * }*/

            string description;

            if (organizationProduct.ProductVersionID != null)
            {
                description = "Removed product '" + (string)organizationProduct.Row["ProductName"] + "' version '" + (string)organizationProduct.Row["VersionNumber"] + "' from customer '" +
                              (string)organizationProduct.Row["OrganizationName"] + "'";
                ActionLogs.AddActionLog(LoginUser, ActionLogType.Delete, ReferenceType.ProductVersions, (int)organizationProduct.ProductVersionID, description);
            }
            else
            {
                description = "Removed product '" + (string)organizationProduct.Row["ProductName"] + "' from customer '" +
                              (string)organizationProduct.Row["OrganizationName"] + "'";
            }
            ActionLogs.AddActionLog(LoginUser, ActionLogType.Delete, ReferenceType.Organizations, organizationProduct.OrganizationID, description);
            ActionLogs.AddActionLog(LoginUser, ActionLogType.Delete, ReferenceType.Products, organizationProduct.ProductID, description);

            organizationProducts.DeleteFromDB(organizationProductID);
        }
Esempio n. 17
0
        public SlaLevel Clone(string cloneName = null)
        {
            int       cloneSlaLevelId = 0;
            LoginUser loginUser       = Collection.LoginUser;
            SlaLevels slaLevels       = new SlaLevels(loginUser);
            SlaLevel  clone           = slaLevels.AddNewSlaLevel();

            clone.OrganizationID = OrganizationID;

            if (string.IsNullOrEmpty(cloneName))
            {
                clone.Name = Name + " (Clone)";
            }
            else
            {
                clone.Name = cloneName;
            }

            clone.Collection.Save();
            cloneSlaLevelId = clone.SlaLevelID;

            string actionLog = string.Format("{0} cloned SLA Level {1} into {2}.", loginUser.GetUserFullName(), this.Name, clone.Name);

            ActionLogs.AddActionLog(loginUser, ActionLogType.Insert, ReferenceType.Sla, cloneSlaLevelId, actionLog);

            //Clone SLA's triggers
            SlaTriggers clonedSlaTriggers   = new SlaTriggers(loginUser);
            SlaTriggers originalSlaTriggers = new SlaTriggers(loginUser);

            try
            {
                originalSlaTriggers.LoadBySlaLevel(OrganizationID, SlaLevelID);

                foreach (SlaTrigger slaTrigger in originalSlaTriggers.OrderBy(o => o.SlaTriggerID).ToList())
                {
                    SlaTrigger clonedSlaTrigger = clonedSlaTriggers.AddNewSlaTrigger();
                    slaTrigger.ClonePropertiesTo(clonedSlaTrigger);
                    clonedSlaTrigger.SlaLevelID = cloneSlaLevelId;
                }

                clonedSlaTriggers.BulkSave();
            }
            catch (Exception ex)
            {
                actionLog = string.Format("Failed to clone sla {0} Triggers into {1}.", this.SlaLevelID, clone.SlaLevelID);
                ActionLogs.AddActionLog(loginUser, ActionLogType.Insert, ReferenceType.Sla, cloneSlaLevelId, actionLog);
                ExceptionLogs.LogException(loginUser, ex, "Cloning Sla Triggers", "SlaLevels.Clone - Triggers");
            }

            //Clone SLA's Pause on specific days
            try
            {
                clonedSlaTriggers = new SlaTriggers(loginUser);
                clonedSlaTriggers.LoadBySlaLevel(OrganizationID, cloneSlaLevelId);

                foreach (SlaTrigger slaTrigger in originalSlaTriggers)
                {
                    SlaPausedDays clonedSlaPausedDays   = new SlaPausedDays(loginUser);
                    SlaPausedDays originalSlaPausedDays = new SlaPausedDays(loginUser);
                    originalSlaPausedDays.LoadByTriggerID(slaTrigger.SlaTriggerID);
                    int newTriggerId = clonedSlaTriggers.Where(p => p.TicketTypeID == slaTrigger.TicketTypeID && p.TicketSeverityID == slaTrigger.TicketSeverityID && p.SlaLevelID == cloneSlaLevelId).First().SlaTriggerID;

                    foreach (SlaPausedDay slaPausedDay in originalSlaPausedDays.OrderBy(o => o.DateToPause).ToList())
                    {
                        SlaPausedDay clonedSlaPausedDay = clonedSlaPausedDays.AddNewSlaPausedDay();
                        clonedSlaPausedDay.SlaTriggerId = newTriggerId;
                        clonedSlaPausedDay.DateToPause  = slaPausedDay.DateToPauseUtc;
                    }

                    clonedSlaPausedDays.BulkSave();
                }
            }
            catch (Exception ex)
            {
                actionLog = string.Format("Failed to clone sla {0} DaysToPause into {1}.", this.SlaLevelID, clone.SlaLevelID);
                ActionLogs.AddActionLog(loginUser, ActionLogType.Insert, ReferenceType.Sla, cloneSlaLevelId, actionLog);
                ExceptionLogs.LogException(loginUser, ex, "Cloning Sla Pause On Days", "SlaLevels.Clone - Pause On Days");
            }

            return(clone);
        }
Esempio n. 18
0
        partial void AfterRowInsert(Product product)
        {
            string description = "Created product '" + product.Name + "'";

            ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Products, product.ProductID, description);
        }