public Child AdvisorReady(Guid advisorID) { if (advisors.ContainsKey(advisorID)) { m_isQueueOpen = true; lock (advisors) { var advisor = advisors[advisorID]; advisor.Messages.Clear(); advisor.LastUpdate = DateTime.Now; if (advisor.Child != null && advisor.Child.Value != Guid.Empty) { return(children[advisor.Child.Value]); } for (int i = 0; i < children.Count; i++) { var child = children.ElementAt(i); if (!child.Value.Advisor.HasValue) { advisor.Child = child.Key; child.Value.Advisor = advisorID; DateTime received = DateTime.Now; advisor.Messages.Add(new Message() { ID = advisor.Messages.Count, From = Guid.Empty, Received = received, MessageType = eMessageType.Binding, Status = eStatus.Ready, Text = Advisor.Binding(child.Value) }); child.Value.Messages.Add(new Message() { ID = child.Value.Messages.Count, From = Guid.Empty, Received = received, MessageType = eMessageType.Binding, Status = eStatus.Ready, Text = Child.Binding(advisor) }); return(child.Value); } } } } return(null); }
public void AdvisorLeave(Guid advisorID, eAdvisorStatus status) { if (advisors.ContainsKey(advisorID)) { var advisor = advisors[advisorID]; var childId = advisor.Child; var text = Advisor.StatusText(advisor.Name == advisorID.ToString() ? "Advisor" : advisor.Name, status); if (childId.HasValue && children.ContainsKey(childId.Value)) { AdvisorSay(advisorID, text, eMessageType.Leave); children[childId.Value].Advisor = null; } advisors.Remove(advisorID); } if (advisors.Count == 0) { m_isQueueOpen = false; } }
public static string Binding(Advisor value) { return(value.AdvisorID.ToString() == value.Name ? "Advisor ready to chat" : string.Format("{0} is ready to chat with you", value.Name)); }
public static string Binding(Advisor value) { return value.AdvisorID.ToString() == value.Name ? "Advisor ready to chat" : string.Format("{0} is ready to chat with you", value.Name); }