private void gridView1_DoubleClick(object sender, System.EventArgs e)
 {
     if (gridView_Command.FocusedRowHandle > 0)
     {
         T_TaxiOperation_SendCommand item       = (T_TaxiOperation_SendCommand)gridView_Command.GetFocusedRow();
         List <T_TaxiOperation>      lstCuocgoi = T_TaxiOperation.Inst.GetByID(item.IdCuocGoi);
         if (lstCuocgoi != null && lstCuocgoi.Count > 0)
         {
             grid_CuocGoi.DataSource = lstCuocgoi;
         }
         else
         {
             grid_CuocGoi.DataSource = new T_TaxiOperation();
         }
     }
 }
Example #2
0
        /// <summary>
        /// Gửi lệnh cho lái xe bằng biển số.
        /// </summary>
        /// <param name="privateCode">Số hiệu xe</param>
        /// <param name="Text">Lệnh gửi lái xe</param>
        /// <param name="BookId">BookId</param>
        /// <param name="idCuocGoi">ID Cuộc gọi</param>
        /// <param name="userId">nhân viên gửi Lệnh</param>
        /// <param name="cmdId">Mã Lệnh</param>
        /// <param name="result">Driver Command gửi lên từ lái xe, tới điều hành là gửi ACKDriver Command
        /// Để xác nhận lệnh từ lái xe đã tới điều hành.
        /// Vì thế để biết ĐH xử lý thế nào thì gửi OperatorCmd result là true: false
        /// Ví dụ: lái xe xin số, điều hành gửi về result:false => ko được, true: có được xem số</param>
        public static void SendText(string privateCode, string Text, Guid BookId, long idCuocGoi, string userId, bool isContract, int cmdId = 0, bool result = true)
        {
            try
            {
                //LogError.WriteLogInfo(string.Format("SendText:{0}" , Text));
                var Content = new SendTextContext
                {
                    VehiclePlate = CommonBL.ConvertSangBienSo(privateCode),
                    TextCommand  = Text,
                    CmdId        = cmdId,
                    BookId       = BookId,
                    Result       = result
                };
                if (Content.VehiclePlate != "")
                {
                    //Nếu là xe Car thì gửi cho bên Car
                    if (CommonBL.DictDriver.ContainsKey(privateCode))
                    {
                        if (CommonBL.DictDriver[privateCode].SystemType == Enum_SystemType.Car)
                        {
                            isContract = true;
                        }
                    }
                    Task.Factory.StartNew(() =>
                    {
                        if (isContract)
                        {
                            if (Content.CmdId == 0)
                            {
                                return(WCFServicesAppXHD.SendText(Content.VehiclePlate, Content.TextCommand, Content.BookId));
                            }
                            else
                            {
                                return(WCFServicesAppXHD.SendOperatorCmd(Content.VehiclePlate, Content.BookId, Content.CmdId, Content.TextCommand, Content.Result));
                            }
                        }
                        else
                        {
                            if (Content.CmdId == 0)
                            {
                                return(WCFServicesApp.SendText(Content.VehiclePlate, Content.TextCommand, Content.BookId));
                            }
                            else
                            {
                                return(WCFServicesApp.SendOperatorCmd(Content.VehiclePlate, Content.BookId, Content.CmdId, Content.TextCommand, Content.Result));
                            }
                        }
                    }).ContinueWith(x =>
                    {
                        if (x.Result == false)
                        {
                            if (MessageBox.Show("Lỗi gửi lệnh cho lái xe, Vui lòng gửi lại", "Thông báo",
                                                MessageBoxButtons.RetryCancel,
                                                MessageBoxIcon.Warning,
                                                MessageBoxDefaultButton.Button1) == DialogResult.Retry)
                            {
                                SendText(privateCode, Text, BookId, idCuocGoi, userId, isContract, cmdId, Content.Result);
                            }
                        }
                    });

                    var history = new T_TaxiOperation_SendCommand()
                    {
                        BookId      = Content.BookId,
                        CommandID   = Content.CmdId,
                        CommandText = Content.TextCommand,
                        CreatedBy   = userId,
                        IdCuocGoi   = idCuocGoi,
                        PrivateCode = privateCode,
                        Result      = false
                    };
                    history.Insert();
                }
            }
            catch (Exception ex)
            {
                if (MessageBox.Show("Lỗi gửi lệnh cho lái xe, Vui lòng gửi lại", "Thông báo", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) == DialogResult.Retry)
                {
                    SendText(privateCode, Text, BookId, idCuocGoi, userId, isContract, cmdId = 0, result);
                }
                LogError.WriteLogError("SendText:", ex);
            }
        }