Пример #1
0
        /**
         * 데이터베이스에 주기적으로 접속해서 데이터를 가져와서
         * FDP전송하고 데이터베이스에 다시 업데이트를 수행한다.
         * 쓰레드 함수
         */
        public void WindLidarDataProcess()
        {
            while (!isShutdown)
            {
                int found = 0;
                if (isShutdown == false)
                {
                    waitHandle.Reset();
                    // 데이터베이스에 접속해서 데이터를 가져온다.
                    try
                    {
                        // 하나의 Row 가져오기
                        StsInfo fileData = ftsProcess.getRcvDataInfo();

                        if (fileData != null)
                        {
                            fileData.mode = 1;
                            // FTP 전송 - need module
                            ftsProcess.setFtpInfo(fileData.s_code, FTP_URI, ParamInitInfo.Instance.m_ftpIP, ParamInitInfo.Instance.m_ftpPort,
                                                  ParamInitInfo.Instance.m_ftpUser, ParamInitInfo.Instance.m_ftpPass);
                            bool sts = ftsProcess.ftpSendData(fileData);

                            if (sts == false)
                            {
                                Console.WriteLine("[WindLidarDataProcess] ftpSendData false...........[" + fileData.s_code + "]");
                                ftsProcess.ftpFailUpdate(fileData);
                                found = 0;
                            }
                            else
                            {
                                found = 1;
                            }
                        }
                        else
                        {
                            Console.WriteLine("[WindLidarDataProcess]The transfer data is not found .......");
                            found = 0;
                        }
                    }
                    catch (MySqlException e)
                    {
                        log("[ ProcessReceiver::WindLidarDataProcess(error) ] Error : " + e.Message);
                    }
                    if (found == 0)
                    {
                        waitHandle.WaitOne(1000 * System.Convert.ToInt16(ParamInitInfo.Instance.m_ftpThreadTime));  // 1 minute ( need setup)
                    }
                    else
                    {
                        waitHandle.WaitOne(1000 * 2);   // 10 seconds
                    }
                }
            }
        }
Пример #2
0
        public void StaThreadProcess()
        {
            while (!isShutdown)
            {
                int found = 0;
                if (isShutdown == false)
                {
                    staHandle.Reset();
                    // 데이터베이스에 접속해서 데이터를 가져온다.
                    try
                    {
                        StsInfo fileData = atsProcess.getStaRcvDataInfo();
                        if (fileData != null)
                        {
                            fileData.mode = 0;
                            // FTP 전송 - need module
                            atsProcess.setFtpInfo(fileData.s_code, FTP_URI, ParamInitInfo.Instance.m_ftpIP, ParamInitInfo.Instance.m_ftpPort,
                                                  ParamInitInfo.Instance.m_ftpUser, ParamInitInfo.Instance.m_ftpPass);

                            bool sts = atsProcess.ftpStaSendData(fileData);

                            if (sts == false)
                            {
                                Console.WriteLine("[StaThreadProcess] ftpSendData false...........[" + fileData.s_code + "]");
                                log("[StaThreadProcess] ftpSendData false...........[" + fileData.s_code + " : " + fileData.no + "]");
                                atsProcess.ftpFailUpdate(fileData);
                            }
                            found = 1;
                        }
                        else
                        {
                            Console.WriteLine("[StaThreadProcess] The transfer data is not found .......");
                            found = 0;
                        }
                    }
                    catch (MySqlException e)
                    {
                        log("[ ProcessReceiver::StaThreadProcess(error) ] Error : " + e.Message);
                    }
                    if (found == 0)
                    {
                        staHandle.WaitOne(1000 * System.Convert.ToInt16(ParamInitInfo.Instance.m_staThreadTime));       // 1 min
                    }
                    else
                    {
                        // 처리할 데이터가 있을 수 있다.
                        staHandle.WaitOne(1000 * 8);    // 10 seconds
                    }
                }
            }
        }