/// <remarks/> public void writeAsync(Reference node, string property, byte[] content, ContentFormat format, object userState) { if ((this.writeOperationCompleted == null)) { this.writeOperationCompleted = new System.Threading.SendOrPostCallback(this.OnwriteOperationCompleted); } this.InvokeAsync("write", new object[] { node, property, content, format }, this.writeOperationCompleted, userState); }
/// <summary> /// Guarda un fichero en el nodo especificado /// </summary> /// <param name="parentId">uuid del nodo donde queremos guardar el documento</param> /// <param name="documentPath">Ruta local de la que se debe sacar el fichero, aquí se devuelve la ruta del repositorio donde se ha guardado el documento</param> /// <param name="document">raw document, si este valor es null se intentará leer el documento del documentPath</param> /// <returns>uuid del documento que se ha salvado</returns> public string CreateFileByParentId(string parentId, ref string documentName, byte[] document) { if (document == null) { return(null); } string documentId = null; var mimeType = new MimetypeMap(); try { UpdateResult[] updateResult = CreateNode(parentId, null, Constants.TYPE_CONTENT); // work around to cast Alfresco.RepositoryWebService.Reference to Alfresco.ContentWebService.Reference RepositoryWebService.Reference rwsRef = updateResult[0].destination; ContentWebService.Reference newContentNode = new Alfresco.ContentWebService.Reference(); newContentNode.path = rwsRef.path; newContentNode.uuid = rwsRef.uuid; ContentWebService.Store cwsStore = new Alfresco.ContentWebService.Store(); cwsStore.address = Constants.SPACES_STORE; newContentNode.store = cwsStore; var contentFormat = new Alfresco.ContentWebService.ContentFormat(); contentFormat.mimetype = mimeType.GuessMimetype(Name); Content lContent = WebServiceFactory.getContentService().write(newContentNode, Constants.PROP_CONTENT, document, contentFormat); documentName = ISO9075.Decode(PathUtils.ConvertFromRepositoryPath(lContent.node.path)); documentId = lContent.node.uuid; } catch (SoapException ex) { if (ex.Detail.InnerText.Contains("DuplicateChildNodeNameException")) { var node = new NodeBase(); var nodePath = String.Format("{0}/{1}", node.GetPathById(parentId), System.IO.Path.GetFileName(documentName)); var id = node.GetIdByPath(nodePath); throw new DuplicateDocumentException(id, nodePath); } else { throw ex; } } catch (Exception ex) { throw ex; } return(documentId); }
private Content UpdateDocument(Alfresco.RepositoryWebService.Reference reference, byte[] document) { MimetypeMap mimeType = new MimetypeMap(); var newContentNode = new Alfresco.ContentWebService.Reference(); newContentNode.path = reference.path; newContentNode.uuid = reference.uuid; Alfresco.ContentWebService.Store cwsStore = new Alfresco.ContentWebService.Store(); cwsStore.address = Constants.SPACES_STORE; newContentNode.store = cwsStore; var contentFormat = new Alfresco.ContentWebService.ContentFormat(); contentFormat.mimetype = mimeType.GuessMimetype(Name); return(WebServiceFactory.getContentService().write(newContentNode, Constants.PROP_CONTENT, document, contentFormat)); }
private void btnUpload_Click(object sender, EventArgs e) { try { String file = this.textBox1.Text; if (file.Equals("")) { MessageBox.Show("Please select a file"); this.btnSelect.Focus(); return; } if (this.tbLocation.Text.Equals("")) { MessageBox.Show("Please select the location"); this.btnLocation.Focus(); return; } int start = file.LastIndexOf("\\") + 1; int length = file.Length - start; // get the filename only String fileName = file.Substring(start, length); if (file == null || file.Equals("")) { MessageBox.Show("please select a file"); return; } // Display a wait cursor while the file is uploaded Cursor.Current = Cursors.WaitCursor; // Initialise the reference to the spaces store Alfresco.RepositoryWebService.Store spacesStore = new Alfresco.RepositoryWebService.Store(); spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace; spacesStore.address = "SpacesStore"; // Create the parent reference, the company home folder Alfresco.RepositoryWebService.ParentReference parentReference = new Alfresco.RepositoryWebService.ParentReference(); parentReference.store = spacesStore; // parentReference.path = "/app:company_home"; parentReference.uuid = this.locationUuid; parentReference.associationType = Constants.ASSOC_CONTAINS; parentReference.childName = Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, fileName); // Create the properties list NamedValue nameProperty = new NamedValue(); nameProperty.name = Constants.PROP_NAME; nameProperty.value = fileName; nameProperty.isMultiValue = false; NamedValue[] properties = new NamedValue[2]; properties[0] = nameProperty; nameProperty = new NamedValue(); nameProperty.name = Constants.PROP_TITLE; nameProperty.value = fileName; nameProperty.isMultiValue = false; properties[1] = nameProperty; // Create the CML create object CMLCreate create = new CMLCreate(); create.parent = parentReference; create.id = "1"; create.type = Constants.TYPE_CONTENT; create.property = properties; // Create and execute the cml statement CML cml = new CML(); cml.create = new CMLCreate[] { create }; UpdateResult[] updateResult = repoService.update(cml); // work around to cast Alfresco.RepositoryWebService.Reference to // Alfresco.ContentWebService.Reference Alfresco.RepositoryWebService.Reference rwsRef = updateResult[0].destination; Alfresco.ContentWebService.Reference newContentNode = new Alfresco.ContentWebService.Reference(); newContentNode.path = rwsRef.path; newContentNode.uuid = rwsRef.uuid; Alfresco.ContentWebService.Store cwsStore = new Alfresco.ContentWebService.Store(); cwsStore.address = "SpacesStore"; spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace; newContentNode.store = cwsStore; // Open the file and convert to byte array FileStream inputStream = new FileStream(file, FileMode.Open); int bufferSize = (int)inputStream.Length; byte[] bytes = new byte[bufferSize]; inputStream.Read(bytes, 0, bufferSize); inputStream.Close(); Alfresco.ContentWebService.ContentFormat contentFormat = new Alfresco.ContentWebService.ContentFormat(); contentFormat.mimetype = mimeType.GuessMimetype(file); WebServiceFactory.getContentService().write(newContentNode, Constants.PROP_CONTENT, bytes, contentFormat); // Reset the cursor to the default for all controls. Cursor.Current = Cursors.Default; MessageBox.Show(file + " uploaded"); } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); MessageBox.Show(ex.StackTrace); } }
/// <remarks/> public void writeAsync(Reference node, string property, byte[] content, ContentFormat format) { this.writeAsync(node, property, content, format, null); }
public Content write(Reference node, string property, [System.Xml.Serialization.XmlElementAttribute(DataType = "base64Binary")] byte[] content, ContentFormat format) { object[] results = this.Invoke("write", new object[] { node, property, content, format }); return((Content)(results[0])); }
private Content UpdateDocument(Alfresco.RepositoryWebService.Reference reference, byte[] document) { MimetypeMap mimeType = new MimetypeMap(); var newContentNode = new Alfresco.ContentWebService.Reference(); newContentNode.path = reference.path; newContentNode.uuid = reference.uuid; Alfresco.ContentWebService.Store cwsStore = new Alfresco.ContentWebService.Store(); cwsStore.address = Constants.SPACES_STORE; newContentNode.store = cwsStore; var contentFormat = new Alfresco.ContentWebService.ContentFormat(); contentFormat.mimetype = mimeType.GuessMimetype(Name); return WebServiceFactory.getContentService().write(newContentNode, Constants.PROP_CONTENT, document, contentFormat); }
/// <summary> /// Guarda un fichero en el nodo especificado /// </summary> /// <param name="parentId">uuid del nodo donde queremos guardar el documento</param> /// <param name="documentPath">Ruta local de la que se debe sacar el fichero, aquí se devuelve la ruta del repositorio donde se ha guardado el documento</param> /// <param name="document">raw document, si este valor es null se intentará leer el documento del documentPath</param> /// <returns>uuid del documento que se ha salvado</returns> public string CreateFileByParentId(string parentId, ref string documentName, byte[] document) { if (document == null) return null; string documentId = null; var mimeType = new MimetypeMap(); try { UpdateResult[] updateResult = CreateNode(parentId, null, Constants.TYPE_CONTENT); // work around to cast Alfresco.RepositoryWebService.Reference to Alfresco.ContentWebService.Reference RepositoryWebService.Reference rwsRef = updateResult[0].destination; ContentWebService.Reference newContentNode = new Alfresco.ContentWebService.Reference(); newContentNode.path = rwsRef.path; newContentNode.uuid = rwsRef.uuid; ContentWebService.Store cwsStore = new Alfresco.ContentWebService.Store(); cwsStore.address = Constants.SPACES_STORE; newContentNode.store = cwsStore; var contentFormat = new Alfresco.ContentWebService.ContentFormat(); contentFormat.mimetype = mimeType.GuessMimetype(Name); Content lContent = WebServiceFactory.getContentService().write(newContentNode, Constants.PROP_CONTENT, document, contentFormat); documentName = ISO9075.Decode(PathUtils.ConvertFromRepositoryPath(lContent.node.path)); documentId = lContent.node.uuid; } catch (SoapException ex) { if (ex.Detail.InnerText.Contains("DuplicateChildNodeNameException")) { var node = new NodeBase(); var nodePath = String.Format("{0}/{1}", node.GetPathById(parentId), System.IO.Path.GetFileName(documentName)); var id = node.GetIdByPath(nodePath); throw new DuplicateDocumentException(id, nodePath); } else throw ex; } catch (Exception ex) { throw ex; } return documentId; }
/// <remarks/> public void writeAsync(Reference node, string property, byte[] content, ContentFormat format, object userState) { if ((this.writeOperationCompleted == null)) { this.writeOperationCompleted = new System.Threading.SendOrPostCallback(this.OnwriteOperationCompleted); } this.InvokeAsync("write", new object[] { node, property, content, format}, this.writeOperationCompleted, userState); }
public Content write(Reference node, string property, [System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")] byte[] content, ContentFormat format) { object[] results = this.Invoke("write", new object[] { node, property, content, format}); return ((Content)(results[0])); }