Options

ReadMultiple (SOAP Webservice), New Record Late Detection

puz_mepuz_me Member Posts: 18
Hi all,

I am developing a form based solution, using c#, which will read and write data from SQLite database to Dynamics NAV 2015 database, vice versa.

In a part of my solution, I need to check whether there is any new record in a NAV database table every second. If yes, then I need to replicate that record as soon as possible in my SQLite database. So I read the NAV records from my application using NAV’s SOAP Web service and write the same information to my SQLite database.

Actually this is working as expected except for the interval between the new record being written to NAV database until it is read through the SOAP Web service. It is about 30 second (localhost connection) until the readmultiple can get the new inserted or modified records. In the real life environment, I need the records available in the SQLite database less than a couple of seconds (close to real-time if possible).

Here is the function I use to consume the SOAP webservice and update my SQLiteDatabase:

private void UpdateCallEntryFromDynamics()
{
QueueCallEntryService_Service CallEntryWS = new QueueCallEntryService_Service();
CallEntryWS.Credentials = new NetworkCredential("user", "xxxxxx");

List<QueueCallEntryService_Filter> CallEntryFilters = new List<QueueCallEntryService_Filter>();
QueueCallEntryService_Filter StatusFilter = new QueueCallEntryService_Filter();
StatusFilter.Field = QueueCallEntryService_Fields.Status;
StatusFilter.Criteria = "NEW";
CallEntryFilters.Add(StatusFilter);

QueueCallEntryService.QueueCallEntryService[] Entries = CallEntryWS.ReadMultiple(CallEntryFilters.ToArray(), null, 200);
QueueCallEntryService.QueueCallEntryService CallEntry = new QueueCallEntryService.QueueCallEntryService();

foreach (QueueCallEntryService.QueueCallEntryService Entry in Entries)
{
connectToDatabase();
string sql =
"INSERT INTO CallEntry"
+ "(Date,EntryNo,QueueEntryNo,QueueTypeID,QueueNo,CounterNo,Status,CallTime)"
+ "VALUES ("
+ "'" + Entry.Date.ToString("yyyy-MM-dd") + "'"
+ ",'" + Entry.EntryNo.ToString() + "'"
+ ",'" + Entry.QueueEntryNo.ToString() + "'"
+ ",'" + Entry.QueueTypeID.ToString() + "'"
+ ",'" + Entry.QueueNo.ToString() + "'"
+ ",'" + Entry.CounterNo.ToString() + "'"
+ ",'NEW'"
+ ",'" + Entry.Time.ToString("hh:mm:ss") + "'"
+ ")";
SQLiteCommand cmd = new SQLiteCommand(sql, Conn);
cmd.ExecuteNonQuery();

CallEntry = Entry;
CallEntry.Status = "ON QMS";
CallEntryWS.Update(ref CallEntry);
}
CallEntryWS.Dispose();
CallEntryFilters.Clear();
}

Is there any information regarding how we can reduce the time interval? Thanks in advance.

Regrads,

Philipus

Best Answers

  • Options
    SilverXSilverX Member Posts: 134
    Answer ✓
    Do you use multiple NST? Is it possible, that data is written on NST1 while you read it from NST2? Then it could be the cache synchronization period of 30 seconds. If so, try SELECTLATESTVERSION before actually reading data.
    Cheers
    Carsten


    ==> How To Ask Questions The Smart Way

    This post is my own opinion and does not necessarily reflect the opinion or view of my employer.

Answers

  • Options
    puz_mepuz_me Member Posts: 18
    amazingly, i change the credential type to Windows and the problem is gone. the new inserted / modified record can be read instantly. Any suggestion on how to resolve this?
  • Options
    puz_mepuz_me Member Posts: 18
    after so long the problem's gone, now I'm facing the same problem again. Is there any cause and how to work arround it?
  • Options
    archer89archer89 Member Posts: 337
    if the nav table does not contain flowfields you could load the data direct ftom database. for instant notification of new records work with sql triggers.
    best regards
    Franz Kalchmair, MVP
    Alias: Jonathan Archer

    please like / agree / verify my answer, if it was helpful for you. thx.
    Blog: http://moxie4nav.wordpress.com/
  • Options
    SilverXSilverX Member Posts: 134
    Answer ✓
    Do you use multiple NST? Is it possible, that data is written on NST1 while you read it from NST2? Then it could be the cache synchronization period of 30 seconds. If so, try SELECTLATESTVERSION before actually reading data.
    Cheers
    Carsten


    ==> How To Ask Questions The Smart Way

    This post is my own opinion and does not necessarily reflect the opinion or view of my employer.
  • Options
    puz_mepuz_me Member Posts: 18
    SilverX wrote: »
    Do you use multiple NST? Is it possible, that data is written on NST1 while you read it from NST2? Then it could be the cache synchronization period of 30 seconds. If so, try SELECTLATESTVERSION before actually reading data.

    yes, this might be the case. I often separate Client service and the SOAP web service. Is there anyway we could reduce the cache synchronization period?

    thx.
  • Options
    SilverXSilverX Member Posts: 134
    Yes. Have a look at this article: Data Access.
    Cheers
    Carsten


    ==> How To Ask Questions The Smart Way

    This post is my own opinion and does not necessarily reflect the opinion or view of my employer.
Sign In or Register to comment.