Exemple #1
0
        protected virtual Type GetSensorClassType(eSensorType sensorType)
        {
            Assembly asm      = ParentLogger.GetType().Assembly;
            string   fullname = ParentLogger.GetType().Namespace;

            return(asm.GetType(fullname.Substring(0, fullname.IndexOf('.') + 1) + STRUCTURE.SENSORS + "." + sensorType.ToString()));
        }
Exemple #2
0
        public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter)
        {
            if (!IsEnabled(logLevel))
            {
                return;
            }

            if (formatter == null)
            {
                throw new ArgumentNullException(nameof(formatter));
            }

            string message = formatter(state, exception);

            if (!string.IsNullOrEmpty(message) || exception != null)
            {
                if (ParentLogger != null)
                {
                    ParentLogger.WriteMessage(Name, logLevel, eventId.Id, message, exception);
                }
                else
                {
                    WriteMessage(Name, logLevel, eventId.Id, message, exception);
                }
            }
        }
        private SoundPlayer GetPath(string messageToShow, string defaultPath, out string path)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (defaultPath.Length > 0)
            {
                try { ofd.FileName = defaultPath; }
                catch { }
            }
            else
            {
                try { ofd.InitialDirectory = Directory.GetCurrentDirectory(); }
                catch { }
            }
            ofd.Title = messageToShow;
            DialogResult dgRes;

            if (this.ParentForm == null || this.ParentForm.InvokeRequired)
            {
                dgRes = ofd.ShowDialog();
            }
            else
            {
                dgRes = ofd.ShowDialog(this.ParentForm);
            }
            if (dgRes == DialogResult.Abort || dgRes == DialogResult.Cancel)
            {
                path = "";
                return(null);
            }
            try
            {
                SoundPlayer res = new SoundPlayer(ofd.FileName);
                path = ofd.FileName;
                return(res);
            }
            catch (Exception ex)
            {
                if (ParentLogger != null)
                {
                    ParentLogger.WriteLog("Ошибка загрузки звукового файла:\r\n" + ex.Message, true);
                }
                path = "";
                return(null);
            }
        }
 public virtual void WriteWarning(string message)
 {
     ParentLogger.WriteWarning(message);
 }
 public virtual void WriteMessage(string message)
 {
     ParentLogger.WriteMessage(message);
 }
 public virtual void WriteError(string error)
 {
     ParentLogger.WriteError(error);
 }