123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373 |
- using System;
- using System.Text;
- using System.Web.Services.Protocols;
- using System.Threading;
- using System.Windows.Forms;
- using SamplesCommon;
- using cognosdotnet_10_2;
- namespace ReportParameters
- {
-
-
-
- public class ReportParameters
- {
-
-
-
- public ReportParameters()
- {
- }
- public static reportService1 repSvc = null;
- public static contentManagerService1 cmService = null;
- public static SamplesConnect connection = null;
- public static SamplesWindow gui = null;
-
-
-
-
-
-
-
- public baseParameter[] getReportParameters( string reportPath, reportService1 cBIRS )
- {
- searchPathSingleObject cmReportPath = new searchPathSingleObject();
- cmReportPath.Value = reportPath;
-
-
- asynchReply gpReply = cBIRS.getParameters( cmReportPath, new parameterValue[] {}, new runOption[]{} );
-
-
- if ((gpReply.status != asynchReplyStatusEnum.complete)
- && (gpReply.status != asynchReplyStatusEnum.conversationComplete) )
- {
- while ( (gpReply.status != asynchReplyStatusEnum.complete)
- && (gpReply.status != asynchReplyStatusEnum.conversationComplete) )
- {
- gpReply = cBIRS.wait(gpReply.primaryRequest,new parameterValue[] {}, new option[] {});
- }
- }
- if (gpReply.details == null)
- {
- return null;
- }
-
- for (int i = 0; i < gpReply.details.Length; i++)
- {
- if (gpReply.details[i] is asynchDetailParameters)
- {
- return ((asynchDetailParameters)gpReply.details[i]).parameters;
- }
- }
-
- return null;
- }
-
-
-
-
-
-
- public parameterValue[] setReportParameters( string reportName, baseParameter[] prm, bool isGui )
- {
- if( prm.Length > 0 )
- {
- parameterValue[] parms = new parameterValue[prm.Length];
- int pidx = 0;
- if( isGui )
- {
- SamplesInput inputter = new SamplesInput();
-
- foreach( parameter p in prm )
- {
-
-
-
-
-
-
- string desc = "Enter a value for prompt '" + p.name + "' (of type " + p.type.ToString() + "):";
- string val = inputter.getInput( null, desc, p.type.ToString() );
- simpleParmValueItem item = new simpleParmValueItem();
- item.use = val;
- parmValueItem[] pvi = new parmValueItem[1];
- pvi[0] = item;
- parms[pidx] = new parameterValue();
- parms[pidx].name = p.name;
- parms[pidx].value = pvi;
- pidx = pidx+1;
- }
-
- }
- else
- {
- foreach( parameter p in prm )
- {
-
-
-
-
-
-
- string desc = "Enter a value for prompt \"" + p.name + "\" (of type " + p.type.ToString() + "):";
- Console.WriteLine( desc );
- string val = Console.ReadLine();
- simpleParmValueItem item = new simpleParmValueItem();
- item.use = val;
- parmValueItem[] pvi = new parmValueItem[1];
- pvi[0] = item;
- parms[pidx] = new parameterValue();
- parms[pidx].name = p.name;
- parms[pidx].value = pvi;
- pidx = pidx+1;
- }
- }
- return parms;
- }
- return null;
- }
-
-
-
-
-
- public static void Main( string[] args )
- {
- Control.CheckForIllegalCrossThreadCalls = false;
- try
- {
- if( args[0].CompareTo( "--test" ) == 0 )
- {
-
- ReportParameters test = new ReportParameters();
- baseParameter[] param = test.getReportParameters("/content/folder[@name='Samples']/folder[@name='Models']/package[@name='GO Data Warehouse (query)']/folder[@name='SDK Report Samples']/report[@name='Order Method Range List']", repSvc);
- foreach( parameter p in param )
- {
- Console.WriteLine( "Name: {0}, Type: {1}", p.name, p.type );
- }
- parameterValue[] pv = test.setReportParameters("/content/folder[@name='Samples']/folder[@name='Models']/package[@name='GO Data Warehouse (query)']/folder[@name='SDK Report Samples']/report[@name='Order Method Range List']", param, false);
- foreach( parameterValue p in pv )
- {
- Console.WriteLine( "Name: {0}, Value: {1}", p.name, p.value );
- }
-
- }
- else
- {
-
- Console.WriteLine( "Unknown argument: {0}", args[0] );
- Console.WriteLine( "Use '--test' to run an automated test." );
- }
- }
- catch( IndexOutOfRangeException )
- {
-
- gui = new SamplesWindow();
- gui.Activated += new EventHandler( gui_Activated );
- gui.Actions.Click += new EventHandler( Actions_Click );
- Application.Run( gui );
- }
- }
- private static bool wasActivated = false;
-
-
-
-
-
-
- private static void gui_Activated( object sender, EventArgs e )
- {
- if( !wasActivated )
- {
- wasActivated = true;
- SamplesWindow ui = (SamplesWindow)sender;
- ui.applicationName = "Report Parameters";
- ui.applicationTitle = "Report Parameters";
- ui.applicationAction = "Go";
- ui.applicationVersion = "1.0";
- ui.AddText( "Connecting..." );
- ThreadPool.QueueUserWorkItem( new WaitCallback( createConnection ) );
- }
- }
-
-
-
-
-
-
-
-
- private static void createConnection( object state )
- {
- try
- {
- gui.Actions.Enabled = false;
- repSvc = new reportService1();
- repSvc.Url = gui.serverUrl;
- cmService = new contentManagerService1();
- cmService.Url = gui.serverUrl;
- gui.AddText( "... done creating connection." );
- gui.Actions.Enabled = true;
- }
- catch( SoapException ex )
- {
- SamplesException.ShowExceptionMessage(ex,true,ex.Message);
- gui.Close();
- }
- }
-
-
-
-
-
- private static void Actions_Click( object sender, EventArgs e )
- {
- gui.Actions.Enabled = false;
- gui.AddText( "Collecting parameters..." );
- Boolean bTestAnonymous = false;
-
- repSvc.Url = gui.serverUrl;
- cmService.Url = gui.serverUrl;
-
-
- searchPathMultipleObject homeDir = new searchPathMultipleObject();
- homeDir.Value = "~";
- try
- {
- baseClass[] bc = cmService.query ( homeDir, new propEnum[]{} , new sort[]{}, new queryOptions () );
- if (bc != null)
- bTestAnonymous = true;
- else
- bTestAnonymous = false;
- }
- catch( Exception ex )
- {
- ex.Message.ToString ();
- }
- if (bTestAnonymous == true)
- {
- gui.Actions.Enabled = true;
- ReportParameters test = new ReportParameters();
- baseParameter[] param = test.getReportParameters("/content/folder[@name='Samples']/folder[@name='Models']/package[@name='GO Data Warehouse (query)']/folder[@name='SDK Report Samples']/report[@name='Order Method Range List']", repSvc);
- foreach( baseParameter p in param )
- {
- StringBuilder output = new StringBuilder();
- output.AppendFormat( "Name: {0}, Type: {1}", p.name, p.type );
- gui.AddText( output.ToString() );
- }
- parameterValue[] pv = test.setReportParameters("/content/folder[@name='Samples']/folder[@name='Models']/package[@name='GO Data Warehouse (query)']/folder[@name='SDK Report Samples']/report[@name='Order Method Range List']", param, true);
- foreach( parameterValue p in pv )
- {
- StringBuilder output = new StringBuilder();
- foreach( simpleParmValueItem pvi in p.value )
- {
- output.AppendFormat( "Name: {0}, Value: {1}", p.name, pvi.use );
- }
- gui.AddText( output.ToString() );
- }
-
- gui.AddText( "... done query." );
- }
- else
- {
-
- SamplesLogon logon = new SamplesLogon( cmService );
- logon.ShowDialog( gui );
-
- if( !logon.loggedOn )
- {
- gui.AddText( "Unable to log on." );
- return;
- }
- else
- {
- ReportParameters test = new ReportParameters();
- baseParameter[] param = test.getReportParameters("/content/folder[@name='Samples']/folder[@name='Models']/package[@name='GO Data Warehouse (query)']/folder[@name='SDK Report Samples']/report[@name='Order Method Range List']", repSvc);
- foreach( parameter p in param )
- {
- StringBuilder output = new StringBuilder();
- output.AppendFormat( "Name: {0}, Type: {1}", p.name, p.type );
- gui.AddText( output.ToString() );
- }
- parameterValue[] pv = test.setReportParameters("/content/folder[@name='Samples']/folder[@name='Models']/package[@name='GO Data Warehouse (query)']/folder[@name='SDK Report Samples']/report[@name='Order Method Range List']", param, true);
- foreach( parameterValue p in pv )
- {
- StringBuilder output = new StringBuilder();
- foreach( simpleParmValueItem pvi in p.value )
- {
- output.AppendFormat( "Name: {0}, Value: {1}", p.name, pvi.use );
- }
- gui.AddText( output.ToString() );
- }
-
- gui.AddText( "... done querying." );
- }
- }
- gui.Actions.Enabled = true;
- }
- }
- }
|