internal static TaskStoreObject FromDarTask(DarTask task, StoreObjectProvider objectProvider)
        {
            if (task == null)
            {
                throw new ArgumentNullException("task");
            }
            if (objectProvider == null)
            {
                throw new ArgumentNullException("objectProvider");
            }
            TaskStoreObject taskStoreObject = task.WorkloadContext as TaskStoreObject;

            if (taskStoreObject == null)
            {
                taskStoreObject = objectProvider.FindByAlternativeId <TaskStoreObject>(task.Id);
                if (taskStoreObject == null)
                {
                    taskStoreObject = new TaskStoreObject();
                }
            }
            if (taskStoreObject != null)
            {
                taskStoreObject.UpdateFromDarTask(task);
            }
            return(taskStoreObject);
        }
        internal static TaskAggregateStoreObject FromExistingObject(TaskAggregateStoreObject storeObject, StoreObjectProvider objectProvider)
        {
            TaskAggregateStoreObject taskAggregateStoreObject = objectProvider.FindByAlternativeId <TaskAggregateStoreObject>(storeObject.Id);

            taskAggregateStoreObject.Id                  = storeObject.Id;
            taskAggregateStoreObject.Enabled             = storeObject.Enabled;
            taskAggregateStoreObject.TaskType            = storeObject.TaskType;
            taskAggregateStoreObject.ScopeId             = storeObject.ScopeId;
            taskAggregateStoreObject.MaxRunningTasks     = storeObject.MaxRunningTasks;
            taskAggregateStoreObject.RecurrenceType      = storeObject.RecurrenceType;
            taskAggregateStoreObject.RecurrenceFrequency = storeObject.RecurrenceFrequency;
            taskAggregateStoreObject.RecurrenceInterval  = storeObject.RecurrenceInterval;
            return(taskAggregateStoreObject);
        }
        internal static TaskStoreObject FromExistingObject(TaskStoreObject storeObject, StoreObjectProvider objectProvider)
        {
            TaskStoreObject taskStoreObject = objectProvider.FindByAlternativeId <TaskStoreObject>(storeObject.Id);

            taskStoreObject.Id       = storeObject.Id;
            taskStoreObject.Category = storeObject.Category;
            taskStoreObject.Priority = storeObject.Priority;
            taskStoreObject.TaskSynchronizationKey    = Helper.ToDefaultString(storeObject.TaskSynchronizationKey, null);
            taskStoreObject.TaskSynchronizationOption = storeObject.TaskSynchronizationOption;
            taskStoreObject.TaskType               = Helper.ToDefaultString(storeObject.TaskType, null);
            taskStoreObject.TenantId               = storeObject.TenantId;
            taskStoreObject.TaskState              = storeObject.TaskState;
            taskStoreObject.TaskQueuedTime         = storeObject.TaskQueuedTime;
            taskStoreObject.MinTaskScheduleTime    = storeObject.MinTaskScheduleTime;
            taskStoreObject.TaskScheduledTime      = storeObject.TaskScheduledTime;
            taskStoreObject.TaskExecutionStartTime = storeObject.TaskExecutionStartTime;
            taskStoreObject.TaskCompletionTime     = storeObject.TaskCompletionTime;
            taskStoreObject.TaskRetryTotalCount    = storeObject.TaskRetryTotalCount;
            taskStoreObject.TaskRetryInterval      = storeObject.TaskRetryInterval;
            taskStoreObject.TaskRetryCurrentCount  = storeObject.TaskRetryCurrentCount;
            taskStoreObject.SerializedTaskData     = Helper.ToDefaultString(storeObject.SerializedTaskData, null);
            return(taskStoreObject);
        }