private static void timeLoop_TimeTo(object sender, EventArgs e)
        {
            try
            {
                if (IsTimeToWork() && IsWork == false)
                {
                    IsWork = true; //开始工作
                    try
                    {
                        M_Config config     = CommonClass.SystemConfig.GetConfig();
                        bool     testReturn = false;
                        ReaderInfoSource.XZXSource source = new ReaderInfoSource.XZXSource();
                        testReturn = source.LinkDataSourceTest(config);
                        string msg = testReturn ? "第三方链接成功" : "第三方链接失败";
                        Display(msg);

                        Display("开始获取记录条数");
                        int recordCount = source.GetReaderInfo(config);
                        Display("共获取到记录数" + recordCount + "条");
                        Display("开始下载读者信息文件");

                        string newFilePath = AppDomain.CurrentDomain.BaseDirectory + "File\\";
                        string oldFilePath = AppDomain.CurrentDomain.BaseDirectory + "RecvTemp\\";

                        string[] files = Directory.GetFiles(oldFilePath);
                        if (files.Length < 1)
                        {
                            throw new Exception("找不到读者信息文件!");
                        }
                        else
                        {
                            string oldFile = files[files.Length - 1];
                            File.Copy(oldFile, newFilePath + "data", true);
                            Display("读者信息文件下载成功");
                        }
                    }
                    catch (Exception ex)
                    {
                        Display(ex.ToString());
                        SeatManage.SeatManageComm.WriteLog.Write(ex.ToString());
                    }
                    IsWork = false;
                }
            }
            catch (Exception ex)
            {
                WriteLog.Write("异常信息:" + ex);
                Display("异常信息:" + ex);
            }
        }
예제 #2
0
        //private bool isSync = false;
        /// <summary>
        /// 连接测试
        /// </summary>
        public void LinkTest()
        {
            M_Config config     = CommonClass.SystemConfig.GetConfig();
            bool     testReturn = false;

            if (SyncMessage != null)
            {
                SyncMessage("连接测试......");
            }
            try
            {
                switch (config.SourceType)
                {
                case E_SyncSourceType.Excel:
                {
                    ReaderInfoSource.ExcelSource source = new ReaderInfoSource.ExcelSource();
                    testReturn = source.LinkDataSourceTest(config);
                }
                break;

                case E_SyncSourceType.Sybase:
                {
                    ReaderInfoSource.SybaseSource source = new ReaderInfoSource.SybaseSource();
                    testReturn = source.LinkDataSourceTest(config);
                }
                break;

                case E_SyncSourceType.Orcale:
                {
                    ReaderInfoSource.OrcaleSource source = new ReaderInfoSource.OrcaleSource();
                    testReturn = source.LinkDataSourceTest(config);
                }
                break;

                case E_SyncSourceType.SQL:
                {
                    ReaderInfoSource.SQLSource source = new ReaderInfoSource.SQLSource();
                    testReturn = source.LinkDataSourceTest(config);
                }
                break;

                case E_SyncSourceType.TXT:
                {
                    ReaderInfoSource.TxtSource source = new ReaderInfoSource.TxtSource();
                    testReturn = source.LinkDataSourceTest(config);
                }
                break;

                case E_SyncSourceType.Xml:
                {
                    ReaderInfoSource.XmlSource source = new ReaderInfoSource.XmlSource();
                    testReturn = source.LinkDataSourceTest(config);
                }
                break;

                case E_SyncSourceType.XZX:
                {
                    ReaderInfoSource.XZXSource source = new ReaderInfoSource.XZXSource();
                    testReturn = source.LinkDataSourceTest(config);
                }
                break;
                }
                if (SyncMessage != null)
                {
                    SyncMessage(testReturn ? "连接成功!" : "连接失败!");
                }
            }
            catch (Exception ex)
            {
                if (SyncMessage != null)
                {
                    SyncMessage(ex.Message);
                }
            }
        }