Running a DataSource with Code
Using the following codes, the DataSource can be run with the code on the Flow side and read the returned result.
Required Libraries
using Bimser.Synergy.Entities.Workflow.EventArguments; using System; using Bimser.CSP.Runtime.Common.Extensions; using Bimser.Synergy.ServiceAPI; using Bimser.Synergy.ServiceAPI.Models.Authentication; using Bimser.Synergy.ServiceAPI.Models.Form; using Newtonsoft.Json; using Bimser.Synergy.Entities.Shared.Business.Objects; using System.Threading.Tasks; using System.Collections.Generic; using Bimser.CSP.FormControls.Common;
Code
The result returned from the query is written to this class. public class UserData { public string UserName{get;set;}
}
public void Position1_OnAfterExecution(object sender,OnAfterExecutionArguments args)
{
The parameters to be sent to the query are given in this section.
var parameters = new
{
ID= ".." parameter value
};
var result = ServiceApi.DataSourceManager.ExecuteQuery("PROJE_ADI", "<
UserData>DATASOURCE_ADI",parameters). Result;
if (result. Count>0)
{
foreach (var resultItem in result)
{
LogExtension.Log(resultItem.UserName,args. Context);
}
} else{ LogExtension.Log("noresult",args. Context); } }