ReadMultiple (SOAP Webservice), New Record Late Detection
puz_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
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
0
Best Answers
-
yes, the problem's gone. Here what I did (not sure which solve the problems):
[*] Compile the page
[*] un-check and recheck the publish on web service page
[*] Restart the service instance
[*] Update the web reference on Visual Studio projects
When I test my solution, new record (insert / modified) immediately read on readmultiple command.5 -
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.1
Answers
-
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?0
-
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?0
-
yes, the problem's gone. Here what I did (not sure which solve the problems):
[*] Compile the page
[*] un-check and recheck the publish on web service page
[*] Restart the service instance
[*] Update the web reference on Visual Studio projects
When I test my solution, new record (insert / modified) immediately read on readmultiple command.5 -
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/0 -
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.1 -
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.
0 -
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.0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
