/// <summary> /// upsert edge with the from and to instances /// </summary> /// <typeparam name="TEdge"></typeparam> /// <typeparam name="TFrom"></typeparam> /// <typeparam name="TTo"></typeparam> /// <param name="arangoDatabase"></param> /// <param name="from"></param> /// <param name="to"></param> /// <param name="setter"></param> /// <returns></returns> public static TEdge UpsertEdge <TEdge, TFrom, TTo>(this IArangoDatabase arangoDatabase, TFrom from, TTo to, Action <TEdge> setter = null) where TEdge : EdgeBase, new() where TFrom : VertexBase where TTo : VertexBase { TEdge edge = new TEdge(); edge._from = $"{typeof(TFrom).Name}/{from._key}"; edge._to = $"{typeof(TTo).Name}/{to._key}"; edge.BuildIdWithFromTo(); setter?.Invoke(edge); arangoDatabase.UpsertEdge(edge); return(edge); }
/// <summary> /// upsert edge with the from and to instances /// </summary> /// <typeparam name="TEdge"></typeparam> /// <typeparam name="TFrom"></typeparam> /// <typeparam name="TTo"></typeparam> /// <param name="arangoDatabase"></param> /// <param name="from"></param> /// <param name="to"></param> /// <param name="setter"></param> /// <returns></returns> public static TEdge UpsertEdge <TEdge, TFrom, TTo>(this IArangoDatabase arangoDatabase, string keyFrom, string keyTo, Action <TEdge> setter = null) where TEdge : EdgeBase, new() where TFrom : VertexBase where TTo : VertexBase { TEdge edge = new TEdge(); edge._from = keyFrom.EnsureGraphId <TFrom>(); edge._to = keyTo.EnsureGraphId <TTo>(); edge.BuildIdWithFromTo(); setter?.Invoke(edge); arangoDatabase.UpsertEdge(edge); return(edge); }
public async Task Search(JobAnalysis jobAnalysis, IArangoDatabase client, string timeStamp) { var urls = SearchJob(jobAnalysis); Dictionary <string, Job> jobs = new Dictionary <string, Job>(); JobAnalysisEntry jobAnalysisEntry = new JobAnalysisEntry() { _key = $"{jobAnalysis._key}__{timeStamp}", AnalysisTime = DateTime.Now, KeywordStatistics = new Dictionary <string, int>(), TotalJobs = urls.Count, }; int urlIndex = 0; // download jobs and add edge to entry foreach (var url in urls) { urlIndex++; _logger.Information($"Download Job Url ({urlIndex} of {urls.Count}): {url}"); await DownloadJob(url, jobAnalysisEntry, client, jobs); } AnalyzeJobs(jobAnalysis, jobAnalysisEntry, jobs); client.UpsertIgnoreNull(jobAnalysisEntry); client.UpsertEdge <EntryOf, JobAnalysisEntry, JobAnalysis>(jobAnalysisEntry, jobAnalysis); // add edges to jobs; foreach (var job in jobs.Values) { client.UpsertEdge <JobAnalysisOf, JobAnalysisEntry, Job>(jobAnalysisEntry, job); } }