Beispiel #1
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);
            }
        }
Beispiel #2
0
        async public Task create()
        {
            if (custom)
            {
                bool exists = await this.tableExists();

                IBatchProducer batch = _serviceLayerConnector.CreateBatch();

                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}");
                }
            }

            if (custom)
            {
                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}");
                    }
                }
            }

            System.Console.WriteLine("OK");
        }