/// <summary> /// Get a displayed event based on event data /// </summary> /// <remarks>The method always returns a non-null object.</remarks> public DispEvent GetDispEvent(EventTableLight.Event ev, DataFormatter dataFormatter) { var dispEvent = new DispEvent(); try { dispEvent.Num = ev.Number; dispEvent.Time = ev.DateTime.ToLocalizedString(); dispEvent.Ack = ev.Checked ? CommonPhrases.EventAck : CommonPhrases.EventNotAck; var cnlProps = GetCnlProps(ev.CnlNum); var cnlStatProps = GetCnlStatProps(ev.NewCnlStat); if (cnlProps == null) { dispEvent.Obj = GetObjName(ev.ObjNum); dispEvent.KP = GetKPName(ev.KPNum); } else { dispEvent.Obj = cnlProps.ObjName; dispEvent.KP = cnlProps.KPName; dispEvent.Cnl = cnlProps.CnlName; dispEvent.Color = dataFormatter.GetCnlValColor( ev.NewCnlVal, ev.NewCnlStat, cnlProps, cnlStatProps); dispEvent.Sound = cnlProps.EvSound; } dispEvent.Text = dataFormatter.GetEventText(ev, cnlProps, cnlStatProps); } catch (Exception ex) { log.WriteException(ex, "Error getting displayed event based on the event data"); } return(dispEvent); }
/// <summary> /// Получить отображаемое событие на основе данных события. /// </summary> /// <remarks>Метод всегда возвращает объект, не равный null.</remarks> public DispEvent GetDispEvent(EventTableLight.Event ev, DataFormatter dataFormatter) { DispEvent dispEvent = new DispEvent(); try { dispEvent.Num = ev.Number; dispEvent.Time = ev.DateTime.ToLocalizedString(); dispEvent.Ack = ev.Checked ? CommonPhrases.EventAck : CommonPhrases.EventNotAck; InCnlProps cnlProps = GetCnlProps(ev.CnlNum); CnlStatProps cnlStatProps = GetCnlStatProps(ev.NewCnlStat); if (cnlProps == null) { dispEvent.Obj = GetObjName(ev.ObjNum); dispEvent.KP = GetKPName(ev.KPNum); } else { dispEvent.Obj = cnlProps.ObjName; dispEvent.KP = cnlProps.KPName; dispEvent.Cnl = cnlProps.CnlName; dispEvent.Color = dataFormatter.GetCnlValColor( ev.NewCnlVal, ev.NewCnlStat, cnlProps, cnlStatProps); dispEvent.Sound = cnlProps.EvSound; } dispEvent.Text = dataFormatter.GetEventText(ev, cnlProps, cnlStatProps); } catch (Exception ex) { log.WriteException(ex, Localization.UseRussian ? "Ошибка при получении отображаемого события на основе данных события" : "Error getting displayed event based on the event data"); } return(dispEvent); }