Example #1
0
        void GetSUPOrders()
        {
            while (isGetSUPOrdersThreadStatus)
            {
                try
                {
                    int time = 0;

                    WriteLog.Write("方法:GetSUPOrders 开始取单:" + DateTime.Now.ToString(), LogPathFile.Other);

                    List <Order> orderSet = new GetAndNotifySUPOrders().getOrderFromSUP(ref time);

                    WriteLog.Write("方法:GetSUPOrders 取到订单:" + DateTime.Now.ToString(), LogPathFile.Other);

                    if (orderSet != null && orderSet.Count > 0)
                    {
                        bool result  = SQLOrder.AddOrder(orderSet);
                        int  Recount = 0;
                        while (!result)
                        {
                            if (Recount > 10)
                            {
                                break;
                            }
                            result = SQLOrder.AddOrder(orderSet);
                            Recount++;
                            Thread.Sleep(1 * 1000);
                        }

                        WriteLog.Write("方法:GetSUPOrders 订单保存成功:" + DateTime.Now.ToString(), LogPathFile.Other);

                        //foreach (Order order in orderSet)
                        //{
                        //    bool result = SQLOrder.AddOrder(order);
                        //    int Recount = 0;
                        //    while (!result)
                        //    {
                        //        if (Recount > 10)
                        //        {
                        //            break;
                        //        }
                        //        result = SQLOrder.AddOrder(order);
                        //        Recount++;
                        //        Thread.Sleep(1 * 1000);
                        //    }
                        //}
                    }
                    Thread.Sleep(time * 1000);
                }
                catch (Exception ex)
                {
                    WriteLog.Write("方法:GetSUPOrders异常,信息:" + ex.Message + ex.StackTrace, LogPathFile.Exception.ToString());
                }
            }
        }
Example #2
0
        void getSWOrders()
        {
            while (isGetSWOrdersThreadStatus)
            {
                try
                {
                    int time = 0;

                    List <Order> orderSet = new ManageSW().getOrderFromSW(ref time);

                    if (orderSet == null)
                    {
                        Thread.Sleep(time * 1000);
                        continue;
                    }

                    foreach (Order order in orderSet)
                    {
                        if (new ManageSW().notigyOrderToSW(order, true))
                        {
                            bool result  = SQLOrder.AddOrder(order);
                            int  Recount = 0;
                            while (!result)
                            {
                                if (Recount > 10)
                                {
                                    break;
                                }
                                result = SQLOrder.AddOrder(order);
                                Recount++;
                                Thread.Sleep(1 * 1000);
                            }
                        }
                    }
                    Thread.Sleep(time * 1000);
                }
                catch (Exception ex)
                {
                    WriteLog.Write("方法:getSWOrders异常,信息:" + ex.Message + ex.StackTrace, LogPathFile.Exception.ToString());
                }
            }
        }