예제 #1
0
파일: Program.cs 프로젝트: fniwes/n2cms
        static void Main(string[] args)
        {
            if (!Environment.UserInteractive)
            {
                ServiceBase.Run(new WindowsService());
                return;
            }

            var server = new IndexerServer();

            server.Start();

            Console.WriteLine("Listening on " + server.UriPrefix + ". Press enter key to exit");
            string command = "";

            do
            {
                command = Console.ReadLine();
                if ("debug".Equals(command, StringComparison.InvariantCultureIgnoreCase))
                {
                    Trace.Listeners.Add(new ConsoleWriterTraceListener());
                }
                if ("exit".Equals(command, StringComparison.InvariantCultureIgnoreCase))
                {
                    break;
                }
                if ("cls".Equals(command, StringComparison.InvariantCultureIgnoreCase))
                {
                    Console.Clear();
                }
            } while (!string.IsNullOrEmpty(command));

            Console.WriteLine("Exiting...");
            server.Stop();
        }
예제 #2
0
파일: Program.cs 프로젝트: brianmatic/n2cms
        static void Main(string[] args)
        {
            if (!Environment.UserInteractive)
            {
                ServiceBase.Run(new WindowsService());
                return;
            }

            var server = new IndexerServer();

            server.Start();

            Console.WriteLine("Listening on " + server.UriPrefix + ". Press enter key to exit");
            string command = "";
            do
            {
                command = Console.ReadLine();
                if ("debug".Equals(command, StringComparison.InvariantCultureIgnoreCase))
                    Trace.Listeners.Add(new ConsoleWriterTraceListener());
                if ("exit".Equals(command, StringComparison.InvariantCultureIgnoreCase))
                    break;
                if ("cls".Equals(command, StringComparison.InvariantCultureIgnoreCase))
                    Console.Clear();
            } while (!string.IsNullOrEmpty(command));

            Console.WriteLine("Exiting...");
            server.Stop();
        }
예제 #3
0
		public override void TestFixtureSetUp()
		{
			base.TestFixtureSetUp();

			definitions = TestSupport.SetupDefinitions(typeof(PersistableItem), typeof(PersistableItem2), typeof(PersistablePart));
			server = new IndexerServer();
			server.Start();
		}
예제 #4
0
파일: Program.cs 프로젝트: nikita239/Aspect
 private static void Search(IndexerServer server, string instance, string query)
 {
     Console.WriteLine("Searching for " + query);
     foreach (var result in server.Search(instance, query).Hits)
     {
         Console.WriteLine(result.Content.ID + ":\t" + result.Title);
     }
 }
예제 #5
0
		private static void Search(IndexerServer server, string instance, string query)
		{
			Console.WriteLine("Searching for " + query);
			foreach (var result in server.Search(instance, query).Hits)
			{
				Console.WriteLine(result.Content.ID + ":\t" + result.Title);
			}
		}
예제 #6
0
        public WindowsService()
        {
            ServiceName  = "N2 Search Service";
            EventLog.Log = "Application";

            this.CanHandlePowerEvent         = true;
            this.CanHandleSessionChangeEvent = true;
            this.CanPauseAndContinue         = true;
            this.CanShutdown = true;
            this.CanStop     = true;

            server = new IndexerServer();
        }
예제 #7
0
		public WindowsService()
		{
			ServiceName = "N2 Search Service";
			EventLog.Log = "Application";

			this.CanHandlePowerEvent = true;
			this.CanHandleSessionChangeEvent = true;
			this.CanPauseAndContinue = true;
			this.CanShutdown = true;
			this.CanStop = true;

			server = new IndexerServer();
		}
예제 #8
0
        static void Main(string[] args)
        {
            if (!Environment.UserInteractive)
            {
                ServiceBase.Run(new WindowsService());
                return;
            }

            var server = new IndexerServer();

            server.Start();
            Console.WriteLine("Listening on " + server.UriPrefix + ". Type \"exit\" and press enter to exit");

			string instance = "Pages";
			var commands = new Dictionary<string, Action<string>>(StringComparer.InvariantCultureIgnoreCase);

			commands["debug"] = (arg) => Trace.Listeners.Add(new ConsoleWriterTraceListener());
			commands["exit"] = (arg) => { server.Stop(); Environment.Exit(-1); };
			commands["cls"] = (arg) => Console.Clear();
			commands["search"] = (arg) => Search(server, instance, arg);
			commands["count"] = (arg) => Count(server, instance);
			commands["instance"] = (arg) => { if (string.IsNullOrEmpty(arg)) Console.WriteLine("Current instance: " + instance); else instance = arg; };
			commands["help"] = (arg) => { Console.WriteLine("Available commands: "); foreach (var command in commands) Console.WriteLine(" * " + command.Key); };

			try
			{	        
				do
				{
					Console.Write(">");
					var input = Console.ReadLine();
					var command = input.Split(' ')[0];
					var argument = input.Substring(command.Length);

					Action<string> action;
					if (commands.TryGetValue(command, out action))
						action(argument);
					else if (!string.IsNullOrEmpty(command))
						Console.WriteLine("Invalid command");
					
				} while (true);

			}
			finally
			{
				Console.WriteLine("Exiting...");
				server.Stop();
			}
        }
예제 #9
0
파일: Program.cs 프로젝트: nikita239/Aspect
 private static void Count(IndexerServer server, string instance)
 {
     Console.WriteLine("Number of documents on instance " + instance + ": " + server.Statistics(instance).TotalDocuments);
 }
예제 #10
0
파일: Program.cs 프로젝트: nikita239/Aspect
        static void Main(string[] args)
        {
            if (!Environment.UserInteractive)
            {
                ServiceBase.Run(new WindowsService());
                return;
            }

            var server = new IndexerServer();

            server.Start();
            Console.WriteLine("Listening on " + server.UriPrefix + ". Type \"exit\" and press enter to exit");

            string instance = "Pages";
            var    commands = new Dictionary <string, Action <string> >(StringComparer.InvariantCultureIgnoreCase);

            commands["debug"]    = (arg) => Trace.Listeners.Add(new ConsoleWriterTraceListener());
            commands["exit"]     = (arg) => { server.Stop(); Environment.Exit(-1); };
            commands["cls"]      = (arg) => Console.Clear();
            commands["search"]   = (arg) => Search(server, instance, arg);
            commands["count"]    = (arg) => Count(server, instance);
            commands["instance"] = (arg) => { if (string.IsNullOrEmpty(arg))
                                              {
                                                  Console.WriteLine("Current instance: " + instance);
                                              }
                                              else
                                              {
                                                  instance = arg;
                                              } };
            commands["help"] = (arg) => { Console.WriteLine("Available commands: "); foreach (var command in commands)
                                          {
                                              Console.WriteLine(" * " + command.Key);
                                          }
            };

            try
            {
                do
                {
                    Console.Write(">");
                    var input    = Console.ReadLine();
                    var command  = input.Split(' ')[0];
                    var argument = input.Substring(command.Length);

                    Action <string> action;
                    if (commands.TryGetValue(command, out action))
                    {
                        action(argument);
                    }
                    else if (!string.IsNullOrEmpty(command))
                    {
                        Console.WriteLine("Invalid command");
                    }
                } while (true);
            }
            finally
            {
                Console.WriteLine("Exiting...");
                server.Stop();
            }
        }
예제 #11
0
		private static void Count(IndexerServer server, string instance)
		{
			Console.WriteLine("Number of documents on instance " + instance + ": " + server.Statistics(instance).TotalDocuments);
		}