Example #1
0
        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");
        }
Example #2
0
        public void CachePlan(PlanSchedule plan)
        {
            Parser.path = @"D:\documents\frostbow\";
            var savePath = Parser.GetTopDirectory() + @"Results\" + problemname + @"\Solutions\";

            Directory.CreateDirectory(savePath);
            var planStepList = new List <IPlanStep>();
            var mergeMap     = plan.MM.ToRootMap();

            foreach (var step in plan.Orderings.TopoSort(plan.InitialStep))
            {
                if (step is CamPlanStep cps)
                {
                    foreach (var seg in cps.TargetDetails.ActionSegs)
                    {
                        if (mergeMap.ContainsKey(seg.ActionID))
                        {
                            seg.ActionID = mergeMap[seg.ActionID];
                        }
                    }
                }
                planStepList.Add(step);
            }
            BinarySerializer.SerializeObject(savePath + "PlanSteps", planStepList);

            //BinarySerializer.SerializeObject(savePath + "Merges")
        }
Example #3
0
        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);
            }
        }
Example #4
0
 private void btSchedule_Click()
 {
     try{
         var activesheet = (Excel.Worksheet)_excelapp.ActiveSheet;
         if (!_parser.checkTablePresent(activesheet))
         {
             return;
         }
         using (var lForm = new FrmSchedule(_excelapp.Hwnd)) {
             lForm.Reports     = _parser.GetReportsList(activesheet.ListObjects[1]);
             lForm.Destination = _settings.GetWorksheetParam("Destination", "");
             lForm.Format      = _settings.GetWorksheetParam("Format", "");
             lForm.NotifEmail  = _settings.GetWorksheetParam("NotifEmail", "");
             if (lForm.ShowDialog() != DialogResult.OK)
             {
                 return;
             }
             var reports = _parser.ParseListObjectToReports(activesheet.ListObjects[1], true);
             if (lForm.Schedule)
             {
                 _settings.SetWorksheetParam("Destination", lForm.Destination);
                 _settings.SetWorksheetParam("Format", lForm.Format);
                 _settings.SetWorksheetParam("NotifEmail", lForm.NotifEmail);
                 var scheduler = new SchedulerManager(_session);
                 var runner    = new FrmRunner(_session.Logger, scheduler.Cancel);
                 var exitcode  = runner.Execute(() =>
                                                scheduler.ScheduleReports(
                                                    ref reports,
                                                    lForm.WithPrompts,
                                                    lForm.Date,
                                                    lForm.Destination,
                                                    lForm.Format,
                                                    lForm.WaitEnd,
                                                    lForm.CleanEnd,
                                                    lForm.NotifEmail
                                                    )
                                                );
                 if (exitcode == ExitCode.FAILED || exitcode == ExitCode.CANCELED)
                 {
                     return;
                 }
                 _parser.UpdateListObjectStatus(activesheet.ListObjects[1], reports);
             }
             else if (lForm.CreateXML)
             {
                 string lFilename = String.Empty;
                 using (SaveFileDialog saveDialog = new SaveFileDialog()) {
                     saveDialog.Filter = "XML FIle|*.xml";
                     saveDialog.Title  = "Save XML File";
                     saveDialog.ShowDialog();
                     lFilename = saveDialog.FileName;
                 }
                 if (lFilename != String.Empty)
                 {
                     try {
                         Application.UseWaitCursor = true;
                         PlanSchedule schedulerplan = new PlanSchedule {
                             Credentials = this._session.Credentials,
                             WithPrompts = lForm.WithPrompts,
                             Destination = lForm.Destination,
                             Format      = lForm.Format,
                             WaitEnd     = lForm.WaitEnd,
                             CleanEnd    = lForm.CleanEnd,
                             NotifEmail  = lForm.NotifEmail,
                             Reports     = reports
                         };
                         schedulerplan.ParseToXml(lFilename);
                         MsgBox.Show("Command line :", "\"" + Func.GetRunnerPath() + "\" \"" + lFilename + "\" \"" + lFilename.Replace(".xml", ".log") + "\"");
                     } catch { throw; } finally {
                         Application.UseWaitCursor = false;
                     }
                 }
             }
         }
     } catch (Exception ex) { new BusinessObjectsUtils.FrmException(_excelapp.Hwnd, ex).ShowDialog(); }
 }