/// <summary> /// 设置附件信息 /// </summary> public static void SetAttachmentResult(string flag, byte[] result) { lock (AttachmentResults) { RemoveExpireResult(); if (result == null) { AttachmentResults.Remove(flag); } else { AttachmentContent attachment = new AttachmentContent() { Content = result, ExpireIn = DateTime.Now.AddDays(1) }; AttachmentResults[flag] = attachment; } } }
/// <summary> /// 获取附件信息 /// </summary> /// <returns></returns> public static bool TryGetAttachmentResult(string flag, out byte[] result) { lock (AttachmentResults) { AttachmentContent attachment = null; if (AttachmentResults.TryGetValue(flag, out attachment)) { if (attachment.ExpireIn < DateTime.Now) { AttachmentResults.Remove(flag); result = null; return(false); } result = attachment.Content; return(true); } } result = null; return(false); }