Example #1
0
        public AutomationData GetData()
        {
            AutomationData result = new AutomationData();
            TicketAutomationPossibleActions actions = new TicketAutomationPossibleActions(UserSession.LoginUser);

            actions.LoadActive();
            result.Actions = actions.GetTicketAutomationPossibleActionProxies();


            List <AutoFieldItem> fieldItems = new List <AutoFieldItem>();
            ReportTableFields    fields     = new ReportTableFields(TSAuthentication.GetLoginUser());

            fields.LoadByReportTableID(10);

            CustomFields customs = new CustomFields(fields.LoginUser);

            customs.LoadByReferenceType(TSAuthentication.OrganizationID, ReferenceType.Tickets);

            CustomFields orgfields = new CustomFields(fields.LoginUser);

            orgfields.LoadByReferenceType(TSAuthentication.OrganizationID, ReferenceType.Organizations);
            List <string> orgCustomFields = new List <string>();

            foreach (CustomField c in orgfields)
            {
                orgCustomFields.Add(c.Name + ":" + c.CustomFieldID);
            }


            TicketTypes ticketTypes = new TicketTypes(fields.LoginUser);

            ticketTypes.LoadAllPositions(TSAuthentication.OrganizationID);

            foreach (ReportTableField field in fields)
            {
                fieldItems.Add(new AutoFieldItem(field));
            }

            List <AutoFieldItem> customFieldsItems = new List <AutoFieldItem>();

            foreach (CustomField custom in customs)
            {
                TicketType ticketType = ticketTypes.FindByTicketTypeID(custom.AuxID);
                if (ticketType == null)
                {
                    fieldItems.Add(new AutoFieldItem(custom));
                    customFieldsItems.Add(new AutoFieldItem(custom));
                }
                else
                {
                    fieldItems.Add(new AutoFieldItem(custom, string.Format("{0} ({1})", custom.Name, ticketType.Name)));
                    customFieldsItems.Add(new AutoFieldItem(custom, string.Format("{0} ({1})", custom.Name, ticketType.Name)));
                }
            }
            result.CustomFields = customFieldsItems.ToArray();

            ReportTableField actionsViewDescription = ReportTableFields.GetReportTableField(fields.LoginUser, 6);

            actionsViewDescription.Alias = "Action Text";
            fieldItems.Add(new AutoFieldItem(actionsViewDescription));

            ReportTableField actionsViewName = ReportTableFields.GetReportTableField(fields.LoginUser, 5);

            fieldItems.Add(new AutoFieldItem(actionsViewName));

            ReportTableField actionsViewType = ReportTableFields.GetReportTableField(fields.LoginUser, 18);

            fieldItems.Add(new AutoFieldItem(actionsViewType));

            AutoFieldItem afiDayOfWeekCreated = new AutoFieldItem();

            afiDayOfWeekCreated.Alias         = "Day of Week Created";
            afiDayOfWeekCreated.DataType      = "list";
            afiDayOfWeekCreated.FieldID       = 101001;
            afiDayOfWeekCreated.FieldName     = "Day of Week Created";
            afiDayOfWeekCreated.IsCustom      = false;
            afiDayOfWeekCreated.IsVisible     = true;
            afiDayOfWeekCreated.ListValues    = new string[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
            afiDayOfWeekCreated.LookupTableID = null;
            afiDayOfWeekCreated.Size          = 0;
            afiDayOfWeekCreated.Description   = "";
            afiDayOfWeekCreated.TableID       = -2;
            afiDayOfWeekCreated.RefType       = ReferenceType.Tickets;
            afiDayOfWeekCreated.AuxID         = null;
            afiDayOfWeekCreated.OtherTrigger  = "ticketsview.dayofweekcreated";
            fieldItems.Add(afiDayOfWeekCreated);

            AutoFieldItem afiHourOfDayCreated = new AutoFieldItem();

            afiHourOfDayCreated.Alias         = "Hour of Day Created";
            afiHourOfDayCreated.DataType      = "text";
            afiHourOfDayCreated.FieldID       = 101002;
            afiHourOfDayCreated.FieldName     = "Hour of Day Created";
            afiHourOfDayCreated.IsCustom      = false;
            afiHourOfDayCreated.IsVisible     = true;
            afiHourOfDayCreated.ListValues    = null;
            afiHourOfDayCreated.LookupTableID = null;
            afiHourOfDayCreated.Size          = 0;
            afiHourOfDayCreated.Description   = "";
            afiHourOfDayCreated.TableID       = -2;
            afiHourOfDayCreated.RefType       = ReferenceType.Tickets;
            afiHourOfDayCreated.AuxID         = null;
            afiHourOfDayCreated.OtherTrigger  = "ticketsview.hourofdaycreated";
            fieldItems.Add(afiHourOfDayCreated);

            AutoFieldItem afiMinSinceLastAction = new AutoFieldItem();

            afiMinSinceLastAction.Alias         = "Minutes Since last Action Added";
            afiMinSinceLastAction.DataType      = "text";
            afiMinSinceLastAction.FieldID       = 101003;
            afiMinSinceLastAction.FieldName     = "Minutes Since last Action Added";
            afiMinSinceLastAction.IsCustom      = false;
            afiMinSinceLastAction.IsVisible     = true;
            afiMinSinceLastAction.ListValues    = null;
            afiMinSinceLastAction.LookupTableID = null;
            afiMinSinceLastAction.Size          = 0;
            afiMinSinceLastAction.Description   = "";
            afiMinSinceLastAction.TableID       = -2;
            afiMinSinceLastAction.RefType       = ReferenceType.Tickets;
            afiMinSinceLastAction.AuxID         = null;
            afiMinSinceLastAction.OtherTrigger  = "ticketsview.minutessincelastactionadded";
            fieldItems.Add(afiMinSinceLastAction);

            AutoFieldItem afiHoursSinceAction = new AutoFieldItem();

            afiHoursSinceAction.Alias         = "Hours Since Last Action Added";
            afiHoursSinceAction.DataType      = "text";
            afiHoursSinceAction.FieldID       = 101004;
            afiHoursSinceAction.FieldName     = "Hours Since Last Action Added";
            afiHoursSinceAction.IsCustom      = false;
            afiHoursSinceAction.IsVisible     = true;
            afiHoursSinceAction.ListValues    = null;
            afiHoursSinceAction.LookupTableID = null;
            afiHoursSinceAction.Size          = 0;
            afiHoursSinceAction.Description   = "";
            afiHoursSinceAction.TableID       = -2;
            afiHoursSinceAction.RefType       = ReferenceType.Tickets;
            afiHoursSinceAction.AuxID         = null;
            afiHoursSinceAction.OtherTrigger  = "ticketsview.hourssincelastactionadded";
            fieldItems.Add(afiHoursSinceAction);

            AutoFieldItem afiCurrentDayOfWeek = new AutoFieldItem();

            afiCurrentDayOfWeek.Alias         = "Current Day of Week";
            afiCurrentDayOfWeek.DataType      = "list";
            afiCurrentDayOfWeek.FieldID       = 101005;
            afiCurrentDayOfWeek.FieldName     = "Current Day of Week";
            afiCurrentDayOfWeek.IsCustom      = false;
            afiCurrentDayOfWeek.IsVisible     = true;
            afiCurrentDayOfWeek.ListValues    = new string[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
            afiCurrentDayOfWeek.LookupTableID = null;
            afiCurrentDayOfWeek.Size          = 0;
            afiCurrentDayOfWeek.Description   = "";
            afiCurrentDayOfWeek.TableID       = -2;
            afiCurrentDayOfWeek.RefType       = ReferenceType.Tickets;
            afiCurrentDayOfWeek.AuxID         = null;
            afiCurrentDayOfWeek.OtherTrigger  = "ticketsview.currentdayofweek";
            fieldItems.Add(afiCurrentDayOfWeek);

            AutoFieldItem afiCurrentHourOfDay = new AutoFieldItem();

            afiCurrentHourOfDay.Alias         = "Current Hour of Day";
            afiCurrentHourOfDay.DataType      = "text";
            afiCurrentHourOfDay.FieldID       = 101006;
            afiCurrentHourOfDay.FieldName     = "Current Hour of Day";
            afiCurrentHourOfDay.IsCustom      = false;
            afiCurrentHourOfDay.IsVisible     = true;
            afiCurrentHourOfDay.ListValues    = null;
            afiCurrentHourOfDay.LookupTableID = null;
            afiCurrentHourOfDay.Size          = 0;
            afiCurrentHourOfDay.Description   = "";
            afiCurrentHourOfDay.TableID       = -2;
            afiCurrentHourOfDay.RefType       = ReferenceType.Tickets;
            afiCurrentHourOfDay.AuxID         = null;
            afiCurrentHourOfDay.OtherTrigger  = "ticketsview.currenthourofday";
            fieldItems.Add(afiCurrentHourOfDay);

            AutoFieldItem afiAssignedUserIsAvailable = new AutoFieldItem();

            afiAssignedUserIsAvailable.Alias         = "Assigned User Is Available";
            afiAssignedUserIsAvailable.DataType      = "bit";
            afiAssignedUserIsAvailable.FieldID       = 101007;
            afiAssignedUserIsAvailable.FieldName     = "Assigned User Is Available";
            afiAssignedUserIsAvailable.IsCustom      = false;
            afiAssignedUserIsAvailable.IsVisible     = true;
            afiAssignedUserIsAvailable.ListValues    = null;
            afiAssignedUserIsAvailable.LookupTableID = null;
            afiAssignedUserIsAvailable.Size          = 0;
            afiAssignedUserIsAvailable.Description   = "";
            afiAssignedUserIsAvailable.TableID       = -2;
            afiAssignedUserIsAvailable.RefType       = ReferenceType.Tickets;
            afiAssignedUserIsAvailable.AuxID         = null;
            afiAssignedUserIsAvailable.OtherTrigger  = "ticketsview.assigneduseravailable";
            fieldItems.Add(afiAssignedUserIsAvailable);

            AutoFieldItem afiAssignedUserIsBusy = new AutoFieldItem();

            afiAssignedUserIsBusy.Alias         = "Assigned User Is Busy";
            afiAssignedUserIsBusy.DataType      = "bit";
            afiAssignedUserIsBusy.FieldID       = 101008;
            afiAssignedUserIsBusy.FieldName     = "Assigned User Is Busy";
            afiAssignedUserIsBusy.IsCustom      = false;
            afiAssignedUserIsBusy.IsVisible     = true;
            afiAssignedUserIsBusy.ListValues    = null;
            afiAssignedUserIsBusy.LookupTableID = null;
            afiAssignedUserIsBusy.Size          = 0;
            afiAssignedUserIsBusy.Description   = "";
            afiAssignedUserIsBusy.TableID       = -2;
            afiAssignedUserIsBusy.RefType       = ReferenceType.Tickets;
            afiAssignedUserIsBusy.AuxID         = null;
            afiAssignedUserIsBusy.OtherTrigger  = "ticketsview.assignedusernotavailable";
            fieldItems.Add(afiAssignedUserIsBusy);

            AutoFieldItem afiAgentRatings = new AutoFieldItem();

            afiAgentRatings.Alias         = "Agent Rating";
            afiAgentRatings.DataType      = "list";
            afiAgentRatings.FieldID       = 101009;
            afiAgentRatings.FieldName     = "AgentRating";
            afiAgentRatings.IsCustom      = false;
            afiAgentRatings.IsVisible     = true;
            afiAgentRatings.ListValues    = new string[] { "Positive", "Negative", "Neutral" };
            afiAgentRatings.LookupTableID = null;
            afiAgentRatings.Size          = 0;
            afiAgentRatings.Description   = "";
            afiAgentRatings.TableID       = -2;
            afiAgentRatings.RefType       = ReferenceType.Tickets;
            afiAgentRatings.AuxID         = null;
            afiAgentRatings.OtherTrigger  = "ticketsview.AgentRating";
            fieldItems.Add(afiAgentRatings);

            AutoFieldItem afiCDIValue = new AutoFieldItem();

            afiCDIValue.Alias         = "Customer CDI Value";
            afiCDIValue.DataType      = "text";
            afiCDIValue.FieldID       = 101010;
            afiCDIValue.FieldName     = "Customer CDI Value";
            afiCDIValue.IsCustom      = false;
            afiCDIValue.IsVisible     = true;
            afiCDIValue.ListValues    = null;
            afiCDIValue.LookupTableID = null;
            afiCDIValue.Size          = 0;
            afiCDIValue.Description   = "";
            afiCDIValue.TableID       = -2;
            afiCDIValue.RefType       = ReferenceType.Tickets;
            afiCDIValue.AuxID         = null;
            afiCDIValue.OtherTrigger  = "organizations.cdivalue";
            fieldItems.Add(afiCDIValue);

            AutoFieldItem afiCDITrend = new AutoFieldItem();

            afiCDITrend.Alias         = "Customer CDI Trend";
            afiCDITrend.DataType      = "text";
            afiCDITrend.FieldID       = 101011;
            afiCDITrend.FieldName     = "Customer CDI Trend";
            afiCDITrend.IsCustom      = false;
            afiCDITrend.IsVisible     = true;
            afiCDITrend.ListValues    = new string[] { "1", "0", "-1" };;
            afiCDITrend.LookupTableID = null;
            afiCDITrend.Size          = 0;
            afiCDITrend.Description   = "";
            afiCDITrend.TableID       = -2;
            afiCDITrend.RefType       = ReferenceType.Tickets;
            afiCDITrend.AuxID         = null;
            afiCDITrend.OtherTrigger  = "organizations.cditrend";
            fieldItems.Add(afiCDITrend);

            AutoFieldItem afiServiceLevelName = new AutoFieldItem();

            afiServiceLevelName.Alias         = "Service Level Name";
            afiServiceLevelName.DataType      = "text";
            afiServiceLevelName.FieldID       = 101012;
            afiServiceLevelName.FieldName     = "Service Level Name";
            afiServiceLevelName.IsCustom      = false;
            afiServiceLevelName.IsVisible     = true;
            afiServiceLevelName.ListValues    = null;
            afiServiceLevelName.LookupTableID = null;
            afiServiceLevelName.Size          = 0;
            afiServiceLevelName.Description   = "";
            afiServiceLevelName.TableID       = -2;
            afiServiceLevelName.RefType       = ReferenceType.Tickets;
            afiServiceLevelName.AuxID         = null;
            afiServiceLevelName.OtherTrigger  = "organizations.SLAName";
            fieldItems.Add(afiServiceLevelName);

            AutoFieldItem afiServiceExpirationDate = new AutoFieldItem();

            afiServiceExpirationDate.Alias         = "Service Expiration Date";
            afiServiceExpirationDate.DataType      = "datetime";
            afiServiceExpirationDate.FieldID       = 101013;
            afiServiceExpirationDate.FieldName     = "Service Expiration Date";
            afiServiceExpirationDate.IsCustom      = false;
            afiServiceExpirationDate.IsVisible     = true;
            afiServiceExpirationDate.ListValues    = null;
            afiServiceExpirationDate.LookupTableID = null;
            afiServiceExpirationDate.Size          = 0;
            afiServiceExpirationDate.Description   = "";
            afiServiceExpirationDate.TableID       = -2;
            afiServiceExpirationDate.RefType       = ReferenceType.Tickets;
            afiServiceExpirationDate.AuxID         = null;
            afiServiceExpirationDate.OtherTrigger  = "organizations.serviceexpirationdate";
            fieldItems.Add(afiServiceExpirationDate);

            AutoFieldItem afiCustomerIsActive = new AutoFieldItem();

            afiCustomerIsActive.Alias         = "Customer Is Active";
            afiCustomerIsActive.DataType      = "bit";
            afiCustomerIsActive.FieldID       = 101014;
            afiCustomerIsActive.FieldName     = "Customer Is Active";
            afiCustomerIsActive.IsCustom      = false;
            afiCustomerIsActive.IsVisible     = true;
            afiCustomerIsActive.ListValues    = null;
            afiCustomerIsActive.LookupTableID = null;
            afiCustomerIsActive.Size          = 0;
            afiCustomerIsActive.Description   = "";
            afiCustomerIsActive.TableID       = -2;
            afiCustomerIsActive.RefType       = ReferenceType.Tickets;
            afiCustomerIsActive.AuxID         = null;
            afiCustomerIsActive.OtherTrigger  = "organizations.active";
            fieldItems.Add(afiCustomerIsActive);

            AutoFieldItem afiCustomerCustomValue = new AutoFieldItem();

            afiCustomerCustomValue.Alias         = "Customer Custom Value";
            afiCustomerCustomValue.DataType      = "text";
            afiCustomerCustomValue.FieldID       = -999;
            afiCustomerCustomValue.FieldName     = "Customer Custom Value";
            afiCustomerCustomValue.IsCustom      = false;
            afiCustomerCustomValue.IsVisible     = true;
            afiCustomerCustomValue.ListValues    = orgCustomFields.ToArray();
            afiCustomerCustomValue.LookupTableID = null;
            afiCustomerCustomValue.Size          = 0;
            afiCustomerCustomValue.Description   = "";
            afiCustomerCustomValue.TableID       = -2;
            afiCustomerCustomValue.RefType       = ReferenceType.Tickets;
            afiCustomerCustomValue.AuxID         = null;
            afiCustomerCustomValue.OtherTrigger  = "organizations.customvalue";
            fieldItems.Add(afiCustomerCustomValue);

            AutoFieldItem afiCustomerServiceExpired = new AutoFieldItem();

            afiCustomerServiceExpired.Alias         = "Customer Service Expired";
            afiCustomerServiceExpired.DataType      = "bit";
            afiCustomerServiceExpired.FieldID       = 101015;
            afiCustomerServiceExpired.FieldName     = "Customer Service Expired";
            afiCustomerServiceExpired.IsCustom      = false;
            afiCustomerServiceExpired.IsVisible     = true;
            afiCustomerServiceExpired.ListValues    = null;
            afiCustomerServiceExpired.LookupTableID = null;
            afiCustomerServiceExpired.Size          = 0;
            afiCustomerServiceExpired.Description   = "";
            afiCustomerServiceExpired.TableID       = -2;
            afiCustomerServiceExpired.RefType       = ReferenceType.Tickets;
            afiCustomerServiceExpired.AuxID         = null;
            afiCustomerServiceExpired.OtherTrigger  = "organizations.serviceexpired";
            fieldItems.Add(afiCustomerServiceExpired);

            result.Fields = fieldItems.ToArray();

            Users users = new Users(UserSession.LoginUser);

            users.LoadByOrganizationID(UserSession.LoginUser.OrganizationID, true);
            List <AutocompleteItem> userItems = new List <AutocompleteItem>();

            foreach (User user in users)
            {
                userItems.Add(new AutocompleteItem(user.DisplayName, user.UserID.ToString()));
            }
            result.Users = userItems.ToArray();

            Groups groups = new Groups(UserSession.LoginUser);

            groups.LoadByOrganizationID(UserSession.LoginUser.OrganizationID);
            List <AutocompleteItem> groupItems = new List <AutocompleteItem>();

            foreach (Group group in groups)
            {
                groupItems.Add(new AutocompleteItem(group.Name, group.GroupID.ToString()));
            }
            result.Groups = groupItems.ToArray();

            TicketSeverities severities = new TicketSeverities(UserSession.LoginUser);

            severities.LoadByOrganizationID(UserSession.LoginUser.OrganizationID);
            List <AutocompleteItem> severityItems = new List <AutocompleteItem>();

            foreach (TicketSeverity severity in severities)
            {
                severityItems.Add(new AutocompleteItem(severity.Name, severity.TicketSeverityID.ToString()));
            }
            result.Severities = severityItems.ToArray();

            List <AutocompleteItem> statusItems = new List <AutocompleteItem>();

            List <AutocompleteItem> ticketTypeItems = new List <AutocompleteItem>();

            foreach (TicketType ticketType in ticketTypes)
            {
                ticketTypeItems.Add(new AutocompleteItem(ticketType.Name, ticketType.TicketTypeID.ToString()));


                TicketStatuses statuses = new TicketStatuses(UserSession.LoginUser);
                statuses.LoadAllPositions(ticketType.TicketTypeID);

                foreach (TicketStatus status in statuses)
                {
                    statusItems.Add(new AutocompleteItem(ticketType.Name + " - " + status.Name, status.TicketStatusID.ToString()));
                }
            }
            result.Statuses    = statusItems.ToArray();
            result.TicketTypes = ticketTypeItems.ToArray();
            return(result);
        }
    public static string GetTypesHtml(SelectedType type, string arg)
    {
        Organization organization = Organizations.GetOrganization(UserSession.LoginUser, UserSession.LoginUser.OrganizationID);
        DataTable    table        = new DataTable();

        table.Columns.Add("ID");
        table.Columns.Add("Name");
        table.Columns.Add("Description");
        string result = "";

        switch (type)
        {
        case SelectedType.ActionTypes:
            ActionTypes actionTypes = new ActionTypes(UserSession.LoginUser);
            actionTypes.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            table.Columns.Add("Is Timed");
            foreach (ActionType actionType in actionTypes)
            {
                table.Rows.Add(new string[] { actionType.ActionTypeID.ToString(), actionType.Name, actionType.Description, actionType.IsTimed.ToString() });
            }
            break;

        case SelectedType.PhoneTypes:
            PhoneTypes phoneTypes = new PhoneTypes(UserSession.LoginUser);
            phoneTypes.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            foreach (PhoneType phoneType in phoneTypes)
            {
                table.Rows.Add(new string[] { phoneType.PhoneTypeID.ToString(), phoneType.Name, phoneType.Description });
            }
            break;

        case SelectedType.ProductVersionStatuses:
            ProductVersionStatuses productVersionStatuses = new ProductVersionStatuses(UserSession.LoginUser);
            productVersionStatuses.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            table.Columns.Add("Is Shipping");
            table.Columns.Add("Is Discontinued");
            foreach (ProductVersionStatus productVersionStatus in productVersionStatuses)
            {
                table.Rows.Add(new string[] { productVersionStatus.ProductVersionStatusID.ToString(), productVersionStatus.Name, productVersionStatus.Description, productVersionStatus.IsShipping.ToString(), productVersionStatus.IsDiscontinued.ToString() });
            }
            break;

        case SelectedType.TicketSeverities:
            table.Columns.Add("Visible on Portal");
            TicketSeverities ticketSeverities = new TicketSeverities(UserSession.LoginUser);
            ticketSeverities.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            foreach (TicketSeverity ticketSeverity in ticketSeverities)
            {
                table.Rows.Add(new string[] { ticketSeverity.TicketSeverityID.ToString(), ticketSeverity.Name, ticketSeverity.Description, ticketSeverity.VisibleOnPortal.ToString() });
            }
            break;

        case SelectedType.TicketStatuses:
            TicketStatuses ticketStatuses = new TicketStatuses(UserSession.LoginUser);
            ticketStatuses.LoadAllPositions(int.Parse(arg));

            table.Columns.Add("Is Closed");
            table.Columns.Add("Closed Email");
            table.Columns.Add("Email Response");
            table.Columns.Add("Pause SLA");

            foreach (TicketStatus ticketStatus in ticketStatuses)
            {
                table.Rows.Add(new string[] { ticketStatus.TicketStatusID.ToString(), ticketStatus.Name, ticketStatus.Description, ticketStatus.IsClosed.ToString(), ticketStatus.IsClosedEmail.ToString(), ticketStatus.IsEmailResponse.ToString(), ticketStatus.PauseSLA.ToString() });
            }
            break;

        case SelectedType.TicketTypes:
            table.Columns.Add("Icon");
            table.Columns.Add("Visible on Portal");
            string icon = "<img src=\"../{0}\" />";
            if (organization.UseProductFamilies)
            {
                TicketTypesView ticketTypes = new TicketTypesView(UserSession.LoginUser);
                ticketTypes.LoadAllPositions(UserSession.LoginUser.OrganizationID);
                table.Columns.Add("Product Line");
                table.Columns.Add("Active");
                foreach (TicketTypesViewItem ticketType in ticketTypes)
                {
                    table.Rows.Add(new string[] { ticketType.TicketTypeID.ToString(), ticketType.Name, ticketType.Description, string.Format(icon, ticketType.IconUrl), ticketType.IsVisibleOnPortal.ToString(), ticketType.ProductFamilyName });
                }
            }
            else
            {
                TicketTypes ticketTypes = new TicketTypes(UserSession.LoginUser);
                ticketTypes.LoadAllPositions(UserSession.LoginUser.OrganizationID);
                table.Columns.Add("Active");
                foreach (TicketType ticketType in ticketTypes)
                {
                    table.Rows.Add(new string[] { ticketType.TicketTypeID.ToString(), ticketType.Name, ticketType.Description, string.Format(icon, ticketType.IconUrl), ticketType.IsVisibleOnPortal.ToString() });
                }
            }
            break;

        case SelectedType.ActivityTypes:
            ActivityTypes activityTypes = new ActivityTypes(UserSession.LoginUser);
            activityTypes.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            foreach (ActivityType activityType in activityTypes)
            {
                table.Rows.Add(new string[] { activityType.ActivityTypeID.ToString(), activityType.Name, activityType.Description });
            }
            break;

        default:
            break;
        }

        return(BuildTable(table));
    }
        private void LoadCustomProperties()
        {
            int oldID = GetSelectedPropertyID();

            ReferenceType refType = GetSelectedPropertyType();

            DataTable table = new DataTable();

            table.Columns.Add("ID", System.Type.GetType("System.Int32"));
            table.Columns.Add("Name");
            table.Columns.Add("Description");
            table.Columns.Add("IsClosed", System.Type.GetType("System.Boolean"));
            table.Columns.Add("IsShipping", System.Type.GetType("System.Boolean"));
            table.Columns.Add("IsDiscontinued", System.Type.GetType("System.Boolean"));

            gridProperties.Columns["IsShipping"].IsVisible     = false;
            gridProperties.Columns["IsDiscontinued"].IsVisible = false;
            gridProperties.Columns["IsClosed"].IsVisible       = false;

            switch (refType)
            {
            case ReferenceType.ActionTypes:
                ActionTypes actionTypes = new ActionTypes(LoginSession.LoginUser);
                actionTypes.LoadAllPositions(OrganizationID);
                foreach (ActionType actionType in actionTypes)
                {
                    DataRow row = table.NewRow();
                    row[0] = actionType.ActionTypeID;
                    row[1] = actionType.Name;
                    row[2] = actionType.Description;
                    row[3] = false;
                    row[4] = false;
                    row[5] = false;
                    table.Rows.Add(row);
                }

                break;

            case ReferenceType.PhoneTypes:
                PhoneTypes phoneTypes = new PhoneTypes(LoginSession.LoginUser);
                phoneTypes.LoadAllPositions(OrganizationID);
                foreach (PhoneType phoneType in phoneTypes)
                {
                    DataRow row = table.NewRow();
                    row[0] = phoneType.PhoneTypeID;
                    row[1] = phoneType.Name;
                    row[2] = phoneType.Description;
                    row[3] = false;
                    row[4] = false;
                    row[5] = false;
                    table.Rows.Add(row);
                }
                break;

            case ReferenceType.ProductVersionStatuses:
                ProductVersionStatuses productVersionStatuses = new ProductVersionStatuses(LoginSession.LoginUser);
                productVersionStatuses.LoadAllPositions(OrganizationID);
                foreach (ProductVersionStatus productVersionStatus in productVersionStatuses)
                {
                    DataRow row = table.NewRow();
                    row[0] = productVersionStatus.ProductVersionStatusID;
                    row[1] = productVersionStatus.Name;
                    row[2] = productVersionStatus.Description;
                    row[3] = false;
                    row[4] = productVersionStatus.IsShipping;
                    row[5] = productVersionStatus.IsDiscontinued;
                    table.Rows.Add(row);
                }
                gridProperties.Columns["IsShipping"].IsVisible     = true;
                gridProperties.Columns["IsDiscontinued"].IsVisible = true;
                break;

            case ReferenceType.TicketSeverities:
                TicketSeverities ticketSeverities = new TicketSeverities(LoginSession.LoginUser);
                ticketSeverities.LoadAllPositions(OrganizationID);
                foreach (TicketSeverity ticketSeverity in ticketSeverities)
                {
                    DataRow row = table.NewRow();
                    row[0] = ticketSeverity.TicketSeverityID;
                    row[1] = ticketSeverity.Name;
                    row[2] = ticketSeverity.Description;
                    row[3] = false;
                    row[4] = false;
                    row[5] = false;
                    table.Rows.Add(row);
                }
                break;

            case ReferenceType.TicketStatuses:
                TicketStatuses ticketStatuses = new TicketStatuses(LoginSession.LoginUser);
                ticketStatuses.LoadAllPositions(GetSelectedTicketType());
                foreach (TicketStatus ticketStatus in ticketStatuses)
                {
                    DataRow row = table.NewRow();
                    row[0] = ticketStatus.TicketStatusID;
                    row[1] = ticketStatus.Name;
                    row[2] = ticketStatus.Description;
                    row[3] = ticketStatus.IsClosed;
                    row[4] = false;
                    row[5] = false;
                    table.Rows.Add(row);
                }
                gridProperties.Columns["IsClosed"].IsVisible = true;
                break;

            default:
                break;
            }



            gridProperties.DataSource = table;
            if (gridProperties.Rows.Count > 0)
            {
                gridProperties.Rows[0].IsCurrent = true;
            }
            SetSelectedPropertyID(oldID);
        }
    public static RadComboBoxItemData[] GetReplaceTypeComboData(int id, SelectedType type, int ticketTypeID)
    {
        //IDictionary<string, object> contextDictionary = (IDictionary<string, object>)context;
        List <RadComboBoxItemData> list = new List <RadComboBoxItemData>();

        /*string[] s = context["FilterString"].ToString().Split(',');
         * SelectedType type = (SelectedType)int.Parse(s[0]);
         * int ticketTypeID = int.Parse(s[1]);
         * int id = int.Parse(s[2]);*/

        BaseCollection collection  = null;
        string         nameColName = "Name";
        string         idColName   = "ID";

        switch (type)
        {
        case SelectedType.ActionTypes:
            ActionTypes actionTypes = new ActionTypes(UserSession.LoginUser);
            actionTypes.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            collection = actionTypes;
            idColName  = "ActionTypeID";
            break;

        case SelectedType.PhoneTypes:
            PhoneTypes phoneTypes = new PhoneTypes(UserSession.LoginUser);
            phoneTypes.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            collection = phoneTypes;
            idColName  = "PhoneTypeID";
            break;

        case SelectedType.ProductVersionStatuses:
            ProductVersionStatuses productVersionStatuses = new ProductVersionStatuses(UserSession.LoginUser);
            productVersionStatuses.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            collection = productVersionStatuses;
            idColName  = "ProductVersionStatusID";
            break;

        case SelectedType.TicketSeverities:
            TicketSeverities ticketSeverities = new TicketSeverities(UserSession.LoginUser);
            ticketSeverities.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            collection = ticketSeverities;
            idColName  = "TicketSeverityID";
            break;

        case SelectedType.TicketStatuses:
            TicketStatuses ticketStatuses = new TicketStatuses(UserSession.LoginUser);
            TicketType     ticketType     = TicketTypes.GetTicketType(UserSession.LoginUser, ticketTypeID);
            if (ticketType.OrganizationID == UserSession.LoginUser.OrganizationID)
            {
                ticketStatuses.LoadAllPositions(ticketTypeID);
                collection = ticketStatuses;
                idColName  = "TicketStatusID";
            }
            break;

        case SelectedType.TicketTypes:
            TicketTypes ticketTypes = new TicketTypes(UserSession.LoginUser);
            ticketTypes.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            collection = ticketTypes;
            idColName  = "TicketTypeID";
            break;

        case SelectedType.ActivityTypes:
            ActivityTypes activityTypes = new ActivityTypes(UserSession.LoginUser);
            activityTypes.LoadAllPositions(UserSession.LoginUser.OrganizationID);
            //Load base items
            //Get default activity types
            foreach (ActivityTypeEnum activity in Enum.GetValues(typeof(ActivityTypeEnum)))
            {
                var value = Enum.Parse(typeof(ActivityTypeEnum), activity.ToString());
                //results.Add(new ActivityTypesDropDown() { Name = activity.ToString(), Value = (int)value });
                RadComboBoxItemData itemData = new RadComboBoxItemData();
                itemData.Text  = activity.ToString();
                itemData.Value = ((int)value).ToString();
                list.Add(itemData);
            }

            collection = activityTypes;
            idColName  = "ActivityTypeID";
            break;

        default:
            break;
        }

        foreach (DataRow row in collection.Table.Rows)
        {
            int i = (int)row[idColName];
            if (id != i)
            {
                RadComboBoxItemData itemData = new RadComboBoxItemData();
                itemData.Text  = row[nameColName].ToString();
                itemData.Value = i.ToString();
                list.Add(itemData);
            }
        }

        if (list.Count < 1)
        {
            RadComboBoxItemData noData = new RadComboBoxItemData();
            noData.Text  = "[No types to display.]";
            noData.Value = "-1";
            list.Add(noData);
        }

        return(list.ToArray());
    }