<?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 Re: Problem with setting integer custom property when uploading document Using CMIS in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/problem-with-setting-integer-custom-property-when-uploading/m-p/85200#M25888</link>
    <description>&lt;P&gt;Can you share some source code?&lt;/P&gt;
&lt;P&gt;The description of your problem doesn't fit with any other issue related with CMIS I've heard of before...&lt;/P&gt;</description>
    <pubDate>Fri, 20 Sep 2019 09:34:46 GMT</pubDate>
    <dc:creator>angelborroy</dc:creator>
    <dc:date>2019-09-20T09:34:46Z</dc:date>
    <item>
      <title>Problem with setting integer custom property when uploading document Using CMIS</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/problem-with-setting-integer-custom-property-when-uploading/m-p/85199#M25887</link>
      <description>&lt;P&gt;While uploading document to Alfresco Content services using CMIS we are passing Metadata as Alfresco Custom Properties along with it. All Custom propertis are being accepted and document content uploaded, but values for some custom properties are not being set. Their values are shown as none. For example custom properties such as string, DateTime and long are bein set along with their values, but Custom property value for int (integer) is not being set in ACS(value is shown as (None).&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 07:48:12 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/problem-with-setting-integer-custom-property-when-uploading/m-p/85199#M25887</guid>
      <dc:creator>santolovic</dc:creator>
      <dc:date>2019-09-20T07:48:12Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with setting integer custom property when uploading document Using CMIS</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/problem-with-setting-integer-custom-property-when-uploading/m-p/85200#M25888</link>
      <description>&lt;P&gt;Can you share some source code?&lt;/P&gt;
&lt;P&gt;The description of your problem doesn't fit with any other issue related with CMIS I've heard of before...&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 09:34:46 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/problem-with-setting-integer-custom-property-when-uploading/m-p/85200#M25888</guid>
      <dc:creator>angelborroy</dc:creator>
      <dc:date>2019-09-20T09:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with setting integer custom property when uploading document Using CMIS</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/problem-with-setting-integer-custom-property-when-uploading/m-p/85201#M25889</link>
      <description>&lt;PRE&gt;public static AlfrescoSearchItem UploadDocument(string fileName, string filePath, string nodeName, SaveVersion version = null)
        { 
IDocument remoteDocument = null;

                IOperationContext oc = session.CreateOperationContext();
                oc.IncludeAcls = true;

                IFolder folder = session.GetRootFolder(oc);

                folder = (IFolder)session.GetObject(nodeName);

                IDictionary&amp;lt;string, object&amp;gt; properties = new Dictionary&amp;lt;string, object&amp;gt;();
                properties.Add(alfObjectType, $"D:{alfModelPrefix}:{alfModelType}");
                properties.Add(PropertyIds.Name, fileName);
                foreach (var prop in version.VersionProperties)
                {
                    if (!(prop.Name == DMS.pathMetaData))
                    {
                        SetAlfrescoProperty(prop, properties);
                    }
                }

                ContentStream contentStream = new ContentStream();
                contentStream.FileName = fileName;
                contentStream.MimeType = System.Web.MimeMapping.GetMimeMapping(fileName);
                contentStream.Stream = System.IO.File.OpenRead(filePath);

                remoteDocument = folder.CreateDocument(properties, contentStream, null);
}

 private static void SetAlfrescoProperty(VersionProperty prop, IDictionary&amp;lt;string, object&amp;gt; properties)
        {

            var alfrescoPropName = mappingProps.Where(x =&amp;gt; x.CTXPropName == prop.Name).Select(x =&amp;gt; x.AlfrescoPropName).FirstOrDefault();
            var alfrescoPropType = mappingProps.Where(x =&amp;gt; x.CTXPropName == prop.Name).Select(x =&amp;gt; x.PropTypeName).FirstOrDefault();
            switch (alfrescoPropType)
            {
                case "int":
                    long intConverted;
                    if (long.TryParse(prop.Value, out intConverted))
                    {
                        properties.Add(alfrescoPropName, intConverted);
                    }
                    else
                    {
                        var exc = new Exception($"Bad 'int' format in File property: {prop.Name} with value={prop.Value}");
                        exc.Data.Add(prop.Name.ToString(), prop.Value.ToString());
                        throw exc;

                    }
                    break;
                case "float":
                    float floatConverted;
                    if (float.TryParse(prop.Value, out floatConverted))
                    {
                        properties.Add(alfrescoPropName, floatConverted);
                    }
                    else
                    {
                        var exc = new Exception($"Bad 'float' format in File property: {prop.Name} with value={prop.Value}");
                        exc.Data.Add(prop.Name.ToString(), prop.Value.ToString());
                        throw exc;
                    }
                    break;
                case "long":
                    long longConverted;
                    if (long.TryParse(prop.Value, out longConverted))
                    {
                        properties.Add(alfrescoPropName, longConverted);
                    }
                    else
                    {
                        var exc = new Exception($"Bad 'long' format in File property: {prop.Name} with value={prop.Value}");
                        exc.Data.Add(prop.Name.ToString(), prop.Value.ToString());
                        throw exc;
                    }

                    break;
                case "double":
                    double doubleConverted;
                    if (double.TryParse(prop.Value, out doubleConverted))
                    {
                        properties.Add(alfrescoPropName, doubleConverted);
                    }
                    else
                    {
                        var exc = new Exception($"Bad 'double' format in File property: {prop.Name} with value={prop.Value}");
                        exc.Data.Add(prop.Name.ToString(), prop.Value.ToString());
                        throw exc;
                    }
                    break;
                case "dateTime":
                    DateTime dateTimeconverted;
                    if (DateTime.TryParse(prop.Value, out dateTimeconverted))
                    {
                        properties.Add(alfrescoPropName, dateTimeconverted);
                    }
                    else
                    {
                        var exc = new Exception($"Bad 'DateTime' format in File property: {prop.Name} with value={prop.Value}");
                        exc.Data.Add(prop.Name.ToString(), prop.Value.ToString());
                        throw exc;
                    }
                    break;
                case "boolean":
                    bool boolConverted;
                    if (bool.TryParse(prop.Value, out boolConverted))
                    {
                        properties.Add(alfrescoPropName, boolConverted);
                    }
                    else
                    {
                        var exc = new Exception($"Bad 'boolean' format in File property: {prop.Name} with value={prop.Value}");
                        exc.Data.Add(prop.Name.ToString(), prop.Value.ToString());
                        throw exc;
                    }
                    break;
                default:
                    properties.Add(alfrescoPropName, prop.Value);
                    break;
            }
        }&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Sep 2019 10:32:02 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/problem-with-setting-integer-custom-property-when-uploading/m-p/85201#M25889</guid>
      <dc:creator>santolovic</dc:creator>
      <dc:date>2019-09-20T10:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with setting integer custom property when uploading document Using CMIS</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/problem-with-setting-integer-custom-property-when-uploading/m-p/85202#M25890</link>
      <description>&lt;P&gt;I have found solution and you can see it in source code I have sent in previous post. I converted C# property to type long instead of&amp;nbsp; int and pass it to Alfresco property which is (in Alfresco Content service model) type of int.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 10:36:49 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/problem-with-setting-integer-custom-property-when-uploading/m-p/85202#M25890</guid>
      <dc:creator>santolovic</dc:creator>
      <dc:date>2019-09-20T10:36:49Z</dc:date>
    </item>
  </channel>
</rss>

