using System;
using System.Text;
using Medivators.BusinessObjects;
using Medivators.Common;
using Medivators.Common.Logging;

namespace Medivators.Data.Queries
{
	public class InsertCycleReport : AsynchronousExecute, IInsertQuery
	{
		private CycleReport _report = null;
		public InsertCycleReport(CycleReport report)
		{
			_report = report;
		}
		public void Insert()
		{
			try
			{				
				string columnList = "[Key]," +
									"MachineID," +
									"Station," +
									"StartTimestamp," +
									"EndTimestamp," +
									"CycleCount," +
									"DisinfectantCycleCount," +
									"OperatorID," +
									"PatientID," +
									"PhysicianID," +
									"ScopeID," +
									"SSGRatio";

				string valueList = Constants.DoubleQuote + _report.Key + Constants.DoubleQuote + ", " +
								   _report.MachineID.ToString() + ", " +
								   Constants.DoubleQuote + _report.Station + Constants.DoubleQuote + ", " +
								   Constants.DateDelimiter + _report.StartTimestamp.ToString() + Constants.DateDelimiter + ", " +
								   Constants.DateDelimiter + _report.EndTimestamp.ToString() + Constants.DateDelimiter + ", " +
								   _report.CycleCount.ToString() + ", " +
								   _report.DisinfectantCycleCount.ToString() + ", " +
								   _report.OperatorID.ToString() + ", " +
								   _report.PatientID.ToString() + ", " +
								   _report.PhysicianID.ToString() + ", " +
								   _report.ScopeID.ToString() + ", " +
								   Constants.DoubleQuote + _report.SSGRatio + Constants.DoubleQuote;

				string sql = "insert into CycleReports (" + columnList + ") values (" + valueList + ")";
				base.Insert(sql);
			}
			catch (Exception ex)
			{
				ErrorHandler.GetInstance().LogException("InsertCycleReport.Insert error: ", ex);
			}
		}
	}
}
