public List <Model.Attachment> Attachment(string stGuidConnect, SVAOLLib.Card gCard, List <string> idAttachments, Boolean addBinary = true) { //var att = UtilSvCard.attchment(sConnection, oSvCard, LogId, idAttachments, true); List <dynamic> lAttachmentExt = new List <dynamic>(); using (var oCardManager = new CardManager(_Logger, _sLogId)) { lAttachmentExt = oCardManager.GetAttachmentExt(stGuidConnect, gCard, idAttachments, true); } List <Model.Attachment> oAttachments = new List <Model.Attachment>(); foreach (var singleAttach in lAttachmentExt) { Model.Attachment oAttachment = new Model.Attachment(); oAttachment.BinaryContent = singleAttach.binarycontent; oAttachment.Filename = singleAttach.nomefile; oAttachment.Note = singleAttach.note; oAttachments.Add(oAttachment); } return(oAttachments); }
public Model.Document Transition(Data.Version version, out List <Exception> errors) { Model.Document document = new Model.Document(); Model.Attachment att = null; string prop; errors = null; try { document.Id = version.VersionId.ToString(); if (!string.IsNullOrEmpty(version.Revision)) { document.Rev = version.Revision; } document.Add("$type", "version"); document.Add("$md5", version.Md5); document.Add("$extension", version.Extension); document.Add("$created", version.Created); document.Add("$creator", version.Creator); document.Add("$modified", version.Modified); document.Add("$modifier", version.Modifier); if (version.Metadata != null) { if ((errors = AddMetadata(version, document)) != null) { return(null); } } if (version.Content != null) { att = new Model.Attachment(); att.ContentType = version.Content.ContentType.Name; att.AttachmentLength = version.Content.Length; if (string.IsNullOrEmpty(version.Content.LocalFilepath)) { document.AddAttachment("file", att); } else { document.AddAttachment(System.IO.Path.GetFileName(version.Content.LocalFilepath), att); } } if (!VerifyDocumentIntegrity(document, out prop)) { Logger.Storage.Error("The document is not properly formatted. It is missing the property '" + prop + "'."); throw new FormattingException("The argument document does not have the necessary property '" + prop + "'."); } } catch (Exception e) { Logger.Storage.Error("An exception occurred while attempting to parse the version object.", e); throw; } return(document); }
private void btnSubmit_Click(object sender, EventArgs e) { try { Model.Content oContent = new Model.Content(); if (!CheckSubmit()) { return; } oContent.Folder = cboLibrary.SelectedItem as Model.Folder; //--------------------------------------------------------- //oContent.Name = txtContent.Text; oContent.Tags = new List <string>(); oContent.Name = cboBrank.Text + cboWorkflow.Text + DateTime.Now.ToString("yyMMddHHmmssff"); oContent.Tags.Add(oContent.Name.Replace(" ", "_")); //----------------------------------------------------------- //Update Field Library oContent.LibraryFieldValues = new Dictionary <string, object>(); var library = oUCMSApiClient.Folder.GetLibrary(oContent.Folder.Id); foreach (var item in library.Fields) { oContent.LibraryFieldValues.Add(item.Id, item.DefaultValue); } if (library.ContentTypes.Count > 0) { var contentType = oUCMSApiClient.ContentType.GetById(library.ContentTypes[0].Id); oContent.ContentType = new Model.ContentType() { Id = contentType.Id }; oContent.Values = new Dictionary <string, object>(); foreach (var item in contentType.Fields) //Chon gia tri cho contentType { oContent.Values.Add(item.Name, item.DefaultValue); } } oContent.Values.Add("BranchId", cboBrank.Text); var oContentMd = oUCMSApiClient.Content.Create(oContent); //oUCMSApiClient.Content.SetPrivateData(oContentMd.Id, new Model.ContentPrivateData() { }); // ---------Attachment----------------------------------------------------------------- oUCMSApiClient.Content.Checkout(oContentMd.Id);//Checkout content foreach (String item in tempNameFolders.Split(';')) { if (item.Trim().Length > 0) { var attachment = new Model.Attachment(); attachment.Name = Path.GetFileName(item.Trim()); attachment.ContentId = oContentMd.Id; attachment.MIME = Path.GetExtension(item.Trim()).Replace(".", "image/"); attachment.Data = File.ReadAllBytes(item.Trim()); attachment.Type = Model.Enum.AttachmentType.Public; attachment.Path = item.Trim(); oUCMSApiClient.Attachment.Upload(attachment); } } oUCMSApiClient.Content.Checkin(oContentMd.Id); // Checkint content //----------------------------------------------------------------------------------------- //---Insert content in workflow------------------------------------------------------------ Model.WorkflowItem oWorkflowItem = new Model.WorkflowItem(); oWorkflowItem.Content = oContentMd; oWorkflowItem.WorkflowStep = new Model.WorkflowStep() { Id = (cboWorkflowStep.SelectedItem as Model.WorkflowStep).Id }; oWorkflowItem.Workflow = new Model.Workflow() { Id = (cboWorkflow.SelectedItem as Model.Workflow).Id }; oWorkflowItem.State = Model.Enum.WorkflowItemState.Ready; oWorkflowItem.Priority = Model.Enum.WorkflowItemPriority.Normal; oUCMSApiClient.WorkflowItem.Insert(oWorkflowItem, true); //----------------------------------------------------------------------------------------- MessageBox.Show("Cập nhật thành công"); txtContent.Text = ""; txtFolders.Text = ""; } catch (Exception ex) { } }
public PutAttachment(IDatabase db, Model.Document document, string attachmentName, Model.Attachment attachment, System.IO.Stream stream) : base(UriBuilder.Build(db, document, attachmentName), new Http.Methods.Delete()) { _stream = stream; }
public Model.Document Transition(Data.Version version, out List<Exception> errors) { Model.Document document = new Model.Document(); Model.Attachment att = null; string prop; errors = null; try { document.Id = version.VersionId.ToString(); if (!string.IsNullOrEmpty(version.Revision)) document.Rev = version.Revision; document.Add("$type", "version"); document.Add("$md5", version.Md5); document.Add("$extension", version.Extension); document.Add("$created", version.Created); document.Add("$creator", version.Creator); document.Add("$modified", version.Modified); document.Add("$modifier", version.Modifier); if (version.Metadata != null) { if ((errors = AddMetadata(version, document)) != null) return null; } if (version.Content != null) { att = new Model.Attachment(); att.ContentType = version.Content.ContentType.Name; att.AttachmentLength = version.Content.Length; if (string.IsNullOrEmpty(version.Content.LocalFilepath)) document.AddAttachment("file", att); else document.AddAttachment(System.IO.Path.GetFileName(version.Content.LocalFilepath), att); } if (!VerifyDocumentIntegrity(document, out prop)) { Logger.Storage.Error("The document is not properly formatted. It is missing the property '" + prop + "'."); throw new FormattingException("The argument document does not have the necessary property '" + prop + "'."); } } catch (Exception e) { Logger.Storage.Error("An exception occurred while attempting to parse the version object.", e); throw; } return document; }