Beispiel #1
0
        public virtual async Task <RegisterTaskResult> RegisterTaskAsync(string taskManagementUrl, RegisterTaskRequest requestData)
        {
            while (true)
            {
                try
                {
                    return(await RepositoryClient.RegisterTaskAsync(taskManagementUrl, requestData).ConfigureAwait(false));
                }
                catch (Exception ex)
                {
                    // look for a special error message about an unknown app id
                    if (ex is TaskManagementException && string.CompareOrdinal(ex.Message, RegisterTaskRequest.ERROR_UNKNOWN_APPID) == 0)
                    {
                        // try to re-register the app
                        if (SnTaskManager.RegisterApplication())
                        {
                            // skip error logging and try to register the task again
                            continue;
                        }
                    }

                    SnLog.WriteException(ex, "Error during task registration.",
                                         EventId.TaskManagement.General,
                                         properties: new Dictionary <string, object>
                    {
                        { "TaskManagementUrl", taskManagementUrl },
                        { "Type", requestData.Type },
                        { "Title", requestData.Title },
                        { "Data", requestData.TaskData }
                    });

                    // do not retry again after a real error
                    break;
                }
            }

            // no need to throw an exception, we already logged the error
            return(null);
        }
Beispiel #2
0
 public static bool RegisterApplication()
 {
     return(SnTaskManager.RegisterApplication());
 }
Beispiel #3
0
 public static void OnTaskFinished(SnTaskResult result)
 {
     SnTaskManager.OnTaskFinished(result);
 }
Beispiel #4
0
 public static RegisterTaskResult RegisterTask(RegisterTaskRequest requestData)
 {
     return(SnTaskManager.RegisterTask(requestData));
 }