<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic CREATE A NEW DOCUMENT VERSION GIVE CONFLICT  in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/create-a-new-document-version-give-conflict/m-p/95255#M28052</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, am trying to create a document version on alfresco using c#, but i keep on getting conflict error. bellow is my&amp;nbsp;&lt;/P&gt;&lt;P&gt;private bool ConnectingUsingAtomPub_CreateDocumentNewVersion(string documentname, string retireefoldername, HttpPostedFileBase uploadedfile,string docID,string CheckInComment)&lt;BR /&gt; {&lt;BR /&gt; try&lt;BR /&gt; {&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;bool foldercreated = false;&lt;BR /&gt; // define dictonary with key value pair&lt;BR /&gt; Dictionary&amp;lt;string, string&amp;gt; parameters = new Dictionary&amp;lt;string, string&amp;gt;();&lt;/P&gt;&lt;P&gt;// define binding type, in our example we are using ATOMPUB as stated above&lt;BR /&gt; parameters[DotCMIS.SessionParameter.BindingType] = BindingType.AtomPub;&lt;/P&gt;&lt;P&gt;// define CMIS available path which is already available under alfresco&lt;BR /&gt; parameters[DotCMIS.SessionParameter.AtomPubUrl] = "http://localhost:8080/alfresco/cmisatom";&lt;/P&gt;&lt;P&gt;// alfresco portal admin user name&lt;BR /&gt; parameters[DotCMIS.SessionParameter.User] = "admin";&lt;/P&gt;&lt;P&gt;// alfresco portal admin password&lt;BR /&gt; parameters[DotCMIS.SessionParameter.Password] = "root";&lt;/P&gt;&lt;P&gt;// define session factory&lt;BR /&gt; SessionFactory factory = SessionFactory.NewInstance();&lt;/P&gt;&lt;P&gt;// using session factory get the default repository, on this repository we would be performing actions &amp;amp; create session on this repository&lt;BR /&gt; ISession session = factory.GetRepositories(parameters)[0].CreateSession();&lt;/P&gt;&lt;P&gt;// get the root folder in which we would be creating a new folder&lt;BR /&gt; IFolder rootfolder = session.GetRootFolder();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; IItemEnumerable&amp;lt;ICmisObject&amp;gt; rootchildrens = rootfolder.GetChildren();&lt;/P&gt;&lt;P&gt;ICmisObject tstdoc = rootchildrens.Where(a =&amp;gt; a.Name.ToLower() == "pension").FirstOrDefault();&lt;/P&gt;&lt;P&gt;IFolder Pesionfolder = tstdoc as IFolder;&lt;/P&gt;&lt;P&gt;IItemEnumerable&amp;lt;ICmisObject&amp;gt; pensionfolderchildrens = Pesionfolder.GetChildren();&lt;/P&gt;&lt;P&gt;ICmisObject theretireeIcm = pensionfolderchildrens.Where(a =&amp;gt; a.Name.ToLower() == retireefoldername.ToLower()).FirstOrDefault();&lt;/P&gt;&lt;P&gt;IFolder retireefolder = theretireeIcm as IFolder;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// define dictionary&lt;/P&gt;&lt;P&gt;Document doc = ((Document)session.GetObject(docID));&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; // Document doc = ((Document)session.GetObject("workspace://SpacesStore/c38e8efa-04dd-46e1-938c-a20884dff5ee"));&lt;BR /&gt; string objId = string.Empty;&lt;BR /&gt; Document pwc=null;&lt;BR /&gt; try&lt;BR /&gt; {&lt;/P&gt;&lt;P&gt;// checkout the doc&lt;BR /&gt; IObjectId Iobj = doc.CheckOut();&lt;BR /&gt; objId = Iobj.Id;&lt;BR /&gt; pwc = (Document)session.GetObject(Iobj);&lt;BR /&gt; // Response.Write("Checked out doc ID: " + objId);&lt;BR /&gt; }&lt;BR /&gt; catch (Exception cbe)&lt;BR /&gt; {&lt;BR /&gt; // cancel the checkout incase of exception&lt;BR /&gt; doc.CancelCheckOut();&lt;BR /&gt; // Response.Write("Exception checking out; must be checked out already: " + cbe.Message);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;// string versionlbl = "V"+(Convert.ToInt32(doc.VersionLabel)+0.1).ToString();&lt;BR /&gt; string lblvv = doc.VersionLabel;&lt;BR /&gt; // document name&lt;BR /&gt; // int inxex = documentname.IndexOf(".pdf");&lt;BR /&gt; string versionlbl = "V2.0";&lt;BR /&gt; string formattedName = versionlbl+"_"+documentname;&lt;BR /&gt; IDictionary&amp;lt;string, object&amp;gt; properties = new Dictionary&amp;lt;string, object&amp;gt;();&lt;BR /&gt; properties.Add(PropertyIds.Name, formattedName);&lt;/P&gt;&lt;P&gt;// define object type as document, as we wanted to create document&lt;BR /&gt; properties.Add(PropertyIds.ObjectTypeId, "cmis:document");&lt;BR /&gt; properties.Add(PropertyIds.ObjectId, objId);&lt;/P&gt;&lt;P&gt;BinaryReader rdr = new BinaryReader(uploadedfile.InputStream);&lt;BR /&gt; byte[] imageByte = rdr.ReadBytes((int)uploadedfile.ContentLength);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// read a empty document with empty bytes&lt;BR /&gt; // fileUpload1: is a .net file upload control&lt;BR /&gt; ContentStream contentStream = new ContentStream&lt;BR /&gt; {&lt;BR /&gt; FileName = formattedName,&lt;BR /&gt; //MimeType = "application/msword",&lt;BR /&gt; MimeType = "application/pdf",&lt;BR /&gt; Length = uploadedfile.InputStream.Length,&lt;BR /&gt; Stream = new MemoryStream(imageByte)&lt;BR /&gt; };&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; retireefolder.CreateDocument(properties, contentStream, DotCMIS.Enums.VersioningState.CheckedOut);&lt;BR /&gt; IObjectId ob = pwc.CheckIn(true, properties, null, CheckInComment);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; //IObjectId ob = doc.CheckIn(true, null, null, CheckInComment);&lt;BR /&gt; //addveriosn = doc.VersionLabel;&lt;BR /&gt; Document docd = (Document)session.GetObject(ob);&lt;BR /&gt; // Document newv = (Document)session.GetLatestDocumentVersion(ob);&lt;BR /&gt; return true;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; catch (Exception ex)&lt;BR /&gt; {&lt;BR /&gt; return false;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Jun 2019 16:44:31 GMT</pubDate>
    <dc:creator>abfrank</dc:creator>
    <dc:date>2019-06-25T16:44:31Z</dc:date>
    <item>
      <title>CREATE A NEW DOCUMENT VERSION GIVE CONFLICT</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/create-a-new-document-version-give-conflict/m-p/95255#M28052</link>
      <description>Hello, am trying to create a document version on alfresco using c#, but i keep on getting conflict error. bellow is my&amp;nbsp;private bool ConnectingUsingAtomPub_CreateDocumentNewVersion(string documentname, string retireefoldername, HttpPostedFileBase uploadedfile,string docID,string CheckInComment) { try</description>
      <pubDate>Tue, 25 Jun 2019 16:44:31 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/create-a-new-document-version-give-conflict/m-p/95255#M28052</guid>
      <dc:creator>abfrank</dc:creator>
      <dc:date>2019-06-25T16:44:31Z</dc:date>
    </item>
  </channel>
</rss>

