/// <summary> /// Kijelölt üzenetek törlése. /// </summary> public void RemoveSelectedMessage() { var current = 0; this.RaiseListChangedEvents = false; try { foreach (var item in SelectedItems) { RemoveMessage(item.Index); Remove(item); if (current % 20 == 0) { OnProgressChanged(this, new ProgressChangedEventArgs((int)((current / (double)SelectedItems.Count) * 100), "Deleting: " + item.ToString())); } current++; } OnProgressChanged(this, new ProgressChangedEventArgs(100, "Deleting Complete...")); } catch (Exception ex) { AppDiagService.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name + "=>" + "ERROR" + " " + ex.Message); OnProgressChanged(this, new ProgressChangedEventArgs(100, "Deleting Failed...")); throw ex; } finally { this.RaiseListChangedEvents = true; this.ResetBindings(); ((LogFileMessageStatistics)_statistics).RiseChanged(); } }
protected override void OnClick(EventArgs e) { base.OnClick(e); if (Enabled) { try { _view.LogGrid.AllowClick = false; (_view.LogGrid.Source as ILogFileMessageCollection).RemoveSelectedMessage(); } catch (Exception ex) { #if TRACE AppDiagService.WriteLine(this.GetType().Namespace + "." + this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + "=>" + "ERROR" + " " + ex.Message); #endif throw ex; } finally { _view.LogGrid.AllowClick = true; } } }
protected override void OnClick(EventArgs e) { base.OnClick(e); #if TRACE AppDiagService.WriteLine(this.GetType().Namespace + "." + this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()"); #endif _logs.Load(_storage.Loaction, _storage.FileName); }
/// <summary> /// Az erőforrásbó string megszerzésee név alapján. /// </summary> /// <param name="name"></param> /// <returns></returns> public string GetString(string name) { var str = string.Empty; try { str = _resource.GetString(name); } catch { AppDiagService.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name + "=>" + "ERROR" + " " + "Culture Not found Resource for: [" + name + "]"); str = name; } return(str); }
/// <summary> /// Load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OptionsAboutView_Load(object sender, EventArgs e) { AppDiagService.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name); labelCompanyName.Text = String.Format("{0}", Application.CompanyName); labelProductName.Text = String.Format("Prdouct: {0}", Application.ProductName); labelProductVersion.Text = "Version: " + Application.ProductVersion; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); string line = string.Empty; foreach (var asm in assemblies) { AssemblyName asmName = asm.GetName(); line = asmName.Name + " Version:" + asmName.Version; richTextBox1.AppendText(line, Color.LightBlue, true); } }
/// <summary> /// Ütemesen nézzük mi a helyzet az adapterrel /// </summary> private void DoWork() { _isRunning = true; Exception loopException = null; { /*SynContext*/ Action doMehtod = () => OnStarted(); if (App.SyncContext != null) { App.SyncContext.Post((e1) => { doMehtod(); }, null); } else { doMehtod(); } } do { if (_adapter != null && _adapter.IsConnected) { if (_adapter.LasException != null) { Debug.WriteLine(GetType().Namespace + "." + GetType().Name + "." + MethodBase.GetCurrentMethod().Name + "(): DoWork is now shutdown by Adapter LastException is not null."); loopException = _adapter.LasException; break; } /* * TODO: Ezt megcsinálni a ToolTable-re is * if (_messageSenders.LastException != null) * { * Debug.WriteLine(GetType().Namespace + "." + GetType().Name + "." + MethodBase.GetCurrentMethod().Name + "(): DoWork is now shutdown by MessageSender LastException is not null."); * loopException = _messageSenders.LastException; * break; * } */ try { #region CAN Adapter Funcitons if (_txQueue.Count > 0) { var tx = _txQueue.Dequeue(); var txTimestamp = DateTime.Now; var txTrace = new MessageTraceItem( name: tx.Name, timestamp: txTimestamp, direction: MessageDirection.Transmitted, type: tx.Type, remote: tx.Remote, arbitrationId: tx.ArbitrationId, data: tx.Data, documentation: tx.Documentation, description: tx.Description); _adapter.Write(new[] { new CanMessage( isRemote: tx.Remote ? (byte)0x01 : (byte)0x00b, arbitrationId: (tx.Type == ArbitrationIdType.Standard) ? tx.ArbitrationId : tx.ArbitrationId | 0x20000000, data: tx.Data) }); if (!_paramters.FiltersEnabled || _filters.DoAddToTrace( arbitrationId: tx.ArbitrationId, type: tx.Type, remote: tx.Remote, direction: MessageDirection.Transmitted)) { if (_project.Parameters.TraceEnabled) { _messageTrace.Add(txTrace); } } if (!_paramters.FiltersEnabled || _filters.DoAddToLog( arbitrationId: tx.ArbitrationId, type: tx.Type, remote: tx.Remote, direction: MessageDirection.Transmitted)) { if (_project.Parameters.LogEnabled) { _log.Messages.AddToStorage( name: tx.Name, timestamp: txTimestamp, direction: MessageDirection.Transmitted, type: tx.Type, arbitrationId: tx.ArbitrationId, isRemote: tx.Remote, data: tx.Data, documentation: tx.Documentation, description: tx.Description); } } if (_project.Parameters.MessageStatisticsEnabled) { Action doMehtod = () =>/*SynContext*/ { _messageStat.InsertMessage( name: tx.Name, direction: MessageDirection.Transmitted, type: tx.Type, arbitrationId: tx.ArbitrationId, data: tx.Data, remote: tx.Remote, timestamp: txTimestamp); }; if (App.SyncContext != null) { App.SyncContext.Post((e1) => { doMehtod(); }, null); } else { doMehtod(); } } } if (_adapter.Attributes.PendingRxMessages > 0) { var rxItems = new CanMessage[1]; _adapter.Read(rxItems, 0, 1); var rxType = ((rxItems[0].ArbitrationId & 0x20000000) == 0) ? ArbitrationIdType.Standard : ArbitrationIdType.Extended; var rxArbId = unchecked (rxItems[0].ArbitrationId & (uint)(~0x20000000)); var rxIsRmote = rxItems[0].IsRemote != 0 ? true : false; var rxTimestamp = new DateTime(rxItems[0].TimestampTick); var rxData = rxItems[0].Data; var rxName = string.Empty; var rxDocumentation = string.Empty; var rxDescription = string.Empty; /* * TODO: Ezt megcsinálni * if (_paramters.RxMsgResolvingBySenderEnabled) * { * var resolvedRxMsg = _messageSenders.GetMsg(rxArbId, rxType, rxIsRmote); * if (resolvedRxMsg != null) * { * rxName = resolvedRxMsg.Name; * rxDocumentation = resolvedRxMsg.Documentation; * rxDescription = resolvedRxMsg.Description; * } * } */ var rxTrace = new MessageTraceItem( name: rxName, timestamp: rxTimestamp, direction: MessageDirection.Received, type: rxType, remote: rxIsRmote, arbitrationId: rxArbId, data: rxData, documentation: rxDocumentation, description: rxDescription); if (!_paramters.FiltersEnabled || _filters.DoAddToTrace( arbitrationId: rxArbId, type: rxType, remote: rxIsRmote, direction: MessageDirection.Received)) { if (_paramters.TraceEnabled) { _messageTrace.Add(rxTrace); } } if (!_paramters.FiltersEnabled || _filters.DoAddToLog( arbitrationId: rxArbId, type: rxType, remote: rxIsRmote, direction: MessageDirection.Received)) { if (_paramters.LogEnabled) { _log.Messages.AddToStorage( name: rxName, timestamp: rxTimestamp, direction: MessageDirection.Received, type: rxType, arbitrationId: rxArbId, isRemote: rxIsRmote, data: rxData, documentation: rxDocumentation, description: rxDescription); } } if (_paramters.MessageStatisticsEnabled) { Action doMehtod = () =>/*SynContext*/ { _messageStat.InsertMessage( name: rxName, direction: MessageDirection.Received, type: rxType, arbitrationId: rxArbId, data: rxData, remote: rxIsRmote, timestamp: rxTimestamp); }; if (App.SyncContext != null) { App.SyncContext.Post((e1) => { doMehtod(); }, null); } else { doMehtod(); } } } if (_paramters.AdapterStatisticsEnabled) { /*Statiszitikai az adapter követi. Az értkékeket időnként le kell kérdezni tőle.*/ /*Az adapter leállítását követően még egyszer LE KELL KÉRDEZNI, hogy az UI-n az UTOLSÓ érték látszódjon.*/ long nowDateTimeTicks = DateTime.Now.Ticks; if ((nowDateTimeTicks - _statusUpdateTimestamp) > 10000 * 1000) { AppDiagService.WriteLine(GetType().Namespace + "." + GetType().Name + "." + MethodBase.GetCurrentMethod().Name + "(): Adapter Staistics Poll Now... DiffTime: " + ((DateTime.Now.Ticks - _statusUpdateTimestamp) / 10000).ToString("N4") + "ms"); _statusUpdateTimestamp = nowDateTimeTicks; _adapterStat.UpdateReceived( total: _adapter.Attributes.RxTotal, drop: _adapter.Attributes.RxDrop, error: _adapter.Attributes.RxErrorCounter, pending: _adapter.Attributes.PendingRxMessages); _adapterStat.UpdateTransmitted( total: _adapter.Attributes.TxTotal, drop: _adapter.Attributes.TxDrop, error: _adapter.Attributes.TxErrorCounter, pending: _txQueue.Count); } } #endregion } catch (Exception ex) { Debug.WriteLine(GetType().Namespace + "." + GetType().Name + "." + MethodBase.GetCurrentMethod().Name + "(): DoWork is now shutdown by Loop Fuction Exception."); loopException = ex; break; } } else { try { #region Virtual CAN Adapter Funcitions /*Virtuaális adapter*/ if (_txQueue.Count > 0) { _virtualAdapterFrameCounter++; var tx = _txQueue.Dequeue(); var txTrace = new MessageTraceItem( name: tx.Name, timestamp: DateTime.Now, direction: MessageDirection.Transmitted, type: tx.Type, remote: tx.Remote, arbitrationId: tx.ArbitrationId, data: tx.Data, documentation: tx.Documentation, description: tx.Description); if (!_paramters.FiltersEnabled || _filters.DoAddToTrace( arbitrationId: tx.ArbitrationId, type: tx.Type, remote: tx.Remote, direction: MessageDirection.Transmitted)) { if (_paramters.TraceEnabled) { _messageTrace.Add(txTrace); } } if (!_paramters.FiltersEnabled || _filters.DoAddToLog( arbitrationId: tx.ArbitrationId, type: tx.Type, remote: tx.Remote, direction: MessageDirection.Transmitted)) { if (_project.Parameters.LogEnabled) { _log.Messages.AddToStorage( name: tx.Name, timestamp: DateTime.Now, direction: MessageDirection.Transmitted, type: tx.Type, arbitrationId: tx.ArbitrationId, isRemote: tx.Remote, data: tx.Data, documentation: tx.Documentation, description: tx.Description); } } if (_paramters.MessageStatisticsEnabled) { Action doMehtod = () => { _messageStat.InsertMessage( name: tx.Name, direction: MessageDirection.Transmitted, type: tx.Type, arbitrationId: tx.ArbitrationId, data: tx.Data, remote: tx.Remote, timestamp: DateTime.Now); }; if (App.SyncContext != null) { App.SyncContext.Post((e1) => { doMehtod(); }, null); } else { doMehtod(); } } } if (_paramters.AdapterStatisticsEnabled) { /*Statiszitikai az adapter követi. Az értkékeket időnként le kell kérdezni tőle.*/ /*Az adapter leállítását követően még egyszer LE KELL KÉRDEZNI, hogy az UI-n az UTOLSÓ érték látszódjon.*/ long nowDateTimeTicks = DateTime.Now.Ticks; if ((nowDateTimeTicks - _statusUpdateTimestamp) > 10000 * 1000) { AppDiagService.WriteLine(GetType().Namespace + "." + GetType().Name + "." + MethodBase.GetCurrentMethod().Name + "(): Virtual Adapter Staistics Poll Now... DiffTime: " + ((DateTime.Now.Ticks - _statusUpdateTimestamp) / 10000).ToString("N4") + "ms"); _statusUpdateTimestamp = nowDateTimeTicks; _adapterStat.UpdateTransmitted( total: _virtualAdapterFrameCounter, drop: 0, error: 0, pending: _txQueue.Count); } } #endregion } catch (Exception ex) { Debug.WriteLine(GetType().Namespace + "." + GetType().Name + "." + MethodBase.GetCurrentMethod().Name + "(): DoWork is now shutdown by Loop Fuction Exception."); loopException = ex; break; } } if (_shutdownEvent.WaitOne(0)) { Debug.WriteLine(GetType().Namespace + "." + GetType().Name + "." + MethodBase.GetCurrentMethod().Name + "(): DoWork is now shutdown!"); break; } } while (_isRunning); /*Probléma megjelnítése*/ if (loopException != null) { new ErrorHandlerService().Show(loopException); } #region Update Last State if (loopException == null) { /*Csak ha nem volt gebasz az adapterrel...*/ if (_paramters.DeviceName != VirtualDeviceName && _adapter.IsConnected) { /*Statisztika lefrissítése az UI-nak*/ _adapterStat.UpdateReceived( total: _adapter.Attributes.RxTotal, drop: _adapter.Attributes.RxDrop, error: _adapter.Attributes.RxErrorCounter, pending: _adapter.Attributes.PendingRxMessages); _adapterStat.UpdateTransmitted( total: _adapter.Attributes.TxTotal, drop: _adapter.Attributes.TxDrop, error: _adapter.Attributes.TxErrorCounter, pending: _txQueue.Count); _adapter.Disconnect(); } else { _adapterStat.UpdateTransmitted( total: _virtualAdapterFrameCounter, drop: 0, error: 0, pending: _txQueue.Count); } } #endregion #region Resource Freeing if (_adapter != null) { _adapter.Dispose(); _adapter = null; } // _messageSenders.Stop(); _readyToDisposeEvent.Set(); _isRunning = false; _toolTables.Stop(); #endregion #region Loop Terminate { /*SynContext*/ Action doMehtod = () => { try { if (_project.Parameters.LogEnabled) { _log.Messages.AddToStorageEnd(); _logFiles.Add(_log); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { /*Minden áron jelezni kell! hogy megállt.*/ OnStopped(); Debug.WriteLine(GetType().Namespace + "." + GetType().Name + "." + MethodBase.GetCurrentMethod().Name + "(): Loop is colsed..."); } }; if (App.SyncContext != null) { App.SyncContext.Post((e1) => { doMehtod(); }, null); } else { doMehtod(); } } #endregion }
private void splitContainerMainTree_SplitterMoved(object sender, SplitterEventArgs e) { #if DEBUG AppDiagService.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + splitContainerMainTree.SplitterDistance + ", Percent: " + splitContainerMainTree.SplitterPrecent.ToString()); #endif }