public void onTransferFinish(MegaSDK api, MTransfer transfer, MError e) { if (_timer != null) { _timer.Dispose(); } if (e.getErrorCode() == MErrorType.API_EOVERQUOTA) { //Stop the Camera Upload Service LogService.Log(MLogLevel.LOG_LEVEL_INFO, "Disabling CAMERA UPLOADS service (API_EOVERQUOTA)"); OnQuotaExceeded(EventArgs.Empty); return; } try { if (e.getErrorCode() == MErrorType.API_OK) { ulong mtime = api.getNodeByHandle(transfer.getNodeHandle()).getModificationTime(); DateTime pictureDate = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(Convert.ToDouble(mtime)); SettingsService.SaveSettingToFile <DateTime>("LastUploadDate", pictureDate); // If file upload succeeded. Clear the error information for a clean sheet. ErrorProcessingService.Clear(); } else { // An error occured. Log and process it. switch (e.getErrorCode()) { case MErrorType.API_EFAILED: case MErrorType.API_EEXIST: case MErrorType.API_EARGS: case MErrorType.API_EREAD: case MErrorType.API_EWRITE: { LogService.Log(MLogLevel.LOG_LEVEL_ERROR, e.getErrorString()); ErrorProcessingService.ProcessFileError(transfer.getFileName()); break; } } } } catch (Exception) { // Setting could not be saved. Just continue the run } finally { // Start a new upload action ScheduledAgent.Upload(); } }
public void onNodesUpdate(MegaSDK api, MNodeList nodes) { // If the SDK has resumed the possible pending transfers if (nodes == null) { // If no pending transfers to resume start a new upload // Else it will start when finish the current transfer if (api.getTransfers(MTransferType.TYPE_UPLOAD).size() == 0) { ScheduledAgent.Upload(); } } }