Esempio n. 1
0
        /// <summary>
        /// 根据主单据ID获取单据及其所有子单据的实例.
        /// </summary>
        /// <param name="pCate">单据类型(支持的类型包括取消商城订单和取消退货订单)</param>
        /// <param name="pOid">返回HttpReqXml_OrderCacnel对象实体,若失败则返回Null</param>
        /// <returns></returns>
        static public HttpReqXmlBase GetReqXmlBody_CancelOrder(TCWmsOrderCategory pCate, string pOid)
        {
            var ret = new ThirdResult <List <object> >(string.Format("单据[{0}]取消, 根据主单据{1}获取单据及其所有子单据的实例, 开始", pCate, pOid));

            HttpReqXmlBase         retObj    = null;
            HttpReqXml_OrderCacnel tmpReqObj = null;
            CWmsMcocOrder          order     = null;

            try
            {
                // 从获取单据实体
                if (null != (order = GetCWmsOrder(pCate, pOid) as CWmsMcocOrder))
                {
                    tmpReqObj = new HttpReqXml_OrderCacnel(order);
                    retObj    = tmpReqObj;
                }
            }
            catch (Exception ex)
            {
                if (null != ex.InnerException)
                {
                    ret.Append(string.Format("InnerException: {0}", ex.InnerException.Message));
                }
                ret.Append(string.Format("发生异常: {0}\r\n调用堆栈:{1}", ex.Message, ex.StackTrace));
            }
            ret.Append(string.Format("单据[{0}]取消, 根据主单据{1}获取单据及其所有子单据的实例完成, 返回{2}", pCate, pOid, retObj));
            ret.End();
            return(retObj);
        }
Esempio n. 2
0
        /// <summary>
        /// 根据主退货订单Id获取主退货订单实体及其所有子退货订单的实体
        /// </summary>
        /// <param name="pRid">主退货订单Id</param>
        /// <returns>返回HttpRespXml_ReturnOrderCreate对象实体,若失败则返回Null</returns>
        static public HttpReqXmlBase GetReqXmlBody_ReturnOrderCreate(string pRid)
        {
            var ret = new ThirdResult <List <object> >(string.Format("根据主退货订单[{0}]获取主退货订单实体及其所有子退货订单的实体, 开始", pRid));

            HttpReqXmlBase retObj = null;
            HttpReqXml_ReturnOrderCreate tmpRespObj = null;
            List <HttpReqXml_ReturnOrderCreate_Orders> orderLinesList = null;
            CWmsReturnOrder order = null;

            try
            {
                #region 从商城里获取主退货订单及其所有子单据
                order = GetCWmsReturnOrder(pRid);
                #endregion
                #region 根据商城的退货订单创建HttpRespXml_ReturnOrderCreate实体
                if (null != order)
                {
                    orderLinesList = new List <HttpReqXml_ReturnOrderCreate_Orders>(1);
                    foreach (var so in order.SubOrders)
                    {
                        HttpReqXml_ReturnOrderCreate_Orders orderLine = new HttpReqXml_ReturnOrderCreate_Orders();
                        orderLine.CopyFrom(so.Value as CWmsSubReturnOrder);
                        ret.Append(string.Format("itemcode={0}", (so.Value.MangoOrder as MangoSubReturnOrder).ProductId.ToString()));
                        orderLine.itemCode = (so.Value.MangoOrder as MangoSubReturnOrder).ProductId.ToString();
                        orderLinesList.Add(orderLine);
                    }

                    tmpRespObj = new HttpReqXml_ReturnOrderCreate();
                    tmpRespObj.returnOrder.CopyFrom(order);
                    tmpRespObj.orders = orderLinesList.ToArray();
                    retObj            = tmpRespObj;
                    ret.Append(string.Format("根据商城的退货订单创建HttpRespXml实体: {0}, 子单据数量: {1}", retObj, (retObj as HttpReqXml_ReturnOrderCreate).orders.Length));
                }
                else
                {
                    ret.Append(string.Format("从商城里获取主退货订单及其所有子单据失败,order={0}", order));
                }
                #endregion
            }
            catch (Exception ex)
            {
                if (null != ex.InnerException)
                {
                    ret.Append(string.Format("InnerException: {0}", ex.InnerException.Message));
                }
                ret.Append(string.Format("发生异常: {0}\r\n调用堆栈:{1}", ex.Message, ex.StackTrace));
            }
            ret.End();
            return(retObj);
        }
Esempio n. 3
0
        /// <summary>
        /// 执行HTTP会话。
        /// </summary>
        /// <param name="args">重载方法应传入至少2个参数。且第一个输入参数为string类型的商城系统中的主出库单ID</param>
        /// <returns>返回存储了HTTP response body的HttpRespXmlBase实例</returns>
        public HttpRespXmlBase DoTransaction(params object[] args)
        {
            var ret = new ThirdResult <List <object> >("CWmsStockoutCreate.DoTransaction()开始");

            HttpReqXmlBase  reqBody      = null;         // new HttpReqXml_InventoryMonitoring();请求
            HttpRespXmlBase respBody     = null;         //响应
            int             addTo709Rows = 0;            //添加到709中的数据
            string          errMsg       = string.Empty; //错误信息

            #region 从入参中获取单据ID
            try { mCachedOrderId = args[0] as string; }//传递值转换成string 失败就抛出异常
            catch (Exception ex)
            {
                ret.Append(string.Format("发生异常:{0}", ex.Message));
                ret.End();
                return(null);
            }
            #endregion
            try
            {
                var cwmsOrder = CWmsStockoutOrderHandler.NewOrder(mCachedOrderId);
                cwmsOrder.Handler.UpdateDict709(cwmsOrder, TDict285_Values.EDeleted, TDict285_Values.ENormal, true);
                // update Dit[709]
                if (0 >= Dict709Handle.UpdateRow_StockoutCreate(mCachedOrderId, TDict285_Values.EDeleted, TDict285_Values.ENormal, out addTo709Rows, out errMsg))
                {
                    ret.Append(string.Format("CWmsStockoutCreate.DoTransaction()结束,向Dict[709]插入创建出库订单行失败:{0}, {1}", addTo709Rows, errMsg));
                    ret.End();
                    return(null);
                }//提交709数据

                // generate Http request body
                if (null == (reqBody = CWmsDataFactory.GetReqXmlBody_ExWarehouseCreate(mCachedOrderId)))
                {
                    ret.Append(string.Format("CWmsStockoutCreate.DoTransaction(),创建请求体对象失败"));
                    ret.End();
                    return(null);
                }

                respBody = Post(reqBody);   // Do Http transaction
                ret.Append(string.Format("ResponseXML={0}", respBody.ToString()));
                // 处理response body
                if (null == respBody)
                {
                    // update Dict[709]
                    Dict709Handle.UpdateRow_StockoutCreate(mCachedOrderId, TDict285_Values.ENormal, TDict285_Values.ENormal, out addTo709Rows, out errMsg);
                    ret.Append(string.Format("CWmsStockoutCreate.DoTransaction()结束"));
                    // TODO: 返回失败
                    ret.Append(string.Format("失败,ResponseXML对象为null"));
                    ret.End();

                    return(null);
                }
                else if (!respBody.IsSuccess())
                {
                    // TODO: 返回失败
                    ret.Append(string.Format("失败,ResponseXML对象flag=failure"));
                    ret.End();
                    return(respBody);
                }
                else
                {
                    Dict709Handle.UpdateRow_StockoutCreate(mCachedOrderId, TDict285_Values.ENormal, TDict285_Values.ENormal, out addTo709Rows, out errMsg);
                    ret.Append(string.Format("CWmsStockoutCreate.DoTransaction()结束"));
                    ret.End();
                    return(respBody);
                }
            }
            catch (Exception ex)
            {
                if (null != ex.InnerException)
                {
                    ret.Append(string.Format("InnerException: {0}", ex.InnerException.Message));
                }
                ret.Append(string.Format("发生异常: {0}\r\n调用堆栈:{1}", ex.Message, ex.StackTrace));
                ret.End();
                return(null);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// inner method. 执行HTTP会话
        /// </summary>
        /// <param name="pMapClassId">Dict[709].MapClassId</param>
        /// <param name="moid">待取消的主单据Id</param>
        /// <param name="pResp">返回HTTP Response XML实体</param>
        /// <param name="pMsg">返回错误描述</param>
        /// <returns>返回存储了HTTP response body的HttpRespXmlBase实例</returns>
        /// <returns></returns>
        protected int DoTransaction(TDict709_Value pMapClassId, string moid, out HttpRespXmlBase pResp, out string pMsg)
        {
            var ret = new ThirdResult <List <object> >(string.Format("同步取消单据HTTP会话,开始, MapClassId={0}, modi{1}", pMapClassId, moid));

            try
            {
                #region temp variables
                pMsg  = string.Empty;
                pResp = null;
                int    errCode    = TError.Post_ParamError.Int(); // 方法返回值
                int    errDict709 = TError.WCF_RunError.Int();
                string errMsg     = string.Empty;
                List <MisModel.Product_WMS_Interface> d709fList = null; // 操作Dict709失败时的,缓存操作失败的行的列表
                HttpReqXmlBase  reqBody  = null;                        // HTTP请求XML
                HttpRespXmlBase respBody = null;                        // HTTP响应XML
                #endregion
                #region validate arguments
                if (TDict709_Value.ECancelReturnOrder != pMapClassId)
                {
                    pMsg = string.Format("不支持的单据类型, pMapClassId={0}", pMapClassId);
                    ret.Append(pMsg);
                    ret.End();
                    return(errCode);
                }
                // TODO: other arguments validations
                #endregion
                #region Update Dict[709]
                errCode = Dict709Handle.UpdateRowVA_Order(pMapClassId, moid, TDict285_Values.EDeleted, TDict285_Values.ENormal, out d709fList, out errDict709, out pMsg);
                if (TError.WCF_RunError.Int() == errCode)
                {
                    errMsg = string.Format("更新Dict[709]失败:errCode={0}, errDict709={1}, pMsg={2}", errCode, errDict709, pMsg);
                    ret.Append(string.Format("同步取消单据HTTP会话失败, {0}", errMsg));
                    ret.End();
                    return(errCode);
                }
                #endregion

                reqBody  = CWmsDataFactory.GetReqXmlBody_CancelOrder(Dict709Handle.Dict709ToMoc(pMapClassId), moid) as HttpReqXml_OrderCacnel; // get HTTP request body
                respBody = Post(reqBody);                                                                                                      // Do http transaction

                #region handle response
                if (null == pResp)
                {
                    pMsg    = "HTTP会话异常,HTTP响应体为null";
                    errCode = TError.WCF_RunError.Int();
                    ret.Append(string.Format("同步取消单据HTTP会话失败,系统异常:errCode={0}, message={1}", errCode, pMsg));
                }
                else if (!pResp.IsSuccess())
                {
                    pMsg    = pResp.ToString();
                    errCode = pResp.code.Int();
                    ret.Append(string.Format("同步取消单据HTTP会话失败,响应失败: errCode={0}, message={1}", errCode, pMsg));
                }
                else
                {
                    // update Dict[709]
                    errCode = Dict709Handle.UpdateRowVA_Order(pMapClassId, moid, TDict285_Values.EDeleted, TDict285_Values.ENormal, out d709fList, out errDict709, out pMsg);
                    ret.Append(string.Format("同步取消单据HTTP会话成功:{0}, {1}", errCode, pMsg));
                }
                #endregion

                ret.End();
                return(errCode);
            }
            catch (Exception ex)
            {
                pResp = null;
                pMsg  = ex.Message;

                if (null != ex.InnerException)
                {
                    ret.Append(string.Format("InnerException: {0}", ex.InnerException.Message));
                }
                ret.Append(string.Format("发生异常: {0}\r\n调用堆栈:{1}", ex.Message, ex.StackTrace));
                ret.End();
                return(TError.WCF_RunError.Int());
            }
        }