本文整理汇总了C#中Attachment类的典型用法代码示例。如果您正苦于以下问题:C# Attachment类的具体用法?C# Attachment怎么用?C# Attachment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Attachment类属于命名空间,在下文中一共展示了Attachment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OnRead
// This is fired when actually retrieving the attachment
public override void OnRead(string key, Attachment attachment)
{
// Get the filename, and make sure its in the returned metadata
var filename = AugmentMetadataWithFilename(key, attachment.Metadata);
// We can't do anything else without a filename
if (filename == null)
return;
// Add a Content-Type header
var contentType = Utils.GetMimeType(filename);
if (!string.IsNullOrEmpty(contentType))
attachment.Metadata["Content-Type"] = contentType;
// Add a Content-Disposition header
// The filename is supposed to be quoted, but it doesn't escape the quotes properly.
// http://issues.hibernatingrhinos.com/issue/RavenDB-824
// This was fixed in 2235. For prior versions, don't send the quotes.
if (Utils.RavenVersion < Version.Parse("2.0.2235.0"))
attachment.Metadata["Content-Disposition"] = string.Format("attachment; filename={0}", filename);
else
attachment.Metadata["Content-Disposition"] = string.Format("attachment; filename=\"{0}\"", filename);
}
开发者ID:tzarger,项目名称:contrib,代码行数:26,代码来源:ReadAttachmentTrigger.cs
示例2: UploadAttach
public static Guid UploadAttach(FileUpload fu)
{
if (!fu.HasFile || fu.FileName.Length == 0)
{
throw new BusinessObjectLogicException("Please select upload file!");
}
string path = null;
try
{
string subDirectory = DateTime.Now.ToString("yyyyMM") + Path.DirectorySeparatorChar + DateTime.Now.ToString("dd");
string directory = System.Configuration.ConfigurationManager.AppSettings["File"] + subDirectory;
if (!Directory.Exists(directory)) Directory.CreateDirectory(directory);
string title = Path.GetFileNameWithoutExtension(fu.FileName);
string ext = Path.GetExtension(fu.FileName);
path = Path.DirectorySeparatorChar + Path.GetRandomFileName() + ext;
fu.SaveAs(directory + path);
Attachment attach = new Attachment(UserHelper.UserName);
attach.Title = title;
attach.Path = subDirectory + path;
new AttachmentBl().AddAttach(attach);
return attach.UID;
}
catch
{
throw new BusinessObjectLogicException("File upload fail!");
}
}
开发者ID:niceplayer454,项目名称:cfi,代码行数:35,代码来源:FileDUHelper.cs
示例3: IsSignatureRtf
private static bool IsSignatureRtf(Attachment attachment)
{
if (attachment.PropertyAccessor.GetProperty(MAPIProxy.MAPIStringDefines.PR_ATTACH_METHOD) == MAPIProxy.MapiDefines.ATTACH_OLE)
{
// Only allow file types we DON'T clean to be signatures.
try
{
if (attachment.DisplayName == "Picture (Device Independent Bitmap)")
return true;
if (FileTypeBridge.GetSupportedFileType(attachment.FileName) == FileType.Unknown)
{
Interop.Logging.Logger.LogInfo(string.Format("Signature {0} on Rtf formatted message", attachment.DisplayName));
return true;
}
}
catch (System.Exception ex)
{
Interop.Logging.Logger.LogDebug("Caught exception: assuming that when the mail format is rtf you are unable access the filename property of embedded images.");
Interop.Logging.Logger.LogDebug(ex);
return true;
}
}
return false;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:25,代码来源:OomSignatureInspector.cs
示例4: IsCalendar
public static bool IsCalendar(Attachment attachment)
{
if (Path.HasExtension(attachment.FileName) && Path.GetExtension(attachment.FileName).ToLower() == ".ics")
return true;
string loweredFileName = attachment.FileName.ToLower();
if (loweredFileName == "paycal_uparrow.gif")
return true;
if (loweredFileName == "paycal_line_datepick.gif")
return true;
if (loweredFileName == "paycal_line_outer_thick.gif")
return true;
if (loweredFileName == "paycal_line_outer_thin.gif")
return true;
if (loweredFileName == "paycal_free.gif")
return true;
if (loweredFileName == "paycal_tent.gif")
return true;
if (loweredFileName == "paycal_busy.gif")
return true;
if (loweredFileName == "paycal_oof.gif")
return true;
if (loweredFileName == "paycal_oowh.gif")
return true;
if (loweredFileName == "paycal_workingelsewhere.gif")
return true;
return false;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:30,代码来源:Utils.cs
示例5: OpenActualDocumentFromPlaceHolder
public bool OpenActualDocumentFromPlaceHolder(Attachment attachment)
{
try
{
if (attachment.Size > (1024*5))
{
Logger.LogTrace("Returning without doing anything as the file size is > 5k");
return false;
}
using (var lcfm = new LocalCopyOfFileManager())
{
string filename = lcfm.GetLocalCopyOfFileTarget(attachment.FileName);
attachment.SaveAsFile(filename);
Logger.LogTrace("Saving placeholder file to " + filename);
var lah = new LargeAttachmentHelper(filename);
if (lah.IsLargeAttachment)
{
Logger.LogTrace("Opening actual file from" + lah.ActualPath);
var startInfo = new ProcessStartInfo();
startInfo.FileName = lah.ActualPath;
Process.Start(startInfo);
return true;
}
}
return false;
}
catch (Exception ex)
{
Logger.LogError(ex);
throw;
}
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:34,代码来源:BigAttachmentsManager.cs
示例6: OnAttachmentAdd
private void OnAttachmentAdd(Attachment Attachment)
{
if (AttachmentAdd != null)
{
AttachmentAdd(_wsAttachments.Add(Attachment));
}
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:7,代码来源:WsMailItem.cs
示例7: OnBeforeAttachmentRead
private void OnBeforeAttachmentRead(Attachment Attachment, ref bool Cancel)
{
if (BeforeAttachmentRead != null)
{
// This is needed to ensure that attachments cannot be opened while IP is updating
// the attachments;
if (LockedForUpdating)
{
Cancel = true;
}
using (var attachment = new WsAttachment(Attachment))
{
foreach (WsAttachment wsAttachment in _wsAttachments)
{
if (wsAttachment.RecordKey == attachment.RecordKey && !string.IsNullOrEmpty(wsAttachment.RecordKey))
{
BeforeAttachmentRead(wsAttachment, ref Cancel);
return;
}
}
}
}
else
Marshal.ReleaseComObject(Attachment);
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:26,代码来源:WsMailItem.cs
示例8: SendReturnParent
private void SendReturnParent(DirectoryInfo dirInfo)
{
Attachment subFile = new Attachment();
subFile.Name = ".";
subFile.IsReturnParent = true;
SendHeader(subFile);
}
开发者ID:ChrisCross67,项目名称:Messenger,代码行数:7,代码来源:FileSender.cs
示例9: AttachmentBytes
internal static Attachment AttachmentBytes(string filename)
{
Attachment attachment = new Attachment(filename, null, null, null, false);
attachment.Content = System.IO.File.ReadAllBytes(filename);
return attachment;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:7,代码来源:ArrayHelper.cs
示例10: ThreadMail
void ThreadMail()
{
email = nameInputField.text;
Debug.Log (email);
MailMessage mail = new MailMessage("[email protected]", email);
// MailMessage mail = new MailMessage("[email protected]", email);
if (Application.platform == RuntimePlatform.IPhonePlayer) {
Attachment a = new Attachment (Application.persistentDataPath + "/" + path, MediaTypeNames.Application.Octet);
mail.Attachments.Add (a);
} else {
Attachment a = new Attachment (path, MediaTypeNames.Application.Octet);
mail.Attachments.Add (a);
}
SmtpClient client = new SmtpClient();
client.EnableSsl = true;
client.Host = "w0062da6.kasserver.com";
// client.Host = "smtp.gmail.com";
// client.Port = 25;
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential ("m0399d9f", "3mVEVGT7wKwKDb5X") as ICredentialsByHost;
// client.Credentials = new System.Net.NetworkCredential ("[email protected]", "okaconf2016") as ICredentialsByHost;
ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
};
mail.Subject = "OKA Configuration";
mail.Body = "";
client.Send (mail);
// Debug.Log(a);
}
开发者ID:deadkatz,项目名称:OKA_Project,代码行数:35,代码来源:SendMail.cs
示例11: SendDirectory
private void SendDirectory(DirectoryInfo dirInfo)
{
Attachment subFile = new Attachment();
subFile.Name = dirInfo.Name;
subFile.IsDirectory = true;
SendHeader(subFile);
}
开发者ID:ChrisCross67,项目名称:Messenger,代码行数:7,代码来源:FileSender.cs
示例12: BtnOKButton_Click
private void BtnOKButton_Click(object sender, EventArgs e)
{
try
{
if (type == DialogType.Edit)
{
byte[] file = File.ReadAllBytes(textBoxAttachmentFilePath.Text);
Upload uploadedFile = RedmineClientForm.redmine.UploadFile(file);
uploadedFile.FileName = Path.GetFileName(textBoxAttachmentFilePath.Text);
uploadedFile.Description = textBoxDescription.Text;
uploadedFile.ContentType = GetMimeType(Path.GetExtension(textBoxAttachmentFilePath.Text));
issue.Uploads = new List<Upload>();
issue.Uploads.Add(uploadedFile);
RedmineClientForm.redmine.UpdateObject<Issue>(issue.Id.ToString(), issue);
}
else
{
NewAttachment = new Attachment
{
ContentUrl = textBoxAttachmentFilePath.Text,
Description = textBoxDescription.Text,
FileName = Path.GetFileName(textBoxAttachmentFilePath.Text),
ContentType = GetMimeType(Path.GetExtension(textBoxAttachmentFilePath.Text)),
FileSize = (int)new FileInfo(textBoxAttachmentFilePath.Text).Length,
Author = new IdentifiableName { Id = RedmineClientForm.Instance.CurrentUser.Id, Name = RedmineClientForm.Instance.CurrentUser.CompleteName() }
};
}
DialogResult = DialogResult.OK;
this.Close();
}
catch (Exception ex)
{
MessageBox.Show(String.Format(Lang.Error_Exception, ex.Message), Lang.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
开发者ID:forestail,项目名称:redmine-desktop-client,代码行数:35,代码来源:AttachmentForm.cs
示例13: CheckAttachment
void CheckAttachment(Attachment attachment)
{
Assert.Equal("application/x-file", attachment.ContentType);
Assert.Equal(attachmentId, attachment.Id);
Assert.Equal(attachmentDataBuffer.Length, attachment.Length);
Assert.Equal(attachmentDataBuffer, ReadStreamToBuffer(attachment.Syncronously.OpenRead()));
}
开发者ID:artikh,项目名称:CouchDude,代码行数:7,代码来源:CouchApiAttachments.cs
示例14: Equals
public virtual bool Equals(Attachment other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return base.Equals(other) && Equals(other.FileName, FileName) && Equals(other.ContentType, ContentType) &&
other.ContentLength == ContentLength;
}
开发者ID:gwhn,项目名称:Weblitz.MessageBoard,代码行数:7,代码来源:Attachment.cs
示例15: WsAttachment
public WsAttachment(Attachment attachment, WsAttachments parent)
{
Id = Guid.NewGuid();
_parent = parent;
_attachment = attachment;
InitializeAttachment();
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:7,代码来源:WsAttachment.cs
示例16: AttachmentReference
internal static Attachment AttachmentReference(string filename)
{
Attachment attachment = new Attachment(filename, null, null, null, false);
attachment.Content = null;
return attachment;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:7,代码来源:ArrayHelper.cs
示例17: PdfMail
public static bool PdfMail(Stream stream, string toAddress)
{
try {
MailMessage message = new MailMessage(new MailAddress("[email protected]", "Eaztimate Jour"), new MailAddress(toAddress));
message.BodyEncoding = Encoding.GetEncoding("ISO-8859-1");
message.Subject = "Jourrapport";
message.Body = "Här kommer en jourrapport\r\n";
stream.Seek(0, SeekOrigin.Begin);
Attachment att = new Attachment(stream, MediaTypeNames.Application.Pdf);
att.ContentDisposition.FileName = "Jourrapport.pdf";
message.Attachments.Add(att);
message.IsBodyHtml = false;
int port = 0;
int.TryParse(ConfigurationManager.AppSettings["SMTPPort"], out port);
SmtpClient client = new SmtpClient(ConfigurationManager.AppSettings["SMTPServer"], port);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["AutomatedEMailAddress"], ConfigurationManager.AppSettings["SMTPPassword"]);
//client.Credentials = CredentialCache.DefaultNetworkCredentials;
client.Send(message);
return true;
} catch (Exception ex) {
ex.ToString();
return false;
}
}
开发者ID:peterbjons,项目名称:Eaztimate,代码行数:26,代码来源:Common.cs
示例18: DownloadAttachment
// This handles getting the stream for downloading. Luke, you can probably make more sense of this
// than I can.
// - Sean
public static System.IO.Stream DownloadAttachment(MirrorService service, Attachment attachment)
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(
new Uri(attachment.ContentUrl));
service.Authenticator.ApplyAuthenticationToRequest(request);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
return response.GetResponseStream();
}
else
{
Console.WriteLine(
"An error occurred: " + response.StatusDescription);
return null;
}
}
catch (Exception e)
{
Console.WriteLine("An error occurred: " + e.Message);
return null;
}
}
开发者ID:ndatdev,项目名称:mirror-exploration,代码行数:28,代码来源:MainController.cs
示例19: OnAttachmentRemove
private void OnAttachmentRemove(Attachment Attachment)
{
if (AttachmentRemove != null)
{
AttachmentRemove(_wsAttachments.Remove(Attachment));
}
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:7,代码来源:WsMailItem.cs
示例20: Send
public async void Send(string message, string score, string webHookUrl = null)
{
if (Simulate)
{
Console.WriteLine("Simulate message: " + message + " score: " + score);
return;
}
if (webHookUrl == null)
{
webHookUrl = WebHookUrl;
}
using (var client = new HttpClient())
{
var content = new Attachment();
content.Fallback = $"{message}. The current score is {score}.";
content.Fields = new List<Field>();
var messageField = new Field();
messageField.Value = message;
messageField.Short = true;
content.Fields.Add(messageField);
var scoreField = new Field();
scoreField.Title = "Score";
scoreField.Value = score;
scoreField.Short = true;
content.Fields.Add(scoreField);
var contentAsString = JsonConvert.SerializeObject(content);
await client.PostAsync(webHookUrl, new StringContent(contentAsString));
}
}
开发者ID:joshhendo,项目名称:cricket-integration,代码行数:35,代码来源:MessageSender.cs
注:本文中的Attachment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论