Example #1
0
        private void WriteMoveCopyAction(RuleAction.MoveCopy moveCopy)
        {
            Exception exception;

            if (!RuleUtil.TryRunStoreCode(delegate
            {
                StoreObjectId folderId = StoreObjectId.FromProviderSpecificId(moveCopy.FolderEntryID, StoreObjectType.Folder);
                try
                {
                    Folder folder = this.folders.FirstOrDefault((Folder candidate) => candidate.StoreObjectId.Equals(folderId));
                    if (folder == null)
                    {
                        folder = Folder.Bind(this.session, folderId);
                        this.folders.Add(folder);
                    }
                    this.writer.WriteAttributeString("FolderName", folder.DisplayName);
                }
                catch (ObjectNotFoundException)
                {
                    this.writer.WriteAttributeString("FolderName", ServerStrings.RuleWriterObjectNotFound);
                }
            }, out exception))
            {
                this.WriteExceptionElement("Opening target folder for rule action.", exception);
            }
            this.WriteBinaryData("FolderEntry", moveCopy.FolderEntryID);
            this.WriteBinaryData("StoreEntry", moveCopy.StoreEntryID);
        }
Example #2
0
 private void WriteFolder(Folder folder)
 {
     this.writer.WriteStartElement("Folder");
     if (folder != null)
     {
         Rule[]    rules = null;
         Exception exception;
         if (RuleUtil.TryRunStoreCode(delegate
         {
             MapiFolder mapiFolder = folder.MapiFolder;
             rules = mapiFolder.GetRules(new PropTag[0]);
         }, out exception))
         {
             this.writer.WriteAttributeString("FolderName", folder.DisplayName);
             this.writer.WriteAttributeString("Rules", rules.Length.ToString());
             for (int i = 0; i < rules.Length; i++)
             {
                 Rule rule = rules[i];
                 this.WriteRule(rule, i);
             }
         }
         else
         {
             this.WriteExceptionElement("Getting rules from folder: " + folder.DisplayName, exception);
         }
     }
     this.writer.WriteEndElement();
 }
Example #3
0
        private void WriteReplyAction(byte[] replyTemplateMessageId, Guid replyGuid, bool includeSubject)
        {
            this.writer.WriteAttributeString("ReplyTemplateGuid", replyGuid.ToString());
            Exception exception;

            if (!RuleUtil.TryRunStoreCode(delegate
            {
                try
                {
                    StoreId itemId = StoreObjectId.FromProviderSpecificId(replyTemplateMessageId);
                    using (MessageItem messageItem = Item.BindAsMessage(this.session, itemId, StoreObjectSchema.ContentConversionProperties))
                    {
                        if (includeSubject)
                        {
                            this.writer.WriteAttributeString("ReplySubject", messageItem.Subject);
                        }
                        using (TextReader textReader = messageItem.Body.OpenTextReader(BodyFormat.TextPlain))
                        {
                            string text = textReader.ReadToEnd();
                            this.writer.WriteStartElement("ReplyBody");
                            this.writer.WriteString(Environment.NewLine);
                            this.writer.WriteString(text);
                            this.writer.WriteString(Environment.NewLine);
                            this.writer.WriteEndElement();
                        }
                    }
                }
                catch (ObjectNotFoundException)
                {
                    this.writer.WriteAttributeString("ReplySubject", ServerStrings.RuleWriterObjectNotFound);
                }
            }, out exception))
            {
                this.WriteExceptionElement("Opening reply template message", exception);
            }
            this.WriteBinaryData("ReplyTemplateMessageId", replyTemplateMessageId);
        }