public PipelineContext(PipelineContext ctx, DatasourceAdmin ds, DatasourceReport report) { var eng = ctx.ImportEngine; Switches = ctx.Switches; NewLastUpdated = eng.StartTimeUtc; ImportEngine = eng; RunAdministrations = eng.RunAdministrations; DatasourceAdmin = ds; DatasourceReport = report; Pipeline = ds.Pipeline; ImportLog = eng.ImportLog.Clone(ds.Name); DebugLog = eng.DebugLog.Clone(ds.Name); ErrorLog = eng.ErrorLog.Clone(ds.Name); MissedLog = eng.MissedLog.Clone(ds.Name); ImportFlags = eng.ImportFlags; LogAdds = (ds.LogAdds > 0) ? ds.LogAdds : eng.LogAdds; MaxAdds = (ds.MaxAdds >= 0) ? ds.MaxAdds : eng.MaxAdds; MaxEmits = (ds.MaxEmits >= 0) ? ds.MaxEmits : eng.MaxEmits; if (MaxEmits < 0 && (ImportFlags & _ImportFlags.MaxAddsToMaxEmits) != 0) { MaxEmits = MaxAdds; } ImportLog.Log("Current maxAdds={0}, maxEmits={1}", MaxAdds, MaxEmits); }
public RunAdministrations LoadAdministration(PipelineContext ctx) { JObject cmdObj = JObject.Parse("{ 'sort': [{'adm_date': 'desc'}]}"); var ret = new RunAdministrations(ctx.ImportEngine.RunAdminSettings); try { if (!DocType.IndexExists) { return(ret); //Nothing to load here... } String url = ((ctx.ImportFlags & _ImportFlags.FullImport) == 0) ? DocType.UrlPart : DocType.UrlPartForPreviousIndex; if (!Connection.Exists(url)) { ctx.ErrorLog.Log("Cannot load previous administration: '{0}' not exists", url); return(ret); } var e = new ESRecordEnum(Connection, url, cmdObj, ret.Settings.Capacity, "5m", false); foreach (var doc in e) { RunAdministration ra; try { ra = new RunAdministration(doc._Source); } catch (Exception err) { String msg = String.Format("Invalid record in run administration. Skipped.\nRecord={0}.", doc); ctx.ImportLog.Log(_LogType.ltWarning, msg); ctx.ErrorLog.Log(_LogType.ltWarning, msg); ctx.ErrorLog.Log(err); continue; } ret.Add(ra); if (ret.Count >= 500) { break; } } return(ret.Dump("loaded")); } catch (Exception err) { if ((ctx.ImportFlags & _ImportFlags.FullImport) == 0) { throw; } ctx.ErrorLog.Log("Cannot load previous administration:"); ctx.ErrorLog.Log(err); return(ret); } }
public PipelineContext(ImportEngine eng) { ImportEngine = eng; ImportLog = eng.ImportLog; DebugLog = eng.DebugLog; ErrorLog = eng.ErrorLog; MissedLog = eng.MissedLog; ImportFlags = eng.ImportFlags; NewLastUpdated = eng.StartTimeUtc; RunAdministrations = eng.RunAdministrations; Switches = new Switches(eng.SwitchesFromXml + " " + eng.Switches); //Switches are overriding }
public void SaveAdministration(PipelineContext ctx, RunAdministrations admins) { if (admins == null || admins.Count == 0) { return; } String urlPart = DocType.UrlPart + "/"; foreach (var a in admins) { String key = a.DataSource + "_" + a.RunDateUtc.ToString("yyyyMMdd_HHmmss"); Connection.Post(urlPart + key, a.ToJson()).ThrowIfError(); } }
public void Merge(RunAdministrations other) { Dump("before dst"); other.Dump("before src"); if (other == null || other.list.Count == 0) { return; } if (list.Count == 0) { list.AddRange(other.list); return; } foreach (var a in other.list) { Add(a); } Dump("after merge"); }
public void Save(RunAdministrations a) { a.Save(); }