using FLY.Thick.FilmCasting.IService;
using FObjBase;
using FObjBase.Reflect;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FLY.Thick.FilmCasting.Client
{
    public class BulkDbServiceClient : FObjBase.Reflect.Reflect_SeviceClient, IBulkDbService
    {
        protected override Type InterfaceType => typeof(IBulkDbService);

        public long LastScanDataId { get; set; }

        public long LastProfileId { get; set; }

        public DateTime LastTimestamp { get; set; }

        public DateTime StartTime { get; set; }

        public DateTime EndTime { get; set; }

        public bool IsFinished { get; set; }

        public BulkDbServiceClient(UInt32 serviceId) : base(serviceId) { }
        public BulkDbServiceClient(UInt32 serviceId, string connName) : base(serviceId, connName) { }

        public event EventHandler TempFrameChanged;



        public void Trigger_TempFrameChanged(BulkDbTempFrameChangedEventArgs e) {
            TempFrameChanged?.Invoke(this, e);
        }

        public void GetTempFrame(AsyncCBHandler asyncDelegate, object asyncContext)
        {
            Call(nameof(GetTempFrame), null, asyncDelegate, asyncContext);
        }

        public void GetProfile(Pack_GetProfileRequest request, AsyncCBHandler asyncDelegate, object asyncContext)
        {
            Call(nameof(GetProfile), new { request }, asyncDelegate, asyncContext);
        }

        public void GetFrame(Pack_GetFrameRequest request, AsyncCBHandler asyncDelegate, object asyncContext)
        {
            Call(nameof(GetFrame), new { request }, asyncDelegate, asyncContext);
        }
        public void GetFrame2(Pack_GetFrameRequest request, AsyncCBHandler asyncDelegate, object asyncContext)
        {
            Call(nameof(GetFrame2), new { request }, asyncDelegate, asyncContext);
        }

        /// <summary>
        /// 获取近期的大量数据
        /// </summary>
        /// <param name="request"></param>
        /// <param name="asyncDelegate"></param>
        /// <param name="asyncContext"></param>
        [Call(typeof(Pack_GetRecentFramesReponse))]
        public void GetRecentFrames(
            Pack_GetRecentFramesRequest request,
            AsyncCBHandler asyncDelegate, object asyncContext)
        {
            Call(nameof(GetRecentFrames), new { request }, asyncDelegate, asyncContext);
        }

        public void GetTrend(Pack_GetTrendRequest request, AsyncCBHandler asyncDelegate, object asyncContext)
        {
            Call(nameof(GetTrend), new { request }, asyncDelegate, asyncContext);
        }



        public void Finish()
        {
            Call(nameof(Finish));
        }
    }
}
