void RemoteDeskCheckTimerCallback(object state) { if (Interlocked.CompareExchange(ref _remoteDeskpCheckTimerCallbackState, 1, 1) == 1) { return; } try { bool started = AnyDesk.IsClientOpened(); if (_remoteDeskConnectState.TimerState == TimerState.CheckRemoteDeskConnectOpen) { if (started) { Invoke(() => { tsslRemoteConnectInfo.Text = string.Format("远程控制 [{0}] 中...", _remoteDeskConnectState.ConnectModel.UserAccount); tsslConnectStartTimeLabel.Visible = true; tsslConnectStartTime.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); tsslConnectStartTime.Visible = true; }); _remoteDeskConnectState.TimerState = TimerState.CheckRemoteDeskConnectClose; } return; } if (_remoteDeskConnectState.TimerState == TimerState.CheckRemoteDeskConnectClose) { if (!started) { _remoteDeskCheckTimer.Change(Timeout.Infinite, 2000); Invoke(() => { StartOrderRecord(); }); } return; } } catch (Exception ex) { Error("RemoteDeskCheckTimerCallback Error.", ex); } finally { Interlocked.Exchange(ref _remoteDeskpCheckTimerCallbackState, 0); } }
void SdgvOrderRecordListCellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 9) { var parent = FindForm() as ViewOptMain; if (parent == null) { return; } var row = SdgvOrderRecordList.Rows[e.RowIndex]; var value = row.Cells[9].FormattedValue.ToString(); if (string.Equals(value, "连接")) { if (parent.RemoteDeskConnectState.Connected) { MessageBoxEx.Show(this, "已经连接挂机端操作,不能同时进行多个连接操作!", "连接挂机端", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if ((bool)row.Cells[7].Value) { parent.RemoteDeskConnectState.Connected = true; var orcderRecord = row.DataBoundItem as OrderRecordDetails; parent.OnRemoteOperationRequest(new UserSubAccountPageListVM { UserId = orcderRecord.ClientUserId, Id = orcderRecord.ClientUserSubAccountId, UserAccount = orcderRecord.ClientUserAccount, TaoBaoAccount = orcderRecord.ClientUserSubAccount }, ConnectOptFrom.OrderRecorList); } else { MessageBoxEx.Show(this, "该挂机端不在线,不能连接!\r\n\r\n可尝试刷新挂机端信息后,再进行操作。", "连接挂机端", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else if (string.Equals(value, "已完结")) { MessageBoxEx.Show(this, "该刷单操作已完结,不能再进行操作。", "连接挂机端", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (AnyDesk.IsClientOpened()) { AnyDesk.CloseClient(); } parent.StartOrderRecord(); } } }
void Init() { SetToMax(); _orderRecordControl = new OrderRecordListControl(_shopBll, _orderStateBll); _orderRecordControl.Dock = DockStyle.Fill; tpShippingList.Controls.Add(_orderRecordControl); skinTabControl.SelectedIndexChanged += (sender, e) => { if (skinTabControl.SelectedIndex == 1 && !_remoteDeskConnectState.Connected) { LoadOrderRecordPageList(1, _orderRecordControl.PaginationOrderRecordList.PageSize); } }; _remoteDeskConnectState = new RemoteDeskConnectState(); _remoteDeskCheckTimer = new System.Threading.Timer( RemoteDeskCheckTimerCallback, null, Timeout.Infinite, 2000); sdgvSubAccountList.AutoGenerateColumns = false; sdgvSubAccountList.CellFormatting += (sender, e) => { switch (e.ColumnIndex) { case 1: string acc = e.Value as string; if (!string.IsNullOrEmpty(acc)) { int result; int markCount = Math.DivRem(acc.Length, 2, out result); if (result != 0) { markCount++; } var accArray = acc.ToCharArray(); for (int i = 1; i <= markCount; i += 1) { accArray[acc.Length - i] = '*'; } e.Value = new string(accArray); } break; case 2: byte?index = (byte?)e.Value; if (index.HasValue) { e.Value = ConstData.TaoBaoLevels[index.Value - 1].Name; } break; case 3: bool?sex = (bool?)e.Value; if (sex.HasValue) { e.Value = sex.Value ? "男" : "女"; } break; case 5: var data = sdgvSubAccountList.DataSource as IList <UserSubAccountPageListVM>; if (data != null && data.Count > e.RowIndex) { var vm = data[e.RowIndex]; e.Value = string.Format("{0} - {1} - {2}", vm.Province, vm.City, vm.District); } break; case 8: if ((bool)e.Value) { e.Value = "在线"; e.CellStyle.BackColor = Color.Green; e.CellStyle.SelectionBackColor = Color.Green; } else { e.Value = "离线"; e.CellStyle.BackColor = Color.Red; e.CellStyle.SelectionBackColor = Color.Red; } break; case 9: if (e.Value == null) { e.Value = "未连接"; } if (e.Value.ToString().Equals("正在连接")) { e.CellStyle.BackColor = Color.Yellow; e.CellStyle.SelectionBackColor = Color.Yellow; e.CellStyle.ForeColor = Color.Red; e.CellStyle.SelectionForeColor = Color.Red; } break; case 10: if (e.Value == null) { e.Value = "连接"; } break; case 11: int?dayCount = e.Value as int?; if (dayCount.HasValue && dayCount.Value >= 3) { e.CellStyle.BackColor = e.CellStyle.SelectionBackColor = Color.Red; } break; case 13: var orderTypeDetailsList = e.Value as IList <OrderTypeDetails>; if (orderTypeDetailsList != null && orderTypeDetailsList.Count > 0) { StringBuilder orderTypeSb = new StringBuilder(); foreach (var orderTypeDetails in orderTypeDetailsList) { orderTypeSb.AppendFormat("{0}({1}) ", orderTypeDetails.Name, orderTypeDetails.Count); } e.Value = orderTypeSb.ToString(); } else { e.Value = string.Empty; } break; } }; sdgvSubAccountList.CellContentClick += (sender, e) => { if (e.RowIndex == -1) { return; } if (e.ColumnIndex == 10) { var row = sdgvSubAccountList.Rows[e.RowIndex]; var value = row.Cells[e.ColumnIndex].FormattedValue.ToString(); if (string.Equals(value, "连接")) { if (_remoteDeskConnectState.Connected) { MessageBoxEx.Show(this, "已经连接挂机端操作,不能同时进行多个连接操作!", "连接挂机端", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //开始连接前,关闭所有连接窗口。 while (AnyDesk.IsClientOpened()) { AnyDesk.CloseClient(); } if ((bool)row.Cells[8].Value) { _remoteDeskConnectState.Connected = true; var view = _viewFactory.GetView <ViewReadyConnectClient>(); view.Model = row.DataBoundItem as UserSubAccountPageListVM; if (view.ShowDialog(this) != DialogResult.OK) { _remoteDeskConnectState.Connected = false; } } else { MessageBoxEx.Show(this, "该挂机端不在线,不能连接!\r\n\r\n可尝试刷新挂机端信息后,再进行操作。", "连接挂机端", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else { while (AnyDesk.IsClientOpened()) { AnyDesk.CloseClient(); } StartOrderRecord(); } } }; scbProvince.SelectedIndexChanged += (sender, e) => { if (scbProvince.SelectedIndex != -1) { var value = scbProvince.SelectedItem as Province; if (value.ProvinceID != -1) { scbCity.DisplayMember = "CityName"; scbCity.DataSource = _areaBll.GetCityList(value.ProvinceID); } else { scbCity.DataSource = null; scbDistrict.DataSource = null; } } else { scbCity.DataSource = null; scbDistrict.DataSource = null; } }; scbCity.SelectedIndexChanged += (sender, e) => { if (scbCity.SelectedIndex != -1) { var value = scbCity.SelectedItem as City; if (value.CityID != -1) { scbDistrict.DisplayMember = "DistrictName"; scbDistrict.DataSource = _areaBll.GetDistrictList(value.CityID); } else { scbDistrict.DataSource = null; } } else { scbDistrict.DataSource = null; } }; tsmiSubAccManage.Click += (sender, e) => { var view = _viewFactory.GetView <ViewSubAccountManage>(); view.ShowDialog(this); }; tsmiShopManage.Click += (sender, e) => { var view = _viewFactory.GetView <ViewShopManage>(); view.ShowDialog(this); }; tsmiAccountInfo.Click += (sender, e) => { var view = _viewFactory.GetView <ViewUserInfo>(); view.ShowDialog(this); }; tsmiChangePwd.Click += (sender, e) => { var view = _viewFactory.GetView <ViewChangePassword>(); view.ShowDialog(this); }; tsmiAbout.Click += (sender, e) => { var view = _viewFactory.GetView <ViewAbout>(); view.ShowDialog(this); }; paginationSubAccount.Reload += (sender, e) => { LoadSubAccountPageList( paginationSubAccount.PageIndex, paginationSubAccount.PageSize); }; sbtnSearch.Click += (sender, e) => { LoadSubAccountPageList( 1, paginationSubAccount.PageSize); }; }