Esempio n. 1
0
        public async Task <ActionResult <ApiTestItem> > PostTestItem(ApiTestItem TestItem)
        {
            _context.TestItems.Add(TestItem);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetTestItem), new { id = TestItem.ApiTestId }, TestItem));
        }
Esempio n. 2
0
        public async Task <IActionResult> PutTestItem(long id, ApiTestItem testItem)
        {
            if (id != testItem.ApiTestId)
            {
                return(BadRequest());
            }

            _context.Entry(testItem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TestItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 3
0
 /// <summary>
 /// 用户操作现场
 /// </summary>
 internal void CreateDefaultItem()
 {
     SelecTestItem = new ApiTestItem
     {
         Visibility = Visibility.Visible,
         Station    = Station.StationName,
         Api        = Document.RouteName,
         Arguments  = OutputJson(Document.ArgumentInfo),
         IsModify   = false
     };
 }
Esempio n. 4
0
        /// <summary>
        /// 用户操作现场
        /// </summary>
        internal void LoadApiScript()
        {
            if (Document == null)
            {
                SelecTestItem = new ApiTestItem
                {
                    Visibility = Visibility.Collapsed
                };
                return;
            }

            var folder = IOHelper.CheckPath(ZeroApplication.Config.DataFolder, "Scripts", Station.StationName);
            var file   = Path.Combine(folder, Document.RouteName.Replace('/', '_') + ".json");

            if (!File.Exists(file))
            {
                CreateDefaultItem();
                return;
            }

            try
            {
                var json = File.ReadAllText(file);
                if (string.IsNullOrWhiteSpace(json))
                {
                    CreateDefaultItem();
                    return;
                }

                SelecTestItem = JsonConvert.DeserializeObject <ApiTestItem>(json);
                if (SelecTestItem?.Api == null)
                {
                    CreateDefaultItem();
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
                CreateDefaultItem();
            }
        }