Reputation: 1499
I have created a basic Custom Module (KC.CM.Divalto) that aims to:
I will output data into MessageBox for beginning.
At this stage, I read previous questions concerning Custom Modules and it helped me have a valid exe:
create custom module for pdf manipulation
internal class Program
{
static void Main(string[] args)
{
AppDomain.CurrentDomain.AssemblyResolve += (sender, eventArgs) => KcAssemblyResolver.Resolve(eventArgs);
Run(args);
return;
}
static void Run(string[] args)
{
var login = new Login();
login.EnableSecurityBoost = true;
login.Login();
login.ApplicationName = "KC.CM.Divalto";
login.Version = "1.0";
login.ValidateUser("KC.CM.Divalto.exe", false, "", "");
var session = login.RuntimeSession;
var activeBatch = session.NextBatchGet(login.ProcessID);
MessageBox.Show("activeBatch.Name: " + activeBatch.Name);
activeBatch.BatchClose(
KfxDbState.KfxDbBatchReady, KfxDbQueue.KfxDbQueueNext, 0, "");
var url = "http://localhost/webservice.asmx";
var data1 = "data1";
var data2 = "data2";
var data3 = "data3";
Dictionary<string, string> data = new Dictionary<string, string>();
data.Add("data1", data1);
data.Add("data2", data2);
data.Add("data3", data3);
WsCaller wsCaller= new WsCaller();
WsResponse returnValue =
wsCaller.SoapApiCaller(url, data1, data2, data3);
Console.WriteLine(returnValue);
MessageBox.Show("returnValue" + returnValue);
session.Dispose();
login.Logout();
}
}
Here my test call is working and returns the webservice response. I need to get extracted fields values in order to pass them to the webservice.
My questions are the following:
Thanks
Upvotes: 0
Views: 129
Reputation: 1499
I solved the first part of my issue:
static void Run(string[] args)
{
// MessageBox.Show("activeBatch.BatchFieldValue: " + activeBatch.BatchFieldValue);
var url = "http://myurl/soap.asmx";
try
{
var login = new Login();
login.EnableSecurityBoost = true;
login.Login();
login.ApplicationName = "KC.CM.Divalto";
login.Version = "1.0";
login.ValidateUser("KC.CM.Divalto.exe", false, "", "");
var session = login.RuntimeSession;
// get the batch
var activeBatch = session.NextBatchGet(login.ProcessID);
IACDataElement oRoot = activeBatch.ExtractRuntimeACDataElement(0);
IACDataElement oBatch = oRoot.FindChildElementByName("Batch");
// get the documents elt
IACDataElement oDocument = oBatch.FindChildElementByName("Documents");
IACDataElementCollection oDocColl = oDocument.FindChildElementsByName("Document");
Dictionary<string, string> data = new Dictionary<string, string>();
foreach (IACDataElement oDoc in oDocColl)
{
IACDataElement oIndex = oDoc.FindChildElementByName("IndexFields");
IACDataElementCollection oIndexColl = oIndex.FindChildElementsByName("IndexField");
sw.WriteLine("Document: {0}", oDoc["UniqueID"].ToString());
foreach (IACDataElement oField in oIndexColl)
{
data.Add(oField["Name"].ToString(), oField["Value"].ToString());
sw.WriteLine("Name: {0}, Value: {1}", oField["Name"].ToString(), oField["Value"].ToString());
}
sw.WriteLine("---------------------------------------");
WsCaller wsCaller= new WsCaller();
WsResponse returnValue =
wsCaller.SoapApiCaller(url, data);
var js = new JavaScriptSerializer();
MessageBox.Show("data send" + js.Serialize(data));
Console.WriteLine(returnValue);
MessageBox.Show("returnValue" + returnValue);
}
}
activeBatch.BatchClose(
KfxDbState.KfxDbBatchReady, KfxDbQueue.KfxDbQueueNext, 0, "");
session.Dispose();
login.Logout();
} catch(Exception ex)
{
throw new Exception(ex.Message);
}
}
The data are stored in oIndexColl: with a foreach, i build my query... My dictionnary has a known size...
Upvotes: 0