This commit is contained in:
@@ -414,36 +414,44 @@ namespace AyaNova.Biz
|
||||
//BUILD A LIST OF MatchingDictionaryEntry items FOR THE MATCHING WORDS
|
||||
List<MatchingDictionaryEntry> MatchingKeywordIdList = new List<MatchingDictionaryEntry>();
|
||||
|
||||
//ITERATE ALL THE KEYWORDS, SEARCH IN THE SEARCHDICTIONARY TABLE AND COLLECT ID'S OF ANY PRE-EXISTING IN DB KEYWORDS
|
||||
var ExistingKeywordMatches = ct.SearchDictionary.Where(m => KeyWordList.Contains(m.Word)).ToDictionary(m => m.Id, m => m.Word);
|
||||
//Put the matching keyword ID's into the list
|
||||
foreach (KeyValuePair<long, string> K in ExistingKeywordMatches)
|
||||
{
|
||||
bool IsName = false;
|
||||
if (NameKeyWordList.Contains(K.Value))
|
||||
IsName = true;
|
||||
MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = K.Key, InName = IsName });
|
||||
}
|
||||
|
||||
//ITERATE THROUGH THE KEYWORDS THAT DO *NOT* HAVE MATCHES IN THE SEARCHDICTIONARY AND ADD THEM TO THE SEARCH DICTIONARY, COLLECTING THEIR ID'S
|
||||
bool NewWordsAdded = false;
|
||||
var NewSearchDictionaryWordsList = new List<SearchDictionary>();
|
||||
foreach (string KeyWord in KeyWordList)
|
||||
//######### FROM HERE NEEDS TO LOCK SEARCHDICTIONARY FROM HERE TO ADDING NEW WORDS
|
||||
using (var transaction = ct.Database.BeginTransaction())
|
||||
{
|
||||
if (!ExistingKeywordMatches.ContainsValue(KeyWord))
|
||||
//ITERATE ALL THE KEYWORDS, SEARCH IN THE SEARCHDICTIONARY TABLE AND COLLECT ID'S OF ANY PRE-EXISTING IN DB KEYWORDS
|
||||
var ExistingKeywordMatches = ct.SearchDictionary.Where(m => KeyWordList.Contains(m.Word)).ToDictionary(m => m.Id, m => m.Word);
|
||||
//Put the matching keyword ID's into the list
|
||||
foreach (KeyValuePair<long, string> K in ExistingKeywordMatches)
|
||||
{
|
||||
NewSearchDictionaryWordsList.Add(new SearchDictionary() { Word = KeyWord });
|
||||
NewWordsAdded = true;
|
||||
bool IsName = false;
|
||||
if (NameKeyWordList.Contains(K.Value))
|
||||
IsName = true;
|
||||
MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = K.Key, InName = IsName });
|
||||
}
|
||||
}
|
||||
|
||||
//Save the context in order to get the id's of the new words added
|
||||
if (NewWordsAdded)
|
||||
{
|
||||
//adding in a range sped this up noticeably
|
||||
ct.SearchDictionary.AddRange(NewSearchDictionaryWordsList);
|
||||
ct.SaveChanges();
|
||||
}
|
||||
//ITERATE THROUGH THE KEYWORDS THAT DO *NOT* HAVE MATCHES IN THE SEARCHDICTIONARY AND ADD THEM TO THE SEARCH DICTIONARY, COLLECTING THEIR ID'S
|
||||
bool NewWordsAdded = false;
|
||||
var NewSearchDictionaryWordsList = new List<SearchDictionary>();
|
||||
foreach (string KeyWord in KeyWordList)
|
||||
{
|
||||
if (!ExistingKeywordMatches.ContainsValue(KeyWord))
|
||||
{
|
||||
NewSearchDictionaryWordsList.Add(new SearchDictionary() { Word = KeyWord });
|
||||
NewWordsAdded = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Save the context in order to get the id's of the new words added
|
||||
if (NewWordsAdded)
|
||||
{
|
||||
//adding in a range sped this up noticeably
|
||||
ct.SearchDictionary.AddRange(NewSearchDictionaryWordsList);
|
||||
ct.SaveChanges();
|
||||
}
|
||||
|
||||
transaction.Commit();
|
||||
}//end transaction
|
||||
//#########################
|
||||
|
||||
|
||||
//-----
|
||||
|
||||
@@ -236,7 +236,20 @@ namespace raven_integration
|
||||
var ErrorMessage = string.Empty;
|
||||
var ERR = a.ObjectResponse["error"];
|
||||
if (ERR != null)
|
||||
ErrorMessage = ERR.Value<string>();
|
||||
{
|
||||
var ecode = ERR["code"];
|
||||
if (ecode != null)
|
||||
ErrorMessage += $"CODE: {ecode} ";
|
||||
|
||||
var emsg = ERR["message"];
|
||||
if (emsg != null)
|
||||
ErrorMessage += $"MESSAGE: {emsg} ";
|
||||
|
||||
var etarget = ERR["target"];
|
||||
if (etarget != null)
|
||||
ErrorMessage += $"TARGET: {etarget} ";
|
||||
}
|
||||
|
||||
a.ObjectResponse["error"].Should().BeNull("because there should not be an error on an api call, error was: {0}", ErrorMessage);
|
||||
a.ObjectResponse["result"].Should().NotBeNull("A result should be returned");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user