Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C# API Classification Problem

Status
Not open for further replies.

FloKro

Programmer
Apr 20, 2017
2
AT
Hey there folks, I got a problem regarding the Classification of OpenText's LiveLink Contentserver.

My UWP App got access via OpenLink's C# API. Creating documents is no problem, but there seem's to be an issue with the classification of the document.
I got my classification template from the Content Server with the ID, the document is listed with the classification, but the GUI from the Content Server does not show the classification.

Code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Json;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using ContentServerTest.CWS;
using Newtonsoft.Json;

namespace ContentServerTest
{
    class Program
    {

        private static OTAuthentication _otAuth = new OTAuthentication();

        private const int OfferCatId = 18582094;
  
        private const string FilePath = @"C:\Users\Desktop\Testtxt.txt";

        private static readonly Dictionary<string, object> MetadataValues = new Dictionary<string, object>
        {
            {"Anmerkungen", "Test"},
            {"Dateinamen", "Test1"},
            {"Erstelldatum", DateTime.Now},
            {"GFNR", "000123456"},
            {"GPNR", "123456"},
            {"LSID", "123"},
            {"Produkt", "testprodukt"}
        };
              
        static void Main(string[] args)
        {

            var docManClient = new DocumentManagementClient();
        
            Authenticate();
          
            #region uploaddocument

            var fileInfo = new FileInfo(FilePath);
            var contents = File.ReadAllBytes(FilePath);

            try
            {
               
                var node = docManClient.CreateDocument(ref _otAuth, GetNodeId(), fileInfo.Name, string.Empty, false, CreateMetadata(), CreateAttachment(fileInfo, contents));
                //var version = docManClient.AddVersion(ref _otAuth, node.ID, CreateMetadata(), CreateAttachment(fileInfo, contents));
               
                var node3 = docManClient.GetNodeByName(ref _otAuth, GetNodeId(), "Testtxt.txt");
                
                Console.WriteLine("Success");
            }
            catch (FaultException e)
            {
                Console.WriteLine("{0} : {1}\n", e.Code.Name, e.Message);
                Console.ReadLine();
                return;
            }

            #endregion

            
            Console.ReadLine();
        }

        private static Metadata CreateMetadata()
        {
            var docManClient = new DocumentManagementClient();

            var categoryTemplate = docManClient.GetCategoryTemplate(ref _otAuth, OfferCatId);

            foreach (var t in categoryTemplate.Values)
            {
                if (t is StringValue)
                {
                    ((StringValue)t).Values = new[]
                        {MetadataValues[t.Description] as string};
                }
                else if (t is DateValue)
                {
                    ((DateValue)t).Values = new[]
                        {(DateTime?) MetadataValues[t.Description]};
                }
            }

            return new Metadata { AttributeGroups = new[] { categoryTemplate } };
        }

        private static FileAtts CreateFileAttributes(FileInfo fileInfo)
        {
            return new FileAtts
            {
                CreatedDate = fileInfo.CreationTime,
                FileName = fileInfo.Name,
                FileSize = fileInfo.Length,
                ModifiedDate = fileInfo.LastWriteTime
            };
        }

        private static FileStream CreateFileStream()
        {
            return new FileStream(FilePath, FileMode.Open, FileAccess.Read);
        }

        private static Attachment CreateAttachment(FileInfo fileInfo, byte[] contents)
        {
            return new Attachment
            {
                Contents = contents,
                CreatedDate = fileInfo.CreationTime,
                FileName = fileInfo.Name,
                FileSize = contents.Length,
                ModifiedDate = fileInfo.LastWriteTime
            };
        }

       
        private static int GetNodeId()
        {
            using (var docManClient = new DocumentManagementClient())
            {
                var rootNode = docManClient.GetRootNode(ref _otAuth, "EnterpriseWS");
                return docManClient.GetNodeByPath(ref _otAuth, rootNode.ID, new[] { // Path }).ID;
            }
        }

        private static void Authenticate()
        {
           // does Authenticate with the server


        }
    }
}


With CreateDocument() I fetch the ClassifcationTemplate with the offercatId, the Metadatavalues are also rightfully set, but I seem to miss something. Where/How can I set it in my C# Programm the way it is shown in the GUI ContentServer? docManClient.GetNodeByPath(ref _otAuth, rootNode.ID, new[] { //Classification Path }).ID returns the right ID, so the Node is where it's supposed to be, but the classification isn't set. And there does not exist any Documentation for the services I use from the API.

Best regards,

Florian
 
Two things to help you.

1)Classification/RM Classification is yet another term that is used in Livelink.For this purpose I think you are calling the MetaData Template a.k.a Categories/Attributes as "classification" is that right?.If you are intending to do Classifications in its true sense then your client code should download the Classification WSDL Proxies or the RMClassification WSDL Proxies which are two additional wsdl end points provided by OT.
2)If you intend to do metadata to a node so that it becomes visible when you click the "Categories" function in livelink here is the correct flow of action with psuedocode

a)Allocate a Node of some type like Folder/document
b)Get the metadata template either from the category object definition or template as the OT example shows,or from another Object like the folder.Once you get the template you can change its values etc putting where required values are.In the OT example they create the category definition object right before a new document node is created.However that is only showing it can be done.All the time programmers would only be "Applying" a previously obtained category.In my blog i have written some useful articles most of them are in C# and some in java.

I would suggest trying to d this manually using the GUI as if the code does.Actually I see no problem in your code per se but you can only debug so much in a forum.

I would write an auxilary program just getting this value categoryTemplate and then an existing node in livelink with a GetNode to compare those structures.My blog has info on how to debug more etc.Also you could try SOAPUI as well.

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008,Livelink ECM Champion 2010
 
Hello appnair, thanks for your reply.

It was indeed your first solution. I did not have the end points you mentioned. I was intending to do the Classification in it's true sense, apologies for the misunderstanding there.

Best regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top