using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace QC.QTMXmlSchema;

[Serializable]
public class ParamResult
{
	public const double ERROR_VALUE = -9999.0;

	public string Name;

	public string UnitOfMeasure;

	private ArrayList arrayStr;

	public string LowerLimit;

	public double? Value;

	public string CHAR_Value;

	public string ExtHyperLink;

	public string UpperLimit;

	public string Index;

	public bool? Result;

	public bool? ReportingEnabled;

	public string DataType;

	public Dictionary<string, string> additionalInfo = new Dictionary<string, string>();

	[XmlElement(Type = typeof(ArrayResult))]
	public ArrayList Array
	{
		get
		{
			return arrayStr;
		}
		set
		{
			arrayStr = value;
		}
	}

	public void AddArrayItem(string arrayItemName, string arrayItemIndex, string arrayItemColIndex, double? arrayItemValue, string arrayItemUpperLimit, string arrayItemLowerLimit)
	{
		try
		{
			AddArrayItemData(arrayItemName, arrayItemIndex, arrayItemColIndex, arrayItemValue, arrayItemUpperLimit, arrayItemLowerLimit, "", "");
		}
		catch (Exception ex)
		{
			throw new Exception("AddArrayItem failed for ArrayItem: " + arrayItemName + "; Error: " + ex.Message);
		}
	}

	public void AddArrayItem(string arrayItemName, string arrayItemIndex, string arrayItemColIndex, string arrayItemValue, string arrayItemUpperLimit, string arrayItemLowerLimit)
	{
		try
		{
			AddArrayItemData(arrayItemName, arrayItemIndex, arrayItemColIndex, null, arrayItemUpperLimit, arrayItemLowerLimit, arrayItemValue, "");
		}
		catch (Exception ex)
		{
			throw new Exception("AddArrayItem failed for ArrayItem: " + arrayItemName + "; Error: " + ex.Message);
		}
	}

	public void AddArrayItem(string arrayItemName, string arrayItemIndex, string arrayItemColIndex, string arrayItemCharValue, string arrayItemExtHyperLink)
	{
		try
		{
			AddArrayItemData(arrayItemName, arrayItemIndex, arrayItemColIndex, null, "", "", arrayItemCharValue, arrayItemExtHyperLink);
		}
		catch (Exception ex)
		{
			throw new Exception("AddArrayItem failed for ArrayItem: " + arrayItemName + "; Error: " + ex.Message);
		}
	}

	public void AddArrayItem(string arrayItemName, string arrayItemIndex, string arrayItemColIndex, string arrayItemCharValue)
	{
		try
		{
			AddArrayItemData(arrayItemName, arrayItemIndex, arrayItemColIndex, null, "", "", arrayItemCharValue, "");
		}
		catch (Exception ex)
		{
			throw new Exception("AddArrayItem failed for ArrayItem: " + arrayItemName + "; Error: " + ex.Message);
		}
	}

	private void AddArrayItemData(string arrayItemName, string arrayItemIndex, string arrayItemColIndex, double? arrayItemValue, string arrayItemUpperLimit, string arrayItemLowerLimit, string arrayItemCharValue, string arrayItemExtHyperLink)
	{
		try
		{
			if (Array == null)
			{
				Array = new ArrayList();
			}
			ArrayResult arrayResult = new ArrayResult();
			arrayResult.Name = arrayItemName;
			arrayResult.RowIndex = arrayItemIndex;
			arrayResult.ColumnIndex = arrayItemColIndex;
			arrayResult.Value = Utility.ConvertObjToDouble(arrayItemValue);
			arrayResult.UpperLimit = arrayItemUpperLimit;
			arrayResult.LowerLimit = arrayItemLowerLimit;
			arrayResult.CHAR_Value = arrayItemCharValue;
			arrayResult.ExtHyperLink = arrayItemExtHyperLink;
			Array.Add(arrayResult);
		}
		catch (Exception ex)
		{
			throw new Exception(ex.Message);
		}
	}

	public void AdditionalInfo(string key, string value)
	{
		if (additionalInfo.ContainsKey(key))
		{
			additionalInfo.Remove(key);
		}
		additionalInfo.Add(key, value);
	}
}
