using Newtonsoft.Json.Linq;

namespace MisDataSaveDate
{
    public class TCSAGV_TaskRequest
    {
        public string externalCode { get; set; }
        public string type { get; set; }
        public int priority { get; set; }
        public string param { get; set; }
        public string mcrgroup { get; set; }
        public string mcrip { get; set; }
        public string operatoruserid { get; set; }
    }

    public class TCSAGV_TaskStatusPushRequest
    {
        public string externalCode { get; set; }
        public string status { get; set; }
        public string ip { get; set; }
        public string type { get; set; }
        public string beginTime { get; set; }
        public string endTime { get; set; }
        public string remark { get; set; }
    }

    public class TCSAGV_PositionPushRequest
    {
        public string ip { get; set; }
        public string currentPos { get; set; }
        public string objectivePos { get; set; }
    }

    public class TCSAGV_StationDispatchRequest
    {
        public string stationCode { get; set; }
        public string actionType { get; set; }
        public string portCombination { get; set; }
        public string operatorCode { get; set; }
        public string parentExternalCode { get; set; }
    }

    public class TCSAGV_StepDispatchRequest
    {
        public string stationCode { get; set; }
        public string programName { get; set; }
        public string operatorCode { get; set; }
        public string parentExternalCode { get; set; }
    }

    public class TCSAGV_TaskOperationRequest
    {
        public string externalCode { get; set; }
        public string operatorCode { get; set; }
        public string remark { get; set; }
        public bool notifyPlc { get; set; }
    }

    public class TCSAGV_RobotOperationRequest
    {
        public string externalCode { get; set; }
        public string ip { get; set; }
        public string operatorCode { get; set; }
        public string remark { get; set; }
    }

    public class TCSAGV_Config
    {
        public string BaseUrl { get; set; }
        public bool Enabled { get; set; }
        public string McrGroup { get; set; }
        public string McrIp { get; set; }
        public string OperatorUserId { get; set; }
        public int DefaultPriority { get; set; }
        public int HttpTimeoutSeconds { get; set; }
    }

    public class TCSAGV_PointConfig
    {
        public string LineCode { get; set; }
        public string StationCode { get; set; }
        public string PositionName { get; set; }
        public string WorkStation { get; set; }
        public string InsertXsdProgram { get; set; }
        public string InsertXseProgram { get; set; }
        public string PullXsdProgram { get; set; }
        public string PullXseProgram { get; set; }
    }

    public class TCSAGV_CallResult
    {
        public bool Success { get; set; }
        public int Code { get; set; }
        public string Message { get; set; }
        public string ExternalCode { get; set; }
        public string RequestText { get; set; }
        public string ResponseText { get; set; }
        public JObject Response { get; set; }
    }

    public class TCSAGV_ApiResponse
    {
        public bool success { get; set; }
        public int code { get; set; }
        public string message { get; set; }
        public object data { get; set; }
        public long timestamp { get; set; }

        public static TCSAGV_ApiResponse Ok(string message, object data = null)
        {
            return new TCSAGV_ApiResponse
            {
                success = true,
                code = 200,
                message = message,
                data = data,
                timestamp = System.DateTimeOffset.Now.ToUnixTimeMilliseconds()
            };
        }

        public static TCSAGV_ApiResponse Fail(string message)
        {
            return new TCSAGV_ApiResponse
            {
                success = false,
                code = 500,
                message = message,
                data = null,
                timestamp = System.DateTimeOffset.Now.ToUnixTimeMilliseconds()
            };
        }
    }
}
