コード例 #1
0
        public void Delete([FromBody] JsonElement body)
        {
            string     json       = JsonSerializer.Serialize(body);
            DeleteBody deleteBody = JsonSerializer.Deserialize <DeleteBody>(json);

            Directory.Delete(deleteBody.Path);
        }
コード例 #2
0
        public void Delete([FromBody] JsonElement body)
        {
            string     json       = JsonSerializer.Serialize(body);
            DeleteBody deleteBody = JsonSerializer.Deserialize <DeleteBody>(json);

            System.IO.File.Delete(deleteBody.Path);
        }
コード例 #3
0
        public ActionResult DeleteEvent(int id, [FromBody] DeleteBody body, [FromQuery] bool finished = false)
        {
            var @event = _eventRepository.GetEvent(id);

            if (!ValidateType(@event))
            {
                return(Ok(new InvalidOperationException()));
            }

            var validatedEvent = (Event)@event;

            foreach (var comment in validatedEvent.Comments)
            {
                _commentRepository.ArchiveComment(comment, id);
            }
            foreach (var feedback in validatedEvent.Feedback)
            {
                _feedbackRepository.ArchiveFeedback(feedback, id);
            }
//            foreach (var actionlog in validatedEvent.ActionLogs) _actionLogRepository.ArchiveActionLog(actionlog, id);
            foreach (var info in validatedEvent.AdditionalInfo)
            {
                _additionalInfoRepository.ArchiveAdditionalInfo(info, id);
            }

            var result = _eventRepository.DeleteEvent(validatedEvent, body.Conclusion, finished);

            return(Ok(new { result }));
        }
コード例 #4
0
        public IHttpActionResult Delete2(string id, [FromBody] DeleteBody body)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (body == null)
            {
                throw new ArgumentNullException(nameof(body));
            }

            var perf            = PerfCounter.NewThenCheck(this.ToString() + "." + MethodBase.GetCurrentMethod().Name);
            var fulfillmentPath = GetFullIntrospectionDataPath(DateTime.Now, IntrospectionDataType.Fulfillments);
            var antiSpamResult  = PassAntiSpamDefender(fulfillmentPath, AuthMode.SimpleDeletion);

            if (!antiSpamResult.Valid)
            {
                return(DtoResultV5.Fail(BadRequest, antiSpamResult.Message));
            }
            perf.Check("anti spam end");

            SyncRoutine(fulfillmentPath);
            perf.Check("sync routine end");

            var fulfillments = ReadLskjson <Guid, RoutineFulfillment>(fulfillmentPath, CollectLskjsonLineIncludeDeleted);

            perf.Check("read fulfillment end");

            var inputUid = Guid.Parse(id);
            var fulfill  = fulfillments.FirstOrDefault(f => f.Uid == inputUid);

            if (fulfill == null)
            {
                return(DtoResultV5.Fail(BadRequest, "Routine not found, may already deleted, please refresh page"));
            }

            fulfill.IsDeleted    = true;
            fulfill.DeleteAt     = DateTime.Now;
            fulfill.DeletedBy    = "fixme-delete";
            fulfill.DeleteReason = body.Reason;

            WriteToFile(fulfillmentPath, fulfillments);
            perf.End("override fulfill end", true);
            return(DtoResultV5.Success(Json, DtoRoutine.From(fulfill, false)));
        }