private bool doViewReportsWithSubElements(contentManagerService1 cCMS, ref List<CogObject> reports, string cogVersion, string baseReportPath)
        {
            if (cCMS == null)
            {
                reports = null;
                return false;
            }

            // Declare query properties array for report
            propEnum[] reportProps = new propEnum[] { propEnum.searchPath, propEnum.defaultName,
                                                propEnum.owner, propEnum.storeID, propEnum.connectionString, propEnum.creationTime,
                                                propEnum.metadataModelPackage, propEnum.ancestors, propEnum.disabled};

            // Declare properties to retrieve for package object internal to report object
            refProp packageProps = new refProp();
            packageProps.refPropName = propEnum.metadataModelPackage;
            packageProps.properties = new propEnum[] { propEnum.searchPath, propEnum.storeID,
                                                       propEnum.defaultName, propEnum.disabled,
                                                       propEnum.ancestors };

            // Declare sort properties for reports and users
            //reports
            sort[] reportSort = new sort[] { new sort() };
            reportSort[0].order = orderEnum.ascending;
            reportSort[0].propName = propEnum.defaultName;

            // Set up query options for the call. Adding the packageProps
            // will cause all requested subproperties to be retrieved for
            // the properties listed that refer to other objects.
            queryOptions qo = new queryOptions();
            qo.refProps= new refProp[] { packageProps };

            // Declare search path for reports and for a single user, based on CAMID
            searchPathMultipleObject reportsPath = new searchPathMultipleObject();
            searchPathMultipleObject userPath = new searchPathMultipleObject();
            //Set search paths to get reports. Userpath must be set
            //separately for each individual based on CAMID
            reportsPath.Value = "/content//report";

            // Run query to get all reports. Users will be queried as part of this
            // process, one for each report.
            baseClass[] bc = cCMS.query(reportsPath, reportProps, reportSort, qo);
            if (bc.Length > 0)
            {
                foreach (baseClass report_item in bc)
                {
                    // Cast base class object to more specific report object for access to more
                    // properties

                    cognosdotnet_2_0.report report = (cognosdotnet_2_0.report)report_item;
                    CogObject rpt = new CogObject();
                    rpt.ID = report_item.storeID.value.Value;
                    rpt.AddAttribute("ID", rpt.ID);
                    rpt.AddAttribute("Name", report_item.defaultName.value);
                    rpt.AddAttribute("CreationTime", report_item.creationTime.value.ToString());
                    rpt.AddAttribute("Type", "Report");
                    rpt.AddAttribute("Disabled", report.disabled.value.ToString());

                    // Make sure package or model is not null
                    if (report.metadataModelPackage.value!= null)
                    {
                        cognosdotnet_2_0.package package = (cognosdotnet_2_0.package)report.metadataModelPackage.value[0];
                        rpt.AddAttribute("Package_Path", report.metadataModelPackage.value[0].searchPath.value);
                        rpt.AddAttribute("Package_Name", getPackageName(rpt.getAttributeValue("Package_Path")));
                        rpt.AddAttribute("Package_Disabled", package.disabled.value.ToString());
                    }
                    else
                    {
                        rpt.AddAttribute("Package_Path", "null");
                        rpt.AddAttribute("Package_Name", "null");
                        rpt.AddAttribute("Package_Disabled", "null");
                    }
                    // Make sure owner is not null
                    if (report_item.owner.value != null)
                    {
                        getUserAccount(cCMS, report_item.owner.value[0].searchPath.value, ref rpt);
                        rpt.AddAttribute("Author_CAMID", report_item.owner.value[0].searchPath.value);
                    }
                    else
                    {
                        rpt.AddAttribute("Author_CAMID", "Unknown");
                    }
                    String version = cogVersion;
                    rpt.AddAttribute("Version", cogVersion);
                    rpt.AddAttribute("Path", report_item.searchPath.value);
                    rpt.AddAttribute("URL", baseReportPath + report_item.searchPath.value);
                    getSubElements(cCMS, report_item.searchPath.value, ref rpt);
                    /* This gets some limited auditing information. Most of this can be found
                     * more easily in the Raw Usage report of the Business Intelligence Dashboard
                     * package on perform-dev.tyson.com. Uncommenting the following line will
                     * cause a dramatic increase in runtime for this program
                     */
                    //getAuditInfo(ref cog);
                    reports.Add(rpt);
                }
            }
            else
            {
                reports = null;
            }
            return true;
        }
        public List<CogObject> getGroupsAndRoles()
        {
            propEnum[] props = new propEnum[] { propEnum.defaultName, propEnum.searchPath, propEnum.type, propEnum.members,
                                                propEnum.objectClass };

            // Properties used to get account class information for the members
            refProp memberProps = new refProp();
            memberProps.refPropName = propEnum.members;
            memberProps.properties = new propEnum[] { propEnum.searchPath, propEnum.defaultName, propEnum.userName,
                                                      propEnum.objectClass };

            baseClass[] securityObjects = new baseClass[]{};
            searchPathMultipleObject spMulti = new searchPathMultipleObject();
            account[] targetAccount = null;
            List<CogObject> cogObjects = new List<CogObject>();

            queryOptions qo = new queryOptions();

            qo.refProps = new refProp[] { memberProps };

            // Set search path to pull back all groups and roles in Cognos
            spMulti.Value = "CAMID(\"ADS:f:ou=enterprise reporting,ou=applications,ou=tyson groups\")//group | //group | //role";
            Console.WriteLine(spMulti.Value);

            // Query for all groups and roles
            try
            {
                securityObjects = cCMS.query(spMulti, props, new sort[] { }, qo);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            if (securityObjects.Length <= 0)
            {
                Console.WriteLine("No roles or groups were found.");
            }

            // Loop through groups and roles and get members for each
            foreach (baseClass securityObject in securityObjects)
            {
                baseClass[] members = new baseClass[] { };
                searchPathMultipleObject membersPath = new searchPathMultipleObject();
                membersPath.Value = "expandMembers(" + securityObject.searchPath.value + ")";

                // Attempt to get members for the group or role
                try
                {
                    members = cCMS.query(membersPath, props, new sort[] { }, new queryOptions());

                    // Loop through members of the group
                    foreach (account account in members)
                    {
                        CogObject user = new CogObject();
                        user.AddAttribute("user", account.defaultName.value);

                        if (securityObject is role)
                        {
                            user.AddAttribute("categoryType", "role");
                        }
                        else if (securityObject is group)
                        {
                            user.AddAttribute("categoryType", "group");
                        }
                        else
                        {
                            user.AddAttribute("categoryType", "unknown");
                        }

                        user.AddAttribute("categoryName", securityObject.defaultName.value);
                        cogObjects.Add(user);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }

            return cogObjects;
        }
        private bool doViewQueriesWithSubElements(contentManagerService1 cCMS, ref List<CogObject> queries, string cogVersion, string baseQueryPath)
        {
            if (cCMS == null)
            {
                queries = null;
                return false;
            }

            //queries
            propEnum[] queryProps = new propEnum[] { propEnum.searchPath, propEnum.defaultName,
                                                propEnum.owner, propEnum.storeID, propEnum.connectionString, propEnum.creationTime,
                                                propEnum.metadataModelPackage, propEnum.ancestors, propEnum.disabled};

            // Declare properties to retrieve for package object internal to report object
            refProp packageProps = new refProp();
            packageProps.refPropName = propEnum.metadataModelPackage;
            packageProps.properties = new propEnum[] { propEnum.searchPath, propEnum.storeID,
                                                       propEnum.defaultName, propEnum.disabled,
                                                       propEnum.ancestors };

            //queries
            sort[] querySort = new sort[] { new sort() };
            querySort[0].order = orderEnum.ascending;
            querySort[0].propName = propEnum.defaultName;

            // Set up query options for the call. Adding the packageProps
            // will cause all requested subproperties to be retrieved for
            // the properties listed that refer to other objects.
            queryOptions qo = new queryOptions();
            qo.refProps = new refProp[] { packageProps };

            searchPathMultipleObject userPath = new searchPathMultipleObject();
            searchPathMultipleObject queriesPath = new searchPathMultipleObject();
            queriesPath.Value = "/content//query";

            // Make call to get all queries. Get each author for each query during this process
            // by making a separate call, based on CAMID; the same as above when pulling the reports.
            baseClass[] bcQueries = cCMS.query(queriesPath, queryProps, querySort, qo);
            if (bcQueries.Length > 0)
            {
                foreach (baseClass query_item in bcQueries)
                {
                    // Cast base class object to more specific report object for access to more
                    // properties
                    cognosdotnet_2_0.query query = (cognosdotnet_2_0.query)query_item;
                    CogObject qry = new CogObject();
                    qry.ID = query_item.storeID.value.Value;
                    qry.AddAttribute("ID", qry.ID);
                    qry.AddAttribute("Name", query_item.defaultName.value);
                    qry.AddAttribute("CreationTime", query_item.creationTime.value.ToString());
                    qry.AddAttribute("Type", "Query");
                    qry.AddAttribute("Disabled", query.disabled.value.ToString());

                    // Make sure package or package is not null
                    if (query.metadataModelPackage.value != null)
                    {
                        cognosdotnet_2_0.package package = (cognosdotnet_2_0.package)query.metadataModelPackage.value[0];
                        qry.AddAttribute("Package_Path", query.metadataModelPackage.value[0].searchPath.value);
                        qry.AddAttribute("Package_Name", getPackageName(qry.getAttributeValue("Package_Path")));
                        qry.AddAttribute("Package_Disabled", package.disabled.value.ToString());
                    }
                    else
                    {
                        qry.AddAttribute("Package_Path", "null");
                        qry.AddAttribute("Package_Name", "null");
                        qry.AddAttribute("Package_Disabled", "null");
                    }
                    // Make sure owner is not null
                    if (query_item.owner.value != null)
                    {
                        getUserAccount(cCMS, query_item.owner.value[0].searchPath.value, ref qry);
                        qry.AddAttribute("Author_CAMID", query_item.owner.value[0].searchPath.value);
                    }
                    else
                    {
                        qry.AddAttribute("Author_CAMID", "Unknown");
                    }
                    qry.AddAttribute("Version", cogVersion);
                    qry.AddAttribute("Path", query_item.searchPath.value);
                    qry.AddAttribute("URL", baseQueryPath + query_item.searchPath.value);
                    getSubElements(cCMS, query_item.searchPath.value, ref qry);
                    /* This gets some limited auditing information. Most of this can be found
                     * more easily in the Raw Usage report of the Business Intelligence Dashboard
                     * package on perform-dev.tyson.com. Uncommenting the following line will
                     * cause a dramatic increase in runtime for this program
                     */
                    //getAuditInfo(ref cog);
                    queries.Add(qry);
                }
            }
            else
            {
                queries = null;
            }
            return true;
        }
        private bool turnOffReportViewDuration(int[] cellCount)
        {
            Microsoft.Office.Interop.Excel.Application oXL = new Microsoft.Office.Interop.Excel.Application();
            Microsoft.Office.Interop.Excel._Workbook oWB;
            Microsoft.Office.Interop.Excel._Worksheet oSheet;
            Microsoft.Office.Interop.Excel.Range oRange;

            // Create Excel Application
            oXL.Visible = true;

            //Get a new workbook.
            oWB = (Microsoft.Office.Interop.Excel._Workbook)(oXL.Workbooks.Add(Missing.Value));
            oSheet = (Microsoft.Office.Interop.Excel._Worksheet)oWB.ActiveSheet;

            if (cCMS == null)
            {
                return false;
            }

            // Declare query properties array for report
            propEnum[] reportProps = new propEnum[] { propEnum.searchPath, propEnum.defaultName,
                                                      propEnum.retentions, propEnum.owner };

            // Properties used to get account class information for the owner
            refProp ownerProps = new refProp();
            ownerProps.refPropName = propEnum.owner;
            ownerProps.properties = new propEnum[] { propEnum.searchPath, propEnum.defaultName };

            // Declare sort properties for reports and users
            //reports
            sort[] reportSort = new sort[] { new sort() };
            reportSort[0].order = orderEnum.ascending;
            reportSort[0].propName = propEnum.defaultName;

            // Set up query options for the call. Adding the packageProps
            // will cause all requested subproperties to be retrieved for
            // the properties listed that refer to other objects.
            queryOptions qo = new queryOptions();
            qo.refProps = new refProp[] { ownerProps };

            // Declare search path for reports and for a single user, based on CAMID
            searchPathMultipleObject objectsPath = new searchPathMultipleObject();
            searchPathMultipleObject userPath = new searchPathMultipleObject();
            //Set search paths to get reports. Userpath must be set
            //separately for each individual based on CAMID
            objectsPath.Value = "//reportView";
            //objectsPath.Value = "/content/package[@name='National Accounts']/report[@name='(0226) NA Ebit by Customer/Minor Line - Combined']";
            //objectsPath.Value = "CAMID(\"ADS:u:cn=miller\\, barret,ou=new,ou=groups,ou=general,ou=tyson team members\")/folder[@name='My Folders']/reportView[@name='Report View of (0224) Combined Sales']";
            // Run query to get all reports. Users will be queried as part of this
            // process, one for each report.
            baseClass[] bc = cCMS.query(objectsPath, reportProps, reportSort, qo);

            retentionRuleArrayProp retentionRules = new retentionRuleArrayProp();
            retentionRule[] outputRule = new retentionRule[1];
            outputRule[0] = new retentionRule();
            outputRule[0].objectClass = classEnum.reportVersion;
            outputRule[0].prop = propEnum.creationTime;
            outputRule[0].maxDuration = null;
            //outputRule[0].maxObjects = "1";
            retentionRules.value = outputRule;
            List<baseClass> turnOffDurationList = new List<baseClass>();

            if (bc.Length > 0)
            {
                foreach (baseClass report_item in bc)
                {
                    // Cast base class object to more specific report object for access to more
                    // properties
                    if (report_item is reportView)
                    {
                        cognosdotnet_2_0.reportView reportv = (cognosdotnet_2_0.reportView)report_item;
                        foreach (retentionRule rule in reportv.retentions.value)
                        {
                            // If the rule is for the type 'reportVersion' and has the duration set
                            if ((rule.objectClass == classEnum.reportVersion) && (rule.maxDuration != null))
                            {
                                // Output the name
                                oSheet.Cells[cellCount[0], cellCount[1]] = reportv.defaultName.value;
                                //Increment the column count
                                cellCount[1]++;
                                //Output the path
                                oSheet.Cells[cellCount[0], cellCount[1]] = reportv.searchPath.value;
                                //Increment the column count
                                cellCount[1]++;
                                if (reportv.owner.value == null)
                                {
                                    oSheet.Cells[cellCount[0], cellCount[1]] = "unknown";
                                }
                                else
                                {
                                    oSheet.Cells[cellCount[0], cellCount[1]] = reportv.owner.value[0].defaultName.value;
                                }
                                //Reset the column count, and increment the row count
                                cellCount[1] = 1;
                                cellCount[0]++;
                                reportv.retentions = retentionRules;
                                turnOffDurationList.Add(report_item);
                            }
                        }
                    }
                }
                if (turnOffDurationList.Count > 0)
                {
                    cCMS.update(turnOffDurationList.ToArray(), new updateOptions());
                }
            }
            return true;
        }
        private bool turnOffMyFolderContentDuration(int[] cellCount)
        {
            Microsoft.Office.Interop.Excel.Application oXL = new Microsoft.Office.Interop.Excel.Application();
            Microsoft.Office.Interop.Excel._Workbook oWB;
            Microsoft.Office.Interop.Excel._Worksheet oSheet;
            Microsoft.Office.Interop.Excel.Range oRange;

            // Create Excel Application
            oXL.Visible = true;

            //Get a new workbook.
            oWB = (Microsoft.Office.Interop.Excel._Workbook)(oXL.Workbooks.Add(Missing.Value));
            oSheet = (Microsoft.Office.Interop.Excel._Worksheet)oWB.ActiveSheet;

            string camid = "//account"; //this is the search path for all user accounts
            //string camid = "CAMID(\"ADS:u:cn=miller\\, barret,ou=new,ou=groups,ou=general,ou=tyson team members\")";
            string userSearchPaths = "";
            // We will display My Folders and My Pages for all users in namespace
            propEnum[] props = new propEnum[]{propEnum.searchPath,
                    propEnum.objectClass,propEnum.defaultName,propEnum.portalPages,
                    propEnum.ancestors, propEnum.owner};

            // Same query options used for all calls
            queryOptions qo = new queryOptions();
            // Create sort object
            sort[] accountSort = new sort[] { new sort() };
            accountSort[0].order = orderEnum.ascending;
            accountSort[0].propName = propEnum.defaultName;

            //query for all accounts
            searchPathMultipleObject spMulti = new searchPathMultipleObject();
            spMulti.Value = camid;
            baseClass[] bc = cCMS.query(spMulti, props, accountSort, qo);

            if (bc != null && bc.Length > 0)
            {
                // Set different properties to grab for the reports, queries, or report views
                props = new propEnum[]{propEnum.searchPath, propEnum.defaultName,
                                       propEnum.owner, propEnum.storeID, propEnum.connectionString, propEnum.creationTime,
                                       propEnum.metadataModelPackage, propEnum.ancestors, propEnum.disabled, propEnum.user,
                                       propEnum.retentions };
                // Declare properties to retrieve for package object internal to report object
                refProp packageProps = new refProp();
                packageProps.refPropName = propEnum.metadataModelPackage;
                packageProps.properties = new propEnum[] { propEnum.searchPath, propEnum.storeID,
                                                       propEnum.defaultName, propEnum.disabled,
                                                       propEnum.ancestors };
                // Properties used to get base class information if the object is a report view
                refProp reportProps = new refProp();
                reportProps.refPropName = propEnum.@base;
                reportProps.properties = new propEnum[] { propEnum.metadataModelPackage, propEnum.storeID,
                                                      propEnum.searchPath, propEnum.disabled };

                qo.refProps = new refProp[] { packageProps, reportProps };

                retentionRuleArrayProp retentionRules = new retentionRuleArrayProp();
                retentionRule[] outputRule = new retentionRule[1];
                outputRule[0] = new retentionRule();
                outputRule[0].objectClass = classEnum.reportVersion;
                outputRule[0].prop = propEnum.creationTime;
                outputRule[0].maxDuration = null;
                //outputRule[0].maxObjects = "1";
                List<baseClass> turnOffDurationList = new List<baseClass>();

                for (int i = 0; i < bc.Length; i++)
                {
                    //Query the Content Store for all objects in My Folders for user bc[i]
                    userSearchPaths = bc[i].searchPath.value + "/folder[@name='My Folders']//report"; /*+
                                      bc[i].searchPath.value + "/folder[@name='My Folders']//query |" +
                                      bc[i].searchPath.value + "/folder[@name='My Folders']//reportView";*/

                    spMulti.Value = userSearchPaths;
                    baseClass[] contents = cCMS.query(spMulti, props, new sort[] { }, qo);
                    if (contents != null && contents.Length > 0)
                    {
                        //Disable Duration all objects in My Folders for user bc[i]
                        for (int j = 0; j < contents.Length; j++)
                        {
                            /*
                             * Check whether object is a more specific type (e.g. query or report)
                             */
                            if (contents[j] is report)
                            {
                                cognosdotnet_2_0.report report = (cognosdotnet_2_0.report)contents[j];
                                foreach (retentionRule rule in report.retentions.value)
                                {
                                    // If the rule is for the type 'reportVersion' and has the duration set
                                    if ((rule.objectClass == classEnum.reportVersion) && (rule.maxDuration != null))
                                    {
                                        // Output the name
                                        oSheet.Cells[cellCount[0], cellCount[1]] = report.defaultName.value;
                                        //Increment the column count
                                        cellCount[1]++;
                                        //Output the path
                                        oSheet.Cells[cellCount[0], cellCount[1]] = report.searchPath.value;
                                        //Increment the column count
                                        cellCount[1]++;
                                        oSheet.Cells[cellCount[0], cellCount[1]] = bc[i].defaultName.value;
                                        //Reset the column count, and increment the row count
                                        cellCount[1] = 1;
                                        cellCount[0]++;
                                        report.retentions = retentionRules;
                                        turnOffDurationList.Add(contents[j]);
                                    }
                                }

                            }
                            else if (contents[j] is query)
                            {
                                cognosdotnet_2_0.query query = (cognosdotnet_2_0.query)contents[j];
                                foreach (retentionRule rule in query.retentions.value)
                                {
                                    // If the rule is for the type 'reportVersion' and has the duration set
                                    if ((rule.objectClass == classEnum.reportVersion) && (rule.maxDuration != null))
                                    {
                                        // Output the name
                                        oSheet.Cells[cellCount[0], cellCount[1]] = query.defaultName.value;
                                        //Increment the column count
                                        cellCount[1]++;
                                        //Output the path
                                        oSheet.Cells[cellCount[0], cellCount[1]] = query.searchPath.value;
                                        //Increment the column count
                                        cellCount[1]++;
                                        oSheet.Cells[cellCount[0], cellCount[1]] = bc[i].defaultName.value;
                                        //Reset the column count, and increment the row count
                                        cellCount[1] = 1;
                                        cellCount[0]++;
                                        query.retentions = retentionRules;
                                        turnOffDurationList.Add(contents[j]);
                                    }
                                }
                            }
                            else if (contents[j] is reportView)
                            {
                                cognosdotnet_2_0.reportView reportView = (cognosdotnet_2_0.reportView)contents[j];
                                foreach (retentionRule rule in reportView.retentions.value)
                                {
                                    // If the rule is for the type 'reportVersion' and has the duration set
                                    if ((rule.objectClass == classEnum.reportVersion) && (rule.maxDuration != null))
                                    {
                                        // Output the name
                                        oSheet.Cells[cellCount[0], cellCount[1]] = reportView.defaultName.value;
                                        //Increment the column count
                                        cellCount[1]++;
                                        //Output the path
                                        oSheet.Cells[cellCount[0], cellCount[1]] = reportView.searchPath.value;
                                        //Increment the column count
                                        cellCount[1]++;
                                        oSheet.Cells[cellCount[0], cellCount[1]] = bc[i].defaultName.value;
                                        //Reset the column count, and increment the row count
                                        cellCount[1] = 1;
                                        cellCount[0]++;
                                        reportView.retentions = retentionRules;
                                        turnOffDurationList.Add(contents[j]);
                                    }
                                }
                            }
                        }
                        if (turnOffDurationList.Count > 0)
                        {
                            cCMS.update(turnOffDurationList.ToArray(), new updateOptions());
                        }
                    }
                }
            }
            return true;
        }
        /* Does the bulk of the work to extract information on Users' MyFolder objects
         */
        private bool doViewUsersMyFolderContentsWithSubElements(contentManagerService1 cCMS, ref List<CogObject> cogs, string cogVersion, string baseReportPath)
        {
            string camid = "//account"; //this is the search path for all user accounts
            string userSearchPaths = "";
            // We will display My Folders and My Pages for all users in namespace
            propEnum[] props = new propEnum[]{propEnum.searchPath,
                    propEnum.objectClass,propEnum.defaultName,propEnum.portalPages,
                    propEnum.ancestors, propEnum.owner};

            // Same query options used for all calls
            queryOptions qo = new queryOptions();
            // Create sort object
            sort[] accountSort = new sort[] { new sort() };
            accountSort[0].order = orderEnum.ascending;
            accountSort[0].propName = propEnum.defaultName;

            //query for all accounts
            searchPathMultipleObject spMulti = new searchPathMultipleObject();
            spMulti.Value = camid;
            baseClass[] bc = cCMS.query(spMulti, props, accountSort, qo);

            if (bc != null && bc.Length > 0)
            {
                // Set different properties to grab for the reports, queries, or report views
                props = new propEnum[]{propEnum.searchPath, propEnum.defaultName,
                                       propEnum.owner, propEnum.storeID, propEnum.connectionString, propEnum.creationTime,
                                       propEnum.metadataModelPackage, propEnum.ancestors, propEnum.disabled};
                // Declare properties to retrieve for package object internal to report object
                refProp packageProps = new refProp();
                packageProps.refPropName = propEnum.metadataModelPackage;
                packageProps.properties = new propEnum[] { propEnum.searchPath, propEnum.storeID,
                                                       propEnum.defaultName, propEnum.disabled,
                                                       propEnum.ancestors };
                // Properties used to get base class information if the object is a report view
                refProp reportProps = new refProp();
                reportProps.refPropName = propEnum.@base;
                reportProps.properties = new propEnum[] { propEnum.metadataModelPackage, propEnum.storeID,
                                                      propEnum.searchPath, propEnum.disabled };
                qo.refProps = new refProp[] { packageProps, reportProps };

                for (int i = 0; i < bc.Length; i++)
                {
                    //Query the Content Store for all objects in My Folders for user bc[i]
                    userSearchPaths = bc[i].searchPath.value + "/folder[@name='My Folders']//report |" +
                                      bc[i].searchPath.value + "/folder[@name='My Folders']//query |" +
                                      bc[i].searchPath.value + "/folder[@name='My Folders']//reportView";

                    spMulti.Value = userSearchPaths;
                    baseClass[] contents = cCMS.query(spMulti, props, new sort[] { }, qo);
                    if (contents != null && contents.Length > 0)
                    {
                        //Display all objects in My Folders for user bc[i]
                        for (int j = 0; j < contents.Length; j++)
                        {
                            CogObject cog = new CogObject();
                            /*
                             * Check whether object is a more specific type (e.g. query or report)
                             */
                            if (contents[j] is report)
                            {
                                // Cast base class object to more specific report object for access to more
                                // properties
                                cognosdotnet_2_0.report report = (cognosdotnet_2_0.report)contents[j];
                                cog.AddAttribute("Type", "Report");
                                cog.AddAttribute("CreationTime", contents[j].creationTime.value.ToString());
                                // Make sure package or Package is not null
                                if (report.metadataModelPackage.value != null)
                                {
                                    cognosdotnet_2_0.package package = (cognosdotnet_2_0.package)report.metadataModelPackage.value[0];
                                    cog.AddAttribute("Package_Path", report.metadataModelPackage.value[0].searchPath.value);
                                    cog.AddAttribute("Package_Name", getPackageName(cog.getAttributeValue("Package_Path")));
                                    cog.AddAttribute("Package_Disabled", package.disabled.value.ToString());
                                }
                                else
                                {
                                    cog.AddAttribute("Package_Path", "null");
                                    cog.AddAttribute("Package_Name", "null");
                                    cog.AddAttribute("Package_Disabled", "null");
                                }
                                cog.AddAttribute("Disabled", report.disabled.value.ToString());
                            }
                            else if (contents[j] is query)
                            {
                                // Cast base class object to more specific report object for access to more
                                // properties
                                cognosdotnet_2_0.query query = (cognosdotnet_2_0.query)contents[j];
                                cog.AddAttribute("Type", "Query");
                                // Make sure package or Package is not null
                                if (query.metadataModelPackage.value != null)
                                {
                                    cognosdotnet_2_0.package package = (cognosdotnet_2_0.package)query.metadataModelPackage.value[0];
                                    cog.AddAttribute("Package_Path", query.metadataModelPackage.value[0].searchPath.value);
                                    cog.AddAttribute("Package_Name", getPackageName(cog.getAttributeValue("Package_Path")));
                                    cog.AddAttribute("Package_Disabled", package.disabled.value.ToString());
                                }
                                else
                                {
                                    cog.AddAttribute("Package_Path", "null");
                                    cog.AddAttribute("Package_Name", "null");
                                    cog.AddAttribute("Package_Disabled", "null");
                                }
                                cog.AddAttribute("Disabled", query.disabled.value.ToString());
                            }
                            else if (contents[j] is reportView)
                            {
                                // Cast base class object to more specific report object for access to more
                                // properties
                                cognosdotnet_2_0.reportView reportView = (cognosdotnet_2_0.reportView)contents[j];
                                cog.AddAttribute("Type", "ReportView");
                                // Make sure package or Package is not null
                                if (reportView.packageBase != null)
                                {
                                    cog.AddAttribute("Package_Path", reportView.packageBase.value);
                                    cog.AddAttribute("Package_Name", getPackageName(cog.getAttributeValue("Package_Path")));
                                }
                                else
                                {
                                    cog.AddAttribute("Package_Path", "null");
                                    cog.AddAttribute("Package_Name", "null");
                                }

                                if ([email protected] != null)
                                {
                                    cog.AddAttribute("BaseID", [email protected][0].storeID.value.Value);
                                    cog.AddAttribute("BasePath", [email protected][0].searchPath.value);

                                    if ([email protected][0] is report)
                                    {
                                        report tempReport = (report)[email protected][0];
                                        if (tempReport.metadataModelPackage.value[0] != null)
                                        {
                                            cog.AddAttribute("BasePackage_Path", tempReport.metadataModelPackage.value[0].searchPath.value);
                                            cog.AddAttribute("BasePackage_Name", getPackageName(cog.getAttributeValue("BasePackage_Path")));
                                        }
                                    }
                                    else if ([email protected][0] is query)
                                    {
                                        query tempQuery = (query)[email protected][0];
                                        if (tempQuery.metadataModelPackage.value[0] != null)
                                        {
                                            cog.AddAttribute("BasePackage_Path", tempQuery.metadataModelPackage.value[0].searchPath.value);
                                            cog.AddAttribute("BasePackage_Name", getPackageName(cog.getAttributeValue("BasePackage_Path")));
                                        }
                                    }
                                    cog.AddAttribute("Disabled", reportView.disabled.value.ToString());

                                }
                            }

                            // Make sure owner is not null
                            if (contents[j].owner.value != null)
                            {
                                /* We will get the author based on who's folder the report is in. This may
                                * not be strictly true. Uncomment the following line to get the old method.
                                * Also comment out or remove the line farther below that sets the Author_Name
                                * attribute*/
                                //getUserAccount(cCMS, contents[j].owner.value[0].searchPath.value, ref cog);
                                cog.AddAttribute("Author_CAMID", contents[j].owner.value[0].searchPath.value);
                            }
                            else
                            {
                                cog.AddAttribute("Author_CAMID", "Unknown");
                            }

                            cog.AddAttribute("Author_Name", bc[i].defaultName.value);
                            cog.AddAttribute("Version", cogVersion);
                            cog.AddAttribute("Name", contents[j].defaultName.value);
                            cog.AddAttribute("Path", contents[j].searchPath.value);
                            cog.AddAttribute("URL", baseReportPath + contents[j].searchPath.value);
                            cog.AddAttribute("MyFolder", "TRUE");
                            getSubElements(cCMS, contents[j].searchPath.value, ref cog);

                            /* This gets some limited auditing information. Most of this can be found
                             * more easily in the Raw Usage report of the Business Intelligence Dashboard
                             * package on perform-dev.tyson.com. Uncommenting the following line will
                             * cause a dramatic increase in runtime for this program
                             */
                            //getAuditInfo(ref cog);
                            cogs.Add(cog);
                        }
                    }
                }
            }
            else
            {
                cogs = null;
            }
            return true;
        }
        private bool turnOffAndReport_QueryDuration(ref _Worksheet oSheet, int[] cellCount)
        {
            if (cCMS == null)
            {
                return false;
            }

            // Declare query properties array for report
            propEnum[] reportProps = new propEnum[] { propEnum.searchPath, propEnum.defaultName,
                                                      propEnum.retentions, propEnum.owner };

            // Properties used to get account class information for the owner
            refProp ownerProps = new refProp();
            ownerProps.refPropName = propEnum.owner;
            ownerProps.properties = new propEnum[] { propEnum.searchPath, propEnum.defaultName };

            // Declare sort properties for reports and users
            //reports
            sort[] reportSort = new sort[] { new sort() };
            reportSort[0].order = orderEnum.ascending;
            reportSort[0].propName = propEnum.defaultName;

            // Set up query options for the call. Adding the packageProps
            // will cause all requested subproperties to be retrieved for
            // the properties listed that refer to other objects.
            queryOptions qo = new queryOptions();
            qo.refProps = new refProp[] { ownerProps };

            // Declare search path for reports and for a single user, based on CAMID
            searchPathMultipleObject objectsPath = new searchPathMultipleObject();
            searchPathMultipleObject userPath = new searchPathMultipleObject();
            //Set search paths to get reports. Userpath must be set
            //separately for each individual based on CAMID
            objectsPath.Value = "//query";
            //objectsPath.Value = "/content/package[@name='National Accounts']/report[@name='(0226) NA Ebit by Customer/Minor Line - Combined']";
            // Run query to get all reports. Users will be queried as part of this
            // process, one for each report.
            baseClass[] bc = cCMS.query(objectsPath, reportProps, reportSort, qo);

            retentionRuleArrayProp retentionRules = new retentionRuleArrayProp();
            retentionRule[] outputRule = new retentionRule[1];
            outputRule[0] = new retentionRule();
            outputRule[0].objectClass = classEnum.reportVersion;
            outputRule[0].prop = propEnum.creationTime;
            outputRule[0].maxDuration = null;
            //outputRule[0].maxObjects = "1";
            List<baseClass> turnOffDurationList = new List<baseClass>();

            if (bc.Length > 0)
            {
                foreach (baseClass report_item in bc)
                {
                    retentionRules.value = outputRule;
                    // Cast base class object to more specific report object for access to more
                    // properties
                    if (report_item is query)
                    {
                        cognosdotnet_2_0.query query = (cognosdotnet_2_0.query)report_item;
                        foreach (retentionRule rule in query.retentions.value)
                        {
                            // If the rule is for the type 'reportVersion' and has the duration set
                            if ((rule.objectClass == classEnum.reportVersion) && (rule.maxDuration != null))
                            {
                                // Output the name
                                oSheet.Cells[cellCount[0], cellCount[1]] = query.defaultName.value;
                                //Increment the column count
                                cellCount[1]++;
                                //Output the path
                                oSheet.Cells[cellCount[0], cellCount[1]] = query.searchPath.value;
                                //Increment the column count
                                cellCount[1]++;
                                if (query.owner.value == null)
                                {
                                    oSheet.Cells[cellCount[0], cellCount[1]] = "unknown";
                                }
                                else
                                {
                                    oSheet.Cells[cellCount[0], cellCount[1]] = query.owner.value[0].defaultName.value;
                                }
                                //Reset the column count, and increment the row count
                                cellCount[1] = 1;
                                cellCount[0]++;
                                query.retentions = retentionRules;
                                turnOffDurationList.Add(report_item);
                            }
                        }
                    }
                }
                if (turnOffDurationList.Count > 0)
                {
                    cCMS.update(turnOffDurationList.ToArray(), new updateOptions());
                }
            }
            return true;
        }
        private bool report_ReportViewDuration(ref _Worksheet oSheet, int[] cellCount)
        {
            if (cCMS == null)
            {
                return false;
            }

            // Declare query properties array for report
            propEnum[] reportProps = new propEnum[] { propEnum.searchPath, propEnum.defaultName,
                                                      propEnum.retentions, propEnum.owner };

            // Properties used to get account class information for the owner
            refProp ownerProps = new refProp();
            ownerProps.refPropName = propEnum.owner;
            ownerProps.properties = new propEnum[] { propEnum.searchPath, propEnum.defaultName };

            // Declare sort properties for reports and users
            //reports
            sort[] reportSort = new sort[] { new sort() };
            reportSort[0].order = orderEnum.ascending;
            reportSort[0].propName = propEnum.defaultName;

            // Set up query options for the call. Adding the packageProps
            // will cause all requested subproperties to be retrieved for
            // the properties listed that refer to other objects.
            queryOptions qo = new queryOptions();
            qo.refProps = new refProp[] { ownerProps };

            // Declare search path for reports and for a single user, based on CAMID
            searchPathMultipleObject objectsPath = new searchPathMultipleObject();
            searchPathMultipleObject userPath = new searchPathMultipleObject();
            //Set search paths to get reports. Userpath must be set
            //separately for each individual based on CAMID
            objectsPath.Value = "//reportView";
            //objectsPath.Value = "/content/package[@name='National Accounts']/report[@name='(0226) NA Ebit by Customer/Minor Line - Combined']";
            //objectsPath.Value = "CAMID(\"ADS:u:cn=miller\\, barret,ou=new,ou=groups,ou=general,ou=tyson team members\")/folder[@name='My Folders']/reportView[@name='Report View of (0224) Combined Sales']";
            // Run query to get all reports. Users will be queried as part of this
            // process, one for each report.
            baseClass[] bc = cCMS.query(objectsPath, reportProps, reportSort, qo);

            if (bc.Length > 0)
            {
                foreach (baseClass report_item in bc)
                {
                    // Cast base class object to more specific report object for access to more
                    // properties
                    if (report_item is reportView)
                    {
                        cognosdotnet_2_0.reportView reportv = (cognosdotnet_2_0.reportView)report_item;
                        foreach (retentionRule rule in reportv.retentions.value)
                        {
                            // If the rule is for the type 'reportVersion' and has the duration set
                            if ((rule.objectClass == classEnum.reportVersion) && (rule.maxDuration != null))
                            {
                                // Output the name
                                oSheet.Cells[cellCount[0], cellCount[1]] = reportv.defaultName.value;
                                //Increment the column count
                                cellCount[1]++;
                                //Output the path
                                oSheet.Cells[cellCount[0], cellCount[1]] = reportv.searchPath.value;
                                //Increment the column count
                                cellCount[1]++;
                                if (reportv.owner.value == null)
                                {
                                    oSheet.Cells[cellCount[0], cellCount[1]] = "unknown";
                                }
                                else
                                {
                                    oSheet.Cells[cellCount[0], cellCount[1]] = reportv.owner.value[0].defaultName.value;
                                }
                                //Reset the column count, and increment the row count
                                cellCount[1] = 1;
                                cellCount[0]++;
                            }
                        }
                    }
                }
            }
            return true;
        }