INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

C# API Classification Problem

C# API Classification Problem

(OP)
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 --> c#

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

RE: C# API Classification Problem

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 https://appukili.wordpress.com/ 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
http://www.tek-tips.com/faqs.cfm?fid=2884
http://www.linkedin.com/in/appunair
http://www.livelink.in

RE: C# API Classification Problem

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close