private void SetInteractionQueue() { if (InteractionQueue == null) { InteractionQueue = new InteractionQueue(InteractionsManager.GetInstance(Session), new QueueId(QueueType.MyInteractions, Session.UserId)); } InteractionQueue.InteractionAdded += InteractionQueueInteractionAdded; InteractionQueue.InteractionChanged += InteractionQueueInteractionChanged; InteractionQueue.InteractionRemoved += InteractionQueueInteractionRemoved; InteractionQueue.ConferenceInteractionAdded += InteractionQueueConferenceInteractionAdded; InteractionQueue.ConferenceInteractionChanged += InteractionQueueConferenceInteractionChanged; InteractionQueue.ConferenceInteractionRemoved += InteractionQueueConferenceInteractionRemoved; List <string> RequiredAttributes = new List <string>(); RequiredAttributes.Add(InteractionAttributeName.CallIdKey.ToString()); RequiredAttributes.Add(InteractionAttributeName.RemoteName.ToString()); RequiredAttributes.Add(InteractionAttributeName.RemoteAddress.ToString()); RequiredAttributes.Add(InteractionAttributeName.State.ToString()); //RequiredAttributes.Add(InteractionAttributeName.SupervisorRecorders.ToString()); //RequiredAttributes.Add(InteractionAttributeName.Recorders.ToString()); RequiredAttributes.Add(InteractionAttributeName.Muted.ToString()); InteractionQueue.StartWatchingAsync(RequiredAttributes.ToArray(), UpdateInteractionList, null); }
public static bool HasInteraction <T>(Sim sim) { if (sim == null) { return(false); } InteractionQueue queue = sim.InteractionQueue; if (queue == null) { return(false); } foreach (InteractionInstance instance in queue.mRunningInteractions) { if ((instance is T) || (instance.InteractionDefinition is T)) { return(true); } } foreach (InteractionInstance instance2 in queue.mInteractionList) { if ((instance2 is T) || (instance2.InteractionDefinition is T)) { return(true); } } return(false); }
public void DisconnectInteraction(string InteractionID) { foreach (Interaction i in InteractionQueue.GetContents()) { if (i.InteractionId.ToString() == InteractionID.Substring(0, 10)) { i.Disconnect(); } } }
public void HoldInteraction(string InteractionID) { foreach (Interaction i in InteractionQueue.GetContents()) { if (i.InteractionId.ToString() == InteractionID.Substring(0, 10)) { if (i.IsConnected || i.IsHeld) { i.Hold(!i.IsHeld); } } } }
public void AnswerInteraction(string InteractionID) { foreach (Interaction i in InteractionQueue.GetContents()) { if (i.InteractionId.ToString() == InteractionID.Substring(0, 10)) { if (!i.IsConnected) { i.Pickup(); } } } }
public void MuteInteraction(string InteractionID) { foreach (Interaction i in InteractionQueue.GetContents()) { if (i.InteractionId.ToString() == InteractionID.Substring(0, 10)) { if (i.IsConnected) { } } i.Mute(!i.IsMuted); } }
private static bool IsCheckKillSimInteraction(Sim sim) { if (sim == null || Urnstone.KillSim.Singleton == null) { return(false); } InteractionQueue intt = sim.InteractionQueue; if (intt == null || intt.mInteractionList == null) { return(false); } Type typeKillSim = Urnstone.KillSim.Singleton.GetType(); Type typeSocialInteractionB = typeof(SocialInteractionB.DefinitionDeathInteraction); foreach (InteractionInstance item in intt.mInteractionList) { if (item != null && item.InteractionDefinition != null) { Type tf2 = item.InteractionDefinition.GetType(); if (tf2 == typeSocialInteractionB) { return(true); } if (tf2 == typeKillSim) { return(true); } } } Type typeCacheNiecModSocial = typeof(NiecMod.KillNiec.KillSimNiecX.NiecDefinitionDeathInteraction); Type typeExtKillSimNiec = typeof(NiecMod.Interactions.ExtKillSimNiec); foreach (InteractionInstance mInteraction in intt.mInteractionList) { if (mInteraction.GetType() == typeExtKillSimNiec) { return(true); } if (mInteraction.InteractionDefinition != null && mInteraction.InteractionDefinition.GetType() == typeCacheNiecModSocial) { return(true); } } return(false); }
public void Initialize(Session session, IInteractionSelector interactionSelector) { using (Trace.Main.scope()) { try { Trace.Main.always("Initializing VidyoPanelViewModel"); // Set things if (_session == null) { // Only do these things the first time around _session = session; _session.ConnectionStateChanged += SessionOnConnectionStateChanged; } _interactionSelector = interactionSelector; _customNotification = new CustomNotification(_session); MyInteractions = new InteractionQueue(InteractionsManager.GetInstance(_session), new QueueId(QueueType.User, _session.UserId)); // Watch queue MyInteractions.InteractionAdded += MyInteractionsOnInteractionAdded; MyInteractions.InteractionChanged += MyInteractionsOnInteractionChanged; MyInteractions.InteractionRemoved += MyInteractionsOnInteractionRemoved; MyInteractions.StartWatching(_watchedAttrs.ToArray()); // Watch for custom notifications _customNotification.CustomNotificationReceived += OnCustomNotificationReceived; WatchCustomNotifications(); // Get the Vidyo service client base URL SendCustomNotification(CustomMessageType.ApplicationRequest, VidyoServiceClientBaseUrlRequestOid, VidyoServiceClientBaseUrlRequestEid, _session.UserId.ToLower()); // Let everyone know we're ready IsInitialized = true; } catch (Exception ex) { Console.WriteLine(ex); Trace.Main.exception(ex, ex.Message); //MessageBox.Show( // "There was an error intializing the Vidyo addin. Please contact your system administrator.", // "Vidyo Addin - critical error"); throw; } } }
public bool ___ReturnBonehildaToCoffin(BonehildaCoffin target) { if (target == null || target.mBonehildaSim == null) // custom { return(false); } InteractionQueue tInteractionQueue = target.mBonehildaSim.InteractionQueue; if (tInteractionQueue != null && !tInteractionQueue.HasInteractionOfType(BonehildaCoffin.BonehildaReturnToCoffin.Singleton)) { Sim targetsim = target.mBonehildaSim; try { tInteractionQueue.CancelAllInteractions(); } catch (Exception) { NFinalizeDeath.ForceCancelAllInteractionsWithoutCleanup(targetsim); NFinalizeDeath.ForceDestroyObject(targetsim); target.mBonehildaSim = null; return(true); } targetsim = target.mBonehildaSim; if (targetsim == null || targetsim.SimDescription == null || targetsim.HasBeenDestroyed) { target.mBonehildaSim = null; return(true); } var entry = BonehildaCoffin.BonehildaReturnToCoffin .Singleton.CreateInstance(target, targetsim, new InteractionPriority(InteractionPriorityLevel.RequiredNPCBehavior), isAutonomous: false, cancellableByPlayer: true) as BonehildaCoffin.BonehildaReturnToCoffin; tInteractionQueue.AddNext(entry); } if (tInteractionQueue == null) { target.mBonehildaSim = null; } return(true); }
protected override bool Allow(SimDescription sim) { Sim createdSim = sim.CreatedSim; if (createdSim == null) { IncStat("Hibernating"); return(false); } InteractionQueue queue = createdSim.InteractionQueue; if (queue == null) { IncStat("No Queue"); return(false); } return(base.Allow(sim)); }
public override bool Run() { try { if (!TimePortal.sTimeTravelerHasBeenSummoned && Actor.CreateRoute().PlanToSlot(Target, Slot.RoutingSlot_0).Succeeded()) { if (!TimeTravelerSituation.Create(Actor.LotHome, Actor.ObjectId, Target.ObjectId)) { return(false); } CauseEffectService.OpportunityPortal = Target; mTimeTravlerArrivalHandled = false; } if ((Target.InUse && !Target.IsActorUsingMe(Actor)) || !Actor.RouteToSlot(Target, Slot.RoutingSlot_0, false)) { return(false); } if (Actor.HasExitReason(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached))) { return(false); } Definition interactionDefinition = InteractionDefinition as Definition; if (Target.Active) { interactionDefinition.curState = TimePortal.PortalState.Active; } else { interactionDefinition.curState = TimePortal.PortalState.Inactive; } Actor.SkillManager.AddElement(SkillNames.Future); StandardEntry(!Target.IsActorUsingMe(Actor)); BeginCommodityUpdates(); Target.mTimeToStepBack = false; EnterStateMachine("timeportal", "Enter", "x"); SetActor("portal", Target); mCurrentStateMachine.AddOneShotScriptEventHandler(0x65, SwitchActiveState); mCurrentStateMachine.AddOneShotScriptEventHandler(0x66, PositionTimeTraveler); AnimateSim("Mess With"); if (!TimePortal.sTimeTravelerHasBeenSummoned) { Common.DebugNotify("A"); mCurrentStateMachine.RequestState(false, "x", "FirstTimeReact"); emergencyStopWatch = StopWatch.Create(StopWatch.TickStyles.Seconds); int num = 0x2d; mTimeTraveler = CauseEffectService.GetInstance().GetTimeTraveler(); while ((mTimeTraveler == null) && (emergencyStopWatch.GetElapsedTime() < num)) { SpeedTrap.Sleep(0x1); // Custom SimDescription simDesc = SimDescription.Find(CauseEffectService.sPersistableData.TimeTravelerSimID); if (simDesc == null) { CauseEffectService.sPersistableData.TimeTravelerSimID = 0; CauseEffectService.GetInstance().RequestTimeTravelerSimDesc(Household.NpcHousehold); } else { mTimeTraveler = Instantiation.PerformOffLot(simDesc, Target.LotCurrent, null); } } Common.DebugNotify("B"); if (mTimeTraveler != null) { InteractionQueue interactionQueue = mTimeTraveler.InteractionQueue; mLinkedInteraction = TimePortal.BeSummoned.Singleton.CreateInstance(Actor, mTimeTraveler, new InteractionPriority(InteractionPriorityLevel.CriticalNPCBehavior), false, false) as TimePortal.BeSummoned; mLinkedInteraction.SyncTarget = Actor; interactionQueue.AddNext(mLinkedInteraction); Actor.SynchronizationRole = Sim.SyncRole.Initiator; Actor.SynchronizationTarget = mTimeTraveler; Actor.SynchronizationLevel = Sim.SyncLevel.Routed; if (Actor.WaitForSynchronizationLevelWithSim(mTimeTraveler, Sim.SyncLevel.Started, 40f)) { Common.DebugNotify("C"); SetActorAndEnter("y", mTimeTraveler, "TTEnter"); AnimateJoinSims("TimeTravelerExit"); Actor.SynchronizationLevel = Sim.SyncLevel.Completed; TimeTravelerSituation situation = ServiceSituation.FindServiceSituationInvolving(mTimeTraveler) as TimeTravelerSituation; if (situation != null) { situation.OnAppearComplete(mTimeTraveler, 0f); while (!Actor.HasExitReason(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached))) { Actor.LoopIdle(); SpeedTrap.Sleep(0xa); } } else { Target.ActorsUsingMe.Clear(); TimePortal.sTimeTravelerHasBeenSummoned = true; } } else { AnimateSim("Exit"); } Common.DebugNotify("D"); mTimeTravlerArrivalHandled = true; } else { AnimateSim("Exit"); } } else { if (!GameUtils.IsFutureWorld()) { MiniSimDescription simDesc = MiniSimDescription.Find(CauseEffectService.sPersistableData.TimeTravelerSimID); if (simDesc == null) { CauseEffectService.sPersistableData.TimeTravelerSimID = 0; CauseEffectService.GetInstance().RequestTimeTravelerSimDesc(Household.NpcHousehold); } } AnimateSim("Exit"); Vector3 v = Target.Position + ((Vector3)(2f * Target.ForwardVector)); Actor.RouteToPoint(v); Actor.RouteTurnToFace(Target.Position); } EndCommodityUpdates(true); StandardExit(); if (Target.Active) { EventTracker.SendEvent(EventTypeId.kInspectedTimePortal, Actor); } return(true); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); } finally { TravelUtil.PlayerMadeTravelRequest = false; //Sims3.Gameplay.Gameflow.Singleton.EnableSave(this); } return(false); }
private void StartOrRefreshWatchingInteractions() { if (_queues == null) { _queues = new Collection <InteractionQueue>(); try { var workgroups = Repository.Workgroups.Where(w => w.Profiles.Any() && !w.MarkedForDeletion); if (workgroups.Any() && _interactionsManager != null && _interactionsManager.Session != null && _interactionsManager.Session.ConnectionState == ConnectionState.Up) { foreach (var workgroup in workgroups) { try { var interactionQueue = new InteractionQueue(_interactionsManager, new QueueId(QueueType.Workgroup, workgroup.DisplayName)); interactionQueue.InteractionAdded += QueueOnInteractionAdded; interactionQueue.StartWatchingAsync(_queueAttributes, Interactions_StartOrRefreshWatchingCompleted, null); _queues.Add(interactionQueue); } catch (Exception e) { _logging.TraceException(e, "WorkgroupInteractions Error"); } } } } catch (Exception e) { _logging.TraceException(e, "WorkgroupInteractions Error"); } } else { var workgroups = Repository.Workgroups.Where(w => w.Profiles.Any() && !w.MarkedForDeletion).ToList(); if (workgroups.Any()) { foreach (var workgroup in workgroups) { var existing = _queues.FirstOrDefault(q => q.QueueId.QueueName == workgroup.DisplayName); if (existing == null) { try { var interactionQueue = new InteractionQueue(_interactionsManager, new QueueId(QueueType.Workgroup, workgroup.DisplayName)); interactionQueue.InteractionAdded += QueueOnInteractionAdded; interactionQueue.StartWatchingAsync(_queueAttributes, Interactions_StartOrRefreshWatchingCompleted, null); _queues.Add(interactionQueue); } catch (Exception e) { _logging.TraceException(e, "WorkgroupInteractions Error"); } } else { if (workgroup.MarkedForDeletion) { try { if (existing.IsWatching()) { existing.StopWatching(); } _queues.Remove(existing); } catch (Exception e) { _logging.TraceException(e, "WorkgroupInteractions Error"); } } } } } } }
public ChatBotService() { using (Trace.Main.scope()) { try { var useWindowsAuth = false; // Parse some settings bool.TryParse(ConfigurationManager.AppSettings["CicUseWindowsAuth"], out useWindowsAuth); bool.TryParse(ConfigurationManager.AppSettings["EnableCommands"], out _enableCommands); // Connect IceLib if (useWindowsAuth) { _session.Connect(new SessionSettings(), new HostSettings(new HostEndpoint(ConfigurationManager.AppSettings["CicServer"])), new WindowsAuthSettings(), new StationlessSettings()); } else { _session.Connect(new SessionSettings(), new HostSettings(new HostEndpoint(ConfigurationManager.AppSettings["CicServer"])), new ICAuthSettings(ConfigurationManager.AppSettings["CicUser"], ConfigurationManager.AppSettings["CicPassword"]), new StationlessSettings()); } // Set up bot manager _botManager = new BotManager(new ServiceProviderDelegates { GetAttributeMethod = GetAttribute, GetAttributesMethod = GetAttributes, SetAttributeMethod = SetAttribute, SetAttributesMethod = SetAttributes, SendChatMessageMethod = SendChatMessage, ReassignChatMethod = ReassignChat }); _botManager.LoadBots(); // Watch queues var queueNames = ConfigurationManager.AppSettings["QueueList"].Split(new[] { '|' }); foreach (var queueName in queueNames) { try { Console.WriteLine("Watching queue " + queueName); var queue = new InteractionQueue(InteractionsManager.GetInstance(_session), new QueueId(QueueType.Workgroup, queueName)); queue.QueueContentsChanged += QueueOnQueueContentsChanged; queue.StartWatching(_queueAttributes); _queues.Add(queue); } catch (Exception ex) { Console.WriteLine(ex); Trace.Main.exception(ex); } } // Make sure we have some queues if (_queues.Count == 0) { throw new Exception("Not watching any queues after initialization!"); } } catch (Exception ex) { Console.WriteLine(ex); Trace.Main.exception(ex); throw; } } }
public QueueViewModel(Session session) { try { // Initialize objects //Interactions = new ObservableCollection<InteractionViewModel>(); // Set command bindings CommandBindings.Add(new CommandBinding(UiCommands.PickUpCommand, PickUp_Executed, (sender, e) => { e.CanExecute = true; e.Handled = true; })); CommandBindings.Add(new CommandBinding(UiCommands.DisconnectCommand, Disconnect_Executed, (sender, e) => { e.CanExecute = true; e.Handled = true; })); CommandBindings.Add(new CommandBinding(UiCommands.MuteCommand, Mute_Executed, (sender, e) => { e.CanExecute = true; e.Handled = true; })); CommandBindings.Add(new CommandBinding(UiCommands.HoldCommand, Hold_Executed, (sender, e) => { e.CanExecute = true; e.Handled = true; })); CommandBindings.Add(new CommandBinding(UiCommands.ConferenceCommand, Conference_Executed, (sender, e) => { e.CanExecute = true; e.Handled = true; })); CommandBindings.Add(new CommandBinding(UiCommands.DialCommand, Dial_Executed, (sender, e) => { e.CanExecute = true; e.Handled = true; })); // Set objects _session = session; _queue = new InteractionQueue(InteractionsManager.GetInstance(_session), new QueueId(QueueType.MyInteractions, _session.UserId)); _queue.QueueContentsChanged += QueueOnQueueContentsChanged; _queue.StartWatching(_queueAttributes); } catch (Exception ex) { MainViewModel.Instance.LogMessage(ex); } }
public override bool Run() { try { if (!Actor.RouteToSlotAndCheckInUse(Target, BotMakingStation.kOperatorRoutingSlot)) { return(false); } StandardEntry(); BeginCommodityUpdates(); CASAgeGenderFlags adult = CASAgeGenderFlags.Adult; CASAgeGenderFlags gender = CASAgeGenderFlags.None | CASAgeGenderFlags.Male; RobotForms humanoid = RobotForms.Humanoid; SimDescription simDescription = OccultRobot.MakeRobot(adult, gender, humanoid); if (simDescription == null) { StandardExit(); return(false); } FutureSkill.SetupReactToFutureTech(Target); EnterStateMachine("BotMakingStation", "Enter", "x"); SetActor("BotMakingStation", Target); Target.SetGeometryState("on"); Animate("x", "CreateServoBot"); bool flag = false; Household.NpcHousehold.Add(simDescription); try { new Sims.Advanced.EditInCAS(true).Perform(new GameHitParameters <SimDescriptionObject>(Sim.ActiveActor, new SimDescriptionObject(simDescription), GameObjectHit.NoHit)); while (GameStates.NextInWorldStateId != InWorldState.SubState.LiveMode) { SpeedTrap.Sleep(); } flag |= CASChangeReporter.Instance.CasCancelled; Household.NpcHousehold.Remove(simDescription); Target.LotCurrent.SetDisplayLevel(LotManager.GetBestLevelToDisplayForSim(Actor, Target.LotCurrent)); Household household = Actor.Household; /* Overstuffed * if (!household.CanAddSimDescriptionToHousehold(simDescription)) * { * flag = true; * } */ if (flag) { AnimateSim("CancelCreateServoBot"); simDescription.Dispose(); AnimateSim("Exit"); } else { CASRobotData supernaturalData = simDescription.SupernaturalData as CASRobotData; supernaturalData.CreatorSim = Actor.SimDescription.SimDescriptionId; supernaturalData.BotQualityLevel = Target.GetCreationLevel(Actor); household.Add(simDescription); Sim sim = null; Slot[] containmentSlots = Target.GetContainmentSlots(); if ((containmentSlots != null) && (containmentSlots.Length > 0x0)) { Vector3 slotPosition = Target.GetSlotPosition(containmentSlots[0x0]); Vector3 forwardOfSlot = Target.GetForwardOfSlot(containmentSlots[0x0]); sim = Genetics.InstantiateRobotAndGrantPhone(simDescription, slotPosition); sim.SetPosition(slotPosition); sim.SetForward(forwardOfSlot); } else { Vector3 position = Actor.Position; Vector3 forwardVector = Actor.ForwardVector; sim = simDescription.Instantiate(position); GlobalFunctions.FindGoodLocationNearby(sim, ref position, ref forwardVector); sim.SetPosition(position); sim.SetForward(forwardVector); } Actor.Genealogy.AddChild(sim.Genealogy); InteractionQueue interactionQueue = sim.InteractionQueue; mLinkedInteraction = BotMakingStation.BeCreated.Singleton.CreateInstance(Target, sim, new InteractionPriority(InteractionPriorityLevel.CriticalNPCBehavior), false, false) as BotMakingStation.BeCreated; mLinkedInteraction.SyncTarget = Actor; interactionQueue.AddNext(mLinkedInteraction); Actor.SynchronizationRole = Sim.SyncRole.Initiator; Actor.SynchronizationTarget = sim; Actor.SynchronizationLevel = Sim.SyncLevel.Routed; if (!Actor.WaitForSynchronizationLevelWithSim(sim, Sim.SyncLevel.Started, 40f)) { Actor.ClearSynchronizationData(); AnimateJoinSims("CompleteCreateServoBot"); AnimateSim("ExitWithBot"); Target.SetGeometryState("off"); EndCommodityUpdates(false); StandardExit(); return(false); } SetActorAndEnter("y", sim, "BotEnter"); CASRobotData data2 = simDescription.SupernaturalData as CASRobotData; if (data2 != null) { SetParameter("IsHoverBot", data2.Form == RobotForms.Hovering); } else { SetParameter("IsHoverBot", false); } Actor.ModifyFunds(-BotMakingStation.kCostToBuildServoBot); AnimateJoinSims("CompleteCreateServoBot"); AnimateSim("ExitWithBot"); BotBuildingSkill element = Actor.SkillManager.GetElement(SkillNames.BotBuilding) as BotBuildingSkill; sim.SimDescription.TraitChipManager.UpgradeNumTraitChips(element.GetSimMaxAllowedUpgradeSlots()); EventTracker.SendEvent(EventTypeId.kCreatedBot, Actor, sim); element.OnBotCreated(); } } catch { simDescription.Dispose(); } Target.SetGeometryState("off"); EndCommodityUpdates(!flag); StandardExit(); return(true); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); } return(false); }
public static int GetAgentAvailabilityByProfile(int profileId) { try { if (UseCachedValue(profileId) || _isResetting) { int agentsAvailable; if (_availableAgentsByProfileId.TryGetValue(profileId, out agentsAvailable)) { return(agentsAvailable); } } } catch (Exception exception) { _logging.LogException(exception); } if (_lastAvailabilityCheckByProfileId.ContainsKey(profileId)) { _lastAvailabilityCheckByProfileId[profileId] = DateTime.Now; } else { _lastAvailabilityCheckByProfileId.Add(profileId, DateTime.Now); } if (ShouldReset()) { ResetWatched(); } var logMessage = ""; var availableAgents = 0; try { var repository = new Repository(); var profile = repository.Profiles.FirstOrDefault(p => p.ProfileId == profileId); if (profile != null && _peopleManager != null && _peopleManager.Session != null && _peopleManager.Session.ConnectionState == ConnectionState.Up) { var workgroup = profile.Workgroup; if (workgroup != null) { logMessage += "/~ Checking Availability for: " + workgroup.ConfigId + "~/"; var wgUtils = workgroup.Utilizations.ToList(); var agents = workgroup.ActiveMembers; foreach (var agent in agents) { try { logMessage += "/~ Checking Agent: " + agent.ConfigId + "~/"; var usl = new UserStatusList(_peopleManager); var status = usl.GetUserStatus(agent.ConfigId); var hasRequiredSkills = true; var acdAvailable = status.LoggedIn && status.StatusMessageDetails.IsAcdStatus; logMessage += "/~ Status: " + status.StatusMessageDetails.MessageText + "~/"; logMessage += "/~ Logged In: " + status.LoggedIn + "~/"; logMessage += "/~ Is Stale: " + status.IsStale + "~/"; logMessage += "/~ Station Count: " + status.Stations.Count + "~/"; var agentSkills = agent.Skills; foreach (var skill in profile.Skills) { if (!agentSkills.Contains(skill)) { hasRequiredSkills = false; } } logMessage += "/~ Has Required Skills: " + hasRequiredSkills + "~/"; var agentUtils = agent.Utilizations.ToList(); var utils = agentUtils.Any(u => u.MediaType == MediaType.Chat) ? agentUtils : wgUtils; var maxChats = 1; if (utils != null) { maxChats = utils.FirstOrDefault(m => m.MediaType == MediaType.Chat).MaxAssignable; } if ((agent.IsLicensedForChat || agent.MediaLevel == 3) && agent.HasActiveClientLicense && //agent.ActiveInWorkgroups.Contains(workgroup) && //already finding agents for workgroup above hasRequiredSkills && utils.Any(u => u.MediaType == MediaType.Chat) && acdAvailable && maxChats > 0) { logMessage += "/~ Meets base criteria ~/"; var watched = _queues.FirstOrDefault(q => q.QueueId.QueueName == agent.ConfigId && q.QueueId.QueueType == QueueType.User); var maxReached = false; if (((watched != null && !watched.IsWatching()) || watched == null) && _interactionsManager != null) { if (watched != null) { _queues.Remove(watched); } var interactionQueue = new InteractionQueue(_interactionsManager, new QueueId(QueueType.User, agent.ConfigId)); string[] attributes = { InteractionAttributeName.InteractionType, InteractionAttributeName.State, InteractionAttributeName.Direction }; interactionQueue.StartWatching(attributes); _queues.Add(interactionQueue); watched = interactionQueue; } var interactions = watched.GetContents(); var callUtil = agentUtils.Any(u => u.MediaType == MediaType.Call) ? agentUtils.FirstOrDefault(u => u.MediaType == MediaType.Call).UtilizationPercent : wgUtils.Any(u => u.MediaType == MediaType.Call) ? wgUtils.FirstOrDefault(u => u.MediaType == MediaType.Call).UtilizationPercent : 0; var callbackUtil = agentUtils.Any(u => u.MediaType == MediaType.Callback) ? agentUtils.FirstOrDefault(u => u.MediaType == MediaType.Callback).UtilizationPercent : wgUtils.Any(u => u.MediaType == MediaType.Callback) ? wgUtils.FirstOrDefault(u => u.MediaType == MediaType.Callback).UtilizationPercent : 0; var chatUtil = agentUtils.Any(u => u.MediaType == MediaType.Chat) ? agentUtils.FirstOrDefault(u => u.MediaType == MediaType.Chat).UtilizationPercent : wgUtils.Any(u => u.MediaType == MediaType.Chat) ? wgUtils.FirstOrDefault(u => u.MediaType == MediaType.Chat).UtilizationPercent : 0; var emailUtil = agentUtils.Any(u => u.MediaType == MediaType.Email) ? agentUtils.FirstOrDefault(u => u.MediaType == MediaType.Email).UtilizationPercent : wgUtils.Any(u => u.MediaType == MediaType.Email) ? wgUtils.FirstOrDefault(u => u.MediaType == MediaType.Email).UtilizationPercent : 0; var genericUtil = agentUtils.Any(u => u.MediaType == MediaType.Generic) ? agentUtils.FirstOrDefault(u => u.MediaType == MediaType.Generic).UtilizationPercent : wgUtils.Any(u => u.MediaType == MediaType.Generic) ? wgUtils.FirstOrDefault(u => u.MediaType == MediaType.Generic).UtilizationPercent : 0; var workitemUtil = agentUtils.Any(u => u.MediaType == MediaType.WorkItem) ? agentUtils.FirstOrDefault(u => u.MediaType == MediaType.WorkItem).UtilizationPercent : wgUtils.Any(u => u.MediaType == MediaType.WorkItem) ? wgUtils.FirstOrDefault(u => u.MediaType == MediaType.WorkItem).UtilizationPercent : 0; var util = chatUtil; foreach (var interaction in interactions) { //Should I be checking for WorkgroupQueue or other identifier in case a non ACD call is connected and the agent is technically unavailable? var type = interaction.InteractionType; var isActive = (interaction.State != InteractionState.ExternalDisconnect && interaction.State != InteractionState.InternalDisconnect && interaction.State != InteractionState.None); if (type == InteractionType.Chat && isActive) { util += chatUtil; maxChats--; } if (type == InteractionType.Call && isActive) { util += callUtil; } if (type == InteractionType.Callback && isActive) { util += callbackUtil; } if (type == InteractionType.Email && isActive) { util += emailUtil; } if (type == InteractionType.Generic && isActive) { util += genericUtil; } if (type == InteractionType.WorkItem && isActive) { util += workitemUtil; } if (maxChats < 1 || util > 100) { maxReached = true; } } if (!maxReached) { logMessage += "/~ Agent " + agent.ConfigId + " is available. ~/"; availableAgents++; } } } catch (Exception e) { logMessage += "/~" + e.ToString() + "~/"; } } } } } catch (Exception e) { logMessage += "/~" + e.ToString() + "~/"; } logMessage += "/~ Agents Available: " + availableAgents + "~/"; try { _logging.LogNote(logMessage); } catch (Exception) { } if (_availableAgentsByProfileId.ContainsKey(profileId)) { _availableAgentsByProfileId[profileId] = availableAgents; } else { _availableAgentsByProfileId.Add(profileId, availableAgents); } return(availableAgents); }
public void Test() { var interactionQueue = new InteractionQueue(); var saidSomthing = "hello"; // interactionQueue.GetInteractionFromDialogue(saidSomthing); }