private void InitUserTypeSelector() { var canAddUser = TenantStatisticsProvider.GetUsersCount() < TenantExtra.GetTenantQuota().ActiveUsers; var canEditType = SecurityContext.CheckPermissions(Constants.Action_AddRemoveUser) && (!(ProfileIsAdmin || ProfileIsAnyModuleAdmin) || !IsPageEditProfileFlag); var isVisitorType = (ProfileIsMe && !IsPageEditProfileFlag) ? Request["type"] == "guest" : ProfileIsVisitor; if (canAddUser) { if (isVisitorType && !canEditType) { UserTypeSelectorClass = "disabled"; UserTypeSelectorGuestItemClass = "active"; UserTypeSelectorUserItemClass = "disabled"; } else { if (canEditType) { UserTypeSelectorClass = ""; UserTypeSelectorGuestItemClass = isVisitorType ? "active" : ""; UserTypeSelectorUserItemClass = isVisitorType ? "" : "active"; } else { UserTypeSelectorClass = "disabled"; UserTypeSelectorGuestItemClass = "disabled"; UserTypeSelectorUserItemClass = "active"; } } } else { if (isVisitorType || !IsPageEditProfileFlag) { UserTypeSelectorClass = canEditType ? "" : "disabled"; UserTypeSelectorGuestItemClass = "active"; UserTypeSelectorUserItemClass = "disabled"; } else { if (canEditType) { UserTypeSelectorClass = ""; UserTypeSelectorGuestItemClass = isVisitorType ? "active" : ""; UserTypeSelectorUserItemClass = isVisitorType ? "" : "active"; } else { UserTypeSelectorClass = "disabled"; UserTypeSelectorGuestItemClass = "disabled"; UserTypeSelectorUserItemClass = "active"; } } } }
protected void Page_Load(object sender, EventArgs e) { IsPageEditProfileFlag = (Request["action"] == "edit"); ProfileHelper = new ProfileHelper(Request["user"]); UserInfo = ProfileHelper.UserInfo; if ((IsPageEditProfileFlag && !(UserInfo.IsMe() || CanEdit())) || (!IsPageEditProfileFlag && !IsAdmin())) { Response.Redirect("~/products/people/", true); } Page.RegisterBodyScripts("~/usercontrols/users/userprofile/js/userprofileeditcontrol.js"); Page.RegisterStyle("~/usercontrols/users/userprofile/css/profileeditcontrol_style.less"); CanAddUser = TenantStatisticsProvider.GetUsersCount() < TenantExtra.GetTenantQuota().ActiveUsers; CanEditType = SecurityContext.CheckPermissions(Constants.Action_AddRemoveUser) && (!(UserInfo.IsAdmin() || IsModuleAdmin()) || !IsPageEditProfileFlag); if (IsPageEditProfileFlag) { Phone = UserInfo.MobilePhone.HtmlEncode(); ProfileGender = UserInfo.Sex.HasValue ? UserInfo.Sex.Value ? "1" : "0" : "-1"; Departments = CoreContext.UserManager.GetUserGroups(UserInfo.ID); SocContacts = ProfileHelper.Contacts; OtherContacts = new List <MyContact>(); OtherContacts.AddRange(ProfileHelper.Emails); OtherContacts.AddRange(ProfileHelper.Messengers); OtherContacts.AddRange(ProfileHelper.Phones); var deps = Departments.ToList(); var script = String.Format( @"<script type='text/javascript'> var departmentsList = {0}; var socContacts = {1}; var otherContacts = {2}; var userId= {3}; </script>", JsonConvert.SerializeObject(deps.ConvertAll(item => new { id = item.ID, title = item.Name.HtmlEncode() })), JsonConvert.SerializeObject(SocContacts), JsonConvert.SerializeObject(OtherContacts), JsonConvert.SerializeObject(UserInfo.ID)); Page.ClientScript.RegisterStartupScript(GetType(), Guid.NewGuid().ToString(), script); } var photoControl = (LoadPhotoControl)LoadControl(LoadPhotoControl.Location); loadPhotoWindow.Controls.Add(photoControl); Page.Title = HeaderStringHelper.GetPageTitle(GetTitle()); }
protected void Page_Load(object sender, EventArgs e) { Page .RegisterBodyScripts("~/usercontrols/management/tariffsettings/js/tariffusage.js", "~/js/asc/plugins/countries.js", "~/js/asc/plugins/phonecontroller.js") .RegisterStyle( "~/skins/default/phonecontroller.css", "~/usercontrols/management/tariffsettings/css/tariff.less", "~/usercontrols/management/tariffsettings/css/tariffusage.less") .RegisterClientScript(new CountriesResources()); CurrentRegion = RegionDefault; Regions.Add(CurrentRegion); UsersCount = TenantStatisticsProvider.GetUsersCount(); UsedSize = TenantStatisticsProvider.GetUsedSize(); CurrentTariff = TenantExtra.GetCurrentTariff(); CurrentQuota = TenantExtra.GetTenantQuota(); if (_quotaList == null || !_quotaList.Any()) { _quotaList = TenantExtra.GetTenantQuotas(); } else if (!CurrentQuota.Trial) { CurrentQuota = _quotaList.FirstOrDefault(q => q.Id == CurrentQuota.Id) ?? CurrentQuota; } _quotaList = _quotaList.OrderBy(r => r.ActiveUsers).ToList().Where(r => !r.Trial); QuotasYear = _quotaList.Where(r => r.Year).ToList(); MonthIsDisable = !CurrentQuota.Free && (CurrentQuota.Year || CurrentQuota.Year3) && CurrentTariff.State == TariffState.Paid; YearIsDisable = !CurrentQuota.Free && CurrentQuota.Year3 && CurrentTariff.State == TariffState.Paid; var minYearQuota = QuotasYear.FirstOrDefault(q => q.ActiveUsers >= UsersCount && q.MaxTotalSize >= UsedSize); MinActiveUser = minYearQuota != null ? minYearQuota.ActiveUsers : (QuotasYear.Count > 0 ? QuotasYear.Last().ActiveUsers : 0 + 1); HideBuyRecommendation = CurrentTariff.Autorenewal || TariffSettings.HideRecommendation; downgradeInfoContainer.Options.IsPopup = true; buyRecommendationContainer.Options.IsPopup = true; AjaxPro.Utility.RegisterTypeForAjax(GetType()); if (StudioSmsNotificationSettings.IsVisibleSettings && (SettingsManager.Instance.LoadSettings <StudioSmsNotificationSettings>(TenantProvider.CurrentTenantID).EnableSetting || CoreContext.UserManager.IsUserInGroup(SecurityContext.CurrentAccount.ID, Constants.GroupAdmin.ID))) { SmsEnable = true; var smsBuy = (SmsBuy)LoadControl(SmsBuy.Location); smsBuy.ShowLink = !SettingsManager.Instance.LoadSettings <StudioSmsNotificationSettings>(TenantProvider.CurrentTenantID).EnableSetting; SmsBuyHolder.Controls.Add(smsBuy); } RegisterScript(); CurrencyCheck(); }
private void InitData() { HasPendingProfiles = CoreContext.UserManager.GetUsers().Any(u => u.ActivationStatus == EmployeeActivationStatus.Pending); EnableAddUsers = TenantStatisticsProvider.GetUsersCount() < TenantExtra.GetTenantQuota().ActiveUsers; EnableAddVisitors = CoreContext.Configuration.Standalone || TenantStatisticsProvider.GetVisitorsCount() < TenantExtra.GetTenantQuota().ActiveUsers *Constants.CoefficientOfVisitors; CurrentUserFullAdmin = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsAdmin(); CurrentUserAdmin = CurrentUserFullAdmin || WebItemSecurity.IsProductAdministrator(WebItemManager.PeopleProductID, SecurityContext.CurrentAccount.ID); IsFreeTariff = TenantExtra.GetTenantQuota().Free; }
protected Tuple <string, string, string> GetShoppingData(TenantQuota quota, string currency, int quantity) { var getLink = true; var buttonText = Resource.TariffButtonBuy; var infoText = string.Empty; var currentUsersCount = TenantStatisticsProvider.GetUsersCount(); var currentVisitorsCount = TenantStatisticsProvider.GetVisitorsCount(); var currentUsedSize = TenantStatisticsProvider.GetUsedSize(); var currentTariff = TenantExtra.GetCurrentTariff(); var currentQuota = TenantExtra.GetTenantQuota(); var language = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName; var customerId = CoreContext.TenantManager.GetCurrentTenant().OwnerId.ToString(); var quotaActiveUsers = quota.ActiveUsers == -1 ? quantity : quota.ActiveUsers; var quotaMaxTotalSize = quota.ActiveUsers == -1 ? quota.MaxTotalSize * quantity : quota.MaxTotalSize; if (quotaActiveUsers < currentUsersCount || quotaMaxTotalSize < currentUsedSize || (!currentQuota.Free && (quotaActiveUsers * Constants.CoefficientOfVisitors) < currentVisitorsCount)) { getLink = false; } else if (Equals(quota.Id, currentQuota.Id) && quantity == currentTariff.Quantity) { buttonText = Resource.TariffButtonExtend; if (!currentTariff.Prolongable) { getLink = false; } else if (currentTariff.Autorenewal) { getLink = false; buttonText = Resource.TariffEnabledAutorenew; infoText = Resource.TariffRemarkProlongEnable; } } else if (currentTariff.Prolongable) { buttonText = Resource.TariffButtonBuy; infoText = Resource.TariffRemarkProlongDisable; } else if (currentTariff.State == TariffState.Paid && quotaActiveUsers < currentQuota.ActiveUsers) { getLink = false; buttonText = Resource.TariffButtonBuy; infoText = currentQuota.Year3 ? Resource.TariffRemarkDisabledYear : Resource.TariffRemarkDisabledMonth; } var link = getLink ? GetShoppingLink(quota, currency, language, customerId, quantity) : string.Empty; return(new Tuple <string, string, string>(buttonText, infoText, link)); }
private void InitData() { Groups = CoreContext.UserManager.GetDepartments().Select(r => new MyGroup(r)).ToList(); Groups.Sort((group1, group2) => String.Compare(group1.Title, group2.Title, StringComparison.Ordinal)); Profiles = CoreContext.UserManager.GetUsers().ToList(); HasPendingProfiles = Profiles.FindAll(u => u.ActivationStatus == EmployeeActivationStatus.Pending).Count > 0; EnableAddUsers = TenantStatisticsProvider.GetUsersCount() < TenantExtra.GetTenantQuota().ActiveUsers; CurrentUserAdmin = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsAdmin(); }
public static TenantQuota GetRightQuota() { var usedSpace = TenantStatisticsProvider.GetUsedSize(); var needUsersCount = TenantStatisticsProvider.GetUsersCount(); return(GetTenantQuotas().OrderBy(r => r.ActiveUsers) .FirstOrDefault(quota => quota.ActiveUsers > needUsersCount && quota.MaxTotalSize > usedSpace && quota.DocsEdition && !quota.Year)); }
public AjaxResponse RequestPayPal(int qoutaId) { var res = new AjaxResponse(); try { if (!HttpRuntime.Cache.Get(PartnerCache).Equals(DateTime.UtcNow)) { HttpRuntime.Cache.Insert(PartnerCache, DateTime.UtcNow); } var partnerId = CoreContext.TenantManager.GetCurrentTenant().PartnerId; var partner = CoreContext.PaymentManager.GetPartner(partnerId); if (partner == null || partner.Status != PartnerStatus.Approved || partner.Removed || partner.PaymentMethod != PartnerPaymentMethod.PayPal) { throw new MethodAccessException(Resource.PartnerPayPalExc); } var tenantQuota = TenantExtra.GetTenantQuota(qoutaId); var curruntQuota = TenantExtra.GetTenantQuota(); if (TenantExtra.GetCurrentTariff().State == TariffState.Paid && tenantQuota.ActiveUsers < curruntQuota.ActiveUsers && tenantQuota.Year == curruntQuota.Year) { throw new MethodAccessException(Resource.PartnerPayPalDowngrade); } if (tenantQuota.Price > partner.AvailableCredit) { CoreContext.PaymentManager.RequestClientPayment(partnerId, qoutaId, false); throw new Exception(Resource.PartnerRequestLimitInfo); } var usersCount = TenantStatisticsProvider.GetUsersCount(); var usedSize = TenantStatisticsProvider.GetUsedSize(); if (tenantQuota.ActiveUsers < usersCount || tenantQuota.MaxTotalSize < usedSize) { res.rs2 = "quotaexceed"; return(res); } res.rs1 = CoreContext.PaymentManager.GetButton(partner.Id, qoutaId); } catch (Exception e) { res.message = e.Message; } return(res); }
public void GetFree() { var quota = TenantExtra.GetTenantQuota(); var usersCount = TenantStatisticsProvider.GetUsersCount(); var usedSize = TenantStatisticsProvider.GetUsedSize(); if (!quota.Free && quota.ActiveUsers >= usersCount && quota.MaxTotalSize >= usedSize) { TenantExtra.FreeRequest(); } }
protected void Page_Load(object sender, EventArgs e) { Page.RegisterBodyScripts("~/js/uploader/ajaxupload.js"); Page.RegisterBodyScripts("~/usercontrols/management/tariffsettings/js/tariffstandalone.js"); Page.RegisterStyle("~/usercontrols/management/tariffsettings/css/tariff.less"); Page.RegisterStyle("~/usercontrols/management/tariffsettings/css/tariffstandalone.less"); UsersCount = TenantStatisticsProvider.GetUsersCount(); CurrentTariff = TenantExtra.GetCurrentTariff(); CurrentQuota = TenantExtra.GetTenantQuota(); AjaxPro.Utility.RegisterTypeForAjax(GetType()); }
public TenantQuota GetRightQuota() { var usedSpace = TenantStatisticsProvider.GetUsedSize(); var needUsersCount = TenantStatisticsProvider.GetUsersCount(); var quotas = GetTenantQuotas(); return(quotas.OrderBy(q => q.ActiveUsers) .ThenBy(q => q.Year) .FirstOrDefault(q => q.ActiveUsers > needUsersCount && q.MaxTotalSize > usedSpace && !q.Free && !q.Trial)); }
protected void Page_Load(object sender, EventArgs e) { LinkText = CustomNamingPeople.Substitute <Resource>("InviteUsersToPortalLink").HtmlEncode(); if (CoreContext.Configuration.Personal) { EnableAddUsers = true; EnableAddVisitors = true; } else { EnableAddUsers = TenantStatisticsProvider.GetUsersCount() < TenantExtra.GetTenantQuota().ActiveUsers; EnableAddVisitors = CoreContext.Configuration.Standalone || TenantStatisticsProvider.GetVisitorsCount() < TenantExtra.GetTenantQuota().ActiveUsers *Constants.CoefficientOfVisitors; } }
public QuotaWrapper(TenantQuota quota, IList <TenantQuotaRow> quotaRows) { StorageSize = (ulong)Math.Max(0, quota.MaxTotalSize); UsedSize = (ulong)Math.Max(0, quotaRows.Sum(r => r.Counter)); MaxFileSize = Math.Min(AvailableSize, (ulong)quota.MaxFileSize); MaxUsersCount = TenantExtra.GetTenantQuota().ActiveUsers; UsersCount = TenantStatisticsProvider.GetUsersCount(); StorageUsage = quotaRows .Select(x => new QuotaUsage { Path = x.Path.TrimStart('/').TrimEnd('/'), Size = x.Counter, }) .ToList(); }
private UserInfo AddUser(UserInfo userInfo) { UserInfo newUserInfo; try { newUserInfo = userInfo.Clone() as UserInfo; if (newUserInfo == null) { return(Constants.LostUser); } _log.DebugFormat("Adding or updating user in database, userId={0}", userInfo.ID); SecurityContext.CurrentAccount = ASC.Core.Configuration.Constants.CoreSystem; if (string.IsNullOrEmpty(newUserInfo.UserName)) { var limitExceeded = TenantStatisticsProvider.GetUsersCount() >= TenantExtra.GetTenantQuota().ActiveUsers; newUserInfo = UserManagerWrapper.AddUser(newUserInfo, UserManagerWrapper.GeneratePassword(), true, false, isVisitor: limitExceeded); } else { if (!UserFormatter.IsValidUserName(userInfo.FirstName, userInfo.LastName)) { throw new Exception(Resource.ErrorIncorrectUserName); } CoreContext.UserManager.SaveUserInfo(newUserInfo); } /*var photoUrl = samlResponse.GetRemotePhotoUrl(); * if (!string.IsNullOrEmpty(photoUrl)) * { * var photoLoader = new UserPhotoLoader(); * photoLoader.SaveOrUpdatePhoto(photoUrl, userInfo.ID); * }*/ } finally { SecurityContext.Logout(); } return(newUserInfo); }
private void AddUser(SamlResponse samlResponse, UserInfo userInfo) { try { _log.DebugFormat("Adding or updating user in database, userId={0}", userInfo.ID); SecurityContext.AuthenticateMe(ASC.Core.Configuration.Constants.CoreSystem); if (!string.IsNullOrEmpty(userInfo.MobilePhone)) { userInfo.MobilePhone = SmsManager.GetPhoneValueDigits(userInfo.MobilePhone); } if (string.IsNullOrEmpty(userInfo.UserName)) { if (string.IsNullOrWhiteSpace(userInfo.FirstName)) { userInfo.FirstName = Resource.FirstName; } if (string.IsNullOrWhiteSpace(userInfo.LastName)) { userInfo.LastName = Resource.LastName; } if (TenantStatisticsProvider.GetUsersCount() < TenantExtra.GetTenantQuota().ActiveUsers) { userInfo = UserManagerWrapper.AddUser(userInfo, UserManagerWrapper.GeneratePassword(), true, false); } else { userInfo = UserManagerWrapper.AddUser(userInfo, UserManagerWrapper.GeneratePassword(), true, false, true); } } else { CoreContext.UserManager.SaveUserInfo(userInfo); } var photoUrl = samlResponse.GetRemotePhotoUrl(); if (!string.IsNullOrEmpty(photoUrl)) { var photoLoader = new UserPhotoLoader(); photoLoader.SaveOrUpdatePhoto(photoUrl, userInfo.ID); } } finally { SecurityContext.Logout(); } var cookiesKey = SecurityContext.AuthenticateMe(userInfo.ID); CookiesManager.SetCookies(CookiesType.AuthKey, cookiesKey); }
protected void Page_Load(object sender, EventArgs e) { AjaxPro.Utility.RegisterTypeForAjax(GetType()); Page.RegisterBodyScripts(ResolveUrl("~/usercontrols/management/maildomainsettings/js/maildomainsettings.js")); Page.RegisterStyleControl(VirtualPathUtility.ToAbsolute("~/usercontrols/management/maildomainsettings/css/maildomainsettings.less")); _currentTenant = CoreContext.TenantManager.GetCurrentTenant(); _studioTrustedDomainSettings = SettingsManager.Instance.LoadSettings <StudioTrustedDomainSettings>(TenantProvider.CurrentTenantID); _enableInviteUsers = TenantStatisticsProvider.GetUsersCount() < TenantExtra.GetTenantQuota().ActiveUsers; if (!_enableInviteUsers) { _studioTrustedDomainSettings.InviteUsersAsVisitors = true; } }
protected void Page_Load(object sender, EventArgs e) { Page .RegisterBodyScripts("~/UserControls/Management/TariffSettings/js/tariffusage.js", "~/js/asc/plugins/countries.js", "~/js/asc/plugins/phonecontroller.js") .RegisterStyle( "~/skins/default/phonecontroller.css", "~/UserControls/Management/TariffSettings/css/tariff.less", "~/UserControls/Management/TariffSettings/css/tariffusage.less") .RegisterClientScript(new CountriesResources()); CurrentRegion = RegionDefault; Regions.Add(CurrentRegion); UsersCount = TenantStatisticsProvider.GetUsersCount(); UsedSize = TenantStatisticsProvider.GetUsedSize(); CurrentTariff = TenantExtra.GetCurrentTariff(); CurrentQuota = TenantExtra.GetTenantQuota(); if (_quotaList == null || !_quotaList.Any()) { _quotaList = TenantExtra.GetTenantQuotas(); } else if (!CurrentQuota.Trial) { CurrentQuota = _quotaList.FirstOrDefault(q => q.Id == CurrentQuota.Id) ?? CurrentQuota; } _quotaList = _quotaList.OrderBy(r => r.ActiveUsers).ToList().Where(r => !r.Trial); QuotasYear = _quotaList.Where(r => r.Year).ToList(); MonthIsDisable = !CurrentQuota.Free && (CurrentQuota.Year || CurrentQuota.Year3) && CurrentTariff.State == TariffState.Paid; YearIsDisable = !CurrentQuota.Free && CurrentQuota.Year3 && CurrentTariff.State == TariffState.Paid; var minYearQuota = QuotasYear.FirstOrDefault(q => q.ActiveUsers >= UsersCount && q.MaxTotalSize >= UsedSize); MinActiveUser = minYearQuota != null ? minYearQuota.ActiveUsers : (QuotasYear.Count > 0 ? QuotasYear.Last().ActiveUsers : 0 + 1); HideBuyRecommendation = CurrentTariff.Autorenewal || TariffSettings.HideRecommendation; downgradeInfoContainer.Options.IsPopup = true; buyRecommendationContainer.Options.IsPopup = true; AjaxPro.Utility.RegisterTypeForAjax(GetType()); RegisterScript(); CurrencyCheck(); }
protected void Page_Load(object sender, EventArgs e) { Page.RegisterBodyScripts("~/js/uploader/ajaxupload.js"); Page.RegisterBodyScripts("~/usercontrols/management/tariffsettings/js/tariffstandalone.js"); Page.RegisterStyle("~/usercontrols/management/tariffsettings/css/tariff.less"); Page.RegisterStyle("~/usercontrols/management/tariffsettings/css/tariffstandalone.less"); UsersCount = TenantStatisticsProvider.GetUsersCount(); CurrentTariff = TenantExtra.GetCurrentTariff(); CurrentQuota = TenantExtra.GetTenantQuota(); TenantCount = CoreContext.TenantManager.GetTenants().Count(t => t.Status == TenantStatus.Active); Settings = AdditionalWhiteLabelSettings.Instance; Settings.LicenseAgreementsUrl = CommonLinkUtility.GetRegionalUrl(Settings.LicenseAgreementsUrl, CultureInfo.CurrentCulture.TwoLetterISOLanguageName); AjaxPro.Utility.RegisterTypeForAjax(GetType()); }
private static Web.Core.Files.DocumentService GetDocumentService() { int timeout; Int32.TryParse(WebConfigurationManager.AppSettings["files.docservice.timeout"], out timeout); var documentService = new Web.Core.Files.DocumentService( StudioKeySettings.GetKey(), StudioKeySettings.GetSKey(), TenantStatisticsProvider.GetUsersCount()); if (timeout > 0) { documentService.Timeout = timeout; } return(documentService); }
protected void Page_Load(object sender, EventArgs e) { var quota = TenantExtra.GetTenantQuota().ActiveUsers - TenantStatisticsProvider.GetUsersCount(); PeopleLimit = quota > 0 ? quota : 0; icon.Options.IsPopup = true; icon.Options.PopupContainerCssClass = "okcss popupContainerClass"; icon.Options.OnCancelButtonClick = "ImportUsersManager.HideInfoWindow('okcss');"; limitPanel.Options.IsPopup = true; limitPanel.Options.OnCancelButtonClick = "ImportUsersManager.HideImportUserLimitPanel();"; AjaxPro.Utility.RegisterTypeForAjax(GetType()); RegisterScript(); }
protected void Page_Load(object sender, EventArgs e) { Page .RegisterBodyScripts("~/UserControls/Management/TariffSettings/js/tariffcustom.js", "~/js/asc/plugins/countries.js", "~/js/asc/plugins/phonecontroller.js") .RegisterStyle( "~/skins/default/phonecontroller.css", "~/UserControls/Management/TariffSettings/css/tariff.less", "~/UserControls/Management/TariffSettings/css/tariffusage.less", "~/UserControls/Management/TariffSettings/css/tariffcustom.less") .RegisterClientScript(new CountriesResources()); CurrentRegion = RegionDefault; UsersCount = TenantStatisticsProvider.GetUsersCount(); UsedSize = TenantStatisticsProvider.GetUsedSize(); CurrentTariff = TenantExtra.GetCurrentTariff(); CurrentQuota = TenantExtra.GetTenantQuota(); if (_quotaList == null || !_quotaList.Any()) { _quotaList = TenantExtra.GetTenantQuotas(); } else if (!CurrentQuota.Trial) { CurrentQuota = _quotaList.FirstOrDefault(q => q.Id == CurrentQuota.Id) ?? CurrentQuota; } _quotaList = _quotaList.OrderBy(r => r.ActiveUsers).ToList().Where(r => !r.Trial); QuotasYear = _quotaList.Where(r => r.Year).ToList(); MonthIsDisable = !CurrentQuota.Free && (CurrentQuota.Year || CurrentQuota.Year3) && CurrentTariff.State == TariffState.Paid; YearIsDisable = !CurrentQuota.Free && CurrentQuota.Year3 && CurrentTariff.State == TariffState.Paid; var minYearQuota = QuotasYear.FirstOrDefault(q => q.ActiveUsers >= UsersCount && q.MaxTotalSize >= UsedSize); MinActiveUser = minYearQuota != null ? minYearQuota.ActiveUsers : (QuotasYear.Count > 0 ? QuotasYear.Last().ActiveUsers : 0 + 1); MonthPrice = Convert.ToInt32(ConfigurationManager.AppSettings["core.custom-mode.month-price"] ?? "290"); YearPrice = Convert.ToInt32(ConfigurationManager.AppSettings["core.custom-mode.year-price"] ?? "175"); AjaxPro.Utility.RegisterTypeForAjax(GetType()); CurrencyCheck(); }
protected void Page_Load(object sender, EventArgs e) { var quota = TenantExtra.GetTenantQuota(); PeopleLimit = Math.Min(quota.ActiveUsers - TenantStatisticsProvider.GetUsersCount(), 0); FreeTariff = (quota.Free || quota.NonProfit || quota.Trial) && !quota.Open; HelpLink = CommonLinkUtility.GetHelpLink(); icon.Options.IsPopup = true; icon.Options.PopupContainerCssClass = "okcss popupContainerClass"; icon.Options.OnCancelButtonClick = "ImportUsersManager.HideInfoWindow('okcss');"; limitPanel.Options.IsPopup = true; limitPanel.Options.OnCancelButtonClick = "ImportUsersManager.HideImportUserLimitPanel();"; AjaxPro.Utility.RegisterTypeForAjax(GetType()); RegisterScript(); }
public QuotaWrapper( Tenant tenant, CoreBaseSettings coreBaseSettings, CoreConfiguration configuration, TenantExtra tenantExtra, TenantStatisticsProvider tenantStatisticsProvider, AuthContext authContext, SettingsManager settingsManager, WebItemManager webItemManager, Constants constants) { TenantExtra = tenantExtra; TenantStatisticsProvider = tenantStatisticsProvider; WebItemManager = webItemManager; var quota = TenantExtra.GetTenantQuota(); var quotaRows = TenantStatisticsProvider.GetQuotaRows(tenant.TenantId).ToList(); StorageSize = (ulong)Math.Max(0, quota.MaxTotalSize); UsedSize = (ulong)Math.Max(0, quotaRows.Sum(r => r.Counter)); MaxUsersCount = quota.ActiveUsers; UsersCount = coreBaseSettings.Personal ? 1 : TenantStatisticsProvider.GetUsersCount(); MaxVisitors = coreBaseSettings.Standalone ? -1 : constants.CoefficientOfVisitors * quota.ActiveUsers; VisitorsCount = coreBaseSettings.Personal ? 0 : TenantStatisticsProvider.GetVisitorsCount(); StorageUsage = quotaRows .Select(x => new QuotaUsage { Path = x.Path.TrimStart('/').TrimEnd('/'), Size = x.Counter, }) .ToList(); if (coreBaseSettings.Personal && SetupInfo.IsVisibleSettings("PersonalMaxSpace")) { UserStorageSize = configuration.PersonalMaxSpace(settingsManager); var webItem = WebItemManager[WebItemManager.DocumentsProductID]; if (webItem.Context.SpaceUsageStatManager is IUserSpaceUsage spaceUsageManager) { UserUsedSize = spaceUsageManager.GetUserSpaceUsage(authContext.CurrentAccount.ID); } } MaxFileSize = Math.Min(AvailableSize, (ulong)quota.MaxFileSize); }
protected void Page_Load(object sender, EventArgs e) { Page .RegisterBodyScripts( "~/js/uploader/jquery.fileupload.js", "~/UserControls/Management/TariffSettings/js/tariffstandalone.js") .RegisterStyle("~/UserControls/Management/TariffSettings/css/tariff.less", "~/UserControls/Management/TariffSettings/css/tariffstandalone.less"); UsersCount = TenantStatisticsProvider.GetUsersCount(); CurrentTariff = TenantExtra.GetCurrentTariff(); CurrentQuota = TenantExtra.GetTenantQuota(); Settings = AdditionalWhiteLabelSettings.Instance; Settings.LicenseAgreementsUrl = CommonLinkUtility.GetRegionalUrl(Settings.LicenseAgreementsUrl, CultureInfo.CurrentCulture.TwoLetterISOLanguageName); Settings.FeedbackAndSupportUrl = CommonLinkUtility.GetRegionalUrl(Settings.FeedbackAndSupportUrl, CultureInfo.CurrentCulture.TwoLetterISOLanguageName); AjaxPro.Utility.RegisterTypeForAjax(GetType()); }
public IEnumerable <EmployeeWraperFull> UpdateUserStatus(EmployeeStatus status, IEnumerable <Guid> userIds) { SecurityContext.DemandPermissions(Core.Users.Constants.Action_EditUser); var users = userIds .Where(userId => !CoreContext.UserManager.IsSysytemUser(userId)) .Select(userId => CoreContext.UserManager.GetUsers(userId)) .ToList(); foreach (var user in users) { if (user.IsOwner() || user.IsMe()) { continue; } switch (status) { case EmployeeStatus.Active: if (user.Status == EmployeeStatus.Terminated) { if (TenantStatisticsProvider.GetUsersCount() < TenantExtra.GetTenantQuota().ActiveUsers || user.IsVisitor()) { user.Status = EmployeeStatus.Active; CoreContext.UserManager.SaveUserInfo(user); } } break; case EmployeeStatus.Terminated: user.Status = EmployeeStatus.Terminated; CoreContext.UserManager.SaveUserInfo(user); break; } } MessageService.Send(Request, MessageAction.UsersUpdatedStatus, users.Select(x => x.DisplayUserName(false))); return(users.Select(user => new EmployeeWraperFull(user)).ToSmartList()); }
protected void Page_Load(object sender, EventArgs e) { AjaxPro.Utility.RegisterTypeForAjax(GetType()); Page.RegisterBodyScripts("~/usercontrols/management/maildomainsettings/js/maildomainsettings.js"); Page.RegisterStyle("~/usercontrols/management/maildomainsettings/css/maildomainsettings.less"); _currentTenant = CoreContext.TenantManager.GetCurrentTenant(); _studioTrustedDomainSettings = SettingsManager.Instance.LoadSettings <StudioTrustedDomainSettings>(TenantProvider.CurrentTenantID); _enableInviteUsers = TenantStatisticsProvider.GetUsersCount() < TenantExtra.GetTenantQuota().ActiveUsers; if (!_enableInviteUsers) { _studioTrustedDomainSettings.InviteUsersAsVisitors = true; } var managementPage = Page as Studio.Management; _tenantAccessAnyone = managementPage != null ? managementPage.TenantAccess.Anyone : SettingsManager.Instance.LoadSettings <TenantAccessSettings>(TenantProvider.CurrentTenantID).Anyone; }
protected void Page_Load(object sender, EventArgs e) { var userInfo = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID); IsAdmin = userInfo.IsAdmin() || WebItemSecurity.IsProductAdministrator(WebItemManager.PeopleProductID, userInfo.ID); Actions = new AllowedActions(userInfo); var quota = TenantExtra.GetTenantQuota(); IsFreeTariff = quota.Free && !quota.Open; IsStandalone = CoreContext.Configuration.Standalone; DisplayPayments = TenantExtra.EnableTariffSettings && (!CoreContext.Configuration.Standalone || quota.ActiveUsers != LicenseReader.MaxUserCount); if (DisplayPayments) { int notifyCount; int.TryParse(ConfigurationManagerExtension.AppSettings["web.tariff-notify.user"] ?? "5", out notifyCount); DisplayPaymentsFirstUser = notifyCount > 0 && quota.ActiveUsers - TenantStatisticsProvider.GetUsersCount() < notifyCount; DisplayPaymentsFirstGuest = !IsStandalone && notifyCount > 0 && quota.ActiveUsers * Constants.CoefficientOfVisitors - TenantStatisticsProvider.GetVisitorsCount() < notifyCount; } var controlEmailChange = (UserEmailChange)LoadControl(UserEmailChange.Location); controlEmailChange.UserInfo = userInfo; controlEmailChange.RegisterStylesAndScripts = true; userEmailChange.Controls.Add(controlEmailChange); loaderHolder.Controls.Add(LoadControl(LoaderPage.Location)); userConfirmationDelete.Controls.Add(LoadControl(ConfirmationDeleteUser.Location)); if (Actions.AllowEdit) { userPwdChange.Controls.Add(LoadControl(PwdTool.Location)); } Title = HeaderStringHelper.GetPageTitle(PeopleResource.ProductName); HelpLink = CommonLinkUtility.GetHelpLink(); }
public IEnumerable <EmployeeWraperFull> UpdateUserType(EmployeeType type, IEnumerable <Guid> userIds) { var users = userIds .Where(userId => !CoreContext.UserManager.IsSystemUser(userId)) .Select(userId => CoreContext.UserManager.GetUsers(userId)) .ToList(); foreach (var user in users) { if (user.IsOwner() || user.IsAdmin() || user.IsMe() || user.GetListAdminModules().Any()) { continue; } switch (type) { case EmployeeType.User: if (user.IsVisitor()) { if (TenantStatisticsProvider.GetUsersCount() < TenantExtra.GetTenantQuota().ActiveUsers) { CoreContext.UserManager.RemoveUserFromGroup(user.ID, Core.Users.Constants.GroupVisitor.ID); WebItemSecurity.ClearCache(); } } break; case EmployeeType.Visitor: CoreContext.UserManager.AddUserIntoGroup(user.ID, Core.Users.Constants.GroupVisitor.ID); WebItemSecurity.ClearCache(); break; } } MessageService.Send(Request, MessageAction.UsersUpdatedType, users.Select(x => x.DisplayUserName(false))); return(users.Select(user => new EmployeeWraperFull(user)).ToSmartList()); }
private static void SetQuota(TenantQuota quota) { if (quota == null) { throw new ArgumentNullException("quota"); } if (TenantStatisticsProvider.GetUsersCount() > quota.ActiveUsers) { throw new Exception(string.Format(Resource.PortalAccessSettingsUserLimitException, quota.ActiveUsers)); } if (TenantStatisticsProvider.GetUsedSize() > quota.MaxTotalSize) { throw new Exception(string.Format(Resource.PortalAccessSettingsDiscSpaceLimitException, FileSizeComment.FilesSizeToString(quota.MaxTotalSize))); } CoreContext.PaymentManager.SetTariff(TenantProvider.CurrentTenantID, new Tariff { QuotaId = quota.Id, DueDate = DateTime.MaxValue }); }
public static string GenerateValidateKey(string documentRevisionId) { var docServiceConnector = new Web.Core.Files.DocumentService( StudioKeySettings.GetKey(), StudioKeySettings.GetSKey(), TenantStatisticsProvider.GetUsersCount()); string userIp = null; try { if (HttpContext.Current != null) { userIp = HttpContext.Current.Request.UserHostAddress; } } catch { userIp = string.Empty; } return(docServiceConnector.GenerateValidateKey(GenerateRevisionId(documentRevisionId), userIp)); }