Cognos Analytics

 View Only
Expand all | Collapse all

Help with Importing Deployment Archive using the Cognos SDK in C#

  • 1.  Help with Importing Deployment Archive using the Cognos SDK in C#

    Posted Wed September 25, 2024 02:39 PM
    Edited by Marc Percy Tue October 01, 2024 07:45 AM

    Hello everyone, I'm not a C# programmer nor am I super familiar with the SDK, but I'm working on an automation script to import a deployment archive and I'm running into the following error in the DeployContent method (the line throwing the error is bold and red below):

    CM-REQ-4317 Content Manager cannot access the history object. 

    If anyone has successfully done this in C#, I would love some tips. Thank you.

    Here is the code that I call the Deployment methods (I took the java version and used Co-Pilot to help convert it to C#)

                            archiveName = "..\\deployment\\" + tenant.EamVersion + "EAM";
                            deployArchiveName = tenant.EamVersion + "EAM";
                            var deployment = new CognosDeployment();
                            var publicFolderContent = deployment.GetPubFolderContent(archiveName, c8CMS);
                            string[] selectedPubContent = CognosDeployment.GetSelectedPackageName(publicFolderContent);
                            string result = deployment.DeployContent("import", archiveName, deployArchiveName, selectedPubContent, c8CMS);

    Here is the contents of the CognosDeployment.cs that is the converted Deployment.java:

    EDITED TO ADD: This is the updated code that works! Originally the post contained the version that had issues, but I figured the working version would be more helpful for those trying to solve the same issue.

    using cognosdotnet_10_2;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Web.Services.Description;

    namespace Server_Config_SDK
    {
        internal class CognosDeployment
        {
            public const string strlocale = "en";

           // private Dictionary<string, searchPathSingleObject> packageInformation = new Dictionary<string, searchPathSingleObject>();
            private Dictionary<string, string> packageInformation = new Dictionary<string, string>();

            private static String DEPLOY_OPTION_NAME = "deploymentOptionObjectInformationArray";

            public string[] GetListOfArchives(contentManagerService1 connection)
            {
                string[] listOfArchives = null;
                try
                {
                    listOfArchives = connection.listArchives();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("An error occurred while retrieving archive list:" + "\n" + ex.Message);
                }

                return listOfArchives;
            }

            public string[] GetAllFolders(contentManagerService1 myCon)
            {
                baseClass[] listOfFolders = null;
                string[] allFolders = null;
                int count = 0;
                string packName = null;
                string packSearchPath = null;
                searchPathSingleObject myPackSearchPath = null;

                string[] mySearchPath = new string[2];
                mySearchPath[0] = "/content//package";
                mySearchPath[1] = "/content/folder";

                // get available packages
                baseClass[] packageList = GetCSObject(myCon, mySearchPath[0]);
                // get available folders
                baseClass[] folderList = GetCSObject(myCon, mySearchPath[1]);

                var packageInformation = new Dictionary<string, searchPathSingleObject>(packageList.Length + folderList.Length);

                for (int i = 0; i < packageList.Length; i++)
                {
                    packName = packageList[i].defaultName.value;
                    packSearchPath = packageList[i].searchPath.value;
                    myPackSearchPath = new searchPathSingleObject();
                    myPackSearchPath.Value = packSearchPath;
                    packageInformation[packName] = myPackSearchPath;
                }

                for (int j = 0; j < folderList.Length; j++)
                {
                    packName = folderList[j].defaultName.value;
                    packSearchPath = folderList[j].searchPath.value;
                    myPackSearchPath = new searchPathSingleObject();
                    myPackSearchPath.Value = packSearchPath;
                    packageInformation[packName] = myPackSearchPath;
                }

                listOfFolders = new baseClass[packageList.Length + folderList.Length];
                allFolders = new string[packageList.Length + folderList.Length];

                if (packageList != null && packageList.Length > 0)
                {
                    for (int j = 0; j < packageList.Length; j++)
                    {
                        listOfFolders[count] = packageList[j];
                        allFolders[count] = listOfFolders[count].ToString();
                        count++;
                    }
                }

                if (folderList != null && folderList.Length > 0)
                {
                    for (int i = 0; i < folderList.Length; i++)
                    {
                        listOfFolders[count] = folderList[i];
                        allFolders[count] = listOfFolders[count].ToString();
                        count++;
                    }
                }

                return allFolders;
            }

            public static string[] GetSelectedPackageName(Dictionary<string, string> selectedPackageNamePath)
            {
                string[] selectedPackage = null;

                if (selectedPackageNamePath.Count > 0)
                {
                    var mySelectedPackage = selectedPackageNamePath.Keys.ToArray();
                    selectedPackage = new string[mySelectedPackage.Length];
                    for (int n = 0; n < mySelectedPackage.Length; n++)
                    {
                        selectedPackage[n] = mySelectedPackage[n];
                    }
                }
                return selectedPackage;
            }


            public baseClass[] GetCSObject(contentManagerService1 con, string myPathStr)
            {
                searchPathMultipleObject cmSearchPath = new searchPathMultipleObject();
                cmSearchPath.Value = myPathStr;
                baseClass[] myCMObject = null;

                propEnum[] props = new propEnum[] { propEnum.searchPath, propEnum.defaultName };
                sort[] sortOptions = { new sort() };
                sortOptions[0].order = orderEnum.ascending;
                sortOptions[0].propName = propEnum.defaultName;

                try
                {
                    myCMObject = con.query(cmSearchPath, props, sortOptions, new queryOptions());
                }
                catch (Exception ex)
                {
                    Console.WriteLine("An error occurred while querying CM object:\n" + ex.Message);
                }

                return myCMObject;
            }

            //public Dictionary<string, searchPathSingleObject> GetPubFolderContent(string myArchive, contentManagerService1 myConnection)
            public Dictionary<string, string> GetPubFolderContent(string myArchive, contentManagerService1 myConnection)
            {
                option[] deployOptEnum = new option[] { };
                //Dictionary<string, searchPathSingleObject> arrOfPublicFolder = new Dictionary<string, searchPathSingleObject>();
                Dictionary<string, string> arrOfPublicFolder = new Dictionary<string, string>();

                try
                {
                    deployOptEnum = myConnection.getDeploymentOptions(myArchive, new option[] { });

                    foreach (var option in deployOptEnum)
                    {
                        string oName = option.GetType().Name;
                        if (oName.Equals(DEPLOY_OPTION_NAME))
                        {
                            var packDeployInfo = ((deploymentOptionObjectInformationArray)option).value;
                            foreach (var info in packDeployInfo)
                            {
                                string packFoldername = info.defaultName;
                                searchPathSingleObject packagePath = info.searchPath;
                                string strPackagePath = packagePath.Value;
                                arrOfPublicFolder[packFoldername] = strPackagePath;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("An error occurred in getting Deployment options." + "\n" + "The error: " + e.Message);
                }
                //packageInformation = new Dictionary<string, searchPathSingleObject>(arrOfPublicFolder);
                packageInformation = new Dictionary<string, string>(arrOfPublicFolder);

                return arrOfPublicFolder;
            }

            public string DeployContent(string myDeployType, string strArchiveName, string strDeployArchive, string[] selectedPubContent, contentManagerService1 connection)
            {
                asynchReply asynchReply = null;
                string reportEventID = "-1";

                string deployPath;
                searchPathSingleObject searchPathObject = new searchPathSingleObject();

                baseClass[] ArchiveInfo = AddArchive(myDeployType, strArchiveName, connection);

                if (ArchiveInfo != null && ArchiveInfo.Length == 1)
                {
                    deployPath = ArchiveInfo[0].searchPath.value;
                    searchPathObject.Value = deployPath;
                }
                else
                {
                    return reportEventID;
                }

                option[] myDeploymentOptionsEnum = null;
                if (myDeployType.Equals("import", StringComparison.OrdinalIgnoreCase))
                {
                    myDeploymentOptionsEnum = SetdeploymentOptionEnum(myDeployType, strDeployArchive, selectedPubContent, connection);
                }


                optionArrayProp deploymentOptionsArray = new optionArrayProp();
                deploymentOptionsArray.value = myDeploymentOptionsEnum;
                if (myDeployType.Equals("import", StringComparison.OrdinalIgnoreCase))
                {
                    ((importDeployment)ArchiveInfo[0]).options = deploymentOptionsArray;
                }


                try
                {
                    connection.update(ArchiveInfo, new updateOptions());
                    option[] arConnectRunOpt = new option[] { };
                    parameterValue[] arConnectRunParam = new parameterValue[] { };
                    monitorService1 monSrv = new monitorService1();
                    monSrv.Url = connection.Url;
                    monSrv.biBusHeaderValue = connection.biBusHeaderValue;
                    asynchReplyVar = monSrv.run(searchPathObject, arConnectRunParam, arConnectRunOpt);
                }
                catch (Exception remoteEx)
                {
                    Console.WriteLine("An error occurred while deploying content:" + "\n" + remoteEx.Message);
                }

                if (asynchReply != null)
                {
                    reportEventID = "Success";
                }
                else
                {
                    reportEventID = "Failed";
                }
                return reportEventID;
            }

            private baseClass[] AddArchive(string deploySpec, string nameOfArchive, contentManagerService1 con)
            {
                importDeployment importDeploy = null;
                exportDeployment exportDeploy = null;
                baseClass[] addedDeploymentObjects = null;
                baseClass[] bca = new baseClass[1];
                addOptions addOpts = null;

                searchPathSingleObject objOfSearchPath = new searchPathSingleObject();
                objOfSearchPath.Value = "/adminFolder";

                multilingualTokenProp multilingualTokenProperty = new multilingualTokenProp();
                multilingualToken[] multilingualTokenArr = new multilingualToken[1];
                multilingualToken myMultilingualToken = new multilingualToken();

                myMultilingualToken.locale = strlocale;
                myMultilingualToken.value = nameOfArchive;
                multilingualTokenArr[0] = myMultilingualToken;
                multilingualTokenProperty.value = multilingualTokenArr;

                if (deploySpec.Equals("import", StringComparison.OrdinalIgnoreCase))
                {
                    importDeploy = new importDeployment();
                    addOpts = new addOptions();
                    importDeploy.name = multilingualTokenProperty;
                    addOpts.updateAction = updateActionEnum.replace;
                    bca[0] = importDeploy;
                }
                else
                {
                    exportDeploy = new exportDeployment();
                    addOpts = new addOptions();
                    exportDeploy.name = multilingualTokenProperty;
                    addOpts.updateAction = updateActionEnum.replace;
                    bca[0] = exportDeploy;
                }

                try
                {
                    addedDeploymentObjects = con.add(objOfSearchPath, bca, addOpts);
                }
                catch (Exception remoEx)
                {
                    Console.WriteLine("An error occurred when adding a deployment object:" + "\n" + remoEx.Message);
                }

                return addedDeploymentObjects;
            }

            private option[] SetdeploymentOptionEnum(string deploymentType, string nameOfArchive, string[] listOfSelectedFolders, contentManagerService1 con)
            {
                List<option> deploymentOptions = new List<option>();
                int num = 0;
                int eOptionCount = 2;

                string[] deployOptionEnumBoolean = { "archiveOverwrite", "dataSourceSelect", "namespaceSelect", "namespaceThirdParty", "objectPolicies", "packageHistories", "packageOutputs", "packageSchedules", "packageSelect", "recipientsSelect", "takeOwnership", "packageDatasetOutputs" };

                string[] deployOptionEnumResolution = { "dataSourceConflictResolution", "namespaceConflictResolution", "objectPoliciesConflictResolution", "ownershipConflictResolution", "packageHistoriesConflictResolution", "packageOutputsConflictResolution", "packageSchedulesConflictResolution", "recipientsConflictResolution", "packageDatasetOutputsConflictResolution" };
                var deployOption = new deploymentOptionEnum();

                deploymentOptions.Capacity = eOptionCount + deployOptionEnumBoolean.Length + deployOptionEnumResolution.Length;

                // Define the deployment options
                deploymentOptions.Add(SetImportDeploymentOptionPackageInfo(listOfSelectedFolders));

                deploymentOptions.Add(SetDeploymentOptionString(nameOfArchive));
                // change default value into 'true'
                deploymentOptions.Add(SetArchiveOverWrite(true));
                // use default value
                deploymentOptions.Add(SetDataSourceSelect(false));
                // use default value
                deploymentOptions.Add(SetNameSpaceSelect(false));
                // change default value into 'false'
                deploymentOptions.Add(SetNameSpaceThirdParty(false));
                // use default value
                deploymentOptions.Add(SetObjectPolicies(false));
                // use default value
                deploymentOptions.Add(SetPackageHistories(false));
                // use default value
                deploymentOptions.Add(SetPackageOutputs(false));
                // use default value
                deploymentOptions.Add(SetPackageSchedules(false));
                // use default value
                deploymentOptions.Add(SetPackageSelect(true));
                // use default value
                deploymentOptions.Add(SetRecipientsSelect(false));
                // change default value into 'true'
                deploymentOptions.Add(SetTakeOwnership(true));
                // this sample uses 'false' (default) value for export and 'true' for import
                if (deploymentType.Equals("import", StringComparison.OrdinalIgnoreCase))
                {
                    deploymentOptions.Add(SetPackageDatasetOutputs(true));
                }
                // use default value
                deploymentOptions.Add(SetDataSourceConflictResolution(true));
                // use default value
                deploymentOptions.Add(SetNamespaceConflictResolution(true));
                // use default value
                deploymentOptions.Add(SetObjectPoliciesConflictResolution(true));
                // use default value
                deploymentOptions.Add(SetOwnershipConflictResolution(true));
                // use default value
                deploymentOptions.Add(SetPackageHistoriesConflictResolution(true));
                // use default value
                deploymentOptions.Add(SetPackageOutputsConflictResolution(true));
                // use default value
                deploymentOptions.Add(SetPackageSchedulesConflictResolution(true));
                // use default value
                deploymentOptions.Add(SetRecipientsConflictResolution(true));
                // use default value
                deploymentOptions.Add(SetPackageDatasetOutputsConflictResolution(true));

                return deploymentOptions.ToArray();
            }


            // set import deployment option property (mandatory)
            private deploymentOptionImportRuleArray SetImportDeploymentOptionPackageInfo(string[] arrOfFolders)
            {
                var pkgDeployInfoArr = new deploymentImportRule[arrOfFolders.Length];
                deploymentImportRule pkgDeployInfo;
                multilingualToken[] multilingualTokenArr;
                multilingualToken multilingualToken;
                searchPathSingleObject packSearchPath = null;

                for (int i = 0; i < arrOfFolders.Length; i++)
                {
                    multilingualToken = new multilingualToken();
                    multilingualTokenArr = new multilingualToken[1];

                    pkgDeployInfo = new deploymentImportRule();

                    multilingualToken.locale = strlocale;
                    multilingualToken.value = arrOfFolders[i];
                    multilingualTokenArr[0] = multilingualToken;

                    string myPackageName = arrOfFolders[i];
                    //var myPackInfo = new Dictionary<string, searchPathSingleObject>(packageInformation);
                    var myPackInfo = new Dictionary<string, string>(packageInformation);

                    if (myPackInfo.ContainsKey(myPackageName))
                    {
                        packSearchPath = new searchPathSingleObject();
                        packSearchPath.Value = myPackInfo[myPackageName];
                    }

                    pkgDeployInfo.archiveSearchPath = packSearchPath;
                    pkgDeployInfo.name = multilingualTokenArr;
                    pkgDeployInfo.parent = new searchPathSingleObject();
                    pkgDeployInfo.parent.Value = "/content";
                    pkgDeployInfoArr[i] = pkgDeployInfo;
                }

                var deployOptionPkgInfo = new deploymentOptionImportRuleArray
                {
                    name = deploymentOptionEnum.import,
                    value = pkgDeployInfoArr
                };

                return deployOptionPkgInfo;
            }

            // set DeploymentOptionString property (mandatory)
            private deploymentOptionString SetDeploymentOptionString(string archiveName)
            {
                var archiveDefault = new multilingualString
                {
                    locale = strlocale,
                    value = archiveName
                };

                var deployOptionStr = new deploymentOptionString
                {
                    name = deploymentOptionEnum.archive,
                    value = archiveDefault.value
                };

                return deployOptionStr;
            }

            // allow the deployment overwrites the archive
            private deploymentOptionBoolean SetArchiveOverWrite(bool setValue)
            {
                var deployOptionBool = new deploymentOptionBoolean
                {
                    name = deploymentOptionEnum.archiveOverwrite,
                    value = !setValue
                };
                return deployOptionBool;
            }

            // set dataSourceSelect as default value - 'false'
            private deploymentOptionBoolean SetDataSourceSelect(bool setValue)
            {
                var deployOptionBool = new deploymentOptionBoolean
                {
                    name = deploymentOptionEnum.dataSourceSelect,
                    value = !setValue
                };
                return deployOptionBool;
            }

            // set namespaceSelect as default value - 'false'
            private deploymentOptionBoolean SetNameSpaceSelect(bool setValue)
            {
                var deployOptionBool = new deploymentOptionBoolean
                {
                    name = deploymentOptionEnum.namespaceSelect,
                    value = !setValue
                };
                return deployOptionBool;
            }

            // Not include references to external namespaces - value is false
            private deploymentOptionBoolean SetNameSpaceThirdParty(bool setValue)
            {
                var deployOptionBool = new deploymentOptionBoolean
                {
                    name = deploymentOptionEnum.namespaceThirdParty,
                    value = setValue
                };
                return deployOptionBool;
            }

            // set objectPolicies as default value - 'false'
            private deploymentOptionBoolean SetObjectPolicies(bool setValue)
            {
                var deployOptionBool = new deploymentOptionBoolean
                {
                    name = deploymentOptionEnum.objectPolicies,
                    value = !setValue
                };
                return deployOptionBool;
            }

            // set packageHistories as default value - 'false'
            private deploymentOptionBoolean SetPackageHistories(bool setValue)
            {
                var deployOptionBool = new deploymentOptionBoolean
                {
                    name = deploymentOptionEnum.packageHistories,
                    value = !setValue
                };
                return deployOptionBool;
            }

            // set packageOutputs as default value - 'false'
            private deploymentOptionBoolean SetPackageOutputs(bool setValue)
            {
                var deployOptionBool = new deploymentOptionBoolean
                {
                    name = deploymentOptionEnum.packageOutputs,
                    value = !setValue
                };
                return deployOptionBool;
            }

            // set packageSchedules as default value - 'false'
            private deploymentOptionBoolean SetPackageSchedules(bool setValue)
            {
                var deployOptionBool = new deploymentOptionBoolean
                {
                    name = deploymentOptionEnum.packageSchedules,
                    value = !setValue
                };
                return deployOptionBool;
            }

            // set packageSelect as default value - 'true'
            private deploymentOptionBoolean SetPackageSelect(bool setValue)
            {
                var deployOptionBool = new deploymentOptionBoolean
                {
                    name = deploymentOptionEnum.packageSelect,
                    value = setValue
                };
                return deployOptionBool;
            }

            // set recipientsSelect as default value - 'false'
            private deploymentOptionBoolean SetRecipientsSelect(bool setValue)
            {
                var deployOptionBool = new deploymentOptionBoolean
                {
                    name = deploymentOptionEnum.recipientsSelect,
                    value = !setValue
                };
                return deployOptionBool;
            }

            // set the owner to the owner from the source - the value is 'true'
            private deploymentOptionBoolean SetTakeOwnership(bool setValue)
            {
                var deployOptionBool = new deploymentOptionBoolean
                {
                    name = deploymentOptionEnum.takeOwnership,
                    value = !setValue
                };
                return deployOptionBool;
            }

            // set upload data for packages - the default value is 'false' (this sample uses 'true' for import)
            private deploymentOptionBoolean SetPackageDatasetOutputs(bool setValue)
            {
                var deployOptionBool = new deploymentOptionBoolean
                {
                    name = deploymentOptionEnum.packageDatasetOutputs,
                    value = setValue
                };
                return deployOptionBool;
            }

            // set dataSourceConflictResolution as default value - 'replace'
            private deploymentOptionResolution SetDataSourceConflictResolution(bool setValue)
            {
                var deployOptionResolute = new deploymentOptionResolution
                {
                    name = deploymentOptionEnum.dataSourceConflictResolution,
                    value = setValue ? conflictResolutionEnum.replace : conflictResolutionEnum.keep
                };
                return deployOptionResolute;
            }

            // set namespaceConflictResolution as default value - 'replace'
            private deploymentOptionResolution SetNamespaceConflictResolution(bool setValue)
            {
                var deployOptionResolute = new deploymentOptionResolution
                {
                    name = deploymentOptionEnum.namespaceConflictResolution,
                    value = setValue ? conflictResolutionEnum.replace : conflictResolutionEnum.keep
                };
                return deployOptionResolute;
            }

            // set objectPoliciesConflictResolution as default value - 'replace'
            private deploymentOptionResolution SetObjectPoliciesConflictResolution(bool setValue)
            {
                var deployOptionResolute = new deploymentOptionResolution
                {
                    name = deploymentOptionEnum.objectPoliciesConflictResolution,
                    value = setValue ? conflictResolutionEnum.replace : conflictResolutionEnum.keep
                };
                return deployOptionResolute;
            }

            // set ownershipConflictResolution as default value - 'replace'
            private deploymentOptionResolution SetOwnershipConflictResolution(bool setValue)
            {
                var deployOptionResolute = new deploymentOptionResolution
                {
                    name = deploymentOptionEnum.ownershipConflictResolution,
                    value = setValue ? conflictResolutionEnum.replace : conflictResolutionEnum.keep
                };
                return deployOptionResolute;
            }

            // set packageHistoriesConflictResolution as default value - 'replace'
            private deploymentOptionResolution SetPackageHistoriesConflictResolution(bool setValue)
            {
                var deployOptionResolute = new deploymentOptionResolution
                {
                    name = deploymentOptionEnum.packageHistoriesConflictResolution,
                    value = setValue ? conflictResolutionEnum.replace : conflictResolutionEnum.keep
                };
                return deployOptionResolute;
            }

            // set packageOutputsConflictResolution as default value - 'replace'
            private deploymentOptionResolution SetPackageOutputsConflictResolution(bool setValue)
            {
                var deployOptionResolute = new deploymentOptionResolution
                {
                    name = deploymentOptionEnum.packageOutputsConflictResolution,
                    value = setValue ? conflictResolutionEnum.replace : conflictResolutionEnum.keep
                };
                return deployOptionResolute;
            }

            // set packageSchedulesConflictResolution as default value - 'replace'
            private deploymentOptionResolution SetPackageSchedulesConflictResolution(bool setValue)
            {
                var deployOptionResolute = new deploymentOptionResolution
                {
                    name = deploymentOptionEnum.packageSchedulesConflictResolution,
                    value = setValue ? conflictResolutionEnum.replace : conflictResolutionEnum.keep
                };
                return deployOptionResolute;
            }

            // set recipientsConflictResolution as default value - 'replace'
            private deploymentOptionResolution SetRecipientsConflictResolution(bool setValue)
            {
                var deployOptionResolute = new deploymentOptionResolution
                {
                    name = deploymentOptionEnum.recipientsConflictResolution,
                    value = setValue ? conflictResolutionEnum.replace : conflictResolutionEnum.keep
                };
                return deployOptionResolute;
            }

            // set packageDatasetOutputsConflictResolution as default value - 'replace'
            private deploymentOptionResolution SetPackageDatasetOutputsConflictResolution(bool setValue)
            {
                var deployOptionResolute = new deploymentOptionResolution
                {
                    name = deploymentOptionEnum.packageDatasetOutputsConflictResolution,
                    value = setValue ? conflictResolutionEnum.replace : conflictResolutionEnum.keep
                };
                return deployOptionResolute;
            }

        }
    }



    ------------------------------
    Marc Percy
    ------------------------------



  • 2.  RE: Help with Importing Deployment Archive using the Cognos SDK in C#

    Posted Fri September 27, 2024 03:08 PM
    Edited by Andrei Istomine Fri September 27, 2024 03:11 PM

    Hi Marc,

    I assume you're able to import a package in the Cognos Admin UI with the same user ID? Have you tried running the original IBM SDK Java sample in this environment? Did it work?

    In any case, I'd suggest implementing minimal code to test the SDK import. Take the IBM Java sample, remove all extra code, leaving the bare minimum. Ensure it's working, then convert it to C#.

    Hope this helps!

    ------------------------------
    Andrei Istomine
    Open to work - anything Cognos
    https://www.linkedin.com/in/andreii/



  • 3.  RE: Help with Importing Deployment Archive using the Cognos SDK in C#

    Posted Mon September 30, 2024 07:17 AM

    Thank you for the reply. I tested a previous SDK program that we have used to do the imports and it is using the Java version and it worked fine. The code that is converted to C# above is minimal code, as it is the deployment.java converted with nothing else added. 



    ------------------------------
    Marc Percy
    ------------------------------



  • 4.  RE: Help with Importing Deployment Archive using the Cognos SDK in C#

    Posted Mon September 30, 2024 12:50 PM

    IBM Deployment.java sample is using MonitorService to run the deployment:

      asynchReply = connection.getMonitorService().run(searchPathObject,  new ParameterValue[] {}, new Option[] {});

    Your C# code is using contentManagerService1:

      asynchReply = connection.run(searchPathObject, arConnectRunParam, arConnectRunOpt);

    I wonder if this is a bug in the Sample code. I did not try it.

    If I get it right your C# code is able to update the Archive but fails when you run the deployment.



    ------------------------------
    Andrei Istomine
    Open to work - anything Cognos
    https://www.linkedin.com/in/andreii/
    ------------------------------



  • 5.  RE: Help with Importing Deployment Archive using the Cognos SDK in C#

    Posted Mon September 30, 2024 01:00 PM

    getMonitorService is not part of connectionManager1. Java uses connectionManager, so that may be the issue. All other places where it used a getXXX service, I was just able to remove them and it has worked. You are correct it adds the deploayment to the list with the folders selected but fails on the import.



    ------------------------------
    Marc Percy
    ------------------------------



  • 6.  RE: Help with Importing Deployment Archive using the Cognos SDK in C#

    Posted Mon September 30, 2024 01:26 PM

    Unfortunately, I can't test the Deployment code in my environment at the moment.

    >All other places where it used a getXXX service, I was just able to remove them and it has worked.

    Did you mean that modified Java code has worked without using connection.getMonitorService()?



    ------------------------------
    Andrei Istomine
    Open to work - anything Cognos
    https://www.linkedin.com/in/andreii/
    ------------------------------



  • 7.  RE: Help with Importing Deployment Archive using the Cognos SDK in C#

    Posted Mon September 30, 2024 03:43 PM

    Nothing else uses the getMonitorService, but instead of con.getCMSService().query, in c# I just needed con.query.

    Some of the other things were variations of the command, like setName, was name. 



    ------------------------------
    Marc Percy
    ------------------------------



  • 8.  RE: Help with Importing Deployment Archive using the Cognos SDK in C#
    Best Answer

    Posted Mon September 30, 2024 07:20 PM

    You must use the monitorService1 to run Import.

    You have dropped the "Checkhov's gun". It was not there by accident.

    Please refactor your code to match  Java sample.



    ------------------------------
    Andrei Istomine
    Open to work - anything Cognos
    https://www.linkedin.com/in/andreii/
    ------------------------------



  • 9.  RE: Help with Importing Deployment Archive using the Cognos SDK in C#

    Posted Tue October 01, 2024 07:42 AM

    Thank you for the help. With some trial and error, I was able to get it to import properly. Here is the code that was updated:

                    connection.update(ArchiveInfo, new updateOptions());
                    option[] arConnectRunOpt = new option[] { };
                    parameterValue[] arConnectRunParam = new parameterValue[] { };
                    monitorService1 monSrv = new monitorService1();
                    monSrv.Url = connection.Url;
                    monSrv.biBusHeaderValue = connection.biBusHeaderValue;
                    asynchReplyVar = monSrv.run(searchPathObject, arConnectRunParam, arConnectRunOpt);



    ------------------------------
    Marc Percy
    ------------------------------



  • 10.  RE: Help with Importing Deployment Archive using the Cognos SDK in C#

    Posted Tue October 01, 2024 11:19 AM

    I'm glad I could help you to figure this out.

    You can mark my message as the best answer if you feel it was helpful in the resolution.

    Best!



    ------------------------------
    Andrei Istomine
    Open to work - anything Cognos
    https://www.linkedin.com/in/andreii/
    ------------------------------