/* ==============================================================================
 * 功能描述：ServiceMBIClientHandler  
 * 创 建 者：Garrett
 * 创建日期：2019/4/12 15:08:46
 * ==============================================================================*/

using System;
using System.Windows.Forms;
using TaskDatabase;
using TaskDatabase.Model;
using System.Configuration;

namespace Client.Start
{
    /// <summary>
    /// ServiceMBIClientHandler
    /// </summary>
    public class ServiceMBIClientHandler
    {
        private static ClientApp m_Client;
        public static void Start()
        {
            string ip = ConfigurationManager.AppSettings["IP"];
            Console.WriteLine(ip);
            int port = Convert.ToInt32(ConfigurationManager.AppSettings["Port"]);
            string dir = ConfigurationManager.AppSettings["DownloadFileDir"];
            int maxtask = Convert.ToInt32(ConfigurationManager.AppSettings["MaxTaskCount"]);
            int maxDownloadTask = Convert.ToInt32(ConfigurationManager.AppSettings["MaxDownloadTaskCount"]);
            //192.168.20.225
            m_Client = new ClientApp(ip, port, dir, maxtask, new RevitCmdExecutor(), maxDownloadTask);
            m_Client.Start();
            //Console.WriteLine("begin");
            //Console.ReadKey();
        }

        public static void Stop()
        {
            m_Client?.Close();
        }
    }
}
