コード例 #1
0
        // Token: 0x06000432 RID: 1074 RVA: 0x00023E34 File Offset: 0x00022034
        private void AddAttachments()
        {
            InfobarMessageType  type = InfobarMessageType.Error;
            AttachmentAddResult attachmentAddResult = AttachmentUtility.AddAttachment(base.Item, base.Request.Files, base.UserContext);

            if (attachmentAddResult.ResultCode != AttachmentAddResultCode.NoError)
            {
                base.Infobar.AddMessageHtml(attachmentAddResult.Message, type);
            }
            base.Item.Load();
            if (attachmentAddResult.ResultCode != AttachmentAddResultCode.IrresolvableConflictWhenSaving)
            {
                this.changeKeyString = base.Item.Id.ChangeKeyAsBase64String();
            }
            if (Globals.ArePerfCountersEnabled)
            {
                OwaSingleCounters.ItemsUpdated.Increment();
            }
        }
コード例 #2
0
        public void SendByEmail()
        {
            ExTraceGlobals.DocumentsCallTracer.TraceDebug((long)this.GetHashCode(), "DocumentLibraryEventHandler.SendByEmail");
            MessageItem messageItem = null;

            string[] array  = (string[])base.GetParameter("uri");
            Stream   stream = null;
            bool     flag   = DocumentLibraryUtilities.IsNavigationToWSSAllowed(base.UserContext);
            bool     flag2  = DocumentLibraryUtilities.IsNavigationToUNCAllowed(base.UserContext);

            try
            {
                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]);
                        throw new OwaEventHandlerException("Could not add attachment to email", LocalizedStrings.GetNonEncoded(1948229493), OwaEventHandlerErrorCode.SendByEmailError);
                    }
                    DocumentLibraryObjectId objectId = documentLibraryObjectId.ObjectId;
                    if (objectId == null)
                    {
                        ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "ObjectId could not be created from URI parameter: " + array[i]);
                        throw new OwaEventHandlerException("Could not add attachment to email", LocalizedStrings.GetNonEncoded(1948229493), OwaEventHandlerErrorCode.SendByEmailError);
                    }
                    UriFlags uriFlags = objectId.UriFlags;
                    try
                    {
                        string text;
                        switch (uriFlags)
                        {
                        case UriFlags.SharepointDocument:
                        {
                            if (!flag)
                            {
                                throw new OwaSegmentationException("Access to Sharepoint documents is disabled");
                            }
                            SharepointSession  session            = base.UserContext.LogonIdentity.CreateSharepointSession(objectId);
                            SharepointDocument sharepointDocument = SharepointDocument.Read(session, objectId);
                            stream = sharepointDocument.GetDocument();
                            text   = (string.IsNullOrEmpty(sharepointDocument.DisplayName) ? LocalizedStrings.GetNonEncoded(1797976510) : sharepointDocument.DisplayName);
                            break;
                        }

                        case UriFlags.UncDocument:
                        {
                            if (!flag2)
                            {
                                throw new OwaSegmentationException("Access to Unc documents is disabled");
                            }
                            UncSession  session2    = base.UserContext.LogonIdentity.CreateUncSession(objectId);
                            UncDocument uncDocument = UncDocument.Read(session2, objectId);
                            stream = uncDocument.GetDocument();
                            text   = Path.GetFileName(uncDocument.Uri.ToString());
                            if (!string.IsNullOrEmpty(text))
                            {
                                text = HttpUtility.UrlDecode(text);
                            }
                            break;
                        }

                        default:
                            throw new OwaNotSupportedException("Unhandled document library type");
                        }
                        if (messageItem == null)
                        {
                            messageItem = MessageItem.Create(base.UserContext.MailboxSession, base.UserContext.DraftsFolderId);
                            messageItem[ItemSchema.ConversationIndexTracking] = true;
                        }
                        int num;
                        AttachmentAddResult attachmentAddResult = AttachmentUtility.AddAttachmentFromStream(messageItem, text, null, stream, base.UserContext, out num);
                        if (Globals.ArePerfCountersEnabled)
                        {
                            if (uriFlags == UriFlags.UncDocument)
                            {
                                OwaSingleCounters.UncRequests.Increment();
                                OwaSingleCounters.UncBytes.IncrementBy((long)num);
                            }
                            else
                            {
                                OwaSingleCounters.WssRequests.Increment();
                                OwaSingleCounters.WssBytes.IncrementBy((long)num);
                            }
                        }
                        if (attachmentAddResult.ResultCode != AttachmentAddResultCode.NoError)
                        {
                            throw new OwaEventHandlerException("Could not add attachment to email. " + attachmentAddResult.Message, LocalizedStrings.GetNonEncoded(1948229493), OwaEventHandlerErrorCode.SendByEmailError);
                        }
                    }
                    finally
                    {
                        if (stream != null)
                        {
                            stream.Close();
                            stream = null;
                        }
                    }
                }
                messageItem.Save(SaveMode.ResolveConflicts);
                messageItem.Load();
                this.Writer.Write(messageItem.Id.ObjectId.ToBase64String());
            }
            finally
            {
                if (messageItem != null)
                {
                    messageItem.Dispose();
                    messageItem = null;
                }
            }
        }