public T Save(string jsonKeys, ParamsIntegrateErp configErp, List <object> parameterAditional) { WorkerIntegrate workerIntegrate = null; Workers worker = null; DealerShopIntegrate dealerShopIntegrate = null; if (Enum.TryParse(configErp.DllType, out ErpsTypes dllType)) { worker = DataAccesErpContract.GetWorker(jsonKeys, dllType, new ParamsContract() { ConectionStringErp = configErp.ConectionStringErp, ConectionStringSystime = configErp.ConectionStringToSystime, Language = configErp.LanguageDb, SupportShop = configErp.IdShopsErpArray }, out List <Tuple <Type, String> > listOtherAccionPreIntegrate); dealerShopIntegrate = UtilsIIntegrateErpToSystime.IntegrateOtherTypes <DealerShopIntegrate>(listOtherAccionPreIntegrate, configErp, null); if (dealerShopIntegrate == null) { dealerShopIntegrate = UtilsIIntegrateErpToSystime.ResolveTypeParameter <DealerShopIntegrate>(parameterAditional); } if (worker != null) { if (worker?.IdDealerShop != dealerShopIntegrate?.DealerShopSystime?.IdDealerShop) { worker.IdDealerShop = dealerShopIntegrate?.DealerShopSystime?.IdDealerShop; } worker = new WorkersSystime(configErp.ConectionStringToSystime).SaveWorker(worker, configErp.UserModify); if (worker != null) { workerIntegrate = new WorkerIntegrate() { WokerSystime = worker }; if (configErp.SaveInAzure) { List <Object> modelsParams = new List <object>(); if (dealerShopIntegrate?.DealerShopUbicar != null) { modelsParams.Add(dealerShopIntegrate?.DealerShopUbicar); } workerIntegrate.WorkerUbicar = SaveInAzure(worker, modelsParams, configErp); } } } } if (workerIntegrate != null) { return((T)Convert.ChangeType(workerIntegrate, typeof(T))); } return(default(T)); }
public WorkOrder SaveInAzure(WorkOrders workOrder, List <Object> paramsService, ParamsIntegrateErp configErp) { ServiceUbicar.Save(new WorkOrder() { IdCustomer = UtilsIIntegrateErpToSystime.ResolveTypeParameter <Person>(paramsService)?.IdPerson, IdDealerRepresentative = UtilsIIntegrateErpToSystime.ResolveTypeParameter <DealerRepresentative>(paramsService)?.IdDealerRepresentative, IdDealerShop = UtilsIIntegrateErpToSystime.ResolveTypeParameter <DealerShop>(paramsService)?.IdDealerShop, IdInsuraceConpany = UtilsIIntegrateErpToSystime.ResolveTypeParameter <InsuranceCompany>(paramsService)?.IdInsuranceCompany, IdVehicle = UtilsIIntegrateErpToSystime.ResolveTypeParameter <Vehicle>(paramsService)?.IdVehicle, IdErpQuote = workOrder?.IdErpQuote?.ToString(), WorkOrderIdErp = workOrder?.WorkOrderNumber, EnteredAt = workOrder?.EnteredAt, AutorizedAt = workOrder?.AuthorizedAt, IsTotalLoss = workOrder?.HasTotalLoss, Note = workOrder?.Note, ProgressMessaje = workOrder?.Note, PartsCompletedAt = workOrder?.PartsCompletedAt, ReadyToBePickedUpAt = workOrder?.ReadyToPickUpAt, PickedUpAt = workOrder?.PickedUpAt, PromisedAt = workOrder?.PromisedAt }, configErp.ReturnModelService, configErp.UrlService, configErp.LanguageDb, configErp.Token); if (ServiceUbicar.CodErrorRequest().HasValue&& (ServiceUbicar.CodErrorRequest().Value == TypeErrorWebServicess.OperationOk.GetHashCode() || ServiceUbicar.CodErrorRequest().Value == TypeErrorWebServicess.NotDataFromUpdate.GetHashCode())) { new WorkOrderLoadErrorLogSystime(configErp.ConectionStringToSystime).DeleteWorkOrderError(workOrder.WorkOrderNumber, workOrder.IdDealerShop); } else { new WorkOrderLoadErrorLogSystime(configErp.ConectionStringToSystime).SaveWorkOrderError(new WorkOrderLoadErrorLog() { idCustomerOT = workOrder.IdCustomer.ToString(), idVehicle = workOrder.IdVinNumber, IdWorkOrderNumberErp = workOrder.WorkOrderNumber, idDealerShopOtErp = workOrder.IdDealerShop, idWorkerOT = workOrder.WorkOrderNumber, CloudUpdateError = String.Concat(ServiceUbicar.CodErrorRequest(), "-", ServiceUbicar.MessageError()) }, configErp.UserModify); } return(null); }
public Models.DealerRepresentative SaveInAzure(Workers worker, List <Object> paramsService, ParamsIntegrateErp configErp) { ServiceUbicar.Save(new Models.DealerRepresentative() { IdCity = worker?.IdCity, IdDealer = configErp.IdDealerUbicarService, IdDealerShop = UtilsIIntegrateErpToSystime.ResolveTypeParameter <Models.DealerShop>(paramsService)?.IdDealerShop, IdErpRepresentative = worker?.IdWorker, IdentityNumber = worker?.IdWorker, Email = worker?.Email, FullName = worker?.FullName, Mobile = worker?.Mobile, Phone = worker?.Phone }, configErp.ReturnModelService, configErp.UrlService, configErp.LanguageDb, configErp.Token); if (ServiceUbicar.CodErrorRequest().HasValue&& (ServiceUbicar.CodErrorRequest().Value == TypeErrorWebServicess.OperationOk.GetHashCode() || ServiceUbicar.CodErrorRequest().Value == TypeErrorWebServicess.NotDataFromUpdate.GetHashCode())) { return(ServiceUbicar.CastObjectResponse <Models.DealerRepresentative>()); } return(null); }
public Models.Vehicle SaveInAzure(Vehicles vehicle, List <Object> paramsService, ParamsIntegrateErp configErp) { ServiceUbicar.Save(new Models.Vehicle() { IdDealer = configErp.IdDealerUbicarService, IdCity = vehicle?.IdCity, IdCountry = vehicle?.IdCountry, IdVehicleModel = vehicle?.IdVehicleModel, IdInsuranceCompany = UtilsIIntegrateErpToSystime.ResolveTypeParameter <Models.InsuranceCompany>(paramsService)?.IdInsuranceCompany ?? ConstansServiceUbicar.ID_DEFAULT_INSURANCECOMPANYCLOUD, IdVehicleServiceType = vehicle?.IdVehicleServiceType, Vin = String.IsNullOrEmpty(vehicle?.IdVinNumber) ? vehicle?.Plate : vehicle?.IdVinNumber, IdVehicleType = vehicle?.IdVehicleType, ModelYear = vehicle?.ModelYear, Plate = vehicle?.Plate }, configErp.ReturnModelService, configErp.UrlService, configErp.LanguageDb, configErp.Token); if (ServiceUbicar.CodErrorRequest().HasValue&& (ServiceUbicar.CodErrorRequest().Value == TypeErrorWebServicess.OperationOk.GetHashCode() || ServiceUbicar.CodErrorRequest().Value == TypeErrorWebServicess.NotDataFromUpdate.GetHashCode())) { return(ServiceUbicar.CastObjectResponse <Models.Vehicle>()); } return(null); }
T IIntegrate <T> .Save(string jsonKeys, ParamsIntegrateErp configErp, List <Object> parameterAditional) { VehicleIntegrate vehicleIntegrate = null; Vehicles vehicles = null; CustomerIntegrate customerParam = null; InsuranceCompanyIntegrate integrateinsuranceCompany = null; InsuranceCompanyIntegrate insuranceCompanyParam = null; int?mileageParam = null; if (Enum.TryParse(configErp.DllType, out ErpsTypes dllType)) { vehicles = DataAccesErpContract.GetVehicle(jsonKeys, dllType, configErp.ConfigParamsToErp, out List <Tuple <Type, string> > listOtherAccionPreIntegrate); if (vehicles != null) { integrateinsuranceCompany = UtilsIIntegrateErpToSystime.IntegrateOtherTypes <InsuranceCompanyIntegrate>(listOtherAccionPreIntegrate, configErp, null); insuranceCompanyParam = UtilsIIntegrateErpToSystime.ResolveTypeParameter <InsuranceCompanyIntegrate>(parameterAditional); customerParam = UtilsIIntegrateErpToSystime.ResolveTypeParameter <CustomerIntegrate>(parameterAditional); mileageParam = UtilsIIntegrateErpToSystime.ResolveTypeParameter <int>(parameterAditional); if (customerParam?.CustomerSystime?.IdCustomer > 0 && customerParam?.CustomerSystime?.IdCustomer != vehicles.IdCustomerOwner) { vehicles.IdCustomerOwner = customerParam.CustomerSystime.IdCustomer; } if (mileageParam.HasValue && mileageParam.Value > vehicles.LastMileage) { vehicles.LastMileage = mileageParam.Value; } if (insuranceCompanyParam?.InsuranceCompnaySystime?.IdInsuranceCompany != null && insuranceCompanyParam?.InsuranceCompnaySystime?.IdInsuranceCompany != integrateinsuranceCompany?.InsuranceCompnaySystime?.IdInsuranceCompany) { integrateinsuranceCompany = insuranceCompanyParam; } vehicles.IdInsuranceCompany = integrateinsuranceCompany?.InsuranceCompnaySystime.IdInsuranceCompany; vehicles = new VehiclesSystime(configErp.ConectionStringToSystime).SaveVehicle(vehicles, configErp.UserModify); if (vehicles != null) { vehicleIntegrate = new VehicleIntegrate() { VehicleSystime = vehicles }; if (configErp.SaveInAzure) { List <Object> modelsParams = new List <object>(); if (insuranceCompanyParam?.InsuranceCompnayUbicar != null) { modelsParams.Add(insuranceCompanyParam?.InsuranceCompnayUbicar); } if (customerParam?.CustomerUbicar != null) { modelsParams.Add(customerParam?.CustomerUbicar); } vehicleIntegrate.VehicleUbicar = SaveInAzure(vehicles, modelsParams, configErp); } } ; } } if (vehicleIntegrate != null) { return((T)Convert.ChangeType(vehicleIntegrate, typeof(T))); } return(default(T)); }