Hi... I need your help with Documentum

gcamou
edited January 8, 2009 in Documentum #1

First of all excuse my English because it is very bad and I used a translator.

i am new in Documentum... I am developer.. and I need to do a program to upload files to my repository

but I can not get the format of the files ...

v.g but class FileContent .... How to know if I have a *.doc that this is a msw8

Header 1

        public Form1()
        {
            InitializeComponent();

            serviceFactory = ServiceFactory.Instance;
        }

      

        private void Form1_Load(object sender, EventArgs e)
        {
            objectService = serviceFactory.GetRemoteService<IObjectService>(
                GetServiceContext(repository, userName, password, domain), serviceModule, contextRoot);
        }

      

        private void btnCreateFolder_Click(object sender, EventArgs e)
        {
            CreateCabinet(folderPath, repository);
        }

      

        private void btnUpLoadFile_Click(object sender, EventArgs e)
        {
            openFileDialog.Filter = "all File|*.*";

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string objectName = Path.GetFileName(openFileDialog.FileName);
                objectName = objectName.Substring(0, objectName.IndexOf('.'));

                string typeObject = Path.GetExtension(openFileDialog.FileName);
                typeObject = typeObject.Substring(1);

                the problem is here!!!

                if typeObject is "txt" the program fails as it should be "text" or "crtext" not to fail, how can I get those values

                BuildObject(repository, typeObjectIdentity, objectName, subject, title, keywords, typeObject, openFileDialog.FileName);

                MessageBox.Show("Listo...!");
            }
        }

      

        private void CreateCabinet(string folderPath, string repositoryName)
        {
            try { objectService.CreatePath(new ObjectPath(folderPath), repositoryName); }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }

      

        private void BuildObject(string repositoryName, string typeObjectIdentity, string objectName, string subject, string title, string[] keywords, string typeObject, string contentPath)
        {
            DataPackage dataPackage = new DataPackage();

            try
            {
                ReferenceRelationship referenceRelationship = setReferenceRelationship(folderPath, repositoryName);

                Emc.Documentum.FS.DataModel.Core.DataObject dataObject
                    = new Emc.Documentum.FS.DataModel.Core.DataObject(new ObjectIdentity(repositoryName), typeObjectIdentity);

                dataObject.Properties.Set("object_name", objectName);
                dataObject.Properties.Set("subject", subject);
                dataObject.Properties.Set("title", title);
                dataObject.Properties.Set("keywords", keywords);
                dataObject.Properties.Set("a_content_type", typeObject);

                if (!File.Exists(contentPath)) MessageBox.Show("The file: " + contentPath + " does not exist");
                dataObject.Contents.Add(new FileContent(contentPath, typeObject));

                dataObject.Relationships.Add(referenceRelationship);

                dataPackage.AddDataObject(dataObject);

                OperationOptions operationOptions = null;
                objectService.Create(dataPackage, operationOptions);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

      

        private IServiceContext GetServiceContext(string repositoryName, string userName, string password, string domain)
        {
            IServiceContext serviceContext = ContextFactory.Instance.NewContext();
            try
            {
                serviceContext.AddIdentity(new RepositoryIdentity(repositoryName, userName, password, domain));

                ContentTransferProfile contentTransferProfile = new ContentTransferProfile();

                contentTransferProfile.TransferMode = ContentTransferMode.MTOM;
                contentTransferProfile.Geolocation = "Pleasanton";

                serviceContext.SetProfile(contentTransferProfile);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
       
            return serviceContext;
        }
       
        private ReferenceRelationship setReferenceRelationship(string folderPath, string repository)
        {
            ReferenceRelationship referenceRelationship = new ReferenceRelationship();

            try
            {
                ObjectIdentity objectIdentity = new ObjectIdentity(new ObjectPath(folderPath), repository);

                referenceRelationship.Name = Relationship.RELATIONSHIP_FOLDER;
                referenceRelationship.Target = objectIdentity;
                referenceRelationship.TargetRole = Relationship.ROLE_PARENT;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
           
            return referenceRelationship;
        }

thanks....

Comments

  • ealvarez
    edited January 8, 2009 #2

    It seems you are trying to use the DOS extention rather than the format name. The format name is defined in a dm_format object so I guess you could query for it if you wanted.

    Have you tried not defining that property? DFC Operations used to take the default value defined on dm_format objects when the extention was part of the name and I believe DFS does the same, but this early in the morning I'm not sure.

  • aflowers001
    edited January 8, 2009 #3

    Hi,

    If I recall right you don't need to set the a_content_type, this will be done behind the scenes for you when you make the call into DFS, it works it out based on the name of the file being uploaded. You might want to confirm this as I don't have access to a development machine to test the theory.

    On a separate, but related, point, you might want to consider moving the business logic to a custom DFS service (or an SBO fronted by a custom DFS service). That way clients can call into your service without needing to know too much about Documentum, DFC, DFS etc. as they will call a business logic specific method such as CreateMyBusinessDocument(...params...) and you could double wrap the generated client side code such that they don't even have to know that DFS is being used, all the call is your actual method and the underlying client side implementation takes care of the plumbing.

  • gcamou
    edited January 8, 2009 #4
    thanks guys, but I think I explained well ...

    I want to do is get the format that corresponds to the extensions txt, pdf, doc, docx, etc. .... regarding the format or extensions of Documentum

    e.v.
    private string getFormat(string extension)
    ......
    string extension = "doc";
    string result = "";
    result = getFormat(extension);
    console.writeline("The format is: ", result);
    .......
    The format is: msw8
    ........
    the table to convert is....
    Table 5. Documentum format mapping
    DescriptionDocumentum name
    (includes Office 2003)
    Documentum name
    (Office 2007 only)
    CAD drawings (DWF,
    DWG)
    acad
    Corel WordPerfect (WPD)wpd8, wpd10
    HTMLhtml
    Microsoft Excel (XLS)excel8bookexcel12book
    Microsoft Excel (XLT)excel8templateexcel12template
    Microsoft PowerPoint (POT)ppt8_templateppt12template
    Microsoft PowerPoint (PPT)ppt8ppt12
    Microsoft Visio (VSD)vsd, vsd1, vsd2, vsd3, vsd4
    Microsoft Word (DOC)msw8msw12
    Microsoft Word (DOT)msw8templatemsw12template
    PDFpdf

        thanks....
  • aflowers001
    edited January 8, 2009 #5

    Ok.

    DFC provides this via the getFormatRecognizer method if IDfClientX for a specific file name so you can wrap that up in a DFS service and call that

    or

    You can use a query of the form select name, description, mime_type, dos_extension from dm_format where dos_extension != ' ' to select the formats. See the object model reference for dm_format.

  • gcamou
    edited January 8, 2009 #6

    thank you very much ...

    went well with the query I need to prove the method ... but thank you very much indeed ...

  • gcamou
    edited January 8, 2009 #7

    Apology getFormatRecognizer this method within the class IDfClientX?

    namespace belongs to the class IDfClientX

  • aflowers001
    edited January 8, 2009 #8

    getFormatRecognizer is defined in the IDfClientX interface, which is implemented by DfClientX. Both are in the Java package com.documentum.com.

    As you mention namespace I assume your client is C#, if so you should be able to find the direct DFC packages in the PIA documentation.