Ejemplo n.º 1
0
    public override bool Save()
    {
        Organization organization = (Organization)Organizations.GetOrganization(UserSession.LoginUser, _organizationID);

        int?id = int.Parse(cmbUsers.SelectedValue);

        organization.PrimaryUserID = id < 0 ? null : id;

        organization.TimeZoneID            = cmbTimeZones.SelectedValue;
        UserSession.LoginUser.TimeZoneInfo = null;
        try
        {
            TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(organization.TimeZoneID);
        }
        catch (Exception)
        {
        }
        Settings.OrganizationDB.WriteBool("ShowOnlyCustomerProducts", cbLinkTicketCustomersWithProducts.Checked);
        organization.AutoAssignCustomerWithAssetOnTickets = cbAutoAssignCustomerWithAssetOnTickets.Checked;
        organization.AutoAssociateCustomerToTicketBasedOnAssetAssignment = cbAutoAssociateCustomerToTicketBasedOnAssetAssignment.Checked;
        organization.CultureName   = cmbDateFormat.SelectedValue;
        organization.UseEuropeDate = (cmbDateFormat.SelectedValue == "en-GB");

        organization.FontFamily = (FontFamily)Convert.ToInt32(cmbFontFamily.SelectedValue);
        organization.FontSize   = (TeamSupport.Data.FontSize)Convert.ToInt32(cmbFontSize.SelectedValue);

        if (cmbSla.SelectedIndex == 0)
        {
            organization.InternalSlaLevelID = null;
        }
        else
        {
            organization.InternalSlaLevelID = int.Parse(cmbSla.SelectedValue);
        }
        Settings.OrganizationDB.WriteBool("DisableStatusNotification", cbDisableStatusNotifications.Checked);
        organization.SetNewActionsVisibleToCustomers             = cbNewActionsVisible.Checked;
        organization.AllowUnsecureAttachmentViewing              = cbUnsecureAttachments.Checked;
        organization.SlaInitRespAnyAction                        = cbSlaInitRespAnyAction.Checked;
        organization.ShowGroupMembersFirstInTicketAssignmentList = cbShowGroupMembersFirstInTicketAssignmentList.Checked;
        organization.HideDismissNonAdmins                        = cbHideDismissNonAdmins.Checked;
        organization.UpdateTicketChildrenGroupWithParent         = cbUpdateTicketChildrenGroupWithParent.Checked;
        //organization.UseForums = cbCommunity.Checked;
        Settings.OrganizationDB.WriteBool("RequireNewTicketCustomer", cbRequireCustomer.Checked);
        //organization.AdminOnlyCustomers = cbAdminCustomers.Checked;
        organization.TimedActionsRequired = cbTimeRequired.Checked;
        organization.AdminOnlyReports     = cbAdminReports.Checked;
        organization.Website        = textWebSite.Text;
        organization.CompanyDomains = textDomains.Text;
        organization.Description    = textDescription.Text;
        if (timeBDStart.SelectedDate != null)
        {
            organization.BusinessDayStart = (DateTime)DataUtils.DateToUtc(UserSession.LoginUser, timeBDStart.SelectedDate);
        }
        if (timeBDEnd.SelectedDate != null)
        {
            organization.BusinessDayEnd = (DateTime)DataUtils.DateToUtc(UserSession.LoginUser, timeBDEnd.SelectedDate);
        }
        organization.ClearBusinessDays();
        if (cbBDSunday.Checked)
        {
            organization.AddBusinessDay(DayOfWeek.Sunday);
        }
        if (cbBDMonday.Checked)
        {
            organization.AddBusinessDay(DayOfWeek.Monday);
        }
        if (cbBDTuesday.Checked)
        {
            organization.AddBusinessDay(DayOfWeek.Tuesday);
        }
        if (cbBDWednesday.Checked)
        {
            organization.AddBusinessDay(DayOfWeek.Wednesday);
        }
        if (cbBDThursday.Checked)
        {
            organization.AddBusinessDay(DayOfWeek.Thursday);
        }
        if (cbBDFriday.Checked)
        {
            organization.AddBusinessDay(DayOfWeek.Friday);
        }
        if (cbBDSaturday.Checked)
        {
            organization.AddBusinessDay(DayOfWeek.Saturday);
        }

        organization.ProductRequired        = cbRequireProduct.Checked;
        organization.ProductVersionRequired = cbRequireProductVersion.Checked;

        organization.UseProductFamilies = cbUseProductFamilies.Checked;

        organization.IsCustomerInsightsActive     = cbIsCustomerInsightsActive.Checked;
        organization.TwoStepVerificationEnabled   = cbTwoStepVerification.Checked;
        organization.NoAttachmentsInOutboundEmail = cbNoAttachmentsInOutboundEmail.Checked;

        if (organization.NoAttachmentsInOutboundEmail && lbNoAttachmentsInOutboundExcludeProductLine.Items.Count > 0)
        {
            string exclude = null;

            foreach (ListItem item in lbNoAttachmentsInOutboundExcludeProductLine.Items)
            {
                if (item.Selected)
                {
                    exclude += string.Empty + item.Value + ",";
                }
            }

            if (!string.IsNullOrEmpty(exclude) && exclude.LastIndexOf(",") == exclude.Length - 1)
            {
                exclude = exclude.TrimEnd(',');
            }

            organization.NoAttachmentsInOutboundExcludeProductLine = exclude;
        }

        organization.UseWatson        = cbUseWatson.Checked;
        organization.RequireTwoFactor = cbRequireTwoFactor.Checked;
        organization.RequireGroupAssignmentOnTickets = cbRequireGroupAssignmentOnTickets.Checked;
        organization.AlertContactNoEmail             = cbAlertContactNoEmail.Checked;
        if (organization.DisableSupportLogin != !cbDisableSupport.Checked)
        {
            ActionLogs.AddActionLog(organization.Collection.LoginUser, ActionLogType.Update, ReferenceType.SystemSettings, organization.Collection.LoginUser.UserID, "Changed the 'Allow TeamSupport to log into your account for technical support' to: " + (cbDisableSupport.Checked).ToString());
        }
        organization.DisableSupportLogin      = !cbDisableSupport.Checked;
        organization.DaysBeforePasswordExpire = (int)textPWExpire.Value;

        try
        {
            organization.DefaultWikiArticleID = int.Parse(cmbWikiArticle.SelectedValue);
        }
        catch (Exception)
        {
            organization.DefaultWikiArticleID = null;
        }

        organization.Collection.Save();

        UserSession.RefreshCurrentUserInfo();
        UserSession.RefreshLoginUser();
        return(true);
    }