This commit is contained in:
@@ -415,45 +415,52 @@ namespace AyaNova.Biz
|
|||||||
List<MatchingDictionaryEntry> MatchingKeywordIdList = new List<MatchingDictionaryEntry>();
|
List<MatchingDictionaryEntry> MatchingKeywordIdList = new List<MatchingDictionaryEntry>();
|
||||||
|
|
||||||
|
|
||||||
//######### FROM HERE NEEDS TO LOCK SEARCHDICTIONARY FROM HERE TO ADDING NEW WORDS
|
|
||||||
using (var transaction = ct.Database.BeginTransaction())
|
//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)
|
||||||
{
|
{
|
||||||
//ITERATE ALL THE KEYWORDS, SEARCH IN THE SEARCHDICTIONARY TABLE AND COLLECT ID'S OF ANY PRE-EXISTING IN DB KEYWORDS
|
bool IsName = false;
|
||||||
var ExistingKeywordMatches = ct.SearchDictionary.Where(m => KeyWordList.Contains(m.Word)).ToDictionary(m => m.Id, m => m.Word);
|
if (NameKeyWordList.Contains(K.Value))
|
||||||
//Put the matching keyword ID's into the list
|
IsName = true;
|
||||||
foreach (KeyValuePair<long, string> K in ExistingKeywordMatches)
|
MatchingKeywordIdList.Add(new MatchingDictionaryEntry() { DictionaryId = K.Key, InName = IsName });
|
||||||
{
|
}
|
||||||
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
|
//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;
|
bool NewWordsAdded = false;
|
||||||
var NewSearchDictionaryWordsList = new List<SearchDictionary>();
|
var NewSearchDictionaryWordsList = new List<SearchDictionary>();
|
||||||
foreach (string KeyWord in KeyWordList)
|
foreach (string KeyWord in KeyWordList)
|
||||||
|
{
|
||||||
|
if (!ExistingKeywordMatches.ContainsValue(KeyWord))
|
||||||
{
|
{
|
||||||
if (!ExistingKeywordMatches.ContainsValue(KeyWord))
|
NewSearchDictionaryWordsList.Add(new SearchDictionary() { Word = KeyWord });
|
||||||
{
|
NewWordsAdded = true;
|
||||||
NewSearchDictionaryWordsList.Add(new SearchDictionary() { Word = KeyWord });
|
|
||||||
NewWordsAdded = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Save the context in order to get the id's of the new words added
|
//Save the context in order to get the id's of the new words added
|
||||||
if (NewWordsAdded)
|
if (NewWordsAdded)
|
||||||
|
{
|
||||||
|
//adding in a range sped this up noticeably
|
||||||
|
ct.SearchDictionary.AddRange(NewSearchDictionaryWordsList);
|
||||||
|
try
|
||||||
{
|
{
|
||||||
//adding in a range sped this up noticeably
|
|
||||||
ct.SearchDictionary.AddRange(NewSearchDictionaryWordsList);
|
|
||||||
ct.SaveChanges();
|
ct.SaveChanges();
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//In integration testing hit duplicate values of widget names
|
||||||
|
//adjusted uniquify code in test util class to use milliseconds instead of seconds (duh) and didn't hit this again,
|
||||||
|
//however just in case I'm leaving it here as a potential debug break point if it arises again
|
||||||
|
//Outside of a test situation I can't imagine this will be an issue in actual production use
|
||||||
|
//as it seems unlikely that two separate manual users inputting data are going to generate the same word at the same exact moment
|
||||||
|
//in time
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
transaction.Commit();
|
|
||||||
}//end transaction
|
|
||||||
//#########################
|
|
||||||
|
|
||||||
|
|
||||||
//-----
|
//-----
|
||||||
//Now add the id's of the newly created words to the matching keyword id list for this object
|
//Now add the id's of the newly created words to the matching keyword id list for this object
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ namespace raven_integration
|
|||||||
uint OriginalConcurrencyToken = a.ObjectResponse["result"]["concurrencyToken"].Value<uint>();
|
uint OriginalConcurrencyToken = a.ObjectResponse["result"]["concurrencyToken"].Value<uint>();
|
||||||
|
|
||||||
//Now TechFullAuthToken attempt to modify it via patch
|
//Now TechFullAuthToken attempt to modify it via patch
|
||||||
var newName = Util.Uniquify("ServerShouldDisAllowOwnerOnlyRightsUserToPatchNonOwned - UPDATED TEST WIDGET");
|
var newName = Util.Uniquify("ServerShouldDisAllowOwnerOnlyRightsUserToPatchNonOwned - UPDATED TEST WIDGETB");
|
||||||
string patchJson = "[{\"value\": \"" + newName + "\",\"path\": \"/name\",\"op\": \"replace\"}]";
|
string patchJson = "[{\"value\": \"" + newName + "\",\"path\": \"/name\",\"op\": \"replace\"}]";
|
||||||
a = await Util.PatchAsync("Widget/" + Id.ToString() + "/" + OriginalConcurrencyToken.ToString(), await Util.GetTokenAsync( "TechFull"), patchJson);
|
a = await Util.PatchAsync("Widget/" + Id.ToString() + "/" + OriginalConcurrencyToken.ToString(), await Util.GetTokenAsync( "TechFull"), patchJson);
|
||||||
//2004 unauthorized expected
|
//2004 unauthorized expected
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace raven_integration
|
|||||||
public static string Uniquify(string s)
|
public static string Uniquify(string s)
|
||||||
{
|
{
|
||||||
|
|
||||||
return s + ((DateTimeOffset)DateTime.Now).ToUnixTimeSeconds();
|
return s + ((DateTimeOffset)DateTime.Now).ToUnixTimeMilliseconds().ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async static Task<string> GetTokenAsync(string login, string password = null)
|
public async static Task<string> GetTokenAsync(string login, string password = null)
|
||||||
|
|||||||
Reference in New Issue
Block a user