示例#1
0
        /// <summary>
        /// 扔回公海
        /// </summary>
        /// <param name="vo"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static void ReturnCustomersToPublic(ReturnCustomersToPublic vo, String token)
        {
            RestClient rc      = new RestClient();
            var        request = new RestRequest(GlobalConfig.CUSTOER_RETURN_PUBLIC);

            request.AddHeader(GlobalConfig.AUTHORIZATION, token);
            request.AddJsonBody(vo);
            IRestResponse response;

            try
            {
                response = rc.Execute(request, Method.PATCH);
            }
            catch (Exception ex)
            {
                throw new BusinessException(ex.Message);
            }
            if (response.StatusCode == 0)
            {
                throw new BusinessException("请检查网络");
            }
            if (response.StatusCode != HttpStatusCode.NoContent)
            {
                var res             = rc.Deserialize <CustomException>(response);
                var customException = res.Data;
                throw new BusinessException(customException.message);
            }
        }
示例#2
0
        private void ReturnCustomersToPublic()
        {
            if (lvClients.CheckedIndices.Count < 1)
            {
                MessageBox.Show("请先选择用户,在用户记录前面打勾✔", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (MessageBox.Show("您确认要将选中的用户放回公海吗?数据数量:" + lvClients.CheckedItems.Count, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }
            ReturnCustomersToPublic vo = new ReturnCustomersToPublic
            {
                customerIds = new List <String>()
            };

            foreach (ListViewItem lvi in lvClients.CheckedItems)
            {
                CustomerDto customer = (CustomerDto)lvi.Tag;
                vo.customerIds.Add(customer.id);
            }
            try
            {
                CustomerService.ReturnCustomersToPublic(vo, Global.USER_TOKEN);
                Query();
            }
            catch (BusinessException ex)
            {
                MessageBox.Show("将选定客户扔回公海时发生错误:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
                lvClients.Focus();
            }
            foreach (ListViewItem lvi in lvClients.CheckedItems)
            {
                lvClients.Items.Remove(lvi);
            }
        }