/// <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); } }
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(); } }
private void ExecuteAddAttachmentCommand() { var files = Open.ChooseFiles(""); foreach (var item in files) { AttachmentList.Add(item); } }
/// <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 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); } }
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); }
// 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; } }