Posted on 22/08/2016 16:44:17
You're quite right, Maarten - I stand corrected! :-)
In that case you need to write your own "stuff". In this case stuff will be a TableScript. A table script will feed you with an input row at a time. You can then manipulate the row before sending it forward again. In the example below we simply decide wether we should use the password from input, or use the one already stored in database:
using Dynamicweb;
using System.Linq;
using System.Collections.Generic;
namespace Dynamicweb.eCommerce.LiveIntegration.NotificationSubscribers
{
public class DiscountTableScript : Dynamicweb.Data.Integration.TableScript
{
public override string ScriptingName
{
get
{
return "Processing script for Users";
}
}
public override void ProcessInputRow(Dynamicweb.Data.Integration.Mapping mapping, Dictionary<string, object> row)
{
if (mapping.SourceTable != null)
{
string _password = GetUserPassword(row["AccessUserUserName"].ToString());
if (_password != string.Empty)
row["AccessUserPassword"] = _password;
}
}
private string GetUserPassword(string userName)
{
// If user has updated password, then return users' updated password as it is stored on the user in the database.
// Otherwise return empty string.
string password = string.Empty;
using (System.Data.IDataReader reader = Dynamicweb.Database.CreateDataReader(string.Format("SELECT AccessUserPassword,AccessUser_UserHasUpdated FROM AccessUser WHERE AccessUserUsername='{0}'", userName)))
{
while (reader.Read())
{
if (Base.ChkBoolean(reader["AccessUser_UserHasUpdated"]) == true)
{
password = reader["AccessUserPassword"].ToString();
}
}
}
return password;
}
}
}
It's a shot from the hip, so disclaimers are available. :-)
Compiling and putting the DLL on the solution, will expose it as an available script on Data Integration Jobs: http://screencast.com/t/rk1NhuPq
Best regards
Snedker