public string GetBarPromotions(string domain, string page, bool desktop)
        {
            try
            {
                var showPromotions = PromotionsSettings.Load().Show;

                if (!showPromotions)
                {
                    return(null);
                }

                var tenant = CoreContext.TenantManager.GetCurrentTenant();
                var user   = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);

                var uriBuilder = new UriBuilder(SetupInfo.NotifyAddress + "promotions/Get");

                var query = HttpUtility.ParseQueryString(uriBuilder.Query);

                if (string.IsNullOrEmpty(domain))
                {
                    domain = Request.UrlReferrer != null ? Request.UrlReferrer.Host : string.Empty;
                }

                if (string.IsNullOrEmpty(page))
                {
                    page = Request.UrlReferrer != null ? Request.UrlReferrer.PathAndQuery : string.Empty;
                }

                query["userId"]      = user.ID.ToString();
                query["language"]    = Thread.CurrentThread.CurrentCulture.Name.ToLowerInvariant();
                query["version"]     = tenant.Version.ToString(CultureInfo.InvariantCulture);
                query["tariff"]      = TenantExtra.GetTenantQuota().Id.ToString(CultureInfo.InvariantCulture);
                query["admin"]       = user.IsAdmin().ToString();
                query["userCreated"] = user.CreateDate.ToString(CultureInfo.InvariantCulture);
                query["promo"]       = true.ToString();
                query["domain"]      = domain;
                query["page"]        = page;
                query["agent"]       = Request.UserAgent ?? Request.Headers["User-Agent"];
                query["desktop"]     = desktop.ToString();

                uriBuilder.Query = query.ToString();

                using (var client = new WebClient())
                {
                    client.Encoding = System.Text.Encoding.UTF8;
                    return(client.DownloadString(uriBuilder.Uri));
                }
            }
            catch (Exception ex)
            {
                LogManager.GetLogger("ASC.Web").Error("GetBarTips", ex);
                return(null);
            }
        }
Пример #2
0
        private void InitStudioSettingsInlineScript()
        {
            var showPromotions = PromotionsSettings.Load().Show;
            var showTips       = TipsSettings.LoadForCurrentUser().Show;

            var script = new StringBuilder();

            script.AppendFormat("window.ASC.Resources.Master.ShowPromotions={0};", showPromotions.ToString().ToLowerInvariant());
            script.AppendFormat("window.ASC.Resources.Master.ShowTips={0};", showTips.ToString().ToLowerInvariant());

            RegisterInlineScript(script.ToString(), true, false);
        }
Пример #3
0
        private void InitStudioSettingsInlineScript()
        {
            var paid           = !TenantStatisticsProvider.IsNotPaid();
            var showPromotions = paid && PromotionsSettings.Load().Show;
            var showTips       = !Request.DesktopApp() && paid && TipsSettings.LoadForCurrentUser().Show;

            var script = new StringBuilder();

            script.AppendFormat("window.ASC.Resources.Master.ShowPromotions={0};", showPromotions.ToString().ToLowerInvariant());
            script.AppendFormat("window.ASC.Resources.Master.ShowTips={0};", showTips.ToString().ToLowerInvariant());

            RegisterInlineScript(script.ToString(), true, false);
        }