public ActionResult Audit()
        {
            Users currentUser = new Users();

            currentUser.AddNewUser();
            currentUser.AccessUsersLDAP();
            ViewBag.Users         = currentUser.GetAllUsers().ToList();
            ViewData["MainAdmin"] = currentUser.GetAdminState(System.Web.HttpContext.Current.Application["UserEmail"].ToString(), "Maintenance");

            Maintenance t = new Maintenance();

            ViewBag.Locations             = t.GetLocations().ToList();
            ViewBag.IncompleteAuditReport = t.GetIncompleteAuditReport().ToList();
            //ViewBag.CompletedAuditReports = t.GetCompletedAuditReports().ToList();
            return(View());
        }
예제 #2
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);
    }
예제 #3
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);
    }
예제 #4
0
        public static string CreateUser(RestCommand command)
        {
            if (Organizations.GetUserCount(command.LoginUser, command.LoginUser.OrganizationID) >= command.Organization.UserSeats)
            {
                throw new RestException(HttpStatusCode.Forbidden, "You are already at your maximum user seat count for your license.");
            }
            Addresses addresses = new Addresses(command.LoginUser);
            Address   address   = addresses.AddNewAddress();

            PhoneNumbers phoneNumbers = new PhoneNumbers(command.LoginUser);
            PhoneNumber  phoneNumber  = phoneNumbers.AddNewPhoneNumber();

            Users users = new Users(command.LoginUser);
            User  user  = users.AddNewUser();

            user.FullReadFromXml(command.Data, true, ref phoneNumber, ref address);
            if (String.IsNullOrWhiteSpace(user.FirstName))
            {
                throw new RestException(HttpStatusCode.BadRequest, "FirstName is required.");
            }
            ;
            if (String.IsNullOrWhiteSpace(user.LastName))
            {
                throw new RestException(HttpStatusCode.BadRequest, "LastName is required.");
            }
            ;
            if (String.IsNullOrWhiteSpace(user.Email) || user.Email.IndexOf('@') < 0 || user.Email.IndexOf('.') < 0 || !users.IsEmailValid(user.Email, -1, command.LoginUser.OrganizationID))
            {
                throw new RestException(HttpStatusCode.BadRequest, "Email is invalid.");
            }
            ;
            user.OrganizationID       = command.LoginUser.OrganizationID;
            user.ActivatedOn          = DateTime.UtcNow;
            user.LastLogin            = DateTime.UtcNow.AddHours(-1);
            user.LastActivity         = DateTime.UtcNow.AddHours(-1);
            user.EnforceSingleSession = true;
            user.NeedsIndexing        = true;
            user.Collection.Save();
            user.UpdateCustomFieldsFromXml(command.Data);

            if (!String.IsNullOrEmpty(phoneNumber.Number) || !String.IsNullOrEmpty(phoneNumber.Extension))
            {
                phoneNumber.RefType = ReferenceType.Users;
                phoneNumber.RefID   = user.UserID;
                phoneNumbers.Save();
            }

            if (!String.IsNullOrEmpty(address.Description) ||
                !String.IsNullOrEmpty(address.Addr1) ||
                !String.IsNullOrEmpty(address.Addr2) ||
                !String.IsNullOrEmpty(address.Addr3) ||
                !String.IsNullOrEmpty(address.City) ||
                !String.IsNullOrEmpty(address.Country) ||
                !String.IsNullOrEmpty(address.Description) ||
                !String.IsNullOrEmpty(address.State) ||
                !String.IsNullOrEmpty(address.Zip))
            {
                address.RefType = ReferenceType.Users;
                address.RefID   = user.UserID;
                addresses.Save();
            }

            return(UsersView.GetUsersViewItem(command.LoginUser, user.UserID).GetXml("User", true));
        }
예제 #5
0
        public static string CreateContact(RestCommand command, int?organizationID)
        {
            Addresses addresses = new Addresses(command.LoginUser);
            Address   address   = addresses.AddNewAddress();

            PhoneNumbers phoneNumbers = new PhoneNumbers(command.LoginUser);
            PhoneNumber  phoneNumber  = phoneNumbers.AddNewPhoneNumber();

            Users users = new Users(command.LoginUser);
            User  user  = users.AddNewUser();

            user.IsActive = true;
            user.FullReadFromXml(command.Data, true, ref phoneNumber, ref address);
            if (organizationID == null && user.OrganizationID == 0)
            {
                if (!String.IsNullOrEmpty(user.Email) && user.Email.Contains("@"))
                {
                    Organizations matchDomainCompany = new Organizations(command.LoginUser);
                    matchDomainCompany.LoadFirstDomainMatch(command.LoginUser.OrganizationID, user.Email.Substring(user.Email.LastIndexOf("@") + 1));
                    if (!matchDomainCompany.IsEmpty)
                    {
                        user.OrganizationID = matchDomainCompany[0].OrganizationID;
                    }
                }

                if (user.OrganizationID == 0)
                {
                    user.OrganizationID = Organizations.GetUnknownCompanyID(command.LoginUser);
                }
            }
            else if (organizationID != null)
            {
                user.OrganizationID = (int)organizationID;
            }
            user.ActivatedOn       = DateTime.UtcNow;
            user.LastLogin         = DateTime.UtcNow;
            user.LastActivity      = DateTime.UtcNow.AddHours(-1);
            user.IsPasswordExpired = true;
            user.NeedsIndexing     = true;

            if (!string.IsNullOrEmpty(user.CryptedPassword))
            {
                user.CryptedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(user.CryptedPassword, "MD5");
            }

            user.Collection.Save();
            user.UpdateCustomFieldsFromXml(command.Data);

            if (!String.IsNullOrEmpty(phoneNumber.Number) || !String.IsNullOrEmpty(phoneNumber.Extension))
            {
                phoneNumber.RefType = ReferenceType.Users;
                phoneNumber.RefID   = user.UserID;
                phoneNumbers.Save();
            }

            if (!String.IsNullOrEmpty(address.Description) ||
                !String.IsNullOrEmpty(address.Addr1) ||
                !String.IsNullOrEmpty(address.Addr2) ||
                !String.IsNullOrEmpty(address.Addr3) ||
                !String.IsNullOrEmpty(address.City) ||
                !String.IsNullOrEmpty(address.Country) ||
                !String.IsNullOrEmpty(address.Description) ||
                !String.IsNullOrEmpty(address.State) ||
                !String.IsNullOrEmpty(address.Zip))
            {
                address.RefType = ReferenceType.Users;
                address.RefID   = user.UserID;
                addresses.Save();
            }

            return(ContactsView.GetContactsViewItem(command.LoginUser, user.UserID).GetXml("Contact", true));
        }
 public void Adduser()
 {
     Users.AddNewUser();
 }