public static string GetCustomerHub(RestCommand command, int customerHubID)
        {
            CustomerHub customerHub = CustomerHubs.GetCustomerHub(command.LoginUser, customerHubID);

            if (customerHub.OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            return(customerHub.GetXml("CustomerHub", true));
        }
        public static string GetCustomerHubs(RestCommand command)
        {
            CustomerHubs customerHubs = new CustomerHubs(command.LoginUser);

            customerHubs.LoadByOrganizationID(command.Organization.OrganizationID);

            if (command.Format == RestFormat.XML)
            {
                return(customerHubs.GetXml("CustomerHubs", "CustomerHub", true, command.Filters));
            }
            else
            {
                throw new RestException(HttpStatusCode.BadRequest, "Invalid data format");
            }
        }
Exemplo n.º 3
0
        private List <TicketSearchItem> GetTicketResults(SearchResults results, LoginUser loginUser, int contactID, int parentID, int customerHubID)
        {
            List <TicketSearchItem> items   = new List <TicketSearchItem>();
            TicketLoadFilter        filters = new TicketLoadFilter();

            int  customerID = 0;
            User user       = Users.GetUser(loginUser, contactID);

            if (user != null)
            {
                customerID = user.OrganizationID;
                Organizations orgHelper = new Organizations(loginUser);
                orgHelper.LoadByUnknownCompany(parentID);

                if (orgHelper.Any())
                {
                    if (orgHelper[0].OrganizationID == user.OrganizationID)
                    {
                        filters.ContactID = contactID;
                    }
                }
            }

            filters.CustomerID        = user.OrganizationID;
            filters.IsVisibleOnPortal = true;
            filters.ForumCategoryID   = null;

            if (customerHubID != -1)
            {
                CustomerHubFeatureSettings hubFeatureSettings = new CustomerHubFeatureSettings(loginUser);
                hubFeatureSettings.LoadByCustomerHubID(customerHubID);

                if (hubFeatureSettings.Any() && hubFeatureSettings[0].EnableProductFamilyFiltering)
                {
                    CustomerHubs customerHub = new CustomerHubs(loginUser);
                    customerHub.LoadByCustomerHubID(customerHubID);
                    if (customerHub.Any())
                    {
                        filters.ProductFamilyID = customerHub[0].ProductFamilyID;
                    }
                }
            }

            TicketsView ticketsViewHelper = new TicketsView(loginUser);

            ticketsViewHelper.LoadHubtickets(loginUser, contactID, parentID, filters, null, 0, 100000000);

            for (int i = 0; i < results.Count; i++)
            {
                results.GetNthDoc(i);
                int ticketID = int.Parse(results.CurrentItem.Filename);
                if (ticketID > 0)
                {
                    if (ticketsViewHelper.Any())
                    {
                        foreach (var ticket in ticketsViewHelper)
                        {
                            if (ticket.TicketID == ticketID)
                            {
                                TicketSearchItem item = new TicketSearchItem();
                                item.Ticket              = new TicketsViewItemProxy();
                                item.Ticket.TicketID     = ticket.TicketID;
                                item.Ticket.Name         = ticket.Name;
                                item.Ticket.TicketNumber = ticket.TicketNumber;
                                item.Ticket.DateCreated  = ticket.DateCreated;

                                item.HitRating = results.CurrentItem.ScorePercent;

                                items.Add(item);
                            }
                        }
                    }
                }
            }

            return(items);
        }