davidvera
davidvera

Reputation: 1499

Create a Custom Module Kofax for data validation through webservice

I have created a basic Custom Module (KC.CM.Divalto) that aims to:

enter image description here

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:

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

Answers (1)

davidvera
davidvera

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

Related Questions