/// <summary> /// This method returns the list of variables in the log file from the log descriptor /// in the same order as they are defined in the descriptor /// </summary> /// <returns>The list of variables read from the log descriptor</returns> public Descriptor(string logDescriptorFileName) { List <string> variableList = new List <string>(); XmlDocument logDescriptor = new XmlDocument(); if (File.Exists(logDescriptorFileName)) { try { logDescriptor.Load(logDescriptorFileName); XmlNode node = logDescriptor.FirstChild; if (node.Name == XMLTags.descriptorRootNodeName) { if (node.Attributes.GetNamedItem(XMLTags.descriptorBinaryDataFile) != null) { BinaryLogFile = node.Attributes[XMLTags.descriptorBinaryDataFile].Value; } if (node.Attributes.GetNamedItem(XMLTags.descriptorSceneFile) != null) { SceneFile = node.Attributes[XMLTags.descriptorSceneFile].Value; } foreach (XmlNode child in node.ChildNodes) { string variableName = child.InnerText; switch (child.Name) { case XMLTags.descriptorStateVarNodeName: StateVariables.Add(variableName); break; case XMLTags.descriptorActionVarNodeName: ActionVariables.Add(variableName); break; case XMLTags.descriptorRewardVarNodeName: RewardVariables.Add(variableName); break; case XMLTags.descriptorStatVarNodeName: StatVariables.Add(variableName); break; } } } } catch (Exception ex) { throw new Exception("Error loading log descriptor: " + logDescriptorFileName + ex.Message); } } }
/// <summary> /// Called when [next]. /// </summary> /// <param name="value">The value.</param> public void OnNext(IStatisticsCollection value) { Request statreq = new Request(); List <string> tempThresholdValues; List <Color> tempThresholdColors; try { logger.Debug("AgentStatisticsSubscriber : OnNext Method : Entry"); if (value != null) { if (value.AgentStatistics != null && value.AgentStatistics.Count != 0) { try { foreach (IAgentStatistics agentstat in value.AgentStatistics) { string[] configuredstat = value.StatisticsCommon.AgentStatistics.Split(','); { foreach (string configstat in configuredstat) { if (configstat == agentstat.TempStatName) { string statName = agentstat.StatisticsName.ToString(); string filter = agentstat.FilterName.ToString(); string serverName = agentstat.ServerName.ToString(); string format = agentstat.StatisticsFormat.ToString(); logger.Info("AgentStatisticsSubscriber : OnNext Method : Request : ReferenceId - " + agentstat.ReferenceID); logger.Info("AgentStatisticsSubscriber : OnNext Method : Request : StatName - " + statName); logger.Info("AgentStatisticsSubscriber : OnNext Method : Request : ServerName - " + serverName); IMessage response; if (!StatisticsSetting.GetInstance().isAdmin) { if (agentstat.ReferenceID < StatisticsSetting.GetInstance().BAttributeReferenceId) { logger.Info("AgentStatisticsSubscriber : OnNext Method : Request : AgentEmpId - " + StatisticsSetting.GetInstance().AgentEmpId); response = statreq.StatRequest(value.StatisticsCommon.TenantName, StatisticsSetting.GetInstance().AgentEmpId, StatisticObjectType.Agent, statName, value.StatisticsCommon.NotifySeconds, filter, value.StatisticsCommon.Insensitivity, agentstat.ReferenceID, serverName); } else { //logger.Info("AgentStatisticsSubscriber : OnNext Method : Request : AgentEmpId - " + StatisticsSetting.GetInstance().AgentEmpId); response = statreq.StatRequest(value.StatisticsCommon.TenantName, StatisticsSetting.GetInstance().AgentEmpId, StatisticObjectType.Agent, value.StatisticsCommon.NotifySeconds, filter, configstat, agentstat.ReferenceID, serverName); } } else { if (!StatisticsSetting.GetInstance().RequestIds.Contains(agentstat.ReferenceID)) { StatisticsSetting.GetInstance().RequestIds.Add(agentstat.ReferenceID); } response = statreq.StatRequest(value.StatisticsCommon.TenantName, StatisticsSetting.GetInstance().IndividualAgent, StatisticObjectType.Agent, statName, value.StatisticsCommon.NotifySeconds, filter, value.StatisticsCommon.Insensitivity, agentstat.ReferenceID, serverName); } if (response != null) { statVariables = new StatVariables(); switch (response.Id) { case EventStatisticOpened.MessageId: EventStatisticOpened info; info = (EventStatisticOpened)response; statVariables.Statfilter = filter; statVariables.StatType = StatisticObjectType.Agent.ToString(); statVariables.DisplayName = agentstat.DisplayName; statVariables.Tooltip = agentstat.ToolTipName; statVariables.Statformat = format; statVariables.ObjectType = agentstat.TempStatName; statVariables.ObjectID = StatisticsSetting.GetInstance().AgentEmpId; statVariables.ReferenceId = info.ReferenceId.ToString(); tempThresholdValues = new List <string>(); tempThresholdValues.Add(agentstat.ThresholdLevelOne); tempThresholdValues.Add(agentstat.ThresholdLevelTwo); tempThresholdColors = new List <Color>(); tempThresholdColors.Add(agentstat.StatColor); tempThresholdColors.Add(agentstat.ThresholdColorOne); tempThresholdColors.Add(agentstat.ThresholdColorTwo); StatisticsBase.GetInstance().IsMyStats = true; if (!StatisticsSetting.GetInstance().ListRequestIds.Contains(agentstat.ReferenceID)) { StatisticsSetting.GetInstance().ListRequestIds.Add(agentstat.ReferenceID); } if (!StatisticsSetting.GetInstance().ThresholdValues.ContainsKey(agentstat.ReferenceID.ToString())) { StatisticsSetting.GetInstance().ThresholdValues.Add(agentstat.ReferenceID.ToString(), tempThresholdValues); } if (!StatisticsSetting.GetInstance().ThresholdColors.ContainsKey(agentstat.ReferenceID.ToString())) { StatisticsSetting.GetInstance().ThresholdColors.Add(agentstat.ReferenceID.ToString(), tempThresholdColors); } if (!StatisticsSetting.GetInstance().DictAllStats.ContainsKey(info.ReferenceId.ToString())) { StatisticsSetting.GetInstance().DictAllStats.Add(info.ReferenceId.ToString(), agentstat.TempStatName); } if (!StatisticsSetting.GetInstance().agentStatisticsPluginHolder.ContainsKey(info.ReferenceId)) { StatisticsSetting.GetInstance().agentStatisticsPluginHolder.Add(info.ReferenceId, statVariables); } StatisticsSetting.GetInstance().FinalAgentPackageID.Add(agentstat.ReferenceID); break; case EventError.MessageId: EventError eventError = (EventError)response; logger.Error("AgentStatisticsSubscriber : OnNext Method : " + eventError.StringValue); break; } statVariables = null; } } } } } } catch (Exception generalException) { logger.Error("AgentStatisticsSubscriber : OnNext Method : " + generalException.Message); } finally { GC.Collect(); } } } } catch (Exception GeneralException) { logger.Error("AgentStatisticsSubscriber : OnNext Method : " + GeneralException.Message); } finally { logger.Debug("AgentStatisticsSubscriber : OnNext Method : Exit"); statreq = null; } }
/// <summary> /// Called when [next]. /// </summary> /// <param name="value">The value.</param> public void OnNext(IStatisticsCollection value) { Request statreq = new Request(); List <string> tempThresholdValues; List <Color> tempThresholdColors; int tempRefid = StatisticsSetting.GetInstance().ReferenceId + 150; try { logger.Debug("VQStatisticsSubscriber : OnNext Method : Entry"); if (value != null) { if (value.VirtualQueueStatistics != null && value.VirtualQueueStatistics.Count != 0) { try { string[] VQueues = value.StatisticsCommon.VQueueObjects.Split(','); foreach (string vqueue in VQueues) { StatisticsSetting.GetInstance().VQueueListCollections.Add(vqueue); } foreach (IVirtualQueueStatistics vqstat in value.VirtualQueueStatistics) { string[] configuredstat = value.StatisticsCommon.VQueueStatistics.Split(','); { foreach (string configstat in configuredstat) { if (configstat == vqstat.TempStatName) { for (int VQIndex = 0; VQIndex < StatisticsSetting.GetInstance().VQueueListCollections.Count; VQIndex++) { string Dilimitor = "_@"; string[] vq_Switch = StatisticsSetting.GetInstance().VQueueListCollections[VQIndex].Split(new[] { Dilimitor }, StringSplitOptions.None); string statName = vqstat.StatisticsName.ToString(); string filter = vqstat.FilterName.ToString(); string serverName = vqstat.ServerName.ToString(); string format = vqstat.StatisticsFormat.ToString(); //if (string.Compare(vqstat.TempStatName, vq_Switch[2].ToString(), true) == 0) { logger.Info("VQStatisticsSubscriber : OnNext Method : Request : ReferenceId - " + tempRefid); logger.Info("VQStatisticsSubscriber : OnNext Method : Request : StatName - " + statName); logger.Info("VQStatisticsSubscriber : OnNext Method : Request : VQueueName - " + vq_Switch[0] + "@" + vq_Switch[1]); logger.Info("VQStatisticsSubscriber : OnNext Method : Request : serverName - " + serverName); IMessage response; if (tempRefid < StatisticsSetting.GetInstance().BAttributeReferenceId) { response = statreq.StatRequest(value.StatisticsCommon.TenantName, vq_Switch[0] + "@" + vq_Switch[1], StatisticObjectType.Queue, statName, value.StatisticsCommon.NotifySeconds, filter, value.StatisticsCommon.Insensitivity, tempRefid, serverName); } else { response = statreq.StatRequest(value.StatisticsCommon.TenantName, vq_Switch[0] + "@" + vq_Switch[1], StatisticObjectType.Queue, value.StatisticsCommon.NotifySeconds, filter, configstat, tempRefid, serverName); } logger.Info("VQStatisticsSubscriber : OnNext Method : Request : " + response.ToString()); if (response != null) { statVariables = new StatVariables(); switch (response.Id) { case EventStatisticOpened.MessageId: EventStatisticOpened info; info = (EventStatisticOpened)response; statVariables.Statfilter = filter; statVariables.StatType = StatisticObjectType.Queue.ToString(); //statVariables.DisplayName = vqstat.DisplayName; statVariables.Tooltip = vqstat.ToolTipName; statVariables.Statformat = format; statVariables.ObjectType = vqstat.TempStatName; statVariables.ReferenceId = info.ReferenceId.ToString(); string[] tempQueueName = StatisticsSetting.GetInstance().VQueueListCollections[VQIndex].Split(new[] { Dilimitor }, StringSplitOptions.None); statVariables.DisplayName = vqstat.DisplayName; if (StatisticsBase.GetInstance().QueueDisplayName == StatisticsEnum.ACDDisplayName.Queue.ToString() || StatisticsBase.GetInstance().QueueDisplayName == StatisticsEnum.ACDDisplayName.RoutingPoint.ToString()) { statVariables.ObjectID = tempQueueName[0].ToString(); statVariables.CCStat = vqstat.DisplayName + " " + tempQueueName[0].ToString(); } else if (StatisticsBase.GetInstance().QueueDisplayName == StatisticsEnum.ACDDisplayName.Skill.ToString()) { statVariables.ObjectID = tempQueueName[1].ToString(); statVariables.CCStat = vqstat.DisplayName + " " + tempQueueName[1].ToString(); } else { statVariables.ObjectID = tempQueueName[0].ToString(); statVariables.CCStat = vqstat.DisplayName + " " + tempQueueName[0].ToString(); } tempThresholdValues = new List <string>(); tempThresholdValues.Add(vqstat.ThresholdLevelOne); tempThresholdValues.Add(vqstat.ThresholdLevelTwo); tempThresholdColors = new List <Color>(); tempThresholdColors.Add(vqstat.StatColor); tempThresholdColors.Add(vqstat.ThresholdColorOne); tempThresholdColors.Add(vqstat.ThresholdColorTwo); StatisticsBase.GetInstance().IsCCStats = true; if (!StatisticsSetting.GetInstance().ThresholdValues.ContainsKey(info.ReferenceId.ToString())) { StatisticsSetting.GetInstance().ThresholdValues.Add(info.ReferenceId.ToString(), tempThresholdValues); } if (!StatisticsSetting.GetInstance().ThresholdColors.ContainsKey(info.ReferenceId.ToString())) { StatisticsSetting.GetInstance().ThresholdColors.Add(info.ReferenceId.ToString(), tempThresholdColors); } if (!StatisticsSetting.GetInstance().DictAllStats.ContainsKey(info.ReferenceId.ToString())) { StatisticsSetting.GetInstance().DictAllStats.Add(info.ReferenceId.ToString(), vqstat.TempStatName); } if (!StatisticsSetting.GetInstance().VQStatisticsValueHolder.ContainsKey(info.ReferenceId)) { StatisticsSetting.GetInstance().VQStatisticsValueHolder.Add(info.ReferenceId, statVariables); } StatisticsSetting.GetInstance().FinalVQPackageID.Add(info.ReferenceId); break; case EventError.MessageId: EventError eventError = (EventError)response; logger.Error("VQStatisticsSubscriber : OnNext Method: " + eventError.StringValue); break; } statVariables = null; } tempRefid++; } } } } } } } catch (Exception generalException) { logger.Error("VQStatisticsSubscriber : OnNext Method : " + generalException.Message); } finally { GC.Collect(); } } } } catch (Exception GeneralException) { logger.Error("VQStatisticsSubscriber : OnNext Method : " + GeneralException.Message); } finally { logger.Debug("VQStatisticsSubscriber : OnNext Method : Exit"); statreq = null; } }
// Loads information from AllVeriables to StatVeriables void UseData(int filterType, List <Match> matchList) { List <Match> matches = new List <Match>(); int currentParticipantID = 0; string isWinner = "Loser"; Dictionary <DateTime, bool> dateList = new Dictionary <DateTime, bool>(); List <TableElements> dataGridList = new List <TableElements>(); if (!StatVariables.IsEmpty()) { StatVariables.MakeNulls(); } foreach (var match in matchList) { DateTime date = new DateTime(1970, 1, 1).AddMilliseconds((match.GameCreation)).AddHours(2); foreach (var participantID in match.ParticipantIdentities) { if (participantID.Player.SummonerId == CurrentUserElements.Player.ID) { currentParticipantID = participantID.ParticipantID; } } foreach (var participant in match.Participants) { var stats = participant.Stats; if (stats.ParticipantID == currentParticipantID) { isWinner = "Loser"; if (stats.Win) { isWinner = "Winner"; StatVariables.WinsCount++; } switch (filterType) { case 0: // All matches matches.Add(match); dataGridList.Add(new TableElements(string.Format("http://ddragon.leagueoflegends.com/cdn/6.24.1/img/champion/{0}.png", CurrentUserElements.Champions.Keys[participant.ChampionID]), date.ToString(), isWinner, string.Format("{0}/{1}/{2}", stats.Kills, stats.Deaths, stats.Assists), stats.GoldEarned.ToString())); break; case 1: // Ranked Matches matches.Add(match); if (match.QueueID == 420 || match.QueueID == 440 || match.QueueID == 470) { dataGridList.Add(new TableElements(string.Format("http://ddragon.leagueoflegends.com/cdn/6.24.1/img/champion/{0}.png", CurrentUserElements.Champions.Keys[participant.ChampionID]), date.ToString(), isWinner, string.Format("{0}/{1}/{2}", stats.Kills, stats.Deaths, stats.Assists), stats.GoldEarned.ToString())); } break; case 2: // Simple Matches matches.Add(match); if (match.QueueID != 420 && match.QueueID != 440 && match.QueueID != 470) { dataGridList.Add(new TableElements(string.Format("http://ddragon.leagueoflegends.com/cdn/6.24.1/img/champion/{0}.png", CurrentUserElements.Champions.Keys[participant.ChampionID]), date.ToString(), isWinner, string.Format("{0}/{1}/{2}", stats.Kills, stats.Deaths, stats.Assists), stats.GoldEarned.ToString())); } break; } StatVariables.AverageKills += stats.Kills; StatVariables.AverageDeaths += stats.Deaths; StatVariables.AverageAssists += stats.Assists; StatVariables.AverageGold += stats.GoldEarned; dateList.Add(new DateTime(1970, 1, 1).AddMilliseconds(match.GameCreation).AddHours(2), stats.Win); } } } TopDayOfTheWeek(dateList); StatVariables.DataGridList = dataGridList; }