예제 #1
0
파일: Tests.cs 프로젝트: lafar6502/cogmon
 public static void TestJob(string jobId)
 {
     var wc = new Castle.Windsor.WindsorContainer();
     ServiceConfigurator.Begin(wc)
         .FinishConfiguration();
     var js = wc.Resolve<JobScheduler>();
     js.TestJobId = jobId;
     foreach (var st in wc.ResolveAll<NGinnBPM.MessageBus.Impl.IStartableService>())
     {
         st.Start();
     }
     Console.WriteLine("Testing job {0}. Hit enter to stop", jobId);
     Console.ReadLine();
     foreach (var st in wc.ResolveAll<NGinnBPM.MessageBus.Impl.IStartableService>())
     {
         st.Stop();
     }
     wc.Dispose();
 }
예제 #2
0
        /// <summary>
        /// main entry point of the application
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            //setup Dependency Container
            SetupContainer();
            //register Dependencies
            RegisterComponents();

            int exitCode = 0x0;

            try
            {
                var cmdCollection = _container.Resolve <SpreadsheetCmdCollection>();
                var sheetPrinter  = _container.Resolve <ISheetPrinter>();

                //variable that hold the current sheet
                ISheet currentSheet = null;
                while (true)
                {
                    Console.Write("enter command:");

                    //extract a series of parameters in user input with a space separator
                    //format of the command line: <command key> <param1> <param2> <param3> ...
                    //e.g. N 5 6
                    string[] input = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                    //command key is the first parameter
                    string cmdKey = input.Length > 0 ? input[0] : "";

                    if (cmdKey.Equals("Q"))
                    {
                        //break the loop amd end this application
                        break;
                    }

                    //the subsequent parameters will be used as command arguments
                    string[] cmdArgs = input.Length > 1 ? input.Skip(1).ToArray() : new string[] { };

                    //start matching the command key with the registered commands
                    if (cmdCollection.CommandCollection.ContainsKey(cmdKey))
                    {
                        var cmd    = cmdCollection.CommandCollection[cmdKey];
                        var result = cmd.Execute(currentSheet, cmdArgs);
                        if (result.Success)
                        {
                            currentSheet = result.Spreadsheet;
                            sheetPrinter.PrintContent(currentSheet, Console.Out);
                        }
                        else
                        {
                            Console.WriteLine(result.ErrorMessage);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Invalid Command");
                    }
                }
            }
            catch (Exception ex)
            {
                //unexpected error goes to here
                exitCode = ex.HResult;
            }
            finally
            {
                //set exit code
                Environment.ExitCode = exitCode;
                //dispose dependencies
                _container.Dispose();
            }
        }