Esempio n. 1
0
        public static BusinessPartnerBeanLocationBean transformToBusinessPartner(GeolocalizacionBean incidencia)
        {
            try
            {
                var businessPartner = new BusinessPartnerBeanLocationBean();
                var addresses       = new List <AddressLocationBean>();
                addresses.Add(new AddressLocationBean()
                {
                    AddressName = incidencia.CodigoDireccion,
                    AddressType = incidencia.Tipo.Equals("B") ? Constant.BILL_TO : Constant.SHIP_TO,
                    U_MSSM_LAT  = incidencia.Latitud,
                    U_MSSM_LON  = incidencia.Longitud,
                    RowNum      = incidencia.RowNum
                });

                businessPartner.BPAddresses = addresses;

                return(businessPartner);
            }
            catch (Exception ex)
            {
                MainProcess.log.Error("GeolocalizacionDAO > transformToBusinessPartner() > " + ex.Message);
                return(null);
            }
        }
Esempio n. 2
0
        public static string actualizarDireccion(string sessionId, string routeId, string urlSL, GeolocalizacionBean gelocation)
        {
            string res = string.Empty;

            try
            {
                var document = transformToBusinessPartner(gelocation);
                if (document != null)
                {
                    File.WriteAllText(Util.castURL(MainProcess.mConn.pathJSONLog, "\\") + "UBICACION_" + gelocation.ClaveMovil
                                      + ".json",
                                      SimpleJson.SerializeObject(document));
                    IRestResponse response = makeRequest(Util.castURL(urlSL, "/") +
                                                         Constant.BUSINESS_PARTNERS + "('" + gelocation.CodigoCliente.Trim() + "')",
                                                         Method.PATCH, sessionId, routeId, document);

                    if (response.StatusCode != System.Net.HttpStatusCode.NoContent)
                    {
                        //res = string.Empty;
                        //MainProcess.log.Error("GeolocalizacionDAO > acualizarDireccion() > Ubicación " +
                        //    gelocation.ClaveMovil + " - " + gelocation.CodigoDireccion + " > " + response.Content);
                        //actualizarPropiedades(gelocation.ClaveMovil,
                        //    MainProcess.mConn.urlPatchIncidencia +whats
                        //                    "?empId=" + gelocation.Empresa +
                        //                    "&ccId=" + gelocation.CodigoCliente,
                        //    "{\"MIGRADO\":\"N\", \"MENSAJE\": \"" + Util.replaceEscChar(response.Content) + "\"}");
                    }
                    else
                    {
                        actualizarPropiedades(gelocation.ClaveMovil, MainProcess.mConn.urlPatchUbicacion +
                                              "?codEmpresa=" + gelocation.Empresa +
                                              "&codCliente=" + gelocation.CodigoCliente +
                                              "&codDireccion=" + gelocation.CodigoDireccion,
                                              "{\"Migrado\":\"Y\"}");
                    }
                }
            }
            catch (Exception ex)
            {
                res = string.Empty;
                MainProcess.log.Error("GeolocalizacionDAO > acualizarDireccion() > " + ex.Message);
            }

            return(res);
        }