Exemplo n.º 1
0
        public bool SaveAll(ParamsIntegrateErp configErp, DateTime dateTimeMin)
        {
            List <String> listKsonKeys = null;
            int?          countTotal   = 0;
            int           countOk      = 0;

            if (Enum.TryParse(configErp.DllType, out ErpsTypes dllType))
            {
                listKsonKeys = DataAccesErpContract.GetAllJsonKeysWorkORder(dllType, new ParamsContract()
                {
                    ConectionStringErp     = configErp.ConectionStringErp,
                    ConectionStringSystime = configErp.ConectionStringToSystime,
                    Language    = configErp.LanguageDb,
                    SupportShop = configErp.IdShopsErpArray
                }, dateTimeMin);

                countTotal = listKsonKeys?.Count;

                Parallel.ForEach(listKsonKeys, k => {
                    try
                    {
                        WorkOrderIntegrate wokrOrerIntegrarte = null;
                        wokrOrerIntegrarte = Save(k, configErp, null);
                        if (wokrOrerIntegrarte?.WorkOrderSystime != null)
                        {
                            countOk++;
                        }
                    }
#pragma warning disable S2486 // Generic exceptions should not be ignored
                    catch (Exception ex)
#pragma warning disable S108  // Nested blocks of code should not be left empty
                    {
                    }
#pragma warning restore S108  // Nested blocks of code should not be left empty
#pragma warning restore S2486 // Generic exceptions should not be ignored
                });

                //listKsonKeys.ForEach(

                if (countOk != 0 && countTotal != 0)
                {
                    return(countOk == countTotal);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        private T Saving(WorkOrders workOrder, List <Tuple <Type, String> > listOtherAccionPreIntegrate, ParamsIntegrateErp configErp)
        {
            WorkOrderIntegrate        workOrderIntegrate        = null;
            InsuranceCompanyIntegrate integrateinsuranceCompany = null;
            CustomerIntegrate         integrateCustoemr         = null;
            WorkerIntegrate           integrateWorker           = null;
            DealerShopIntegrate       integrateDalerShop        = null;
            VehicleIntegrate          vehicleIntegrate          = null;
            int milageWorkOrder = 0;

            if (workOrder != null)
            {
                integrateinsuranceCompany = UtilsIIntegrateErpToSystime.IntegrateOtherTypes <InsuranceCompanyIntegrate>(listOtherAccionPreIntegrate, configErp, null);
                integrateCustoemr         = UtilsIIntegrateErpToSystime.IntegrateOtherTypes <CustomerIntegrate>(listOtherAccionPreIntegrate, configErp, null);
                integrateDalerShop        = UtilsIIntegrateErpToSystime.IntegrateOtherTypes <DealerShopIntegrate>(listOtherAccionPreIntegrate, configErp, null);
                List <Object> paramsFromWorker = new List <object>
                {
                    integrateDalerShop
                };
                integrateWorker = UtilsIIntegrateErpToSystime.IntegrateOtherTypes <WorkerIntegrate>(listOtherAccionPreIntegrate, configErp, paramsFromWorker);
                milageWorkOrder = UtilsIIntegrateErpToSystime.SearchValueFromType <int>(listOtherAccionPreIntegrate);

                List <Object> paramsFromVehicle = new List <object>
                {
                    integrateinsuranceCompany,
                    milageWorkOrder,
                    integrateCustoemr
                };


                vehicleIntegrate = UtilsIIntegrateErpToSystime.IntegrateOtherTypes <VehicleIntegrate>(listOtherAccionPreIntegrate, configErp, paramsFromVehicle);

                if (integrateCustoemr?.CustomerSystime != null && integrateWorker?.WokerSystime != null &&
                    integrateDalerShop?.DealerShopSystime != null)
                {
                    workOrder.IdVinNumber           = vehicleIntegrate?.VehicleSystime?.IdVinNumber;
                    workOrder.IdSalesRepresentative = integrateWorker?.WokerSystime?.IdWorker;
                    workOrder.IdDealerShop          = integrateDalerShop?.DealerShopSystime?.IdDealerShop;
                    workOrder.IdInsuranceCompany    = integrateinsuranceCompany?.InsuranceCompnaySystime?.IdInsuranceCompany;
                    workOrder.IdCustomer            = integrateCustoemr?.CustomerSystime?.IdCustomer ?? 0;

                    workOrder = new WorOrdersSystime(configErp.ConectionStringToSystime).SaveWorkOrder(workOrder, configErp.UserModify);
                    if (workOrder != null)
                    {
                        new WorkOrderLoadErrorLogSystime(configErp.ConectionStringToSystime).DeleteWorkOrderError(workOrder.WorkOrderNumber, workOrder.IdDealerShop);
                        workOrderIntegrate = new WorkOrderIntegrate()
                        {
                            WorkOrderSystime = workOrder
                        };

                        if (configErp.SaveInAzure)
                        {
                            List <Object> modelsParams = new List <object>();
                            if (integrateinsuranceCompany?.InsuranceCompnayUbicar != null)
                            {
                                modelsParams.Add(integrateinsuranceCompany?.InsuranceCompnayUbicar);
                            }
                            if (integrateCustoemr?.CustomerUbicar != null)
                            {
                                modelsParams.Add(integrateCustoemr?.CustomerUbicar);
                            }
                            if (integrateDalerShop?.DealerShopUbicar != null)
                            {
                                modelsParams.Add(integrateDalerShop?.DealerShopUbicar);
                            }
                            if (vehicleIntegrate?.VehicleUbicar != null)
                            {
                                modelsParams.Add(vehicleIntegrate?.VehicleUbicar);
                            }
                            if (integrateWorker?.WorkerUbicar != null)
                            {
                                modelsParams.Add(integrateWorker?.WorkerUbicar);
                            }
                            workOrderIntegrate.WorkOrderUbicar = SaveInAzure(workOrder, modelsParams, configErp);
                        }
                    }
                }
                else if (workOrder != null)
                {
                    new WorkOrderLoadErrorLogSystime(configErp.ConectionStringToSystime).SaveWorkOrderError(new WorkOrderLoadErrorLog()
                    {
                        idCustomerOT         = workOrder.IdCustomer.ToString(),
                        idVehicle            = workOrder.IdVinNumber,
                        IdWorkOrderNumberErp = workOrder.WorkOrderNumber,
                        idDealerShopOtErp    = workOrder.IdDealerShop,
                        idWorkerOT           = workOrder.WorkOrderNumber,
                    }, configErp.UserModify);
                }

                if (workOrderIntegrate != null)
                {
                    return((T)Convert.ChangeType(workOrderIntegrate, typeof(T)));
                }
            }
            return(default(T));
        }