public static void DeleteProductVersion(LoginUser loginUser, int productVersionID)
        {
            ProductVersions productVersions = new ProductVersions(loginUser);

            using (SqlCommand command = new SqlCommand())
            {
                command.CommandText = "DELETE FROM OrganizationProducts WHERE (ProductVersionID = @ProductVersionID)";
                command.CommandType = CommandType.Text;
                command.Parameters.Clear();
                command.Parameters.AddWithValue("@ProductVersionID", productVersionID);
                productVersions.ExecuteNonQuery(command, "OrganizationProducts");

                command.CommandText = "UPDATE Tickets SET SolvedVersionID = null WHERE (SolvedVersionID = @ProductVersionID)";
                command.CommandType = CommandType.Text;
                command.Parameters.Clear();
                command.Parameters.AddWithValue("@ProductVersionID", productVersionID);
                productVersions.ExecuteNonQuery(command, "Tickets");

                command.CommandText = "UPDATE Tickets SET ReportedVersionID = null WHERE (ReportedVersionID = @ProductVersionID)";
                command.CommandType = CommandType.Text;
                command.Parameters.Clear();
                command.Parameters.AddWithValue("@ProductVersionID", productVersionID);
                productVersions.ExecuteNonQuery(command, "Tickets");
            }


            productVersions.LoadByProductVersionID(productVersionID);
            if (!productVersions.IsEmpty)
            {
                productVersions[0].Delete();
            }
            productVersions.Save();
        }
예제 #2
0
        public void AddCustomer(int organizationID, int productID, int versionID)
        {
            using (SqlCommand command = new SqlCommand())
            {
                command.CommandText = @"INSERT INTO 
          OrganizationProducts 
          (OrganizationID, ProductID, ProductVersionID, IsVisibleOnPortal, DateCreated, DateModified, CreatorID, ModifierID) 
          VALUES 
          (@OrganizationID, @ProductID, @ProductVersionID, 1, @DateCreated, @DateModified, @CreatorID, @ModifierID)";
                command.CommandType = CommandType.Text;
                command.Parameters.AddWithValue("@OrganizationID", organizationID);
                command.Parameters.AddWithValue("@ProductID", productID);
                command.Parameters.AddWithValue("@ProductVersionID", versionID);
                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 versionNumber    = ((ProductVersion)ProductVersions.GetProductVersion(LoginUser, (int)versionID)).VersionNumber;

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

            ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.ProductVersions, (int)versionID, description);
            ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Products, productID, description);
            ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Organizations, organizationID, 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);
        }
        public static ProductVersion GetProductVersion(LoginUser loginUser, int productVersionID)
        {
            ProductVersions productVersions = new ProductVersions(loginUser);

            productVersions.LoadByProductVersionID(productVersionID);
            if (productVersions.IsEmpty)
            {
                return(null);
            }
            else
            {
                return(productVersions[0]);
            }
        }
        public static int?GetIDByName(LoginUser loginUser, string versionNumber, int?productID)
        {
            int?result = null;

            if (productID != null)
            {
                ProductVersions productVersions = new ProductVersions(loginUser);
                productVersions.LoadByProductIDAndVersionNumber((int)productID, versionNumber);
                if (!productVersions.IsEmpty)
                {
                    result = productVersions[0].ProductVersionID;
                }
            }
            return(result);
        }
예제 #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
             */
        }
 public ProductVersion(DataRow row, ProductVersions productVersions) : base(row, productVersions)
 {
     _productVersions = productVersions;
 }