Ejemplo n.º 1
0
        public static string GetTicketTypes(RestCommand command, bool orderByDateCreated = false)
        {
            TicketTypes items = new TicketTypes(command.LoginUser);

            if (orderByDateCreated)
            {
                items.LoadByOrganizationID(command.Organization.OrganizationID, "DateCreated DESC");
            }
            else
            {
                items.LoadByOrganizationID(command.Organization.OrganizationID);
            }
            return(items.GetXml("TicketTypes", "TicketType", true, command.Filters));
        }
    public static TicketCounts[] GetData()
    {
        List <TicketCounts> result = new List <TicketCounts>();

        TicketTypes ticketTypes = new TicketTypes(UserSession.LoginUser);

        ticketTypes.LoadByOrganizationID(UserSession.LoginUser.OrganizationID, UserSession.CurrentUser.ProductType);

        Users users = new Users(UserSession.LoginUser);

        users.LoadByOrganizationID(UserSession.LoginUser.OrganizationID, true);

        foreach (User user in users)
        {
            string value = user.DisplayName;
            int    count = 0;

            foreach (TicketType ticketType in ticketTypes)
            {
                count += Tickets.GetUserOpenTicketCount(UserSession.LoginUser, user.UserID, ticketType.TicketTypeID);
            }

            TicketCounts counts = new TicketCounts();
            counts.Name  = value;
            counts.Count = count;
            result.Add(counts);
        }


        return(result.OrderBy(ticketcount => ticketcount.Name).ToArray());
    }
    public static TicketCounts[] GetData()
    {
        List <TicketCounts> result      = new List <TicketCounts>();
        TicketTypes         ticketTypes = new TicketTypes(UserSession.LoginUser);

        ticketTypes.LoadByOrganizationID(UserSession.LoginUser.OrganizationID, UserSession.CurrentUser.ProductType);

        foreach (TicketType ticketType in ticketTypes)
        {
            int    count = Tickets.GetUserOpenTicketCount(UserSession.LoginUser, UserSession.LoginUser.UserID, ticketType.TicketTypeID);
            string value = ticketType.Name;
            if (value.Length > 8)
            {
                value = value.Substring(0, 8);
            }
            value = value + " (" + count.ToString() + ")";
            TicketCounts counts = new TicketCounts();
            counts.Name  = value;
            counts.Count = count;
            result.Add(counts);
        }


        return(result.ToArray());
    }
Ejemplo n.º 4
0
    private void LoadCharts(int organizationID)
    {
        TicketTypes ticketTypes = new TicketTypes(UserSession.LoginUser);

        ticketTypes.LoadByOrganizationID(UserSession.LoginUser.OrganizationID, UserSession.CurrentUser.ProductType);

        DataTable table = new DataTable();

        table.Columns.Add("TicketType");
        table.Columns.Add("Count", Type.GetType("System.Int32"));

        int total = 0;

        foreach (TicketType ticketType in ticketTypes)
        {
            int count = Tickets.GetOrganizationOpenTicketCount(UserSession.LoginUser, organizationID, ticketType.TicketTypeID);
            total += count;
            if (count > 0)
            {
                table.Rows.Add(new string[] { ticketType.Name, count.ToString() });
            }
        }

        chartOpenTickets.ChartTitle.TextBlock.Text = total.ToString() + " Open Tickets";
        chartOpenTickets.DataSource = table;
        chartOpenTickets.DataBind();
        chartOpenTickets.Series[0].Appearance.LabelAppearance.Distance           = 20;
        chartOpenTickets.Series[0].Appearance.TextAppearance.TextProperties.Font = new System.Drawing.Font("Arial", 6);

        table = new DataTable();
        table.Columns.Add("TicketType");
        table.Columns.Add("Count", Type.GetType("System.Int32"));

        total = 0;

        foreach (TicketType ticketType in ticketTypes)
        {
            int count = Tickets.GetOrganizationClosedTicketCount(UserSession.LoginUser, organizationID, ticketType.TicketTypeID);
            total += count;
            if (count > 0)
            {
                table.Rows.Add(new string[] { ticketType.Name, count.ToString() });
            }
        }

        chartClosedTickets.ChartTitle.TextBlock.Text = total.ToString() + " Closed Tickets";
        chartClosedTickets.DataSource = table;
        chartClosedTickets.DataBind();
        chartClosedTickets.Series[0].Appearance.LabelAppearance.Distance           = 20;
        chartClosedTickets.Series[0].Appearance.TextAppearance.TextProperties.Font = new System.Drawing.Font("Arial", 6);
    }
Ejemplo n.º 5
0
        public static string GetTicketTypes(RestCommand command)
        {
            TicketTypes ticketTypes = new TicketTypes(command.LoginUser);

            ticketTypes.LoadByOrganizationID(command.Organization.OrganizationID);

            if (command.Format == RestFormat.XML)
            {
                return(ticketTypes.GetXml("TicketTypes", "TicketType", true, command.Filters));
            }
            else
            {
                throw new RestException(HttpStatusCode.BadRequest, "Invalid data format");
            }
        }
Ejemplo n.º 6
0
    private void LoadTicketTypes()
    {
        cmbTicketTypes.Items.Clear();
        TicketTypes types = new TicketTypes(UserSession.LoginUser);

        types.LoadByOrganizationID(UserSession.LoginUser.OrganizationID, UserSession.CurrentUser.ProductType);
        foreach (TicketType type in types)
        {
            cmbTicketTypes.Items.Add(new RadComboBoxItem(type.Name, type.TicketTypeID.ToString()));
        }
        if (cmbTicketTypes.Items.Count > 0)
        {
            cmbTicketTypes.SelectedIndex = 0;
        }
    }
        public static string GetTickets(RestCommand command)
        {
            string xml = "";

            if (command.Filters["TicketTypeID"] != null)
            {
                try
                {
                    ReportTicketsView tickets = new ReportTicketsView(command.LoginUser);
                    int        ticketTypeID   = int.Parse(command.Filters["TicketTypeID"]);
                    TicketType ticketType     = TicketTypes.GetTicketType(command.LoginUser, ticketTypeID);
                    if (ticketType.OrganizationID != command.Organization.OrganizationID)
                    {
                        throw new Exception();
                    }
                    tickets.LoadByTicketTypeID(ticketTypeID);
                    xml = tickets.GetXml("Tickets", "Ticket", true, command.Filters);
                }
                catch (Exception ex)
                {
                    throw new RestException(HttpStatusCode.NotAcceptable, "Invalid TicketTypeID to filter.", ex);
                }
            }
            else
            {
                TicketTypes ticketTypes = new TicketTypes(command.LoginUser);
                ticketTypes.LoadByOrganizationID(command.Organization.OrganizationID);

                ReportTicketsView tickets = new ReportTicketsView(command.LoginUser);
                XmlTextWriter     writer  = Tickets.BeginXmlWrite("Tickets");

                foreach (TicketType ticketType in ticketTypes)
                {
                    tickets.LoadByTicketTypeID(ticketType.TicketTypeID);
                    //writer.WriteStartElement(ticketType.Name);
                    foreach (DataRow row in tickets.Table.Rows)
                    {
                        tickets.WriteXml(writer, row, "Ticket", true, command.Filters);
                    }
                    //writer.WriteEndElement();
                }

                xml = Tickets.EndXmlWrite(writer);
            }

            //return tickets.GetXml("Tickets", "Ticket", command.Filters["TicketTypeID"] != null, command.Filters);
            return(xml);
        }
Ejemplo n.º 8
0
    private void CreateNavButtons()
    {
        tsMain.Tabs.Clear();

        tsMain.Tabs.Add(new RadTab("Details", "OrganizationInformation.aspx?OrganizationID="));
        tsMain.Tabs.Add(new RadTab("Contacts", "Contacts.aspx?OrganizationID="));
        if (!UserSession.CurrentUser.IsTSUser)
        {
            if (UserSession.CurrentUser.ProductType == ProductType.Enterprise)
            {
                tsMain.Tabs.Add(new RadTab("Products", "OrganizationProducts.aspx?OrganizationID="));
            }
            tsMain.Tabs.Add(new RadTab("Attachments", "Attachments.aspx?RefType=9&RefID="));
            tsMain.Tabs.Add(new RadTab("Notes", "Notes.aspx?RefType=9&RefID="));
        }
        else
        {
            tsMain.Tabs.Add(new RadTab("Account Info", "AccountInformation.aspx?OrganizationID="));
        }

        RadTab tab = new RadTab("History", "History.aspx?RefType=9&RefID=");

        tsMain.Tabs.Add(tab);

        if (UserSession.CurrentUser.IsInventoryEnabled)
        {
            tsMain.Tabs.Add(new RadTab("Inventory", "../Inventory/CustomerInventory.aspx?CustID="));
        }

        tsMain.Tabs.Add(new RadTab("Water Cooler", "../vcr/1_9_0/Pages/Watercooler.html?"));

        if (!UserSession.CurrentUser.IsTSUser)
        {
            tsMain.Tabs.Add(new RadTab("All Tickets", "TicketTabsAll.aspx?tf_CustomerID="));

            //tsMain.Tabs.Add(new RadTab("All Tickets", "Tickets.aspx?CustomerID="));
            TicketTypes ticketTypes = new TicketTypes(UserSession.LoginUser);
            ticketTypes.LoadByOrganizationID(UserSession.LoginUser.OrganizationID, UserSession.CurrentUser.ProductType);
            foreach (TicketType ticketType in ticketTypes)
            {
                tsMain.Tabs.Add(new RadTab(ticketType.Name, "TicketTabsOrganization.aspx?TicketTypeID=" + ticketType.TicketTypeID.ToString() + "&OrganizationID="));
            }
        }
        else
        {
            tsMain.Tabs.Add(new RadTab("All Tickets (READONLY - DO NOT MODIFY!!!)", "Tickets.aspx?CustomerID="));
        }
    }
Ejemplo n.º 9
0
        private void LoadTicketTypes(Organization organization)
        {
            if (organization == null)
            {
                return;
            }
            cmbTicketType.Items.Clear();

            TicketTypes ticketTypes = new TicketTypes(LoginSession.LoginUser);

            ticketTypes.LoadByOrganizationID(OrganizationID, organization.ProductType);

            foreach (TicketType type in ticketTypes)
            {
                cmbTicketType.Items.Add(new NamObjectItem(type.Name, type.TicketTypeID));
            }

            if (cmbTicketType.Items.Count > 0)
            {
                cmbTicketType.SelectedIndex = 0;
            }
        }
Ejemplo n.º 10
0
    private void CreateNavButtons()
    {
        tsMain.Tabs.Clear();

        tsMain.Tabs.Add(new RadTab("Product Information", "ProductInformation.aspx?"));
        tsMain.Tabs.Add(new RadTab("Version Information", "../vcr/1_9_0/Pages/ProductVersion.html?"));
        tsMain.Tabs.Add(new RadTab("Customers", "ProductOrganizations.aspx?"));

        RadTab tab = new RadTab("History", "History.aspx?");

        tsMain.Tabs.Add(tab);
        tsMain.Tabs.Add(new RadTab("Water Cooler", "../vcr/1_9_0/Pages/Watercooler.html?"));
        tsMain.Tabs.Add(new RadTab("All Tickets", "TicketTabsAll.aspx?"));

        TicketTypes ticketTypes = new TicketTypes(UserSession.LoginUser);

        ticketTypes.LoadByOrganizationID(UserSession.LoginUser.OrganizationID, UserSession.CurrentUser.ProductType);
        foreach (TicketType ticketType in ticketTypes)
        {
            tsMain.Tabs.Add(new RadTab(ticketType.Name, "TicketTabsProduct.aspx?tf_TicketTypeID=" + ticketType.TicketTypeID.ToString() + "&"));
        }
        tsMain.Tabs.Add(new RadTab("Knowledge Base", "../vcr/1_9_0/Pages/TicketGrid.html?tf_IsKnowledgeBase=true&"));
    }
Ejemplo n.º 11
0
        private static List <DescriptiveClauseItem> GetSummaryDescFields(LoginUser loginUser, SummaryReport summaryReport)
        {
            List <DescriptiveClauseItem> result = new List <DescriptiveClauseItem>();
            ReportSubcategory            sub    = ReportSubcategories.GetReportSubcategory(loginUser, summaryReport.Subcategory);

            ReportTables tables = new ReportTables(loginUser);

            tables.LoadAll();

            ReportTableFields tableFields = new ReportTableFields(loginUser);

            tableFields.LoadAll();
            TimeSpan    offset      = loginUser.Offset;
            TicketTypes ticketTypes = new TicketTypes(loginUser);

            ticketTypes.LoadByOrganizationID(loginUser.OrganizationID);

            foreach (ReportSummaryDescriptiveField field in summaryReport.Fields.Descriptive)
            {
                if (field.Field.IsCustom)
                {
                    CustomField customField = (CustomField)CustomFields.GetCustomField(loginUser, field.Field.FieldID);
                    if (customField == null)
                    {
                        continue;
                    }
                    string fieldName = DataUtils.GetReportPrimaryKeyFieldName(customField.RefType);
                    if (fieldName != "")
                    {
                        fieldName = DataUtils.GetCustomFieldColumn(loginUser, customField, fieldName, true, false);

                        if (customField.FieldType == CustomFieldType.DateTime)
                        {
                            fieldName = string.Format("CAST(SWITCHOFFSET(TODATETIMEOFFSET({0}, '+00:00'), '{1}{2:D2}:{3:D2}') AS DATETIME)",
                                                      fieldName,
                                                      offset < TimeSpan.Zero ? "-" : "+",
                                                      Math.Abs(offset.Hours),
                                                      Math.Abs(offset.Minutes));

                            fieldName = GetDateGroupField(fieldName, field.Value1);
                        }
                        string alias = customField.Name;

                        if (customField.AuxID > 0 && customField.RefType == ReferenceType.Tickets)
                        {
                            TicketType ticketType = ticketTypes.FindByTicketTypeID(customField.AuxID);
                            if (ticketType != null && ticketType.OrganizationID == customField.OrganizationID)
                            {
                                alias = string.Format("{1} ({2})", fieldName, customField.Name, ticketType.Name);
                            }
                        }
                        result.Add(new DescriptiveClauseItem(fieldName, alias));
                    }
                }
                else
                {
                    ReportTableField tableField = tableFields.FindByReportTableFieldID(field.Field.FieldID);
                    ReportTable      table      = tables.FindByReportTableID(tableField.ReportTableID);
                    string           fieldName  = table.TableName + "." + tableField.FieldName;
                    if (tableField.DataType.Trim().ToLower() == "datetime")
                    {
                        fieldName = string.Format("CAST(SWITCHOFFSET(TODATETIMEOFFSET({0}, '+00:00'), '{1}{2:D2}:{3:D2}') AS DATETIME)",
                                                  fieldName,
                                                  offset < TimeSpan.Zero ? "-" : "+",
                                                  Math.Abs(offset.Hours),
                                                  Math.Abs(offset.Minutes));
                        fieldName = GetDateGroupField(fieldName, field.Value1);
                    }

                    result.Add(new DescriptiveClauseItem(fieldName, tableField.Alias));
                }
            }
            return(result);
        }
        public FieldItem[] GetAllFields(ReferenceType refType, int?auxID, bool isReadOnly)
        {
            List <FieldItem> items = new List <FieldItem>();
            //The fields that are synched by 'default' (stock) should not be available in the dropdown list for the mappings because this creates issues with the sync (data being overwritten). Add them to this list in lowercase.
            List <string> excludedFields = new List <string>();
            int           tableID;

            switch (refType)
            {
            case ReferenceType.Organizations: tableID = 6; break;

            case ReferenceType.Tickets: tableID = 10; break;

            case ReferenceType.Users: tableID = 11; break;

            case ReferenceType.Contacts:
                tableID = 12;
                //reference: Integration.vb UpdateContactInfo()
                excludedFields = new List <string>()
                {
                    "name", "title", "email"
                };
                break;

            case ReferenceType.TicketTypes: tableID = 16; break;

            default: return(null);
            }

            TicketTypes ticketTypes = new TicketTypes(TSAuthentication.GetLoginUser());

            ticketTypes.LoadByOrganizationID(TSAuthentication.OrganizationID);

            if (refType == ReferenceType.TicketTypes)
            {
                foreach (TicketType ticketType in ticketTypes)
                {
                    items.Add(new FieldItem(ticketType.TicketTypeID, false, ticketType.Name));
                }
            }
            else
            {
                ReportTableFields fields = new ReportTableFields(TSAuthentication.GetLoginUser());
                fields.LoadByReportTableID(tableID, isReadOnly);

                CustomFields customs = new CustomFields(fields.LoginUser);
                customs.LoadByReferenceType(TSAuthentication.OrganizationID, refType, auxID);

                foreach (ReportTableField field in fields)
                {
                    if (excludedFields.Count == 0 ||
                        (tableID == 12 &&
                         !excludedFields.Contains(field.FieldName.ToLower())))
                    {
                        items.Add(new FieldItem(field.ReportTableFieldID, false, field.FieldName));
                    }
                }

                foreach (CustomField custom in customs)
                {
                    string ticketTypeName = ticketTypes.Where(p => p.TicketTypeID == custom.AuxID).Select(t => t.Name).SingleOrDefault();
                    items.Add(new FieldItem(custom.CustomFieldID,
                                            true,
                                            string.Format("{0}{1}", custom.Name,
                                                          string.IsNullOrEmpty(ticketTypeName) ? "" : " (" + ticketTypeName + ")")));
                }
            }

            return(items.ToArray());
        }
Ejemplo n.º 13
0
        public TsMenuItem[] GetMainMenuItems()
        {
            List <TsMenuItem> items     = new List <TsMenuItem>();
            LoginUser         loginUser = TSAuthentication.GetLoginUser();

            Organization org  = TSAuthentication.GetOrganization(loginUser);
            User         user = TSAuthentication.GetUser(loginUser);
            string       data = @"{{""ContentUrl"":""{0}"",""PaneInfoUrl"":""{1}""}}";


            if (org.ParentID != null)
            {
                if (user.ShowWelcomePage == true && user.IsSystemAdmin == true)
                {
                    items.Add(new TsMenuItem("welcome", "mniWelcome", "Getting Started", "vcr/1_9_0/images/nav/20/GettingStarted.png", string.Format(data, "vcr/1_9_0/Pages/Welcome.html", "vcr/1_9_0/PaneInfo/Welcome.html")));
                }

                if (IsMenuItemActive(user, "mniDashboard"))
                {
                    items.Add(new TsMenuItem("dashboard", "mniDashboard", "Dashboard", "vcr/1_9_0/images/nav/20/Dashboard.png", string.Format(data, "vcr/1_9_0/Pages/Dashboard.html", "vcr/1_9_0/PaneInfo/Dashboard.html")));
                }

                if (IsMenuItemActive(user, "mniMyTickets"))
                {
                    TsMenuItem myItem = new TsMenuItem("mytickets", "mniMyTickets", "My Tickets", "vcr/1_9_0/images/nav/20/mytickets.png", string.Format(data, "vcr/1_9_0/Pages/TicketTabs.html?UserID=" + TSAuthentication.UserID, "vcr/1_9_0/PaneInfo/MyTickets.html"));
                    items.Add(myItem);

                    Reports privateTicketViews = new Reports(TSAuthentication.GetLoginUser());
                    privateTicketViews.LoadAllPrivateTicketViews(TSAuthentication.OrganizationID, TSAuthentication.UserID);

                    if (!privateTicketViews.IsEmpty)
                    {
                        foreach (Report report in privateTicketViews)
                        {
                            myItem.AddItem(new TsMenuItem("tickettype", "mniTicketView_" + report.ReportID.ToString(), report.Name, "vcr/1_9_0/images/nav/20/tickets.png", string.Format(data, "vcr/1_9_0/Pages/TicketView.html?ReportID=" + report.ReportID.ToString(), "vcr/1_9_0/PaneInfo/Reports.html")));
                        }
                    }
                }

                if (IsMenuItemActive(user, "mniTickets"))
                {
                    TsMenuItem ticketItem = new TsMenuItem("tickets", "mniTickets", "All Tickets", "vcr/1_9_0/images/nav/20/tickets.png", string.Format(data, "vcr/1_9_0/Pages/TicketTabs.html", "vcr/1_9_0/PaneInfo/Tickets.html"));
                    items.Add(ticketItem);

                    Reports publicTicketViews = new Reports(TSAuthentication.GetLoginUser());
                    publicTicketViews.LoadAllPublicTicketViews(TSAuthentication.OrganizationID, TSAuthentication.UserID);

                    if (!publicTicketViews.IsEmpty)
                    {
                        foreach (Report report in publicTicketViews)
                        {
                            ticketItem.AddItem(new TsMenuItem("tickettype", "mniTicketView_" + report.ReportID.ToString(), report.Name, "vcr/1_9_0/images/nav/20/tickets.png", string.Format(data, "vcr/1_9_0/Pages/TicketView.html?ReportID=" + report.ReportID.ToString(), "vcr/1_9_0/PaneInfo/Reports.html")));
                        }
                    }

                    TicketTypes ticketTypes = new TicketTypes(loginUser);
                    ticketTypes.LoadByOrganizationID(TSAuthentication.OrganizationID, org.ProductType);
                    foreach (TicketType ticketType in ticketTypes)
                    {
                        if (ticketType.IsActive)
                        {
                            string mniID = "mniTicketType_" + ticketType.TicketTypeID.ToString();
                            if (IsMenuItemActive(user, mniID))
                            {
                                ticketItem.AddItem(new TsMenuItem("tickettype", mniID, ticketType.Name, ticketType.IconUrl, string.Format(data, "vcr/1_9_0/Pages/TicketTabs.html?TicketTypeID=" + ticketType.TicketTypeID.ToString(), "vcr/1_9_0/PaneInfo/Tickets.html")));
                            }
                        }
                    }
                }

                if (org.ProductType == ProductType.Enterprise && IsMenuItemActive(user, "mniTasks"))
                {
                    items.Add(new TsMenuItem("tasks", "mniTasks", "Tasks", "vcr/1_9_0/images/nav/20/tasks.png", string.Format(data, "vcr/1_9_0/Pages/tasks.html", "vcr/1_9_0/PaneInfo/Tasks.html")));
                }

                if (IsMenuItemActive(user, "mniTicketTags"))
                {
                    items.Add(new TsMenuItem("tickettags", "mniTicketTags", "Ticket Tags", "vcr/1_9_0/images/nav/20/tag.png", string.Format(data, "Frames/TicketTags.aspx", "vcr/1_9_0/PaneInfo/TicketTags.html")));
                }

                if (IsMenuItemActive(user, "mniKB"))
                {
                    items.Add(new TsMenuItem("kb", "mniKB", "Knowledge Base", "vcr/1_9_0/images/nav/20/knowledge.png", string.Format(data, "vcr/1_9_0/Pages/KnowledgeBase.html", "vcr/1_9_0/PaneInfo/Knowledge.html")));
                }

                if (IsMenuItemActive(user, "mniForum") && org.UseForums == true)
                {
                    items.Add(new TsMenuItem("forum", "mniForum", "Community", "vcr/1_9_0/images/nav/20/forum.png", string.Format(data, "vcr/1_9_0/Pages/TicketGrid.html?tf_ForumCategoryID=-1", "vcr/1_9_0/PaneInfo/Community.html")));
                }

                if (org.ProductType != ProductType.Express && IsMenuItemActive(user, "mniWiki"))
                {
                    items.Add(new TsMenuItem("wiki", "mniWiki", "Wiki", "vcr/1_9_0/images/nav/20/wiki.png", string.Format(data, "vcr/1_9_0/Pages/Wiki_view.html", "vcr/1_9_0/PaneInfo/Wiki_view.html")));
                }

                if (IsMenuItemActive(user, "mniSearch"))
                {
                    items.Add(new TsMenuItem("search", "mniSearch", "Search", "vcr/1_9_0/images/nav/20/search.png", string.Format(data, "vcr/1_9_0/Pages/Search.html", "vcr/1_9_0/PaneInfo/Search.html")));
                }

                if (user.IsChatUser && org.ChatSeats > 0 && IsMenuItemActive(user, "mniChat"))
                {
                    //old chat: items.Add(new TsMenuItem("chat", "mniChat", "Customer Chat", "vcr/1_9_0/images/nav/20/chat.png", string.Format(data, "Frames/Chat.aspx", "vcr/1_9_0/PaneInfo/Chat.html")));
                    items.Add(new TsMenuItem("chat", "mniChat", "Customer Chat", "vcr/1_9_0/images/nav/20/chat.png", string.Format(data, "vcr/1_9_0/Pages/AgentCustomerChat.html", "vcr/1_9_0/PaneInfo/Chat.html")));
                }

                if (org.ProductType != ProductType.Express && IsMenuItemActive(user, "mniWC2"))
                {
                    items.Add(new TsMenuItem("wc2", "mniWC2", "Water Cooler", "vcr/1_9_0/images/nav/20/watercooler.png", string.Format(data, "vcr/1_9_0/Pages/WaterCooler.html", "vcr/1_9_0/PaneInfo/WaterCooler.html")));
                }

                items.Add(new TsMenuItem("calender", "mniCalender", "Calendar", "vcr/1_9_0/images/nav/20/calendar.png", string.Format(data, "vcr/1_9_0/Pages/Calendar.html", "vcr/1_9_0/PaneInfo/Calendar.html")));

                if (IsMenuItemActive(user, "mniUsers"))
                {
                    items.Add(new TsMenuItem("users", "mniUsers", "Users", "vcr/1_9_0/images/nav/20/users.png", string.Format(data, "vcr/1_9_0/Pages/Users.html", "vcr/1_9_0/PaneInfo/Users.html")));
                }

                if (IsMenuItemActive(user, "mniGroups"))
                {
                    items.Add(new TsMenuItem("groups", "mniGroups", "Groups", "vcr/1_9_0/images/nav/20/groups.png", string.Format(data, "vcr/1_9_0/Pages/Groups.html", "vcr/1_9_0/PaneInfo/Groups.html")));
                    //items.Add(new TsMenuItem("groups1", "mniGroups1", "Groups1", "vcr/1_9_0/images/nav/20/groups.png", string.Format(data, "Frames/Groups.aspx", "vcr/1_9_0/PaneInfo/Groups.html")));
                }

                if ((org.ProductType == ProductType.Enterprise || org.ProductType == ProductType.HelpDesk) && IsMenuItemActive(user, "mniCustomers"))
                {
                    //items.Add(new TsMenuItem("customers1", "mniCustomers1", "Customers1", "vcr/1_9_0/images/nav/20/customers.png", string.Format(data, "Frames/Organizations.aspx", "vcr/1_9_0/PaneInfo/Customers.html")));
                    items.Add(new TsMenuItem("customers", "mniCustomers", "Customers", "vcr/1_9_0/images/nav/20/customers.png", string.Format(data, "vcr/1_9_0/Pages/Customers.html", "vcr/1_9_0/PaneInfo/Customers.html")));
                }


                if ((org.ProductType == ProductType.Enterprise || org.ProductType == ProductType.BugTracking) && IsMenuItemActive(user, "mniProducts"))
                {
                    items.Add(new TsMenuItem("products", "mniProducts", "Products", "vcr/1_9_0/images/nav/20/products.png", string.Format(data, "vcr/1_9_0/Pages/Products.html", "vcr/1_9_0/PaneInfo/Products.html")));
                    //items.Add(new TsMenuItem("products", "mniProducts", "Products", "vcr/1_9_0/images/nav/20/products.png", string.Format(data, "Frames/Products.aspx", "vcr/1_9_0/PaneInfo/Products.html")));
                    //if (TSAuthentication.OrganizationID == 1078 || TSAuthentication.OrganizationID == 13679 || TSAuthentication.OrganizationID == 362372 || TSAuthentication.OrganizationID == 428340)
                    //{
                    //  items.Add(new TsMenuItem("products", "mniProducts1", "New Products", "vcr/1_9_0/images/nav/20/products.png", string.Format(data, "vcr/1_9_0/Pages/Products.html", "vcr/1_9_0/PaneInfo/Products.html")));
                    //}
                }

                if (org.IsInventoryEnabled && IsMenuItemActive(user, "mniInventory"))
                {
                    //items.Add(new TsMenuItem("inventory", "mniInventory", "Inventory", "vcr/1_9_0/images/nav/20/inventory.png", string.Format(data, "Inventory/Inventory.aspx", "vcr/1_9_0/PaneInfo/Inventory.html")));
                    items.Add(new TsMenuItem("inventory", "mniInventory", "Inventory", "vcr/1_9_0/images/nav/20/inventory.png", string.Format(data, "vcr/1_9_0/Pages/Inventory.html", "vcr/1_9_0/PaneInfo/Inventory.html")));
                }

                if ((user.IsSystemAdmin || !org.AdminOnlyReports) && IsMenuItemActive(user, "mniReports"))
                {
                    items.Add(new TsMenuItem("reports", "mniReports", "Reports", "vcr/1_9_0/images/nav/20/reports.png", string.Format(data, "vcr/1_9_0/pages/reports.html", "vcr/1_9_0/PaneInfo/Reports.html")));
                }

                if (user.IsSystemAdmin && IsMenuItemActive(user, "mniAdmin"))
                {
                    items.Add(new TsMenuItem("admin", "mniAdmin", "Admin", "vcr/1_9_0/images/nav/20/admin.png", string.Format(data, "Frames/Admin.aspx", "vcr/1_9_0/PaneInfo/Admin.html")));
                }

                if (TSAuthentication.OrganizationID == 1078)
                {
                    TsMenuItem utils = new TsMenuItem("utils", "mniUtils", "Utilities", "vcr/1_9_0/images/nav/20/admin.png", string.Format(data, "vcr/1_9_0/Utils/Utils.html", "vcr/1_9_0/PaneInfo/Admin.html"));
                    items.Add(utils);
                    utils.AddItem(new TsMenuItem("utils", "utils-accounts", "Accounts", "vcr/1_9_0/images/nav/20/admin.png", string.Format(data, "vcr/1_9_0/Utils/Accounts.html", "vcr/1_9_0/PaneInfo/Admin.html")));
                    utils.AddItem(new TsMenuItem("utils", "utils-tickets", "Tickets", "vcr/1_9_0/images/nav/20/admin.png", string.Format(data, "vcr/1_9_0/Utils/Tickets.html", "vcr/1_9_0/PaneInfo/Admin.html")));
                    utils.AddItem(new TsMenuItem("utils", "utils-organizations", "Organizations", "vcr/1_9_0/images/nav/20/admin.png", string.Format(data, "vcr/1_9_0/Utils/Organizations.html", "vcr/1_9_0/PaneInfo/Admin.html")));
                    utils.AddItem(new TsMenuItem("utils", "utils-devflow", "Dev Workflow", "vcr/1_9_0/images/nav/20/admin.png", string.Format(data, "https://app.teamsupport.com/wiki/justarticle.aspx?Organizationid=1078&ArticleID=44728", "vcr/1_9_0/PaneInfo/Admin.html")));
                    if (user.UserID == 34 || user.UserID == 47 || user.UserID == 4759191)
                    {
                        utils.AddItem(new TsMenuItem("utils", "utils-reporttest", "Custom Reports", "vcr/1_9_0/images/nav/20/admin.png", string.Format(data, "vcr/1_9_0/Utils/ReportTest.html", "vcr/1_9_0/PaneInfo/Admin.html")));
                    }
                }
            }
            else
            {
                items.Add(new TsMenuItem("tsusers", "mniUsers", "System Users", "vcr/1_9_0/images/nav/20/users.png", string.Format(data, "Frames/Users.aspx", "vcr/1_9_0/PaneInfo/Users.html")));
                items.Add(new TsMenuItem("tscustomers", "mniCustomers", "System Customers", "vcr/1_9_0/images/nav/20/customers.png", string.Format(data, "Frames/Organizations.aspx", "vcr/1_9_0/PaneInfo/Organizations.html")));
            }

            return(items.ToArray());
        }
        private void GetTabluarSelectClause(SqlCommand command, StringBuilder builder, TabularReport tabularReport, bool includeHiddenFields, bool isSchemaOnly, string sortField = null, string sortDir = null)
        {
            LoginUser         loginUser = _userRights._loginUser;
            ReportSubcategory sub       = ReportSubcategories.GetReportSubcategory(loginUser, tabularReport.Subcategory);

            ReportTables tables = new ReportTables(loginUser);

            tables.LoadAll();

            ReportTableFields tableFields = new ReportTableFields(loginUser);

            tableFields.LoadAll();
            TimeSpan    offset      = loginUser.Offset;
            TicketTypes ticketTypes = new TicketTypes(loginUser);

            ticketTypes.LoadByOrganizationID(loginUser.OrganizationID);

            string sortClause = "";


            foreach (ReportSelectedField field in tabularReport.Fields)
            {
                if (field.IsCustom)
                {
                    CustomField customField = (CustomField)CustomFields.GetCustomField(loginUser, field.FieldID);
                    if (customField == null)
                    {
                        continue;
                    }
                    string fieldName = DataUtils.GetReportPrimaryKeyFieldName(customField.RefType);
                    if (fieldName != "")
                    {
                        //handle the ticket views custom fields
                        if (tabularReport.Subcategory == 70)
                        {
                            fieldName = "UserTicketsView.TicketID";
                        }
                        else if (tabularReport.Subcategory == 74)
                        {
                            fieldName = "TicketsView.TicketID";
                        }


                        fieldName = DataUtils.GetCustomFieldColumn(loginUser, customField, fieldName, true, false);
                        string colName = fieldName;

                        if (customField.FieldType == CustomFieldType.DateTime)
                        {
                            fieldName = string.Format("CAST(SWITCHOFFSET(TODATETIMEOFFSET({0}, '+00:00'), '{1}{2:D2}:{3:D2}') AS DATETIME)",
                                                      fieldName,
                                                      offset < TimeSpan.Zero ? "-" : "+",
                                                      Math.Abs(offset.Hours),
                                                      Math.Abs(offset.Minutes));
                        }
                        else if (customField.FieldType == CustomFieldType.Boolean)
                        {
                            fieldName = string.Format("(SELECT ISNULL(({0}),0))", fieldName);
                        }

                        if (!string.IsNullOrWhiteSpace(sortField) && colName == sortField)
                        {
                            sortClause = fieldName;
                        }

                        builder.Append(builder.Length < 1 ? "SELECT " : ", ");
                        string displayName = customField.Name;
                        if (customField.AuxID > 0 && customField.RefType == ReferenceType.Tickets)
                        {
                            TicketType ticketType = ticketTypes.FindByTicketTypeID(customField.AuxID);
                            if (ticketType != null && ticketType.OrganizationID == customField.OrganizationID)
                            {
                                displayName = $"{customField.Name} ({ticketType.Name})";
                            }
                        }
                        builder.Append($"{fieldName} AS [{displayName}]");

                        if (!string.IsNullOrWhiteSpace(sortField) && displayName == sortField)
                        {
                            sortClause = fieldName;
                        }
                    }
                }
                else
                {
                    ReportTableField tableField = tableFields.FindByReportTableFieldID(field.FieldID);

                    ReportTable table     = tables.FindByReportTableID(tableField.ReportTableID);
                    string      fieldName = table.TableName + "." + tableField.FieldName;
                    if (tableField.DataType.Trim().ToLower() == "datetime")
                    {
                        fieldName = string.Format("CAST(SWITCHOFFSET(TODATETIMEOFFSET({0}, '+00:00'), '{1}{2:D2}:{3:D2}') AS DATETIME)",
                                                  fieldName,
                                                  offset < TimeSpan.Zero ? "-" : "+",
                                                  Math.Abs(offset.Hours),
                                                  Math.Abs(offset.Minutes));
                    }

                    if (!string.IsNullOrWhiteSpace(sortField) && tableField.Alias == sortField)
                    {
                        sortClause = fieldName;
                    }

                    if (builder.Length < 1)
                    {
                        builder.Append("SELECT " + fieldName + " AS [" + tableField.Alias + "]");
                    }
                    else
                    {
                        builder.Append(", " + fieldName + " AS [" + tableField.Alias + "]");
                    }
                }
            }
            if (!string.IsNullOrWhiteSpace(sortClause))
            {
                builder.Append($", ROW_NUMBER() OVER (ORDER BY {sortClause} {sortDir}) AS [RowNum]");
            }

            if (includeHiddenFields)
            {
                ReportTable hiddenTable = tables.FindByReportTableID(sub.ReportCategoryTableID);
                if (!string.IsNullOrWhiteSpace(hiddenTable.LookupKeyFieldName))
                {
                    builder.Append(string.Format(", {1}.{0} AS [hidden{0}]", hiddenTable.LookupKeyFieldName, hiddenTable.TableName));
                }

                if (sub.ReportTableID != null)
                {
                    hiddenTable = tables.FindByReportTableID((int)sub.ReportTableID);
                    if (!string.IsNullOrWhiteSpace(hiddenTable.LookupKeyFieldName))
                    {
                        builder.Append(string.Format(", {1}.{0} AS [hidden{0}]", hiddenTable.LookupKeyFieldName, hiddenTable.TableName));
                    }
                }

                if (tabularReport.Subcategory == 70)
                {
                    string dueDateField = hiddenTable.TableName + ".DueDate";
                    dueDateField = string.Format("CAST(SWITCHOFFSET(TODATETIMEOFFSET({0}, '+00:00'), '{1}{2:D2}:{3:D2}') AS DATETIME)",
                                                 dueDateField,
                                                 offset < TimeSpan.Zero ? "-" : "+",
                                                 Math.Abs(offset.Hours),
                                                 Math.Abs(offset.Minutes));
                    builder.Append(string.Format(", {0} AS [hiddenDueDate]", dueDateField));

                    string dateModifiedField = hiddenTable.TableName + ".DateModified";
                    dateModifiedField = string.Format("CAST(SWITCHOFFSET(TODATETIMEOFFSET({0}, '+00:00'), '{1}{2:D2}:{3:D2}') AS DATETIME)",
                                                      dateModifiedField,
                                                      offset < TimeSpan.Zero ? "-" : "+",
                                                      Math.Abs(offset.Hours),
                                                      Math.Abs(offset.Minutes));
                    builder.Append(string.Format(", {0} AS [hiddenDateModified]", dateModifiedField));

                    builder.Append(string.Format(", {1}.{0} AS [hidden{0}]", "SlaWarningTime", hiddenTable.TableName));
                    builder.Append(string.Format(", {1}.{0} AS [hidden{0}]", "SlaViolationTime", hiddenTable.TableName));
                    builder.Append(string.Format(", {1}.{0} AS [hidden{0}]", "IsRead", hiddenTable.TableName));
                    builder.Append(string.Format(", {1}.{0} AS [hidden{0}]", "IsClosed", hiddenTable.TableName));
                    builder.Append(string.Format(", {1}.{0} AS [hidden{0}]", "TicketTypeID", hiddenTable.TableName));
                    builder.Append(string.Format(", {1}.{0} AS [hidden{0}]", "UserID", hiddenTable.TableName));
                    builder.Append(string.Format(", {1}.{0} AS [hidden{0}]", "SeverityPosition", hiddenTable.TableName));
                    builder.Append(string.Format(", {1}.{0} AS [hidden{0}]", "StatusPosition", hiddenTable.TableName));
                }
            }
            builder.Append(" " + sub.BaseQuery);

            ReportTable mainTable = tables.FindByReportTableID(sub.ReportCategoryTableID);

            _organizationIDFieldName = mainTable.OrganizationIDFieldName;

            builder.Append(" WHERE (" + mainTable.TableName + "." + mainTable.OrganizationIDFieldName + " = @OrganizationID)");
            if (tabularReport.Subcategory == 70)
            {
                builder.Append(" AND (" + mainTable.TableName + ".ViewerID = @UserID)");
            }

            _userRights.UseTicketRights((int)tabularReport.Subcategory, tables, command, builder);

            if (isSchemaOnly)
            {
                builder.Append(" AND (0=1)");
            }
        }
Ejemplo n.º 15
0
        public static string GetTickets(RestCommand command)
        {
            string xml             = "";
            bool   hasBeenFiltered = false;
            int    totalRecords    = 0;

            if (command.IsPaging)
            {
                try
                {
                    TicketsView tickets = new TicketsView(command.LoginUser);
                    tickets.LoadAllTicketIds(command.Organization.OrganizationID, command.Filters, command.PageNumber, command.PageSize);
                    hasBeenFiltered = true;
                    XmlTextWriter writer = Tickets.BeginXmlWrite("Tickets");

                    foreach (int ticketTypeId in tickets.GroupBy(g => g.TicketTypeID).Select(p => p.Key).ToList())
                    {
                        try
                        {
                            TicketsView ticketsResult = new TicketsView(command.LoginUser);
                            ticketsResult.LoadByTicketIDList(command.Organization.OrganizationID, ticketTypeId, tickets.Where(w => w.TicketTypeID == ticketTypeId).Select(p => p.TicketID).ToList());

                            foreach (DataRow row in ticketsResult.Table.Rows)
                            {
                                int  ticketId = (int)row["TicketID"];
                                Tags tags     = new Tags(command.LoginUser);
                                tags.LoadByReference(ReferenceType.Tickets, ticketId);
                                tags = tags ?? new Tags(command.LoginUser);
                                ticketsResult.WriteXml(writer, row, "Ticket", true, !hasBeenFiltered ? command.Filters : new System.Collections.Specialized.NameValueCollection(), tags);
                            }
                        }
                        catch (Exception ex)
                        {
                            ExceptionLogs.LogException(command.LoginUser, ex, "API", "RestTickets. GetTickets(). Paging.");
                        }
                    }

                    if (tickets.Count > 0)
                    {
                        totalRecords = tickets[0].TotalRecords;
                    }

                    writer.WriteElementString("TotalRecords", totalRecords.ToString());
                    xml = Tickets.EndXmlWrite(writer);
                }
                catch (Exception ex)
                {
                    ExceptionLogs.LogException(command.LoginUser, ex, "API", "RestTickets. GetTickets(). Paging. SQL filtering generation failed.");
                    throw new RestException(HttpStatusCode.InternalServerError, "There was an error processing your request. Please contact TeamSupport.com", ex);
                }
            }
            else
            {
                //No Paging
                if (command.Filters["TicketTypeID"] != null)
                {
                    try
                    {
                        TicketsView tickets      = new TicketsView(command.LoginUser);
                        int         ticketTypeID = int.Parse(command.Filters["TicketTypeID"]);
                        TicketType  ticketType   = TicketTypes.GetTicketType(command.LoginUser, ticketTypeID);
                        if (ticketType.OrganizationID != command.Organization.OrganizationID)
                        {
                            throw new Exception();
                        }

                        try
                        {
                            tickets.LoadByTicketTypeID(ticketTypeID, command.Organization.OrganizationID, command.Filters);
                        }
                        catch (Exception ex)
                        {
                            //if something fails use the old method
                            tickets.LoadByTicketTypeID(ticketTypeID);
                            ExceptionLogs.LogException(command.LoginUser, ex, "API", "RestTickets. GetTickets(). No Paging. SQL filtering generation failed, fell into old method.");
                        }

                        xml = tickets.GetXml("Tickets", "Ticket", true, command.Filters);
                        xml = AddTagsToTickets(xml, command);
                    }
                    catch (Exception ex)
                    {
                        throw new RestException(HttpStatusCode.NotAcceptable, "Invalid TicketTypeID to filter.", ex);
                    }
                }
                else
                {
                    TicketTypes ticketTypes = new TicketTypes(command.LoginUser);
                    ticketTypes.LoadByOrganizationID(command.Organization.OrganizationID);

                    TicketsView   tickets = new TicketsView(command.LoginUser);
                    XmlTextWriter writer  = Tickets.BeginXmlWrite("Tickets");

                    foreach (TicketType ticketType in ticketTypes)
                    {
                        try
                        {
                            tickets.LoadByTicketTypeID(ticketType.TicketTypeID, command.Organization.OrganizationID, command.Filters);
                        }
                        catch (Exception ex)
                        {
                            if (ex is System.Data.SqlClient.SqlException && ex.Message.ToLower().Contains("variable names must be unique within a query batch or stored procedure"))
                            {
                                throw ex;
                            }
                            else
                            {
                                //if something fails use the old method
                                tickets.LoadByTicketTypeID(ticketType.TicketTypeID);
                                ExceptionLogs.LogException(command.LoginUser, ex, "API", "RestTickets. GetTickets(). No Paging. No TicketTypeId filter. SQL filtering generation failed, fell into old method.");
                            }
                        }

                        foreach (DataRow row in tickets.Table.Rows)
                        {
                            int  ticketId = (int)row["TicketID"];
                            Tags tags     = new Tags(command.LoginUser);
                            tags.LoadByReference(ReferenceType.Tickets, ticketId);
                            tags = tags ?? new Tags(command.LoginUser);
                            tickets.WriteXml(writer, row, "Ticket", true, command.Filters, tags);
                        }
                    }

                    xml = Tickets.EndXmlWrite(writer);
                }
            }

            return(xml);
        }
Ejemplo n.º 16
0
        private void ImportOrg(int orgID, LoginUser loginUser)
        {
            string existingImportID = GetImportID(orgID);

            if (!string.IsNullOrWhiteSpace(existingImportID))
            {
                MessageBox.Show("This company has already been imported");
                return;
            }

            try
            {
                _importID         = orgID.ToString() + "-" + Guid.NewGuid().ToString();
                _logs             = new Logs(orgID.ToString() + " - Org.txt");
                _usersAndContacts = new Users(loginUser);
                _usersAndContacts.LoadContactsAndUsers(orgID, false);

                _badProducts           = new Products(GetCorrupteLoginUser());
                _badProductVersions    = new ProductVersions(GetCorrupteLoginUser());
                _badGroups             = new Groups(GetCorrupteLoginUser());
                _badUsers              = new Users(GetCorrupteLoginUser());
                _badTicketTypes        = new TicketTypes(GetCorrupteLoginUser());
                _badTicketStatuses     = new TicketStatuses(GetCorrupteLoginUser());
                _badTicketSeverities   = new TicketSeverities(GetCorrupteLoginUser());
                _badTicketKBCategories = new KnowledgeBaseCategories(GetCorrupteLoginUser());
                _badProducts.LoadByOrganizationID(orgID);
                _badProductVersions.LoadByParentOrganizationID(orgID);
                _badGroups.LoadByOrganizationID(orgID);
                _badUsers.LoadByOrganizationID(orgID, false);
                _badTicketTypes.LoadByOrganizationID(orgID);
                _badTicketStatuses.LoadByOrganizationID(orgID);
                _badTicketSeverities.LoadByOrganizationID(orgID);
                _badTicketKBCategories.LoadCategories(orgID);

                _goodProducts           = new Products(loginUser);
                _goodProductVersions    = new ProductVersions(loginUser);
                _goodGroups             = new Groups(loginUser);
                _goodUsers              = new Users(loginUser);
                _goodTicketTypes        = new TicketTypes(loginUser);
                _goodTicketStatuses     = new TicketStatuses(loginUser);
                _goodTicketSeverities   = new TicketSeverities(loginUser);
                _goodTicketKBCategories = new KnowledgeBaseCategories(loginUser);

                _goodProducts.LoadByOrganizationID(orgID);
                _goodProductVersions.LoadByParentOrganizationID(orgID);
                _goodGroups.LoadByOrganizationID(orgID);
                _goodUsers.LoadByOrganizationID(orgID, false);
                _goodTicketTypes.LoadByOrganizationID(orgID);
                _goodTicketStatuses.LoadByOrganizationID(orgID);
                _goodTicketSeverities.LoadByOrganizationID(orgID);
                _goodTicketKBCategories.LoadCategories(orgID);


                _exceptionOcurred = false;
                if (cbCompanies.Checked)
                {
                    RecoverCompanies(orgID, loginUser);
                }
                //RecoverContacts(orgID);
                if (cbProducts.Checked)
                {
                    RecoverProducts(orgID, loginUser);
                }
                // RecoverAssets(orgID);
                if (cbOldActions.Checked)
                {
                    RecoverActionsFromOldTickets(orgID, loginUser);
                }
                if (cbTickets.Checked)
                {
                    RecoverTickets(orgID, loginUser);
                }

                if (_exceptionOcurred)
                {
                    SaveOrgResults(orgID, "Finished with exceptions", _importID);
                }
                else
                {
                    SaveOrgResults(orgID, "Success", _importID);
                }
                SqlExecutor.ExecuteNonQuery(loginUser, "update organizations set LastIndexRebuilt='1/1/2000' where OrganizationID=" + orgID.ToString());
                MessageBox.Show("Import Complete");
            }
            catch (Exception ex)
            {
                SaveOrgResults(orgID, "Failure: " + ex.Message, _importID);
                ExceptionLogs.LogException(GetCorrupteLoginUser(), ex, "recover");
            }
        }