public void MovePositionDown(int ticketStatusID)
        {
            ValidatePositions(TicketStatuses.GetTicketStatus(LoginUser, ticketStatusID).TicketTypeID);

            TicketStatuses types1 = new TicketStatuses(LoginUser);

            types1.LoadByTicketStatusID(ticketStatusID);
            if (types1.IsEmpty || types1[0].Position >= GetMaxPosition(types1[0].TicketTypeID))
            {
                return;
            }

            TicketStatuses types2 = new TicketStatuses(LoginUser);

            types2.LoadByPosition(types1[0].TicketTypeID, 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(types1[0].TicketTypeID);
        }
        partial void AfterRowInsert(TicketStatus ticketStatus)
        {
            TicketStatuses statuses = new TicketStatuses(LoginUser);

            statuses.LoadByTicketTypeID(ticketStatus.TicketTypeID);
            TicketNextStatuses ticketNextStatuses = new TicketNextStatuses(LoginUser);

            for (int i = 0; i < statuses.Count; i++)
            {
                if (statuses[i].TicketStatusID != ticketStatus.TicketStatusID)
                {
                    TicketNextStatus ticketNextStatus = ticketNextStatuses.AddNewTicketNextStatus();
                    ticketNextStatus.CurrentStatusID = ticketStatus.TicketStatusID;
                    ticketNextStatus.NextStatusID    = statuses[i].TicketStatusID;
                    ticketNextStatus.Position        = i;
                }
            }

            foreach (TicketStatus status in statuses)
            {
                if (status.TicketStatusID != ticketStatus.TicketStatusID)
                {
                    TicketNextStatus ticketNextStatus = ticketNextStatuses.AddNewTicketNextStatus();
                    ticketNextStatus.CurrentStatusID = status.TicketStatusID;
                    ticketNextStatus.NextStatusID    = ticketStatus.TicketStatusID;
                    ticketNextStatus.Position        = TicketNextStatuses.GetMaxPosition(LoginUser, status.TicketStatusID) + 1;
                }
            }
            ticketNextStatuses.Save();



            ticketStatus.FillWorkflow();
        }
        public static void DeleteByTicketTypeID(LoginUser loginUser, int ticketTypeID)
        {
            TicketStatuses statuses = new TicketStatuses(loginUser);

            statuses.LoadByTicketTypeID(ticketTypeID);
            foreach (TicketStatus status in statuses)
            {
                statuses.DeleteFromDB(status.TicketStatusID);
            }
        }
Exemple #4
0
        public static TicketStatus GetTicketStatus(LoginUser loginUser, int ticketStatusID)
        {
            TicketStatuses ticketStatuses = new TicketStatuses(loginUser);

            ticketStatuses.LoadByTicketStatusID(ticketStatusID);
            if (ticketStatuses.IsEmpty)
            {
                return(null);
            }
            else
            {
                return(ticketStatuses[0]);
            }
        }
        public void ValidatePositions(int ticketTypeID)
        {
            TicketStatuses ticketStatuses = new TicketStatuses(LoginUser);

            ticketStatuses.LoadAllPositions(ticketTypeID);
            int i = 0;

            foreach (TicketStatus ticketStatus in ticketStatuses)
            {
                ticketStatus.Position = i;
                i++;
            }
            ticketStatuses.Save();
        }
        public static TicketStatus GetTop(LoginUser loginUser, int ticketTypeID)
        {
            TicketStatuses items = new TicketStatuses(loginUser);

            items.LoadTopOne(ticketTypeID);
            if (items.IsEmpty)
            {
                return(null);
            }
            else
            {
                return(items[0]);
            }
        }
        public static int?GetIDByName(LoginUser loginUser, string name, int?parentID)
        {
            int?result = null;

            if (parentID != null)
            {
                TicketStatuses statuses = new TicketStatuses(loginUser);
                statuses.LoadByTicketTypeIDAndName((int)parentID, name);
                if (!statuses.IsEmpty)
                {
                    result = statuses[0].TicketStatusID;
                }
            }
            return(result);
        }
        public void LoadNotNextStatuses(int currentStatusID)
        {
            TicketStatuses statuses = new TicketStatuses(LoginUser);

            statuses.LoadByTicketStatusID(currentStatusID);
            if (statuses.IsEmpty)
            {
                return;
            }
            TicketStatus status = statuses[0];

            using (SqlCommand command = new SqlCommand())
            {
                command.CommandText = "SELECT * FROM TicketStatuses ts WHERE (ts.TicketStatusID not in (SELECT tns.NextStatusID FROM TicketNextStatuses tns WHERE (tns.CurrentStatusID = @CurrentStatusID))) AND (ts.TicketTypeID = @TicketTypeID) AND (ts.TicketStatusID <> @CurrentStatusID)";
                command.CommandType = CommandType.Text;
                command.Parameters.AddWithValue("CurrentStatusID", currentStatusID);
                command.Parameters.AddWithValue("TicketTypeID", status.TicketTypeID);
                Fill(command, "TicketStatuses,TicketNextStatuses");
            }
        }
Exemple #9
0
 public TicketStatus(DataRow row, TicketStatuses ticketStatuses) : base(row, ticketStatuses)
 {
     _ticketStatuses = ticketStatuses;
 }
Exemple #10
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
             */
        }