本文整理汇总了C#中Workshare.Where方法的典型用法代码示例。如果您正苦于以下问题:C# Workshare.Where方法的具体用法?C# Workshare.Where怎么用?C# Workshare.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Workshare
的用法示例。
在下文中一共展示了Workshare.Where方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReplaceProcessedAttachments
public void ReplaceProcessedAttachments(dynamic mailItem, Workshare.PolicyContent.Attachment[] processedAttachments, ZipAllOptions groupedZip)
{
Redemption.SafeMailItem safeMailItem = RedemptionLoader.new_SafeMailItem();
using (new ComRelease(safeMailItem))
{
safeMailItem.Item = mailItem.UnSafeMailItem;
if ((groupedZip != null) && groupedZip.ZipAll && safeMailItem.Attachments.Count > 0)
{
ZipAttachments(mailItem, processedAttachments, groupedZip);
return;
}
//AttachmentProperties
Dictionary<string, AttachmentProperties> dictAttachmentProps =
new Dictionary<string, AttachmentProperties>(safeMailItem.Attachments.Count);
GetAttachmentProperties(safeMailItem, dictAttachmentProps);
Redemption.MAPIUtils redemptionMAPIUtils = RedemptionLoader.new_MAPIUtils();
// Use .ToArray() to ensure the attachments are removed first, before any re-additions.
var removedAttachments =
processedAttachments.Where(a => RemoveAttachment(safeMailItem, a)).ToArray();
int renderingPosition = 1;
foreach (var attachment in removedAttachments)
{
string displayName = attachment.Name;
if (string.IsNullOrEmpty(displayName) || string.IsNullOrEmpty(displayName.Trim()))
{
displayName = UntitledAttachmentTitle;
}
string proposedFileName = GetProposedFileName(attachment);
string fileName = attachment.FileName;
DateTime creationTime = new DateTime();
DateTime lastModificationTime = new DateTime();
// For unmodified attachments we want to restore the timestamp so they appear as they were (ie unchanged!)
// We need to set the file creation/modification correctly, removing/adding resets the timestamp
if (!attachment.IsProcessed &&
GetAttachmentFileTimes(attachment, dictAttachmentProps, ref creationTime,
ref lastModificationTime))
{
File.SetCreationTime(fileName, creationTime);
File.SetLastWriteTime(fileName, lastModificationTime);
}
Redemption.Attachment redemptionAttachment;
// [VE2711] Use the DisplayName instead of MessageItem.Subject when adding .msg items back.
// DMS and other programes can add msg attachments with a custom name and not the .msg Subject.
// [DE9621/CR00126587] implemented the seperated handler for .msg files. Previously .msg files where handled
// the same way as any other attachments and this used to as still is for all other attachments
// the Attachment.Name property (the original DisplayName). As part of DE9621 the DisplayName was
// changed to the MessageItem.Subject. This was done (a) because that is the default MS Outlook
// behaviour if you add a .msg file to an email as an attachment and (b) the code that set
// Attachment.Name in Workshare.Mime.Conversions.OutlookAttachmentsProxy.this[int] was changed
// to use the FileName instead of the DisplayName [DE9621/CR00126587][DE9310/CR00123897], which ment the
// original DisplayName was nolonger available. Related change is in OutlookAttachmentsProxy.cs
if (fileName.EndsWith(".msg", StringComparison.InvariantCultureIgnoreCase))
{
Redemption.MessageItem redemptionMessageItem = redemptionMAPIUtils.GetItemFromMsgFile(fileName);
// Need to release "msgItem" before delete the file, as it holds reference to the file.
using (new ComRelease(redemptionMessageItem))
{
// Attach .msg via "olEmbeddedItem" to avoid Unicode msg attachment being blocked by "Symantec anti-virus Outlook addin"
redemptionAttachment = safeMailItem.Attachments.Add(redemptionMessageItem,
OlAttachmentType.olEmbeddeditem,
renderingPosition, displayName);
// Redemption does not set Unicode displayname properly, need to set manually.
redemptionAttachment.set_Fields(MapiDefines.PR_DISPLAY_NAME_W, displayName);
}
}
else
{
redemptionAttachment = safeMailItem.Attachments.Add(fileName, OlAttachmentType.olByValue,
renderingPosition, displayName);
try
{
// Redemption.dll (current version 4.6.0.924) didn't handle Unicode correctly for
// Attachments.Add() function. It attempts to convert Unicode filename to Ansi code
// based on current System Locale ("Language for non-Unicode program").
// Attachment with "e.g. Chinese/Cyrillic" filename will appear as "????".
// Check whether filename can be encoded with current default code page.
Encoding ansiEncoding = Encoding.GetEncoding(Encoding.Default.CodePage,
new EncoderExceptionFallback(),
new DecoderExceptionFallback());
// If not ansi will fail with EncoderFallbackException
byte[] ansiBytes = ansiEncoding.GetBytes(proposedFileName);
}
catch (EncoderFallbackException)
{
// If cannot convert using current system codepage, Redemption's Attachments.add()
// will not behave correctly. Have to manually set the FileName and Displayname with Unicode string.
redemptionAttachment.set_Fields(MapiDefines.PR_ATTACH_LONG_FILENAME_W, proposedFileName);
redemptionAttachment.set_Fields(MapiDefines.PR_ATTACH_FILENAME_W, proposedFileName);
//.........这里部分代码省略.........