Exemplo n.º 1
0
        async public Task Insert(Product entity)
        {
            string record = toJson(entity);

            ServiceLayerResponse response = await _serviceLayerConnector.Post("U_VSIS_PRODUCT", record);

            if (!response.success)
            {
                string message = $"Erro ao inserir dados em '{entity.EntityName}': {response.errorCode}-{response.errorMessage}";

                Console.WriteLine(message);
                throw new ApplicationException(message);
            }
        }
Exemplo n.º 2
0
        async public Task Insert(Model.LegacyFiscalOperations entity)
        {
            IBatchProducer batch = _serviceLayerConnector.CreateBatch();

            batch = _serviceLayerConnector.CreateBatch();
            string record = toJson(entity);

            batch.Post(HttpMethod.Post, "/U_VSCATLGCYCFOP", record);

            ServiceLayerResponse response = await _serviceLayerConnector.Post(batch);


            if (!response.success)
            {
                string message = $"Erro ao enviar transação de '{entity.EntityName}': {response.errorCode}-{response.errorMessage}";
                Console.WriteLine(message);
                throw new ApplicationException(message);
            }
        }
Exemplo n.º 3
0
        async public Task createMulti()
        {
            bool exists = await this.tableExists();

            if (!exists)
            {
                string table = tablePayload();
                ServiceLayerResponse response = await _serviceLayerConnector.Post("UserTablesMD", table, true);

                if (!response.success)
                {
                    // TODO: REGISTRAR LOG DE TABELA NÃO CRIADA
                    System.Console.WriteLine($"Erro ao criar a tabela '{this.name}': {response.errorCode}-{response.errorMessage}");
                }
            }

            foreach (var c in columns)
            {
                string newColumn = columnPayload(c);

                ServiceLayerResponse response = await _serviceLayerConnector.Post("UserFieldsMD", newColumn, true);

                if (!response.success /*&& response.errorCode != FIELD_ALREADY_EXISTS*/)
                {
                    //TODO: REGISTRAR LOG DE CAMPOS NÃO CRIADOS
                    System.Console.WriteLine($"Erro ao criar o campo '{c.name}': {response.errorCode}-{response.errorMessage}");
                }
            }

            foreach (var i in indexes)
            {
                string newIndex = indexPayload(i);
                ServiceLayerResponse response = await _serviceLayerConnector.Post("UserKeysMD", newIndex, true);

                if (!response.success)
                {
                    // TODO: REGISTRAR LOG DE INDICES NÃO CRIADOS
                    System.Console.WriteLine($"Erro ao criar o índice '{i.name}': {response.errorCode}-{response.errorMessage}");
                }
            }
        }