This commit is contained in:
2018-09-21 18:24:04 +00:00
parent d204d9f20c
commit 282097d42d
2 changed files with 26 additions and 7 deletions

View File

@@ -388,26 +388,43 @@ namespace AyaNova.Biz
}
//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;
foreach (string KeyWord in KeyWordList)
{
if (!ExistingKeywordMatches.ContainsValue(KeyWord))
{
ct.SearchDictionary.Add(new SearchDictionary() { Word = KeyWord });
NewWordsAdded = true;
}
}
//Save the context in order to get the id's of the new words added
ct.SaveChanges();
if (NewWordsAdded)
ct.SaveChanges();
//-----
//Now add the id's of the newly created words to the matching keyword id list for this object
foreach (SearchDictionary SD in ct.SearchDictionary.Local)
{
bool IsName = false;
if (NameKeyWordList.Contains(SD.Word))
IsName = true;
MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = SD.Id, InName = IsName });
}
//See if it's already in the matching keywordlist or needs to be added
var ExistingMatch = MatchingKeywordIdList.Where(x => x.DictionaryId == SD.Id).FirstOrDefault();
if (ExistingMatch == null)//If null then needs to be added
MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = SD.Id, InName = IsName });
else
{
//Not null, but may need to be updated to reflect that it's in the name
if (!ExistingMatch.InName && IsName)
{
ExistingMatch.InName = true;
}
}
}
//CREATE THE SEARCHKEY RECORDS FOR ALL THE KEYWORDS
foreach (MatchingDictionaryEntry E in MatchingKeywordIdList)
@@ -415,6 +432,8 @@ namespace AyaNova.Biz
ct.SearchKey.Add(new SearchKey() { WordId = E.DictionaryId, InName = E.InName, ObjectId = objectID, ObjectType = objectType });
}
//---------------------------------
ct.SaveChanges();
}//eoc

View File

@@ -31,7 +31,7 @@ namespace raven_integration
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString());
Util.ValidateDataReturnResponseOk(a);
long FirstWidgetId = a.ObjectResponse["result"]["id"].Value<long>();
long MatchFirstWidgetId = a.ObjectResponse["result"]["id"].Value<long>();
//CREATE A SECOND WIDGET
D = new JObject();
@@ -43,7 +43,7 @@ namespace raven_integration
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString());
Util.ValidateDataReturnResponseOk(a);
long SecondWidgetId = a.ObjectResponse["result"]["id"].Value<long>();
long MatchSecondWidgetId = a.ObjectResponse["result"]["id"].Value<long>();
//CREATE A THIRD WIDGET
D = new JObject();
@@ -55,7 +55,7 @@ namespace raven_integration
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString());
Util.ValidateDataReturnResponseOk(a);
long ThirdWidgetId = a.ObjectResponse["result"]["id"].Value<long>();
long NoMatchThirdWidgetId = a.ObjectResponse["result"]["id"].Value<long>();
//Now see if can find that widget with a phrase search
dynamic SearchParameters = new JObject();