示例#1
0
        public bool Delete(ScheduleBase model, string id)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            try
            {
                ScheduleBase scheduleBase = model as ScheduleBase;
                string       day          = scheduleBase.day;
                string       query        = string.Empty;

                using (MySqlConnection conn = new MySqlConnection(App.sqlConn))
                {
                    conn.Open();
                    query = $"DELETE FROM schedule WHERE id = '{id}' AND DATE(DAY) = '{day}'";

                    MySqlCommand command = new MySqlCommand(query, conn);
                    command.ExecuteNonQuery();
                    conn.Close();
                }
            }
            catch (Exception)
            {
                log.Error("Delete에서 오류 발생");
                MessageBox.Show("오류가 발생했습니다. 로그를 확인하세요.", "오류", MessageBoxButton.OK, MessageBoxImage.Warning);

                return(false);
            }
            stopwatch.Stop();
            writer = File.AppendText("SqlTime.txt");
            writer.WriteLine($"ScheuleDals(Delete) time : " + stopwatch.ElapsedMilliseconds + "ms");
            writer.Close();

            return(true);
        }
示例#2
0
        /// <summary>
        /// Allows the user to change attributes of a schedule.
        /// </summary>
        /// <param name="scheduleId">Id of the Schedule to be updated</param>
        /// <param name="request">Update Request</param>
        /// <param name="cancellationToken"></param>
        /// <returns>A response to a successful PUT request contains confirmation of the arguments passed in. Note: If the new value is too large to return in the response due to internal memory constraints then a value of “Updated.” is returned.</returns>
        public async Task <List <GenericSuccessResponseItem> > UpdateScheduleAsync(string scheduleId, ScheduleBase request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var json           = JsonSerializer.Serialize(request, _jsonSerializerOptions);
            var requestContent = new StringContent(json, Encoding.UTF8, "application/json");
            var response       = await _httpClient.PutAsync($"/api/{_userName}/schedules/{scheduleId}", requestContent, cancellationToken);

            if (response.IsSuccessStatusCode)
            {
                var content = await response.Content.ReadAsStringAsync();

                return(JsonSerializer.Deserialize <List <GenericSuccessResponseItem> >(content, _jsonSerializerOptions));
            }

            return(null);
        }
 public abstract void DeleteSchedule(ScheduleBase schedule);
 public override void DeleteSchedule(ScheduleBase schedule)
 {
     throw new NotImplementedException();
 }
示例#5
0
 internal ComputeStartStopSchedule(string id, ProvisioningStatus?provisioningStatus, ComputePowerAction?action, ScheduleBase schedule)
 {
     Id = id;
     ProvisioningStatus = provisioningStatus;
     Action             = action;
     Schedule           = schedule;
 }