private void DB_AddOrRemoveElementsFromArrayItem_FireAndForget_Internal( string _QueryType, string _Table, string _KeyName, BPrimitiveType _KeyValue, string _ElementName, BPrimitiveType[] _ElementValueEntries, int _Current_RetryCount = 0, Action <string> _ErrorMessageAction = null) { if (DatabaseService == null) { return; } bool bResult; if (_QueryType == Action_DeliveryEnsurer.QUERY_TYPE_DB_ADD_ELEMENTS_TO_ARRAY_ITEM) { bResult = DatabaseService.AddElementsToArrayItem(_Table, _KeyName, _KeyValue, _ElementName, _ElementValueEntries, out JObject _, EBReturnItemBehaviour.DoNotReturn, null, _ErrorMessageAction); } else { bResult = DatabaseService.RemoveElementsFromArrayItem(_Table, _KeyName, _KeyValue, _ElementName, _ElementValueEntries, out JObject _, EBReturnItemBehaviour.DoNotReturn, _ErrorMessageAction); } if (!bResult) { BroadcastFailed_FireAndForget_Operation(new Action_DeliveryEnsurer_DB_Add_Remove_ElementsToArrayItem() { QueryType = _QueryType, TableName = _Table, KeyName = _KeyName, KeyValue = new BPrimitiveType_JStringified(_KeyValue), ElementName = _ElementName, ElementValueEntries = BPrimitiveType_JStringified.ConvertPrimitivesToPrimitiveTypeStructs(_ElementValueEntries).ToList(), RetryCount = _Current_RetryCount }, _ErrorMessageAction); } }
private bool TestAddToList(int _TestStepNo) { PrintAction?.Invoke("Step " + _TestStepNo + "->" + "TestAddToList->Log-> Testing AddElementsToArrayItem-1..."); bool bLocalFailure = !SelectedDBService.AddElementsToArrayItem( TableName, Key, new BPrimitiveType("test_1"), "test_list", new BPrimitiveType[] { new BPrimitiveType("test_value_1"), new BPrimitiveType("test_value_2"), new BPrimitiveType("test_value_3"), new BPrimitiveType("test_value_4") }, out JObject ReturnValue, EBReturnItemBehaviour.ReturnAllOld, null, (string Message) => { Console.WriteLine("Step " + _TestStepNo + "->" + "TestAddToList->Error-> " + Message); bLocalFailure = true; }); if (bLocalFailure) { PrintAction?.Invoke("Step " + _TestStepNo + "->" + "TestAddToList->Error-> AddElementsToArrayItem-1 failed."); return(false); } PrintAction?.Invoke("Step " + _TestStepNo + "->" + "TestAddToList->Log-> AddElementsToArrayItem-1 succeed. Returned: " + ReturnValue?.ToString()); PrintAction?.Invoke("Step " + _TestStepNo + "->" + "TestAddToList->Log-> Testing AddElementsToArrayItem-2. Expecting failure..."); bLocalFailure = !SelectedDBService.AddElementsToArrayItem( TableName, Key, new BPrimitiveType("test_1"), "test_list", new BPrimitiveType[] { new BPrimitiveType("test_value_2"), new BPrimitiveType("test_value_5") }, out ReturnValue, EBReturnItemBehaviour.ReturnAllOld, SelectedDBService.BuildArrayElementNotExistCondition(new BPrimitiveType("test_value_1")), (string Message) => { Console.WriteLine("Step " + _TestStepNo + "->" + "TestAddToList->Error-> " + Message); bLocalFailure = true; }); if (!bLocalFailure) { PrintAction?.Invoke("Step " + _TestStepNo + "->" + "TestAddToList->Error-> AddElementsToArrayItem-2 did not fail."); return(false); } PrintAction?.Invoke("Step " + _TestStepNo + "->" + "TestAddToList->Log-> AddElementsToArrayItem-2 successfully failed. Returned: " + ReturnValue?.ToString()); bLocalFailure = !SelectedDBService.GetItem( TableName, Key, new BPrimitiveType("test_1"), new string[] { "test_list" }, out ReturnValue, (string Message) => { Console.WriteLine("Step " + _TestStepNo + "->" + "TestAddToList->Error-> " + Message); bLocalFailure = true; }); if (bLocalFailure) { PrintAction?.Invoke("Step " + _TestStepNo + "->" + "TestAddToList->Error-> GetItem-1 has failed."); return(false); } PrintAction?.Invoke("Step " + _TestStepNo + "->" + "TestAddToList->Log-> GetItem-1 successfully completed. Returned: " + ReturnValue?.ToString()); return(true); }