Пример #1
0
        internal static async Task <HttpStatusCode> PostScheduled(ScheduleInput transfer)
        {
            HttpResponseMessage response = await httpClient.PostAsJsonAsync(
                "api/schedule", transfer);

            return(response.StatusCode);
        }
        /// <summary>
        /// Allows updating the properties of a snapshot schedule template
        ///
        /// <para>
        /// Allows updating of snapshot schedule template properties. Snapshot
        /// schedule templates are used to consistently provision snapshot
        /// schedules across nPods. They are referenced in nPod templates and
        /// are provisioned when a nPod is formed from such a template.
        /// </para>
        /// </summary>
        /// <param name="guid">
        /// The unique identifier of the snapshot schedule template to update
        /// </param>
        /// <param name="name">
        /// Human readable name for the snapshot schedule template
        /// </param>
        /// <param name="namePattern">
        /// A naming pattern for volume snapshot names when they are
        /// automatically created. Available variables for the format string
        /// are from the standard <c>strftime</c> function. Additionally
        /// <c>%v</c> is used for the base volume name.
        /// </param>
        /// <param name="schedule">
        /// The schedule by which volume snapshots will be created
        /// </param>
        /// <param name="expirationSeconds">
        /// A time in seconds when snapshots will be automatically deleted. If
        /// not specified, snapshots will not be deleted automatically (not
        /// recommended)
        /// </param>
        /// <param name="retentionSeconds">
        /// A time in seconds that prevents users from deleting snapshots. If
        /// not specified, snapshots can be immediately deleted.
        /// </param>
        /// <param name="ignoreBootVolumes">
        /// Allows specifying if boot volumes shall be included when doing
        /// snapshots (<c>true</c>) or if they shall be ignored (<c>false</c>).
        /// By default, all volumes are included.
        /// </param>
        /// <returns></returns>
        public SnapshotScheduleTemplate UpdateSnapshotScheduleTemplate(
            Guid guid,
            string name            = null,
            string namePattern     = null,
            ScheduleInput schedule = null,
            long?expirationSeconds = null,
            long?retentionSeconds  = null,
            bool?ignoreBootVolumes = null)
        {
            UpdateSnapshotScheduleTemplateInput input = new UpdateSnapshotScheduleTemplateInput();

            input.Name              = name;
            input.NamePattern       = namePattern;
            input.Schedule          = schedule;
            input.ExpirationSeconds = expirationSeconds;
            input.RetentionSeconds  = retentionSeconds;
            input.IgnoreBootVolume  = ignoreBootVolumes;

            // perpare parameters
            GraphQLParameters parameters = new GraphQLParameters();

            parameters.Add("uuid", guid, false);
            parameters.Add("input", input, false);

            return(RunMutation <SnapshotScheduleTemplate>(
                       @"updateSnapshotScheduleTemplate",
                       parameters
                       ));
        }
Пример #3
0
        public async Task <Schedule> ModifySchedule([Service] DBAttendanceContext dBAttendanceContext, ScheduleInput input)
        {
            try
            {
                var schedule = await dBAttendanceContext.Schedule.FindAsync(input.Id);

                if (schedule != null)
                {
                    schedule.StartDate  = input.StartDate;
                    schedule.FinishDate = input.FinishDate;
                    schedule.State      = input.State;
                    input.ScheduleDetail.ForEach(sd =>
                    {
                        switch (sd.Action)
                        {
                        case 0:
                            var scheduleDetail = new ScheduleDetail
                            {
                                Day     = sd.Day,
                                InHour  = sd.InHour,
                                OutHour = sd.OutHour
                            };
                            schedule.ScheduleDetail.Add(scheduleDetail);
                            break;

                        case 1:
                            var scheduleDetail1     = schedule.ScheduleDetail.SingleOrDefault(sd1 => sd1.Id == sd.Id);
                            scheduleDetail1.Day     = sd.Day;
                            scheduleDetail1.InHour  = sd.InHour;
                            scheduleDetail1.OutHour = sd.OutHour;
                            break;

                        case 2:
                            var scheduleDetail2 = schedule.ScheduleDetail.SingleOrDefault(sd1 => sd1.Id == sd.Id);
                            schedule.ScheduleDetail.Remove(scheduleDetail2);
                            break;
                        }
                    });
                    await dBAttendanceContext.SaveChangesAsync();

                    return(schedule);
                }
                else
                {
                    throw new QueryException("No se encontró el horario.");
                }
            }
            catch (System.Exception e)
            {
                throw new QueryException(e.Message);
            }
        }
Пример #4
0
        public async Task <Schedule> AddSchedule([Service] DBAttendanceContext dBAttendanceContext, ScheduleInput input)
        {
            try
            {
                var schedule = new Schedule
                {
                    StartDate      = input.StartDate,
                    FinishDate     = input.FinishDate,
                    EmployeeCardId = input.EmployeeCardId
                };
                input.ScheduleDetail.ForEach(sd =>
                {
                    var scheduleDetail = new ScheduleDetail
                    {
                        Day     = sd.Day,
                        InHour  = sd.InHour,
                        OutHour = sd.OutHour
                    };
                    schedule.ScheduleDetail.Add(scheduleDetail);
                });
                dBAttendanceContext.Schedule.Add(schedule);
                await dBAttendanceContext.SaveChangesAsync();

                return(schedule);
            }
            catch (System.Exception e)
            {
                throw new QueryException(e.Message);
            }
        }