예제 #1
0
    public override bool Save()
    {
        OrganizationProduct organizationProduct = null;

        if (_organizationProductID < 0)
        {
            organizationProduct = (new OrganizationProducts(UserSession.LoginUser)).AddNewOrganizationProduct();
        }
        else
        {
            organizationProduct = (OrganizationProduct)OrganizationProducts.GetOrganizationProduct(UserSession.LoginUser, _organizationProductID);
        }

        organizationProduct.OrganizationID = int.Parse(cmbCustomers.SelectedValue);
        organizationProduct.ProductID      = int.Parse(cmbProducts.SelectedValue);
        if (cmbVersions.SelectedIndex > 0)
        {
            organizationProduct.ProductVersionID = int.Parse(cmbVersions.SelectedValue);
        }
        else
        {
            organizationProduct.ProductVersionID = null;
        }
        organizationProduct.SupportExpiration = DataUtils.DateToUtc(UserSession.LoginUser, dtExpiration.SelectedDate);
        organizationProduct.Collection.Save();

        _fieldControls.RefID = organizationProduct.OrganizationProductID;
        _fieldControls.SaveCustomFields();

        return(true);
    }
예제 #2
0
    public override bool Save()
    {
        if (textName.Text.Trim() == "")
        {
            _manager.Alert("Please enter a name for your product.");
            return(false);
        }

        Product  product;
        Products products = new Products(UserSession.LoginUser);;

        if (_productID < 0)
        {
            product = products.AddNewProduct();
            product.OrganizationID = UserSession.LoginUser.OrganizationID;
        }
        else
        {
            products.LoadByProductID(_productID);
            if (products.IsEmpty)
            {
                return(false);
            }
            product = products[0];
        }

        product.Name        = textName.Text;
        product.Description = textDescription.Text;
        product.Collection.Save();

        _fieldControls.RefID = product.ProductID;
        _fieldControls.SaveCustomFields();

        return(true);
    }
예제 #3
0
    public override bool Save()
    {
        if (textVersionNumber.Text.Trim() == "")
        {
            _manager.Alert("Please enter a version number.");
            return(false);
        }

        ProductVersion  version;
        ProductVersions versions = new ProductVersions(UserSession.LoginUser);;

        if (_versionID < 0)
        {
            version = versions.AddNewProductVersion();
        }
        else
        {
            versions.LoadByProductVersionID(_versionID);
            if (versions.IsEmpty)
            {
                return(false);
            }
            version = versions[0];
        }

        version.VersionNumber          = textVersionNumber.Text;
        version.ProductVersionStatusID = int.Parse(cmbStatus.SelectedValue);
        version.ProductID   = int.Parse(cmbProduct.SelectedValue);
        version.Description = editorDescription.Content;
        version.IsReleased  = cbReleased.Checked;
        if (dpRelease.SelectedDate == null)
        {
            version.ReleaseDate = null;
        }
        else
        {
            DateTime date = new DateTime(((DateTime)dpRelease.SelectedDate).Ticks);
            version.ReleaseDate = DataUtils.DateToUtc(UserSession.LoginUser, date);
        }

        version.Collection.Save();
        (new OrganizationProducts(UserSession.LoginUser)).UpdateVersionProduct(version.ProductVersionID, version.ProductID);

        _fieldControls.RefID = version.ProductVersionID;
        _fieldControls.SaveCustomFields();

        return(true);
    }
예제 #4
0
    public override bool Save()
    {
        if (string.IsNullOrEmpty(textName.Text.Trim()))
        {
            _manager.Alert("Please choose a name.");
            return(false);
        }

        Organization organization;

        Organizations organizations = new Organizations(UserSession.LoginUser);

        if (_organizatinID < 0)
        {
            organization               = organizations.AddNewOrganization();
            organization.ParentID      = UserSession.LoginUser.OrganizationID;
            organization.PrimaryUserID = null;

            organization.ExtraStorageUnits = 0;
            organization.PortalSeats       = 0;
            organization.UserSeats         = 0;
            organization.IsCustomerFree    = false;
            organization.ProductType       = ProductType.Express;
            organization.HasPortalAccess   = false;
            organization.IsActive          = true;
            organization.IsBasicPortal     = true;
        }
        else
        {
            organization = Organizations.GetOrganization(UserSession.LoginUser, _organizatinID);
        }

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

        organization.PrimaryUserID = id < 0 ? null : id;
        id = int.Parse(cmbSupportUsers.SelectedValue);
        organization.DefaultSupportUserID = id < 0 ? null : id;
        id = int.Parse(cmbGroups.SelectedValue);
        organization.DefaultPortalGroupID = id < 0 ? null : id;
        id = int.Parse(cmbSupportGroups.SelectedValue);
        organization.DefaultSupportGroupID = id < 0 ? null : id;

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

        if (organization.Name != "_Unknown Company")
        {
            organization.Name = textName.Text;
        }

        organization.Website        = textWebSite.Text;
        organization.CompanyDomains = textDomains.Text;

        organization.Description      = textDescription.Text;
        organization.SAExpirationDate = DataUtils.DateToUtc(UserSession.LoginUser, dpSAExpiration.SelectedDate);

        if (cmbSlas.SelectedIndex == 0)
        {
            organization.SlaLevelID = null;
        }
        else
        {
            organization.SlaLevelID = int.Parse(cmbSlas.SelectedValue);
        }

        int shm = 0;

        int.TryParse(textSupportHoursMonth.Text, out shm);

        organization.SupportHoursMonth = shm;

        if (_isAdmin)
        {
            organization.HasPortalAccess = cbPortal.Checked;
            organization.IsActive        = cbActive.Checked;
            organization.IsApiActive     = cbApiEnabled.Checked;
            organization.IsApiEnabled    = cbApiEnabled.Checked;
            organization.InActiveReason  = textActiveReason.Text;
        }
        organization.Collection.Save();
        Settings.Session.WriteInt("SelectedOrganizationID", organization.OrganizationID);

        _customControls.RefID = organization.OrganizationID;
        if (_organizatinID != UserSession.LoginUser.OrganizationID)
        {
            _customControls.SaveCustomFields();
        }


        return(true);
    }
예제 #5
0
    public override bool Save()
    {
        User  user;
        Users users = new Users(UserSession.LoginUser);

        Organization organization = Organizations.GetOrganization(UserSession.LoginUser, UserSession.LoginUser.OrganizationID);

        string email = textEmail.Text.Trim();

        if (email.Length < 1 || email.IndexOf('@') < 0 || email.IndexOf('.') < 0 || !users.IsEmailValid(email, _userID, _organizationID))
        {
            _manager.Alert("The email you have specified is invalid.  Please choose another email.");
            return(false);
        }

        if (textFirstName.Text.Trim().Length < 1 || textLastName.Text.Trim().Length < 1)
        {
            _manager.Alert("The name you have specified is invalid.  Please enter your name.");
            return(false);
        }


        if (cbChat.Checked && Organizations.GetChatCount(UserSession.LoginUser, UserSession.LoginUser.OrganizationID) >= organization.ChatSeats)
        {
            _manager.Alert("You have exceeded your chat licenses.  Please purchase more seats to add additional chat users.");
            cbChat.Checked = false;
            return(false);
        }

        if (_userID < 0)
        {
            if (Organizations.GetUserCount(UserSession.LoginUser, UserSession.LoginUser.OrganizationID) >= organization.UserSeats)
            {
                _manager.Alert("You have exceeded your user licenses.  Please send an email to [email protected] if you would like to add additional users your account.");
                return(false);
            }

            user = users.AddNewUser();
            user.OrganizationID = _organizationID;
            if (cbActive.Checked)
            {
                user.ActivatedOn = DateTime.UtcNow;
            }
            user.LastLogin                  = DateTime.UtcNow;
            user.LastActivity               = DateTime.UtcNow;
            user.IsPasswordExpired          = true;
            user.ReceiveTicketNotifications = true;
            user.EnforceSingleSession       = true;
            user.IsClassicView              = true;
        }
        else
        {
            users.LoadByUserID(_userID);
            if (users.IsEmpty)
            {
                _manager.Alert("There was an error updating the user information");
                return(false);
            }

            user = users[0];
            if (user.IsActive && !cbActive.Checked)
            {
                user.DeactivatedOn = DateTime.UtcNow;
                Organizations orgs = new Organizations(TSAuthentication.GetLoginUser());
                orgs.ResetDefaultSupportUser(TSAuthentication.GetLoginUser(), user.UserID);
            }

            if (true)
            {
                if (!user.IsActive && cbActive.Checked && Organizations.GetUserCount(UserSession.LoginUser, UserSession.LoginUser.OrganizationID) >= organization.UserSeats)
                {
                    _manager.Alert("You have exceeded your user licenses.  Please send an email to [email protected] if you would like to add additional users your account.");
                    return(false);
                }
            }
        }

        user.Email        = textEmail.Text.Trim();
        user.FirstName    = textFirstName.Text.Trim();
        user.LastName     = textLastName.Text.Trim();
        user.MiddleName   = textMiddleName.Text.Trim();
        user.Title        = textTitle.Text;
        user.IsPortalUser = true;
        user.TimeZoneID   = cmbTimeZones.SelectedValue;
        user.CultureName  = cmbDateFormat.SelectedValue;
        user.FontFamily   = (FontFamily)Convert.ToInt32(cmbFontFamilies.SelectedValue);
        user.FontSize     = (TeamSupport.Data.FontSize)Convert.ToInt32(cmbFontSizes.SelectedValue);
        user.ReceiveTicketNotifications        = cbEmailNotify.Checked;
        user.SubscribeToNewTickets             = cbSubscribe.Checked;
        user.SubscribeToNewActions             = cbSubscribeAction.Checked;
        user.ReceiveAllGroupNotifications      = cbReceiveGroup.Checked;
        user.DoNotAutoSubscribe                = cbNoAutoSubscribe.Checked;
        user.RestrictUserFromEditingAnyActions = cbRestrictUserFromEditingAnyActions.Checked;
        user.AllowUserToEditAnyAction          = cbAllowUserToEditAnyAction.Checked;
        user.UserCanPinAction = cbUserCanPinAction.Checked;
        user.TicketRights     = (TicketRightType)int.Parse(cmbRights.SelectedValue);
        user.ShowWelcomePage  = true;
        UserSession.LoginUser.TimeZoneInfo = null;

        if (UserSession.CurrentUser.IsSystemAdmin)
        {
            user.IsActive      = cbActive.Checked;
            user.IsSystemAdmin = cbIsSystemAdmin.Checked;
            user.IsChatUser    = cbChat.Checked;
        }


        string checkRequired = _fieldControls.CheckRequiredCustomFields();

        if (checkRequired != "")
        {
            _manager.Alert(checkRequired);
            return(false);
        }

        user.Collection.Save();

        if (user.IsActive)
        {
            user.EmailCountToMuroc(true);
        }

        _fieldControls.RefID = user.UserID;
        _fieldControls.SaveCustomFields();

        if (_userID < 0)
        {
            string password = DataUtils.GenerateRandomPassword();
            user.CryptedPassword    = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
            user.IsPasswordExpired  = true;
            user.PasswordCreatedUtc = DateTime.UtcNow;
            user.Collection.Save();
            if (cbEmail.Checked)
            {
                EmailPosts.SendWelcomeTSUser(UserSession.LoginUser, user.UserID, password);
            }

            Organization orgTemplate = Organizations.GetTemplateOrganization(UserSession.LoginUser, organization.ProductType);

            if (orgTemplate != null)
            {
                UserSettings.WriteString(UserSession.LoginUser, user.UserID, "Dashboard", UserSettings.ReadString(UserSession.LoginUser, (int)orgTemplate.PrimaryUserID, "Dashboard"));
            }
        }

        TeamSupportSync.SyncUser(user.UserID, user.OrganizationID, user.FirstName, user.LastName, user.Email, user.Title);

        if (UserSession.CurrentUser.UserID == _userID)
        {
            UserSession.RefreshCurrentUserInfo();
            UserSession.RefreshLoginUser();
        }


        return(true);
    }
예제 #6
0
    public override bool Save()
    {
        User  user;
        Users users    = new Users(UserSession.LoginUser);;
        int   newOrgID = int.Parse(cmbCustomer.SelectedValue);


        string email = textEmail.Text.Trim();

        if ((cbIsPortalUser.Checked) && (email.Length < 1 || email.IndexOf('@') < 0 || email.IndexOf('.') < 0))
        {
            _manager.Alert("The email you have specified is invalid.  Please choose another email.");
            return(false);
        }

        if (email != "" && !users.IsEmailValid(email, _userID, newOrgID))
        {
            _manager.Alert("The email you have specified is already in use.  Please choose another email.");
            return(false);
        }

        if (textFirstName.Text.Trim().Length < 1 || textLastName.Text.Trim().Length < 1)
        {
            _manager.Alert("The name you have specified is invalid.  Please enter your name.");
            return(false);
        }


        if (_userID < 0)
        {
            user = users.AddNewUser();
            user.OrganizationID = newOrgID;
            if (cbActive.Checked)
            {
                user.ActivatedOn = DateTime.UtcNow;
            }
            user.LastLogin                  = DateTime.UtcNow;
            user.LastActivity               = DateTime.UtcNow.AddHours(-1);
            user.IsPasswordExpired          = true;
            user.ReceiveTicketNotifications = true;
        }
        else
        {
            users.LoadByUserID(_userID);
            if (users.IsEmpty)
            {
                _manager.Alert("There was an error updating the user information");
                return(false);
            }

            user = users[0];
            if (user.IsActive && !cbActive.Checked)
            {
                user.DeactivatedOn = DateTime.UtcNow;
            }
            if (user.OrganizationID != newOrgID)
            {
                user.OrganizationID = newOrgID;
                Tickets tickets = new Tickets(UserSession.LoginUser);
                tickets.LoadByContact(user.UserID);
                foreach (Ticket ticket in tickets)
                {
                    tickets.AddOrganization(newOrgID, ticket.TicketID);
                }
            }
        }

        user.Email             = textEmail.Text;
        user.FirstName         = textFirstName.Text;
        user.LastName          = textLastName.Text;
        user.Title             = textTitle.Text;
        user.MiddleName        = textMiddleName.Text;
        user.BlockInboundEmail = cbBlockEmail.Checked;


        user.IsActive = cbActive.Checked;

        if (UserSession.CurrentUser.HasPortalRights && UserSession.CurrentUser.IsSystemAdmin)
        {
            user.IsPortalUser = cbIsPortalUser.Checked;
        }

        if (UserSession.CurrentUser.IsTSUser && UserSession.CurrentUser.IsSystemAdmin)
        {
            user.IsSystemAdmin  = cbIsSystemAdmin.Checked;
            user.IsFinanceAdmin = cbIsFinanceAdmin.Checked;
        }



        user.Collection.Save();

        _fieldControls.RefID = user.UserID;
        _fieldControls.SaveCustomFields();

        if (_userID < 0)
        {
            string password = DataUtils.GenerateRandomPassword();
            user.CryptedPassword   = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
            user.IsPasswordExpired = true;
            user.Collection.Save();
            if (UserSession.CurrentUser.IsTSUser && cbEmail.Checked)
            {
                EmailPosts.SendWelcomeTSUser(UserSession.LoginUser, user.UserID, password);
            }
            else if (cbEmail.Checked && cbIsPortalUser.Checked)
            {
                EmailPosts.SendWelcomePortalUser(UserSession.LoginUser, user.UserID, password);
            }
        }

        return(true);
    }