Example #1
0
        public Tuple <bool, string, string> WriteBackResult(long taskID, XYKernel.OS.Common.Models.Mixed.Result.ResultAdjustmentModel resultAdjust)
        {
            var body = Newtonsoft.Json.JsonConvert.SerializeObject(new ResultMixed()
            {
                id = taskID, fruit = resultAdjust
            });
            var url = this.GetPostUrl(Method_WriteMixedResult, body);

            return(this.PostString(url, body));
        }
Example #2
0
        /// <summary>
        /// 回写走班结果
        /// </summary>
        /// <param name="taskID">任务ID</param>
        /// <param name="result">结果</param>
        /// <returns></returns>
        public Tuple <bool, string> WriteBackResult(long taskID, XYKernel.OS.Common.Models.Mixed.Result.ResultAdjustmentModel resultAdjust)
        {
            var body = Newtonsoft.Json.JsonConvert.SerializeObject(new ResultMixed()
            {
                id = taskID, fruit = resultAdjust
            });
            var postUrl = this.GetPostUrl(Method_WriteMixedResult, body);

            var response = _easyHttpClient.Post(postUrl, body, HttpContentTypes.ApplicationJson);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                var result = Newtonsoft.Json.JsonConvert.DeserializeObject <ResponseInfo>(response.RawText);
                if (result.code == 20000)
                {
                    return(Tuple.Create <bool, string>(true, result.result));
                }
                else
                {
                    List <MessageInfo> messageInfo;
                    try
                    {
                        messageInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <List <MessageInfo> >(result.msg);
                        StringBuilder stringBuilder = new StringBuilder();
                        messageInfo?.ForEach(mi =>
                        {
                            stringBuilder.AppendLine($"({mi.ErrorCode}){mi.Description}");
                        });
                        return(Tuple.Create <bool, string>(false, stringBuilder.ToString()));
                    }
                    catch
                    {
                        return(Tuple.Create <bool, string>(false, $"{result.msg}"));
                    }
                }
            }
            else
            {
                return(Tuple.Create <bool, string>(false, $"{response.StatusCode}-{response.StatusDescription}"));
            }
        }