/// <summary> /// VistaQuery constructor for all uses /// </summary> /// <param name="cxn"></param> /// <param name="sitecode"></param> /// <param name="vistaFile"></param> /// <param name="startIen"></param> /// <param name="maxRecords"></param> /// <param name="fields"></param> //public VistaQuery(/*AbstractConnection cxn, */ string sitecode, string vistaFile, string startIen, string maxRecords, string fields) //{ // //Connection = cxn; // SiteCode = sitecode; // VistaFile = vistaFile; // StartIen = startIen; // MaxRecords = maxRecords; // Fields = fields; //} /// <summary> /// VistaQuery constructor for use based on a job configuration /// </summary> /// <param name="config"></param> public VistaQuery(ExtractorConfiguration job, QueryConfiguration query) { SiteCode = job.SiteCode; MaxRecords = job.MaxRecordsPerQuery; VistaFile = query.File; Fields = query.Fields; StartIen = (job.StartIen == null || job.StartIen.Equals(String.Empty)) ? "0" : job.StartIen; XREF = (query.XREF == null || query.XREF.Equals(String.Empty)) ? "#" : query.XREF; From = (query.From == null || query.From.Equals(String.Empty)) ? StartIen : query.From; Part = (query.Part == null || query.Part.Equals(String.Empty)) ? String.Empty : query.Part; Screen = (query.Screen == null || query.Screen.Equals(String.Empty)) ? String.Empty : query.Screen; Identifier = (query.Identifier == null || query.Identifier.Equals(String.Empty)) ? String.Empty : query.Identifier; IdentifiedFiles = (query.IdentifiedFiles == null || query.IdentifiedFiles.Equals(String.Empty)) ? String.Empty : query.IdentifiedFiles; WP_Or_Computed_Fields = (query.WP_OR_COMPUTED_FIELDS == null || query.WP_OR_COMPUTED_FIELDS.Equals(String.Empty)) ? String.Empty : query.WP_OR_COMPUTED_FIELDS; Gets_Alignment = (query.Gets_Alignment == null || query.Gets_Alignment.Equals(String.Empty)) ? String.Empty : query.Gets_Alignment; if (!query.Packed) { _flags = "I"; } // this helper code is mostly for testing purposes - if no site code was specified on the job, try and set the site to the first in the sites list //if (String.IsNullOrEmpty(SiteCode) && !String.IsNullOrEmpty(job.Sites)) //{ // SiteCode = job.Sites.Split(new char[] { ';' })[0]; //} }
public ExtractorConfiguration Clone() { ExtractorConfiguration newConfig = new ExtractorConfiguration() { BatchId = this.BatchId, ExtractMode = this.ExtractMode, MaxRecordsPerQuery = this.MaxRecordsPerQuery, SiteCode = this.SiteCode, StartIen = this.StartIen, MaxConnectionPoolSize = this.MaxConnectionPoolSize, CRON = this.CRON, ON_COMPLETE = this.ON_COMPLETE, ON_START = this.ON_START }; newConfig.AllOrchestrators = new List <string>(); if (this.AllOrchestrators != null && this.AllOrchestrators.Count > 0) { foreach (string s in this.AllOrchestrators) { newConfig.AllOrchestrators.Add(s); } } newConfig.QueryConfigurations = new Tree <QueryConfiguration>(this.QueryConfigurations.RootNode); return(newConfig); }
public void Push(ExtractorConfiguration config) { lock (_locker) { _workStack.Push(config); } }
public void SortBySiteCode() { lock (_locker) { if (_workStack == null || _workStack.Count == 0) { return; } Dictionary <String, IList <ExtractorConfiguration> > dictForSorting = new Dictionary <string, IList <ExtractorConfiguration> >(); while (_workStack.Count > 0) { ExtractorConfiguration current = _workStack.Pop(); if (!dictForSorting.ContainsKey(current.SiteCode)) { dictForSorting.Add(current.SiteCode, new List <ExtractorConfiguration>()); } dictForSorting[current.SiteCode].Add(current); } // push jobs back on stack by sitecode foreach (String key in dictForSorting.Keys) { foreach (ExtractorConfiguration ec in dictForSorting[key]) { _workStack.Push(ec); } } } }
public void PushOrUpdate(ExtractorConfiguration config) { Remove(config); lock (_locker) { _workStack.Push(config); } }
public ExtractorConfiguration PopSiteUnique(ThreadSafeWorkStack activeJobs) { ExtractorConfiguration retVal = null; lock (_locker) { if (_workStack.Count > 0) { ExtractorConfiguration lcv = null; Stack <ExtractorConfiguration> bucket = new Stack <ExtractorConfiguration>(); while ((lcv = _workStack.Pop()) != null) { if (activeJobs.locklessFind(lcv.SiteCode)) { bucket.Push(lcv); if (_workStack.Count > 0) { continue; } else { break; } } else { retVal = lcv; break; } } if (bucket.Count > 0) { while ((lcv = bucket.Pop()) != null) { _workStack.Push(lcv); if (bucket.Count > 0) { continue; } else { break; } } } } } return(retVal); }
public IList <ExtractorConfiguration> CopyTo(IList <ExtractorConfiguration> destination) { if (destination == null) { destination = new List <ExtractorConfiguration>(); } lock (_locker) { foreach (ExtractorConfiguration config in _workStack) { ExtractorConfiguration newConfig = config.Clone(); destination.Add(newConfig); } } return(destination); }
public bool Contains(ExtractorConfiguration config) { if (config == null || String.IsNullOrEmpty(config.QueryConfigurations.RootNode.Value.File) || String.IsNullOrEmpty(config.SiteCode)) { return(false); } bool found = false; lock (_locker) { foreach (ExtractorConfiguration ec in _workStack) { if (ec.QueryConfigurations.RootNode.Value.File.Equals(config.QueryConfigurations.RootNode.Value.File) && ec.SiteCode.Equals(config.SiteCode)) { found = true; break; } } } return(found); }
public void Remove(ExtractorConfiguration config) { if (config == null || _workStack == null || _workStack.Count == 0) { return; } lock (_locker) { Stack <ExtractorConfiguration> temp = new Stack <ExtractorConfiguration>(); while (_workStack.Count != 0) { temp.Push(_workStack.Pop()); ExtractorConfiguration peeker = temp.Peek(); if (String.Equals(peeker.QueryConfigurations.RootNode.Value.File, config.QueryConfigurations.RootNode.Value.File) && String.Equals(peeker.SiteCode, config.SiteCode)) { temp.Pop(); // if this last one matched the config argument then pop it off to nowhere } } _workStack = temp; } }