Buy the Cognos SDK Guide by BI Centre Now

The Cognos SDK Guide by BI Centre provides you with the complete source code for a C# web solution, C8.1 report based on the GOSR package, and a Word document that will serve as your core reference to understanding the Cognos 8 SDK. It will cover C8 SDK topics such as: authentication; querying the Cognos content store; rendering a C8 report in ASP.NET; exception handling; and much more.



Buy the Cognos 8 Modification Check Now







Monday, February 25, 2008

Cognos SDK -- cube drill down

Here is a C# Cognos SDK code snippet that shows the ability to drill down into a cube report by using the Cognos SDK.  Take note of the bolded code lines below.  You will need to use the Report Service's .drill method and pass in values for the drillOptionParameterValues property.
 
simpleParmValueItem item = new simpleParmValueItem();
                item.use = "[great_outdoors_company].[Years].[Years].[Year]->:[PC].[@MEMBER].[20050101-20051231]";
                item.inclusive = true;
 
option[] drillOptions = new option[1];
                drillOptionParameterValues d1 = new drillOptionParameterValues();
                d1.name = drillOptionEnum.down;
                d1.value = parameters;
                drillOptions[0] = d1;
 
response = this.rptService.drill(response.primaryRequest, parameters, drillOptions);
 
 
 
 
private void GoToDrillDown(reportService1 rptService)
        {
            if (this.rptService == null)
            {
                this.rptService = rptService;
            }
            String reportPath = "/content/package[@name='Great Outdoors Company']/report[@name='MyTestReport']";
           String savePath = "c:\\temp";
            parameterValue[] parameters = new parameterValue[1];
            asynchReply response;
            searchPathSingleObject reportPathObj = new searchPathSingleObject();
            reportPathObj.Value = reportPath;
            try
            {
                option[] runOptions = new option[6];

                runOptionBoolean saveOutput = new runOptionBoolean();
                saveOutput.name = runOptionEnum.saveOutput;
                saveOutput.value = false;
                runOptions[0] = saveOutput;

                // Specify the output format.
                runOptionStringArray outputFormat = new runOptionStringArray();
                outputFormat.name = runOptionEnum.outputFormat;
                outputFormat.value = new String[] { "HTML" };
                runOptions[1] = outputFormat;

                //Set the report not to prompt as we pass the parameters if any
                runOptionBoolean rop = new runOptionBoolean();
                rop.name = runOptionEnum.prompt;
                rop.value = false;
                runOptions[2] = rop;

                runOptionInt maxRows = new runOptionInt();
                maxRows.name = runOptionEnum.verticalElements;
                maxRows.value = 20;
                runOptions[3] = maxRows;

                option[] drillOptions = new option[1];
                drillOptionParameterValues d1 = new drillOptionParameterValues();
                d1.name = drillOptionEnum.down;
                d1.value = parameters;
                drillOptions[0] = d1;

                //Set the option to always have the primaryRequest in the response
                asynchOptionBoolean includePrimaryRequest = new asynchOptionBoolean();

                includePrimaryRequest.name = asynchOptionEnum.alwaysIncludePrimaryRequest;
                includePrimaryRequest.value = true;
                runOptions[4] = includePrimaryRequest;

                runOptionLanguageArray roOutputFormat = new runOptionLanguageArray();
                roOutputFormat.name = runOptionEnum.outputLocale;
                String[] fmt = { "en-us" };
                roOutputFormat.value = fmt;
                runOptions[5] = roOutputFormat;

                //Run the report
                response = this.rptService.run(reportPathObj, new parameterValue[] { }, runOptions);
                //If response is not immediately complete, call wait until complete
                if (!(response.status == (asynchReplyStatusEnum.complete)))
                {
                    while (!(response.status == asynchReplyStatusEnum.complete))
                    {
                        //before calling wait, double check that it is okay
                        if (hasSecondaryRequest(response, "wait"))
                        {
                            response =
                             this.rptService.wait(
                               response.primaryRequest,
                               new parameterValue[] { },
                               new option[] { });
                        }
                        else
                        {
                            Console.Write("Error: Wait method not available as expected.");
                            return;
                        }
                    }
                    //check if output is ready

                    if (outputIsReady(response))
                    {
                        response =
                         this.rptService.getOutput(response.primaryRequest, new parameterValue[] { },
                          new option[] { });
                    }
                    else
                    {
                        Console.Write("output is not ready!");
                    }
                }

                String data = getOutputPage(response);
                // Write the report output to file system
                Console.Write("Writing the output of the original report..");


                StreamWriter sw = File.CreateText(savePath + "\\original.html");
                sw.Write(data);
                sw.Flush();
                sw.Close();


                //Drill down in the report
                //set up drill down parameter.
                simpleParmValueItem item = new simpleParmValueItem();
                item.use = "[great_outdoors_company].[Years].[Years].[Year]->:[PC].[@MEMBER].[20050101-20051231]";
                item.inclusive = true;

                parmValueItem[] pvi = new parmValueItem[1];
                pvi[0] = item;

                parameters[0] = new parameterValue();
                parameters[0].name = "Year";
                parameters[0].value = pvi;

                response = this.rptService.drill(response.primaryRequest, parameters, drillOptions);

                if (!(response.status == (asynchReplyStatusEnum.complete)))
                {
                    while (!(response.status == asynchReplyStatusEnum.complete))
                    {
                        //before calling wait, double check that it is okay
                        if (hasSecondaryRequest(response, "wait"))
                        {
                            response =
                             this.rptService.wait(
                               response.primaryRequest,
                               new parameterValue[] { },
                               new option[] { });
                        }
                        else
                        {
                            Console.Write("Error: Wait method not available as expected.");
                            return;
                        }
                    }
                    //check if output is ready

                    if (outputIsReady(response))
                    {
                        response =
                         this.rptService.getOutput(response.primaryRequest, new parameterValue[] { },
                          new option[] { });
                    }
                    else
                    {
                        Console.Write("output is not ready!");
                    }
                }

                data = getOutputPage(response);
                // Write the report output to file system
                Console.Write("Writing the output of the drill down report..");


                StreamWriter sw2 = File.CreateText(savePath + "\\drilldown.html");
                sw2.Write(data);
                sw2.Flush();
                sw2.Close();


                // release the conversation to free resources.
                this.rptService.release(response.primaryRequest);

            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message.ToString());
                Console.WriteLine(ex.StackTrace);

            }
        }

Cognos 8 SDK google search

Google

New C8 SDK Utility --- Cognos 8 Modification Check

The BI Centre C8 Modification Check provides a Cognos SDK developer with a workable C# solution that will allow you to:

· Search the Content Store for items that have been modified after a selected date value

For example, if you were looking for all reports that were modified on June 3rd, 2008 then you would select the date June 2nd, 2008. The code will search for all items that have been modified after the selected date value from the date control.

The results of the search are then rendered to a text box control.