using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using Core.Mes.ClientFrameWork;
using System.IO;
using System.Configuration;
using System.Diagnostics;
using System.Data;

using STMes;

namespace DataTest
{
    class Program
    {
        static void Main(string[] args)
        {

            string url = ConfigurationManager.AppSettings["RemoteServerUrl"];
            ClientCommon._RemotingHelp.InitServerUrlList("ServerCommon", url);
            //arevent = new AutoResetEvent(false);
            //timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_ElapsedEvent);
            //timer.Interval = 10 * 1000;
            //timer.Start();
            GetTestData();
            Console.Read();


        }
        //private static int j = 0;
        //private static void Timer_ElapsedEvent(Object obj, System.Timers.ElapsedEventArgs args)
        //{
        //    #region 多线程
        //    for (int i = 0; i < 15; i++)
        //    {
        //        int a = i;
        //        count = i;
        //        ThreadPool.QueueUserWorkItem(new WaitCallback(delegate { GetTestData(a); }));

        //    }

        //    j++;
        //    if (j == 2)
        //        timer.Stop();
        //    Console.Read();

        //    #endregion
        //}


        //private static int count = 0;
        //private static int errnum = 0;
        //static AutoResetEvent arevent = null;
        //static System.Timers.Timer timer = new System.Timers.Timer();


        private static void GetTestData()
        {


            //if (count == 14)
            //    arevent.Set();
            //else
            //{
            //    arevent.WaitOne();
            //}


            try
            {

                string strOut = "";

                DataSet obj = ClientCommon._RemotingHelp.ExecuteMethod("PurviewManager", "Core.Mes.PurviewManager.PurviewManager", "DeleteUAM_ROLE", null, out strOut) as DataSet;
                if (strOut != "")
                {
                    Console.WriteLine("失败:" + strOut);
                    return;
                    
                    
                }
                if (strOut == "")
                {
                    Console.WriteLine("success");
                }
                if (obj != null && obj.Tables.Count > 0)
                {
                    
                    Console.WriteLine("数目：" + obj.Tables[0].Rows.Count.ToString() + "\r\n");
                    obj.Clear();
                    obj.Dispose();
                    GC.Collect();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("出错啦，跑不动啦~：" + ex.Message);
            }






        }


    }
}
