/// <summary> /// Tries the get last added record. /// </summary> /// <param name="fieldValues">The field values.</param> /// <param name="filterValues">The filter values.</param> private void TryGetLastAddedRecord(IDictionary <string, string> fieldValues, SPSKeyValueList filterValues) { try { // Try to get identity SqlCommand command = new SqlCommand("SELECT @@IDENTITY", _connection); _adapter = new SqlDataAdapter(command); string key = command.ExecuteScalar().ToString(); // If there is a key if (!string.IsNullOrEmpty(key)) { // Replace the key in the current filter filterValues.ReplaceValue(_config.DataBase.Table.IdentityColumnCollection[0].Name, key); } else { // Set the new filter vales SetNewFilterValues(fieldValues, filterValues); } // Select the added record using the new filter if (filterValues != null) { SelectRecord(filterValues, false); } } catch (SqlException ex) { DumpException("TryGetLastAddedRecord", ex); } }
/// <summary> /// Replaces the values. /// </summary> private void ReplaceValues() { // Replace with Consumer foreach (SPSKeyValuePair keyValue in _variableValues) { Debug.WriteLine("3-CAML Provider - " + keyValue.Key + " " + keyValue.Value); _parameterFormulas.ReplaceValue(keyValue.Key, keyValue.Value); } }
public void ReplaceValue() { SPSKeyValueList keyValues = new SPSKeyValueList(); keyValues.Add(new SPSKeyValuePair("Key", "Value")); keyValues.Add(new SPSKeyValuePair("Key", "Value")); Assert.IsTrue(keyValues.Count == 2); keyValues.ReplaceValue("Key", "Value1"); Assert.IsTrue(keyValues[0].Key == "Key"); Assert.IsTrue(keyValues[0].Value == "Value1"); Assert.IsTrue(keyValues[1].Key == "Key"); Assert.IsTrue(keyValues[1].Value == "Value"); }
/// <summary> /// Evaluates the parameters. /// 1.- Process _variableFunctions list evaluating each function /// 2.- Process _variableFunctions list replacing the evaluated /// formula with a value thats come from _variableValues list /// </summary> private void EvaluateParameters() { SPSEvaluator evaluator = new SPSEvaluator(); // Evaluate all foreach (SPSKeyValuePair keyValue in _variableFunctions) { Debug.WriteLine("1-CAML Original - " + keyValue.Key + " " + keyValue.Value); keyValue.Value = evaluator.Evaluate(keyValue.Value); Debug.WriteLine("2-CAML Evaluated - " + keyValue.Key + " " + keyValue.Value); } // Replace with Consumer foreach (SPSKeyValuePair keyValue in _variableValues) { Debug.WriteLine("3-CAML Provider - " + keyValue.Key + " " + keyValue.Value); _variableFunctions.ReplaceValue(keyValue.Key, keyValue.Value); } }