Discussions regarding 1C:Enterprise for mobile devices with Android, iOS, or Windows Phone.

#1
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Sep 1, 2014
Company: Smart ID Dynamics

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");

Edited: Marius Gidu - Feb 08, 2016 09:25 AM
 
#2
People who like this: 0 Yes / 0 No
Timofey Bugaevsky
Guest

Joined:
Company:

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?

 
#3
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Sep 1, 2014
Company: Smart ID Dynamics

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.

Edited: Marius Gidu - Feb 09, 2016 02:39 AM
 
#4
People who like this: 0 Yes / 0 No
Timofey Bugaevsky
Guest

Joined:
Company:

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?

 
#5
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Sep 1, 2014
Company: Smart ID Dynamics

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, "");

 
#6
People who like this: 0 Yes / 0 No
Timofey Bugaevsky
Guest

Joined:
Company:

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?

 
#7
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Sep 1, 2014
Company: Smart ID Dynamics

I have tried the method you suggested but the same issue, job doesn`t start.

 
#8
People who like this: 0 Yes / 0 No
Timofey Bugaevsky
Guest

Joined:
Company:

Try to make a background job without parameters then. Maybe you are trying to pass some parameter that is not supported by background jobs.

 
#9
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Sep 1, 2014
Company: Smart ID Dynamics

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.

 
#10
People who like this: 0 Yes / 0 No
Timofey Bugaevsky
Guest

Joined:
Company:

Marius Gidu,

Could you please create a simple configuration, using which I could reproduce this issue and submit a bug to developers?

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.

/* Улучшаем читаемость списков в документации */ .workarea ul, .content ul { margin: 15px 0 20px 25px !important; padding: 0 !important; list-style-type: disc !important; } .workarea li, .content li { margin-bottom: 8px !important; padding-left: 5px !important; line-height: 1.6 !important; } /* Ультимативный фикс для всех уровней заголовков в контенте */ .workarea h1, .workarea h2, .workarea h3, .workarea h4, .workarea h5, .workarea h6, .content h1, .content h2, .content h3, .content h4, .content h5, .content h6, div[id*="content"] h5, div[class*="content"] h5 { display: block !important; font-weight: 700 !important; color: #005aa0 !important; /* Наш фирменный синий */ text-transform: none !important; margin-top: 30px !important; margin-bottom: 15px !important; line-height: 1.2 !important; font-family: Arial, sans-serif !important; } /* Принудительные размеры в пикселях (чтобы не зависеть от % или em) */ .workarea h1, .content h1 { font-size: 28px !important; } .workarea h2, .content h2 { font-size: 24px !important; } .workarea h3, .content h3 { font-size: 21px !important; } .workarea h4, .content h4 { font-size: 19px !important; } .workarea h5, .content h5 { font-size: 18px !important; } /* Для 5 решеток ##### */ .workarea h6, .content h6 { font-size: 16px !important; } /* Фикс, если Битрикс добавил лишние отступы перед списками после заголовка */ .workarea h5 + ul, .content h5 + ul { margin-top: 5px !important; }