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

namespace Pms.WebHandle
{

    class SKWMSWebServiceHelper
    {
        public static string addressWebsite = UriSetting.g_WMSUri;//"http://127.0.0.1:8634/casunsystem/"
        static RestRequestHelper requestHelperForClient = new RestRequestHelper(addressWebsite);
        public static string AddOrder(int unionlockid, int occupidway, int carrier, string timestamp)
        {
            //UnionLockRequestInfo registerNewLockerRequest = new UnionLockRequestInfo();
            //registerNewLockerRequest.OccupiedWay = occupidway;
            //registerNewLockerRequest.CarrierID = carrier;
            //registerNewLockerRequest.UnionLockID = unionlockid; ;
            //registerNewLockerRequest.Timestamp = timestamp;
            string strJsonRequest = "";
            string subUri = string.Format("traffic/unionlockrequest?arg={0}", strJsonRequest);
            string uri = string.Format("{0}/{1}", addressWebsite, subUri);
            string strBeforeDecrypt = requestHelperForClient.Post("", uri);
            return strBeforeDecrypt;
        }

        /// <summary>
        /// 对应接口编号005
        /// </summary>
        /// <returns></returns>
        public static TCLClientDownPositionRequestFeedBack ApplyDownPosition(TCLClientDownPositionRequest downPositionRequest)
        {
            string data = JsonHelper.ConvertToJson(typeof(TCLClientDownPositionRequest), downPositionRequest);
            string uri = "AGVSGetStoageInfo";
            string strBeforeDecrypt = requestHelperForClient.PostWithWholeURI(data, UriSetting.g_WMSUri + "/" + uri, true);
            //TextDocument.WriteFile(@"PMS/Log","位置信息同步", "返回:" + strBeforeDecrypt);
            TCLClientDownPositionRequestFeedBack returnValue = (TCLClientDownPositionRequestFeedBack)JsonHelper.ConvertToObject(typeof(TCLClientDownPositionRequestFeedBack), strBeforeDecrypt);
            return returnValue;
        }

        /// <summary>
        /// 对应接口编号006
        /// </summary>
        /// <returns></returns>
        public static TCLClientOrderCompletedFeedBack ReportOrderFinshed(TCLClientOrderCompleted orderCompleted)
        {
            string data = JsonHelper.ConvertToJson(typeof(TCLClientOrderCompleted), orderCompleted);
            string uri = "AGVSMatTakeOn";
            string strBeforeDecrypt = requestHelperForClient.PostWithWholeURI(data, UriSetting.g_WMSUri + "/"+uri,true);
            //TextDocument.WriteFile(@"PMS/Log","位置信息同步", "返回:" + strBeforeDecrypt);
            TCLClientOrderCompletedFeedBack returnValue = (TCLClientOrderCompletedFeedBack)JsonHelper.ConvertToObject(typeof(TCLClientOrderCompletedFeedBack), strBeforeDecrypt);
            return returnValue;
        }
    }
}

