using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using RFrameGenerate.DAL;
using RFrameGenerate.Model;
using RFramework.SQLServer;
using RFramework.SQLQuery;
using RFrameGenerate.DAL.Enums;
using RTCP;


namespace RFrameGenerate.BLL
{
    /// <summary>
    /// 开奖处理
    /// </summary>
    public class LotteryManage
    {
        public static void AddPeriodLotter(Guid periodGuid)
        {
            TcpClientManage client = new TcpClientManage("127.0.0.1", 16561);
            var buffer = client.Send(string.Format("#jfxs#yygkj#{0}#", periodGuid));
            string msg = client.Encoding.GetString(buffer);
            string[] command = msg.Split(new string[] { "#" }, StringSplitOptions.RemoveEmptyEntries);
            if (command.Length != 2 || command[0] != "jfxc")
            {
                Wechat.LogManage.Log("添加一元购开奖处理失败");
            }
        }

        public static double GetPeriodLotter(Guid periodGuid)
        {
            if (periodGuid == Guid.Empty) return 0;
            TcpClientManage client = new TcpClientManage("127.0.0.1", 16561);
            var buffer = client.Send(string.Format("#jfxs#yygjs#{0}#", periodGuid));
            if (buffer != null)
            {
                string msg = client.Encoding.GetString(buffer);
                string[] command = msg.Split(new string[] { "#" }, StringSplitOptions.RemoveEmptyEntries);
                if (command.Length != 2 || command[0] != "jfxc")
                {
                    Wechat.LogManage.Log("获取一元购开奖计时");
                    return 0;
                }
                else
                {
                    return double.Parse(command[1]);
                }
            }
            else
                return 0;
        }
    }
}
