using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WK_KLI_LAPS_Service.App_Data;
using static WK_KLI_LAPS_Service.Controllers.Reports.ReportApiController;

namespace WK_KLI_LAPS_Service.Controllers.Reports
{

    public interface IReportService
    {
        object GetJobstatusReport(reportModel data);
        object GetProductionReport(reportModel data);
    }

    public class ReportServices : IReportService
    {
        CommonRepository oCommonRepository = new CommonRepository();
        MasterRepository oMasterRepository = new MasterRepository();

        public object GetVlexreportdata(reportModel data, string mode)
        {
            var input = JsonConvert.SerializeObject(data);
            return oCommonRepository.ExecuteSP_ReturnList("spvlexreport", input, mode);
        }

        public object GetVlexreportdatagrid(reportModel data, string mode)
        {
            var input = JsonConvert.SerializeObject(data);
            return oCommonRepository.ExecuteSP_ReturnList("spvlexreportfinal", input, mode);
        }

        public object GetJobstatusReport(reportModel data)
        {
            var input = JsonConvert.SerializeObject(data);
            return oCommonRepository.ExecuteSP_ReturnList("spJobStatusReport", input, "getall");
        }

        public object GetJobcreationReport(reportModel data)
        {
            var input = JsonConvert.SerializeObject(data);
            return oCommonRepository.ExecuteSP_ReturnList("spjobcreationreport", input, "getall");
        }


        public object GeGetProductionDashboardStagewiseReport(reportModel data)
        {
            var input = JsonConvert.SerializeObject(data);
            return oCommonRepository.ExecuteSP_ReturnList("spproductiondashboardstagewiseReport", input, "get");

        }

        public object GetUserwiseProductionLogReport(reportModel data)
        {
            var input = JsonConvert.SerializeObject(data);
            return oCommonRepository.ExecuteSP_ReturnList("spuserwiseproductionlogreport", input, "get");

        }
        public object GetProductionReport(reportModel data)
        {
            var input = JsonConvert.SerializeObject(data);
            return oCommonRepository.ExecuteSP_ReturnList("spproductionreport", input, "get");

        }
        public object GetProcessWiseProductionReport(reportModel data)
        {
            var input = JsonConvert.SerializeObject(data);
            return oCommonRepository.ExecuteSP_ReturnList("spprocesswiseproductionreport", input, "get");

        }

        public object GetRuntimeProcesswiseReport(reportModel data)
        {
            var input = JsonConvert.SerializeObject(data);
            return oCommonRepository.ExecuteSP_ReturnList("spruntimeprocesswisereport", input, "get");
            //   return oCommonRepository.ExecuteSP_ReturnList("spruntimeprocesswisereport_test", input, "get");

        }
        public object GetRuntimeDashboardReport(reportModel data)
        {
            var input = JsonConvert.SerializeObject(data);
            return oCommonRepository.ExecuteSP_ReturnList("spruntimedashboardreport", input, "get");
            //  return oCommonRepository.ExecuteSP_ReturnList("spruntimedashboardreport_test", input, "get");

        }

        public object GetRuntimHourlyProjecHealth(reportModel data)
        {
            var input = JsonConvert.SerializeObject(data);

            return oCommonRepository.ExecuteSP_ReturnList("spruntimehourlyprojecthealth_completed", input, "get");
            //   return oCommonRepository.ExecuteSP_ReturnList("spruntimehourlyprojecthealth_completed_test", input, "get");

        }
        public object GetRuntimHourlyProjecHealth_Wip(reportModel data)
        {
            var input = JsonConvert.SerializeObject(data);
            return oCommonRepository.ExecuteSP_ReturnList("spruntimehourlyprojecthealth_wip", input, "get");
            //   return oCommonRepository.ExecuteSP_ReturnList("spruntimehourlyprojecthealth_wip_test", input, "get");
        }
        public object GetDashboardTotalcount(reportModel data)
        {
            var input = JsonConvert.SerializeObject(data);
            return oCommonRepository.ExecuteSP_ReturnList("spdashboardreport ", input, "get");

        }

        public object GetUserwiseProductionReport(reportModel data)
        {
            var input = JsonConvert.SerializeObject(data);
            return oCommonRepository.ExecuteSP_ReturnList("spuserwiseproductionreport ", input, "get");
            // return oCommonRepository.ExecuteSP_ReturnList("spuserwiseproductionreport_update ", input, "get");

        }
        public object GetJobTitle(reportModel data)
        {
            var input = JsonConvert.SerializeObject(data);
            return oCommonRepository.ExecuteSP_ReturnList("spjobmasterselect ", input, "getJobbycreationdate");

        }
        public object GetRecordErrorReport(reportModel data)
        {
            var input = JsonConvert.SerializeObject(data);
            return oCommonRepository.ExecuteSP_ReturnList("sprecorderrorreport", input, "get");

        }
        public object Getruntimeuserperformancereport(reportModel data)
        {
            var today_data = new { p_startdate = data.p_startdate, p_enddate = data.p_enddate, p_stagename = data.p_stagename, p_interval = 0, multipleprojectid_p = data.multipleprojectid_p };
            var today_input = JsonConvert.SerializeObject(today_data);
            var lasthour_data = new { p_startdate = data.p_startdate, p_enddate = data.p_enddate, p_stagename = data.p_stagename, p_interval = 1, multipleprojectid_p = data.multipleprojectid_p };
            var lasthour_input = JsonConvert.SerializeObject(lasthour_data);
            var today = oCommonRepository.ExecuteSP_ReturnList("spruntimeuserperformancereport", today_input, "get");
            var lasthour = oCommonRepository.ExecuteSP_ReturnList("spruntimeuserperformancereport", lasthour_input, "get");

            var json = new List<object>();
            json.Add(today);
            json.Add(lasthour);

            return json;
        }
        public object Getloball()
        {
            return oMasterRepository.AI_ExecuteSP_ReturnList("spprojectdefinitionselect", "{}", "getlob");
        }
        public object GetAnswerData(texttelescopemodel data)
        {
            var input = JsonConvert.SerializeObject(data);
            return oMasterRepository.AI_ExecuteSP_ReturnList("sptexttelescopedata", input, "DateFilter");
        }
        public object Getloginoutuser(string mode)
        {
            //var input = JsonConvert.SerializeObject(data);
            return oCommonRepository.ExecuteSP_ReturnList("spLoginandoutuser", "", mode);
        }
        //public object Getruntimeuserperformancereport(reportModel data)
        //{
        //    //var input = JsonConvert.SerializeObject(data);
        //    //return oCommonRepository.ExecuteSP_ReturnList("spruntimeuserperformancereport ", input, "get");
        //    var today_webcheck_data = new { p_startdate = data.p_startdate, p_enddate = data.p_enddate, p_stagename = "Web Check", p_interval = 0 , multipleprojectid_p = data.multipleprojectid_p};
        //    var today_webcheck_input = JsonConvert.SerializeObject(today_webcheck_data);
        //    var lasthour_webcheck_data = new { p_startdate = data.p_startdate, p_enddate = data.p_enddate, p_stagename = "Web Check", p_interval = 1, multipleprojectid_p = data.multipleprojectid_p };
        //    var lasthour_webcheck_input = JsonConvert.SerializeObject(lasthour_webcheck_data);
        //    var today_bidentry_data = new { p_startdate = data.p_startdate, p_enddate = data.p_enddate, p_stagename = "Bid Entry", p_interval = 0, multipleprojectid_p = data.multipleprojectid_p };
        //    var today_bidentry_input = JsonConvert.SerializeObject(today_bidentry_data);
        //    var lasthour_bidentry_data = new { p_startdate = data.p_startdate, p_enddate = data.p_enddate, p_stagename = "Bid Entry", p_interval = 1, multipleprojectid_p = data.multipleprojectid_p };
        //    var lasthour_bidentry_input = JsonConvert.SerializeObject(lasthour_bidentry_data);
        //    var today_fpr_data = new { p_startdate = data.p_startdate, p_enddate = data.p_enddate, p_stagename = "FPR", p_interval = 0, multipleprojectid_p = data.multipleprojectid_p };
        //    var today_fpr_input = JsonConvert.SerializeObject(today_fpr_data);
        //    var lasthour_fpr_data = new { p_startdate = data.p_startdate, p_enddate = data.p_enddate, p_stagename = "FPR", p_interval = 1, multipleprojectid_p = data.multipleprojectid_p };
        //    var lasthour_fpr_input = JsonConvert.SerializeObject(lasthour_fpr_data);
        //    var today_webcheck = oCommonRepository.ExecuteSP_ReturnList("spruntimeuserperformancereport", today_webcheck_input, "get");
        //    var lasthour_webcheck = oCommonRepository.ExecuteSP_ReturnList("spruntimeuserperformancereport", lasthour_webcheck_input, "get");
        //    var today_bidentry = oCommonRepository.ExecuteSP_ReturnList("spruntimeuserperformancereport", today_bidentry_input, "get");
        //    var lasthour_bidentry = oCommonRepository.ExecuteSP_ReturnList("spruntimeuserperformancereport", lasthour_bidentry_input, "get");
        //    var today_fpr = oCommonRepository.ExecuteSP_ReturnList("spruntimeuserperformancereport", today_fpr_input, "get");
        //    var lasthour_fpr = oCommonRepository.ExecuteSP_ReturnList("spruntimeuserperformancereport", lasthour_fpr_input, "get");
        //    var json = new List<object>();
        //    json.Add(today_webcheck);
        //    json.Add(lasthour_webcheck);
        //    json.Add(today_bidentry);
        //    json.Add(lasthour_bidentry);
        //    json.Add(today_fpr);
        //    json.Add(lasthour_fpr);
        //    return json;
        //}
    }

}
