Exemplo n.º 1
0
        public void LoadUploadRecord()
        {
            Task.Factory.StartNew(() =>
            {
                SearchNotifyRequest request = new SearchNotifyRequest();
                string responseContent      = CoreHelper.DoPost(System.Configuration.ConfigurationManager.AppSettings["PolicyNotifyUrl"].ToString(), request);
                if (string.IsNullOrEmpty(responseContent))
                {
                    // MessageBox.Show("未找到任何上传记录");
                    return;
                }
                SearchNotifyResponse rep = JsonConvert.DeserializeObject <SearchNotifyResponse>(responseContent);
                if (rep.ErrCode == ResultType.Failed)
                {
                    // MessageBox.Show(rep.ErrMsg);
                    return;
                }
                DataTable dt = ListToDataTableWithRec(rep.NotifyList);
                ShowUploadRecord(dt);
                //this.Invoke(showUploadRecord, dt);

                //AddDataAction = new Action(() =>
                //{
                //this.dataGridView2.DataSource = dt;
                // });
            });
        }
        private bool SearchNotifyStatus(string uploadStatusId)
        {
            SearchNotifyRequest request = new SearchNotifyRequest()
            {
                UploadStatusId = uploadStatusId
            };
            string responseContent = CoreHelper.DoPost(System.Configuration.ConfigurationManager.AppSettings["PolicyNotifyUrl"].ToString(), request);

            SearchNotifyResponse rep = JsonConvert.DeserializeObject <SearchNotifyResponse>(responseContent);

            if (rep.ErrCode == ResultType.Failed)
            {
                return(true);
            }
            else
            {
                if (rep.NotifyList[0].NotifyResult == 1 || rep.NotifyList[0].NotifyResult == 2)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
        /// <summary>
        /// 查询回调结果
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public SearchNotifyResponse SearchNotifyList(SearchNotifyRequest request)
        {
            try
            {
                UpLoadRecordLib        recLib     = new UpLoadRecordLib();
                List <UpLoadRecordDto> notifyList = new List <UpLoadRecordDto>();
                if (!string.IsNullOrEmpty(request.UploadStatusId))
                {
                    UpLoadRecord rec = recLib.GetModel(int.Parse(request.UploadStatusId));
                    if (rec.NotifyResult <= 0)//不成功
                    {
                        return(new SearchNotifyResponse()
                        {
                            ErrCode = PolicyService.Enums.ResultType.Failed, ErrMsg = "未找到任何上传记录"
                        });
                    }
                    notifyList.Add(new UpLoadRecordDto
                    {
                        CompleteTime         = rec.CompleteTime,
                        CreateTime           = rec.CreateTime,
                        Id                   = rec.Id,
                        NotifyResult         = rec.NotifyResult,
                        IsEnabled            = rec.IsEnabled,
                        LastPolicyId         = rec.LastPolicyId,
                        LastUpdateTime       = rec.LastUpdateTime,
                        OperName             = rec.OperName,
                        PurchaserType        = rec.PurchaserType,
                        Remark               = rec.Remark,
                        RequestParams        = rec.RequestParams,
                        ResponseParams       = rec.ResponseParams,
                        UploadFilePath       = rec.UploadFilePath,
                        UploadType           = rec.UploadType,
                        Beforelastpolicyid   = rec.BeforeLastPolicyId,
                        Beforelastupdatetime = rec.BeforeLastUpdateTime,
                        Uploadcount          = rec.UploadCount,
                        Policytype           = rec.PolicyType
                    });
                }
                else
                {
                    string strSql = "";
                    if (request.IsSearchSystem)
                    {
                        strSql = " and OperName='system'";
                    }
                    List <UpLoadRecord> lstRecord = recLib.GetModelList("  CreateTime> '" + DateTime.Now.ToString("yyyy-MM-dd") + " 0:00:00" + "' and IsEnabled=1 " + strSql);
                    lstRecord.ForEach(x =>
                    {
                        notifyList.Add(new UpLoadRecordDto
                        {
                            CompleteTime         = x.CompleteTime,
                            CreateTime           = x.CreateTime,
                            Id                   = x.Id,
                            NotifyResult         = x.NotifyResult,
                            IsEnabled            = x.IsEnabled,
                            LastPolicyId         = x.LastPolicyId,
                            LastUpdateTime       = x.LastUpdateTime,
                            OperName             = x.OperName,
                            PurchaserType        = x.PurchaserType,
                            Remark               = x.Remark,
                            RequestParams        = x.RequestParams,
                            ResponseParams       = x.ResponseParams,
                            UploadFilePath       = x.UploadFilePath,
                            UploadType           = x.UploadType,
                            Beforelastpolicyid   = x.BeforeLastPolicyId,
                            Beforelastupdatetime = x.BeforeLastUpdateTime,
                            Uploadcount          = x.UploadCount,
                            Policytype           = x.PolicyType
                        });
                    });
                }

                return(new SearchNotifyResponse()
                {
                    ErrCode = PolicyService.Enums.ResultType.Sucess, ErrMsg = "", NotifyList = notifyList
                });
            }
            catch (Exception ex)
            {
                return(new SearchNotifyResponse()
                {
                    ErrCode = PolicyService.Enums.ResultType.Failed, ErrMsg = ex.Message
                });
            }
        }