1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc;
- using ProductionLineMonitor.Application.Services.CimService.Dtos;
- using ProductionLineMonitor.Core.Dtos;
- using System.Net.Http;
- using System.Text;
- using System.Text.Json;
- namespace ProductionLineMonitor.Web.Controllers
- {
- public class DevOpsController : BaseController
- {
- public IActionResult Index()
- {
- return View();
- }
- public IActionResult GetCimPasswords()
- {
- try
- {
- HttpClient httpClient = new HttpClient();
- using HttpResponseMessage response = httpClient
- .GetAsync(Config.SafeguardUrl + "/api/Cims").Result;
- var jsonResponse = response.Content.ReadAsStringAsync().Result;
- return Ok(jsonResponse);
- }
- catch (System.Exception ex)
- {
- return Ok(ResultDto.Fail(ex.Message));
- }
- }
- public IActionResult SetCimPassword([FromBody] CimPasswordDto dto)
- {
- try
- {
- HttpClient httpClient = new HttpClient();
- using StringContent jsonContent = new StringContent(
- JsonSerializer.Serialize(new
- {
- No = dto.No,
- Password = dto.Password,
- Enabled = dto.Enabled,
- }),
- Encoding.UTF8, "application/json");
- using HttpResponseMessage response = httpClient
- .PostAsync(Config.SafeguardUrl + "/api/Cim/SetPassword", jsonContent).Result;
- var jsonResponse = response.Content.ReadAsStringAsync().Result;
- return Ok(jsonResponse);
- }
- catch (System.Exception ex)
- {
- return Ok(ResultDto.Fail(ex.Message));
- }
- }
- [HttpPost]
- public IActionResult UploadAlarmFile(IFormFile file)
- {
- try
- {
- if (file == null || file.Length == 0)
- {
- return Ok(ResultDto.Fail("No file uploaded"));
- }
- return Ok("file uploaded successfully");
- }
- catch (System.Exception ex)
- {
- return Ok(ex.Message);
- }
- }
- }
- }
|