Exemplo n.º 1
0
        /// <summary>
        /// 用户断连处理
        /// </summary>
        public void CustomerOnDisconnected(CustomerOnDisconnectedDto customerOnDisconnectedDto)
        {
            ServiceRecords ServiceRecordsModel = _serviceRecords.FirstOrDefault(e => e.Id == customerOnDisconnectedDto.ServiceRecordId);

            ServiceRecordsModel.CustomerUnContentDate = DateTime.Now;
            ServiceRecordsModel.CustomerState         = OrderInfo.LoginState.OffLine;
            _serviceRecords.Update(ServiceRecordsModel);

            CustomerConnectRecords CustomerConnectRecordsModel = _customerConnectRecords.FirstOrDefault(e => e.DeviceId == customerOnDisconnectedDto.DeviceId);

            CustomerConnectRecordsModel.CustomerState = OrderInfo.LoginState.OffLine;
            _customerConnectRecords.Update(CustomerConnectRecordsModel);

            ChatRecords ChatRecordsModel = new ChatRecords();

            ChatRecordsModel    = EntityHelper.CopyValue(ServiceRecordsModel, ChatRecordsModel);
            ChatRecordsModel.Id = 0;
            ChatRecordsModel.ServiceRecordsId = customerOnDisconnectedDto.ServiceRecordId;
            ChatRecordsModel.SendInfoType     = OrderInfo.SendInfoType.TextInfo;
            ChatRecordsModel.SendSource       = OrderInfo.TerminalRefer.system;
            ChatRecordsModel.SendContent      = "用户下线";
            ChatRecordsModel.SendDateTime     = DateTime.Now;
            ChatRecordsModel.ReceiveState     = OrderInfo.ReceiveState.Received;
            _chatRecords.Insert(ChatRecordsModel);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 客服断连处理
        /// </summary>
        public void ServicerOnDisconnected(ServicerOnDisconnectedDto servicerOnDisconnectedDto)
        {
            ServiceConnectRecords ServiceConnectRecordsModel = _serviceConnectRecords.FirstOrDefault(e => e.ServiceId == servicerOnDisconnectedDto.ServiceId);

            ServiceConnectRecordsModel.ServiceState = OrderInfo.LoginState.OffLine;
            _serviceConnectRecords.Update(ServiceConnectRecordsModel);

            List <ServiceRecords> ServiceRecordsList = _serviceRecords.GetAllList(e => e.ServiceId == servicerOnDisconnectedDto.ServiceId && e.ServiceState == OrderInfo.LoginState.Online);

            foreach (var item in ServiceRecordsList)
            {
                item.ServiceUnContentDate = DateTime.Now;
                item.ServiceState         = OrderInfo.LoginState.OffLine;
                _serviceRecords.Update(item);

                ChatRecords ChatRecordsModel = new ChatRecords();
                ChatRecordsModel    = EntityHelper.CopyValue(item, ChatRecordsModel);
                ChatRecordsModel.Id = 0;
                ChatRecordsModel.ServiceRecordsId = item.Id;
                ChatRecordsModel.SendInfoType     = OrderInfo.SendInfoType.TextInfo;
                ChatRecordsModel.SendSource       = OrderInfo.TerminalRefer.system;
                ChatRecordsModel.SendContent      = "客服下线";
                ChatRecordsModel.SendDateTime     = DateTime.Now;
                ChatRecordsModel.ReceiveState     = OrderInfo.ReceiveState.Received;
                _chatRecords.Insert(ChatRecordsModel);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 添加聊天记录
        /// </summary>
        /// <param name="addChatRecordsDto"></param>
        public BaseOutput AddChatRecords(AddChatRecordsDto addChatRecordsDto)
        {
            BaseOutput     output = new BaseOutput();
            ServiceRecords ServiceRecordsModel = _serviceRecords.GetAllList(e => e.ServiceId == addChatRecordsDto.ServicerId && e.CustomerDeviceId == addChatRecordsDto.CustomerDeviceId)
                                                 .OrderByDescending(e => e.CustomerContentDate).FirstOrDefault();
            ChatRecords ChatRecordsModel = new ChatRecords();

            ChatRecordsModel    = EntityHelper.CopyValue(ServiceRecordsModel, ChatRecordsModel);
            ChatRecordsModel.Id = 0;
            ChatRecordsModel.ServiceRecordsId = ServiceRecordsModel.Id;
            ChatRecordsModel.SendSource       = addChatRecordsDto.SendSource;
            ChatRecordsModel.SendDateTime     = DateTime.Now;
            ChatRecordsModel.SendContent      = addChatRecordsDto.SendContent;
            ChatRecordsModel.ReceiveState     = OrderInfo.ReceiveState.Received;
            _chatRecords.Insert(ChatRecordsModel);
            return(output);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 添加客户,并建立连接
        /// </summary>
        /// <param name="addCustomerConnectRecordsDto"></param>
        public BaseDataOutput <int> AddServiceConnectRecords(AddCustomerConnectRecordsDto addCustomerConnectRecordsDto)
        {
            BaseDataOutput <int> output          = new BaseDataOutput <int>();
            int         CustomerConnectRecordsId = 0;
            int         ServiceRecordsId         = 0;
            ChatRecords ChatRecordsModel         = new ChatRecords();
            //处理客户记录表
            CustomerConnectRecords CustomerConnectRecordsModel = _CustomerConnectRecords.FirstOrDefault(e => e.DeviceId == addCustomerConnectRecordsDto.DeviceId);

            if (CustomerConnectRecordsModel == null)
            {
                CustomerConnectRecords NewCustomerConnectRecordsModel = new CustomerConnectRecords();
                NewCustomerConnectRecordsModel = EntityHelper.CopyValue(addCustomerConnectRecordsDto, NewCustomerConnectRecordsModel);
                NewCustomerConnectRecordsModel.CustomerState = OrderInfo.LoginState.Online;
                CustomerConnectRecordsId = _CustomerConnectRecords.InsertAndGetId(NewCustomerConnectRecordsModel);
            }
            else
            {
                CustomerConnectRecordsModel.CustomerState = OrderInfo.LoginState.Online;
                _CustomerConnectRecords.Update(CustomerConnectRecordsModel);
                CustomerConnectRecordsId = CustomerConnectRecordsModel.Id;
            }
            //处理连接记录表
            ServiceRecords ServiceRecordsModel = new ServiceRecords();

            ServiceRecordsModel = EntityHelper.CopyValue(addCustomerConnectRecordsDto, ServiceRecordsModel);
            ServiceRecordsModel.CustomerDeviceId = addCustomerConnectRecordsDto.DeviceId;
            //连接记录表-处理客户信息
            ServiceRecordsModel.CustomerConnectRecordsId = CustomerConnectRecordsId;
            ServiceRecordsModel.CustomerContentDate      = DateTime.Now;
            ServiceRecordsModel.CustomerState            = OrderInfo.LoginState.Online;
            //连接记录表-如果匹配到客服,则处理客服信息
            if (addCustomerConnectRecordsDto.ServiceId != null)
            {
                ServiceConnectRecords ServiceConnectRecordsModel = _ServiceConnectRecords.FirstOrDefault(e => e.ServiceId == addCustomerConnectRecordsDto.ServiceId);
                if (ServiceConnectRecordsModel != null)
                {
                    //连接记录表-处理客服信息
                    ServiceRecordsModel    = EntityHelper.CopyValue(ServiceConnectRecordsModel, ServiceRecordsModel);
                    ServiceRecordsModel.Id = 0;
                    ServiceRecordsModel.ServiceConnectRecordsId = ServiceConnectRecordsModel.Id;
                    ServiceRecordsModel.ServiceId            = addCustomerConnectRecordsDto.ServiceId;
                    ServiceRecordsModel.ServiceContentDate   = DateTime.Now;
                    ServiceRecordsModel.ServiceState         = OrderInfo.LoginState.Online;
                    ServiceConnectRecordsModel.ServiceCount += 1;
                    _ServiceConnectRecords.Update(ServiceConnectRecordsModel);
                    //聊天记录表-处理客服信息
                    ChatRecordsModel           = EntityHelper.CopyValue(ServiceConnectRecordsModel, ChatRecordsModel);
                    ChatRecordsModel.ServiceId = addCustomerConnectRecordsDto.ServiceId;
                }
            }
            ServiceRecordsId = _ServiceRecords.InsertAndGetId(ServiceRecordsModel);
            //聊天记录表-处理客户信息
            ChatRecordsModel    = EntityHelper.CopyValue(addCustomerConnectRecordsDto, ChatRecordsModel);
            ChatRecordsModel.Id = 0;
            ChatRecordsModel.CustomerDeviceId = addCustomerConnectRecordsDto.DeviceId;
            //聊天记录表-处理聊天信息
            ChatRecordsModel.ServiceRecordsId = ServiceRecordsId;
            ChatRecordsModel.SendInfoType     = OrderInfo.SendInfoType.TextInfo;
            ChatRecordsModel.SendSource       = OrderInfo.TerminalRefer.system;
            ChatRecordsModel.SendContent      = "客服[" + ChatRecordsModel.ServiceNickName + "]为您服务";
            ChatRecordsModel.SendDateTime     = DateTime.Now;
            ChatRecordsModel.ReceiveState     = OrderInfo.ReceiveState.Received;
            _ChatRecords.Insert(ChatRecordsModel);
            output.Data = ServiceRecordsId;
            return(output);
        }