Пример #1
0
        /// <summary>
        /// 영역 구분선 Visibility 변경
        /// </summary>
        /// <param name="isVisible"></param>
        public void SetBordersVisibility(bool isVisible)
        {
            try
            {
                if (this.ge == null)
                {
                    FileLogManager.GetInstance().WriteLog("[GEController] SetBordersVisibility( GEPlugin is null. )");

                    throw new Exception("External Exception : GEPlugin is null.");
                }

                if (isVisible)
                {
                    ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, 1);
                }
                else
                {
                    ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, 0);
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("SetBordersVisibility Exception : " + ex.ToString());
                FileLogManager.GetInstance().WriteLog("[GEController] SetBordersVisibility( " + ex.ToString() + " )");
            }
        }
Пример #2
0
        /// <summary>
        /// NavigationControl Visibility 변경
        /// </summary>
        /// <param name="isVisible">true : Auto, false : Hide</param>
        public void SetNavigationControlVisibility(bool isVisible)
        {
            try
            {
                if (this.ge == null)
                {
                    FileLogManager.GetInstance().WriteLog("[GEController] SetNavigationControlVisibility( GEPlugin is null. )");

                    throw new Exception("External Exception : GEPlugin is null.");
                }

                if (isVisible)
                {
                    ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);
                }
                else
                {
                    ge.getNavigationControl().setVisibility(ge.VISIBILITY_HIDE);
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("SetNavigationControlVisibility Exception : " + ex.ToString());
                FileLogManager.GetInstance().WriteLog("[GEController] SetNavigationControlVisibility( " + ex.ToString() + " )");
            }
        }
Пример #3
0
        /// <summary>
        /// 로컬에 윈도우 이벤트 로그를 기록한다.
        /// </summary>
        /// <param name="type">이벤트뷰어의 종류</param>
        /// <param name="message">이벤트기록의 내용</param>
        /// <returns></returns>
        public bool WriteLog(EventLogEntryType type, string message)
        {
            try
            {
                if (!EventLog.SourceExists(this.sourceName))
                {
                    EventLog.CreateEventSource(this.sourceName, this.sourceName);
                }

                byte[] rawData = Encoding.Default.GetBytes(currentUserNme);

                EventLog eventLog = new EventLog();
                eventLog.Log    = this.sourceName;
                eventLog.Source = this.sourceName + "_이벤트";
                eventLog.WriteEntry(message, type, 0, 0, rawData);

                return(true);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[EventLogManager] WriteLog4 ( Exception: " + ex.ToString() + " )");
                FileLogManager.GetInstance().WriteLog("[EventLogManager] WriteLog4( " + ex.ToString() + " )");

                return(false);
            }
        }
Пример #4
0
        /// <summary>
        /// KmlDocument 의 Visibility 변경
        /// </summary>
        /// <param name="document"></param>
        /// <param name="isVisible"></param>
        public void SetKmlDocumentVisible(IKmlDocument document, bool isVisible)
        {
            if (document == null)
            {
                System.Console.WriteLine("SetKmlDocumentVisible - KmlDocument is null");
                FileLogManager.GetInstance().WriteLog("[GEController] SetKmlDocumentVisible( KmlDocument is null )");

                return;
            }

            try
            {
                document.setVisibility(Convert.ToInt32(isVisible));

                KmlObjectListCoClass kmlObjectListCoClass = document.getFeatures().getChildNodes();
                for (int i = 0; i < kmlObjectListCoClass.getLength(); i++)
                {
                    IKmlObject kmlObject = kmlObjectListCoClass.item(i);
                    string     strType   = kmlObject.getType();
                    if (strType == "KmlPlacemark")
                    {
                        IKmlPlacemark placemark = kmlObject as IKmlPlacemark;
                        placemark.setVisibility(Convert.ToInt32(isVisible));
                    }
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("SetKmlDocumentVisible Exception : " + ex.ToString());
                FileLogManager.GetInstance().WriteLog("[GEController] SetKmlDocumentVisible( " + ex.ToString() + " )");
            }
        }
Пример #5
0
        /// <summary>
        /// 게이트웨이 연결 상태 감시 쓰레딩 종료.
        /// </summary>
        public int EndConnectionSupervisory()
        {
            System.Console.WriteLine("[CommunicationManager] 게이트웨이 연결 상태 감시 종료");

            try
            {
                this.isPollingContinue = false;
                if (this.manualEvtPolling != null)
                {
                    this.manualEvtPolling.Set();
                }
                if (this.pollingThread != null && this.pollingThread.IsAlive)
                {
                    bool terminated = this.pollingThread.Join(500);
                    if (!terminated)
                    {
                        this.pollingThread.Abort();
                    }
                }
                this.pollingThread = null;
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[CommunicationManager] EndConnectionSupervisory( " + ex.ToString() + " )");
                FileLogManager.GetInstance().WriteLog("[CommunicationManager] EndConnectionSupervisory( Exception=[" + ex.ToString() + "] )");

                return(-99);
            }

            return(0);
        }
Пример #6
0
        /// <summary>
        /// 지정한 위 경도로 이동
        /// </summary>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        /// <param name="altitude"></param>
        /// <param name="speed"></param>
        public void MoveFlyTo(double latitude, double longitude, double altitude, double speed)
        {
            try
            {
                if (this.ge == null)
                {
                    FileLogManager.GetInstance().WriteLog("[GEController] MoveFlyTo( GEPlugin is null. )");

                    throw new Exception("External Exception : GEPlugin is null.");
                }

                //맵 이동------------------------------------------시작
                double prevFlyToSpeed = ge.getOptions().getFlyToSpeed();
                ge.getOptions().setFlyToSpeed(speed);
                IKmlCamera camera = ge.getView().copyAsCamera(ge.ALTITUDE_RELATIVE_TO_GROUND);
                camera.setAltitude(altitude);
                camera.setLatitude(latitude);
                camera.setLongitude(longitude);
                camera.setHeading(360);
                ge.getView().setAbstractView(camera);
                ge.getOptions().setFlyToSpeed(prevFlyToSpeed);
                //맵 이동--------------------------------------------끝
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("MoveFlyTo Exception : " + ex.ToString());
                FileLogManager.GetInstance().WriteLog("[GEController] MoveFlyTo( " + ex.ToString() + " )");
            }
        }
Пример #7
0
        public bool RemoveKml(IKmlObject obj)
        {
            try
            {
                if (this.ge == null)
                {
                    FileLogManager.GetInstance().WriteLog("[GEController] RemoveKml( GEPlugin is null )");

                    throw new Exception("External Exception : GEPlugin is null.");
                }

                if (ge.getFeatures() == null)
                {
                    return(false);
                }
                ge.getFeatures().removeChild(obj);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("RemoveKml Exception : " + ex.ToString());
                FileLogManager.GetInstance().WriteLog("[GEController] RemoveKml( " + ex.ToString() + " )");

                return(false);
            }

            return(true);
        }
Пример #8
0
        /// <summary>
        /// 데이터 수신 처리 쓰레딩 종료.
        /// </summary>
        public int EndDataProcessing()
        {
            try
            {
                this.isReceivedDataProcessingContinue = false;
                if (this.manualEvtReceiveData != null)
                {
                    this.manualEvtReceiveData.Set();
                }
                if (this.dataProcessingThread != null && this.dataProcessingThread.IsAlive)
                {
                    bool isTerminated = this.dataProcessingThread.Join(500);
                    if (!isTerminated)
                    {
                        this.dataProcessingThread.Abort();
                    }
                }
                this.dataProcessingThread = null;
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[CommunicationManager] EndDataProcessing( " + ex.ToString() + " )");
                FileLogManager.GetInstance().WriteLog("[CommunicationManager] EndDataProcessing( Exception=[" + ex.ToString() + "] )");

                return(-99);
            }

            return(0);
        }
Пример #9
0
        /// <summary>
        /// 게이트웨이 연결 상태 감시 쓰레딩 시작.
        /// </summary>
        public bool PrepareConnectionSupervisory()
        {
            System.Console.WriteLine("[CommunicationManager] 게이트웨이 연결 상태 감시 쓰레드 준비");

            bool result = false;

            try
            {
                if (this.pollingThread == null)
                {
                    this.pollingThread = new Thread(this.Polling);
                    this.pollingThread.IsBackground = true;
                    this.pollingThread.Name         = "PollingThread";
                    this.pollingThread.Start();
                }

                result = true;
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[CommunicationManager] PrepareConnectionSupervisory( " + ex.ToString() + " )");
                FileLogManager.GetInstance().WriteLog("[CommunicationManager] PrepareConnectionSupervisory( Exception=[" + ex.ToString() + "] )");

                EndConnectionSupervisory();
                return(false);
            }

            return(result);
        }
Пример #10
0
        /// <summary>
        /// 트랜잭션 종료
        /// </summary>
        /// <param name="endState">트랜잭션 종료 형태 지정. <br></br>
        /// true: Commit 으로 종료 <br></br>
        /// false: RollBack 으로 종료</param>
        /// <returns></returns>
        public bool EndTransaction(bool endState)
        {
            try
            {
                if (endState)
                {
                    // oracleDB.BeginTransaction() 를 호출하지 않는 경우에는, 자동으로 커밋된다.
                    // BeginTransaction을 호출하지 않는 상태에서 커밋을 실행하면 널익셉션 발생
                    oracleDB.Commit();
                }
                else
                {
                    this.oracleDB.Rollback();
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[DBConnector] EndTransaction( " + ex.ToString() + " )");
                FileLogManager.GetInstance().WriteLog("[DBConnector] EndTransaction( Exception=[" + ex.ToString() + "] )");

                //this.oracleDB.Rollback();
                return(false);
            }

            return(true);
        }
Пример #11
0
        /// <summary>
        /// 접속할 대상지의 아이피와 포트 번호를 저장한다.
        /// </summary>
        /// <param name="newIP">접속 대상지 아이피</param>
        /// <param name="newPort">접속 대상지 포트</param>
        public void SetConnectionInfo(string newIP, string newPort)
        {
            FileLogManager.GetInstance().WriteLog("[SessionManager] SetConnectionInfo( start >> newIP=[" + newIP + "], newPort=[" + newPort + "] )");

            if (this.targetIP == newIP && this.targetPort.ToString() == newPort)
            {
                // 동일 정보인 경우, 아무 것도 하지 않음.
                FileLogManager.GetInstance().WriteLog("[SessionManager] SetConnectionInfo( end - 동일 정보 갱신은 무시 )");

                return;
            }

            this.targetIP = newIP;
            int portNumber = 0;

            if (int.TryParse(newPort, out portNumber))
            {
                this.targetPort = portNumber;
            }
            else
            {
                this.targetPort = 0;
            }

            // 변경된 정보로 재접속
            Disconnect();
            Connect();

            FileLogManager.GetInstance().WriteLog("[SessionManager] SetConnectionInfo( end )");
        }
Пример #12
0
        /// <summary>
        /// 게이트웨이와의 접속 해제.
        /// </summary>
        /// <returns>해제 결과</returns>
        public bool DisconnectWithGateway()
        {
            System.Console.WriteLine("[CommunicationManager] 게이트웨이에 해제 요청");

            bool result = false;

            try
            {
                result = this.sessionManager.Disconnect();

                if (this.NotifyIAGWConnectionState != null)
                {
                    IAGWConnectionEventArgs copy = new IAGWConnectionEventArgs();
                    lock (this.currentIAGWConnectionState)
                    {
                        this.currentIAGWConnectionState.IsAuthenticated = false;
                        this.currentIAGWConnectionState.IsConnected     = false;

                        copy.DeepCopyFrom(this.currentIAGWConnectionState);
                    }
                    this.NotifyIAGWConnectionState(this, copy);
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[CommunicationManager] DisconnectWithGateway (Exception:" + ex.ToString() + ")");
                FileLogManager.GetInstance().WriteLog("[CommunicationManager] DisconnectWithGateway( Exception=[" + ex.ToString() + "] )");
            }

            return(result);
        }
Пример #13
0
        /// <summary>
        /// [경보 발령] 버튼 클릭.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOrder_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.lvWaitToOrderSWRList.SelectedItems == null || this.lvWaitToOrderSWRList.SelectedItems.Count <= 0)
                {
                    return;
                }
                string     targetID     = this.lvWaitToOrderSWRList.SelectedItems[0].Name;
                SWRProfile targetRecord = this.lvWaitToOrderSWRList.SelectedItems[0].Tag as SWRProfile;
                if (targetID == null || targetRecord == null)
                {
                    return;
                }

                // 메인에 전달
                if (this.NotifyUpdateSWRAssociationState != null)
                {
                    this.Visible = false;
                    this.NotifyUpdateSWRAssociationState(this, new UpdateSWRAssociationStateEventArgs(targetID, SWRAssociationStateCode.Order, targetRecord));
                    this.Close();
                }
                else
                {
                    DialogResult result = MessageBox.Show("발령 처리에서 오류가 발생하였습니다. \n errorCode=[-1]", "발령 실패", MessageBoxButtons.OK);
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[WaitToOrderForm] btnOrder_Click( Exception: \n" + ex.ToString() + ")");
                FileLogManager.GetInstance().WriteLog("[WaitToOrderForm] btnOrder_Click( Exception=[" + ex.ToString() + "] )");
            }
        }
Пример #14
0
        /// <summary>
        /// [선택 항목 연계 제외] 버튼 클릭.
        /// 연계 발령이 불필요한 경우, 항목 삭제를 통해 제외 시킨다.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.lvWaitToOrderSWRList.SelectedItems == null || this.lvWaitToOrderSWRList.SelectedItems.Count <= 0)
                {
                    return;
                }
                string targetID = this.lvWaitToOrderSWRList.SelectedItems[0].Name;
                this.lvWaitToOrderSWRList.Items.Remove(this.lvWaitToOrderSWRList.SelectedItems[0]);

                if (targetID == null)
                {
                    return;
                }

                // 메인에 전달
                if (this.NotifyUpdateSWRAssociationState != null)
                {
                    this.NotifyUpdateSWRAssociationState(this, new UpdateSWRAssociationStateEventArgs(targetID, SWRAssociationStateCode.Exclude, null));
                }

                // 현 윈도우를 종료
                if (this.lvWaitToOrderSWRList.Items.Count <= 0)
                {
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[WaitToOrderForm] btnDelete_Click( Exception: \n" + ex.ToString() + ")");
                FileLogManager.GetInstance().WriteLog("[WaitToOrderForm] btnDelete_Click( Exception=[" + ex.ToString() + "] )");
            }
        }
Пример #15
0
        /// <summary>
        /// 리스트 아이템 더블클릭.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lvWaitToOrderSWRList_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                AdengListView view = sender as AdengListView;
                if (view == null || view.SelectedItems == null || view.SelectedItems.Count <= 0)
                {
                    return;
                }
                AdengListViewItem item = view.SelectedItems[0];
                if (item == null)
                {
                    return;
                }

                SWRProfile profile = item.Tag as SWRProfile;
                if (profile == null)
                {
                    return;
                }

                SWRWarningItemDetailForm detailForm = new SWRWarningItemDetailForm(profile);
                detailForm.ShowDialog(this);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[WaitToOrderForm] lvWaitToOrderSWRList_DoubleClick( Exception: \n" + ex.ToString() + ")");
                FileLogManager.GetInstance().WriteLog("[WaitToOrderForm] lvWaitToOrderSWRList_DoubleClick( Exception=[" + ex.ToString() + "] )");
            }
        }
Пример #16
0
        /// <summary>
        /// 게이트웨이로 데이터동기화의 동기 처리 결과 메시지 전송.
        /// </summary>
        public bool SendResultOfSASProfileUpdate(uint requestEventID, int updateResult)
        {
            bool result = false;

            try
            {
                SyncResult syncResult = SyncResult.Success;
                if (updateResult != 0)
                {
                    syncResult = SyncResult.Fail;
                }

                SYNCProtocolBase protoBase = IEASProtocolManager.CreateProtocolForSYNC(SYNCCmdValue.SyncResult);
                SYNCPrtCmd13     cmd13     = protoBase as SYNCPrtCmd13;
                cmd13.Result     = syncResult;
                cmd13.Identifier = requestEventID;
                byte[] frameData = IEASProtocolManager.MakeFrameForSYNC(cmd13);

                result = this.sessionManager.SendData(frameData);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[CommunicationManager] SendResultOfSASProfileUpdate( " + ex.ToString() + " )");
                FileLogManager.GetInstance().WriteLog("[CommunicationManager] SendResultOfSASProfileUpdate( Exception=[" + ex.ToString() + "] )");

                return(false);
            }
            return(result);
        }
Пример #17
0
        /// <summary>
        /// 게이트웨이 연결 상태 감시 쓰레딩 시작.
        /// </summary>
        public int StartConnectionSupervisory()
        {
            System.Console.WriteLine("[CommunicationManager] 게이트웨이 연결 상태 감시 시작");

            try
            {
                if (this.pollingThread == null)
                {
                    PrepareConnectionSupervisory();
                }

                this.isPollingContinue = true;

                if (this.manualEvtPolling == null)
                {
                    this.manualEvtPolling = new ManualResetEvent(false);
                }
                this.manualEvtPolling.Set();
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[CommunicationManager] StartConnectionSupervisory( " + ex.ToString() + " )");
                FileLogManager.GetInstance().WriteLog("[CommunicationManager] StartConnectionSupervisory( Exception=[" + ex.ToString() + "] )");

                return(-99);
            }

            return(0);
        }
Пример #18
0
        /// <summary>
        /// DB 접속
        /// </summary>
        /// <returns>접속 수행 결과</returns>
        public bool TestOpenDB(ConfigDBData dbInfo)
        {
            bool result = false;

            try
            {
                // 내부적으로 생성/연결된 컨넥션이 내부 멤버 오브젝트를 Dispose로 삭제해도
                // 실시간으로 삭제되지 않아 컨넥션이 계속해서 남아있는 문제가 있음.
                // 그래서 상위에서 매번 new 해서 새로운 오브젝트를 생성해야할 필요가 있다.
                this.oracleDB = new AdengOracleDbEx();

                this.oracleDB.OpenOracle(dbInfo.HostIP, dbInfo.ServiceID, dbInfo.UserID, dbInfo.UserPassword);
                result = this.oracleDB.IsOpen;
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[DBConnector] TestOpenDB( " + ex.ToString() + " )");
                FileLogManager.GetInstance().WriteLog("[DBConnector] TestOpenDB ( Exception=[" + ex.ToString() + "] )");

                return(false);
            }
            finally
            {
                if (this.oracleDB.IsOpen)
                {
                    this.oracleDB.Close();
                }
                this.oracleDB = null;
            }

            return(result);
        }
Пример #19
0
        /// <summary>
        /// DB 접속
        /// </summary>
        /// <returns>접속 수행 결과</returns>
        public bool OpenDB()
        {
            bool isOpen = false;

            try
            {
                // 내부적으로 생성/연결된 컨넥션이 내부 멤버 오브젝트를 Dispose로 삭제해도
                // 실시간으로 삭제되지 않아 컨넥션이 계속해서 남아있는 문제가 있음.
                // 그래서 상위에서 매번 new 해서 새로운 오브젝트를 생성해야할 필요가 있다.
                this.oracleDB = new AdengOracleDbEx();
                this.oracleDB.OpenOracle(this.targetHostIP, this.targetSID, this.targetUserID, this.targetUserPWD);

                isOpen = this.oracleDB.IsOpen;
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[DBConnector] OpenDB( " + ex.ToString() + " )");
                FileLogManager.GetInstance().WriteLog("[DBConnector] OpenDB ( Exception=[" + ex.ToString() + "] )");

                isOpen = false;

                if (this.oracleDB.IsOpen)
                {
                    this.oracleDB.Close();
                }
                this.oracleDB = null;
            }

            return(isOpen);
        }
Пример #20
0
        /// <summary>
        /// 소켓 연결 이벤트
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void socket_OnOpen(object sender, AdengConnectEvtArgs e)
        {
            System.Console.WriteLine("[SessionManager] socket_OnOpen(Connected=" + e.Connected.ToString() + ")");
            FileLogManager.GetInstance().WriteLog("[SessionManager] socket_OnOpen( e.Connected=[" + e.Connected.ToString() + "] )");

            try
            {
                if (e.Connected)
                {
                    if (this.NotifyConnected != null)
                    {
                        this.NotifyConnected(this, new ConnectEvtArgs(e.ClientSocket));
                    }
                }
                else
                {
                    if (this.NotifyDisconnected != null)
                    {
                        this.NotifyDisconnected(this, new ConnectEvtArgs(e.ClientSocket));
                    }
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[SessionManager] socket_OnOpen (Exception Occured!! \n " + ex.ToString());
                FileLogManager.GetInstance().WriteLog("[SessionManager] socket_OnOpen( " + ex.ToString() + " )");
            }
        }
Пример #21
0
        /// <summary>
        /// 수신 데이터 처리 (쓰레드 호출용 함수)
        /// </summary>
        private void ReceiveDataProcessing()
        {
            try
            {
                if (this.manualEvtReceiveData == null)
                {
                    this.manualEvtReceiveData = new ManualResetEvent(false);
                }

                while (this.isReceivedDataProcessingContinue)
                {
                    int count = 0;
                    lock (this.receivedPacketQueue)
                    {
                        count = this.receivedPacketQueue.Count;
                    }
                    if (count <= 0)
                    {
                        this.manualEvtReceiveData.WaitOne();
                        this.manualEvtReceiveData.Reset();

                        continue;
                    }

                    byte[] buffData = null;
                    lock (this.receivedPacketQueue)
                    {
                        buffData = this.receivedPacketQueue.Dequeue();
                    }

                    ParsingQueuingData(buffData);
                }
            }
            catch (ThreadAbortException ex)
            {
                System.Console.WriteLine("[CommunicationManager] ReceiveDataProcessing( Exception=[ ThreadAbortException ] )");
                FileLogManager.GetInstance().WriteLog("[CommunicationManager] ReceiveDataProcessing( Exception=[ ThreadAbortException ] )");

                Thread.ResetAbort();
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[CommunicationManager] ReceiveDataProcessing (Exception=[" + ex.ToString() + "] )");
                FileLogManager.GetInstance().WriteLog("[CommunicationManager] ReceiveDataProcessing( Exception=[" + ex.ToString() + "] )");

                throw new Exception("[CommunicationManager] CAP/동기화 데이터 처리 중에 예외가 발생하였습니다.");
            }
            finally
            {
                FileLogManager.GetInstance().WriteLog("[CommunicationManager] ReceiveDataProcessing( 종료 )");

                this.isReceivedDataProcessingContinue = false;
                if (this.manualEvtReceiveData != null)
                {
                    this.manualEvtReceiveData.Close();
                    this.manualEvtReceiveData = null;
                }
            }
        }
Пример #22
0
        /// <summary>
        /// 리스트 갱신.
        /// </summary>
        private void UpdateReportList()
        {
            try
            {
                this.lvWaitToOrderSWRList.Items.Clear();
                if (this.currentWaitingList == null || this.currentWaitingList.Count <= 0)
                {
                    return;
                }

                CAPHelper helper = new CAPHelper();
                foreach (SWRProfile profile in this.currentWaitingList)
                {
                    if (profile == null)
                    {
                        continue;
                    }
                    SWRWarningItemProfile warningItem = profile.GetWarningItemProfile();
                    if (warningItem == null)
                    {
                        continue;
                    }

                    // ReportId: 특보 아이디
                    AdengListViewItem newItem = this.lvWaitToOrderSWRList.Items.Add(warningItem.ReportID);

                    // AnnounceTime: 발표 시각
                    newItem.SubItems.Add(warningItem.AnnounceTime.ToString());

                    // AreaName: 특보 구역
                    string targetAreaNames = profile.GetTargetAreaNames();
                    if (!string.IsNullOrEmpty(targetAreaNames))
                    {
                        newItem.SubItems.Add(targetAreaNames);
                    }
                    else
                    {
                        newItem.SubItems.Add("Unknown(" + profile.TargetAreas + ")");
                    }

                    // WarnKind: 특보 종류
                    string kind   = BasisData.FindSWRKindStringByKindCode(profile.WarnKindCode);
                    string stress = BasisData.FindSWRStressStringByStressCode(profile.WarnStressCode);
                    newItem.SubItems.Add(kind + " " + stress);

                    // CommandCode: 발표 코드
                    string command = BasisData.FindSWRCommandStringByCommandCode(profile.CommandCode);
                    newItem.SubItems.Add(command);

                    newItem.Name = profile.ID;
                    newItem.Tag  = profile;
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[WaitToOrderForm] UpdateReportList( Exception: \n" + ex.ToString() + ")");
                FileLogManager.GetInstance().WriteLog("[WaitToOrderForm] UpdateReportList( Exception=[" + ex.ToString() + "] )");
            }
        }
Пример #23
0
        /// <summary>
        /// 기상특보 웹서비스 접속 정보 설정
        /// </summary>
        /// <param name="info"></param>
        public void SetConnectionInfo(ConfigSWRData info)
        {
            System.Diagnostics.Debug.Assert(info != null);
            FileLogManager.GetInstance().WriteLog("[SWRServiceManager] SetConnectionInfo( )");

            this.currentServiceKey = info.ServiceKey;
            this.requestCycleBySec = (uint)(info.CycleTimeMinute * 60);
        }
Пример #24
0
        /// <summary>
        /// 대상지(서버)와 연결
        /// </summary>
        /// <returns></returns>
        public bool Connect()
        {
            FileLogManager.GetInstance().WriteLog("[SessionManager] Connect( start )");

            bool result = true;

            try
            {
                if (socket != null && !socket.Connected)
                {
                    FileLogManager.GetInstance().WriteLog("[SessionManager] Connect( 통신 끊긴 상태=> 이벤트를 해제, 소켓 닫음 )");

                    // 끊긴 상태
                    this.socket.connectEvtHandler -= new ConnectEvtHandler(socket_OnOpen);
                    this.socket.closeEvtHandler   -= new CloseEvtHandler(socket_OnClose);
                    this.socket.recvEvtHandler    -= new RecvEvtHandler(socket_OnReceive);
                    this.socket.Close();
                    this.socket = null;

                    return(false);
                }

                if (this.socket == null)
                {
                    FileLogManager.GetInstance().WriteLog("[SessionManager] Connect( 소켓이 존재하지 않음 => 소켓 생성 )");

                    this.socket = new AdengClientSocket();
                    this.socket.connectEvtHandler += new ConnectEvtHandler(socket_OnOpen);
                    this.socket.closeEvtHandler   += new CloseEvtHandler(socket_OnClose);
                    this.socket.recvEvtHandler    += new RecvEvtHandler(socket_OnReceive);
                }

                if (!this.socket.Connected)
                {
                    this.socket.Connect(this.targetIP, this.targetPort);
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[SessionManager] Connect( " + ex.ToString() + ")");
                FileLogManager.GetInstance().WriteLog("[SessionManager] Connect( " + ex.ToString() + " )");

                if (socket != null)
                {
                    if (this.socket.Connected)
                    {
                        Disconnect();
                    }
                }

                result = false;
                throw ex;
            }

            FileLogManager.GetInstance().WriteLog("[SessionManager] Connect( end )");

            return(result);
        }
Пример #25
0
        /// <summary>
        /// 큐에 저장된 패킷 데이터를 프레임 단위로 파싱.
        /// </summary>
        private int ParsingQueuingData(byte[] queuingData)
        {
            try
            {
                if (queuingData == null)
                {
                    System.Console.WriteLine("[CommunicationManager] 파싱 실패 : 입력 파라미터가 널");
                    return(-1);
                }

                AnalyzeResult frameResult = IEASProtocolManager.AnalyzeFrame(this.remainderPacket, queuingData);
                if (frameResult == null || frameResult.FrameInfo == null)
                {
                    System.Console.WriteLine("[CommunicationManager] 파싱 실패 : 입력 파라미터가 널");
                    return(-2);
                }

                // 프레임을 분리하고 남은 불완전 데이터를 남은데이터 보관 버퍼(로컬)에 저장
                this.remainderPacket = null;
                if (frameResult.RemainderFrame != null && frameResult.RemainderFrame.Length > 0)
                {
                    this.remainderPacket = new byte[frameResult.RemainderFrame.Length];
                    Buffer.BlockCopy(frameResult.RemainderFrame, 0, this.remainderPacket, 0, frameResult.RemainderFrame.Length);
                }

                // 파싱 실패 체크: 프레임 단위로 분리할 만한 데이터 크기가 아닌 경우 등
                if (frameResult.FrameInfo.Count == 0)
                {
                    System.Console.WriteLine("[CommunicationManager] 프레임 분리 실패(길이 부족 등)");
                    return(-3);
                }

                for (int index = 0; index < frameResult.FrameInfo.Count; index++)
                {
                    Frame currentFrame = frameResult.FrameInfo[index];
                    if (currentFrame.HeaderKind == HeaderKind.KCAP)
                    {
                        IEASProtocolBase baseData = IEASProtocolManager.ParseFrameForKCAP(currentFrame.Data);
                        DistributeKCAPCommandData(baseData.CmdValue, baseData);
                    }
                    else
                    {
                        SYNCProtocolBase baseData = IEASProtocolManager.ParseFrameForSYNC(currentFrame.Data);
                        DistributeSYNCCommandData(baseData.CmdValue, baseData);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[CommunicationManager] ParsingQueuingData( " + ex.ToString() + " )");
                FileLogManager.GetInstance().WriteLog("[CommunicationManager] ParsingQueuingData( Exception=[" + ex.ToString() + "] )");

                return(-99);
            }

            return(0);
        }
Пример #26
0
        public void OnNotifyOrderResponseUpdated(object sender, OrderResponseEventArgs e)
        {
            try
            {
                MethodInvoker invoker = delegate()
                {
                    System.Console.WriteLine("[InquiryHistoryForm] OnNotifyOrderResponseUpdated ( 응답 수신 )");
                    FileLogManager.GetInstance().WriteLog("[InquiryHistoryForm] OnNotifyOrderResponseUpdated( 응답 수신 )");

                    if (this.orderDetailForm == null || this.orderDetailForm.IsDisposed)
                    {
                        System.Console.WriteLine("[InquiryHistoryForm] OnNotifyOrderResponseUpdated ( 상세 표시 중이 아님. )");
                        FileLogManager.GetInstance().WriteLog("[InquiryHistoryForm] OnNotifyOrderResponseUpdated( 상세 표시 중이 아님. )");

                        return;
                    }
                    if (this.lvOrderHistory.SelectedItems == null || this.lvOrderHistory.SelectedItems.Count < 1)
                    {
                        System.Console.WriteLine("[InquiryHistoryForm] OnNotifyOrderResponseUpdated ( 선택된 아이템이 없음 )");
                        FileLogManager.GetInstance().WriteLog("[InquiryHistoryForm] OnNotifyOrderResponseUpdated( 선택된 아이템이 없음 )");

                        return;
                    }
                    OrderRecord selectedRecord = this.lvOrderHistory.SelectedItems[0].Tag as OrderRecord;
                    if (selectedRecord == null)
                    {
                        System.Console.WriteLine("[InquiryHistoryForm] OnNotifyOrderResponseUpdated ( 선택된 아이템의 데이터 변환 오류 )");
                        FileLogManager.GetInstance().WriteLog("[InquiryHistoryForm] OnNotifyOrderResponseUpdated( 선택된 아이템의 데이터 변환 오류 )");

                        return;
                    }
                    if (e.ResponseInfo == null || e.ResponseInfo.Count < 1 || selectedRecord.CAPID != e.OrderRecordID)
                    {
                        System.Console.WriteLine("[InquiryHistoryForm] OnNotifyOrderResponseUpdated ( 상세 표시 중인 레코드와 응답 레코드가 다름 )");
                        FileLogManager.GetInstance().WriteLog("[InquiryHistoryForm] OnNotifyOrderResponseUpdated( 상세 표시 중인 레코드와 응답 레코드가 다름 )");

                        return;
                    }

                    this.orderDetailForm.UpdateOrderResponseInfo(e.ResponseInfo);
                };

                if (this.InvokeRequired)
                {
                    Invoke(invoker);
                }
                else
                {
                    invoker();
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[RecentlyOrderHistoryForm] OnNotifyOrderResponseUpdated ( Exception Occured!!!" + ex.ToString() + ")");
                FileLogManager.GetInstance().WriteLog("[InquiryHistoryForm] OnNotifyOrderResponseUpdated( " + ex.ToString() + " )");
            }
        }
Пример #27
0
 /// <summary>
 /// 싱글톤 처리.
 /// 반드시 이 메소드를 호출하여 인스턴스를 사용해야 하며,
 /// WriteLog 호출로 인스턴스가 종료된다.
 /// </summary>
 /// <returns></returns>
 public static FileLogManager GetInstance()
 {
     mutex.WaitOne();
     if (instance == null)
     {
         instance = new FileLogManager();
     }
     return(instance);
 }
Пример #28
0
        public void UpdateSWRList(List <SWRProfile> waitingList)
        {
            try
            {
                MethodInvoker invoker = delegate()
                {
                    // 현재 선택된 아이템을 백업
                    string selectedItemName = string.Empty;
                    if (this.lvWaitToOrderSWRList.SelectedItems != null && this.lvWaitToOrderSWRList.SelectedItems.Count > 0)
                    {
                        selectedItemName = this.lvWaitToOrderSWRList.SelectedItems[0].Text;
                    }

                    // 로컬 리스트 클리어
                    if (this.currentWaitingList == null)
                    {
                        this.currentWaitingList = new List <SWRProfile>();
                    }
                    this.currentWaitingList.Clear();

                    // 새 데이터로 변경
                    foreach (SWRProfile profile in waitingList)
                    {
                        SWRProfile copy = new SWRProfile();
                        copy.DeepCopyFrom(profile);

                        this.currentWaitingList.Add(copy);
                    }

                    // 리스트 갱신
                    UpdateReportList();

                    // 원래 선택했던 아이템 재선택 처리
                    if (this.lvWaitToOrderSWRList.Items != null && !string.IsNullOrEmpty(selectedItemName))
                    {
                        if (this.lvWaitToOrderSWRList.Items.ContainsKey(selectedItemName))
                        {
                            this.lvWaitToOrderSWRList.Items[selectedItemName].Selected = true;
                        }
                    }
                };
                if (this.InvokeRequired)
                {
                    Invoke(invoker);
                }
                else
                {
                    invoker();
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[WaitToOrderForm] UpdateSWRList( Exception: \n" + ex.ToString() + ")");
                FileLogManager.GetInstance().WriteLog("[WaitToOrderForm] UpdateSWRList( Exception=[" + ex.ToString() + "] )");
            }
        }
Пример #29
0
        /// <summary>
        /// 게이트웨이로 개별 해쉬키 체크 결과 전송.
        /// 전체 해쉬키가 불일치일 때만 개별해쉬키 체크가 수행되므로, 불일치 프로필 아이디가 널인 경우는 논리적으로는 있을 수 없다.
        /// </summary>
        public bool SendResultOfCheckSingleHashKey(uint requestEventID, List <string> lstProfileID)
        {
            System.Console.WriteLine("[CommunicationManager] SendResultOfCheckSingleHashKey (requestEventID=[" + requestEventID + "])");

            bool sendResult = true;

            try
            {
                if (lstProfileID == null || lstProfileID.Count <= 0)
                {
                    System.Console.WriteLine("[ERROR] 모든 데이터가 동기화된 상태!!!");

                    // 빈 패킷이라도 보내야 하나?
                }
                else
                {
                    uint totalCount = (uint)(lstProfileID.Count());
                    uint currentNo  = 1;
                    foreach (string profileID in lstProfileID)
                    {
                        SYNCProtocolBase protoBase = IEASProtocolManager.CreateProtocolForSYNC(SYNCCmdValue.ChkSingleHashResult);
                        SYNCPrtCmd12     cmd12     = protoBase as SYNCPrtCmd12;
                        cmd12.Identifier = requestEventID;
                        cmd12.TotalCount = totalCount;
                        cmd12.Num        = currentNo++;
                        cmd12.ProfileID  = profileID;

                        byte[] frameData = IEASProtocolManager.MakeFrameForSYNC(cmd12);

                        bool result = this.sessionManager.SendData(frameData);
                        if (!result)
                        {
                            System.Console.WriteLine("패킷 전송 실패(currentNo=" + currentNo + ")");
                            sendResult = false;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("[CommunicationManager] SendResultOfCheckSingleHashKey( " + ex.ToString() + " )");
                FileLogManager.GetInstance().WriteLog("[CommunicationManager] SendResultOfCheckSingleHashKey( Exception=[" + ex.ToString() + "] )");

                return(false);
            }

            System.Console.WriteLine("[CommunicationManager] SendResultOfCheckSingleHashKey (sendResult=[" + sendResult.ToString() + "])");

            return(sendResult);
        }
Пример #30
0
        /// <summary>
        /// [전체 복원] 버튼 클릭 이벤트 핸들러.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRestoreAll_Click(object sender, EventArgs e)
        {
            try
            {
                if (BasisData.BasicMsgTextInfo == null || BasisData.BasicMsgTextInfo.Values == null)
                {
                    MessageBox.Show("기본 문안 정보가 존재하지 않습니다. 요청을 진행할 수 없습니다.",
                                    "전체 문안 복원 오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                DialogResult answer = MessageBox.Show("등록된 모든 문안의 설정이 시스템 초기 상태로 복원되며, 시스템에 따라 수 분 정도 소요됩니다. \n초기화 하시겠습니까?",
                                                      "전체 문안 복원", MessageBoxButtons.YesNo);
                if (answer != System.Windows.Forms.DialogResult.Yes)
                {
                    return;
                }

                this.Cursor = Cursors.WaitCursor;

                List <MsgText> basicMsgs = new List <MsgText>();
                foreach (DisasterMsgText basicMsg in BasisData.BasicMsgTextInfo.Values)
                {
                    basicMsgs.Add(basicMsg.MsgTxt);
                }
                int result = DBManager.GetInstance().UpdateTransmitMsgText(basicMsgs);
                if (result == 0)
                {
                    BasisData.TransmitMsgTextInfo = DBManager.GetInstance().QueryTransmitMsgTextInfo(null);

                    UpdateTextData();

                    MessageBox.Show("모든 문안 정보를 시스템 초기 상태로 복원하였습니다.", "문안 복원", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("문안 복원 중에 오류가 발생하여 복원에 실패하였습니다. ErrorCode=[" + result + "]",
                                    "전체 문안 복원 실패", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                FileLogManager.GetInstance().WriteLog("[MsgTextManaerForm] 전체 문안 초기화 오류( Exception=[" + ex.ToString() + "] )");
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }