/// <summary> /// Create an SmtpEmailer. /// </summary> public SmtpEmailer() { to = new ArrayList(); files = new ArrayList(); receipients = new ToList(to); attachments = new AttachmentList(files); }
protected void gridArtifacts_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { ASPxGridView gridArtifacts = (ASPxGridView)sender; ASPxGridView gridRepository = (ASPxGridView)gridArtifacts.FindEditFormLayoutItemTemplateControl("gridRepository"); //Use class AttachmentList to create a list of artifacts to be attached AttachmentList xMultiAttachment = new AttachmentList(); //go through grid and create an unit for each selected item for (int i = 0; i <= gridRepository.VisibleRowCount; i = i + 1) { if (gridRepository.Selection.IsRowSelected(i) == true) { //get page ref from text box inside cell template ASPxTextBox txPage = (ASPxTextBox)gridRepository.FindRowCellTemplateControl(i, gridRepository.DataColumns[8], "txPage"); xMultiAttachment.Add(new Attachment() { ArtifactID = gridRepository.GetRowValues(i, "ArtifactID").ToString(), ProjectID = gridRepository.GetRowValues(i, "ProjectID").ToString(), PageReference = txPage.Text.ToString(), ItemID = Session["ItemKey"].ToString() }); } } //If any selected, call the function in rc_services to attach multiple artifacts if (xMultiAttachment.Count > 0) { string xMultiAttachResult = rc_services.AttachArtifact(xMultiAttachment); e.Cancel = true; gridArtifacts.CancelEdit(); gridArtifacts.DataBind(); gridRepository.Selection.UnselectAll(); } }
/// <summary> /// Initializes a new instance of the <see cref="CSharpAttachmentInstruction"/> class. /// </summary> /// <param name="context">The creation context.</param> /// <param name="parentFeature">The parent feature.</param> /// <param name="source">The Easly instruction from which the C# instruction is created.</param> protected CSharpAttachmentInstruction(ICSharpContext context, ICSharpFeature parentFeature, IAttachmentInstruction source) : base(context, parentFeature, source) { SourceExpression = CSharpExpression.Create(context, (IExpression)source.Source); IResultType ResolvedResult = SourceExpression.Source.ResolvedResult.Item; for (int i = 0; i < source.EntityNameList.Count; i++) { IName EntityName = source.EntityNameList[i]; string ValidName = EntityName.ValidText.Item; EntityNameList.Add(new CSharpVariableContext(ValidName)); } foreach (IAttachment Attachment in source.AttachmentList) { ICSharpAttachment NewAttachment = CSharpAttachment.Create(context, this, Attachment); AttachmentList.Add(NewAttachment); } if (source.ElseInstructions.IsAssigned) { ElseInstructions = CSharpScope.Create(context, parentFeature, (IScope)source.ElseInstructions.Item); } }
private void _init() { _index = -1; Title = Content = string.Empty; IsHtml = false; AttachmentList.Clear(); }
private void CheckDocumentAttachments(LogEntry Entry = null) { if (!CanRun) { return; } if (DocReceivedFields == null || DocReceivedFields.Count().Equals(0)) { return; } if (Entry != null && (!Entry.EntryType.Equals(LogEntryType.TrackedDocument) || !DocReceivedFields.Any(x => x.Description.Equals((Entry as TrackedDocument).Title)))) { return; } foreach (FieldDescriptor field in DocReceivedFields) { if (!string.IsNullOrEmpty(field.Description)) { AttachmentList attachments = GetAttachments(field); if (attachments == null) { continue; } EncompassHelper.Set(field.FieldID, attachments.Count.ToString()); } } }
//Метод за нов списък public void newList(string list) { //Присвоява стойностите от ListFromString List = new ListOfBlocks(ListFromString(list)); attachmentList = new AttachmentList(); Steps = new List <CStep>(); }
/// <summary> /// Deserializes this structure from binary data. /// </summary> /// <param name="reader">The <see cref="BinaryReader"/> to read the data from.</param> /// <param name="font">Tiny Font containing this appendix.</param> /// <exception cref="ArgumentNullException"><paramref name="reader"/> is null.</exception> public override void ReadFrom(BinaryReader reader, TinyFont font) { if (reader == null) { throw new ArgumentNullException("reader"); } _offsets.Clear(); for (int i = 0; i < font.TotalCharactersCount; i++) { _offsets.Add(reader.ReadUInt16()); } _attachmentListSize = reader.ReadUInt16(); _lists.Clear(); foreach (ushort offset in _offsets) { if (offset > 0) { AttachmentList list = new AttachmentList(); list.ReadFrom(reader); _lists.Add(list); } } }
private void CheckDocumentRecentAttachment(LogEntry Entry = null) { if (!CanRun) { return; } if (DocAttachmentFields == null || DocAttachmentFields.Count().Equals(0)) { return; } if (Entry != null && (!Entry.EntryType.Equals(LogEntryType.TrackedDocument) || !DocAttachmentFields.Any(x => x.Description.Equals((Entry as TrackedDocument).Title)))) { return; } foreach (FieldDescriptor field in DocAttachmentFields) { if (!string.IsNullOrEmpty(field.Description)) { AttachmentList attachments = GetAttachments(field); if (attachments == null || attachments.Count == 0) { continue; } DateTime newest = attachments.Cast <Attachment>().OrderByDescending(x => x.Date).FirstOrDefault().Date; EncompassHelper.Set(field.FieldID, newest.ToString()); } } }
private void ExecuteDeleteAttachmentCommand(int index) { if (index < 0 || index >= AttachmentList.Count) { return; } AttachmentList.RemoveAt(index); }
/// <summary> /// Creates an instance of Message. /// </summary> public Message() { To = new EmailAddressList(EmailAddressType.To); CC = new EmailAddressList(EmailAddressType.CC); BCC = new EmailAddressList(EmailAddressType.BCC); Attachments = new AttachmentList(); mSendAsyncCompleteCallback = new SendOrPostCallback(SendAsyncWorkerCompleted); }
private void ExecuteAddAttachmentCommand() { var files = Open.ChooseFiles(""); foreach (var item in files) { AttachmentList.Add(item); } }
/// <summary> /// Create an SmtpEmailer. /// </summary> public SmtpEmailer() { to = new ArrayList(); cc = new ArrayList(); bcc = new ArrayList(); files = new ArrayList(); to_receipients = new AddressList(to); cc_receipients = new AddressList(cc); bcc_receipients = new AddressList(bcc); attachments = new AttachmentList(files); }
/// <summary> /// /// multipart/alternative /// text/plain /// multipart/related /// text/html /// image/jpeg /// video/mp4 /// image/png /// /// /// </summary> /// <param name="mediaType"></param> /// <param name="mediaSubtype"></param> /// <param name="fullPath"></param> /// <param name="contentTransferEncoding"></param> /// <param name="contentObjectEncoding"></param> public void AddAttachment(string mediaType, string mediaSubtype, string fullPath, ContentEncoding contentTransferEncoding = ContentEncoding.Base64, ContentEncoding contentObjectEncoding = ContentEncoding.Default) { var attachment = new MimePart(mediaType, mediaSubtype) { ContentObject = new ContentObject(File.OpenRead(fullPath), contentObjectEncoding), ContentDisposition = new ContentDisposition(ContentDisposition.Attachment), ContentTransferEncoding = contentTransferEncoding, FileName = Path.GetFileName(fullPath) }; AttachmentList.Add(attachment); }
private List <Attachment> GetAttachmentForEachBorrowerPair(Loan loan, string trackedDocument) { List <Attachment> attachments = new List <Attachment>(); LogEntryList trackedDocuments = loan.Log.TrackedDocuments.GetDocumentsByTitle(trackedDocument); foreach (TrackedDocument doc in trackedDocuments) { AttachmentList attList = doc.GetAttachments(); foreach (Attachment att in attList) { attachments.Add(att); } } return(attachments); }
private void ExecuteEditCommand(int index) { if (index < 0 || index >= TemlpateList.Count) { return; } _index = index; Title = TemlpateList[index].Title; IsHtml = TemlpateList[index].IsHtml; Content = TemlpateList[index].Content; foreach (var item in TemlpateList[index].Attachment) { AttachmentList.Add(item); } }
public string GetFileList(int zlmxid) { List <AttachmentList> _lists = new List <AttachmentList>(); using (IDataReader dr = dal.ExecuteReader(String.Format(@"select id,urladdress,filename from t_uploadfile where groupid='1003' and TableID={0}", zlmxid))) { while (dr.Read()) { AttachmentList item = new AttachmentList(); item.FileName = dr[2].ToString(); item.FileID = dr[0].ToString(); item.Url = dr[1].ToString(); _lists.Add(item); } } return(ToString <List <AttachmentList> >(_lists)); }
public List <WCMDisclosure> GetDisclosuresFromTrackedDocument(WCMDisclosurePackage packageSelected, TrackedDocument efolder) { var result = new List <WCMDisclosure>(); AttachmentList attachments = efolder.GetAttachments(); foreach (Attachment attachment in attachments) { // SP - 03/21 - Doc Conversion Turned on // attachments are NOT available until after they are fully converted // while loop below allows us to check if doc is fully converted 20 times // thread.sleep in between each try let's doc finish converting int attemptDisclosureCount = 0; while (attemptDisclosureCount < 10) { attemptDisclosureCount++; try { result.Add(PopulateWCMDisclosures(attachment, packageSelected)); break; } catch (Exception ex) { // SP - aftr trying x times, throw ex if (attemptDisclosureCount >= 10) { throw new WCMException($"Unable to retrieve attachment from efolder " + $"'{efolder.Title}. '{ex.ToString()}'"); } Thread.Sleep(5000); } } } return(result); }
private AttachmentList GetAttachments(FieldDescriptor Field, LogEntry Entry = null) { AttachmentList result = new AttachmentList(); if (Field == null) { return(result); } if (Entry != null && (!Entry.EntryType.Equals(LogEntryType.TrackedDocument) || !Field.Description.Equals((Entry as TrackedDocument).Title))) { return(result); } if (!string.IsNullOrEmpty(Field.Description)) { CollectionBase documents = (CollectionBase)EncompassHelper.Loan.Log.TrackedDocuments.GetDocumentsByTitle(Field.Description); if (documents == null || documents.Count.Equals(0)) { return(result); } foreach (TrackedDocument document in documents) { AttachmentList attachments = document.GetAttachments(); if (attachments == null || attachments.Count.Equals(0)) { continue; } foreach (Attachment a in attachments) { result.Add(a); } } } return(result); }
/// <summary> /// View attachment /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AttachmentViewExecuted(object sender, ExecutedRoutedEventArgs e) { int id = e.Parameter is int ? (int)e.Parameter : 0; if (!VM.HasAttachment(id)) { MessageBox.Show(Properties.Resources.NoAttachment); return; } var frm = new AttachmentList(id); frm.ShowDialog(); }
private void ExecuteClearAttachmentCommand() { AttachmentList.Clear(); }
// Callback of the CallbackPanel which contains the entire control, to handle attaching and uploading protected void callAttach_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e) { //Select whether this is an attachment of a existing artifact, or an upload AND attachment of new artifact switch (e.Parameter) { //case "bindrepository": // gridRepository.DataSource = rc_services.GetRepository("P", false); // gridRepository.DataBind(); // break; case "attach": //Use class AttachmentList to create a list of artifacts to be attached AttachmentList xMultiAttachment = new AttachmentList(); //go through grid and create an unit for each selected item for (int i = 0; i <= gridRepository.VisibleRowCount; i = i + 1) { if (gridRepository.Selection.IsRowSelected(i) == true) { //get page ref from text box inside cell template string PageRef = ""; string xRowIndex = Convert.ToString(i); if (paramUpload.Contains("txPage" + xRowIndex)) { PageRef = paramUpload["txPage" + xRowIndex].ToString(); } //ASPxTextBox txPage = (ASPxTextBox)gridRepository.FindRowCellTemplateControl(i, gridRepository.DataColumns[8], "txPage"); string rowlibid = gridRepository.GetRowValues(i, "ArtifactID").ToString(); xMultiAttachment.Add(new Attachment() { ProjectID = Session["projectID"].ToString(), ArtifactID = rowlibid, ItemID = ItemKey.ToString(), PageReference = PageRef }); } } //If any selected, call the function in rc_services to attach multiple artifacts if (xMultiAttachment.Count > 0) { string xMultiAttachResult = rc_services.AttachArtifact(xMultiAttachment); BindGrid(); gridRepository.Selection.UnselectAll(); } break; //If they are uploading new artifact, first create it, and then attach it, using functions in rc_services case "newartifact": //Get variables loaded clientside on ASPxHiddenField Control xFileName = (string)paramUpload.Get("xFileName"); xStorageName = (string)paramUpload.Get("xStorageName"); xType = (string)paramUpload.Get("xType"); xTitle = (string)paramUpload.Get("xTitle"); xDesc = (string)paramUpload.Get("xDesc"); xFullText = (string)paramUpload.Get("xFullText"); //Use NewArtifact from rc_services class to create an object string xNewID = rc_services.NewArtifact(Session["projectID"].ToString(), xTitle, xType, ArtifactHome, xFileName, xStorageName, xDesc, xFullText, (string)Session["UserID"]); AttachmentList xAttachment = new AttachmentList(); xAttachment.Add(new Attachment() { ProjectID = Session["projectID"].ToString(), ArtifactID = xNewID, ItemID = ItemKey }); //Call function that attaches artifact after it has been created in above code string xAttachResult = rc_services.AttachArtifact(xAttachment); paramUpload.Clear(); paramUpload.Add("xNewArtifact", xAttachResult); BindGrid(); break; } }
public static AttachmentList GetAttachmentList(MimeMessage message, bool forReply, FilesToDelete filesToDelete) { var uploadHelper = new UploadHelper("Nortwind/Mail/{3:yyyyMM}/{4}"); var result = new AttachmentList(); result.ByIndex = new Dictionary <int, AttachmentInfo>(); result.InOrder = new List <AttachmentInfo>(); var attachmentNumber = 0; var visitor = new EmailPreviewVisitor(message, (mime, embedUrl) => { var sameAttachment = result.InOrder.FirstOrDefault(x => x.Mime == mime); if (sameAttachment != null) { sameAttachment.IsEmbedded = sameAttachment.IsEmbedded || embedUrl != null; return(sameAttachment.Url); } ++attachmentNumber; string fileName; string downUrl = null; byte[] buffer; using (var output = new MemoryStream()) { (mime as MimePart).Content.DecodeTo(output); buffer = output.GetBuffer(); } if (mime is MessagePart) { fileName = mime.ContentDisposition?.FileName ?? (mime.ContentType.Name ?? "attached" + attachmentNumber + ".eml"); } else { fileName = ((MimePart)mime).FileName ?? "file" + attachmentNumber + ".dat"; } if (embedUrl != null) { downUrl = string.Format("data:{0};base64,{1}", mime.ContentType.MimeType, Convert.ToBase64String(buffer, 0, buffer.Length)); } else { var processor = new UploadProcessor { ThumbWidth = 128, ThumbHeight = 96 }; if (processor.ProcessStream(new MemoryStream(buffer), Path.GetExtension(fileName))) { var temporaryFile = "temporary/" + Path.GetFileName(processor.FilePath); using (var sw = new StreamWriter(Path.ChangeExtension(UploadHelper.DbFilePath(temporaryFile), ".orig"))) sw.WriteLine(fileName); var copyResult = uploadHelper.CopyTemporaryFile(temporaryFile, -1, filesToDelete); downUrl = "/upload/" + copyResult.DbFileName; } else { downUrl = "?"; } } var info = new AttachmentInfo { Key = attachmentNumber, Filename = fileName, Mime = mime, Url = downUrl, IsEmbedded = embedUrl != null, Size = buffer.Length }; result.ByIndex[attachmentNumber] = info; result.InOrder.Add(info); return(downUrl); }, forReply); message.Accept(visitor); result.HtmlBody = visitor.HtmlBody; return(result); }