Exemple #1
0
        private List <KBSearchItem> GetKBResults(SearchResults results, LoginUser loginUser, int userID, int parentID, int hubID)
        {
            bool enableCustomerSpecificKB          = false;
            bool enableCustomerProductAssociation  = false;
            bool enableAnonymousProductAssociation = false;

            List <KBSearchItem> items = new List <KBSearchItem>();
            int  customerID           = 0;
            User user = Users.GetUser(loginUser, userID);

            if (user != null)
            {
                customerID = user.OrganizationID;
            }

            CustomerHubFeatureSettings hubFeatureSettings = new CustomerHubFeatureSettings(loginUser);

            hubFeatureSettings.LoadByCustomerHubID(hubID);

            if (hubFeatureSettings.Any())
            {
                enableCustomerProductAssociation  = hubFeatureSettings[0].EnableCustomerProductAssociation;
                enableAnonymousProductAssociation = hubFeatureSettings[0].EnableAnonymousProductAssociation;
                enableCustomerSpecificKB          = hubFeatureSettings[0].EnableCustomerSpecificKB;
            }

            for (int i = 0; i < results.Count; i++)
            {
                results.GetNthDoc(i);
                int ticketID = int.Parse(results.CurrentItem.Filename);
                if (ticketID > 0)
                {
                    TicketsView ticketsViewHelper = new TicketsView(loginUser);
                    ticketsViewHelper.LoadHubKBByID(ticketID, parentID, customerID, enableCustomerSpecificKB, enableCustomerProductAssociation, enableAnonymousProductAssociation);

                    if (ticketsViewHelper.Any())
                    {
                        KBSearchItem item = new KBSearchItem();
                        item.HitRating = results.CurrentItem.ScorePercent;
                        item.Article   = ticketsViewHelper[0].GetProxy();

                        TicketRatings ratings = new TicketRatings(loginUser);
                        ratings.LoadByTicketID(ticketID);

                        if (ratings.Any())
                        {
                            TicketRating rating = ratings[0];
                            item.VoteRating = rating.ThumbsUp;
                        }

                        items.Add(item);
                    }
                }
            }
            return(items);
        }
        public static string GetCustomerHubFeatureSetting(RestCommand command, int customerHubFeatureSettingID)
        {
            CustomerHubFeatureSetting customerHubFeatureSetting = CustomerHubFeatureSettings.GetCustomerHubFeatureSetting(command.LoginUser, customerHubFeatureSettingID);

            if (customerHubFeatureSetting.OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            return(customerHubFeatureSetting.GetXml("CustomerHubFeatureSetting", true));
        }
        public static string GetCustomerHubFeatureSettings(RestCommand command)
        {
            CustomerHubFeatureSettings customerHubFeatureSettings = new CustomerHubFeatureSettings(command.LoginUser);

            customerHubFeatureSettings.LoadByOrganizationID(command.Organization.OrganizationID);

            if (command.Format == RestFormat.XML)
            {
                return(customerHubFeatureSettings.GetXml("CustomerHubFeatureSettings", "CustomerHubFeatureSetting", true, command.Filters));
            }
            else
            {
                throw new RestException(HttpStatusCode.BadRequest, "Invalid data format");
            }
        }
Exemple #4
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);
        }