Marius Gidu
Feb 08, 2016 09:25 AM
Active user
Points:: 0
Joined:: Sep 1, 2014
I have a problem with BackgroundJobs on mobile platform. I can`t start more than one BackgroundJob at a time, and other problem is that BackgroundJob start only when I install the mobile application, and after that I exit from application and enter again the BackgroundJob doesn`t start again... Please help. Is very important for me to use BackggorundJobs in my mobile application.
Code
BackgroundJobs.Execute("DataExchangeManagerServer.GetUpdatesFromServerInBackground",, String(New UUID), "Update database job");
Profile
Timofey Bugaevsky
Feb 09, 2016 02:30 AM
Guest
Points::
Joined::
Hello, Marius Gidu! Yes, only one background job can be executed at a time in a mobile platform. Which error do you receive when try to start a background job after closing and opening the application?
Profile
Marius Gidu
Feb 09, 2016 02:36 AM
Active user
Points:: 0
Joined:: Sep 1, 2014
I have a try except block on method:
Code
BackgroundJobs.Execute("DataExchangeManagerServer.GetUpdatesFromServerInBackground",, String(New UUID), "Update database job");
but i get no error, instead the code behind this common module method (DataExchangeManagerServer.GetUpdatesFromServerInBackground) doesn`t execute at all and the job remain active always and I can`t start a new job. Even when I exit from the application and enter again, same issue, code behind the job does not execute and the job remain active.
Profile
Timofey Bugaevsky
Feb 09, 2016 07:18 AM
Guest
Points::
Joined::
Which version of 1C:Enterprise mobile platform do you use? Which mobile device and which OS version do you use? Does the DataExchangeManagerServer.GetUpdatesFromServerInBackground function finish execution? Can you make a simple test configuration where I could reproduce this issue?
Profile
Marius Gidu
Feb 09, 2016 08:13 AM
Active user
Points:: 0
Joined:: Sep 1, 2014
Mobile platform version 8.3.7.59 - I use Mobile Application Builder to generate application .apk . Mobile device: Honeywell Dolphin 75e Black with Android 4.4.4, LG G3 D855 with Android 5.0 This is code where I start the Job:
Code LoggingManagement.WriteEvent("UPDATE START", CurrentDate(), Enums.EventTypes.Information, Enums.EventOperations.UpdateData, "");
ExchangeFilter = Constants.ExchangeFilter.Get();
BackgroundJobParameters = New Array();
BackgroundJobParameters.Add(ExchangeFilter);
Try
Job = BackgroundJobs.Execute("DataExchangeManagerServer.GetUpdatesFromServerInBackground", BackgroundJobParameters, String(New UUID), "FileSynchronization");
Return Job.UUID;
Except
LoggingManagement.WriteEvent("Job error " + " - " + ErrorDescription(), CurrentDate(), Enums.EventTypes.Error, Enums.EventOperations.UpdateData, "");
Return Undefined;
EndTry;
This is code behind the function
DataExchangeManagerServer.GetUpdatesFromServerInBackground :
Code LoggingManagement.WriteEvent("UPDATE JOB START", CurrentDate(), Enums.EventTypes.Information, Enums.EventOperations.UpdateData, "");
Try
Address = Constants.ServerAdress.Get();
User = Constants.InfobaseUser.Get();
Password = Constants.InfobasePassword.Get();
HttpServerAddress = Constants.HttpServerAddress.Get();
HttpServerPort = Constants.ServerPort.Get();
Definitions = New WSDefinitions(Address, User, Password);
URI = "http://smartid.ro";
Proxy = New WSProxy(Definitions, URI, "WebExchange", "WebExchangeSoap");
Proxy.User = User;
Proxy.Password = Password;
SysInfo = New SystemInfo;
MobileDeviceCode = String(SysInfo.ClientID);
//2. Exchange with the main base
ExchangeFiles = Proxy.GetExchangeFilesAddresses(MobileDeviceCode, Filter);
j = StrLineCount(ExchangeFiles);
ArrayOfExchangeFiles = New Array;
HTTPConnection = New HTTPConnection(HttpServerAddress, HttpServerPort,,,,14400);
For i = 1 To j Do
Try
//Get file name and file directory
CurrFileName = StrGetLine(ExchangeFiles, i);
CurrDirFileName = TempFilesDir() + CurrFileName;
HttpRequest = New HTTPRequest("/ExchangeFiles/" + CurrFileName);
HTTPConnection.Get(HttpRequest, CurrDirFileName);
ArrayOfExchangeFiles.Add(New Structure("FileName, FileAddress", CurrFileName, CurrDirFileName));
Except
LoggingManagement.WriteEvent("Get file from server error " + " - " + CurrFileName + " - " + ErrorDescription(), CurrentDate(), Enums.EventTypes.Error, Enums.EventOperations.ImportData, "");
EndTry;
EndDo;
If ArrayOfExchangeFiles.Count() > 0 Then
ImportDownloadedFiles(ArrayOfExchangeFiles);
EndIf;
Except
LoggingManagement.WriteEvent("Error error " + " - " + ErrorDescription(), CurrentDate(), Enums.EventTypes.Error, Enums.EventOperations.ImportData, "");
EndTry;
LoggingManagement.WriteEvent("Import end", CurrentDate(), Enums.EventTypes.Information, Enums.EventOperations.ImportData, "");
Function does not finish his code execution at all. But some times it execute after an hour, sometimes after 20 minutes from the BackJob Start Date.
I don`t have other active BackJob because I search is an active jobe exist before starting a new one.
As an example:
This line of code was executed at 13:12:35 :
Code LoggingManagement.WriteEvent("UPDATE START", CurrentDate(), Enums.EventTypes.Information, Enums.EventOperations.UpdateData, "");
And this line was executed at 14:06:16 :
Code LoggingManagement.WriteEvent("UPDATE JOB START", CurrentDate(), Enums.EventTypes.Information, Enums.EventOperations.UpdateData, "");
Profile
Timofey Bugaevsky
Feb 09, 2016 11:42 PM
Guest
Points::
Joined::
Hello, Marius Gidu! Try to remove all script inside the DataExchangeManagerServer.GetUpdatesFromServerInBackground(), except for:
Code LoggingManagement.WriteEvent("UPDATE JOB START",...
LoggingManagement.WriteEvent("Import end"...
How it works now? Does it start faster and gets till the end?
Profile
Marius Gidu
Feb 10, 2016 12:57 AM
Active user
Points:: 0
Joined:: Sep 1, 2014
I have tried the method you suggested but the same issue, job doesn`t start.
Profile
Timofey Bugaevsky
Feb 10, 2016 03:10 AM
Guest
Points::
Joined::
Try to make a background job without parameters then. Maybe you are trying to pass some parameter that is not supported by background jobs.
Profile
Marius Gidu
Feb 10, 2016 03:27 AM
Active user
Points:: 0
Joined:: Sep 1, 2014
I tried this method too but doesn`t working. Sometimes BackgroundJob started after 12 minutes, other time started after 2 hours and i commented the code you suggested. And job stay active for long time even is just a line of code with a log. The Job is created because I can find by his UUID but the code inside the Job Function doesn`t executes at all. As I say, sometimes the code behind the Job function executes after a long period of time from the starting time of the Job. This is a platform bug. Please fix this.
Profile
Timofey Bugaevsky
Feb 10, 2016 04:28 AM
Guest
Points::
Joined::
Marius Gidu, Could you please create a simple configuration, using which I could reproduce this issue and submit a bug to developers?
Profile
Subscribe