コード例 #1
0
        private BusinessPlaces toRecord(dynamic record)
        {
            BusinessPlaces businessplaces = new BusinessPlaces();

            //businessplaces.RecId = Guid.Parse(record.Code);
            businessplaces.AdditionalIdNumber = record.AdditionalIdNumber;
            businessplaces.Address            = record.Address;
            businessplaces.Addressforeign     = record.Addressforeign;
            businessplaces.AddressType        = record.AddressType;
            businessplaces.AliasName          = record.AliasName;
            businessplaces.Block                          = record.Block;
            businessplaces.BPLID                          = record.BPLID;
            businessplaces.BPLName                        = record.BPLName;
            businessplaces.BPLNameForeign                 = record.BPLNameForeign;
            businessplaces.Building                       = record.Building;
            businessplaces.Business                       = record.Business;
            businessplaces.City                           = record.City;
            businessplaces.CommercialRegister             = record.CommercialRegister;
            businessplaces.CompanyQualificationCode       = record.CompanyQualificationCode;
            businessplaces.CooperativeAssociationTypeCode = record.CooperativeAssociationTypeCode;
            businessplaces.Country                        = record.Country;
            businessplaces.County                         = record.County;
            businessplaces.CreditContributionOriginCode   = record.CreditContributionOriginCode;
            businessplaces.DateOfIncorporation            = parseDate(record.DateOfIncorporation);
            businessplaces.DeclarerTypeCode               = record.DeclarerTypeCode;
            businessplaces.DefaultCustomerID              = record.DefaultCustomerID;
            businessplaces.DefaultResourceWarehouseID     = record.DefaultResourceWarehouseID;
            businessplaces.DefaultTaxCode                 = record.DefaultTaxCode;
            businessplaces.DefaultVendorID                = record.DefaultVendorID;
            businessplaces.DefaultWarehouseID             = record.DefaultWarehouseID;
            businessplaces.Disabled                       = record.Disabled;
            businessplaces.EconomicActivityTypeCode       = record.EconomicActivityTypeCode;
            businessplaces.EnvironmentType                = record.EnvironmentType;
            businessplaces.FederalTaxID                   = record.FederalTaxID;
            businessplaces.FederalTaxID2                  = record.FederalTaxID2;
            businessplaces.FederalTaxID3                  = record.FederalTaxID3;
            businessplaces.GlobalLocationNumber           = record.GlobalLocationNumber;
            //record.IENumbers = record.
            businessplaces.Industry      = record.Industry;
            businessplaces.IPIPeriodCode = record.IPIPeriodCode;
            //record.MainBPL = record.
            businessplaces.NatureOfCompanyCode = record.NatureOfCompanyCode;
            //record.Opting4ICMS = record.
            businessplaces.PaymentClearingAccount = record.PaymentClearingAccount;
            businessplaces.PreferredStateCode     = record.PreferredStateCode;
            businessplaces.ProfitTaxationCode     = record.ProfitTaxationCode;
            businessplaces.RepName     = record.RepName;
            businessplaces.SPEDProfile = record.SPEDProfile;
            businessplaces.State       = record.State;
            businessplaces.Street      = record.Street;
            businessplaces.StreetNo    = record.StreetNo;
            businessplaces.TaxOffice   = record.TaxOffice;
            businessplaces.TaxOfficeNo = record.TaxOfficeNo;
            //record.TributaryInfos = record.
            //record.UserFields = record.
            businessplaces.VATRegNum = record.VATRegNum;
            businessplaces.ZipCode   = record.ZipCode;

            return(businessplaces);
        }
コード例 #2
0
 public static void AddOrUpdateBusinessPlaces(BusinessPlaces BusinessPlaces)
 {
     try
     {
         SAPbobsCOM.BusinessPlaces oBP = SAP.SAPCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPlaces);
         if (oBP.GetByKey(BusinessPlaces.BPLId))
         {
             oBP.BPLName                    = BusinessPlaces.BPLName;
             oBP.BPLNameForeign             = BusinessPlaces.TaxIdNum;
             oBP.RepName                    = BusinessPlaces.RepName;
             oBP.Industry                   = BusinessPlaces.Industry;
             oBP.Business                   = BusinessPlaces.Business;
             oBP.Address                    = BusinessPlaces.Address;
             oBP.MainBPL                    = SAPBOneCommon.GetEnumYesNo(BusinessPlaces.MainBPL);
             oBP.TaxOfficeNo                = BusinessPlaces.TxOffcNo;
             oBP.Disabled                   = SAPBOneCommon.GetEnumYesNo(BusinessPlaces.Disabled);
             oBP.DefaultCustomerID          = BusinessPlaces.DflCust;
             oBP.DefaultVendorID            = BusinessPlaces.DflVendor;
             oBP.DefaultWarehouseID         = BusinessPlaces.DflWhs;
             oBP.DefaultResourceWarehouseID = BusinessPlaces.DfltResWhs;
             oBP.AliasName                  = BusinessPlaces.AliasName;
             oBP.AddressType                = BusinessPlaces.AddrType;
             oBP.Block    = BusinessPlaces.Block;
             oBP.City     = BusinessPlaces.City;
             oBP.Street   = BusinessPlaces.Street;
             oBP.StreetNo = BusinessPlaces.StreetNo;
             oBP.Building = BusinessPlaces.Building;
             oBP.ZipCode  = BusinessPlaces.ZipCode;
             oBP.Country  = BusinessPlaces.Country;
             oBP.County   = BusinessPlaces.County;
             oBP.PaymentClearingAccount = BusinessPlaces.PmtClrAct;
             oBP.GlobalLocationNumber   = BusinessPlaces.GlblLocNum;
             int rt = oBP.Update();
             if (rt != 0)
             {
                 //failed
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #3
0
        async public Task <BusinessPlaces> Find(List <Criteria> criterias)
        {
            string recid = criterias[0].Value;
            string query = Global.BuildQuery($"BusinessPlaces('{recid}')");

            string data = await _serviceLayerConnector.getQueryResult(query);

            ExpandoObject record = Global.parseQueryToObject(data);

            BusinessPlaces businessplaces = toRecord(record);

            // Recupera as linhas da nota iscal
            string[] filter = new string[]
            {
                $"Code eq '{recid}'"
            };

            query = Global.MakeODataQuery("BusinessPlaces", null, filter);

            data = await _serviceLayerConnector.getQueryResult(query);

            return(businessplaces);
        }
コード例 #4
0
        private string toJsonPartners(BusinessPlaces businesspartners, string LOJ_CLI)
        {
            string  result = string.Empty;
            dynamic record = new ExpandoObject();

            record.ContactEmployees        = businesspartners.ContactEmployees;
            record.BillToBuildingFloorRoom = businesspartners.BillToBuildingFloorRoom;
            record.AliasName = businesspartners.AliasName;
            record.CardCode  = businesspartners.CardCode.Replace("-", LOJ_CLI);
            record.CardName  = businesspartners.CardName;
            record.CardType  = businesspartners.CardType;
            if (businesspartners.FatherCard != null & businesspartners.FatherCard != "" && !businesspartners.FatherCard.Contains("000000"))
            {
                record.FatherCard = businesspartners.FatherCard;
            }
            record.RelationshipDateFrom    = businesspartners.RelationshipDateFrom;
            record.RelationshipDateTill    = businesspartners.RelationshipDateTill;
            record.BPAddresses             = businesspartners.BPAddresses;
            record.BPFiscalTaxIDCollection = businesspartners.BPFiscalTaxIDCollection;
            record.BPBankAccounts          = businesspartners.BPBankAccounts;
            record.Address = businesspartners.Address;
            result         = JsonConvert.SerializeObject(record);
            return(result);
        }
コード例 #5
0
        async public Task Insert(BusinessPlaces entity)
        {
            IBatchProducer batch    = _serviceLayerConnector.CreateBatch();
            string         codigoWH = criaCodigoWareHouses(entity.BPLName, entity.BPLID.ToString(), "01");

            entity.DefaultWarehouseID         = codigoWH;
            entity.DefaultResourceWarehouseID = codigoWH;
            string recordWareHouses = toJsonwarehouses(entity.BPLName, codigoWH);

            batch.Post(HttpMethod.Post, "/Warehouses", recordWareHouses);
            ServiceLayerResponse response = await _serviceLayerConnector.Post("Warehouses", recordWareHouses);

            codigoWH = criaCodigoWareHouses(entity.BPLName, entity.BPLID.ToString(), "99");
            //entity.DefaultWarehouseID = codigoWH;
            //entity.DefaultResourceWarehouseID = codigoWH;
            recordWareHouses = toJsonwarehouses(entity.BPLName, codigoWH);
            batch.Post(HttpMethod.Post, "/Warehouses", recordWareHouses);
            response = await _serviceLayerConnector.Post("Warehouses", recordWareHouses);

            //businessPlaces
            batch = _serviceLayerConnector.CreateBatch();
            entity.BPLNameForeign = entity.BPLName;
            string record = toJson(entity);

            batch.Post(HttpMethod.Post, "/BusinessPlaces", record);
            response = await _serviceLayerConnector.Post("BusinessPlaces", record);

            if (entity.CardCode.Contains("D"))
            {
            }
            //businesspartners F
            entity.CardType = "cSupplier";
            record          = toJsonPartners(entity, "F");
            batch.Post(HttpMethod.Post, "/BusinessPartners", record);
            response = await _serviceLayerConnector.Post("BusinessPartners", record);

            //businesspartners C
            entity.CardType = "cCustomer";
            record          = toJsonPartners(entity, "C");
            batch.Post(HttpMethod.Post, "/BusinessPartners", record);
            response = await _serviceLayerConnector.Post("BusinessPartners", record);

            //descomentar daqui pra baixo
            //IBatchProducer batch = _serviceLayerConnector.CreateBatch();
            //string codigoWH = criaCodigoWareHouses(entity.BPLName, entity.BPLID.ToString(), "01");
            //entity.DefaultWarehouseID = codigoWH;
            //entity.DefaultResourceWarehouseID = codigoWH;
            //string recordFiliais = toJson(entity);
            //string recordWareHouses = toJsonwarehouses(entity.BPLName, codigoWH);
            //batch.Post(HttpMethod.Post, "/Warehouses", recordWareHouses);
            //batch.Post(HttpMethod.Post, "/BusinessPlaces", recordFiliais);
            //ServiceLayerResponse response = await _serviceLayerConnector.Post(batch);


            if (!response.success && !(response.errorMessage.Contains("1320000140")))
            {
                string message = $"Erro ao enviar transação de '{entity.EntityName}': {response.errorCode}-{response.errorMessage}";
                Console.WriteLine(message);
                throw new ApplicationException(message);
            }
            else
            {
                var    idEntidade = entity.RecId;
                var    cad        = toJsonEntidades();
                string query      = Global.BuildQuery($"U_VSITENTIDADE('{idEntidade}')");
                response = await _serviceLayerConnector.Patch(query, cad, true);
            }
        }
コード例 #6
0
        private string toJsonTeste(BusinessPlaces businessplaces)
        {
            string result = string.Empty;

            dynamic record = new ExpandoObject();

            //record.Code = businessplaces.RecId.ToString();
            record.AdditionalIdNumber = null;
            record.Address            = "Avenue Paulista,13";
            record.Addressforeign     = "Avenue Paulista,13";
            record.AddressType        = "Avenida";
            record.AliasName          = "OEC Computadores DEMONSTRAÇÃO";
            record.Block                          = "Vila Almeida";
            record.BPLID                          = 2142;
            record.BPLName                        = "MASTERCARD ON LINE";
            record.BPLNameForeign                 = "MASTERCARD ON LINE";
            record.Building                       = "cj 1284";
            record.Business                       = null; //
            record.City                           = "São Paulo";
            record.CommercialRegister             = null;
            record.CompanyQualificationCode       = 1;
            record.CooperativeAssociationTypeCode = -1;
            record.Country                        = "BR";   //
            record.County                         = "5344"; //
            record.CreditContributionOriginCode   = 1;
            record.DateOfIncorporation            = "2010-01-01";
            record.DeclarerTypeCode               = 1;
            record.DefaultCustomerID              = businessplaces.DefaultCustomerID;
            record.DefaultResourceWarehouseID     = 1;
            record.DefaultTaxCode                 = 420;
            record.DefaultVendorID                = null;
            record.DefaultWarehouseID             = 1;
            //record.Disabled = businessplaces.Disabled;
            record.EconomicActivityTypeCode = 0;
            record.EnvironmentType          = 1;
            record.FederalTaxID             = businessplaces.FederalTaxID;
            record.FederalTaxID2            = businessplaces.FederalTaxID2;
            record.FederalTaxID3            = businessplaces.FederalTaxID3;
            record.GlobalLocationNumber     = businessplaces.GlobalLocationNumber;
            record.Industry               = businessplaces.Industry;
            record.IPIPeriodCode          = 0;
            record.NatureOfCompanyCode    = 0;
            record.PaymentClearingAccount = businessplaces.PaymentClearingAccount;
            record.PreferredStateCode     = "SP";
            record.ProfitTaxationCode     = 3;
            record.RepName     = businessplaces.RepName;
            record.SPEDProfile = "A";
            record.State       = businessplaces.State;
            record.Street      = "Paulista";
            record.StreetNo    = "13.999";
            record.TaxOffice   = businessplaces.TaxOffice;
            record.TaxOfficeNo = businessplaces.TaxOfficeNo;

            record.VATRegNum = businessplaces.VATRegNum;
            record.ZipCode   = businessplaces.ZipCode;

            //record.IENumbers = businessplaces.
            //record.MainBPL = businessplaces.
            //record.Opting4ICMS = businessplaces.
            //record.TributaryInfos = businessplaces.
            //record.UserFields = businessplaces.
            //record.Browser = businessplaces.
            result = JsonConvert.SerializeObject(record);

            return(result);
        }
コード例 #7
0
 public Task Delete(BusinessPlaces entity)
 {
     throw new NotImplementedException();
 }
コード例 #8
0
        private string toJson(BusinessPlaces businessplaces)
        {
            string result = string.Empty;

            dynamic record = new ExpandoObject();

            //record.Code = businessplaces.RecId.ToString();
            record.AdditionalIdNumber = businessplaces.AdditionalIdNumber;
            record.Address            = businessplaces.Address;
            record.Addressforeign     = businessplaces.Addressforeign;
            record.AddressType        = businessplaces.AddressType;
            record.AliasName          = businessplaces.AliasName;
            record.Block = businessplaces.Block;
            //record.BPLID = businessplaces.BPLID;
            record.BPLName                        = businessplaces.BPLName;
            record.BPLNameForeign                 = businessplaces.BPLNameForeign;
            record.Building                       = businessplaces.Building;
            record.Business                       = businessplaces.Business;
            record.City                           = businessplaces.City;
            record.CommercialRegister             = businessplaces.CommercialRegister;
            record.CompanyQualificationCode       = businessplaces.CompanyQualificationCode;
            record.CooperativeAssociationTypeCode = businessplaces.CooperativeAssociationTypeCode;
            record.Country                        = parseCountry(businessplaces.Country);
            record.County                         = "5344";
            record.CreditContributionOriginCode   = businessplaces.CreditContributionOriginCode;
            record.DateOfIncorporation            = businessplaces.DateOfIncorporation;
            record.DeclarerTypeCode               = businessplaces.DeclarerTypeCode;
            record.DefaultCustomerID              = businessplaces.DefaultCustomerID;
            record.DefaultResourceWarehouseID     = businessplaces.DefaultResourceWarehouseID;
            record.DefaultTaxCode                 = businessplaces.DefaultTaxCode;
            record.DefaultVendorID                = businessplaces.DefaultVendorID;

            record.DefaultWarehouseID       = businessplaces.DefaultWarehouseID;
            record.Disabled                 = "tNO";
            record.EconomicActivityTypeCode = businessplaces.EconomicActivityTypeCode;
            record.EnvironmentType          = businessplaces.EnvironmentType;
            record.FederalTaxID             = businessplaces.FederalTaxID;
            record.FederalTaxID2            = businessplaces.FederalTaxID2;
            record.FederalTaxID3            = businessplaces.FederalTaxID3;
            record.GlobalLocationNumber     = businessplaces.GlobalLocationNumber;
            record.Industry                 = businessplaces.Industry;
            record.IPIPeriodCode            = businessplaces.IPIPeriodCode;
            record.NatureOfCompanyCode      = businessplaces.NatureOfCompanyCode;
            record.PaymentClearingAccount   = businessplaces.PaymentClearingAccount;
            record.PreferredStateCode       = businessplaces.PreferredStateCode;
            record.ProfitTaxationCode       = businessplaces.ProfitTaxationCode;
            record.RepName     = businessplaces.RepName;
            record.SPEDProfile = businessplaces.SPEDProfile;
            record.State       = businessplaces.State;
            record.Street      = businessplaces.Street;
            record.StreetNo    = businessplaces.StreetNo;
            record.TaxOffice   = businessplaces.TaxOffice;
            record.TaxOfficeNo = businessplaces.TaxOfficeNo;

            record.VATRegNum = businessplaces.VATRegNum;
            record.ZipCode   = businessplaces.ZipCode;

            //record.IENumbers = businessplaces.
            //record.MainBPL = businessplaces.
            //record.Opting4ICMS = businessplaces.
            //record.TributaryInfos = businessplaces.
            //record.UserFields = businessplaces.
            //record.Browser = businessplaces.
            result = JsonConvert.SerializeObject(record);

            return(result);
        }