Example #1
0
        public string Add(string sessionId, CustomerInvoice invoice)
        {
            //Real Object
            //var invoice = new CustomerInvoice
            //    {
            //        CustomerCode = "C004200",
            //        DocumentDate = DateTime.Today,
            //        DueDate = DateTime.Today.AddMonths(1),
            //        PostingDate = new DateTime(2015, 11, 01),
            //        SellerCode = 4,
            //        DiscountPercent = 0,
            //        DocumentType = "Alquileres",
            //        ItemDetails = new List<ItemDetail>
            //            {
            //                //new ItemDetail() {ItemCode = "abc001", Quantity = 1, TaxCode = "IV", Currency = "COL"},
            //                new ItemDetail() {ItemCode = "A9999999", Quantity = 2.5,TaxLiable = false, Currency = "USD", Price = 60 }
            //            },
            //            Comments = "Migrado desde Pithos"
            //    };

            var addObject = new AddObject
            {
                CommandID = "Add invoice", BOM = { BO = Mapper.Map <Bombo>(invoice) }
            };

            addObject.BOM.BO.AdmInfo.Object = "oInvoices";


            // Generate SOAP Message
            var command = SoapXmlSerializer.SoapXmlSerialize(addObject, sessionId);

            var result = SapServer.Execute(command);

            return(result.Body.Fault == null?result.Body.AddObjectResponse.RetKey.ToString(CultureInfo.InvariantCulture) : result.Body.Fault.Reason.Text.Value);
        }
Example #2
0
        public string Login(LoginCredentials loginCredentials)
        {
            var command = SoapXmlSerializer.LoginCommand(loginCredentials);

            var result = SapServer.Execute(command);

            return(result.Body.LoginResponse.SessionID);
        }
Example #3
0
        public string Update(string sessionId)
        {
            var project = new CustomerProject
            {
                Code         = "TEST01",
                Name         = "Proyecto Manhathan",
                CustomerName = "Tomela S.A.",
                Address      = "Atras de ti, bruto"
            };

            var addProject = Mapper.Map <UpdateProject>(project);

            // Generate SOAP Message
            var command = SoapXmlSerializer.SoapXmlSerialize(addProject, sessionId);

            var result = SapServer.Execute(command);

            return(result.Body.Fault == null?result.Body.AddObjectResponse.RetKey.ToString(CultureInfo.InvariantCulture) : result.Body.Fault.Reason.Text.Value);
        }
Example #4
0
 public void Logout(string sessionId)
 {
     var command = "<?xml version=\"1.0\" encoding=\"UTF-16\"?><env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\"><env:Header><SessionID>" + sessionId + "</SessionID></env:Header><env:Body><dis:Logout xmlns:dis=\"http://www.sap.com/SBO/DIS\"></dis:Logout></env:Body></env:Envelope>";
     var result  = SapServer.Execute(command);
 }