예제 #1
0
파일: Product.cs 프로젝트: QYFS2018/VC2
        public override ReturnValue ProductDownload()
        {
            ReturnValue _result = new ReturnValue();

            #region get product list

            TProduct _tProduct = new 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.PostProduct(VCBusiness.Common.OwnerCode, item.PartNumber, item.Name);
                if (_result.Success == false)
                {
                    if (_result.Code == -8)
                    {
                        Common.Log("Item : " + item.PartNumber + "---Already exist in VeraCore");
                        continue;
                    }

                    errorNotes = errorNotes + item.PartNumber.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                    failedRecord++;

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

                    continue;
                }


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

            #endregion

            Common.SentAlterEmail(failedRecord, errorNotes);

            _result.Success = true;

            return(_result);
        }
예제 #2
0
파일: Product.cs 프로젝트: QYFS2018/VC2
        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);
        }
예제 #3
0
파일: Order.cs 프로젝트: QYFS2018/VC2
        public override ReturnValue UpdateShipment()
        {
            ReturnValue _result = new ReturnValue();

            Common.Connect();

            #region get order list

            TOrder _tOrder = new TOrder();
            _result = _tOrder.getShimentOrderList();
            if (_result.Success == false)
            {
                _result.Success    = false;
                _result.ErrMessage = "getShimentOrderList failed. \r\n " + _result.ErrMessage;

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

                return(_result);
            }

            EntityList orderList = _result.ObjectList;

            VCBusiness.Model.TProgram_Email _tProgram_Email = Common.CreateObject(this.Owner, "TProgram_Email") as VCBusiness.Model.TProgram_Email;
            _result = _tProgram_Email.getEmailTemplate("SHIP_CONFIRMATION");
            if (_result.Success == false)
            {
                _result.Success    = false;
                _result.ErrMessage = "getEmailTemplate failed. \r\n " + _result.ErrMessage;

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

                return(_result);
            }

            _tProgram_Email = _result.Object as TProgram_Email;



            #endregion

            #region update shipment

            foreach (TOrder order in orderList)
            {
                Common.Log("Order : " + order.OrderId);

                #region GetOrderShipmentInfo

                EntityList productList = new EntityList();

                if (Convert.ToBoolean(System.Configuration.ConfigurationSettings.AppSettings["IsTestMode"].ToString()) == true)
                {
                    #region test


                    TOrder_Line_Item orderline = new TOrder_Line_Item();
                    _result = orderline.getOrderLineItemsByOrderId(order.OrderId);

                    foreach (TOrder_Line_Item item in _result.ObjectList)
                    {
                        item.ShipCarrier    = "UPS";
                        item.ShipMethod     = "STD";
                        item.TrackingNumber = "123456789";
                        item.ShippedDate    = System.DateTime.Now;
                        productList.Add(item);
                    }

                    #endregion
                }
                else
                {
                    #region call Veracore

                    _result = VeraCore.GetOrderShipmentInfo(order.OrderId.ToString());
                    if (_result.Success == false)
                    {
                        if (_result.ErrMessage.IndexOf("Invalid Order ID") > -1)
                        {
                            _result.ErrMessage = "Can't find the order";
                        }
                        else
                        {
                            errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                            failedRecord++;
                        }
                        Common.Log("Order : " + order.OrderId + "  GetOrderShipmentInfo---ER \r\n" + _result.ErrMessage);

                        continue;
                    }

                    productList = _result.ObjectList;

                    if (productList.Count() == 0)
                    {
                        Common.Log("Order : " + order.OrderId + "---Unshipped");

                        continue;
                    }

                    #endregion
                }

                #endregion

                Transaction _tran = new Transaction();

                #region update order line



                foreach (TOrder_Line_Item item in productList)
                {
                    order.ShipCarrier    = item.ShipCarrier;
                    order.ShipMethod     = item.ShipMethod;
                    order.TrackingNumber = item.TrackingNumber;
                    order.ShippedDate    = item.ShippedDate.Value;

                    _result = item.updateOrderLineItemShipment(order.OrderId, item.PartNumber, item.ShippedDate.Value, item.TrackingNumber, _tran);
                    if (_result.Success == false)
                    {
                        _tran.RollbackTransaction();
                        errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                        failedRecord++;

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

                        continue;
                    }

                    if (this.Owner.OwnerInfo["ImportDM"].ToString() == "Y")
                    {
                        TDM_Order_Detail _tDM_Order_Detail = new TDM_Order_Detail();
                        _tDM_Order_Detail.DataConnectProviders = "ZoytoPH";
                        _result = _tDM_Order_Detail.updateDMShipingInfo(order.OrderId, item.PartNumber, order.ShippedDate.Value, order.TrackingNumber);
                        if (_result.Success == false)
                        {
                            _tran.RollbackTransaction();
                            errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                            failedRecord++;

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

                            continue;
                        }
                    }
                }

                #endregion

                #region update carton & ASN

                #region get release list

                TOrder_Line_Item _tOrder_Line_Item = new TOrder_Line_Item();
                _result = _tOrder_Line_Item.getOrderReleaseByOrderId(order.OrderId, _tran);
                if (_result.Success == false)
                {
                    _tran.RollbackTransaction();
                    errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                    failedRecord++;

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

                    continue;
                }

                EntityList _releaseList = _result.ObjectList;

                #endregion

                #region delete cartion and ASN

                TOrder_Line_Shipment_Carton _tOrder_Line_Shipment_Carton = new TOrder_Line_Shipment_Carton();
                _result = _tOrder_Line_Shipment_Carton.deleteOrderLineShipmentCartonByOrderID(order.OrderId, _tran);
                if (_result.Success == false)
                {
                    _tran.RollbackTransaction();
                    errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                    failedRecord++;

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

                    continue;
                }


                TOrder_Line_Shipment_ASN _tOrder_Line_Shipment_ASN = new TOrder_Line_Shipment_ASN();
                _result = _tOrder_Line_Shipment_ASN.deleteOrderLineShipmentASNByOrderID(order.OrderId, _tran);
                if (_result.Success == false)
                {
                    _tran.RollbackTransaction();
                    errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                    failedRecord++;

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

                    continue;
                }

                #endregion

                int releaseID = 1;
                foreach (TOrder_Line_Item item in _releaseList)
                {
                    #region update release number && carton && ASN

                    _result = item.updateOrderReleaseByTracking(order.OrderId, item.TrackingNumber, releaseID, _tran);
                    if (_result.Success == false)
                    {
                        _tran.RollbackTransaction();
                        errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                        failedRecord++;

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

                        continue;
                    }

                    _tOrder_Line_Shipment_Carton                  = new TOrder_Line_Shipment_Carton();
                    _tOrder_Line_Shipment_Carton.ORDER_ID         = order.OrderId;
                    _tOrder_Line_Shipment_Carton.RELEASE_NUM      = releaseID;
                    _tOrder_Line_Shipment_Carton.CARTON_ID_FROM   = releaseID.ToString();
                    _tOrder_Line_Shipment_Carton.CARRIER_ID       = order.ShipCarrier;
                    _tOrder_Line_Shipment_Carton.SHIP_METHOD      = order.ShipMethod;
                    _tOrder_Line_Shipment_Carton.PACKAGE_TRACE_ID = item.TrackingNumber;
                    _tOrder_Line_Shipment_Carton.Ship_date        = item.ShippedDate.Value;

                    _result = _tOrder_Line_Shipment_Carton.Save(_tran);
                    if (_result.Success == false)
                    {
                        _tran.RollbackTransaction();
                        errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                        failedRecord++;

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

                        continue;
                    }


                    _result = item.createASN(order.OrderId, releaseID, _tran);
                    if (_result.Success == false)
                    {
                        _tran.RollbackTransaction();
                        errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                        failedRecord++;

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

                        continue;
                    }

                    #endregion

                    releaseID++;
                }

                #endregion

                #region update phontom item

                _result = _tOrder.updateOrderPhontomOrderStatus(order.OrderId, order.ShippedDate.Value, order.TrackingNumber, _tran);
                if (_result.Success == false)
                {
                    _tran.RollbackTransaction();
                    errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                    failedRecord++;

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

                    continue;
                }

                #endregion

                #region customerEventPostShipmentUpdate

                _result = this.customerEventPostShipmentUpdate(order, productList, _tran);
                if (_result.Success == false)
                {
                    _tran.RollbackTransaction();
                    errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                    failedRecord++;

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

                    continue;
                }



                #endregion

                _tran.CommitTransaction();

                #region sent confirm email

                if (Owner.OwnerInfo["ShipConfirmation"].ToString() == "Y")
                {
                    #region check already sent email

                    App_Log_Mail _app_Log_Mail = new App_Log_Mail();
                    _result = _app_Log_Mail.getEmailLog(order.OrderId, releaseID - 1);
                    if (_result.Success == false)
                    {
                        errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                        failedRecord++;

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

                        continue;
                    }
                    _app_Log_Mail = _result.Object as App_Log_Mail;

                    #endregion

                    if (_app_Log_Mail.ID == 0)
                    {
                        #region sent shipment email

                        #region get email content

                        VCBusiness.EmailFactory EmailFactory = Common.CreateObject(this.Owner, "EmailFactory") as VCBusiness.EmailFactory;
                        _result = EmailFactory.GetMailContent(order.OrderId, releaseID - 1, _tProgram_Email);
                        if (_result.Success == false)
                        {
                            errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                            failedRecord++;

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

                            continue;
                        }
                        EmailMessage email = _result.ObjectValue as EmailMessage;

                        #endregion

                        #region sent email

                        _result = EmailFactory.SentEmail(order.OrderId, releaseID - 1, email);
                        if (_result.Success == false)
                        {
                            errorNotes = errorNotes + order.OrderId.ToString() + "\r\n" + _result.ErrMessage + "\r\n";
                            failedRecord++;

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

                            continue;
                        }
                        #endregion

                        #endregion
                    }
                }

                #endregion

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

            #endregion

            #region update Order Status SH

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

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

                return(_result);
            }


            #endregion

            Common.SentAlterEmail(failedRecord, errorNotes);

            _result.Success = true;


            return(_result);
        }
예제 #4
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);
        }