コード例 #1
0
        private void CheckPreparedRequest(CustomDataSourceTypes dataSourceType, Ix4RequestProps ix4Property)
        {
            try
            {
                // if (UpdateTimeWatcher.TimeToCheck(ix4Property))
                {
                    _loger.Log(string.Format("Start Check {0} using {1} plugin", ix4Property.ToString(), dataSourceType.ToString()));
                    LICSRequest[] requests = _dataCompositor.GetPreparedRequests(dataSourceType, ix4Property);

                    if (requests != null && HasItemsForSending(requests, ix4Property))
                    {
                        foreach (var item in requests)
                        {
                            //_loger.Log(string.Format("Count of available {0} = {1}", ix4Property, item.OrderImport.Length));
                            //_loger.Log("LicsReques orders = " + item.SerializeObjectToString<LICSRequest>());
                            item.ClientId = _customerInfo.ClientID;
                            //_loger.Log("client id = " + _customerInfo.ClientID);
                            foreach (var order in item.OrderImport)
                            {
                                order.ClientNo = _customerInfo.ClientID;
                            }
                            bool res = SendLicsRequestToIx4(item, string.Format("{0}File.xml", ix4Property.ToString()));
                            _loger.Log(string.Format("{0} result: {1}", ix4Property, res));
                            if (res)
                            {
                                UpdateTimeWatcher.SetLastUpdateTimeProperty(ix4Property);
                            }
                        }
                    }
                    _loger.Log(string.Format("Finish Check {0} using {1} plugin", ix4Property.ToString(), dataSourceType.ToString()));
                    System.Threading.Thread.Sleep(30000);
                }
            }
            catch (Exception ex)
            {
                _loger.Log(ex);
            }
        }
コード例 #2
0
        private void CheckArticles()
        {
            int countA = 0;

            if (_isArticlesBusy)
            {
                _loger.Log("Check articles is busy");
                return;
            }
            try
            {
                if (UpdateTimeWatcher.TimeToCheck(Ix4RequestProps.Articles))
                {
                    WrightLog("Check Artikles started");
                    _isArticlesBusy = true;

                    int         currentClientID = _customerInfo.ClientID;
                    LICSRequest request         = new LICSRequest();
                    request.ClientId = currentClientID;
                    LICSRequestArticle[] articles = _dataCompositor.GetRequestArticles();

                    _loger.Log(string.Format("Got ARTICLES {0}", articles != null ? articles.Length : 0));

                    if (articles == null || articles.Length == 0)
                    {
                        _loger.Log("There is no available articles");
                        return;
                    }

                    List <LICSRequestArticle> tempAtricles = new List <LICSRequestArticle>();

                    for (int i = 0; i < articles.Length; i++)
                    {
                        articles[i].ClientNo = currentClientID;
                        tempAtricles.Add(articles[i]);
                        if (tempAtricles.Count >= _articlesPerRequest || i == articles.Length - 1)
                        {
                            request.ArticleImport = tempAtricles.ToArray();
                            var resSent = SendLicsRequestToIx4(request, "articleFile.xml");
                            if (resSent)
                            {
                                countA++;
                                _loger.Log(string.Format("Was sent {0} request with {1} articles", countA, tempAtricles.Count));
                                tempAtricles = new List <LICSRequestArticle>();
                            }
                        }
                    }
                    UpdateTimeWatcher.SetLastUpdateTimeProperty(Ix4RequestProps.Articles);
                }
            }
            catch (Exception ex)
            {
                _loger.Log(ex);
                _loger.Log("Inner excep " + ex.InnerException);
                _loger.Log("Inner excep MESSAGE" + ex.InnerException.Message);
            }
            finally
            {
                _isArticlesBusy = false;
            }
        }
コード例 #3
0
        private void CheckDeliveries()
        {
            try
            {
                if (UpdateTimeWatcher.TimeToCheck(Ix4RequestProps.Deliveries))
                {
                    if (_cachedArticles == null)
                    {
                        _loger.Log("There is no cheched articles for filling deliveries");
                        CheckArticles();
                        if (_cachedArticles == null)
                        {
                            _loger.Log("WE CANNOT GET DELIVERIES WITHOUT ARTICLES");
                            return;
                        }
                    }
                    int         currentClientID = _customerInfo.ClientID;
                    LICSRequest request         = new LICSRequest();
                    request.ClientId = currentClientID;
                    LICSRequestDelivery[]     deliveries            = _dataCompositor.GetRequestDeliveries();
                    List <LICSRequestArticle> articlesByDelliveries = new List <LICSRequestArticle>();
                    _loger.Log(deliveries, "deliveries");
                    if (deliveries.Length == 0)
                    {
                        _loger.Log("There is no deliveries");
                        return;
                    }
                    foreach (LICSRequestDelivery delivery in deliveries)
                    {
                        bool deliveryHasErrors = false;
                        articlesByDelliveries  = new List <LICSRequestArticle>();
                        delivery.ClientNo      = currentClientID;
                        request.DeliveryImport = new LICSRequestDelivery[] { delivery };
                        foreach (var position in delivery.Positions)
                        {
                            LICSRequestArticle findArticle = GetArticleByNumber(position.ArticleNo);
                            if (findArticle == null)
                            {
                                _loger.Log("Cannot find article with no:  " + position.ArticleNo);
                                _loger.Log("Delivery with wrong article position:  " + delivery);
                                deliveryHasErrors = true;
                            }
                            else
                            {
                                articlesByDelliveries.Add(findArticle);
                            }
                        }
                        if (deliveryHasErrors)
                        {
                            _loger.Log("Delivery " + delivery + "WAS NOT SEND");
                            continue;
                        }
                        else
                        {
                            request.ArticleImport = articlesByDelliveries.ToArray();
                            _loger.Log("Delivery before sending: ");
                            foreach (LICSRequestDelivery item in request.DeliveryImport)
                            {
                                _loger.Log(item.SerializeObjectToString <LICSRequestDelivery>());
                            }

                            var res = SendLicsRequestToIx4(request, "deliveryFile.xml");
                            _loger.Log("Delivery result: " + res);
                        }
                    }
                    UpdateTimeWatcher.SetLastUpdateTimeProperty(Ix4RequestProps.Deliveries);
                }
            }
            catch (Exception ex)
            {
                _loger.Log(ex);
            }
        }