示例#1
0
        /// <summary>
        /// 点名, 获取最新位置信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mnuRequest_Click(object sender, EventArgs e)
        {
            var selVehicle = GetSelectedVehicle();

            if (selVehicle == null)
            {
                return;
            }

            var task = Task.Factory.StartNew(() =>
            {
                var lastLocation = UrlApiHelper.GetLastLocation(selVehicle.TerminalId);
                if (lastLocation == null)
                {
                    GuiHelper.MsgBox("服务器连接异常...");
                }
                else if (lastLocation.Status != 0)
                {
                    GuiHelper.MsgBox("点名失败: " + lastLocation.Message);
                }
                else
                {
                    this.dgvVechiles.Invoke(new Action <JsonLastPosition>(AddVehicle), lastLocation);
                    mParent.LocatedVehicle(lastLocation);
                }
            });
        }
示例#2
0
        /// <summary>
        /// 自动点名工作线程
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bgkReport_DoWork(object sender, DoWorkEventArgs e)
        {
            while (!bgkReport.CancellationPending)
            {
                Thread.Sleep(500);
                Application.DoEvents();
                DateTime now = DateTime.Now;
                if ((now - mPrvReportTime).TotalSeconds < Settings.Default.AutoReportInterval)
                {
                    continue;
                }

                mPrvReportTime = now;
                var vehicles = (this.dgvVechiles.DataSource as List <JsonLastPosition>).ToArray();
                if (vehicles == null || vehicles.Length < 1)
                {
                    continue;
                }

                foreach (var vehicle in vehicles)
                {
                    if (bgkReport.CancellationPending)
                    {
                        // 系统取消退出
                        return;
                    }
                    var lastLocation = UrlApiHelper.GetLastLocation(vehicle.TerminalId);
                    if (lastLocation != null && lastLocation.Status == 0)
                    {
                        this.dgvVechiles.Invoke(new Action <JsonLastPosition>(AddVehicle), lastLocation);
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// 登陆验证后台工作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void loginWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            if (e.Argument is string[] loginArgs)
            {
                // FIXME: 目前是通过获取终端编号的位置信息模拟登陆过程, 后期将通过用户名密码验证API进行登陆
                string loginName = loginArgs[0];
                string loginPwd  = loginArgs[1];

                LastLocation = UrlApiHelper.GetLastLocation(loginName);
                if (LastLocation == null)
                {
                    worker.ReportProgress(-1, "服务器连接异常...");
                    return;
                }
                else if (LastLocation.Status != 0)
                {
                    worker.ReportProgress(-1, LastLocation.Message);
                    return;
                }

                // 登陆成功
                UpdateLoginProgress(50, "登陆成功, 正在载入界面...");
                mParentFrm.InvokeIfRequired(frm => frm.LoadUI());
                worker.ReportProgress(100);
            }
            else
            {
                // 失败
                worker.ReportProgress(-1, "参数错误");
            }
        }