예제 #1
0
        /// <summary>
        /// 쿼리한 결과를 DataSet에 넣어 준다..
        /// </summary>
        /// <param name="Query"></param>
        /// <param name="strTable"></param>
        /// <returns></returns>
        public DataSet Excute_Query(string Query, string strTable, bool writelog = false)
        {
            int Count = 0;

            while (this.retryTimes_Query >= Count)
            {
                try
                {
                    Count++;
                    return(excute_Query(Query, strTable, writelog));
                }
                catch (Exception ex)
                {
                    if (_log != null & writelog)
                    {
                        _log.WLog_Exception(string.Format("SQLDB.Excute_Query[{0}번째", Count), ex);
                    }

                    if (Count >= retryTimes_Query)
                    {
                        throw new Exception(string.Empty, ex);
                    }
                }
            }

            return(null);
        }
예제 #2
0
        /// <summary>
        /// ¿¡·¯ 󸮸¦ ÇÑ´Ù. ·Î±×±â·Ï ¹× »óÅÂÇ¥½Ã â...
        /// </summary>
        /// <param name="ex"></param>
        /// <param name="strMethodName"></param>
        /// <param name="showMessageBox">¸Þ¼¼Áö PopUp Ç¥½Ã ¿©ºÎ</param>
        protected virtual void ProcException(Exception ex, string strMethodName, bool showMessageBox = false)
        {
            if (clsLog != null)
            {
                clsLog.WLog_Exception(strMethodName, ex);
            }

            string msg;

            if (ex.Message.Equals(string.Empty))
            {
                msg = ex.InnerException.Message;
            }
            else
            {
                msg = ex.Message;
            }


            if (showMessageBox)
            {
                clsFunction.ShowMsg(this, "¿À·ù ¹ßÇà", msg, frmMessage.enMessageType.OK);
            }

            SetMessage(true, msg, false);

            Console.WriteLine(string.Format("[{0}]{1}", msg, ex.ToString()));
        }
예제 #3
0
        /// <summary>
        /// 셀에 값을 변경한다.
        /// </summary>
        /// <param name="fp"></param>
        /// <param name="sv"></param>
        /// <param name="Y"></param>
        /// <param name="X"></param>
        /// <param name="objValue"></param>
        public static void Invoke_Cell_Value(FarPoint.Win.Spread.FpSpread fp, FarPoint.Win.Spread.SheetView sv, int Y, int X, object objValue)
        {
            if (fp.InvokeRequired)
            {
                fp.Invoke(new delInvoke_Cell_Value(Invoke_Cell_Value), new object[] { fp, sv, Y, X, objValue });
                return;
            }

            try
            {
                sv.Cells[Y, X].Value = objValue;
            }
            catch (Exception ex)
            {
                log.WLog_Exception(string.Format("{0}[sv]{1}[y}{2}[x]{3][obj]{4}", "Invoke_Cell_Value", fp.Name, Y, X, objValue), ex);
            }
        }
예제 #4
0
        /// <summary>
        /// 테그 수신을 일정 시간 동안 읽는다.
        /// </summary>
        /// <param name="intDuration">읽을 시간(ms)</param>
        public void StartReading(int intDuration)
        {
            try
            {
                client.startReading(strRICName);

                Thread.Sleep(intDuration);

                client.stopReading(strRICName);
            }
            catch (Exception ex)
            {
                clsLog.WLog_Exception("StartReading", ex);
                SP_SMS_SET_ERROR(ex);
                throw ex;
            }
        }
예제 #5
0
        private void thTest(object obj)
        {
            if (isTestWork)
            {
                return;
            }

            try
            {
                isTestWork = true;
                if (log == null)
                {
                    string fld = ".\\TestLog";

                    if (!Function.system.clsFile.FolderExists(fld))
                    {
                        Function.system.clsFile.FolderCreate(fld);
                    }

                    log = new Function.Util.Log(fld, "TestLog", 30, true);
                }

                //address, interval, from, to
                string[] param = (string[])obj;


                lngTestTimes++;
                if (lngTestTimes == 1)
                {
                    decTestValue    = decimal.Parse(param[2]);
                    decTestMaxValue = decimal.Parse(param[3]);
                    log.WLog("PlcTest를 시작합니다.[IP]{0} [Port]{1} [PlcType]{2} [ValueFrom]{3} [ValueTo]{4}", Comm.IPAddress, Comm.Port, Comm.enPLCType, decTestValue, decTestMaxValue);
                }
                else if ((lngTestTimes % 100) == 0)
                {
                    log.WLog("PlcTest {0}번째 진행중 [현재값]{1}", lngTestTimes, decTestValue);
                }

                Comm.WriteOrder(param[0], int.Parse(decTestValue.ToString()));

                Function.form.control.Invoke_Control_Text(lblTestMsg, string.Format("[{0}] Value:{1}", DateTime.Now.ToString("HH:mm:ss"), decTestValue));

                decTestValue++;
            }
            catch (Exception ex)
            {
                log.WLog_Exception("thTest", ex);

                Function.form.control.Invoke_Control_Text(lblTestMsg, ex.Message);
            }
            finally
            {
                isTestWork = false;
            }
        }
예제 #6
0
        /// <summary>
        /// 백업을 수행한다.
        /// </summary>
        /// <param name="obj"></param>
        private void DoBackup(object obj)
        {
            if (_isDoBackup)
            {
                return;
            }

            _isDoBackup = true;

            try
            {
                if (!Directory.Exists(_backupFolder))
                {
                    Directory.CreateDirectory(_backupFolder);
                }


                //파일의 속성이 바뀌거나 날짜가 바뀌면 삭제 하고, 1달 이상의 백업은 말일자만 남겨 놓는다.
                foreach (string f in _dicFiles.Keys)
                {
                    BackUpProc(f);
                }

                DelProc();
            }
            catch (Exception ex)
            {
                if (_log != null)
                {
                    _log.WLog_Exception("DoBackup", ex);
                }
            }
            finally
            {
                _isDoBackup = false;
            }
        }
예제 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        private void IF_Db(object o)
        {
            if (!vari.bIF_Chk)
            {
                return;
            }

            if (isIF_Db)
            {
                return;
            }

            try
            {
                isIF_Db = true;
                string   msg;
                DateTime tmS = DateTime.Now;
                Function.form.control.Invoke_Control_Text(lblIF_Status, $"[{tmS.ToString("HH:mm:ss")}] IF작업 시작...");

                DataTable dt = dba.IF_Result();

                DataRow r = dt.Rows[0];

                TimeSpan ts = DateTime.Now - tmS;

                msg = string.Format("[처리시간]{0:F2}초 [대상]{1}건 [처리]{2}건 [잔여]{3}건", ts.TotalSeconds, r["TotalCount"], r["WorkCount"], r["RemainQty"]);
                LvLogAdd(lstIFLog, DateTime.Now, "IF성공", msg, false, enStringLocation.Front);
                ifLog.WLog(msg);

                Function.form.control.Invoke_Control_Text(lblIF_Status, $"IF작업 대기 다음작업[{tmS.AddSeconds(iIF_Span).ToString("HH:mm:ss")}]");
            }
            catch (Exception ex)
            {
                LvLogAdd(lstIFLog, DateTime.Now, "IF오류", ex.Message, true, enStringLocation.Front);
                ifLog.WLog_Exception("IF_Db", ex);
            }
            finally
            {
                isIF_Db = false;
            }
        }
예제 #8
0
        /// <summary>
        /// 상태 체크 스래드 : 주기적으로 GetFirmwareVersion data를 보내 상태 체크를 한다.
        /// </summary>
        private void AliveCheck()
        {
            bool isReOpen = false;

            while (bReadSocket)
            {
                try
                {
                    //현재시간 보다 통신체크한 시간이 뒤..
                    if (dtAliveCheck > DateTime.Now)
                    {
                        dtAliveCheck = DateTime.Now;
                    }


                    //30초이상 통신이 없으면 통신 체크를 한다.
                    if (dtAliveCheck < DateTime.Now.AddSeconds(-30))
                    {
                        if (socket.Connected)
                        {
                            byte[] byt = (byte[])parser.GetFirmwareVersion();
                            clsLog.WLog("Alive Check - Send Firmware Check");
                            Send_Packet(byt);
                        }
                    }
                    else
                    {
                        isReOpen = false;
                    }

                    //10초 한번씩..
                    Thread.Sleep(10000);
                }
                catch (Exception ex)
                {
                    clsLog.WLog_Exception("AliveCheck", ex);
                }


                //1분이상 통신이 없으면 에러 처리를 한다.
                if (dtAliveCheck < DateTime.Now.AddSeconds(-60))
                {
                    try
                    {
                        if (!isReOpen)
                        {
                            clsLog.WLog("TCP Conection 오류 3회 이상 발생 : 소켓 종료 후 재 접속시도");
                        }

                        isReOpen = true;

                        if (socket.Connected)
                        {
                            socket.Shutdown(SocketShutdown.Both);                              //보내기 와 받기 모두 사용할 수 없도록 합니다.
                            socket.Close();
                        }

                        Thread.Sleep(500);

                        Open();
                    }
                    catch
                    {
                        clsLog.WLog("TCP Conection Open 실패");
                        Thread.Sleep(5000);
                    }
                }
            }
        }