public void SimpleCommandLine()
        {
            IndexerParameters indexperParamters = new IndexerParameters();

            indexperParamters.DataSource   = "test1";
            indexperParamters.IndexPath    = "test2";
            indexperParamters.PreviewWidth = 10;
            indexperParamters.ThumbWidth   = 11;

            string            cmd    = IndexerParameters.CreateCommandLine(indexperParamters);
            IndexerParameters parsed = IndexerParameters.ParseCommandLine(cmd.Split(' '));

            Assert.AreEqual(indexperParamters.DataSource, parsed.DataSource);
            Assert.AreEqual(indexperParamters.IndexPath, parsed.IndexPath);
            Assert.AreEqual(indexperParamters.PreviewWidth, parsed.PreviewWidth);
            Assert.AreEqual(indexperParamters.ThumbWidth, parsed.ThumbWidth);
        }
Пример #2
0
        public static void Main(string[] args)
        {
#if DEBUG
            if (args.Length < 2)
            {
                args = CreateFakeParams();
            }
#endif
            try {
                log4net.GlobalContext.Properties["pid"] = Process.GetCurrentProcess().Id;
                Log.Info("indexer started");
                IndexerParameters parameters = IndexerParameters.ParseCommandLine(args);
                Log.Info("Arguments list");
                foreach (var argument in args)
                {
                    Log.Info(string.Format("{0}", argument));
                }
                if (parameters != null)
                {
                    Log.Info("arguments parsed succesfully");
                    SettingsStore.Default.CurrentDataSource = parameters.DataSource;
                    Indexer indexer = new Indexer();
                    indexer.Model = new DmModel();
                    indexer.Model.OpenDataSource(parameters.DataSource);
                    Log.Info("data source ready");
                    indexer.Process(parameters);
                }
                else
                {
                    Log.Info("parameters incorrect");
                }
                Log.Info("indexer stopped");
            } catch (Exception e) {
                Log.Error(e.Message, e);
            }
        }