Пример #1
0
        public override ReturnValue UpdateInventoryStatus()
        {
            ReturnValue _result = new ReturnValue();

            Common.Connect();

            #region get product list

            Model.TProduct _tProduct = Common.CreateObject(this.Owner, "TProduct") as Model.TProduct;
            _result = _tProduct.getProductList();
            if (_result.Success == false)
            {
                _result.Success    = false;
                _result.ErrMessage = "getProductList failed. \r\n " + _result.ErrMessage;

                Common.Log("getProductList---ER \r\n" + _result.ErrMessage);

                return(_result);
            }

            EntityList productList = _result.ObjectList;

            #endregion

            #region get inventory

            foreach (TProduct item in productList)
            {
                _result = VeraCore.GetInventory(VCBusiness.Common.OwnerCode, item);
                if (_result.Success == false)
                {
                    if (_result.ErrMessage.IndexOf("Can not retrieve any information") > -1)
                    {
                        _result.ErrMessage = "Can't find the product in VeraCore";
                    }
                    else
                    {
                        errorNotes = errorNotes + item.PartNumber.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                        failedRecord++;
                    }

                    Common.Log("Item : " + item.PartNumber + "  GetInventory---ER \r\n" + _result.ErrMessage);

                    continue;
                }



                _result = item.updateProductEstUnit(item.ProductId, item.EstUnits, item.PHOnHand);
                if (_result.Success == false)
                {
                    errorNotes = errorNotes + item.PartNumber.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                    failedRecord++;

                    Common.Log("Item : " + item.PartNumber + "  updateProductEstUnit---ER \r\n" + _result.ErrMessage);

                    continue;
                }

                successfulRecord++;
                Common.Log("Item : " + item.PartNumber + "---OK---" + item.EstUnits + "--" + item.PHOnHand);
            }

            #endregion

            #region UpdateBOOrder

            _result = _tProduct.UpdateBOOrder();
            if (_result.Success == false)
            {
                _result.Success    = false;
                _result.ErrMessage = "UpdateBOOrder failed. \r\n " + _result.ErrMessage;

                Common.Log("UpdateBOOrder---ER \r\n" + _result.ErrMessage);

                return(_result);
            }

            #endregion

            Common.SentAlterEmail(failedRecord, errorNotes);

            _result.Success = true;

            return(_result);
        }
Пример #2
0
        public override ReturnValue Download()
        {
            ReturnValue _result = new ReturnValue();

            Common.Connect();

            #region get order list

            Model.TOrder _tOrder = Common.CreateObject(this.Owner, "TOrder") as Model.TOrder;
            _result = _tOrder.getDownloadOrderList(int.Parse(Owner.OwnerInfo["ProgramID"].ToString()));
            if (_result.Success == false)
            {
                _result.Success    = false;
                _result.ErrMessage = "getDownloadOrderList failed. \r\n " + _result.ErrMessage;

                Common.Log("getDownloadOrderList---ER \r\n" + _result.ErrMessage);

                return(_result);
            }

            EntityList orderList = _result.ObjectList;

            #endregion

            #region post order to VerCore

            foreach (TOrder order in orderList)
            {
                #region get order line

                Model.TOrder_Line_Item _tOrder_Line_Item = Common.CreateObject(this.Owner, "TOrder_Line_Item") as Model.TOrder_Line_Item;
                _result = _tOrder_Line_Item.getOrderLineByOrderId(order.OrderId);
                if (_result.Success == false)
                {
                    errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                    failedRecord++;

                    Common.Log("Order : " + order.OrderId + "  getOrderLineByOrderId---ER \r\n" + _result.ErrMessage);

                    continue;
                }

                EntityList orderItemList = _result.ObjectList;

                if (orderItemList.Count() == 0)
                {
                    _result.ErrMessage = "Can't find Line Item";
                    errorNotes         = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                    failedRecord++;

                    Common.Log("Order : " + order.OrderId + "  getOrderLineByOrderId---ER \r\n" + _result.ErrMessage);

                    continue;
                }


                #endregion

                #region fill data

                order.ProgramID = int.Parse(Owner.OwnerInfo["ProgramID"].ToString());


                if (Owner.OwnerInfo.ContainsKey("FreightService") == true)  // VeraCore Default Shipmethod
                {
                    ((TOrder_Line_Item)orderItemList[0]).ShipMethod = Owner.OwnerInfo["FreightService"].ToString();
                }

                _result = this.customerEventPreOrderDownload(order, orderItemList);
                if (_result.Success == false)
                {
                    errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                    failedRecord++;

                    Common.Log("Order : " + order.OrderId + "  customerData---ER \r\n" + _result.ErrMessage);

                    continue;
                }

                #endregion

                #region ExpectedShipDate

                if (this.Owner.OwnerInfo.ContainsKey("ExpectedShipDate") == true && this.Owner.OwnerInfo["ExpectedShipDate"].ToString() == "Y")
                {
                    _result = this.updateExpectedShipDate(order, orderItemList);
                    if (_result.Success == false)
                    {
                        errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                        failedRecord++;

                        Common.Log("Order : " + order.OrderId + "  updateExpectedShipDate---ER \r\n" + _result.ErrMessage);

                        continue;
                    }
                }

                #endregion

                #region post order to VeraCore

                _result = VeraCore.PostOrder(order, orderItemList);
                if (_result.Success == false)
                {
                    if (_result.ErrMessage.IndexOf("already exists") > -1)
                    {
                        _result.ErrMessage = "The Order Already Exists";
                    }

                    errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                    failedRecord++;

                    Common.Log("Order : " + order.OrderId + "  PostOrder---ER \r\n" + _result.ErrMessage);

                    continue;
                }

                #endregion

                #region release  order line

                _result = _tOrder_Line_Item.ReleaseOrderLineByOrderId(order.OrderId);
                if (_result.Success == false)
                {
                    errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                    failedRecord++;

                    Common.Log("Order : " + order.OrderId + "  ReleaseOrderLineByOrderId---ER \r\n" + _result.ErrMessage);

                    continue;
                }

                #endregion

                #region ImportDMOrderDetail

                if (this.Owner.OwnerInfo["ImportDM"].ToString() == "Y")
                {
                    _result = this.ImportDMOrderDetail(order.OrderId);
                    if (_result.Success == false)
                    {
                        errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                        failedRecord++;

                        Common.Log("Order : " + order.OrderId + "  ImportDMOrderDetail---ER \r\n" + _result.ErrMessage);

                        continue;
                    }
                }
                #endregion

                successfulRecord++;
                Common.Log("Order : " + order.OrderId + "---OK");
            }

            #endregion

            #region update stock

            Model.TProduct _tProduct = Common.CreateObject(this.Owner, "TProduct") as Model.TProduct;
            _result = _tProduct.resetProductEstcommitted();
            if (_result.Success == false)
            {
                _result.Success    = false;
                _result.ErrMessage = "resetProductEstcommitted failed. \r\n " + _result.ErrMessage;

                Common.Log("resetProductEstcommitted---ER \r\n" + _result.ErrMessage);

                return(_result);
            }



            #endregion

            Common.SentAlterEmail(failedRecord, errorNotes);

            _result.Success = true;

            return(_result);
        }