Esempio n. 1
0
        /// <summary>
        /// Metoto encarghado de convertir el dealer representative erp
        /// to dealer representative Systime
        /// </summary>
        /// <param name="workerErp"></param>
        /// <param name="idDealerShop"></param>
        /// <returns></returns>
        internal Workers ParseWorker(terceros workerErp, String idDealerShop, Boolean isDEalerRepresentative, String activityWorker, out List <Tuple <Type, String> > paramsAditional, Boolean?isActive = true)
        {
            paramsAditional = null;
            if (workerErp != null)
            {
                String idJobTitle = new ToolsDmsV1(ParamsContract).AjustJobTitle(activityWorker, isDEalerRepresentative);

                String[] phones = new ToolsDmsV1(ParamsContract).AjustPhone(workerErp.telefono_1, workerErp.telefono_2);
                Workers  worker = new Workers()
                {
                    //Ajusta la tienda en systime
                    IdWorker     = new ToolsDmsV1(ParamsContract).AjusWorker(workerErp.nit.ToString()),
                    FullName     = workerErp.nombres,
                    Mobile       = phones[0],
                    IdDealerShop = idDealerShop,
                    Phone        = phones[1],
                    Email        = workerErp.mail,
                    IdCity       = new ToolsDmsV1(ParamsContract).AjusCity(workerErp.y_ciudad, workerErp.y_dpto, workerErp.y_pais),
                    Address      = workerErp.direccion,
                    //TODO :  se debe validar la activacion
                    Active = true
                };

                paramsAditional = new List <Tuple <Type, string> >
                {
                    new Tuple <Type, string>(typeof(CloudCatalogDealerShops), JsonConvert.SerializeObject(new DelaerShopKeysDmsV1()
                    {
                        IdShop = idDealerShop
                    }))
                };
                return(worker);
            }
            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Metoto encargado de obtener Customer a partir
        /// </summary>
        /// <param name="idCustomer"></param>
        /// <returns></returns>
        internal Customers GetCustomer(String jsonKeys)
        {
            CustomerKeys customerKeys = JsonConvert.DeserializeObject <CustomerKeys>(jsonKeys);

            if (customerKeys != null && decimal.TryParse(customerKeys?.IdCustomer, out decimal nit))
            {
                using (DmsV1Entities DataBase = new DmsV1Entities(ConectionStringErp))
                {
                    DataBase.Database.CommandTimeout = 1000;
                    terceros customerErp = DataBase.terceros.FirstOrDefault(d => d.nit == nit);
                    return(ParseCustomer(customerErp));
                }
            }
            return(null);
        }
Esempio n. 3
0
        /// <summary>
        /// Metoto encargado de consutlar el dealerRepresentative en el erp
        /// </summary>
        /// <param name="idDealer"></param>
        /// <param name="idDealerShop"></param>
        /// <returns></returns>
        internal Workers GetWorker(String jsonKeys, out List <Tuple <Type, String> > paramsAditional)
        {
            paramsAditional = null;
            String          DealerShop = null;
            Boolean         isDealerRepresentatives = false;
            String          activityWorker          = "";
            Boolean?        isActive   = true;
            WorkerKeysDmsV1 workerKeys = JsonConvert.DeserializeObject <WorkerKeysDmsV1>(jsonKeys);

            if (workerKeys != null && !String.IsNullOrEmpty(workerKeys?.IdWorker))
            {
                using (DmsV1Entities DataBase = new DmsV1Entities(ConectionStringErp))
                {
                    DataBase.Database.CommandTimeout = 1000;
                    if (int.TryParse(workerKeys.IdWorker, out int id))
                    {
                        tall_operarios operarioErp = DataBase.tall_operarios.FirstOrDefault(w => w.nit == id);
                        terceros       workerErp   = null;
                        if (operarioErp != null)
                        {
                            activityWorker = operarioErp.actividad;
                            isActive       = operarioErp.activo;
                            //Si esto ocurre es operario
                            workerErp  = operarioErp.terceros;
                            DealerShop = operarioErp.bodega?.ToString();
                        }
                        else
                        {
                            isDealerRepresentatives = true;
                            workerErp = DataBase.terceros.FirstOrDefault(w => w.nit == id);
                        }


                        if (String.IsNullOrEmpty(DealerShop))
                        {
                            DealerShop = workerKeys.IdDealerShopWorkOrder;
                        }

                        if (workerErp != null)
                        {
                            return(ParseWorker(workerErp, DealerShop, isDealerRepresentatives, activityWorker, out paramsAditional, isActive));
                        }
                    }
                }
            }
            return(null);
        }
Esempio n. 4
0
        /// <summary>
        /// Metoto encargado de obtener la compañia de seguros
        /// </summary>
        /// <param name="tinInsuranceCompany"></param>
        /// <returns></returns>
        internal CloudCatalogInsuranceCompanies GetInsuranceCompany(String jsonKeys)
        {
            InsuranceComnayKeysDmsV1 InsuranceCompanyKeys = JsonConvert.DeserializeObject <InsuranceComnayKeysDmsV1>(jsonKeys);

            if (InsuranceCompanyKeys != null && decimal.TryParse(InsuranceCompanyKeys?.Tin, out decimal nit))
            {
                using (DmsV1Entities DataBase = new DmsV1Entities(ConectionStringErp))
                {
                    DataBase.Database.CommandTimeout = 1000;
                    terceros InsuranceCompanyErp = DataBase.terceros.FirstOrDefault(i => i.nit == nit);
                    if (InsuranceCompanyErp != null)
                    {
                        return(ParsheInsuranceCompany(InsuranceCompanyErp));
                    }
                }
            }
            return(null);
        }
Esempio n. 5
0
 /// <summary>
 /// Metoto encargado de convertir un trabajador de dmsv1 to trabajador
 /// de systime
 /// </summary>
 /// <param name="workerErp"></param>
 /// <returns></returns>
 internal Customers ParseCustomer(terceros customerErp)
 {
     if (customerErp != null)
     {
         //AjusCustomer
         String[]  phones   = new ToolsDmsV1(ParamsContract).AjustPhone(customerErp.telefono_2, customerErp.telefono_1);
         Customers customer = new Customers()
         {
             FullName       = customerErp.nombres,
             Email          = customerErp.email2,
             DocumentNumber = customerErp.nit.ToString(),
             Phone          = phones[1],
             Mobile         = phones[0],
             IdCountry      = new ToolsDmsV1(ParamsContract).AjusCountrie(customerErp.y_pais),
             IdCity         = new ToolsDmsV1(ParamsContract).AjusCity(customerErp.y_ciudad, customerErp.y_dpto, customerErp.y_pais),
             Address        = customerErp.direccion
         };
         return(customer);
     }
     return(null);
 }
Esempio n. 6
0
 /// <summary>
 /// Metoto encargado de convertir una compañia de seguros
 /// de erp a systime
 /// </summary>
 /// <param name="inSuranceCompanyErp"></param>
 /// <returns></returns>
 internal CloudCatalogInsuranceCompanies ParsheInsuranceCompany(terceros inSuranceCompanyErp)
 {
     if (inSuranceCompanyErp != null)
     {
         String[] phones = new ToolsDmsV1(ParamsContract).AjustPhone(inSuranceCompanyErp.telefono_1, inSuranceCompanyErp.telefono_2);
         CloudCatalogInsuranceCompanies insuranceCompany = new CloudCatalogInsuranceCompanies()
         {
             TIN = inSuranceCompanyErp.nit.ToString(),
             InsuranceCompany = inSuranceCompanyErp.nombres,
             Address          = inSuranceCompanyErp.direccion,
             Website          = inSuranceCompanyErp.paginaweb,
             Mobile           = phones[0],
             Phone            = phones[1],
             Email            = inSuranceCompanyErp.email2,
             IdCity           = new ToolsDmsV1(ParamsContract).AjusCity(inSuranceCompanyErp.y_ciudad, inSuranceCompanyErp.y_dpto, inSuranceCompanyErp.y_pais),
             IdCountry        = new ToolsDmsV1(ParamsContract).AjusCountrie(inSuranceCompanyErp.y_pais),
         };
         return(insuranceCompany);
     }
     return(null);
 }