コード例 #1
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (EmployeeInfo != null)
            {
                var isRetina = TenantLogoManager.IsRetina(HttpContext.Current.Request);

                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("<div {1} style=\"width: {0}px;overflow:hidden;\"><table cellpadding=\"0\" border=\"0\" cellspacing=\"0\" width=\"100%\" >", Width.Value,
                                EmployeeInfo.ActivationStatus == EmployeeActivationStatus.Pending ? "class=\"pending\"" : "");

                sb.Append("<tr valign='top'>");
                sb.Append("<td align=\"left\" style=\"width:56px; padding-right:10px;\">");
                sb.AppendFormat("<a class=\"borderBase\" {1} href=\"{0}\">", EmployeeUrl, "style=\"position:relative;  text-decoration:none; display:block; height:48px; width:48px;\"");
                sb.Append("<img align=\"center\" alt=\"\" style='display:block;margin:0; position:relative;width:48px;' border=0 src=\"" + (isRetina ? EmployeeInfo.GetBigPhotoURL() : EmployeeInfo.GetMediumPhotoURL()) + "\"/>");
                if (EmployeeInfo.ActivationStatus == EmployeeActivationStatus.Pending)
                {
                    sb.Append("<div class=\"pendingInfo borderBase tintMedium\"><div>" + Resource.PendingTitle + "</div></div>");
                }
                sb.Append("</a>");
                sb.Append("</td>");

                sb.Append("<td>");
                if (!EmployeeInfo.ID.Equals(ASC.Core.Users.Constants.LostUser.ID))
                {
                    sb.Append("<div>");
                    sb.AppendFormat("<a class=\"link header-base middle bold\" data-id=\"{2}\" href=\"{0}\" title=\"{1}\">{1}</a>", EmployeeUrl, EmployeeInfo.DisplayUserName(), EmployeeInfo.ID);
                    sb.Append("</div>");

                    //department
                    sb.Append("<div style=\"padding-top: 6px;\">");
                    if (EmployeeInfo.Status != EmployeeStatus.Terminated)
                    {
                        var removecoma = false;
                        foreach (var g in CoreContext.UserManager.GetUserGroups(EmployeeInfo.ID))
                        {
                            sb.AppendFormat("<a class=\"link\" href=\"{0}\">", CommonLinkUtility.GetDepartment(g.ID));
                            sb.Append(HttpUtility.HtmlEncode(g.Name));
                            sb.Append("</a>, ");
                            removecoma = true;
                        }
                        if (removecoma)
                        {
                            sb.Remove(sb.Length - 2, 2);
                        }
                    }
                    sb.Append("&nbsp;</div>");

                    sb.Append("<div style=\"padding-top: 6px;\">");
                    sb.Append(HttpUtility.HtmlEncode(EmployeeInfo.Title) ?? "");
                    sb.Append("&nbsp;</div>");
                }

                sb.Append("</td>");
                sb.Append("</tr>");
                sb.Append("</table></div>");
                writer.Write(sb.ToString());
            }

            base.Render(writer);
        }
コード例 #2
0
 public void Deconstruct(out TenantManager tenantManager,
                         out WebItemSecurity webItemSecurity,
                         out UserManager userManager,
                         out IOptionsMonitor <ILog> optionsMonitor,
                         out TenantExtra tenantExtra,
                         out WebItemManagerSecurity webItemManagerSecurity,
                         out WebItemManager webItemManager,
                         out IConfiguration configuration,
                         out TenantLogoManager tenantLogoManager,
                         out AdditionalWhiteLabelSettingsHelper additionalWhiteLabelSettingsHelper,
                         out TenantUtil tenantUtil,
                         out CoreBaseSettings coreBaseSettings,
                         out CommonLinkUtility commonLinkUtility,
                         out SettingsManager settingsManager,
                         out StudioNotifyHelper studioNotifyHelper)
 {
     tenantManager                      = TenantManager;
     webItemSecurity                    = WebItemSecurity;
     userManager                        = UserManager;
     optionsMonitor                     = Options;
     tenantExtra                        = TenantExtra;
     webItemManagerSecurity             = WebItemManagerSecurity;
     webItemManager                     = WebItemManager;
     configuration                      = Configuration;
     tenantLogoManager                  = TenantLogoManager;
     additionalWhiteLabelSettingsHelper = AdditionalWhiteLabelSettingsHelper;
     tenantUtil         = TenantUtil;
     coreBaseSettings   = CoreBaseSettings;
     commonLinkUtility  = CommonLinkUtility;
     settingsManager    = SettingsManager;
     studioNotifyHelper = StudioNotifyHelper;
 }
コード例 #3
0
 public NotifyConfigurationScope(TenantManager tenantManager,
                                 WebItemSecurity webItemSecurity,
                                 UserManager userManager,
                                 IOptionsMonitor <ILog> options,
                                 TenantExtra tenantExtra,
                                 WebItemManagerSecurity webItemManagerSecurity,
                                 WebItemManager webItemManager,
                                 IConfiguration configuration,
                                 TenantLogoManager tenantLogoManager,
                                 AdditionalWhiteLabelSettingsHelper additionalWhiteLabelSettingsHelper,
                                 TenantUtil tenantUtil,
                                 CoreBaseSettings coreBaseSettings,
                                 CommonLinkUtility commonLinkUtility,
                                 SettingsManager settingsManager,
                                 StudioNotifyHelper studioNotifyHelper
                                 )
 {
     TenantManager                      = tenantManager;
     WebItemSecurity                    = webItemSecurity;
     UserManager                        = userManager;
     Options                            = options;
     TenantExtra                        = tenantExtra;
     WebItemManagerSecurity             = webItemManagerSecurity;
     WebItemManager                     = webItemManager;
     Configuration                      = configuration;
     TenantLogoManager                  = tenantLogoManager;
     AdditionalWhiteLabelSettingsHelper = additionalWhiteLabelSettingsHelper;
     TenantUtil                         = tenantUtil;
     CoreBaseSettings                   = coreBaseSettings;
     CommonLinkUtility                  = commonLinkUtility;
     SettingsManager                    = settingsManager;
     StudioNotifyHelper                 = studioNotifyHelper;
 }
コード例 #4
0
        public object AddAdmin(Guid id)
        {
            var isRetina = TenantLogoManager.IsRetina(HttpContext.Current.Request);

            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

            var user = CoreContext.UserManager.GetUsers(id);

            if (user.IsVisitor())
            {
                throw new System.Security.SecurityException("Collaborator can not be an administrator");
            }

            WebItemSecurity.SetProductAdministrator(Guid.Empty, id, true);

            MessageService.Send(HttpContext.Current.Request, MessageAction.AdministratorAdded, MessageTarget.Create(user.ID), user.DisplayUserName(false));

            InitLdapRights();

            return(new
            {
                id = user.ID,
                smallFotoUrl = user.GetSmallPhotoURL(),
                bigFotoUrl = isRetina ? user.GetBigPhotoURL() : "",
                displayName = user.DisplayUserName(),
                title = user.Title.HtmlEncode(),
                userUrl = CommonLinkUtility.GetUserProfile(user.ID),
                accessList = GetAccessList(user.ID, true)
            });
        }
コード例 #5
0
ファイル: Auth.aspx.cs プロジェクト: ztcyun/CommunityServer
        protected void Page_Load(object sender, EventArgs e)
        {
            TenantName = CoreContext.TenantManager.GetCurrentTenant().Name;
            Page.Title = TenantName;

            Master.DisabledSidePanel = true;
            if (Request.DesktopApp())
            {
                Master.DisabledTopStudioPanel = true;
            }

            withHelpBlock = false;
            if (CoreContext.Configuration.Personal)
            {
                Master.DisabledLayoutMedia    = true;
                Master.TopStudioPanel.TopLogo = TenantLogoManager.IsRetina(Request)
                                                        ? WebImageSupplier.GetAbsoluteWebPath("personal_logo/[email protected]")
                                                        : WebImageSupplier.GetAbsoluteWebPath("personal_logo/logo_personal_auth.png");
                AutorizeDocuments.Controls.Add(CoreContext.Configuration.CustomMode
                                                   ? LoadControl(AuthorizeDocs.LocationCustomMode)
                                                   : LoadControl(AuthorizeDocs.Location));
            }
            else
            {
                var authControl = (Authorize)LoadControl(Authorize.Location);
                authControl.IsLogout = IsLogout;
                AuthorizeHolder.Controls.Add(authControl);

                CommunitationsHolder.Controls.Add(LoadControl(AuthCommunications.Location));
                withHelpBlock = true;
            }
        }
コード例 #6
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);
        }
コード例 #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 = TenantWhiteLabelSettings.DefaultLogoText;

            if ((TenantExtra.Enterprise || TenantExtra.Hosted || (CoreContext.Configuration.Personal && CoreContext.Configuration.CustomMode)) && !MailWhiteLabelSettings.Instance.IsDefault)
            {
                logoText = TenantLogoManager.GetLogoText();
            }

            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(CommonTags.HelpLink, CommonLinkUtility.GetHelpLink(false)));
            request.Arguments.Add(new TagValue(Constants.LetterLogoText, logoText));
            request.Arguments.Add(new TagValue(Constants.LetterLogoTextTM, logoText));
            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));
            }

            AddLetterLogo(request);
        }
コード例 #8
0
 public TenantLogoHelper(
     TenantLogoManager tenantLogoManager,
     SettingsManager settingsManager,
     TenantWhiteLabelSettingsHelper tenantWhiteLabelSettingsHelper,
     TenantInfoSettingsHelper tenantInfoSettingsHelper)
 {
     TenantLogoManager = tenantLogoManager;
     SettingsManager   = settingsManager;
     TenantWhiteLabelSettingsHelper = tenantWhiteLabelSettingsHelper;
     TenantInfoSettingsHelper       = tenantInfoSettingsHelper;
 }
コード例 #9
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));
        }
コード例 #10
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);
        }
コード例 #11
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));
        }
コード例 #12
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));
        }
コード例 #13
0
        private void PageLoad()
        {
            var editPossible = !RequestEmbedded;
            var isExtenral   = false;

            File file;
            var  fileUri = string.Empty;

            try
            {
                if (string.IsNullOrEmpty(RequestFileUrl))
                {
                    var app = ThirdPartySelector.GetAppByFileId(RequestFileId);
                    if (app == null)
                    {
                        file = DocumentServiceHelper.GetParams(RequestFileId, RequestVersion, RequestShareLinkKey, editPossible, !RequestView, true, out _configuration);
                        if (_valideShareLink)
                        {
                            _configuration.Document.SharedLinkKey += RequestShareLinkKey;
                            _configuration.Document.Info.Favorite  = null;

                            if (CoreContext.Configuration.Personal && !SecurityContext.IsAuthenticated)
                            {
                                var user    = CoreContext.UserManager.GetUsers(file.CreateBy);
                                var culture = CultureInfo.GetCultureInfo(user.CultureName);
                                Thread.CurrentThread.CurrentCulture   = culture;
                                Thread.CurrentThread.CurrentUICulture = culture;
                            }
                        }
                    }
                    else
                    {
                        isExtenral = true;

                        bool editable;
                        _thirdPartyApp = true;
                        file           = app.GetFile(RequestFileId, out editable);
                        file           = DocumentServiceHelper.GetParams(file, true, editPossible ? FileShare.ReadWrite : FileShare.Read, false, editable, editable, editable, true, out _configuration);

                        _configuration.Document.Url = app.GetFileStreamUrl(file);
                        _configuration.EditorConfig.Customization.GobackUrl = string.Empty;
                        _configuration.Document.Info.Favorite = null;
                    }
                }
                else
                {
                    isExtenral = true;

                    fileUri = RequestFileUrl;
                    var fileTitle = Request[FilesLinkUtility.FileTitle];
                    if (string.IsNullOrEmpty(fileTitle))
                    {
                        fileTitle = Path.GetFileName(HttpUtility.UrlDecode(fileUri)) ?? "";
                    }

                    file = new File
                    {
                        ID    = RequestFileUrl,
                        Title = Global.ReplaceInvalidCharsAndTruncate(fileTitle)
                    };

                    file = DocumentServiceHelper.GetParams(file, true, FileShare.Read, false, false, false, false, false, out _configuration);
                    _configuration.Document.Permissions.Edit          = editPossible && !CoreContext.Configuration.Standalone;
                    _configuration.Document.Permissions.Rename        = false;
                    _configuration.Document.Permissions.Review        = false;
                    _configuration.Document.Permissions.FillForms     = false;
                    _configuration.Document.Permissions.ChangeHistory = false;
                    _configuration.Document.Permissions.ModifyFilter  = false;
                    _editByUrl = true;

                    _configuration.Document.Url           = fileUri;
                    _configuration.Document.Info.Favorite = null;
                }
                ErrorMessage = _configuration.ErrorMessage;
            }
            catch (Exception ex)
            {
                Global.Logger.Warn("DocEditor", ex);
                ErrorMessage = ex.Message;
                return;
            }

            var        userAgent      = Request.UserAgent.ToString().ToLower();
            HttpCookie deeplinkCookie = Request.Cookies.Get("deeplink");
            var        deepLink       = ConfigurationManagerExtension.AppSettings["deeplink.documents.url"];

            if (!_valideShareLink &&
                deepLink != null && MobileDetector.IsMobile &&
                ((!userAgent.Contains("version/") && userAgent.Contains("android")) || !userAgent.Contains("android")) &&       //check webkit
                ((Request[DeepLinking.WithoutDeeplinkRedirect] == null && deeplinkCookie == null) ||
                 Request[DeepLinking.WithoutDeeplinkRedirect] == null && deeplinkCookie != null && deeplinkCookie.Value == "app"))
            {
                var          currentUser  = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
                DeepLinkData deepLinkData = new DeepLinkData
                {
                    Email  = currentUser.Email,
                    Portal = CoreContext.TenantManager.GetCurrentTenant().TenantDomain,
                    File   = new DeepLinkDataFile
                    {
                        Id        = file.ID.ToString(),
                        Title     = file.Title,
                        Extension = file.ConvertedExtension
                    },
                    Folder = new DeepLinkDataFolder
                    {
                        Id             = file.FolderID.ToString(),
                        ParentId       = file.RootFolderId.ToString(),
                        RootFolderType = (int)file.RootFolderType
                    },
                    OriginalUrl = Request.GetUrlRewriter().ToString()
                };

                var    jsonDeeplinkData   = JsonConvert.SerializeObject(deepLinkData);
                string base64DeeplinkData = Convert.ToBase64String(Encoding.UTF8.GetBytes(jsonDeeplinkData));

                Response.Redirect("~/DeepLink.aspx?data=" + HttpUtility.UrlEncode(base64DeeplinkData));
            }


            if (_configuration.EditorConfig.ModeWrite && FileConverter.MustConvert(file))
            {
                try
                {
                    file = FileConverter.ExecSync(file, RequestShareLinkKey);
                }
                catch (Exception ex)
                {
                    _configuration = null;
                    Global.Logger.Error("DocEditor", ex);
                    ErrorMessage = ex.Message;
                    return;
                }

                var comment = "#message/" + HttpUtility.UrlEncode(string.Format(FilesCommonResource.ConvertForEdit, file.Title));

                Response.Redirect(FilesLinkUtility.GetFileWebEditorUrl(file.ID) + comment);
                return;
            }

            var fileSecurity = Global.GetFilesSecurity();

            if (_configuration.EditorConfig.ModeWrite &&
                FileUtility.CanWebRestrictedEditing(file.Title) &&
                fileSecurity.CanFillForms(file) &&
                !fileSecurity.CanEdit(file))
            {
                if (!file.IsFillFormDraft)
                {
                    FileMarker.RemoveMarkAsNew(file);

                    Folder folderIfNew;
                    try
                    {
                        file = EntryManager.GetFillFormDraft(file, out folderIfNew);
                    }
                    catch (Exception ex)
                    {
                        _configuration = null;
                        Global.Logger.Error("DocEditor", ex);
                        ErrorMessage = ex.Message;
                        return;
                    }

                    var comment = folderIfNew == null
                        ? string.Empty
                        : "#message/" + HttpUtility.UrlEncode(string.Format(FilesCommonResource.MessageFillFormDraftCreated, folderIfNew.Title));

                    Response.Redirect(FilesLinkUtility.GetFileWebEditorUrl(file.ID) + comment);
                    return;
                }
                else if (!EntryManager.CheckFillFormDraft(file))
                {
                    var comment = "#message/" + HttpUtility.UrlEncode(FilesCommonResource.MessageFillFormDraftDiscard);

                    Response.Redirect(FilesLinkUtility.GetFileWebEditorUrl(file.ID) + comment);
                    return;
                }
            }

            Title = file.Title + GetPageTitlePostfix();

            if (_configuration.EditorConfig.Customization.Goback == null || string.IsNullOrEmpty(_configuration.EditorConfig.Customization.Goback.Url))
            {
                _configuration.EditorConfig.Customization.GobackUrl = Request[FilesLinkUtility.FolderUrl] ?? "";
            }

            _configuration.EditorConfig.Customization.IsRetina = TenantLogoManager.IsRetina(Request);

            if (RequestEmbedded)
            {
                _configuration.Type = Services.DocumentService.Configuration.EditorType.Embedded;

                _configuration.EditorConfig.Embedded.ShareLinkParam = string.IsNullOrEmpty(RequestShareLinkKey) ? string.Empty : "&" + FilesLinkUtility.DocShareKey + "=" + RequestShareLinkKey;
            }
            else
            {
                _configuration.Type = IsMobile ? Services.DocumentService.Configuration.EditorType.Mobile : Services.DocumentService.Configuration.EditorType.Desktop;

                if (FileSharing.CanSetAccess(file) &&
                    !(file.Encrypted &&
                      (!Request.DesktopApp() ||
                       CoreContext.Configuration.Personal)))
                {
                    _configuration.EditorConfig.SharingSettingsUrl = CommonLinkUtility.GetFullAbsolutePath(
                        Share.Location
                        + "?" + FilesLinkUtility.FileId + "=" + HttpUtility.UrlEncode(file.ID.ToString())
                        + (Request.DesktopApp() ? "&desktop=true" : string.Empty));
                }

                if (file.RootFolderType == FolderType.Privacy)
                {
                    if (!PrivacyRoomSettings.Enabled)
                    {
                        _configuration = null;
                        ErrorMessage   = FilesCommonResource.ErrorMassage_FileNotFound;
                        return;
                    }
                    else
                    {
                        if (Request.DesktopApp())
                        {
                            var keyPair = EncryptionKeyPair.GetKeyPair();
                            if (keyPair != null)
                            {
                                _configuration.EditorConfig.EncryptionKeys = new Services.DocumentService.Configuration.EditorConfiguration.EncryptionKeysConfig
                                {
                                    PrivateKeyEnc = keyPair.PrivateKeyEnc,
                                    PublicKey     = keyPair.PublicKey,
                                };
                            }
                        }
                    }
                }
            }

            if (!isExtenral)
            {
                _docKeyForTrack = DocumentServiceHelper.GetDocKey(file.ID, -1, DateTime.MinValue);

                FileMarker.RemoveMarkAsNew(file);
                if (!file.Encrypted && !file.ProviderEntry)
                {
                    EntryManager.MarkAsRecent(file);
                }

                if (RequestView)
                {
                    FilesMessageService.Send(file, MessageInitiator.DocsService, MessageAction.FileReaded, file.Title);
                }
                else
                {
                    FilesMessageService.Send(file, MessageInitiator.DocsService, MessageAction.FileOpenedForChange, file.Title);
                }
            }

            if (SecurityContext.IsAuthenticated)
            {
                var saveAsUrl = SaveAs.GetUrl;
                using (var folderDao = Global.DaoFactory.GetFolderDao())
                {
                    var folder = folderDao.GetFolder(file.FolderID);
                    if (folder != null && Global.GetFilesSecurity().CanCreate(folder))
                    {
                        saveAsUrl = SaveAs.GetUrlToFolder(file.FolderID);
                    }
                }

                _configuration.EditorConfig.SaveAsUrl = CommonLinkUtility.GetFullAbsolutePath(saveAsUrl);
            }

            if (_configuration.EditorConfig.ModeWrite)
            {
                _tabId = FileTracker.Add(file.ID);

                Global.SocketManager.FilesChangeEditors(file.ID);

                if (SecurityContext.IsAuthenticated)
                {
                    _configuration.EditorConfig.FileChoiceUrl = CommonLinkUtility.GetFullAbsolutePath(FileChoice.GetUrlForEditor);
                }
            }
            else
            {
                _linkToEdit = _editByUrl
                                  ? CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.GetFileWebEditorExternalUrl(fileUri, file.Title))
                                  : CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.GetFileWebEditorUrl(file.ID));
                if (Request.DesktopApp())
                {
                    _linkToEdit += "&desktop=true";
                }

                if (FileConverter.MustConvert(_configuration.Document.Info.File))
                {
                    _editByUrl = true;
                }
            }

            var actionAnchor = Request[FilesLinkUtility.Anchor];

            if (!string.IsNullOrEmpty(actionAnchor))
            {
                _configuration.EditorConfig.ActionLinkString = actionAnchor;
            }
        }
コード例 #14
0
        private void PageLoad()
        {
            var editPossible = !RequestEmbedded;
            var isExtenral   = false;

            File file;
            var  fileUri = string.Empty;

            try
            {
                if (string.IsNullOrEmpty(RequestFileUrl))
                {
                    var app = ThirdPartySelector.GetAppByFileId(RequestFileId);
                    if (app == null)
                    {
                        var ver = string.IsNullOrEmpty(Request[FilesLinkUtility.Version]) ? -1 : Convert.ToInt32(Request[FilesLinkUtility.Version]);
                        file = DocumentServiceHelper.GetParams(RequestFileId, ver, RequestShareLinkKey, editPossible, !RequestView, true, out _configuration);
                    }
                    else
                    {
                        isExtenral = true;

                        bool editable;
                        _thirdPartyApp = true;
                        file           = app.GetFile(RequestFileId, out editable);
                        file           = DocumentServiceHelper.GetParams(file, true, editPossible ? FileShare.ReadWrite : FileShare.Read, false, editable, editable, editable, true, out _configuration);

                        _configuration.Document.Url = app.GetFileStreamUrl(file);
                        _configuration.EditorConfig.Customization.GobackUrl = string.Empty;
                    }
                }
                else
                {
                    isExtenral = true;

                    fileUri = RequestFileUrl;
                    var fileTitle = Request[FilesLinkUtility.FileTitle];
                    if (string.IsNullOrEmpty(fileTitle))
                    {
                        fileTitle = Path.GetFileName(HttpUtility.UrlDecode(fileUri)) ?? "";
                    }

                    if (CoreContext.Configuration.Standalone)
                    {
                        try
                        {
                            var webRequest = (HttpWebRequest)WebRequest.Create(RequestFileUrl);

                            // hack. http://ubuntuforums.org/showthread.php?t=1841740
                            if (WorkContext.IsMono)
                            {
                                ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
                            }

                            using (var response = webRequest.GetResponse())
                                using (var responseStream = new ResponseStream(response))
                                {
                                    var externalFileKey = DocumentServiceConnector.GenerateRevisionId(RequestFileUrl);
                                    fileUri = DocumentServiceConnector.GetExternalUri(responseStream, MimeMapping.GetMimeMapping(fileTitle), externalFileKey);
                                }
                        }
                        catch (Exception error)
                        {
                            Global.Logger.Error("Cannot receive external url for \"" + RequestFileUrl + "\"", error);
                        }
                    }

                    file = new File
                    {
                        ID    = RequestFileUrl,
                        Title = Global.ReplaceInvalidCharsAndTruncate(fileTitle)
                    };

                    file = DocumentServiceHelper.GetParams(file, true, FileShare.Read, false, false, false, false, false, out _configuration);
                    _configuration.Document.Permissions.Edit          = editPossible && !CoreContext.Configuration.Standalone;
                    _configuration.Document.Permissions.Rename        = false;
                    _configuration.Document.Permissions.Review        = false;
                    _configuration.Document.Permissions.ChangeHistory = false;
                    _editByUrl = true;

                    _configuration.Document.Url = fileUri;
                }
                ErrorMessage = _configuration.ErrorMessage;
            }
            catch (Exception ex)
            {
                Global.Logger.Warn("DocEditor", ex);
                ErrorMessage = ex.Message;
                return;
            }

            if (_configuration.EditorConfig.ModeWrite && FileConverter.MustConvert(file))
            {
                try
                {
                    file = FileConverter.ExecDuplicate(file, RequestShareLinkKey);
                }
                catch (Exception ex)
                {
                    _configuration = null;
                    Global.Logger.Error("DocEditor", ex);
                    ErrorMessage = ex.Message;
                    return;
                }

                var comment = "#message/" + HttpUtility.UrlEncode(FilesCommonResource.CopyForEdit);

                Response.Redirect(FilesLinkUtility.GetFileWebEditorUrl(file.ID) + comment);
                return;
            }

            Title = file.Title;

            if (_configuration.EditorConfig.Customization.Goback == null || string.IsNullOrEmpty(_configuration.EditorConfig.Customization.Goback.Url))
            {
                _configuration.EditorConfig.Customization.GobackUrl = Request[FilesLinkUtility.FolderUrl] ?? "";
            }

            _configuration.EditorConfig.Customization.IsRetina = TenantLogoManager.IsRetina(Request);

            if (RequestEmbedded)
            {
                _configuration.Type = Services.DocumentService.Configuration.EditorType.Embedded;

                _configuration.EditorConfig.Embedded.ShareLinkParam = string.IsNullOrEmpty(RequestShareLinkKey) ? string.Empty : "&" + FilesLinkUtility.DocShareKey + "=" + RequestShareLinkKey;
            }
            else
            {
                _configuration.Type = IsMobile ? Services.DocumentService.Configuration.EditorType.Mobile : Services.DocumentService.Configuration.EditorType.Desktop;

                if (FileSharing.CanSetAccess(file))
                {
                    _configuration.EditorConfig.SharingSettingsUrl = CommonLinkUtility.GetFullAbsolutePath(Share.Location + "?" + FilesLinkUtility.FileId + "=" + file.ID);
                }
            }

            if (!isExtenral)
            {
                _docKeyForTrack = DocumentServiceHelper.GetDocKey(file.ID, -1, DateTime.MinValue);

                FileMarker.RemoveMarkAsNew(file);
            }

            if (_configuration.EditorConfig.ModeWrite)
            {
                _tabId = FileTracker.Add(file.ID);
                if (SecurityContext.IsAuthenticated)
                {
                    _configuration.EditorConfig.FileChoiceUrl  = CommonLinkUtility.GetFullAbsolutePath(FileChoice.Location) + "?" + FileChoice.ParamFilterExt + "=xlsx&" + FileChoice.MailMergeParam + "=true";
                    _configuration.EditorConfig.MergeFolderUrl = CommonLinkUtility.GetFullAbsolutePath(MailMerge.GetUrl);
                }
            }
            else
            {
                _linkToEdit = _editByUrl
                                  ? CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.GetFileWebEditorExternalUrl(fileUri, file.Title))
                                  : CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.GetFileWebEditorUrl(file.ID));

                if (FileConverter.MustConvert(_configuration.Document.Info.File))
                {
                    _editByUrl = true;
                }
            }
        }
コード例 #15
0
        private void RegisterClientScript()
        {
            var isRetina = TenantLogoManager.IsRetina(HttpContext.Current.Request);

            Page.RegisterBodyScripts("~/usercontrols/management/accessrights/js/accessrights.js")
            .RegisterStyle("~/usercontrols/management/accessrights/css/accessrights.less");

            var curTenant    = CoreContext.TenantManager.GetCurrentTenant();
            var currentOwner = CoreContext.UserManager.GetUsers(curTenant.OwnerId);

            var admins = WebItemSecurity.GetProductAdministrators(Guid.Empty).ToList();

            admins = admins
                     .GroupBy(admin => admin.ID)
                     .Select(group => group.First())
                     .Where(admin => admin.ID != currentOwner.ID)
                     .SortByUserName();

            InitLdapRights();

            var sb = new StringBuilder();

            sb.AppendFormat("ownerId = \"{0}\";", curTenant.OwnerId);

            sb.AppendFormat("adminList = {0};", JsonConvert.SerializeObject(admins.ConvertAll(u => new
            {
                id           = u.ID,
                smallFotoUrl = u.GetSmallPhotoURL(),
                bigFotoUrl   = isRetina ? u.GetBigPhotoURL() : "",
                displayName  = u.DisplayUserName(),
                title        = u.Title.HtmlEncode(),
                userUrl      = CommonLinkUtility.GetUserProfile(u.ID),
                accessList   = GetAccessList(u.ID, WebItemSecurity.IsProductAdministrator(Guid.Empty, u.ID)),
                ldap         = LdapRights.Contains(u.ID.ToString())
            })));

            sb.AppendFormat("imageHelper = {0};", JsonConvert.SerializeObject(new
            {
                PeopleImgSrc  = WebImageSupplier.GetAbsoluteWebPath("user_12.png"),
                GroupImgSrc   = WebImageSupplier.GetAbsoluteWebPath("group_12.png"),
                TrashImgSrc   = WebImageSupplier.GetAbsoluteWebPath("trash_12.png"),
                TrashImgTitle = Resource.DeleteButton
            }));

            var managementPage = Page as Studio.Management;
            var tenantAccess   = managementPage != null ? managementPage.TenantAccess : TenantAccessSettings.Load();

            if (!tenantAccess.Anyone)
            {
                var productItemList = GetProductItemListForSerialization();

                foreach (var productItem in productItemList.Where(productItem => !productItem.CanNotBeDisabled))
                {
                    sb.AppendFormat("ASC.Settings.AccessRights.initProduct('{0}');", Convert.ToBase64String(
                                        Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(productItem))));
                }
            }

            sb.AppendFormat("ASC.Settings.AccessRights.init({0});",
                            JsonConvert.SerializeObject(Products.Select(p => p.GetSysName()).ToArray()));

            Page.RegisterInlineScript(sb.ToString());
        }
コード例 #16
0
 protected string GetAbsoluteCompanyTopLogoTitle()
 {
     return(TenantLogoManager.GetLogoText());
 }
コード例 #17
0
        public void RestoreDefault(TenantWhiteLabelSettings tenantWhiteLabelSettings, TenantLogoManager tenantLogoManager, int tenantId, IDataStore storage = null)
        {
            tenantWhiteLabelSettings.LogoLightSmallExt      = null;
            tenantWhiteLabelSettings.LogoDarkExt            = null;
            tenantWhiteLabelSettings.LogoFaviconExt         = null;
            tenantWhiteLabelSettings.LogoDocsEditorExt      = null;
            tenantWhiteLabelSettings.LogoDocsEditorEmbedExt = null;

            tenantWhiteLabelSettings.IsDefaultLogoLightSmall      = true;
            tenantWhiteLabelSettings.IsDefaultLogoDark            = true;
            tenantWhiteLabelSettings.IsDefaultLogoFavicon         = true;
            tenantWhiteLabelSettings.IsDefaultLogoDocsEditor      = true;
            tenantWhiteLabelSettings.IsDefaultLogoDocsEditorEmbed = true;

            tenantWhiteLabelSettings.SetLogoText(null);

            var store = storage ?? StorageFactory.GetStorage(tenantId.ToString(), moduleName);

            try
            {
                store.DeleteFiles("", "*", false);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }

            Save(tenantWhiteLabelSettings, tenantId, tenantLogoManager, true);
        }
コード例 #18
0
        public void RestoreDefault(TenantWhiteLabelSettings tenantWhiteLabelSettings, TenantLogoManager tenantLogoManager)
        {
            tenantWhiteLabelSettings._logoLightSmallExt = null;
            tenantWhiteLabelSettings._logoDarkExt       = null;
            tenantWhiteLabelSettings._logoFaviconExt    = null;
            tenantWhiteLabelSettings._logoDocsEditorExt = null;

            tenantWhiteLabelSettings._isDefaultLogoLightSmall = true;
            tenantWhiteLabelSettings._isDefaultLogoDark       = true;
            tenantWhiteLabelSettings._isDefaultLogoFavicon    = true;
            tenantWhiteLabelSettings._isDefaultLogoDocsEditor = true;

            tenantWhiteLabelSettings.SetLogoText(null);

            var tenantId = TenantManager.GetCurrentTenant().TenantId;
            var store    = StorageFactory.GetStorage(tenantId.ToString(), moduleName);

            try
            {
                store.DeleteFiles("", "*", false);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }

            Save(tenantWhiteLabelSettings, tenantId, tenantLogoManager, true);
        }
コード例 #19
0
        private void InitScript()
        {
            var inlineScript = new StringBuilder();

            inlineScript.AppendFormat("\nASC.Files.Constants.URL_WCFSERVICE = \"{0}\";",
                                      PathProvider.GetFileServicePath);

            if (!CoreContext.Configuration.Personal)
            {
                inlineScript.AppendFormat("\nASC.Files.Constants.URL_MAIL_ACCOUNTS = \"{0}\";",
                                          CommonLinkUtility.GetFullAbsolutePath("~/addons/mail/#accounts"));
            }

            if (SecurityContext.IsAuthenticated && !CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsVisitor())
            {
                inlineScript.AppendFormat("ASC.Files.Constants.URL_HANDLER_CREATE = \"{0}\";" +
                                          "ASC.Files.Constants.TitleNewFileText = \"{1}\";" +
                                          "ASC.Files.Constants.TitleNewFileSpreadsheet = \"{2}\";" +
                                          "ASC.Files.Constants.TitleNewFilePresentation = \"{3}\";",
                                          CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.FileHandlerPath),
                                          FilesJSResource.TitleNewFileText,
                                          FilesJSResource.TitleNewFileSpreadsheet,
                                          FilesJSResource.TitleNewFilePresentation);
            }

            var isRetina = TenantLogoManager.IsRetina(Request);

            inlineScript.AppendFormat("\nASC.Files.Editor.brandingLogoUrl = \"{0}\";" +
                                      "ASC.Files.Editor.brandingLogoEmbeddedUrl = \"{1}\";" +
                                      "ASC.Files.Editor.brandingCustomerLogo = \"{2}\";" +
                                      "ASC.Files.Editor.brandingCustomer = \"{3}\";" +
                                      "ASC.Files.Editor.brandingSite = \"{4}\";",
                                      CommonLinkUtility.GetFullAbsolutePath(TenantLogoHelper.GetLogo(WhiteLabelLogoTypeEnum.DocsEditor, !isRetina)),
                                      CommonLinkUtility.GetFullAbsolutePath(TenantLogoHelper.GetLogo(WhiteLabelLogoTypeEnum.Dark, !isRetina)),
                                      CommonLinkUtility.GetFullAbsolutePath(TenantLogoHelper.GetLogo(WhiteLabelLogoTypeEnum.Dark, !isRetina)),
                                      (SettingsManager.Instance.LoadSettings <TenantWhiteLabelSettings>(TenantProvider.CurrentTenantID).LogoText ?? "").Replace("\\", "\\\\").Replace("\"", "\\\"").Replace("/", "\\/"),
                                      CompanyWhiteLabelSettings.Instance.Site);

            inlineScript.AppendFormat("\nASC.Files.Editor.docKeyForTrack = \"{0}\";" +
                                      "ASC.Files.Editor.shareLinkParam = \"{1}\";" +
                                      "ASC.Files.Editor.serverErrorMessage = \"{2}\";" +
                                      "ASC.Files.Editor.editByUrl = ({3} == true);" +
                                      "ASC.Files.Editor.fixedVersion = ({4} == true);" +
                                      "ASC.Files.Editor.tabId = \"{5}\";" +
                                      "ASC.Files.Editor.thirdPartyApp = ({6} == true);" +
                                      "ASC.Files.Editor.openinigDate = \"{7}\";",
                                      _docKeyForTrack,
                                      string.IsNullOrEmpty(RequestShareLinkKey) ? string.Empty : "&" + FilesLinkUtility.DocShareKey + "=" + RequestShareLinkKey,
                                      (_errorMessage ?? "").Replace("\n", "\\n").Replace("\r", "").Replace("\"", "\\\""),
                                      _editByUrl.ToString().ToLower(),
                                      _fixedVersion.ToString().ToLower(),
                                      _tabId,
                                      _thirdPartyApp.ToString().ToLower(),
                                      DateTime.UtcNow.ToString(CultureInfo.InvariantCulture));

            if (!CoreContext.Configuration.Standalone)
            {
                inlineScript.AppendFormat("\nASC.Files.Editor.showAbout = true;" +
                                          "ASC.Files.Editor.feedbackUrl = \"{0}\";",
                                          AdditionalWhiteLabelSettings.Instance.FeedbackAndSupportEnabled
                                              ? CommonLinkUtility.GetRegionalUrl(
                                              AdditionalWhiteLabelSettings.Instance.FeedbackAndSupportUrl,
                                              CultureInfo.CurrentCulture.TwoLetterISOLanguageName)
                                              : string.Empty);
            }
            else if (_docParams != null)
            {
                inlineScript.AppendFormat("\nASC.Files.Editor.licenseUrl = \"{0}\";" +
                                          "ASC.Files.Editor.customerId = \"{1}\";",
                                          PathProvider.GetLicenseUrl(_docParams.File),
                                          LicenseReader.CustomerId);
            }

            inlineScript.Append(BuildOptions());

            inlineScript.AppendFormat("\nASC.Files.Editor.docServiceParams = {0};",
                                      DocumentServiceParams.Serialize(_docParams));

            InlineScripts.Scripts.Add(new Tuple <string, bool>(inlineScript.ToString(), false));
        }
コード例 #20
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);
        }
コード例 #21
0
        private void PageLoad()
        {
            var editPossible = !RequestEmbedded;
            var isExtenral   = false;

            File file;
            var  fileUri = string.Empty;

            try
            {
                if (string.IsNullOrEmpty(RequestFileUrl))
                {
                    var app = ThirdPartySelector.GetAppByFileId(RequestFileId);
                    if (app == null)
                    {
                        file = DocumentServiceHelper.GetParams(RequestFileId, RequestVersion, RequestShareLinkKey, editPossible, !RequestView, true, out _configuration);
                        if (_valideShareLink)
                        {
                            _configuration.Document.SharedLinkKey += RequestShareLinkKey;

                            if (CoreContext.Configuration.Personal && !SecurityContext.IsAuthenticated)
                            {
                                var user    = CoreContext.UserManager.GetUsers(file.CreateBy);
                                var culture = CultureInfo.GetCultureInfo(user.CultureName);
                                Thread.CurrentThread.CurrentCulture   = culture;
                                Thread.CurrentThread.CurrentUICulture = culture;
                            }
                        }
                    }
                    else
                    {
                        isExtenral = true;

                        bool editable;
                        _thirdPartyApp = true;
                        file           = app.GetFile(RequestFileId, out editable);
                        file           = DocumentServiceHelper.GetParams(file, true, editPossible ? FileShare.ReadWrite : FileShare.Read, false, editable, editable, editable, true, out _configuration);

                        _configuration.Document.Url = app.GetFileStreamUrl(file);
                        _configuration.EditorConfig.Customization.GobackUrl = string.Empty;
                    }
                }
                else
                {
                    isExtenral = true;

                    fileUri = RequestFileUrl;
                    var fileTitle = Request[FilesLinkUtility.FileTitle];
                    if (string.IsNullOrEmpty(fileTitle))
                    {
                        fileTitle = Path.GetFileName(HttpUtility.UrlDecode(fileUri)) ?? "";
                    }

                    file = new File
                    {
                        ID    = RequestFileUrl,
                        Title = Global.ReplaceInvalidCharsAndTruncate(fileTitle)
                    };

                    file = DocumentServiceHelper.GetParams(file, true, FileShare.Read, false, false, false, false, false, out _configuration);
                    _configuration.Document.Permissions.Edit          = editPossible && !CoreContext.Configuration.Standalone;
                    _configuration.Document.Permissions.Rename        = false;
                    _configuration.Document.Permissions.Review        = false;
                    _configuration.Document.Permissions.FillForms     = false;
                    _configuration.Document.Permissions.ChangeHistory = false;
                    _editByUrl = true;

                    _configuration.Document.Url = fileUri;
                }
                ErrorMessage = _configuration.ErrorMessage;
            }
            catch (Exception ex)
            {
                Global.Logger.Warn("DocEditor", ex);
                ErrorMessage = ex.Message;
                return;
            }

            if (_configuration.EditorConfig.ModeWrite && FileConverter.MustConvert(file))
            {
                try
                {
                    file = FileConverter.ExecSync(file, RequestShareLinkKey);
                }
                catch (Exception ex)
                {
                    _configuration = null;
                    Global.Logger.Error("DocEditor", ex);
                    ErrorMessage = ex.Message;
                    return;
                }

                var comment = "#message/" + HttpUtility.UrlEncode(string.Format(FilesCommonResource.ConvertForEdit, file.Title));

                Response.Redirect(FilesLinkUtility.GetFileWebEditorUrl(file.ID) + comment);
                return;
            }

            Title = file.Title;

            if (_configuration.EditorConfig.Customization.Goback == null || string.IsNullOrEmpty(_configuration.EditorConfig.Customization.Goback.Url))
            {
                _configuration.EditorConfig.Customization.GobackUrl = Request[FilesLinkUtility.FolderUrl] ?? "";
            }

            _configuration.EditorConfig.Customization.IsRetina = TenantLogoManager.IsRetina(Request);

            if (RequestEmbedded)
            {
                _configuration.Type = Services.DocumentService.Configuration.EditorType.Embedded;

                _configuration.EditorConfig.Embedded.ShareLinkParam = string.IsNullOrEmpty(RequestShareLinkKey) ? string.Empty : "&" + FilesLinkUtility.DocShareKey + "=" + RequestShareLinkKey;
            }
            else
            {
                _configuration.Type = IsMobile ? Services.DocumentService.Configuration.EditorType.Mobile : Services.DocumentService.Configuration.EditorType.Desktop;

                if (FileSharing.CanSetAccess(file) &&
                    !(file.Encrypted &&
                      (!Request.DesktopApp() ||
                       CoreContext.Configuration.Personal)))
                {
                    _configuration.EditorConfig.SharingSettingsUrl = CommonLinkUtility.GetFullAbsolutePath(
                        Share.Location
                        + "?" + FilesLinkUtility.FileId + "=" + HttpUtility.UrlEncode(file.ID.ToString())
                        + (Request.DesktopApp() ? "&desktop=true" : string.Empty));
                }
            }

            if (!isExtenral)
            {
                _docKeyForTrack = DocumentServiceHelper.GetDocKey(file.ID, -1, DateTime.MinValue);

                FileMarker.RemoveMarkAsNew(file);
            }

            if (SecurityContext.IsAuthenticated)
            {
                _configuration.EditorConfig.SaveAsUrl = _configuration.EditorConfig.MergeFolderUrl = CommonLinkUtility.GetFullAbsolutePath(SaveAs.GetUrl);
            }

            if (_configuration.EditorConfig.ModeWrite)
            {
                _tabId = FileTracker.Add(file.ID);

                Global.SocketManager.FilesChangeEditors(file.ID);

                if (SecurityContext.IsAuthenticated)
                {
                    _configuration.EditorConfig.FileChoiceUrl = CommonLinkUtility.GetFullAbsolutePath(FileChoice.GetUrlForEditor);
                }
            }
            else
            {
                _linkToEdit = _editByUrl
                                  ? CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.GetFileWebEditorExternalUrl(fileUri, file.Title))
                                  : CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.GetFileWebEditorUrl(file.ID));

                if (FileConverter.MustConvert(_configuration.Document.Info.File))
                {
                    _editByUrl = true;
                }
            }

            var actionAnchor = Request[FilesLinkUtility.Anchor];

            if (!string.IsNullOrEmpty(actionAnchor))
            {
                _configuration.EditorConfig.ActionLinkString = actionAnchor;
            }
        }