public override void Run() { base.Run(); Console.WriteLine("Writing configuration"); Console.WriteLine("---------------------"); if (File.Exists(_options.ConfigFile) && _options.Overwrite == false) { Console.WriteLine($"Config file {_options.ConfigFile} exists."); Console.WriteLine($"Overwrite not specified so file will not be overwritten"); return; } var cfg = new OperationConfig(); cfg.Url = _options.Url; cfg.Database = _options.Database; cfg.Token = _options.Token; cfg.Timeout = _options.Timeout; ISitecoreEndpoint endPoint = _endpointFactory.Create(_options.Url); try { Console.Write("Fetching indexes..."); cfg.Indexes = endPoint.FetchIndexes(cfg.Token); Console.WriteLine(); Console.Write("Fetching item data..."); var items = endPoint.FetchItemIds(cfg.Token, _options.Database, _options.Query); cfg.Items = new Queue <ItemEntry>(items); Console.WriteLine(); } catch (Exception ex) { Console.WriteLine(Environment.NewLine + "Exception caught from endpoint while extracting setup data:"); while (ex != null) { Console.WriteLine($"{ex.GetType().Name}: {ex.Message}"); //if(ex is System.Net.WebException) //{ // var s = (ex as System.Net.WebException).Response.GetResponseStream(); // var sr = new StreamReader(s); // Console.WriteLine(sr.ReadToEnd()); //} ex = ex.InnerException; } return; } Console.Write("Saving config to disk..."); _configFileManager.Save(_options.ConfigFile, cfg); Console.WriteLine(); Console.WriteLine($"Config written to {_configFileManager.VerifyFilename(_options.ConfigFile)}"); }
public override void Run() { base.OverrideFileType(_options.ConfigFile); base.Run(); Console.WriteLine("Running indexing"); Console.WriteLine("----------------"); var config = _configFileManager.Load(_options.ConfigFile); if (config == null) { Console.WriteLine($">> Error: Config file '{_configFileManager.VerifyFilename(_options.ConfigFile)}' not found"); return; } if (config.Processed.Count == config.TotalItems) { Console.WriteLine($">> No items to process."); return; } ISitecoreEndpoint endPoint = _endpointFactory.Create(config.Url); var state = new ProcessState(endPoint, _options, config); state.Config.Attempts += 1; var startedAt = DateTime.Now; SetTimeout(state); ProcessAllGroups(state); var endedAt = DateTime.Now; var elapsed = endedAt - startedAt; state.Config.Elapsed += elapsed; SaveState(state); Console.WriteLine($">> Finished"); Console.WriteLine($">> at {endedAt} - after {elapsed.FormatForDisplay()}"); Console.WriteLine($">> with {state.Config.Errors.Count()} errors"); Console.WriteLine($">> total time now {state.Config.Elapsed.FormatForDisplay()} after {state.Config.Attempts} attempts."); }
public ProcessState(ISitecoreEndpoint endPoint, IndexingOptions options, OperationConfig config) { Endpoint = endPoint; Options = options; Config = config; }