Exemplo n.º 1
0
 public static void WriteLineIf(bool condition, string msg)
 {
     if (DefaultContext != null)
     {
         DefaultContext.AppendLineIf(condition, msg);
     }
     else
     {
         ChoTrace.Error(msg);
     }
 }
Exemplo n.º 2
0
 public static void WriteSeperatorIf(bool condition)
 {
     if (DefaultContext != null)
     {
         DefaultContext.AppendLineIf(condition, ChoTrace.SEPERATOR);
     }
     else
     {
         ChoTrace.Error(ChoTrace.SEPERATOR);
     }
 }
Exemplo n.º 3
0
 public static void WriteNewLineIf(bool condition)
 {
     if (DefaultContext != null)
     {
         DefaultContext.AppendIf(condition, Environment.NewLine);
     }
     else
     {
         ChoTrace.Error(Environment.NewLine);
     }
 }
Exemplo n.º 4
0
 public static bool Write(Exception ex)
 {
     if (DefaultContext != null)
     {
         DefaultContext.Append(ex);
     }
     else
     {
         ChoTrace.Error(ex.ToString());
     }
     return(true);
 }
Exemplo n.º 5
0
        public static bool WriteNThrow(Exception ex)
        {
            IChoProfile profile = GetDefaultContext(new StackFrame(1));

            if (profile != null)
            {
                profile.Append(ex);
            }
            else
            {
                ChoTrace.Error(ex.ToString());
            }
            throw new ChoApplicationException("Failed to write.", ex);
        }
Exemplo n.º 6
0
        public static bool Write(Exception ex)
        {
            IChoProfile profile = GetDefaultContext(new StackFrame(1));

            if (profile != null)
            {
                profile.Append(ex);
            }
            else
            {
                ChoTrace.Error(ex.ToString());
            }
            return(true);
        }
Exemplo n.º 7
0
        private static void Refresh()
        {
            try
            {
                lock (_padLock)
                {
                    //_propDict.Clear();
                }

                if (ChoMetaDataFilePathSettings.Me != null)
                {
                    _pbsDataFilepath = ChoMetaDataFilePathSettings.Me.OverridenPBSDataFilePath;
                }

                if (!ChoAppFrxSettings.Me.DisableMetaDataConfig)
                {
                    ChoXmlDocument.CreateXmlFileIfEmpty(_pbsDataFilepath);
                    _pbsDataChangeWatcher = new ChoAppConfigurationChangeFileWatcher(PBS_DATA_KEY, _pbsDataFilepath, _includeFiles);
                    _pbsDataChangeWatcher.SetConfigurationChangedEventHandler(PBS_DATA_FILE_WATCHER_KEY,
                                                                              (sender, e) =>
                    {
                        Refresh();
                    });
                }

                if (!_pbsDataFilepath.IsNullOrWhiteSpace() && File.Exists(_pbsDataFilepath))
                {
                    using (ChoXmlDocument xmlDocument = new ChoXmlDocument(_pbsDataFilepath))
                    {
                        _rootNode     = xmlDocument.XmlDocument.DocumentElement;
                        _includeFiles = xmlDocument != null ? xmlDocument.IncludeFiles : null;
                    }
                }

                BuildProfileBackingStores();
            }
            catch (Exception ex)
            {
                ChoTrace.Error(ex.ToString());
                //throw;
            }
        }
Exemplo n.º 8
0
        private static void BuildProfileBackingStores()
        {
            string xpath = @"//configuration/loggers/profileBackingStores/profileBackingStore";

            if (_rootNode == null)
            {
                return;
            }

            lock (_pbsStoreLock)
            {
                _pbsStoreDef.Clear();
                foreach (XmlNode pbsNode in _rootNode.SelectNodes(xpath))
                {
                    if (pbsNode == null)
                    {
                        continue;
                    }
                    try
                    {
                        ChoProfileBackingStoreDef profileBackingStoreDef;
                        profileBackingStoreDef = pbsNode.ToObject(typeof(ChoProfileBackingStoreDef)) as ChoProfileBackingStoreDef;

                        if (!_pbsStoreDef.ContainsKey(profileBackingStoreDef.Name))
                        {
                            _pbsStoreDef.Add(profileBackingStoreDef.Name, profileBackingStoreDef);
                        }
                        else
                        {
                            throw new ApplicationException("{0}: Duplicate profile backing store found.".FormatString(profileBackingStoreDef.Name));
                        }
                    }
                    catch (Exception ex)
                    {
                        ChoTrace.Error(ex);
                    }
                }
            }
        }