Esempio n. 1
0
        public void Run(string customDataJson)
        {
            m_customerRepository.SyncShadowCustomers();

            m_log.Info("Starting synchronization of customers from ERP");
            foreach (var erp in m_erpClientFactory.GetAllErpClients())
            {
                var erpCustomerModels = erp.LoadCustomers().ToList();
                if (!erpCustomerModels.Any())
                {
                    continue;
                }

                m_customerRepository.SyncCustomers(erpCustomerModels);
            }

            m_log.Info("Newsletter subscribers sync from MailChimp:");

            var mc = new MailchimpClient();

            var subscribers = Task.Run(() => mc.GetMembersSubscriptionStatus(m_mcConfig, m_log)).Result;

            m_log.Info($"Received {subscribers.Count} of newsletter subscribers info");
            m_customerRepository.UpdateNewsletterSubscribersList("Mailchimp", subscribers);

            //m_log.Info($"Obtaining subscribers missing in the Mailchimp but subscribed on web:");
            //var toSubscribe = m_customerRepository.GetSubscribersToSync("Mailchimp");
        }
Esempio n. 2
0
        public void CopyFromFlox(string orderNumber)
        {
            var flox =
                m_erpClientFactory.GetAllErpClients()
                .First(c => c.Erp.Description.Equals("Flox", StringComparison.InvariantCultureIgnoreCase));

            var order = flox.LoadOrder(orderNumber);

            if (order == null)
            {
                throw new InvalidOperationException("Order not found in source");
            }

            var nnum = $"EL{orderNumber}";

            order.SetDebugNumber(nnum);

            m_elerp.SaveOrder(order);
        }
Esempio n. 3
0
        public IEnumerable <IPurchaseOrder> GetAndSyncPaidOrders(DateTime historyDepth, bool skipErp = false)
        {
            m_log.Info($"Nacitam zaplacene objednavky od {historyDepth}");

            if (skipErp)
            {
                foreach (var rpo in m_orderRepository.GetOrdersByStatus(OrderStatus.ReadyToPack))
                {
                    yield return(rpo);
                }

                yield break;
            }


            var erps = m_clientFactory.GetAllErpClients().ToList();

            m_orderRepository.PreloadOrders(historyDepth, DateTime.Now.AddDays(1));

            foreach (var erpClient in erps)
            {
                m_log.Info($"Nacitam zaplacene objednavky od {historyDepth} z ERP = {erpClient.Erp.Description}");

                var paidOrders = erpClient.LoadPaidOrders(historyDepth, DateTime.Now.AddDays(1)).ToList();
                m_log.Info($"Stazeno {paidOrders.Count} objednavek");

                if (!paidOrders.Any())
                {
                    continue;
                }

                foreach (var paidOrder in paidOrders)
                {
                    var importedId = m_orderRepository.ImportErpOrder(paidOrder);
                    yield return(m_orderRepository.GetOrder(importedId));
                }
            }

            m_log.Info("Hotovo");
        }
Esempio n. 4
0
 public ElerpController(IWebSession webSession, ILog log, IErpClientFactory erpClientFactory)
     : base(webSession, log)
 {
     m_erpClientFactory = erpClientFactory;
     m_elerp            = (ElerpClient)m_erpClientFactory.GetAllErpClients().First(i => i.Erp.Description.ToLower().Contains("elerp"));
 }