using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RGDWCSServices.WCS
{
    public class packTask:HouseBase
    {
        /// <summary>
        /// 入参定义
        /// </summary>
        [Serializable]
        public class PARA
        {
            private string _task_no;
            private string _box_bar_code;

            public string TASK_NO
            {
                get { return this._task_no; }
                set { this._task_no = value; }
            }
            public string BOX_BAR_CODE
            {
                get { return this._box_bar_code; }
                set { this._box_bar_code = value; }
            }
        }

        /// <summary>
        /// 出参定义
        /// </summary>
        [Serializable]
        public class DATA : Base.OutPara
        {

        }
        /// <summary>
        /// 入参实体
        /// </summary>
        private PARA _inPara;

        /// <summary>
        /// 出参实体
        /// </summary>
        private DATA _outPara;

        /// <summary>
        /// 构造函数
        /// </summary>
        public packTask()
        {
            this._outPara = new DATA();
        }

        /// <summary>
        /// 通知
        /// </summary>
        /// <param name="sXmlIn">入参</param>
        /// <param name="sXmlOut">出参</param>
        /// <returns>执行结果</returns>
        public bool Notify(string sXmlIn, out string sXmlOut)
        {
            bool bResult = true;

            string sResult = string.Empty;

            sXmlOut = string.Empty;

            try
            {
                this._inPara = this.DeSerialize<PARA>(sXmlIn);

                bResult = null != this._inPara;

                if (!bResult)
                {
                    sResult = string.Format("入参错误（格式错误）");

                    return bResult;
                }

                bResult = this.PACKTASK(_inPara.TASK_NO,_inPara.BOX_BAR_CODE, out sResult);
            }
            catch (Exception ex)
            {
                bResult = false;

                sResult = string.Format(ex.Message);
            }
            finally
            {
                if (bResult)
                {
                    this._outPara.RESULT_FLAG = Enum.RESULT_FLAG.Success.ToString("d");
                }
                else
                {
                    this._outPara.RESULT_FLAG = Enum.RESULT_FLAG.Fail.ToString("d");
                }

                this._outPara.ERROR_INFO = sResult;

                sXmlOut = this.Serializer<DATA>(this._outPara);
            }

            return bResult;
        }
    }
}
