public static string SerializeCountingResultFromCounts(Dictionary <string, int> counts, double processTime)
        {
            LVAOther other = (LVAOther)countingConsolidation.cInference[0];

            other.other.inferenceTime = processTime;
            for (int i = 1; i < (countingConsolidation.cInference.Length); i++)
            {
                LVAEvent lResult = (LVAEvent)countingConsolidation.cInference[i];
                lResult.evt.properties.count       = counts[lResult.evt.name] - lResult.evt.properties.accumulated;
                lResult.evt.properties.accumulated = counts[lResult.evt.name];
            }

            //Create a stream to serialize the object to.
            MemoryStream ms = new MemoryStream();

            //Serializer the User object to the stream.
            var settings = new DataContractJsonSerializerSettings();

            settings.EmitTypeInformation = EmitTypeInformation.Never;
            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(LVACountingResults), settings);

            ser.WriteObject(ms, countingConsolidation);
            byte[] json = ms.ToArray();
            ms.Close();
            return(Encoding.UTF8.GetString(json, 0, json.Length));
        }
        public static string SerializeCountingResultFromItemList(List <Item> detectionItems, double processTime)
        {
            LVAOther other = (LVAOther)countingConsolidation.cInference[0];

            other.other.inferenceTime = processTime;
            for (int i = 1; i < (countingConsolidation.cInference.Length); i++)
            {
                LVAEvent lResult = (LVAEvent)countingConsolidation.cInference[i];
                if (detectionItems != null && detectionItems.Count != 0)
                {
                    int previousAccuCounts = lResult.evt.properties.accumulated;
                    foreach (Item item in detectionItems)
                    {
                        if (lResult.evt.name == item.TriggerLine)
                        {
                            lResult.evt.properties.accumulated++;
                        }
                    }
                    lResult.evt.properties.count = lResult.evt.properties.accumulated - previousAccuCounts;
                }
                else
                {
                    lResult.evt.properties.count = 0;
                }
            }

            //Create a stream to serialize the object to.
            MemoryStream ms = new MemoryStream();

            //Serializer the User object to the stream.
            var settings = new DataContractJsonSerializerSettings();

            settings.EmitTypeInformation = EmitTypeInformation.Never;
            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(LVACountingResults), settings);

            ser.WriteObject(ms, countingConsolidation);
            byte[] json = ms.ToArray();
            ms.Close();
            return(Encoding.UTF8.GetString(json, 0, json.Length));
        }