private void CallBack(Object stateObject)
        {
            if (ConstantValuePool.BizSettingConfig.telCallConfig.Enabled && ConstantValuePool.IsTelCallWorking)
            {
                if (ConstantValuePool.BizSettingConfig.telCallConfig.Model == 0 || ConstantValuePool.BizSettingConfig.telCallConfig.Model == 1)
                {
                    if (LDT.Check_State(ConstantValuePool.TelCallID) == 255)
                    {
                        string strPhoneNo = LDT.GetNumber_Tel(1).ToString();
                        if (strPhoneNo.Length > 0)
                        {
                            //创建通话记录
                            CallRecord callRecord = new CallRecord();
                            callRecord.CallRecordID = Guid.NewGuid();
                            callRecord.Telephone = strPhoneNo;
                            callRecord.CallTime = DateTime.Now;
                            callRecord.Status = 0;
                            CustomersService.GetInstance().CreateOrUpdateCallRecord(callRecord);

                            this.lbTelephone.Text = strPhoneNo;
                            this.txtCustomerName.Text = string.Empty;
                            this.txtAddress1.Text = string.Empty;
                            this.txtAddress2.Text = string.Empty;
                            this.txtAddress3.Text = string.Empty;
                            _customerInfo = CustomersService.GetInstance().GetCustomerInfoByPhone(strPhoneNo);
                            if (_customerInfo != null)
                            {
                                txtCustomerName.Text = _customerInfo.CustomerName;
                                txtAddress1.Text = _customerInfo.DeliveryAddress1;
                                txtAddress2.Text = _customerInfo.DeliveryAddress2;
                                txtAddress3.Text = _customerInfo.DeliveryAddress3;
                                if (_customerInfo.ActiveIndex == 1)
                                {
                                    ckAddress1.Checked = true;
                                }
                                else if (_customerInfo.ActiveIndex == 2)
                                {
                                    ckAddress2.Checked = true;
                                }
                                else if (_customerInfo.ActiveIndex == 3)
                                {
                                    ckAddress3.Checked = true;
                                }
                            }
                        }
                    }
                }
                if (ConstantValuePool.BizSettingConfig.telCallConfig.Model == 0)
                {
                    ConstantValuePool.IsTelCallWorking = LDT.Plugin_Tel(ConstantValuePool.TelCallID);
                }
            }
        }
 /// <summary>
 /// 创建或者更新电话记录
 /// </summary>
 /// <param name="callRecord">电话记录</param>
 /// <returns></returns>
 public bool CreateOrUpdateCallRecord(CallRecord callRecord)
 {
     bool result = false;
     try
     {
         _daoManager.OpenConnection();
         _customerOrderDao.CreateOrUpdateCallRecord(callRecord);
         result = true;
     }
     catch (Exception exception)
     {
         result = false;
         LogHelper.GetInstance().Error(string.Format("[CreateOrUpdateCallRecord]参数:callRecord_{0}", JsonConvert.SerializeObject(callRecord)), exception);
     }
     finally
     {
         _daoManager.CloseConnection();
     }
     return result;
 }
        /// <summary>
        /// 创建或者更新电话记录
        /// </summary>
        /// <param name="callRecord">电话记录</param>
        /// <returns></returns>
        public bool CreateOrUpdateCallRecord(CallRecord callRecord)
        {
            string json = JsonConvert.SerializeObject(callRecord);
            byte[] jsonByte = Encoding.UTF8.GetBytes(json);

            int cByte = ParamFieldLength.PACKAGE_HEAD + jsonByte.Length;
            byte[] sendByte = new byte[cByte];
            int byteOffset = 0;
            Array.Copy(BitConverter.GetBytes((int)Command.ID_CREATE_CALLRECORD), sendByte, BasicTypeLength.INT32);
            byteOffset = BasicTypeLength.INT32;
            Array.Copy(BitConverter.GetBytes(cByte), 0, sendByte, byteOffset, BasicTypeLength.INT32);
            byteOffset += BasicTypeLength.INT32;
            Array.Copy(jsonByte, 0, sendByte, byteOffset, jsonByte.Length);
            byteOffset += jsonByte.Length;

            bool result = false;
            using (SocketClient socket = new SocketClient(ConstantValuePool.BizSettingConfig.IPAddress, ConstantValuePool.BizSettingConfig.Port))
            {
                Byte[] receiveData = null;
                Int32 operCode = socket.SendReceive(sendByte, out receiveData);
                if (operCode == (int)RET_VALUE.SUCCEEDED)
                {
                    result = true;
                }
                socket.Close();
            }
            return result;
        }
Exemple #4
0
 private void DoWork()
 {
     if (ConstantValuePool.BizSettingConfig.telCallConfig.Enabled && ConstantValuePool.IsTelCallWorking)
     {
         while (true)
         {
             if (_currentFormActivate)
             {
                 if (ConstantValuePool.IsTelCallWorking)
                 {
                     if (ConstantValuePool.BizSettingConfig.telCallConfig.Model == 0 || ConstantValuePool.BizSettingConfig.telCallConfig.Model == 1)
                     {
                         if (LDT.Check_State(ConstantValuePool.TelCallID) == 255)
                         {
                             string strPhoneNo = LDT.GetNumber_Tel(1).ToString();
                             if (strPhoneNo.Length > 0)
                             {
                                 //创建通话记录
                                 CallRecord callRecord = new CallRecord();
                                 callRecord.CallRecordID = Guid.NewGuid();
                                 callRecord.Telephone = strPhoneNo;
                                 callRecord.CallTime = DateTime.Now;
                                 callRecord.Status = 0;
                                 CustomersService.GetInstance().CreateOrUpdateCallRecord(callRecord);
                                 //委托弹出窗口
                                 SetIncomingCall(strPhoneNo);
                             }
                         }
                     }
                 }
                 Thread.Sleep(100);
                 if (ConstantValuePool.BizSettingConfig.telCallConfig.Model == 0)
                 {
                     ConstantValuePool.IsTelCallWorking = LDT.Plugin_Tel(ConstantValuePool.TelCallID);
                 }
             }
             Thread.Sleep(500);
         }
     }
 }
 private void dgvCallRecord_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dgvCallRecord.CurrentRow != null)
     {
         int selectIndex = dgvCallRecord.CurrentRow.Index;
         telephone = dgvCallRecord.Rows[selectIndex].Cells[1].Value.ToString();
         const int status = 1; //已接来电
         CallRecord callRecord = new CallRecord
         {
             CallRecordID = new Guid(dgvCallRecord.Rows[selectIndex].Cells[4].Value.ToString()), 
             Status = status
         };
         CustomersService.GetInstance().CreateOrUpdateCallRecord(callRecord);
         this.Close();
     }
 }
 private void btnIgnore_Click(object sender, EventArgs e)
 {
     int status = 2; //忽略
     bool hasChange = false;
     foreach (DataGridViewRow dgvRow in dgvCallRecord.Rows)
     {
         if ((bool)dgvRow.Cells[0].Value)
         {
             CallRecord callRecord = new CallRecord();
             callRecord.CallRecordID = new Guid(dgvRow.Cells[4].Value.ToString());
             callRecord.Status = status;
             hasChange = CustomersService.GetInstance().CreateOrUpdateCallRecord(callRecord);
         }
     }
     if (hasChange)
     {
         status = 0; //未接来电
         IList<CallRecord> callRecordList = CustomersService.GetInstance().GetCallRecordByStatus(status);
         if (callRecordList != null && callRecordList.Count > 0)
         {
             dgvCallRecord.Rows.Clear();
             foreach (CallRecord item in callRecordList)
             {
                 int index = dgvCallRecord.Rows.Add();
                 dgvCallRecord.Rows[index].Cells[0].Value = false;
                 dgvCallRecord.Rows[index].Cells[1].Value = item.Telephone;
                 dgvCallRecord.Rows[index].Cells[2].Value = item.CustomerName;
                 dgvCallRecord.Rows[index].Cells[3].Value = item.CallTime.ToString("yyyy-MM-dd HH:mm");
                 dgvCallRecord.Rows[index].Cells[4].Value = item.CallRecordID;
             }
         }
     }
 }
 /// <summary>
 /// 创建或者更新电话记录
 /// </summary>
 /// <param name="callRecord">电话记录</param>
 /// <returns></returns>
 public bool CreateOrUpdateCallRecord(CallRecord callRecord)
 {
     int result = 0;
     result = ExecuteUpdate("CreateOrUpdateCallRecord", callRecord);
     return result > 0;
 }