public Task <ResultMessageWithDataModel> Export([FromBody] IdIntModel model, [FromServices] OpcUaImporter exporter)
        {
            var userToken   = UserExtension.DalUserToken(User);
            var profileItem = _dal.GetById(model.ID, userToken);

            if (profileItem == null /* || !(profileItem.AuthorId == null || profileItem.AuthorId == userToken)*/)
            {
                return(Task.FromResult(new ResultMessageWithDataModel()
                {
                    IsSuccess = false,
                    Message = $"Item {model?.ID} not found",
                }));
            }

            // Populate the OPC model into a new importer instance

            string xmlNodeSet = null;

            using (var xmlNodeSetStream = new MemoryStream())
            {
                if (exporter.ExportProfileItem(profileItem, xmlNodeSetStream, userToken, null))
                {
                    xmlNodeSet = Encoding.UTF8.GetString(xmlNodeSetStream.ToArray());

                    // TODO read and include the required models in a ZIP file, optionally?
                }
            }
            return(Task.FromResult(new ResultMessageWithDataModel()
            {
                IsSuccess = true,
                Message = "Type definition was exported.",
                Data = xmlNodeSet,
            }));
        }
Ejemplo n.º 2
0
 public ProfileController(IDal <Profile, ProfileModel> dal,
                          Utils.ImportService svcImport,
                          OpcUaImporter exporter,
                          ConfigUtil config, ILogger <ProfileController> logger)
     : base(config, logger)
 {
     _dal       = dal;
     _svcImport = svcImport;
     _exporter  = exporter;
 }
Ejemplo n.º 3
0
        public async Task <IActionResult> ImportSlow([FromBody] List <ImportOPCModel> model, [FromServices] OpcUaImporter importer)
        {
            _logger.LogInformation($"ImportLogController|Import/Slow.");

            var userToken = UserExtension.DalUserToken(User);

            var logId = await _svcImport.CallSlowMethod(model, userToken);

            return(Ok(
                       new ResultMessageWithDataModel()
            {
                IsSuccess = true,
                Message = "Import is processing...",
                Data = logId
            }
                       ));
        }