123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- using System;
- using System.Windows.Forms;
- using System.Web.Services.Protocols;
- using SamplesCommon;
- using cognosdotnet_10_2;
- namespace CancelReport
- {
- class CancelReport
- {
- public CancelReport(){}
- static void Main(string[] args)
- {
- string cBIUrl = "";
- reportService1 cBIRS = null;
- contentManagerService1 cBICMS = null;
- SamplesConnect connectDlg = new SamplesConnect();
- CancelReportDlg cancelReportDlgObject = new CancelReportDlg();
- if (args.GetLength(0) == 0 )
- {
-
- connectDlg.ShowDialog();
- if (connectDlg.IsConnectedToCBI() == true)
- {
- cBIRS = connectDlg.CBIRS;
- cBICMS = connectDlg.CBICMS;
- cBIUrl = connectDlg.CBIURL;
- cancelReportDlgObject.setConnection(cBIRS, cBIUrl);
- cancelReportDlgObject.setReportList(BaseClassWrapper.buildReportQueryList(cBICMS));
- cancelReportDlgObject.setSelectedReportIndex(0);
- cancelReportDlgObject.ShowDialog();
- }
- }
- }
- public string doCancelReport(reportService1 cBIRS, string reportPath, ref string resultMessage)
- {
- if (cBIRS == null)
- {
- return "the Server connection provided is invalid.";
- }
- asynchReply runResponse = null;
- option[] arrReportRunOpts = new option[4];
- asynchOptionInt primaryWait = new asynchOptionInt();
- asynchOptionBoolean includeReq = new asynchOptionBoolean();
- runOptionStringArray formatList = new runOptionStringArray();
- runOptionBoolean blnOutputRunOpts = new runOptionBoolean();
- runOptionBoolean continueConversation = new runOptionBoolean();
- parameterValue[] paramValueArray = new parameterValue[] {};
-
-
- blnOutputRunOpts.name = runOptionEnum.saveOutput;
- blnOutputRunOpts.value = false;
-
- string[] format = new string[1];
- format[0] = "HTML";
- formatList.name = runOptionEnum.outputFormat;
- formatList.value = format;
-
- continueConversation.name = runOptionEnum.continueConversation;
- continueConversation.value = true;
-
- primaryWait.name = asynchOptionEnum.primaryWaitThreshold;
- primaryWait.value = 1;
-
- includeReq.name = asynchOptionEnum.alwaysIncludePrimaryRequest;
- includeReq.value = true;
-
- arrReportRunOpts[0] = blnOutputRunOpts;
- arrReportRunOpts[1] = formatList;
- arrReportRunOpts[2] = primaryWait;
- arrReportRunOpts[3] = includeReq;
- searchPathSingleObject reportPathSO = new searchPathSingleObject();
- reportPathSO.Value = reportPath;
-
-
-
- runResponse = cBIRS.run(reportPathSO, paramValueArray, arrReportRunOpts);
-
-
- if (hasSecondaryRequest(runResponse, "cancel"))
- {
-
-
- cBIRS.cancel(runResponse.primaryRequest);
-
- resultMessage += "The report has been successfully cancelled.";
- }
- else
- {
- resultMessage += "The report ran too quickly to be cancelled.";
- }
- return resultMessage;
- }
- public bool hasSecondaryRequest(asynchReply response, string secondaryRequest)
- {
- asynchSecondaryRequest[] secondaryRequests =
- response.secondaryRequests;
- for (int i = 0; i < secondaryRequests.Length; i++)
- {
- if (secondaryRequests[i].name.CompareTo(secondaryRequest)
- == 0)
- {
- return true;
- }
- }
- return false;
- }
- }
- }
|