コード例 #1
0
        protected override IEnumerable <KeyValuePair <string, object> > GetClientVariables(HttpContext context)
        {
            var curQuota = TenantExtra.GetTenantQuota();
            var tenant   = CoreContext.TenantManager.GetCurrentTenant();
            var helpLink = CommonLinkUtility.GetHelpLink();

            var result = new List <KeyValuePair <string, object> >(4)
            {
                RegisterObject(
                    new {
                    ApiPath         = SetupInfo.WebApiBaseUrl,
                    IsAuthenticated = SecurityContext.IsAuthenticated,
                    IsAdmin         = CoreContext.UserManager.IsUserInGroup(SecurityContext.CurrentAccount.ID, Constants.GroupAdmin.ID),
                    IsVisitor       = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsVisitor(),
                    //CurrentTenantId = tenant.TenantId,
                    CurrentTenantCreatedDate      = tenant.CreatedDateTime,
                    CurrentTenantVersion          = tenant.Version,
                    CurrentTenantUtcOffset        = tenant.TimeZone,
                    CurrentTenantUtcHoursOffset   = tenant.TimeZone.BaseUtcOffset.Hours,
                    CurrentTenantUtcMinutesOffset = tenant.TimeZone.BaseUtcOffset.Minutes,
                    TimezoneDisplayName           = tenant.TimeZone.DisplayName,
                    TimezoneOffsetMinutes         = tenant.TimeZone.GetUtcOffset(DateTime.UtcNow).TotalMinutes,
                    TenantIsPremium = curQuota.Trial ? "No" : "Yes",
                    TenantTariff    = curQuota.Id,
                    EmailRegExpr    = @"^(([^<>()[\]\\.,;:\s@\""]+(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$",
                    GroupSelector_MobileVersionGroup = new { Id = -1, Name = UserControlsCommonResource.LblSelect.HtmlEncode().ReplaceSingleQuote() },
                    GroupSelector_WithGroupEveryone  = new { Id = Constants.GroupEveryone.ID, Name = UserControlsCommonResource.Everyone.HtmlEncode().ReplaceSingleQuote() },
                    GroupSelector_WithGroupAdmin     = new { Id = Constants.GroupAdmin.ID, Name = UserControlsCommonResource.Admin.HtmlEncode().ReplaceSingleQuote() },
                    SetupInfoNotifyAddress           = SetupInfo.NotifyAddress,
                    SetupInfoTipsAddress             = SetupInfo.TipsAddress,
                    CKEDITOR_BASEPATH   = WebPath.GetPath("/usercontrols/common/ckeditor/"),
                    MaxImageFCKWidth    = ConfigurationManager.AppSettings["MaxImageFCKWidth"] ?? "620",
                    UserPhotoHandlerUrl = VirtualPathUtility.ToAbsolute("~/UserPhoto.ashx"),
                    ImageWebPath        = WebImageSupplier.GetImageFolderAbsoluteWebPath(),
                    UrlShareGooglePlus  = SetupInfo.ShareGooglePlusUrl,
                    UrlShareTwitter     = SetupInfo.ShareTwitterUrl,
                    UrlShareFacebook    = SetupInfo.ShareFacebookUrl,
                    LogoDarkUrl         = CommonLinkUtility.GetFullAbsolutePath(TenantLogoManager.GetLogoDark(true)),
                    HelpLink            = helpLink ?? ""
                })
            };

            if (CoreContext.Configuration.Personal)
            {
                result.Add(RegisterObject(new { CoreContext.Configuration.Personal }));
            }

            if (CoreContext.Configuration.Standalone)
            {
                result.Add(RegisterObject(new { CoreContext.Configuration.Standalone }));
            }

            if (!string.IsNullOrEmpty(helpLink))
            {
                result.Add(RegisterObject(new { FilterHelpCenterLink = helpLink.TrimEnd('/') + "/tipstricks/using-search.aspx" }));
            }

            return(result);
        }
コード例 #2
0
        protected string GetAbsoluteCompanyTopLogoPath()
        {
            var general = !TenantLogoManager.IsRetina(Request);

            return
                (CoreContext.Configuration.Personal
                    ? WebImageSupplier.GetAbsoluteWebPath("personal_logo/logo_personal_auth.png")
                    : TenantLogoManager.WhiteLabelEnabled
                          ? TenantLogoManager.GetLogoDark(general)
                          : TenantWhiteLabelSettings.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.Dark, general));
        }
コード例 #3
0
        private List <ITagValue> CreateArgs(string region, string url)
        {
            var args = new List <ITagValue>()
            {
                new TagValue(Tags.RegionName, TransferResourceHelper.GetRegionDescription(region)),
                new TagValue(Tags.PortalUrl, url)
            };

            if (!string.IsNullOrEmpty(url))
            {
                args.Add(new TagValue(CommonTags.VirtualRootPath, url));
                args.Add(new TagValue(CommonTags.ProfileUrl, url + CommonLinkUtility.GetMyStaff()));
                args.Add(new TagValue(CommonTags.LetterLogo, TenantLogoManager.GetLogoDark(true)));
            }
            return(args);
        }
コード例 #4
0
        private static void AddLetterLogo(NotifyRequest request)
        {
            var logoUrl = CommonLinkUtility.GetFullAbsolutePath(TenantLogoManager.GetLogoDark(true));

            if (CoreContext.Configuration.Standalone)
            {
                var attachment = ConvertImageUrlToAttachment(logoUrl);

                if (attachment != null)
                {
                    request.Arguments.Add(new TagValue(Constants.LetterLogo, "cid:" + attachment.ContentId));
                    request.Arguments.Add(new TagValue(Constants.EmbeddedAttachments, new[] { attachment }));
                    return;
                }
            }

            request.Arguments.Add(new TagValue(Constants.LetterLogo, logoUrl));
        }
コード例 #5
0
        private static void AddLetterLogo(NotifyRequest request)
        {
            if (TenantExtra.Enterprise || CoreContext.Configuration.CustomMode)
            {
                try
                {
                    var logoData = TenantLogoManager.GetMailLogoDataFromCache();

                    if (logoData == null)
                    {
                        var logoStream = TenantLogoManager.GetWhitelabelMailLogo();
                        logoData = ReadStreamToByteArray(logoStream) ?? GetDefaultMailLogo();

                        if (logoData != null)
                        {
                            TenantLogoManager.InsertMailLogoDataToCache(logoData);
                        }
                    }

                    if (logoData != null)
                    {
                        var attachment = new NotifyMessageAttachment
                        {
                            FileName  = "logo.png",
                            Content   = ByteString.CopyFrom(logoData),
                            ContentId = MimeUtils.GenerateMessageId()
                        };

                        request.Arguments.Add(new TagValue(CommonTags.LetterLogo, "cid:" + attachment.ContentId));
                        request.Arguments.Add(new TagValue(CommonTags.EmbeddedAttachments, new[] { attachment }));
                        return;
                    }
                }
                catch (Exception error)
                {
                    LogManager.GetLogger("ASC").Error(error);
                }
            }

            var logoUrl = CommonLinkUtility.GetFullAbsolutePath(TenantLogoManager.GetLogoDark(true));

            request.Arguments.Add(new TagValue(CommonTags.LetterLogo, logoUrl));
        }
コード例 #6
0
        private static XsltArgumentList GetXslParameters(this Report report, ReportViewType view, int templateID)
        {
            var parameters = new XsltArgumentList();
            var columns    = report.GetColumns(view, templateID);
            var logo       = string.IsNullOrEmpty(SetupInfo.MainLogoMailTmplURL) ? CommonLinkUtility.GetFullAbsolutePath(TenantLogoManager.GetLogoDark(true)) : SetupInfo.MainLogoMailTmplURL;
            var logoText   = TenantWhiteLabelSettings.Load().LogoText;

            for (var i = 0; i < columns.Count; i++)
            {
                parameters.AddParam("p" + i, string.Empty, columns[i]);
            }

            parameters.AddParam("p" + columns.Count, string.Empty, Global.ReportCsvDelimiter.Value);
            parameters.AddParam("logo", string.Empty, logo);
            parameters.AddParam("logoText", string.Empty, logoText);

            return(parameters);
        }
コード例 #7
0
        private static void BeforeTransferRequest(NotifyEngine sender, NotifyRequest request)
        {
            var aid   = Guid.Empty;
            var aname = string.Empty;

            if (SecurityContext.IsAuthenticated)
            {
                aid = SecurityContext.CurrentAccount.ID;
                if (CoreContext.UserManager.UserExists(aid))
                {
                    aname = CoreContext.UserManager.GetUsers(aid).DisplayUserName(false)
                            .Replace(">", "&#62")
                            .Replace("<", "&#60");
                }
            }

            IProduct product;
            IModule  module;

            CommonLinkUtility.GetLocationByRequest(out product, out module);
            if (product == null && CallContext.GetData("asc.web.product_id") != null)
            {
                product = WebItemManager.Instance[(Guid)CallContext.GetData("asc.web.product_id")] as IProduct;
            }

            var logoText   = TenantLogoManager.GetLogoText();
            var logoTextTM = String.Equals(logoText, TenantWhiteLabelSettings.DefaultLogo, StringComparison.Ordinal)
                ? String.Format("{0}™", logoText.ToUpper())
                : logoText;

            request.Arguments.Add(new TagValue(CommonTags.AuthorID, aid));
            request.Arguments.Add(new TagValue(CommonTags.AuthorName, aname));
            request.Arguments.Add(new TagValue(CommonTags.AuthorUrl, CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(aid))));
            request.Arguments.Add(new TagValue(CommonTags.VirtualRootPath, CommonLinkUtility.GetFullAbsolutePath("~").TrimEnd('/')));
            request.Arguments.Add(new TagValue(CommonTags.ProductID, product != null ? product.ID : Guid.Empty));
            request.Arguments.Add(new TagValue(CommonTags.ModuleID, module != null ? module.ID : Guid.Empty));
            request.Arguments.Add(new TagValue(CommonTags.ProductUrl, CommonLinkUtility.GetFullAbsolutePath(product != null ? product.StartURL : "~")));
            request.Arguments.Add(new TagValue(CommonTags.DateTime, TenantUtil.DateTimeNow()));
            request.Arguments.Add(new TagValue(CommonTags.Helper, new PatternHelper()));
            request.Arguments.Add(new TagValue(CommonTags.RecipientID, Context.SYS_RECIPIENT_ID));
            request.Arguments.Add(new TagValue(CommonTags.RecipientSubscriptionConfigURL, CommonLinkUtility.GetMyStaff()));
            request.Arguments.Add(new TagValue("Partner", GetPartnerInfo()));
            request.Arguments.Add(new TagValue(Constants.LetterLogo, CommonLinkUtility.GetFullAbsolutePath(TenantLogoManager.GetLogoDark(true))));
            request.Arguments.Add(new TagValue(Constants.LetterLogoText, logoText));
            request.Arguments.Add(new TagValue(Constants.LetterLogoTextTM, logoTextTM));
            request.Arguments.Add(new TagValue(Constants.MailWhiteLabelSettings, MailWhiteLabelSettings.Instance));

            if (!request.Arguments.Any(x => CommonTags.SendFrom.Equals(x.Tag)))
            {
                request.Arguments.Add(new TagValue(CommonTags.SendFrom, CoreContext.TenantManager.GetCurrentTenant().Name));
            }
        }