Example #1
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 + ". 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();
        }
Example #2
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 + ". 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();
        }
Example #3
0
		public override void TestFixtureSetUp()
		{
			base.TestFixtureSetUp();

			definitions = TestSupport.SetupDefinitions(typeof(PersistableItem), typeof(PersistableItem2), typeof(PersistablePart));
			server = new IndexerServer();
			server.Start();
		}
Example #4
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);
     }
 }
Example #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);
			}
		}
Example #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();
        }
Example #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();
		}
Example #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();
			}
        }
Example #9
0
 private static void Count(IndexerServer server, string instance)
 {
     Console.WriteLine("Number of documents on instance " + instance + ": " + server.Statistics(instance).TotalDocuments);
 }
Example #10
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();
            }
        }
Example #11
0
		private static void Count(IndexerServer server, string instance)
		{
			Console.WriteLine("Number of documents on instance " + instance + ": " + server.Statistics(instance).TotalDocuments);
		}