コード例 #1
0
ファイル: Order.cs プロジェクト: QYFS2018/VC2
        protected virtual ReturnValue updateExpectedShipDate(TOrder order, EntityList orderline)
        {
            ReturnValue _result = new ReturnValue();

            if (orderline.Count == 0)
            {
                return(_result);
            }


            Model.TOrder_Line_Item _line0 = orderline[0] as Model.TOrder_Line_Item;

            #region calcuate ExpectedShipDate

            TOrder _tOrderExpectedShipDate = new TOrder();
            _tOrderExpectedShipDate.DataConnectProviders = "ZoytoCommon";
            _result = _tOrderExpectedShipDate.getOrderExpectedShipDate(order.ProgramID, System.DateTime.Now, _line0.ShipMethod);
            if (_result.Success == false)
            {
                return(_result);
            }
            _tOrderExpectedShipDate = _result.Object as TOrder;

            if (Convert.ToBoolean(System.Configuration.ConfigurationSettings.AppSettings["IsTestMode"].ToString()) == true)
            {
                _tOrderExpectedShipDate.ExpectedShipDate = System.DateTime.Now.AddDays(5);
            }


            if (_tOrderExpectedShipDate.ExpectedShipDate == null || _tOrderExpectedShipDate.ExpectedShipDate.Value.Year == 1)
            {
                _result.Success    = false;
                _result.ErrMessage = "expected ship date is invalid :" + _tOrderExpectedShipDate.ExpectedShipDate.ToString();
                return(_result);
            }
            else
            {
                order.ExpectedShipDate = _tOrderExpectedShipDate.ExpectedShipDate;
                _result = order.updateOrderExpectedShipDate(order.OrderId, _tOrderExpectedShipDate.ExpectedShipDate.Value);
                if (_result.Success == false)
                {
                    return(_result);
                }
            }

            #endregion


            return(_result);
        }
コード例 #2
0
ファイル: Order.cs プロジェクト: QYFS2018/VC2
        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);
        }