partial void BeforeDBDelete(int productVersionStatusID)
        {
            ProductVersionStatuses productVersionStatuses = new ProductVersionStatuses(LoginUser);

            productVersionStatuses.LoadAllPositions(LoginUser.OrganizationID);

            int id = -1;

            foreach (ProductVersionStatus productVersionStatus in productVersionStatuses)
            {
                if (productVersionStatus.ProductVersionStatusID != productVersionStatusID)
                {
                    id = productVersionStatus.ProductVersionStatusID;
                    break;
                }
            }

            if (id < 0)
            {
                throw new Exception("You cannot delete the last product version.");
            }

            using (SqlCommand command = new SqlCommand())
            {
                command.CommandText = "UPDATE ProductVersions SET ProductVersionStatusID = @NewID WHERE (ProductVersionStatusID = @ProductVersionStatusID)";
                command.CommandType = CommandType.Text;
                command.Parameters.AddWithValue("@ProductVersionStatusID", productVersionStatusID);
                command.Parameters.AddWithValue("@NewID", id);
                ExecuteNonQuery(command, "ProductVersions");
            }
        }
Exemplo n.º 2
0
        public void ValidatePositions(int organizationID)
        {
            ProductVersionStatuses productVersionStatuses = new ProductVersionStatuses(LoginUser);

            productVersionStatuses.LoadAllPositions(organizationID);
            int i = 0;

            foreach (ProductVersionStatus productVersionStatus in productVersionStatuses)
            {
                productVersionStatus.Position = i;
                i++;
            }
            productVersionStatuses.Save();
        }
Exemplo n.º 3
0
        public static ProductVersionStatus GetProductVersionStatus(LoginUser loginUser, int productVersionStatusID)
        {
            ProductVersionStatuses productVersionStatuses = new ProductVersionStatuses(loginUser);

            productVersionStatuses.LoadByProductVersionStatusID(productVersionStatusID);
            if (productVersionStatuses.IsEmpty)
            {
                return(null);
            }
            else
            {
                return(productVersionStatuses[0]);
            }
        }
        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);
            }
        }
Exemplo n.º 5
0
        public void MovePositionUp(int productVersionStatusID)
        {
            ProductVersionStatuses types1 = new ProductVersionStatuses(LoginUser);

            types1.LoadByProductVersionStatusID(productVersionStatusID);
            if (types1.IsEmpty || types1[0].Position < 1)
            {
                return;
            }

            ProductVersionStatuses types2 = new ProductVersionStatuses(LoginUser);

            types2.LoadByPosition(types1[0].OrganizationID, types1[0].Position - 1);
            if (!types2.IsEmpty)
            {
                types2[0].Position = types2[0].Position + 1;
                types2.Save();
            }

            types1[0].Position = types1[0].Position - 1;
            types1.Save();
            ValidatePositions(LoginUser.OrganizationID);
        }
Exemplo n.º 6
0
        public static Organization Clone(LoginUser loginUser, int sourceOrganizationID, string cloneName)
        {
            Organization sOrg = Organizations.GetOrganization(loginUser, sourceOrganizationID);
            Organization dOrg = (new Organizations(loginUser)).AddNewOrganization();

            dOrg.CopyRowData(sOrg);
            dOrg.Name = cloneName;
            dOrg.Collection.Save();

            //** Groups **//
            Groups sGroups = new Groups(loginUser);

            sGroups.LoadByOrganizationID(sourceOrganizationID);

            Groups dGroups = new Groups(loginUser);

            foreach (Group sGroup in sGroups)
            {
                Group dGroup = dGroups.AddNewGroup();
                dGroup.CopyRowData(sGroup);
                dGroup.OrganizationID = dOrg.OrganizationID;
            }
            dGroups.Save();

            //** Users **//

            Users sUsers = new Users(loginUser);

            sUsers.LoadByOrganizationID(sourceOrganizationID, false);

            Users dUsers = new Users(loginUser);

            foreach (User sUser in sUsers)
            {
                User dUser = dUsers.AddNewUser();
                dUser.CopyRowData(sUser);
                dUser.OrganizationID = dOrg.OrganizationID;
                if (sUser.PrimaryGroupID != null)
                {
                    dUser.PrimaryGroupID = dGroups.FindByName(sGroups.FindByGroupID((int)sUser.PrimaryGroupID).Name).GroupID;
                }
            }
            dUsers.Save();


            //** Finish Organization w/ users and groups **//

            dOrg.DefaultPortalGroupID  = sOrg.DefaultPortalGroupID == null ? null : (int?)dGroups.FindByName(sGroups.FindByGroupID((int)sOrg.DefaultPortalGroupID).Name).GroupID;
            dOrg.PrimaryUserID         = sOrg.PrimaryUserID == null ? null : (int?)dUsers.FindByEmail(sUsers.FindByUserID((int)sOrg.PrimaryUserID).Email).UserID;
            dOrg.DefaultSupportUserID  = null;
            dOrg.DefaultSupportGroupID = null;
            dOrg.WebServiceID          = Guid.NewGuid();
            dOrg.SystemEmailID         = Guid.NewGuid();
            dOrg.PortalGuid            = Guid.NewGuid();
            dOrg.Collection.Save();

            //** Ticket Types **//

            TicketTypes sTicketTypes = new TicketTypes(loginUser);

            sTicketTypes.LoadByOrganizationID(sourceOrganizationID);

            TicketTypes dTicketTypes = new TicketTypes(loginUser);

            foreach (TicketType sTicketType in sTicketTypes)
            {
                TicketType dTicketType = dTicketTypes.AddNewTicketType();
                dTicketType.CopyRowData(sTicketType);
                dTicketType.OrganizationID = dOrg.OrganizationID;
            }
            dTicketTypes.Save();

            //** Ticket Severities **//

            TicketSeverities sSeverities = new TicketSeverities(loginUser);

            sSeverities.LoadByOrganizationID(sourceOrganizationID);

            TicketSeverities dSeverities = new TicketSeverities(loginUser);

            foreach (TicketSeverity sSeverity in sSeverities)
            {
                TicketSeverity dSeverity = dSeverities.AddNewTicketSeverity();
                dSeverity.CopyRowData(sSeverity);

                dSeverity.OrganizationID = dOrg.OrganizationID;
            }
            dSeverities.Save();

            //** Ticket Statuses **//

            TicketStatuses sStatuses = new TicketStatuses(loginUser);

            sStatuses.LoadByOrganizationID(sourceOrganizationID);

            TicketStatuses dStatuses = new TicketStatuses(loginUser);

            foreach (TicketStatus sStatus in sStatuses)
            {
                TicketType tempTT = sTicketTypes.FindByTicketTypeID(sStatus.TicketTypeID);
                if (tempTT == null)
                {
                    continue;
                }
                TicketStatus dStatus = dStatuses.AddNewTicketStatus();
                dStatus.CopyRowData(sStatus);
                dStatus.OrganizationID = dOrg.OrganizationID;
                dStatus.TicketTypeID   = dTicketTypes.FindByName(tempTT.Name).TicketTypeID;
            }
            dStatuses.Save();

            TicketNextStatuses sTicketNextStatuses = new TicketNextStatuses(loginUser);
            TicketNextStatuses dTicketNextStatuses = new TicketNextStatuses(loginUser);

            sTicketNextStatuses.LoadAll(sourceOrganizationID);

            foreach (TicketNextStatus sTicketNextStatus in sTicketNextStatuses)
            {
                TicketNextStatus dTicketNextStatus = dTicketNextStatuses.AddNewTicketNextStatus();
                dTicketNextStatus.CopyRowData(sTicketNextStatus);
                TicketStatus tempTS = sStatuses.FindByTicketStatusID(sTicketNextStatus.CurrentStatusID);
                TicketType   tempTT = dTicketTypes.FindByName(sTicketTypes.FindByTicketTypeID(tempTS.TicketTypeID).Name);
                dTicketNextStatus.CurrentStatusID = dStatuses.FindByName(tempTS.Name, tempTT.TicketTypeID).TicketStatusID;
                tempTS = sStatuses.FindByTicketStatusID(sTicketNextStatus.CurrentStatusID);
                tempTT = dTicketTypes.FindByName(sTicketTypes.FindByTicketTypeID(tempTS.TicketTypeID).Name);
                dTicketNextStatus.NextStatusID = dStatuses.FindByName(tempTS.Name, tempTT.TicketTypeID).TicketStatusID;



                //WORKING HERE
            }

            TicketTemplates sTicketTemplates = new TicketTemplates(loginUser);
            TicketTemplates dTicketTemplates = new TicketTemplates(loginUser);

            sTicketTemplates.LoadByOrganization(sourceOrganizationID);

            foreach (TicketTemplate sTicketTemplate in sTicketTemplates)
            {
                TicketTemplate dTicketTemplate = dTicketTemplates.AddNewTicketTemplate();
                dTicketTemplate.CopyRowData(sTicketTemplate);
                dTicketTemplate.OrganizationID = dOrg.OrganizationID;
                dTicketTemplate.TicketTypeID   = dTicketTemplate.TicketTypeID != null ? (int?)dTicketTypes.FindByName(sTicketTypes.FindByTicketTypeID((int)sTicketTemplate.TicketTypeID).Name).TicketTypeID : null;
            }

            //** ActionTypes **//

            ActionTypes sActionTypes = new ActionTypes(loginUser);

            sActionTypes.LoadByOrganizationID(sourceOrganizationID);
            ActionTypes dActionTypes = new ActionTypes(loginUser);

            foreach (ActionType sActionType in sActionTypes)
            {
                ActionType dActionType = dActionTypes.AddNewActionType();
                dActionType.CopyRowData(sActionType);
                dActionType.OrganizationID = dOrg.OrganizationID;
            }
            dActionTypes.Save();


            //** Products **//

            Products sProducts = new Products(loginUser);
            Products dProducts = new Products(loginUser);

            sProducts.LoadByOrganizationID(sourceOrganizationID);

            foreach (Product sProduct in sProducts)
            {
                Product dProduct = dProducts.AddNewProduct();
                dProduct.CopyRowData(sProduct);
                dProduct.OrganizationID = dOrg.OrganizationID;
            }
            dProducts.Save();

            ProductVersionStatuses sProductVersionStatuses = new ProductVersionStatuses(loginUser);
            ProductVersionStatuses dProductVersionStatuses = new ProductVersionStatuses(loginUser);

            sProductVersionStatuses.LoadByOrganizationID(sourceOrganizationID);

            foreach (ProductVersionStatus sProductVersionStatus in sProductVersionStatuses)
            {
                ProductVersionStatus dProductVersionStatus = dProductVersionStatuses.AddNewProductVersionStatus();
                dProductVersionStatus.CopyRowData(sProductVersionStatus);
                dProductVersionStatus.OrganizationID = dOrg.OrganizationID;
            }

            dProductVersionStatuses.Save();

            ProductVersions sProductVersions = new ProductVersions(loginUser);
            ProductVersions dProductVersions = new ProductVersions(loginUser);

            sProductVersions.LoadAll(sourceOrganizationID);

            foreach (ProductVersion sProductVersion in sProductVersions)
            {
                ProductVersion dProductVersion = dProductVersions.AddNewProductVersion();
                dProductVersion.CopyRowData(sProductVersion);
                dProductVersion.ProductID = dProducts.FindByName(sProducts.FindByProductID(sProductVersion.ProductID).Name).ProductID;
            }
            dProductVersions.Save();

            PortalOptions sPortalOptions = new PortalOptions(loginUser);
            PortalOptions dPortalOptions = new PortalOptions(loginUser);

            sPortalOptions.LoadByOrganizationID(sourceOrganizationID);

            foreach (PortalOption sPortalOption in sPortalOptions)
            {
                PortalOption dPortalOption = dPortalOptions.AddNewPortalOption();
                dPortalOption.CopyRowData(sPortalOption);
                dPortalOption.OrganizationID = dOrg.OrganizationID;
                dPortalOption.RequestGroup   = sPortalOption.RequestGroup == null ? null : (int?)dGroups.FindByName(sGroups.FindByGroupID((int)sPortalOption.RequestGroup).Name).GroupID;
                dPortalOption.RequestType    = sPortalOption.RequestType == null ? null : (int?)dTicketTypes.FindByName(sTicketTypes.FindByTicketTypeID((int)sPortalOption.RequestType).Name).TicketTypeID;;
            }
            dPortalOptions.Save();


            return(dOrg);

            /*
             * Actions
             * Addresses
             * Assets
             * ChatSettings
             * ChatUserSettings
             * CrmLinkTable
             * CrmLinkFields
             * CustomFieldCategories
             * CustomFields
             * CustomValues
             * FacebookOptions
             * ForumCategories
             * ForumPermissions
             * ForumTickets
             * GroupUsers
             * Notes
             * OrganizationEmails
             * OrganizationProducts
             * Organizations
             * OrganizationSettings
             * OrganizationTickets
             * PhoneNumbers
             * PhoneQueue
             * PhoneTypes
             * PortalOptions
             * Reminders
             * Reports
             * SlaLevels
             * SlaTriggers
             * Subscriptions
             * Tags
             * TagLinks
             * Automation Stuff
             * TicketQueue
             * TicketRatings
             * TicketRelationShips
             * Users(Contacts)
             * WaterCooler
             * WikiArticles
             */
        }
Exemplo n.º 7
0
 public ProductVersionStatus(DataRow row, ProductVersionStatuses productVersionStatuses) : base(row, productVersionStatuses)
 {
     _productVersionStatuses = productVersionStatuses;
 }