public List <CorePlatformSettings.CustomDomain> GetCustomDomains()
        {
            var customDomains = new List <CorePlatformSettings.CustomDomain>();

            //Get all accounts
            var accounts = AccountManager.GetAllAccountsByFilter("Active", "1", 0, 5000, "AccountNameKey");

            //Get settings for each account
            foreach (var account in accounts)
            {
                if (account.Provisioned)
                {
                    try
                    {
                        var settings = AccountSettingsManager.GetAccountSettings(account);

                        if (settings.CustomDomain != null)
                        {
                            if (settings.CustomDomain != "")
                            {
                                customDomains.Add(new CorePlatformSettings.CustomDomain {
                                    AccountNameKey = account.AccountNameKey, Domain = settings.CustomDomain
                                });
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }

            return(customDomains);
        }
예제 #2
0
        /// <summary>
        /// Create a new label for managing sales leads. (limit 15)
        /// </summary>
        /// <param name="account"></param>
        /// <param name="labelName"></param>
        /// <returns></returns>
        public static DataAccessResponseType CreateLabel(Account account, string labelName)
        {
            #region Validate Sales Lead Label Requirements

            if (labelName.Length > 15)
            {
                //Table names cannot exceed 63 characters.
                //+ 3 for "acc"
                //+ 32 for [accountID]
                //+ 5 for "leads"
                //23 remaining (we do 15 for readability & safety)
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "Labels cannot be longer than 15 characters"
                });
            }
            if (labelName.Contains("  "))
            {
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "Labels cannot contain any double spaces"
                });
            }

            if (Regex.IsMatch(labelName.Replace("-", "").Replace(" ", ""), "^[a-zA-Z0-9]*$") == false)
            {
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "Labels cannot contain any special characters"
                });
            }

            #endregion

            var accountSettings = AccountSettingsManager.GetAccountSettings(account);

            if (accountSettings.SalesSettings.LeadLabels.Count >= 15)
            {
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "You cannot have more than 15 labels for sales leads"
                });
            }

            #region validate name does not already exist

            foreach (string existingLabel in accountSettings.SalesSettings.LeadLabels)
            {
                if (existingLabel.ToLower().Replace("-", "").Replace(" ", "") == labelName.ToLower().Replace("-", "").Replace(" ", ""))
                {
                    return(new DataAccessResponseType {
                        isSuccess = false, ErrorMessage = "This label already exists, or is a reserved label name"
                    });
                }
            }

            #endregion

            accountSettings.SalesSettings.LeadLabels.Add(labelName);

            return(AccountSettingsManager.UpdateAccountSettings(account, accountSettings));
        }
예제 #3
0
        public static DataAccessResponseType RemoveLabel(Account account, string labelName)
        {
            var accountSettings = AccountSettingsManager.GetAccountSettings(account);

            #region validate

            if (labelName.ToLower() == "new" || labelName.ToLower() == "deleted")
            {
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "Cannot delete a reserved label"
                });
            }

            #endregion

            bool labelFound = false;

            foreach (string existingLabel in accountSettings.SalesSettings.LeadLabels)
            {
                if (existingLabel.ToLower() == labelName.ToLower())
                {
                    labelFound = true;
                }
            }

            if (labelFound)
            {
                accountSettings.SalesSettings.LeadLabels.RemoveAt(accountSettings.SalesSettings.LeadLabels.IndexOf(labelName));
                return(AccountSettingsManager.UpdateAccountSettings(account, accountSettings));
            }
            else
            {
                return(new DataAccessResponseType {
                    isSuccess = false, ErrorMessage = "Could not find label to remove"
                });
            }
        }