using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FWHandler
{
    public class LoggerHandler
    {
        private IHTML HTMLController;
        private IXML XMLController;
        private StringBuilder FormatedString { get; set; }
        private StringBuilder TableString { get; set; }

        public LoggerHandler(IHTML HTMLController)
        {
            this.HTMLController = HTMLController;
            FormatedString = new StringBuilder();
            FormatedString.Clear();
            TableString = new StringBuilder();
            TableString.Clear();
            FormatedString.Append(HTMLController.InjectHTML_Head());
        }
        public LoggerHandler(IXML XMLController)
        {
            this.XMLController = XMLController;
        }
        private LoggerHandler() { }
     
        public void Save_TS(string Date, string Project, string BuildInfo, string Requestor, string Duration, int passed, int failed, string ArrowStatus)
        {
           
            FormatedString.Append(HTMLController.InjectHTML_Body_Table1(Date, Project, BuildInfo, Requestor, Duration, passed, failed, ArrowStatus));
            FormatedString.Append(HTMLController.InjectHTML_Body_Table2_Td());
            FormatedString.Append(TableString);
            FormatedString.Append(HTMLController.InjectHTML_Tail());                       
        }

        public void Safe_TC(string TCName, string Status, string Duration, string Error, string ErrorMesage, string pathToErrorPicture)
        {     
            TableString.Append(HTMLController.InjectHTML_Body_Table2_Tr(TCName, Status, Duration, Error, ErrorMesage, pathToErrorPicture));         
        }

        public void Finalize(string pathWay)
        {
            using (FileStream fs = new FileStream(pathWay, FileMode.Create))
            {
                using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
                {
                    w.WriteLine(FormatedString.ToString());
                }
            }
        }
    }
}







/*public string PredictedError { get; set; }
     public string GeneratedError { get; set; }
     public double TestFinallTime { get; set; }
     public string ScreenPath { get; set; }
     public string ProjectName { get; set; }
     public string RelevantVariables { get; set; }
     public DateTime StartingDate { get; set; }
     public string RequestedBy { get; set; }
     public int[] OverAllTestResult = new int[2];
     public bool TestStatus { get; set; }*/
