/// <summary> /// 将选定顾客转移给目标用户 /// </summary> /// <param name="vo"></param> /// <param name="token"></param> /// <returns></returns> public static void GraspCustomersFromPublic(GraspCustomerVo vo, String token) { RestClient rc = new RestClient(); var request = new RestRequest(GlobalConfig.GRASP_CUSTOMERS_FROM_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); } }
private void Grasp() { if (Global.CURRENT_PROJECT_ID.HasValue == false) { MessageBox.Show("您登录时未选择当前操作项目,所以不能抓取数据,请重新登录选择项目或者跟管理员确认您可以操作的项目"); return; } if (lvClients.CheckedIndices.Count < 1) { MessageBox.Show("请选择要抓取的记录然后在其前面打勾✔", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); lvClients.Focus(); return; } GraspCustomerVo vo = new GraspCustomerVo(); IList <String> customerIds = new List <String>(); foreach (ListViewItem lvi in lvClients.CheckedItems) { customerIds.Add(((CustomerDto)lvi.Tag).id); } if (DialogResult.Yes != MessageBox.Show("您确认要将选择的 " + customerIds.Count + " 个客户,加入到当前项目【" + Global.CURRENT_PROJECT_NAME + "】中进行跟进吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { return; } vo.customerIds = customerIds; vo.projectId = Global.CURRENT_PROJECT_ID.Value; try { CustomerService.GraspCustomersFromPublic(vo, Global.USER_TOKEN); foreach (ListViewItem lvi in lvClients.CheckedItems) { lvClients.Items.Remove(lvi); } } catch (BusinessException ex) { MessageBox.Show("抓取数据失败:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); lvClients.Focus(); return; } }