static void TestParse() { PlanSchedule sch = new PlanSchedule { Url = @"http://*****:*****@"c:\", Format = "Excel", WaitEnd = true, Reports = new Report[] { new Report { Id = "4767", Name = "Report A", Cuid = "AAAAAAAAAAAAAAAAAAAé", Type = "Webi", Prompts = new Prompt[] { new Prompt { Name = "Begin Date", Value = "01/01/2009" }, new Prompt { Name = "End Date", Value = "01/02/2009" } } } } }; sch.ParseToXml(@"c:\out2.xml"); PlanSchedule reports2 = PlanSchedule.ParseFromXml(@"c:\out2.xml"); }
static int Main(string[] args) { try{ Console.WriteLine(""); if (args.Length != 2) { Console.WriteLine("Error: Number of argument is invalid !"); PrintHelper(); return((int)ExitCode.InvalidArguments); } string xmlFIlePath = args[0]; string logFIlePath = args[1]; if (!File.Exists(xmlFIlePath)) { Console.WriteLine("Error: Xml file argument doesn't exist !"); PrintHelper(); return((int)ExitCode.InvalidArguments); } if (!Directory.Exists(Path.GetDirectoryName(logFIlePath))) { Console.WriteLine("Error: The directory of the log file argument doesn't exist !"); PrintHelper(); return((int)ExitCode.InvalidArguments); } Logger logger; try{ logger = new Logger(args[1]); }catch (Exception ex) { Console.WriteLine("Failed to create log file: " + ex.Message); return((int)ExitCode.InvalidArguments); } PlanSchedule data; try{ logger.Log("Parse xml file to get reports (" + xmlFIlePath + ")"); data = PlanSchedule.ParseFromXml(xmlFIlePath); logger.Log("\tVersion : " + data.Credentials.Version); logger.Log("\tUrl : " + data.Credentials.Url); logger.Log("\tDomain : " + data.Credentials.Domain); logger.Log("\tAuthType : " + data.Credentials.AuthType); logger.Log("\tLogin : "******"\tWithPrompts : " + data.WithPrompts); logger.Log("\tDestination : " + data.Destination); logger.Log("\tFormat : " + data.Format); logger.Log("\tWaitEnd : " + data.WaitEnd); logger.Log("\tCleanEnd : " + data.CleanEnd); logger.Log("\tReport Count : " + data.Reports.Length); }catch (Exception ex) { logger.LogAndClose("Failed to parse Xml file: " + ex.Message); return((int)ExitCode.FailedToLoadXml); } SessionManager session; try{ session = new SessionManager(); session.LogEvent += new LogHandler(logger.Log); session.Login(data.Credentials); }catch (Exception ex) { logger.LogAndClose(ex.Message); return((int)ExitCode.FailedToLogin); } BusinessObjectsUtils.ExitCode succeed; try{ Report[] reports = data.Reports; var scheduler = new SchedulerManager(session); succeed = BusinessObjectsUtils.ExitCode.SUCCEED; succeed = scheduler.ScheduleReports(ref reports, data.WithPrompts, null, data.Destination, data.Format, data.WaitEnd, data.CleanEnd, data.NotifEmail); session.Logout(); }catch (Exception ex) { session.Logout(); logger.LogAndClose("Failed to schedule reports: " + ex.Message); return((int)ExitCode.FailedToSchedule); } if (succeed == BusinessObjectsUtils.ExitCode.SUCCEED) { logger.LogAndClose("End of scheduling. All repports were successfully scheduled ! "); return((int)ExitCode.Succeed); } else { logger.LogAndClose("End of scheduling. Failed to schedule some reports ! "); return((int)ExitCode.FailedToCreateReports); } }catch (Exception) { return((int)ExitCode.UnknownError); } }