int delay = MUTATE_JOB_DELAY;
BatchJobUtilities batchJobUploadHelper = new BatchJobUtilities(_user);
BatchJob batchJob = null;
try
{
BatchJobOperation operation = new BatchJobOperation { @operator = Operator.ADD, operand = new BatchJob() };
var res = _batchJobService.mutate(new BatchJobOperation[] { operation });
if (res != null && res.value.Count() > 0)
{
batchJob = res.value.FirstOrDefault();
}
else
{
logger.Error("Unable to create job in account {CustomerId}", _customerId);
return -1;
}
}
catch
{
return -1;
}
if (batchJob != null)
{
string uploadUrl = batchJob.uploadUrl.url;
string resumableUploadUrl = batchJobUploadHelper.GetResumableUploadUrl(uploadUrl);
for (int i = 0; i < NB_MUTATE_JOB_RETRIES; i++)
{
try
{
batchJobUploadHelper.Upload(resumableUploadUrl, operations);
return batchJob.id;
}
catch(Exception e)
{
Thread.Sleep(delay);
delay = (int)(delay * 1.33);
}
}
logger.Error("Unable to upload operations in account {CustomerId} after "+NB_MUTATE_JOB_RETRIES+" retries", _customerId);
return -1;
}
else
{
logger.Error("Unable to create job in account {CustomerId}", _customerId);
return -1;
}