Exemplo n.º 1
0
        public void AddFavoriteLibrary()
        {
            ExTraceGlobals.DocumentsCallTracer.TraceDebug((long)this.GetHashCode(), "DocumentLibraryEventHandler.AddFavoriteLibrary");
            string[] array = (string[])base.GetParameter("uri");
            bool     flag  = false;

            this.Writer.Write("<div id=divAFavLibs>");
            for (int i = 0; i < array.Length; i++)
            {
                ClassifyResult documentLibraryObjectId = DocumentLibraryUtilities.GetDocumentLibraryObjectId(array[i], base.UserContext);
                if (documentLibraryObjectId == null)
                {
                    ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "Could not classify link: " + array[i]);
                }
                else
                {
                    DocumentLibraryObjectId objectId = documentLibraryObjectId.ObjectId;
                    if (objectId != null)
                    {
                        UriFlags        uriFlags        = objectId.UriFlags;
                        DocumentLibrary documentLibrary = new DocumentLibrary();
                        bool            flag2           = DocumentLibraryUtilities.IsNavigationToWSSAllowed(base.UserContext);
                        bool            flag3           = DocumentLibraryUtilities.IsNavigationToUNCAllowed(base.UserContext);
                        UriFlags        uriFlags2       = uriFlags;
                        switch (uriFlags2)
                        {
                        case UriFlags.Sharepoint:
                            {
                                if (!flag2)
                                {
                                    throw new OwaSegmentationException("Access to Sharepoint documents is disabled");
                                }
                                SharepointSession sharepointSession = base.UserContext.LogonIdentity.CreateSharepointSession(objectId);
                                documentLibrary.DisplayName = (string.IsNullOrEmpty(sharepointSession.DisplayName) ? LocalizedStrings.GetNonEncoded(-527057840) : sharepointSession.DisplayName);
                                documentLibrary.SiteName    = sharepointSession.DisplayName;
                                break;
                            }

                        case UriFlags.Unc:
                            {
                                if (!flag3)
                                {
                                    throw new OwaSegmentationException("Access to Unc documents is disabled");
                                }
                                UncSession uncSession = base.UserContext.LogonIdentity.CreateUncSession(objectId);
                                documentLibrary.DisplayName = uncSession.Title;
                                documentLibrary.SiteName    = uncSession.Uri.Host;
                                break;
                            }

                        case UriFlags.Sharepoint | UriFlags.Unc:
                        case UriFlags.DocumentLibrary:
                            goto IL_34F;

                        case UriFlags.SharepointDocumentLibrary:
                        {
                            if (!flag2)
                            {
                                throw new OwaSegmentationException("Access to Sharepoint documents is disabled");
                            }
                            SharepointSession         sharepointSession2        = base.UserContext.LogonIdentity.CreateSharepointSession(objectId);
                            SharepointDocumentLibrary sharepointDocumentLibrary = SharepointDocumentLibrary.Read(sharepointSession2, objectId);
                            documentLibrary.DisplayName = (string.IsNullOrEmpty(sharepointDocumentLibrary.Title) ? LocalizedStrings.GetNonEncoded(477016274) : sharepointDocumentLibrary.Title);
                            documentLibrary.SiteName    = sharepointSession2.DisplayName;
                            break;
                        }

                        case UriFlags.UncDocumentLibrary:
                        {
                            if (!flag3)
                            {
                                throw new OwaSegmentationException("Access to Unc documents is disabled");
                            }
                            UncSession         session            = base.UserContext.LogonIdentity.CreateUncSession(objectId);
                            UncDocumentLibrary uncDocumentLibrary = UncDocumentLibrary.Read(session, objectId);
                            documentLibrary.DisplayName = (string.IsNullOrEmpty(uncDocumentLibrary.Title) ? LocalizedStrings.GetNonEncoded(477016274) : uncDocumentLibrary.Title);
                            documentLibrary.SiteName    = uncDocumentLibrary.Uri.Host;
                            break;
                        }

                        default:
                            switch (uriFlags2)
                            {
                            case UriFlags.SharepointFolder:
                            {
                                if (!flag2)
                                {
                                    throw new OwaSegmentationException("Access to Sharepoint documents is disabled");
                                }
                                SharepointSession sharepointSession3 = base.UserContext.LogonIdentity.CreateSharepointSession(objectId);
                                SharepointDocumentLibraryFolder sharepointDocumentLibraryFolder = SharepointDocumentLibraryFolder.Read(sharepointSession3, objectId);
                                documentLibrary.DisplayName = (string.IsNullOrEmpty(sharepointDocumentLibraryFolder.DisplayName) ? LocalizedStrings.GetNonEncoded(-527057840) : sharepointDocumentLibraryFolder.DisplayName);
                                documentLibrary.SiteName    = sharepointSession3.DisplayName;
                                break;
                            }

                            case UriFlags.UncFolder:
                            {
                                if (!flag3)
                                {
                                    throw new OwaSegmentationException("Access to Unc documents is disabled");
                                }
                                UncSession session2 = base.UserContext.LogonIdentity.CreateUncSession(objectId);
                                UncDocumentLibraryFolder uncDocumentLibraryFolder = UncDocumentLibraryFolder.Read(session2, objectId);
                                documentLibrary.DisplayName = (string.IsNullOrEmpty(uncDocumentLibraryFolder.DisplayName) ? LocalizedStrings.GetNonEncoded(-527057840) : uncDocumentLibraryFolder.DisplayName);
                                documentLibrary.SiteName    = uncDocumentLibraryFolder.Uri.Host;
                                break;
                            }

                            default:
                                goto IL_34F;
                            }
                            break;
                        }
                        documentLibrary.Type = uriFlags;
                        documentLibrary.Uri  = array[i];
                        int num = 0;
                        if (DocumentLibraryUtilities.AddFavorite(documentLibrary, base.UserContext, out num) && num <= 1000)
                        {
                            DocumentLibraryUtilities.RenderLibraryItem(this.Writer, documentLibrary, base.UserContext, true);
                            flag = true;
                            goto IL_3A0;
                        }
                        goto IL_3A0;
                        IL_34F:
                        throw new OwaNotSupportedException("Unhandled document library type");
                    }
                    ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "ObjectId could not be created from URI parameter: " + array[i]);
                }
                IL_3A0 :;
            }
            this.Writer.Write("</div>");
            if (flag)
            {
                this.Writer.Write("<div id=divMsgFav>");
                this.Writer.Write(LocalizedStrings.GetHtmlEncoded(344777715));
                this.Writer.Write("</div><div id=divMsgTtl>");
                this.Writer.Write(LocalizedStrings.GetHtmlEncoded(803639727));
            }
            else
            {
                this.Writer.Write("<div id=divNoLib>");
            }
            this.Writer.Write("</div>");
        }