public void disableCogObjects(string startDate, int daysBack) { List<string> reportPaths = getPathToDisableList(startDate, daysBack); /* Debugging List<string> reportPaths = new List<string>(); reportPaths.Add("/content/package[@name='Supply Chain']/folder[@name='Demand']/report[@name='(0014) Product Group Summary'])&ui.name=(0014) Product Group Summary&ui.format=XLS&ui.backURL=/cognos8/cgi-bin/cognosisapi.dll?b_action=xts.run&m=portal/cc.xts&m_folder=iAB52A69DC50C4C77AC3A623A085EF52A"); */ List<string> exceptionPaths = getExceptionPathList(); writePathToDisableList(reportPaths); Console.WriteLine("Please check the file: objectsToDisable.txt in the program executable folder " + "to make sure everything looks good. Do you want to proceed? Enter 'yes' or 'no' (case insensitive)."); string userChoice = Console.ReadLine(); if(userChoice.ToLower() == "yes") { StreamWriter errorWriter = new StreamWriter("objectsNotFoundC8.txt"); StreamWriter successWriter = new StreamWriter("objectsFoundC8.txt"); // Declare query properties array for report propEnum[] props = new propEnum[] { propEnum.defaultName, propEnum.disabled, propEnum.searchPath}; // Declare sort properties for reports and users //reports sort[] sorts = new sort[] { }; // Object representing path to single report searchPathMultipleObject reportSearchPath = new searchPathMultipleObject(); // Query options queryOptions qo = new queryOptions(); List<baseClass> objectsToDisable = new List<baseClass>(); // Loop through all the paths and generate a list of objects // to disable for (int i = 0; i < reportPaths.Count; i++) { string path = reportPaths[i]; // If the path is not in the exception list, then add it to // the list of paths to be disabled if (!checkAgainstExceptions(path, exceptionPaths)) { reportSearchPath.Value = path; // Run query to get all reports. Users will be queried as part of this // process, one for each report. try { baseClass[] bc = cCMS.query(reportSearchPath, props, sorts, qo); if (bc.Length > 0) { booleanProp bp = new booleanProp(); bp.value = true; bc[0].disabled = bp; // Add the object to our List of things to disable objectsToDisable.Add(bc[0]); successWriter.WriteLine(path); } else { errorWriter.WriteLine(path); } } // The exception will simply say "The client did something wrong" // if the path line from the file is nothing resembling a path in the current // cognos environment catch (Exception e) { errorWriter.WriteLine(path); } } } errorWriter.Close(); successWriter.Close(); updateOptions updateOptions = new updateOptions(); cCMS.update(objectsToDisable.ToArray(), updateOptions); } else { Console.WriteLine("User entered something other than 'yes'. Aborting..."); } }
/** * Method to take in a list of paths to cognos objects and disable them. * pwnsauce... */ public void disableCogObjects() { System.IO.TextReader reader = new StreamReader("objectsToDisable.txt"); StreamWriter errorWriter = new StreamWriter("objectsNotFoundC8.txt"); StreamWriter successWriter = new StreamWriter("objectsFoundC8.txt"); // Declare query properties array for report propEnum[] props = new propEnum[] { propEnum.defaultName, propEnum.disabled, propEnum.searchPath}; // Declare sort properties for reports and users //reports sort[] sorts = new sort[] { }; // Object representing path to single report searchPathMultipleObject reportSearchPath = new searchPathMultipleObject(); // Query options queryOptions qo = new queryOptions(); // Read in first path string path = reader.ReadLine(); List<baseClass> objectsToDisable = new List<baseClass>(); // Loop through all the paths and generate a list of objects // to disable while (path != null) { reportSearchPath.Value = path; // Run query to get all reports. Users will be queried as part of this // process, one for each report. try { baseClass[] bc = cCMS.query(reportSearchPath, props, sorts, qo); if (bc.Length > 0) { booleanProp bp = new booleanProp(); bp.value = true; bc[0].disabled = bp; // Add the object to our List of things to disable objectsToDisable.Add(bc[0]); successWriter.WriteLine(path); } else { errorWriter.WriteLine(path); } } // The exception will simply say "The client did something wrong" // if the path line from the file is nothing resembling a path in the current // cognos environment catch (Exception e) { errorWriter.WriteLine(path); } path = reader.ReadLine(); } reader.Close(); errorWriter.Close(); successWriter.Close(); updateOptions updateOptions = new updateOptions(); cCMS.update(objectsToDisable.ToArray(), updateOptions); }