//------------------------------------------------------------------------------- public void SetAgentBusy(Int32 agentId, bool busy) { PoolDS.PoolDSDataTable dtPool = BllProxyPool.SelectPoolAgent(agentId); if (dtPool.Rows.Count != 0) { bool isBusy = busy; if (!isBusy) { IncidentDS.IncidentDSDataTable dtIncident = BllProxyIncident.GetIncidentsByStatus(2, agentId); //2:In-Progress if (dtIncident.Rows.Count != 0) { isBusy = true; } } if (isBusy) { BllProxyPool.SetPoolAgentBusy(agentId, true); } else { BllProxyPool.SetPoolAgentBusy(agentId, busy); } BllProxyPool.SetPoolAgentIncident(agentId, 0); } }
/// <summary> /// Clear the Incident's ReservedAgent and Disable Agent not taking the call /// </summary> /// <param name="dtAllPoolAgents"></param> /// <returns></returns> protected bool checkReservations(PoolDS.PoolDSDataTable dtAllPoolAgents) { bool result = false; PoolDS.PoolDSRow[] rows = (PoolDS.PoolDSRow[])dtAllPoolAgents.Select("is_available=1 and is_busy=0", ""); if (rows.Length > 0) { int cancelInterval = UcConfParameters.UcCallForwardingInterval; // seconds foreach (PoolDS.PoolDSRow row in dtAllPoolAgents.Rows) { if ((!row.Isincident_idNull()) && (!row.Isdate_reservedNull())) { DateTime now = DateTime.Now.ToUniversalTime(); TimeSpan span = now.Subtract(row.date_reserved); TimeSpan max = new TimeSpan(0, 0, cancelInterval); if (TimeSpan.Compare(span, max) > 0) { Int32 incidentId = row.incident_id; Int32 incidentStatusId = 0; Int32 incidentAgentId = 0; IncidentDS.IncidentDSDataTable dtIncident = BllProxyIncident.SelectIncident(incidentId); if (dtIncident.Rows.Count > 0) { incidentStatusId = dtIncident[0].status_id; if (!dtIncident[0].Isagent_idNull()) { incidentAgentId = dtIncident[0].agent_id; } } if (incidentAgentId == 0) { if (incidentStatusId == 1) { BllProxyIncidentHelper.SetIncidentReservation(incidentId, 0); BllProxyPool.SetPoolAgentAvailable(row.agent_id, false); BllProxyPool.SetPoolAgentBusy(row.agent_id, false); } else { BllProxyPool.SetPoolAgentAvailable(row.agent_id, true); BllProxyPool.SetPoolAgentBusy(row.agent_id, true); } } result = true; } } } } return(result); }
/// <summary> /// Disable the Agent if not online (Agent in AgentPool is not renewed for too long) /// Remove the Agent from AgentPool if not online for a week /// </summary> /// <param name="dtAllPoolAgents"></param> /// <returns></returns> protected bool cleanUp(PoolDS.PoolDSDataTable dtAllPoolAgents) { bool result = false; int cleanUpInterval = UcConfParameters.UcCallCleanUpInterval; foreach (PoolDS.PoolDSRow row in dtAllPoolAgents.Rows) { Int32 agentId = row.agent_id; DateTime now = DateTime.Now.ToUniversalTime(); TimeSpan span = now.Subtract(row.date_accessed); TimeSpan max; if (row.is_available) { // Disable the Agent if not online (Agent in AgentPool is not renewed for too long) max = new TimeSpan(0, 0, cleanUpInterval); // seconds if (TimeSpan.Compare(span, max) > 0) { BllProxyPool.SetPoolAgentAvailable(agentId, false); result = true; } // Clean up the Agent's Incident and turn Agent available if the Incident is gone if (!row.Isincident_idNull()) { IncidentDS.IncidentDSDataTable dtIncident = BllProxyIncident.SelectIncident(row.incident_id); if (dtIncident.Rows.Count > 0) { //if ((dtIncident[0].status_id != 1) || (dtIncident[0].agent_id != agentId)) if ((dtIncident[0].status_id != 1) || ((!dtIncident[0].Isagent_idNull()) && (dtIncident[0].agent_id != agentId))) { BllProxyPool.SetPoolAgentIncident(agentId, 0); BllProxyPool.SetPoolAgentBusy(agentId, false); result = true; } } } } else { // Remove the Agent from AgentPool if not online for a week max = new TimeSpan(7, 0, 0, 0); // 7 days if (TimeSpan.Compare(span, max) > 0) { BllProxyPool.DeletePoolAgent(agentId); result = true; } } } return(result); }
private static PoolDS.PoolDSDataTable processData(PoolDS.PoolDSDataTable dt) { foreach (PoolDS.PoolDSRow row in dt.Rows) { row.agent_full_name = Helper.GetFullName(row.agent_first_name, row.agent_last_name); } return(dt); }
//------------------------------------------------------------------------------- public void RegisterAgent(Int32 agentId) { if (agentId != 0) { PoolDS.PoolDSDataTable dt = BllProxyPool.SelectPoolAgent(agentId); if (dt.Rows.Count == 0) { BllProxyPool.InsertPoolAgent(agentId); } } }
//------------------------------------------------------------------------------- public void ReleaseIncident(Int32 incidentId) { PoolDS.PoolDSDataTable dt = BllProxyPool.GetAllPoolAgents(); foreach (PoolDS.PoolDSRow row in dt.Rows) { if (!dt[0].Isincident_idNull()) { if (row.incident_id == incidentId) { BllProxyPool.SetPoolAgentIncident(row.agent_id, 0); } } } }
//------------------------------------------------------------------------------- public Int32 GetAgentIncident(Int32 agentId) { Int32 incidentId = 0; PoolDS.PoolDSDataTable dt = BllProxyPool.SelectPoolAgent(agentId); if (dt.Rows.Count != 0) { if (!dt[0].Isincident_idNull()) { incidentId = dt[0].incident_id; } } return(incidentId); }
/// <summary> /// Assign the Incident to the available Agent /// </summary> /// <param name="dtAllPoolAgents"></param> /// <returns></returns> protected bool handleIncidentQueue(PoolDS.PoolDSDataTable dtAllPoolAgents) { bool result = false; IncidentDS.IncidentDSDataTable dt; PoolDS.PoolDSRow[] rows = (PoolDS.PoolDSRow[])dtAllPoolAgents.Select("", "last_call_time"); foreach (PoolDS.PoolDSRow row in rows) { Int32 agentId = row.agent_id; if ((row.is_available) && (!row.is_busy)) { dt = BllProxyIncident.GetIncidentQueueList(1, agentId); //1:New foreach (IncidentDS.IncidentDSRow rowIncident in dt) { if (rowIncident.Isreserved_agent_idNull()) { Int32 incidentId = rowIncident.incident_id; BllProxyIncidentHelper.SetIncidentReservation(incidentId, agentId); BllProxyPool.SetPoolAgentBusy(agentId, true); BllProxyPool.SetPoolAgentIncident(agentId, incidentId); result = true; break; } //--- } } } return(result); }
public void DoRoutine() { try { PoolDS.PoolDSDataTable dtAllPoolAgents = BllProxyPool.GetAllPoolAgents(); cancelObsoleteIncidents(); if (this.cleanUp(dtAllPoolAgents)) { dtAllPoolAgents = BllProxyPool.GetAllPoolAgents(); } if (this.checkReservations(dtAllPoolAgents)) { dtAllPoolAgents = BllProxyPool.GetAllPoolAgents(); } this.handleIncidentQueue(dtAllPoolAgents); } catch { } }
public bool Update() { PoolDS.PoolDSDataTable dt = BllProxyPool.GetAllPoolAgents(); PoolDS.PoolDSRow[] rows = (PoolDS.PoolDSRow[])dt.Select("", "agent_full_name"); rptAgentPool.DataSource = rows; rptAgentPool.DataBind(); foreach (RepeaterItem item in rptAgentPool.Items) { UcGroupRadioButton ucGroupRadioButton = (UcGroupRadioButton)item.FindControl("ucGroupRadioButton"); if (ucGroupRadioButton != null) { ucGroupRadioButton.Checked = false; HiddenField hfAgentId = (HiddenField)item.FindControl("hfAgentId"); if (hfAgentId != null) { Int32 id = Convert.ToInt32(hfAgentId.Value); if (id == this.selectedAgentId) { ucGroupRadioButton.Checked = true; } } } } upWork.Update(); return(true); }
public static PoolDS.PoolDSDataTable SelectPoolAgent(Int32 agentId) { PoolDS.PoolDSDataTable dt = DalPool.SelectPoolAgent(agentId); return(processData(dt)); }
public static PoolDS.PoolDSDataTable GetAllPoolAgents() { PoolDS.PoolDSDataTable dt = DalPool.GetAllPoolAgents(); return(processData(dt)); }
protected enumAgentStatus updateAgentStatus() { enumAgentStatus agentStatus = enumAgentStatus.NotDefined; if (this.active) { pnlNotRegistered.Visible = false; pnlIncomingCall.Visible = false; pnlUnavailable.Visible = false; pnlBusy.Visible = false; pnlConnected.Visible = false; pnlAvailable.Visible = false; btnRegister.Visible = false; btnTakeCall.Visible = false; btnSetAvailable.Visible = false; btnReset.Visible = false; btnUnRegister.Visible = false; if (agentId == 0) { // Not Defined agentStatus = enumAgentStatus.NotDefined; pnlNotRegistered.Visible = true; ltMessage.Text = "Not registered"; btnRegister.Visible = true; } else { PoolDS.PoolDSDataTable dt = BllProxyPool.SelectPoolAgent(agentId); if (dt.Rows.Count != 0) { if (dt[0].is_available) { if (dt[0].is_busy) { if (!dt[0].Isincident_idNull()) { // Incoming Call agentStatus = enumAgentStatus.IncomingCall; Int32 incidentId = dt[0].incident_id; IncidentDS.IncidentDSDataTable dtIncident = BllProxyIncident.SelectIncident(incidentId); string callName = ""; if (!dtIncident[0].Isfacility_nameNull()) { callName = dtIncident[0].facility_name; } else { if (!dtIncident[0].Iscontact_full_nameNull()) { callName = dtIncident[0].contact_full_name; } else { callName = "UNKNOWN"; } } // Incident Assigned pnlIncomingCall.Visible = true; ltMessage.Text = "You’ve got a call : " + callName; btnTakeCall.Visible = true; } else { // Busy agentStatus = enumAgentStatus.Busy; if (this.checkOnline()) { pnlConnected.Visible = true; pnlBusy.Visible = false; ltMessage.Text = "Online"; } else { pnlBusy.Visible = true; pnlConnected.Visible = false; ltMessage.Text = "Offline"; btnReset.Visible = true; } } } else { // Available agentStatus = enumAgentStatus.Available; pnlAvailable.Visible = true; ltMessage.Text = "Available"; btnUnRegister.Visible = true; } } else { // Off agentStatus = enumAgentStatus.Unavailable; if (this.checkOnline()) { pnlConnected.Visible = true; ltMessage.Text = "Online"; } else { pnlUnavailable.Visible = true; ltMessage.Text = "Unavailable"; btnSetAvailable.Visible = true; } } } else { // Not Defined agentStatus = enumAgentStatus.NotDefined; pnlNotRegistered.Visible = true; ltMessage.Text = "Not registered"; btnRegister.Visible = true; } } } return(agentStatus); }