Exemplo n.º 1
0
        /// <summary>
        /// Create a new <see cref="Altask.www.Models.TaskInstance"/>.
        /// </summary>
        /// <param name="task"></param>
        /// <param name="asset"></param>
        /// <param name="user"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        private static TaskInstance Create(Data.Dto.Task task, Data.Dto.Asset asset, Data.Dto.User user, DateTime date)
        {
            var instance = new TaskInstance()
            {
                Description = task.Description,
                Date        = date,
                IdleTimeout = task.IdleTimeout,
                FormModel   = task.Form.PublishedModel,
                TaskId      = task.Id,
                Metadata    = task.Metadata,
                Name        = task.Name,
                Category    = task.Category,
                Type        = task.Type,
            };

            if (asset != null)
            {
                instance.AssetId = asset.Id;
                instance.Asset   = asset;
            }

            if (user != null)
            {
                instance.UserId = user.Id;
                instance.User   = user;
            }

            return(instance);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a new <see cref="Altask.www.Models.TaskInstance"/> from a <see cref="Altask.Data.Dto.Schedule"/>.
        /// </summary>
        /// <param name="task"></param>
        /// <param name="date"></param>
        /// <param name="schedule"></param>
        /// <returns></returns>
        public static TaskInstance FromSchedule(Data.Dto.Task task, DateTime date, Data.Dto.Schedule schedule)
        {
            var instance = TaskInstance.Create(task, null, null, date);

            instance.AnyTime = schedule.AnyTime.GetValueOrDefault(false);

            if (!instance.AnyTime && schedule.AsEarlyAsN.HasValue)
            {
                switch (schedule.AsEarlyAsFrequency)
                {
                case "Minute(s)":
                    instance.AsEarlyAsDate = date.AddMinutes(-(double)schedule.AsEarlyAsN);
                    break;

                case "Hour(s)":
                    instance.AsEarlyAsDate = date.AddHours(-(double)schedule.AsEarlyAsN);
                    break;

                case "Day(s)":
                    instance.AsEarlyAsDate = date.AddDays(-(double)schedule.AsEarlyAsN);
                    break;

                case "Week(s)":
                    instance.AsEarlyAsDate = date.AddDays(-(double)(schedule.AsEarlyAsN * 7));
                    break;

                case "Month(s)":
                    instance.AsEarlyAsDate = date.AddMonths(-schedule.AsEarlyAsN.Value);
                    break;
                }
            }

            instance.ScheduleId = schedule.Id;
            return(instance);
        }
Exemplo n.º 3
0
 internal async Task <EntityResult> AfterUpdateAsync(Altask.www.Models.TaskInstance instance, Altask.Data.Dto.Occurrence occurrence, bool notifyAll = false)
 {
     SignalRHub.NotifyOccurrenceUpdate(ClientId, instance, occurrence);
     return(await System.Threading.Tasks.Task.FromResult(EntityResult.Succeded(0)));
 }