Ejemplo n.º 1
0
        public Tuple <bool, string, string> WriteBackResult(long taskID, XYKernel.OS.Common.Models.Administrative.Result.ResultAdjustmentModel resultAdjust)
        {
            var body = Newtonsoft.Json.JsonConvert.SerializeObject(new ResultAdministrative()
            {
                id = taskID, fruit = resultAdjust
            });
            var url = this.GetPostUrl(Method_WriteAdminResult, body);

            return(this.PostString(url, body));
        }
Ejemplo n.º 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.Administrative.Result.ResultAdjustmentModel resultAdjust)
        {
            var body = Newtonsoft.Json.JsonConvert.SerializeObject(new ResultAdministrative()
            {
                id = taskID, fruit = resultAdjust
            });
            var postUrl = this.GetPostUrl(Method_WriteAdminResult, 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.code}-{result.msg}"));
                    }
                }
            }
            else
            {
                return(Tuple.Create <bool, string>(false, $"{response.StatusCode}-{response.StatusDescription}"));
            }
        }