Esempio n. 1
0
    private bool DoesNameExist(string name)
    {
        name = name.Trim().ToLower();
        SlaLevels levels = new SlaLevels(UserSession.LoginUser);

        levels.LoadByOrganizationID(UserSession.LoginUser.OrganizationID);
        if (_slaLevelID > -1)
        {
            SlaLevel current = SlaLevels.GetSlaLevel(UserSession.LoginUser, _slaLevelID);
            if (current.Name.Trim().ToLower() == name)
            {
                return(false);
            }
        }



        foreach (SlaLevel level in levels)
        {
            if (level.Name.Trim().ToLower() == name)
            {
                return(true);
            }
        }

        return(false);
    }
    public static void DeleteLevel(int slaLevelID)
    {
        SlaLevel level = SlaLevels.GetSlaLevel(UserSession.LoginUser, slaLevelID);

        if (level != null && level.OrganizationID == UserSession.LoginUser.OrganizationID && UserSession.CurrentUser.IsSystemAdmin)
        {
            level.Delete();
            level.Collection.Save();
        }
    }
        public static string GetSlaLevel(RestCommand command, int slaLevelID)
        {
            SlaLevel slaLevel = SlaLevels.GetSlaLevel(command.LoginUser, slaLevelID);

            if (slaLevel.OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            return(slaLevel.GetXml("SlaLevel", true));
        }
    public static void DeleteTrigger(int slaTriggerID)
    {
        SlaTrigger trigger = SlaTriggers.GetSlaTrigger(UserSession.LoginUser, slaTriggerID);
        SlaLevel   level   = SlaLevels.GetSlaLevel(UserSession.LoginUser, trigger.SlaLevelID);

        if (trigger != null && level.OrganizationID == UserSession.LoginUser.OrganizationID && UserSession.CurrentUser.IsSystemAdmin)
        {
            trigger.Delete();
            trigger.Collection.Save();
        }
    }
Esempio n. 5
0
    public override bool Save()
    {
        if (IsValid())
        {
            if (_isCloning)
            {
                //Clone SLA here
                LoginUser loginUser        = TSAuthentication.GetLoginUser();
                int       clonedSlaLevelId = 0;

                try
                {
                    SlaLevel originalSlaLevel = SlaLevels.GetSlaLevel(loginUser, _slaLevelID);
                    SlaLevel clonedSlaLevel   = originalSlaLevel.Clone(textName.Text.Trim());
                    clonedSlaLevelId = clonedSlaLevel.SlaLevelID;
                }
                catch (Exception ex)
                {
                    ExceptionLogs.LogException(loginUser, ex, "Cloning Sla", "SlaLevel.aspx.cs.Save");
                }
            }
            else
            {
                SlaLevel  level;
                SlaLevels levels = new SlaLevels(UserSession.LoginUser);

                if (_slaLevelID < 0)
                {
                    level = levels.AddNewSlaLevel();
                    level.OrganizationID = UserSession.LoginUser.OrganizationID;
                }
                else
                {
                    level = SlaLevels.GetSlaLevel(UserSession.LoginUser, _slaLevelID);
                    if (level == null)
                    {
                        return(false);
                    }
                }

                level.Name = textName.Text;
                level.Collection.Save();
                DialogResult = level.SlaLevelID.ToString();
            }
        }
        else
        {
            return(false);
        }

        return(true);
    }
Esempio n. 6
0
    private void LoadLevel(int slaLevelID)
    {
        SlaLevel level = SlaLevels.GetSlaLevel(UserSession.LoginUser, slaLevelID);

        if (level == null)
        {
            return;
        }
        if (level.OrganizationID != UserSession.LoginUser.OrganizationID)
        {
            Response.Write("Invalid Request");
            Response.End();
            return;
        }

        textName.Text = level.Name + (_isCloning ? " (Clone)" : "");
    }
        /// <summary>
        /// Finds and sets the Organization fields ids by searching their name
        /// </summary>
        /// <param name="command">Command received in the request to read and process the data in the request body.</param>
        /// <param name="organizationId">OrganizationId to update its record.</param>
        private static void SetFieldIdsByName(RestCommand command, ref Organization organization)
        {
            try
            {
                //Add as necessary to the list and then to the switch-case below for the work to update it.
                List <string> fields = new List <string>()
                {
                    "slaname", "defaultsupportgroup", "defaultsupportuser"
                };

                foreach (string field in fields.Select(p => p.ToLower()).ToList())
                {
                    XmlNode node = GetNode(command, field);

                    if (node != null)
                    {
                        switch (field)
                        {
                        case "slaname":
                            string slaName        = node.InnerText;
                            int?   slaLevelId     = SlaLevel.GetIDByName(command.LoginUser, slaName, null);
                            bool   wasFoundByName = false;

                            if (slaLevelId != null)
                            {
                                //check if id belongs to org
                                SlaLevel slaLevel = SlaLevels.GetSlaLevel(command.LoginUser, (int)slaLevelId);

                                if (slaLevel.OrganizationID == organization.ParentID)
                                {
                                    organization.SlaLevelID = slaLevel.SlaLevelID;
                                    wasFoundByName          = true;
                                }
                            }

                            if (!wasFoundByName)
                            {
                                //check if also the SlaLevelId was sent and it's different than current
                                string  slaLevelIdField = "slalevelid";
                                XmlNode nodeSlaLevelId  = GetNode(command, slaLevelIdField);

                                if (nodeSlaLevelId != null)
                                {
                                    string slaLevelIdText = nodeSlaLevelId.InnerText;
                                    int    slaIdSent      = 0;

                                    if (int.TryParse(slaLevelIdText, out slaIdSent))
                                    {
                                        //check if id belongs to org
                                        SlaLevel slaLevel = SlaLevels.GetSlaLevel(command.LoginUser, slaIdSent);

                                        if (slaLevel != null && slaLevel.OrganizationID == organization.ParentID)
                                        {
                                            organization.SlaLevelID = slaLevel.SlaLevelID;
                                        }
                                        else
                                        {
                                            int?currentSlaLevelId = Organizations.GetOrganization(command.LoginUser, organization.OrganizationID).SlaLevelID;
                                            organization.SlaLevelID = currentSlaLevelId;
                                        }
                                    }
                                }
                            }

                            break;

                        //ToDo: DefaultSupportGroup, DefaultSupportUser
                        default:
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionLogs.LogException(command.LoginUser, ex, "API", string.Format("OrgID: {0}{1}Verb: {2}{1}Url: {3}{1}Body: {4}", command.Organization.OrganizationID, Environment.NewLine, command.Method, command.Method, command.Data));
            }
        }
Esempio n. 8
0
    private void LoadProperties(int organizationID)
    {
        lblProperties.Visible = true;

        Organizations organizations = new Organizations(UserSession.LoginUser);

        organizations.LoadByOrganizationID(organizationID);

        if (organizations.IsEmpty)
        {
            return;
        }
        Organization organization = organizations[0];


        Users  users       = new Users(UserSession.LoginUser);
        string primaryUser = "";

        if (organization.PrimaryUserID != null)
        {
            users.LoadByUserID((int)organization.PrimaryUserID);
            primaryUser = users.IsEmpty ? "" : users[0].LastName + ", " + users[0].FirstName;
        }

        lblProperties.Visible = organizations.IsEmpty;

        DataTable table = new DataTable();

        table.Columns.Add("Name");
        table.Columns.Add("Value");

        string website = organization.Website;
        string link    = "";

        if (website != null)
        {
            if (website.IndexOf("http") < 0)
            {
                website = "http://" + website;
            }
            link = @"<a href=""" + website + @""" target=""OrganizationLink"">" + organization.Website + "</a>";
        }

        table.Rows.Add(new string[] { "Name:", organization.Name });
        table.Rows.Add(new string[] { "Website:", link });
        table.Rows.Add(new string[] { "Description:", organization.Description });
        table.Rows.Add(new string[] { "Service Agreement Expiration Date:", organization.SAExpirationDate == null ? "[None]" : ((DateTime)organization.SAExpirationDate).ToLongDateString() });
        if (organization.SlaLevelID == null)
        {
            table.Rows.Add(new string[] { "Service Level Agreement:", "[None]" });
        }
        else
        {
            SlaLevel level = SlaLevels.GetSlaLevel(UserSession.LoginUser, (int)organization.SlaLevelID);
            if (level != null)
            {
                table.Rows.Add(new string[] { "Service Level Agreement:", level.Name });
            }
        }

        if (organizationID != UserSession.LoginUser.OrganizationID)
        {
            table.Rows.Add(new string[] { "Active:", organization.IsActive.ToString() });
            if (UserSession.CurrentUser.IsSystemAdmin)
            {
                table.Rows.Add(new string[] { "API Enabled:", (organization.IsApiActive && organization.IsApiEnabled).ToString() });
                table.Rows.Add(new string[] { "API Token:", organization.WebServiceID.ToString() });
                table.Rows.Add(new string[] { "OrganizationID:", organization.OrganizationID.ToString() });
            }
        }
        if (UserSession.CurrentUser.HasPortalRights)
        {
            table.Rows.Add(new string[] { "Portal Access:", organization.HasPortalAccess.ToString() });
        }
        table.Rows.Add(new string[] { "Primary Contact:", primaryUser });

        if (organization.DefaultSupportUserID != null)
        {
            User supportUser = Users.GetUser(UserSession.LoginUser, (int)organization.DefaultSupportUserID);
            table.Rows.Add(new string[] { "Default Support User:"******"Default Support User:"******"[None]" });
        }

        if (organization.DefaultSupportGroupID != null)
        {
            Group supportGroup = (Group)Groups.GetGroup(UserSession.LoginUser, (int)organization.DefaultSupportGroupID);
            if (supportGroup != null)
            {
                table.Rows.Add(new string[] { "Default Support Group:", supportGroup.Name });
            }
            else
            {
                table.Rows.Add(new string[] { "Default Support Group:", "[None]" });
            }
        }
        else
        {
            table.Rows.Add(new string[] { "Default Support Group:", "[None]" });
        }
        table.Rows.Add(new string[] { "Domains:", organization.CompanyDomains == null ? "[None Assigned]" : organization.CompanyDomains });


        if (organization.SupportHoursMonth != 0)
        {
            table.Rows.Add(new string[] { "Support hours per month:", organization.SupportHoursMonth.ToString() });
        }
        else
        {
            table.Rows.Add(new string[] { "Support hours per month:", "0" });
        }


        CustomFields fields = new CustomFields(UserSession.LoginUser);

        fields.LoadByReferenceType(UserSession.LoginUser.OrganizationID, ReferenceType.Organizations);

        StringBuilder valueAsString = null;

        foreach (CustomField field in fields)
        {
            if (field.CustomFieldCategoryID != null)
            {
                continue;
            }
            CustomValue value = CustomValues.GetValue(UserSession.LoginUser, field.CustomFieldID, organizationID);
            switch (value.FieldType)
            {
            case CustomFieldType.Date:
                valueAsString = new StringBuilder();
                if (!string.IsNullOrEmpty(value.Value))
                {
                    try
                    {
                        DateTime valueAsDateTime = DataUtils.DateToLocal(UserSession.LoginUser, DateTime.Parse(value.Value));
                        valueAsString.Append(valueAsDateTime.ToString("d", UserSession.LoginUser.CultureInfo));
                    }
                    catch
                    {
                        valueAsString.Append(value.Value);
                    }
                }
                table.Rows.Add(new string[] { field.Name + ":", valueAsString.ToString() });
                break;

            case CustomFieldType.Time:
                valueAsString = new StringBuilder();
                if (!string.IsNullOrEmpty(value.Value))
                {
                    try
                    {
                        DateTime valueAsDateTime = DataUtils.DateToLocal(UserSession.LoginUser, DateTime.Parse(value.Value));
                        valueAsString.Append(valueAsDateTime.ToString("t", UserSession.LoginUser.CultureInfo));
                    }
                    catch
                    {
                        valueAsString.Append(value.Value);
                    }
                }
                table.Rows.Add(new string[] { field.Name + ":", valueAsString.ToString() });
                break;

            case CustomFieldType.DateTime:
                valueAsString = new StringBuilder();
                if (!string.IsNullOrEmpty(value.Value))
                {
                    try
                    {
                        DateTime valueAsDateTime = DataUtils.DateToLocal(UserSession.LoginUser, DateTime.Parse(value.Value));
                        valueAsString.Append(valueAsDateTime.ToString("g", UserSession.LoginUser.CultureInfo));
                    }
                    catch
                    {
                        valueAsString.Append(value.Value);
                    }
                }
                table.Rows.Add(new string[] { field.Name + ":", valueAsString.ToString() });
                break;

            default:
                table.Rows.Add(new string[] { field.Name + ":", value.Value });
                break;
            }
        }

        CustomFieldCategories cats = new CustomFieldCategories(UserSession.LoginUser);

        cats.LoadByRefType(ReferenceType.Organizations);

        StringBuilder builder = new StringBuilder();
        string        prop    = "<div style=\"margin: 5px 5px 5px 15px; line-height: 20px;\"><span style=\"font-weight: bold;\">{0}: </span><span> {1}<br /></span></div>";

        foreach (CustomFieldCategory cat in cats)
        {
            bool   isExpanded   = Settings.UserDB.ReadBool("Custom Cat Expanded (Customer) - " + cat.Category, false);
            string markerClass  = isExpanded ? "ui-icon-triangle-1-s" : "ui-icon-triangle-1-e";
            string displayClass = isExpanded ? "" : "ui-helper-hidden";

            builder.Append("<div class=\"customfield-cat\"><span class=\"ui-icon " + markerClass + "\"></span><span class=\"caption\">" + cat.Category);
            builder.Append("</span></div><div class=\"ui-widget-content ts-separator " + displayClass + "\"></div>");
            builder.Append("<div class=\"" + displayClass + "\">");
            foreach (CustomField field in fields)
            {
                if (field.CustomFieldCategoryID != null && field.CustomFieldCategoryID == cat.CustomFieldCategoryID)
                {
                    CustomValue value = CustomValues.GetValue(UserSession.LoginUser, field.CustomFieldID, organizationID);
                    switch (value.FieldType)
                    {
                    case CustomFieldType.Date:
                        valueAsString = new StringBuilder();
                        if (!string.IsNullOrEmpty(value.Value))
                        {
                            try
                            {
                                DateTime valueAsDateTime = DataUtils.DateToLocal(UserSession.LoginUser, DateTime.Parse(value.Value));
                                valueAsString.Append(valueAsDateTime.ToString("d", UserSession.LoginUser.CultureInfo));
                            }
                            catch
                            {
                                valueAsString.Append(value.Value);
                            }
                        }
                        builder.Append(string.Format(prop, field.Name, valueAsString.ToString()));
                        break;

                    case CustomFieldType.Time:
                        valueAsString = new StringBuilder();
                        if (!string.IsNullOrEmpty(value.Value))
                        {
                            try
                            {
                                DateTime valueAsDateTime = DataUtils.DateToLocal(UserSession.LoginUser, DateTime.Parse(value.Value));
                                valueAsString.Append(valueAsDateTime.ToString("t", UserSession.LoginUser.CultureInfo));
                            }
                            catch
                            {
                                valueAsString.Append(value.Value);
                            }
                        }
                        builder.Append(string.Format(prop, field.Name, valueAsString.ToString()));
                        break;

                    case CustomFieldType.DateTime:
                        valueAsString = new StringBuilder();
                        if (!string.IsNullOrEmpty(value.Value))
                        {
                            try
                            {
                                DateTime valueAsDateTime = DataUtils.DateToLocal(UserSession.LoginUser, DateTime.Parse(value.Value));
                                valueAsString.Append(valueAsDateTime.ToString("g", UserSession.LoginUser.CultureInfo));
                            }
                            catch
                            {
                                valueAsString.Append(value.Value);
                            }
                        }
                        builder.Append(string.Format(prop, field.Name, valueAsString.ToString()));
                        break;

                    default:
                        builder.Append(string.Format(prop, field.Name, value.Value));
                        break;
                    }
                }
            }
            builder.Append("</div>");
        }
        litProperties.Text = builder.ToString();


        rptProperties.DataSource = table;
        rptProperties.DataBind();
    }
        private void NotifyViolation(int ticketID, bool useUser, bool useGroup, bool isWarning, SlaViolationType slaViolationType, SlaNotification notification, int?triggerId)
        {
            Users users = new Users(LoginUser);
            User  user  = null;

            Logs.WriteLine();
            Logs.WriteEvent("***** Processing TicketID: " + ticketID.ToString());
            TicketsViewItem ticket = TicketsView.GetTicketsViewItem(LoginUser, ticketID);

            if (ticket == null)
            {
                Logs.WriteEvent("Ticket is NULL, exiting");
                return;
            }

            //Since we are already re-loading the Ticket information we will check again if the SLAs still apply at this point
            string violationType      = "";
            bool   slaNotApplyAnymore = false;

            switch (slaViolationType)
            {
            case SlaViolationType.InitialResponse:
                violationType      = "Initial Response";
                slaNotApplyAnymore = ticket.SlaWarningInitialResponse == null;
                break;

            case SlaViolationType.LastAction:
                violationType      = "Last Action";
                slaNotApplyAnymore = ticket.SlaViolationLastAction == null;
                break;

            case SlaViolationType.TimeClosed:
                violationType      = "Time to Close";
                slaNotApplyAnymore = ticket.SlaViolationTimeClosed == null;
                break;

            default: break;
            }

            if (slaNotApplyAnymore)
            {
                Logs.WriteEvent($"The {((isWarning) ? "warning" : "violation")} for {violationType} does not apply anymore because the Ticket has been updated to satisfy this SLA while it was in process for the notification.");
            }
            else
            {
                if (!isWarning)
                {
                    SlaViolationHistoryItem history = (new SlaViolationHistory(LoginUser)).AddNewSlaViolationHistoryItem();
                    history.DateViolated  = DateTime.UtcNow;
                    history.GroupID       = ticket.GroupID;
                    history.UserID        = ticket.UserID;
                    history.ViolationType = slaViolationType;
                    history.TicketID      = ticket.TicketID;
                    history.SlaTriggerId  = triggerId;
                    history.Collection.Save();
                }

                Actions actions = new Actions(LoginUser);
                actions.LoadLatestByTicket(ticket.TicketID, false);

                ActionLogs.AddActionLog(LoginUser, ActionLogType.Update, ReferenceType.Tickets, ticket.TicketID, violationType + " SLA " + (isWarning ? "warning" : "violation") + " occurred");

                MailMessage message = EmailTemplates.GetSlaEmail(LoginUser, ticket, violationType, isWarning);


                if (ticket.GroupID != null && useGroup)
                {
                    users.LoadByGroupID((int)ticket.GroupID);
                }

                if (ticket.UserID != null && useUser && users.FindByUserID((int)ticket.UserID) == null)
                {
                    user = Users.GetUser(LoginUser, (int)ticket.UserID);
                }

                foreach (User item in users)
                {
                    if (Emails.IsEmailDisabled(LoginUser, item.UserID, "SLA"))
                    {
                        continue;
                    }
                    message.To.Add(new MailAddress(item.Email, item.FirstLastName));
                }

                if (user != null)
                {
                    if (!Emails.IsEmailDisabled(LoginUser, user.UserID, "SLA"))
                    {
                        message.To.Add(new MailAddress(user.Email, user.FirstLastName));
                        Logs.WriteEvent(string.Format("Adding Main User, Name:{0}  Email:{1}  UserID:{2}", user.FirstLastName, user.Email, user.UserID.ToString()));
                    }
                }

                if (message.To.Count > 0)
                {
                    Email email = Emails.AddEmail(LoginUser, ticket.OrganizationID, null, "Sla Message", message);
                    Logs.WriteEvent("Email Added (EmailID: " + email.EmailID.ToString() + ")", true);
                }

                try
                {
                    TimeZoneInfo tz  = null;
                    Organization org = Organizations.GetOrganization(LoginUser, ticket.OrganizationID);
                    if (org.TimeZoneID != null)
                    {
                        tz = System.TimeZoneInfo.FindSystemTimeZoneById(org.TimeZoneID);
                    }
                    if (tz == null)
                    {
                        Logs.WriteEvent("Timezone is null, using system's");
                        tz = System.TimeZoneInfo.Local;
                    }
                    Logs.WriteEvent(tz.DisplayName);
                    Logs.WriteEvent("Supports DLS: " + tz.SupportsDaylightSavingTime.ToString());
                    Logs.WriteEvent("Is DLS: " + tz.IsDaylightSavingTime(DateTime.UtcNow).ToString());
                    Logs.WriteEvent("UTC: " + DateTime.UtcNow.ToString());
                    Logs.WriteEvent(string.Format("NOTIFYING TicketID:{0}  TicketNumber:{1}  OrganizationID:{2} ", ticket.TicketID.ToString(), ticket.TicketNumber.ToString(), ticket.OrganizationID.ToString()));
                    Logs.WriteEvent(string.Format("User:{1}  Group:{2}  IsWarning:{3}  NoficationType:{4}", ticketID.ToString(), useUser.ToString(), useGroup.ToString(), isWarning.ToString(), slaViolationType));
                    Logs.WriteEvent("Ticket Data:");
                    Logs.WriteData(ticket.Row);
                    Logs.WriteEvent("Notification Data:");
                    Logs.WriteData(notification.Row);
                    Logs.WriteEvent("Organization Data:");
                    Logs.WriteData(org.Row);
                    Organizations customers = new Organizations(LoginUser);
                    customers.LoadByTicketID(ticket.TicketID);

                    foreach (Organization customer in customers)
                    {
                        Logs.WriteEvent("-- Customer: " + customer.Name);
                        if (customer.SlaLevelID != null)
                        {
                            SlaLevel level = SlaLevels.GetSlaLevel(LoginUser, (int)customer.SlaLevelID);
                            Logs.WriteEvent("SLA Level: " + level.Name);
                            SlaTriggers triggers = new SlaTriggers(LoginUser);
                            triggers.LoadByTicketTypeAndSeverity(level.SlaLevelID, ticket.TicketTypeID, ticket.TicketSeverityID);

                            foreach (SlaTrigger trigger in triggers)
                            {
                                Logs.WriteData(trigger.Row);
                            }
                        }
                        else
                        {
                            Logs.WriteEvent("No SLA Level Assigned to " + customer.Name);
                        }
                    }

                    if (org.InternalSlaLevelID != null)
                    {
                        Logs.WriteEvent("Internal SLA:");

                        SlaTriggers triggers = new SlaTriggers(LoginUser);
                        triggers.LoadByTicketTypeAndSeverity((int)org.InternalSlaLevelID, ticket.TicketTypeID, ticket.TicketSeverityID);
                        foreach (SlaTrigger trigger in triggers)
                        {
                            Logs.WriteData(trigger.Row);
                        }
                    }
                    else
                    {
                        Logs.WriteEvent("No Internal SLA");
                    }
                }
                catch (Exception ex)
                {
                    Logs.WriteEvent("Logging Exception:");
                    Logs.WriteException(ex);
                }
            }
        }
Esempio n. 10
0
    private void LoadProperties(int organizationID)
    {
        lblProperties.Visible = true;

        Organizations organizations = new Organizations(UserSession.LoginUser);

        organizations.LoadByOrganizationID(organizationID);

        if (organizations.IsEmpty)
        {
            return;
        }
        Organization organization = organizations[0];


        Users  users       = new Users(UserSession.LoginUser);
        string primaryUser = "******";

        if (organization.PrimaryUserID != null)
        {
            users.LoadByUserID((int)organization.PrimaryUserID);
            primaryUser = users.IsEmpty ? "" : users[0].FirstLastName;
        }


        string defaultGroup = "[Unassigned]";

        if (organization.DefaultPortalGroupID != null)
        {
            Group group = (Group)Groups.GetGroup(UserSession.LoginUser, (int)organization.DefaultPortalGroupID);
            if (group != null)
            {
                defaultGroup = group.Name;
            }
        }

        lblProperties.Visible = organizations.IsEmpty;

        DataTable table = new DataTable();

        table.Columns.Add("Name");
        table.Columns.Add("Value");

        table.Rows.Add(new string[] { "Name:", organization.Name });
        table.Rows.Add(new string[] { "Description:", organization.Description });
        //table.Rows.Add(new string[] { "Portal Access:", organization.HasPortalAccess.ToString() });

        /*
         * if (UserSession.CurrentUser.HasPortalRights)
         * {
         * string portalLink = "http://portal.ts.com?OrganizationID=" + organization.OrganizationID.ToString();
         * portalLink = @"<a href=""" + portalLink + @""" target=""PortalLink"" onclick=""window.open('" + portalLink + @"', 'PortalLink')"">" + portalLink + "</a>";
         * table.Rows.Add(new string[] { "Portal Link:", portalLink });
         * table.Rows.Add(new string[] { "Default Portal Group:", defaultGroup });
         * }
         */
        table.Rows.Add(new string[] { "Organization ID:", organization.OrganizationID.ToString() });
        table.Rows.Add(new string[] { "Primary Contact:", primaryUser });


        //"Central Standard Time"

        TimeZoneInfo timeZoneInfo = null;

        try
        {
            timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(organization.TimeZoneID);
        }
        catch (Exception)
        {
            timeZoneInfo = null;
        }

        table.Rows.Add(new string[] { "Time Zone:", timeZoneInfo == null ? "Central Standard Time" : timeZoneInfo.DisplayName });

        table.Rows.Add(new string[] { "Date Format:", (new CultureInfo(organization.CultureName)).DisplayName });
        table.Rows.Add(new string[] { "Default Font Family:", organization.FontFamilyDescription });
        table.Rows.Add(new string[] { "Default Font Size:", organization.FontSizeDescription });

        table.Rows.Add(new string[] { "Business Days:", organization.BusinessDaysText == "" ? "[None Assigned]" : organization.BusinessDaysText });
        table.Rows.Add(new string[] { "Business Day Start:", organization.BusinessDayStart == null ? "[None Assigned]" : ((DateTime)organization.BusinessDayStart).ToString("t", UserSession.LoginUser.CultureInfo) });
        table.Rows.Add(new string[] { "Business Day End:", organization.BusinessDayEnd == null ? "[None Assigned]" : ((DateTime)organization.BusinessDayEnd).ToString("t", UserSession.LoginUser.CultureInfo) });

        table.Rows.Add(new string[] { "Product Required on Ticket:", organization.ProductRequired.ToString() });
        table.Rows.Add(new string[] { "Product Version Required on ticket:", organization.ProductVersionRequired.ToString() });

        table.Rows.Add(new string[] { "Only show products for the customers of a ticket:", Settings.OrganizationDB.ReadBool("ShowOnlyCustomerProducts", false).ToString() });
        table.Rows.Add(new string[] { "Auto Assign Customer with Asset On Tickets:", organization.AutoAssignCustomerWithAssetOnTickets.ToString() });
        table.Rows.Add(new string[] { "Auto Associate Customer To Ticket based on Asset Assignment:", organization.AutoAssociateCustomerToTicketBasedOnAssetAssignment.ToString() });
        table.Rows.Add(new string[] { "Require customer for new ticket:", Settings.OrganizationDB.ReadBool("RequireNewTicketCustomer", false).ToString() });
        table.Rows.Add(new string[] { "Require time spent on timed actions:", organization.TimedActionsRequired.ToString() });
        table.Rows.Add(new string[] { "Disable ticket status update emails:", Settings.OrganizationDB.ReadBool("DisableStatusNotification", false).ToString() });
        table.Rows.Add(new string[] { "Visible to customers is initially enabled for new actions:", organization.SetNewActionsVisibleToCustomers.ToString() });
        table.Rows.Add(new string[] { "Allow unauthenticated users to view attachments:", organization.AllowUnsecureAttachmentViewing.ToString() });
        table.Rows.Add(new string[] { "Allow private actions to satisfy SLA first reponse:", organization.SlaInitRespAnyAction.ToString() });
        table.Rows.Add(new string[] { "Chat ID:", organization.ChatID.ToString() });


        /*    string email = organization.SystemEmailID + "@teamsupport.com";
         *      table.Rows.Add(new string[] { "System Email:", "<a href=\"mailto:" + email + "\">" + email + "</a>" });
         *      table.Rows.Add(new string[] { "Organization Reply To Address:", organization.OrganizationReplyToAddress });
         *      table.Rows.Add(new string[] { "Require [New] keyword for emails:", organization.RequireNewKeyword.ToString() });
         *      table.Rows.Add(new string[] { "Require a known email address for emails:", organization.RequireKnownUserForNewEmail.ToString() });
         */

        //table.Rows.Add(new string[] { "Use Community:", organization.UseForums.ToString() });
        WikiArticle defArticle = organization.DefaultWikiArticleID == null ? null : WikiArticles.GetWikiArticle(UserSession.LoginUser, (int)organization.DefaultWikiArticleID);

        table.Rows.Add(new string[] { "Default Wiki Article:", defArticle == null ? "[None Assigned]" : defArticle.ArticleName });


        //table.Rows.Add(new string[] { "Only Admin Can Modify Customers:", organization.AdminOnlyCustomers.ToString() });
        table.Rows.Add(new string[] { "Only Admin Can View Reports:", organization.AdminOnlyReports.ToString() });

        SlaLevel level = organization.InternalSlaLevelID != null?SlaLevels.GetSlaLevel(UserSession.LoginUser, (int)organization.InternalSlaLevelID) : null;

        table.Rows.Add(new string[] { "Internal SLA:", level == null ? "[None Assigned]" : level.Name });

        table.Rows.Add(new string[] { "Show Group Members First in Ticket Assignment List:", organization.ShowGroupMembersFirstInTicketAssignmentList.ToString() });
        table.Rows.Add(new string[] { "Require Group Assignment On Tickets:", organization.RequireGroupAssignmentOnTickets.ToString() });
        table.Rows.Add(new string[] { "Update Ticket Children Group With Parent:", organization.UpdateTicketChildrenGroupWithParent.ToString() });
        table.Rows.Add(new string[] { "Hide Alert Dismiss for Non Admins:", organization.HideDismissNonAdmins.ToString() });
        if ((organization.ProductType == ProductType.Enterprise || organization.ProductType == ProductType.BugTracking))
        {
            table.Rows.Add(new string[] { "Use Product Lines:", organization.UseProductFamilies.ToString() });
        }

        table.Rows.Add(new string[] { "Customer Insights:", organization.IsCustomerInsightsActive.ToString() });
        table.Rows.Add(new string[] { "Two Factor Verification:", organization.TwoStepVerificationEnabled.ToString() });
        table.Rows.Add(new string[] { "How many days before user passwords expire:", organization.DaysBeforePasswordExpire.ToString() });
        table.Rows.Add(new string[] { "Do not include attachments on outbound emails:", organization.NoAttachmentsInOutboundEmail.ToString() });

        if (organization.NoAttachmentsInOutboundEmail && !string.IsNullOrEmpty(organization.NoAttachmentsInOutboundExcludeProductLine))
        {
            ProductFamilies productFamilies = new ProductFamilies(UserSession.LoginUser);

            try
            {
                productFamilies.LoadByIds(organization.NoAttachmentsInOutboundExcludeProductLine.Split(',').Select(int.Parse).ToList(), organization.OrganizationID);

                if (productFamilies.Count > 0)
                {
                    table.Rows.Add(new string[] { "Except for the following Product Lines (include attachments):", string.Join(",", productFamilies.Select(p => p.Name).ToArray()) });
                }
            }
            catch (Exception ex)
            {
                ExceptionLogs.LogException(UserSession.LoginUser, ex, "AdminCompany.aspx.cs.LoadProperties");
            }
        }

        table.Rows.Add(new string[] { "Warn if contact has no email address:", organization.AlertContactNoEmail.ToString() });
        table.Rows.Add(new string[] { "Allow TeamSupport to log into your account for technical support:", (!organization.DisableSupportLogin).ToString() });
        table.Rows.Add(new string[] { "Use Watson:", organization.UseWatson.ToString() });
        // table.Rows.Add(new string[] { "Require Two Factor Authentication:", organization.RequireTwoFactor.ToString() });

        rptProperties.DataSource = table;
        rptProperties.DataBind();
    }
    protected override void OnLoad(EventArgs e)
    {
        if (!UserSession.CurrentUser.IsSystemAdmin)
        {
            Response.Write("Invalid Request");
            Response.End();
            return;
        }


        base.OnLoad(e);

        if (Request["SlaTriggerID"] != null)
        {
            _slaTriggerID = int.Parse(Request["SlaTriggerID"]);
        }
        if (Request["SlaLevelID"] != null)
        {
            _slaLevelID = int.Parse(Request["SlaLevelID"]);
        }
        if (Request["TicketTypeID"] != null)
        {
            _ticketTypeID = int.Parse(Request["TicketTypeID"]);
        }

        if (!IsPostBack)
        {
            LoadTimeZones();
            SetTimes(Settings.UserDB.ReadInt("SlaTriggerWarningTime", 1440),
                     Settings.UserDB.ReadInt("SlaTriggerInitialResponseTime", 60),
                     Settings.UserDB.ReadInt("SlaTriggerLastActionTime", 60),
                     Settings.UserDB.ReadInt("SlaTriggerClosedTime", 60));

            cbGroupViolations.Checked             = Settings.UserDB.ReadBool("SlaTriggerGroupViolations", true);
            cbGroupWarnings.Checked               = Settings.UserDB.ReadBool("SlaTriggerGroupWarnings", true);
            cbUserViolations.Checked              = Settings.UserDB.ReadBool("SlaTriggerUserViolations", true);
            cbUserWarnings.Checked                = Settings.UserDB.ReadBool("SlaTriggerUserWarnings", true);
            rbBusinessHours.Checked               = Settings.UserDB.ReadBool("SlaTriggerUseBusinessHours", true);
            rbCustomBusinessHours.Checked         = !rbBusinessHours.Checked;
            cbPauseOnOrganizationHolidays.Checked = Settings.UserDB.ReadBool("SlaTriggerPauseOnOrganizationHolidays", true);
            daysToPauseList.Attributes.Add("onkeydown", "DeleteSelectedItems(event);");
        }

        if (_slaTriggerID > -1)
        {
            _trigger = SlaTriggers.GetSlaTrigger(UserSession.LoginUser, _slaTriggerID);
            if (_trigger == null || SlaLevels.GetSlaLevel(UserSession.LoginUser, _trigger.SlaLevelID).OrganizationID != UserSession.LoginUser.OrganizationID)
            {
                Response.Write("Invalid Request");
                Response.End();
                return;
            }
            _slaLevelID   = _trigger.SlaLevelID;
            _ticketTypeID = _trigger.TicketTypeID;

            if (!IsPostBack)
            {
                LoadTrigger(_trigger);
            }
        }
        else
        {
            DisableEnableCustomBusinessHours(rbBusinessHours.Checked, rbNoBusinessHours.Checked);
        }

        SlaLevel   level = SlaLevels.GetSlaLevel(UserSession.LoginUser, _slaLevelID);
        TicketType type  = TicketTypes.GetTicketType(UserSession.LoginUser, _ticketTypeID);

        if (level == null || type == null || level.OrganizationID != UserSession.LoginUser.OrganizationID || type.OrganizationID != UserSession.LoginUser.OrganizationID)
        {
            Response.Write("Invalid Request");
            Response.End();
            return;
        }

        lblSla.Text        = level.Name;
        lblTicketType.Text = type.Name;

        if (!IsPostBack)
        {
            LoadSeverities();
        }
    }