Пример #1
0
        public static void Log(string logFile, int maxLogSizeKb, DateTime logTime, string header, EventLogEntryType? eventLogEntryType, string format, params object[] parameters)
        {
            try
            {
                if (string.IsNullOrEmpty(logFile))
                {
                    if (eventLogEntryType.HasValue)
                        Log(eventLogEntryType.Value, logTime, header, format, parameters);
                }
                else
                {
                    lock (GetSync(logFile))
                    {
                        var log = string.Format("{0}: {1} : {2}",
                                         logTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture), header,
                            string.Format(format, parameters));
                        var info = new FileInfo(logFile);

                        using (var fs = new StreamWriter(logFile, info.Length + log.Length <= maxLogSizeKb * 1024, Encoding.UTF8))
                        {
                            fs.WriteLine(log);
                        }
                    }
                }
            }
            catch
            {
            }
        }
Пример #2
0
        /// <summary>
        /// The log exception.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="level">The level.</param>
        /// <param name="frame">The frame.</param>
        public void LogException(string message, EventLogEntryType level, int frame)
        {
            try
            {
                var callStack = new StackFrame(frame, true);
                string filename = string.Empty;
                try
                {
                    filename = callStack.GetFileName();
                }
                catch
                {
                }

                string method = callStack.GetMethod().ToString();
                int linenumber = callStack.GetFileLineNumber();
                string stackTrace = string.Empty;

                if (level == EventLogEntryType.Error)
                {
                    stackTrace = "Stack Trace: " + Environment.StackTrace;
                }
                else
                {
                    method = string.Empty;
                    linenumber = 0;
                }

                this.LogToDb(level, filename, method, linenumber, message, stackTrace);
            }
            catch
            {
                // Do nothing since logging is unavailable
            }
        }
Пример #3
0
        private void AddFileEventLog(string message, EventLogEntryType logType = EventLogEntryType.Information, string moduleName = "", int codeErreur = 0, bool fromWindowsLogEvent = false)
        {
            System.IO.StreamWriter w = null;
            System.Text.StringBuilder str = new System.Text.StringBuilder();

            try {
                string strPath = System.IO.Path.GetDirectoryName(_logFilePath);
                if (!System.IO.Directory.Exists(strPath))
                    System.IO.Directory.CreateDirectory(strPath);

                w = new System.IO.StreamWriter(_logFilePath, true, System.Text.Encoding.Default);

                str.AppendFormat("[{0,-10:G} - {1,-8:G}]", DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString());
                str.AppendFormat(" {0}", Const.DEFAULT_APPLICATION_NAME);
                if (!string.IsNullOrEmpty(moduleName))
                    str.AppendFormat(" ({0})", moduleName);
                str.AppendFormat(" - {0}", logType.ToString());
                if (codeErreur != 0)
                    str.AppendFormat(" - Code : {0}", codeErreur);

                str.Append("\r\n");
                str.Append(message);
                str.Append("\r\n");

                w.WriteLine(str.ToString());
            } catch (Exception ex) {
                if (!fromWindowsLogEvent) {
                    AddWindowsEventLog("Impossible d'écrire dans le fichier de log : " + _logFilePath + "\r\n" + message + "\r\nException : " + ex.Message, EventLogEntryType.Error, moduleName, 0, true);
                }
            } finally {
                if ((w != null))
                    w.Close();
            }
        }
Пример #4
0
        internal static void Log(string message, EventLogEntryType level = EventLogEntryType.Information)
        {
            TeamFoundationApplicationCore.Log(message, 9999, level);

            if (PluginConfiguration.Instance.HasLog)
                File.AppendAllText(PluginConfiguration.Instance.LogFile, message + Environment.NewLine);
        }
Пример #5
0
        private void AddWindowsEventLog(string message, EventLogEntryType logType = EventLogEntryType.Information, string moduleName = "", int codeErreur = 0, bool fromFileLogEvent = false)
        {
            EventLog evLog = new EventLog(Const.WINDOWS_LOG_NAME);

            message = string.Concat(message, "\r\n", "Module : ", moduleName);
            evLog.Source = Const.DEFAULT_APPLICATION_NAME;

            InitWindowsEventLog();

            try
            {
                evLog.WriteEntry(message, logType, codeErreur);
            }
            catch (Exception ex)
            {
                if (!fromFileLogEvent)
                {
                    AddFileEventLog("Impossible d'écrire dans le journal de log " + Log.Const.WINDOWS_LOG_NAME + ".\r\nLe journal doit être créé préalablement avec un compte Administrateur.\r\nMessage :\r\n" + message + "\r\nException : " + ex.Message, logType, moduleName, codeErreur, true);
                }
            }
            finally
            {
                evLog.Close();
            }
        }
Пример #6
0
        /// <summary>
        /// This method inform the Logging Manager whether it will accept the 
        /// category for logging.
        /// </summary>
        /// <param name="category">The logging category.</param>
        /// <param name="type">The envent log entry type category.</param>
        /// <returns>A boolean value. True indicates the category is accepted.</returns>
        public override bool AcceptCategory(string category, EventLogEntryType type)
        {
            if (category == "EventLog")
                return true;

            return base.AcceptCategory(category, type);
        }
Пример #7
0
 //Write entry log with custome event log entry type
 public void WriteEntry(string message, EventLogEntryType entryType)
 {
     if (enableDebugLog)
     {
         debugLog.WriteEntry(message, entryType);
     }
 }
Пример #8
0
        /// <summary>
        /// Writes the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="execption">The execption.</param>
        /// <param name="eventLogType">Type of the event log.</param>
        private void Write(object message, Exception execption, EventLogEntryType eventLogType)
        {
            StringBuilder sb = new StringBuilder();

            System.Diagnostics.EventLog eventLogger = new System.Diagnostics.EventLog();
            if (!System.Diagnostics.EventLog.SourceExists(eventLogSource))
            {
                System.Diagnostics.EventLog.CreateEventSource(eventLogSource, eventLogName);
            }

            sb.Append(message).Append(NEW_LINE);
            while (execption != null)
            {
                sb.Append("Message: ").Append(execption.Message).Append(NEW_LINE)
                .Append("Source: ").Append(execption.Source).Append(NEW_LINE)
                .Append("Target site: ").Append(execption.TargetSite).Append(NEW_LINE)
                .Append("Stack trace: ").Append(execption.StackTrace).Append(NEW_LINE);

                // Walk the InnerException tree
                execption = execption.InnerException;
            }

            eventLogger.Source = eventLogSource;
            eventLogger.WriteEntry(String.Format(ERROR_MSG, eventLogName, sb), eventLogType);
        }
Пример #9
0
 public LoggingUtil(EventLogEntryType min, EventLogEntryType max, String applicationName)
 {
     isSytemEvent = true;
     minSysLevel = min;
     maxSysLevel = max;
     _logFile.Source = applicationName;
 }
Пример #10
0
 public void EventLogWriteEntry(string message, EventLogEntryType type)
 {
     if (HostedApplication.EventLogEnabled)
     {
         EventLog.WriteEntry(message, type);
     }
 }
 static void EventLog(String evt, EventLogEntryType tpy)
 {
     if (bEventLog)
         eventLog.WriteEntry(evt, tpy);
     //Console.WriteLine(evt);
     //MessageBox.Show(evt);
 }
Пример #12
0
 // 把错误信息写到日志文件里
 public void WriteErrorLog(string strText,
     EventLogEntryType type = EventLogEntryType.Error)
 {
     EventLog Log = new EventLog();
     Log.Source = "dp2ZServer";
     Log.WriteEntry(strText, EventLogEntryType.Error);
 }
Пример #13
0
 /// <summary/>
 /// <param name="message"/>
 /// <param name="eventLogType"/>
 /// <exclude/>
 public virtual void Log(string message, EventLogEntryType eventLogType)
 {
     lock (lockObj)
     {
         this.eventLog.WriteEntry(message, eventLogType, this.eventId);
     }
 }
Пример #14
0
 public override void WriteLine(EventLogEntryType type, string message)
 {
     lock (_trace)
     {
         _trace.WriteLine(message, type.ToString());
     }
 }
Пример #15
0
    public static void Log(object sender, EventLogEntryType logType, string information) {
      if (sender == null)
        sender = new object();
      if (!Enabled)
        return;
      if (!ShowAll && logType != EventLogEntryType.Error && logType != EventLogEntryType.SuccessAudit)
        return;
      var origin = sender.GetType().FullName;
      var trace = new StringBuilder();

      if (logType == EventLogEntryType.Error) {
        var t = new StackTrace();
        for (var i = 0; i < t.FrameCount; ++i) {
          var declaringType = t.GetFrame(i).GetMethod().DeclaringType;
          if (declaringType != null)
            trace.Append(declaringType.FullName + "." + t.GetFrame(i).GetMethod().Name + "\r\n");
        }
      }
      if (_log != null) {
        try {
          _log.WriteEntry(origin + ": " + information + "\r\n\r\nTRACE:\r\n" + trace, logType);
        } catch {}
      }
      OnEvent?.Invoke(logType, sender, trace.ToString(), information);
    }
Пример #16
0
        public static void WriteLog(string message, EventLogEntryType type)
        {
            //WindowsIdentity winId = (WindowsIdentity)System.Security.Principal.WindowsIdentity.GetCurrent();
            //WindowsImpersonationContext ctx = null;
            try
            {
                // Start impersonating
                //ctx = winId.Impersonate();
                // Now impersonating
                // Access resources using the identity of the authenticated user
                System.Diagnostics.EventLog appLog =
             new System.Diagnostics.EventLog();
                appLog.Source = "PMM Presentation";
                appLog.WriteEntry(message, type);
            }

            // Prevent exceptions from propagating
            catch
            {
            }
            //finally
            //{
            //    // Revert impersonation
            //    if (ctx != null)
            //        ctx.Undo();
            //}
        }
        /// <summary>
        /// Logs the specified STR.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="msgType">Type of the MSG.</param>
        /// <param name="args">The args.</param>
        internal static void Write(string message, EventLogEntryType msgType, params string[] args)
        {
            if (string.IsNullOrEmpty(message))
                return;

            message = string.Format(message, args);

            if (ExecutingCmdlet != null)
            {
                if (msgType == EventLogEntryType.Warning)
                {
                    ExecutingCmdlet.WriteWarning(message);
                }
                else if (msgType == EventLogEntryType.Error)
                {
                    ExecutingCmdlet.WriteError(new System.Management.Automation.ErrorRecord(new Exception(message), null, System.Management.Automation.ErrorCategory.NotSpecified, null));
                }
                ExecutingCmdlet.WriteVerbose(message);
            }
            else
            {
                if (msgType == EventLogEntryType.Warning && !message.ToUpper().StartsWith("WARNING:"))
                    message = "WARNING: " + message;

                if (msgType != EventLogEntryType.Information || Verbose)
                {
                    Console.WriteLine(message);
                }
            }
            if (!string.IsNullOrEmpty(LogFile))
                File.AppendAllText(LogFile, message + "\r\n");
        }
Пример #18
0
 public static void WriteToEventLog(string sourceName, string logName, EventLogEntryType error, int eventID, string message)
 {
     try
     {
         SiAuto.Main.EnterMethod("Helper.WriteToEventLog");
         /*--------- Your code goes here-------*/
         using (EventLog elog = new EventLog())
         {
             if (!EventLog.SourceExists(sourceName))
             {
                 EventLog.CreateEventSource(sourceName, logName);
             }
             elog.Source = sourceName;
             elog.EnableRaisingEvents = true;
             elog.WriteEntry(message, error, eventID);
         }
         /*------------------------------------*/
     }
     catch (Exception ex)
     {
         SiAuto.Main.LogException(ex);
         //throw ex;
     }
     finally
     {
         SiAuto.Main.LeaveMethod("Helper.WriteToEventLog");
     }
 }
Пример #19
0
 private void Log(String msg, EventLogEntryType type)
 {
     if (msg.Length > 32766)
         EventLog.WriteEntry("XebraHandler", msg.Substring(0,32766), type);
     else
         EventLog.WriteEntry("XebraHandler", msg, type);
 }
Пример #20
0
        public void WriteEntry(string message, EventLogEntryType type)
        {
            if (!isEnabled) return;
            switch (logType)
            {
                case LogType.EventLog:
                    Log.WriteEntry(message, type); break;
                case LogType.TextLog:
                    string filename = "log_" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
                    try
                    {
                        if (!Directory.Exists(logPath)) Directory.CreateDirectory(logPath);
                        File.AppendAllText(logPath + filename, DateTime.Now.ToLongTimeString() + " : " + type + " : " + message + Environment.NewLine);
                    }
                    catch (Exception)
                    {
                        Thread.Sleep(new TimeSpan(0, 0, 2));
                        try
                        {
                            if (!Directory.Exists(logPath)) Directory.CreateDirectory(logPath);
                            File.AppendAllText(logPath + filename, DateTime.Now.ToLongTimeString() + " : " + type + " : " + message + Environment.NewLine);
                        }
                        catch (Exception)
                        {

                        }
                    }
                    break;
                default: break;
            }
        }
Пример #21
0
 /// <summary>
 /// Saves the specified _content.
 /// </summary>
 /// <param name="_content">The _content.</param>
 /// <param name="_logType">Type of the _log.</param>
 /// <param name="param">The parameter.</param>
 /// <returns>Result.</returns>
 public Result Save(string _content, EventLogEntryType _logType, object param)
 {
     content = _content;
     logType = _logType;
     sqlConnection = (SqlConnection)param;
     return AddToSQLTable();
 }
Пример #22
0
 public void WriteEventLogEntry(string Message, EventLogEntryType type)
 {
     if(_eventLog!=null)
         _eventLog.WriteEntry(Message, type);
     else
         throw new Exception("Unable to write to event log : not initialized. \r\nMessage to write:\r\n" + Message);
 }
Пример #23
0
        public EventlogListener(string protocol, string source, string category, EventLogEntryType[] types, string key, int value, IMonitoringChannel channel)
        {
            if (protocol == null)
                throw new ArgumentNullException("protocol");

            if (key == null)
                throw new ArgumentNullException("key");

            if (channel == null)
                throw new ArgumentNullException("channel");

            this.key = key;
            this.value = value;

            this.channel = channel;
            this.types = types;

            this.protocol = protocol;
            this.source = source;
            this.category = category;

            try
            {
                this.Initialize();
            }
            catch (ArgumentException exception)
            {
                throw new ArgumentException(
                    exception.Message + " (" + protocol + ")",
                    exception);
            }
        }
Пример #24
0
        private static void Write(string message, EventLogEntryType type)
        {
            if (!EventLog.SourceExists(sSource))
                EventLog.CreateEventSource(sSource, "Application");

            EventLog.WriteEntry(sSource, message, type, eventID);
        }
Пример #25
0
 private static void WriteEventLog(string source, string content, EventLogEntryType type)
 {
     try
     {
         if (!EventLog.SourceExists(source))
         {
             EventLog.CreateEventSource(source, "ECCentral.Service");
         }
         using (EventLog errorLog = new EventLog())
         {
             errorLog.Source = source;
             errorLog.WriteEntry(content, type);
         }
     }
     catch (Exception ex)
     {
         try
         {
             using (EventLog log = new EventLog("Application", ".", "ECCentral.Service.Utility"))
             {
                 log.WriteEntry(ex.ToString(), EventLogEntryType.Error);
             }
         }
         catch
         {
         }
     }
 }
Пример #26
0
 /// <summary>
 /// Saves the specified _content.
 /// </summary>
 /// <param name="_content">The _content.</param>
 /// <param name="_logType">Type of the _log.</param>
 /// <returns>System.String.</returns>
 public Result Save(string _content, EventLogEntryType _logType)
 {
     content = _content;
     logType = _logType;
     logPath = @"C:\Cube\Logs\";
     return AddToFile();
 }
Пример #27
0
 private void BaseWriteEntry(string message, EventLogEntryType logType, int eventId)
 {
     if (this.HasInitialized)
     {
         this.LoggerProxy.Process(new LogObject(message, logType, eventId));
     }
 }
Пример #28
0
        public static void Log(string message, EventLogEntryType logType, [CallerMemberName] string memberName = "",
            [CallerLineNumber] int lineNumber = 0) {
            try {
                using (StreamWriter log = new StreamWriter("logs.txt", true)) {
                    string _out =
                        $"[{DateTime.Now.ToString("dd/MM hh:mm")} {Enum.GetName(typeof(EventLogEntryType), logType)}] ";

                    switch (logType) {
                        case EventLogEntryType.SuccessAudit:
                        case EventLogEntryType.FailureAudit:
                        case EventLogEntryType.Warning:
                        case EventLogEntryType.Error:
                            _out += $"from `{memberName}' at {lineNumber}: {message}";

                            Console.WriteLine(_out);
                            log.WriteLine(_out);
                            log.Flush();
                            break;
                        case EventLogEntryType.Information:
                            _out += message;

                            Console.WriteLine(_out);
                            log.WriteLine(_out);
                            log.Flush();
                            break;
                        default:
                            throw new ArgumentOutOfRangeException(nameof(logType), logType, null);
                    }
                }
            } catch (Exception ex) {
                Console.WriteLine($"||| Logging error occured: {ex}", EventLogEntryType.Error);
            }
        }
        public void Write(string msg, EventLogEntryType type)
        {
            Console.WriteLine(msg);

            // TODO: REBUILD
            //_log.WriteEntry(msg, type);
        }
Пример #30
0
    /// <summary>
    /// Prints a message to the local systems eventlog.
    /// </summary>
    /// <param name="entry"></param>
    /// <param name="type"></param>
    private static void Print(string entry, EventLogEntryType type)
    {
      switch (type)
      {
        case EventLogEntryType.Error: entry = "[error]: " + entry; break;
        case EventLogEntryType.Information: entry = "[comment]: " + entry; break;
        case EventLogEntryType.Warning: entry = "[warning]: " + entry; break;
      }

      try
      {
        if (EventLog.Exists("Application", "."))
        {
          EventLog eventLog = new EventLog("Application", ".", "EasyHook");

#if !DEBUG
                if(InType == EventLogEntryType.Error)
#endif
          eventLog.WriteEntry(entry, type);
        }
      }
      catch
      {
      }

#if DEBUG
      Console.WriteLine(entry);
#endif
    }
Пример #31
0
 public void WriteEvent(string eventSource, string message, EventLogEntryType eventType, int eventId)
 {
 }
Пример #32
0
 internal static void _WriteFile(string message, EventLogEntryType type)
 {
     // If LogStreamWriter is not null (check inside the function) then write to file.
     Current.FileWriter.WriteLine(message);
 }
Пример #33
0
 private void LogEvent(string msg, EventLogEntryType et, int id)
 {
     rtpSession.LogEvent("RtcpListener", msg, et, id);
 }
 public EventInstance(long instanceId, int categoryId, EventLogEntryType entryType) : this(instanceId, categoryId)
 {
     EntryType = entryType;
 }
Пример #35
0
 /// <summary>
 /// Writes an error entry to the Application log, Application Source. This is a fallback error writing mechanism.
 /// </summary>
 /// <param name="message">The error message.</param>
 /// <param name="errorType">Type of error.</param>
 /// <param name="ex">Original exception (optional)</param>
 public static string WriteToAppLog(string message, EventLogEntryType errorType, Exception ex = null)
 {
     message = GetErrorMessageString(message, ex);
     EventLog.WriteEntry("Application", message, errorType, 0);
     return(message);
 }
        private static readonly LamedalCore_ _lamed = LamedalCore_.Instance; // system library

        /// <summary>
        /// Return the eventlog and filter it.
        /// </summary>
        /// <param name="filterLog">If [true] then filter the log</param>
        /// <param name="logName">The event log name</param>
        /// <param name="unique">if [true] then the list is unique</param>
        /// <param name="today">if [true] filter for today</param>
        /// <param name="eventFilterType">The event filter type</param>
        /// <returns></returns>
        public static List <EventLogEntry> EventLog(bool filterLog = true, enEventLog logName = enEventLog.system, bool unique = true, bool today = false, EventLogEntryType eventFilterType = EventLogEntryType.Error)
        {
            //var log = "application";
            var log  = logName.ToString();
            var aLog = new EventLog(log, Environment.MachineName);
            //EventLogEntry entry;
            List <EventLogEntry> result = aLog.Entries.Cast <EventLogEntry>().ToList();

            if (filterLog)
            {
                result = result.Where(x => x.EntryType == eventFilterType).ToList();
            }
            if (today)
            {
                result = result.Where(x => _lamed.Types.DateTime.IsToday(x.TimeGenerated)).ToList();
            }
            if (unique)
            {
                var uniqueList = new Dictionary <string, EventLogEntry>();
                foreach (var entry in result)
                {
                    _lamed.Types.Dictionary.Key_AddSafe(uniqueList, entry.Source, entry, enCompare_DuplicateAction.Ignore);
                    result = uniqueList.Values.ToList();
                }
            }
            return(result);
        }
 void _updater_OnStatusUpdate(string text, EventLogEntryType elt)
 {
     notifyIcon.ShowBalloonTip(0, "Dynamic IP", text, elt == EventLogEntryType.Error ? ToolTipIcon.Error : ToolTipIcon.Info);
 }
Пример #38
0
 /// <summary>
 /// Writes the specified message.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="eventLogType">Type of the event log.</param>
 private void Write(object message, EventLogEntryType eventLogType)
 {
     Write(message, null, eventLogType);
 }
Пример #39
0
 /// <summary/>
 /// <param name="source"/>
 /// <param name="logType"/>
 /// <param name="eventId"/>
 /// <exclude/>
 public EventLogger(string source, EventLogEntryType logType, int eventId)
 {
     this.eventLog = new EventLog(SR.LogName, SR.MachineName, source);
     this.logType  = logType;
     this.eventId  = eventId;
 }
Пример #40
0
        public void WriteToEventLog(Exception exception, EventLogEntryType eventLogEntryType)
        {
            var message = GetMessageFromException(exception);

            WriteToEventLog(message, eventLogEntryType);
        }
 /// <summary>
 /// Запись сообщения в события Windows.
 /// </summary>
 /// <param name="message">Сообщение для записи в лог.</param>
 /// <param name="eventLogEntryType">Статус сообщения: ошибка, информация или др.</param>
 protected static void WriteToEventLog(string message, EventLogEntryType eventLogEntryType = EventLogEntryType.Information)
 {
     EventLog.WriteEntry(LogSourceName, message, eventLogEntryType);
 }
Пример #42
0
        public VehicleEntity CreateVehicle(VehicleEntity newVehicle)
        {
            var resultVehicleEntity        = new VehicleEntity();
            EventLogEntryType eventLogType = EventLogEntryType.Information;

            try
            {
                #region Detailer Call
                var     requestUri       = ConfigurationManager.AppSettings["detailerUrl"];
                dynamic detailerResponse = RestClient.PostData(requestUri, GetDetailerRequestPayload(newVehicle));
                _logger.AppendMessages("Successfully completed Detailer call before Create Vehicle.");
                #endregion Detailer call

                #region Create Vehicle Call
                if (detailerResponse.vehicles != null && detailerResponse.vehicles.GetType() == typeof(JArray) &&
                    detailerResponse.vehicles[0] != null && detailerResponse.vehicles[0].vehicle != null)
                {
                    JObject vehicleEntity = detailerResponse.vehicles[0].vehicle;
                    vehicleEntity.Add("stockNumber", newVehicle.StockNumber ?? string.Empty);

                    _logger.AppendMessages("Detailer found atleast one vehicle in response.");

                    if (newVehicle.photoIds != null)
                    {
                        //??
                        _logger.AppendMessages("Number of PhotoIds: " + newVehicle.photoIds.Count());
                        //vehicleEntity.Add("assets", JObject.Parse("{\"dealerPhotos\": []}"));
                        foreach (var id in newVehicle.photoIds)
                        {
                            if (id != null && !id.Equals(string.Empty) && !id.Equals(" ") && vehicleEntity.GetValue("assets") == null)
                            {
                                //??
                                _logger.AppendMessages("L");
                                vehicleEntity.Add("assets", JObject.Parse("{\"dealerPhotos\": [{\"id\":" + id + "}]}"));
                            }
                        }
                    }

                    if (vehicleEntity.GetValue("source") == null)
                    {
                        vehicleEntity.Add("source", "M");
                    }

                    var createVehicleRequestPayload = string.Format("{{\"criteria\":{{\"vehicleContexts\":[{{\"vehicleContext\":{{\"vehicle\":{0},\"modifiedFields\":[\"assets\",\"bodyStyle\",\"bodyType\",\"certified\",\"colors.exterior.base\",\"colors.exterior.code\",\"colors.exterior.name\",\"colors.interior.code\",\"colors.interior.name\",\"createdDate\",\"descriptions\",\"doors\",\"drivetrain\",\"engine.aspiration\",\"engine.cylinders\",\"engine.description\",\"engine.displacement\",\"engine.fuelType\",\"engine.power\",\"id\",\"inventoryOwner\",\"lastModifiedDate\",\"lotDate\",\"make.Id\",\"make.label\",\"model.Id\",\"model.label\",\"odometer\",\"oemModelCode\",\"options.dealerOptions\",\"options.factoryOptions\",\"preOwned\",\"prices.discountPrice\",\"prices.internetPrice\",\"prices.invoicePrice\",\"prices.msrp\",\"prices.retailPrice\",\"prices.vendedPrice\",\"stockNumber\",\"style.Id\",\"style.trim\",\"transmission.speeds\",\"transmission.text\",\"transmission.type\",\"unmodifiable\",\"vin\",\"warranties\",\"year\"]}}}}],\"inventoryOwner\":\"gmps-kindred\",\"useSource\": true}}}}",
                                                                    vehicleEntity);

                    _logger.AppendMessages(string.Format("Request payload for create vehicle call - {0}", createVehicleRequestPayload));

                    dynamic result = RestClient.PostData(ConfigurationManager.AppSettings["createVehicleUrl"], createVehicleRequestPayload);

                    if (result != null && result.result != null)
                    {
                        result = result.result;
                        if (result != null &&
                            result.status != null &&
                            result.status.GetType() == typeof(JArray) &&
                            result.status[0].vehicle != null)
                        {
                            _logger.AppendMessages(string.Format("Create Vehicle call successful . result {0} ", result));

                            resultVehicleEntity.Vin         = result.status[0].vehicle.vin ?? string.Empty;
                            resultVehicleEntity.StockNumber = result.status[0].vehicle.stockNumber ?? string.Empty;
                            TryGetMake(result.status[0].vehicle, resultVehicleEntity);
                            TryGetModel(result.status[0].vehicle, resultVehicleEntity);
                            TryGetOemModelCode(result.status[0].vehicle, resultVehicleEntity);
                            TryGetTrimAndStyle(result.status[0].vehicle, resultVehicleEntity);
                            TryGetYear(result.status[0].vehicle, resultVehicleEntity);

                            #region Get Color from response
                            var refStyles = result.status[0].vehicle;
                            if (refStyles.colors != null && refStyles.colors.GetType() == typeof(JArray))
                            {
                                foreach (var iColor in refStyles.colors)
                                {
                                    var color          = iColor.color;
                                    var colorRefObject = new ColorReferenceEntity();

                                    if (color.category != null && color.category == "Exterior")
                                    {
                                        resultVehicleEntity.ExternalColor = new Color
                                        {
                                            Code = color.code ?? string.Empty,
                                            //Base = color.exterior.base ?? string.Empty,
                                            Name       = color.name ?? string.Empty,
                                            RgbHexCode = color.RGBHexCode ?? string.Empty
                                        };
                                    }

                                    if (color.category != null && color.category == "Interior")
                                    {
                                        resultVehicleEntity.InternalColor = new Color
                                        {
                                            Code = color.code ?? string.Empty,
                                            //Base = color.exterior.base ?? string.Empty,
                                            Name       = color.name ?? string.Empty,
                                            RgbHexCode = color.RGBHexCode ?? string.Empty
                                        };
                                    }
                                }
                            }

                            #endregion Get Color from response
                        }
                    }

                    if (result.error != null && result.error.message != null)
                    {
                        _logger.AppendMessages("Create Vehicle call unsuccessful");
                        throw new Exception(result.error.message);
                    }
                }

                #endregion Create Vehicle Call
            }
            catch (Exception ex)
            {
                eventLogType = EventLogEntryType.Error;
                _logger.AppendMessages(string.Format("Error - {0}.", ex));
            }
            finally
            {
                _logger.LogAppendedMessages(eventLogType);
            }

            return(resultVehicleEntity);
        }
Пример #43
0
 /// <summary>
 /// EventLog에 항목을 쓴다.
 /// </summary>
 /// <param name="message">로그엔트리 정보</param>
 /// <param name="entryType">엔트리 타입</param>
 public void WriteEntry(string message, EventLogEntryType entryType)
 {
     Log.WriteEntry(message, entryType);
 }
Пример #44
0
 /// <summary>
 /// 지정된 <c>EventLogEntryType</c>(수준)과 같은 <c>EventLogEntry</c>를 검색한다.
 /// </summary>
 /// <param name="entryType">검색할 <c>EventLogEntryType</c>(수준)의 값</param>
 /// <returns>찾은 <c>EventLogEntry</c>의 컬렉션</returns>
 public IEnumerable <EventLogEntry> FindEntryByEntryType(EventLogEntryType entryType)
 {
     return(EventLogTool.FindEntryByEntryType(Log, entryType));
 }
Пример #45
0
 /// <summary>
 /// EventLog에 항목을 쓴다.
 /// </summary>
 /// <param name="message">로그엔트리 정보</param>
 /// <param name="entryType">엔트리 타입</param>
 /// <param name="eventID">이벤트 ID</param>
 /// <param name="category">분류 번호</param>
 public void WriteEntry(string message, EventLogEntryType entryType, int eventID, short category)
 {
     Log.WriteEntry(message, entryType, eventID, category);
 }
Пример #46
0
 /// <summary>
 /// EventLog에 항목을 쓴다.
 /// </summary>
 /// <param name="message">로그엔트리 정보</param>
 /// <param name="entryType">엔트리 타입</param>
 /// <param name="eventID">이벤트 ID</param>
 public void WriteEntry(string message, EventLogEntryType entryType, int eventID)
 {
     Log.WriteEntry(message, entryType, eventID);
 }
Пример #47
0
 /// <summary>
 /// The last error point
 /// </summary>
 public static void DirectEventViewerLog(string message, EventLogEntryType eventLogEntryType)
 {
     EventLog.WriteEntry("GrabCaster", message, eventLogEntryType, 0);
 }
Пример #48
0
 /// <summary>
 /// EventLog에 항목을 쓴다.
 /// </summary>
 /// <param name="message"></param>
 /// <param name="entryType"></param>
 /// <param name="eventID"></param>
 /// <param name="category"></param>
 /// <param name="rawData"></param>
 public void WriteEntry(string message, EventLogEntryType entryType, int eventID, short category, byte[] rawData)
 {
     Log.WriteEntry(message, entryType, eventID, category, rawData);
 }
Пример #49
0
 public void WriteEntry(string message, EventLogEntryType logType)
 {
     this.WriteEntry(message, logType, -2147483648);
 }
Пример #50
0
 /// <summary>
 /// Writes the log entry into the Test Context
 /// </summary>
 /// <param name="category">The application specific category of the log entry.</param>
 /// <param name="title">The title for the log entry. This is usually the 1st thing that
 /// will be seen when entries are reviewed.</param>
 /// <param name="message">The full text of the message sent to the logging provider.</param>
 /// <param name="severity">An indication of how critical an event the entry represents.</param>
 /// <param name="entryType">The type of entry as described in the EventLogEntryType enumeration.</param>
 public override void Write(string category, string title, string message, int severity, EventLogEntryType entryType)
 {
     _testContext.WriteLine("Logger: {0} ({1}/{3}) - {2}\r\n", title, category, message, severity);
 }
Пример #51
0
 /// <summary>
 /// Creates the log.
 /// </summary>
 /// <param name="_context">The _context.</param>
 /// <param name="_level">The _level.</param>
 public void CreateLog(string _content, EventLogEntryType _level)
 {
     ShowLog(_content);
     WriteLog(_content, _level);
 }
 private void WriteLog(string msg, EventLogEntryType t, int id)
 {
     Log.WriteEntry(DateTime.Now.ToString() + " " + _dbg + " " + _ver + msg, t, id);
 }
 /// <summary>
 /// WriteEntry method implementation
 /// </summary>
 public static void WriteEntry(string message, EventLogEntryType type, int eventID)
 {
     EventLog.WriteEntry(EventLogSource, message, type, eventID);
 }
 private void WriteLog(string msg, EventLogEntryType eventType, int eventId)
 {
     EventLog.WriteEntry(serviceEventSource, msg, eventType, eventId);
 }
Пример #55
0
        /// <summary>
        /// Writes to system event log
        /// </summary>
        /// <param name="logName">Sirona</param>
        /// <param name="sourceName">Application or module</param>
        /// <param name="entryMessage">message to log</param>
        /// <param name="logEntryType">Error, Warning, Information, SuccessAudit, FailureAudit</param>
        public static void WriteToEventLog(string logName, string sourceName, string entryMessage, EventLogEntryType logEntryType)
        {
            try
            {
                if ((!EventLog.SourceExists(sourceName)))
                    EventLog.CreateEventSource(sourceName, "Sirona");
            }
            catch (System.Security.SecurityException e)
            {
                sourceName = "Web Error";
            }

            EventLog.WriteEntry(sourceName, entryMessage, logEntryType, 0);
        }
Пример #56
0
        private static void WriteToEventLog(string eventText, EventLogEntryType entryType)
        {
            String source = "vstsAgentService";

            EventLog.WriteEntry(source, eventText, entryType, 100);
        }
Пример #57
0
        /// <summary>
        /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/>
        /// method.
        /// </summary>
        /// <param name="loggingEvent">the event to log</param>
        /// <remarks>
        /// <para>Writes the event to the system event log using the
        /// <see cref="ApplicationName"/>.</para>
        ///
        /// <para>If the event has an <c>EventID</c> property (see <see cref="LoggingEvent.Properties"/>)
        /// set then this integer will be used as the event log event id.</para>
        ///
        /// <para>
        /// There is a limit of 32K characters for an event log message
        /// </para>
        /// </remarks>
        override protected void Append(LoggingEvent loggingEvent)
        {
            //
            // Write the resulting string to the event log system
            //
            int eventID = m_eventId;

            // Look for the EventID property
            object eventIDPropertyObj = loggingEvent.LookupProperty("EventID");

            if (eventIDPropertyObj != null)
            {
                if (eventIDPropertyObj is int)
                {
                    eventID = (int)eventIDPropertyObj;
                }
                else
                {
                    string eventIDPropertyString = eventIDPropertyObj as string;
                    if (eventIDPropertyString == null)
                    {
                        eventIDPropertyString = eventIDPropertyObj.ToString();
                    }
                    if (eventIDPropertyString != null && eventIDPropertyString.Length > 0)
                    {
                        // Read the string property into a number
                        int intVal;
                        if (SystemInfo.TryParse(eventIDPropertyString, out intVal))
                        {
                            eventID = intVal;
                        }
                        else
                        {
                            ErrorHandler.Error("Unable to parse event ID property [" + eventIDPropertyString + "].");
                        }
                    }
                }
            }

            short category = m_category;
            // Look for the Category property
            object categoryPropertyObj = loggingEvent.LookupProperty("Category");

            if (categoryPropertyObj != null)
            {
                if (categoryPropertyObj is short)
                {
                    category = (short)categoryPropertyObj;
                }
                else
                {
                    string categoryPropertyString = categoryPropertyObj as string;
                    if (categoryPropertyString == null)
                    {
                        categoryPropertyString = categoryPropertyObj.ToString();
                    }
                    if (categoryPropertyString != null && categoryPropertyString.Length > 0)
                    {
                        // Read the string property into a number
                        short shortVal;
                        if (SystemInfo.TryParse(categoryPropertyString, out shortVal))
                        {
                            category = shortVal;
                        }
                        else
                        {
                            ErrorHandler.Error("Unable to parse event category property [" + categoryPropertyString + "].");
                        }
                    }
                }
            }

            // Write to the event log
            try
            {
                string eventTxt = RenderLoggingEvent(loggingEvent);

                // There is a limit of about 32K characters for an event log message
                if (eventTxt.Length > MAX_EVENTLOG_MESSAGE_SIZE)
                {
                    eventTxt = eventTxt.Substring(0, MAX_EVENTLOG_MESSAGE_SIZE);
                }

                EventLogEntryType entryType = GetEntryType(loggingEvent.Level);

                using (SecurityContext.Impersonate(this))
                {
                    EventLog.WriteEntry(m_applicationName, eventTxt, entryType, eventID, category);
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.Error("Unable to write to event log [" + m_logName + "] using source [" + m_applicationName + "]", ex);
            }
        }
Пример #58
0
 public static void WriteLogEntryWeb(EventLogEntryType type, string message, params object[] args)
 {
     Helper.WriteLogEntry("Seal Web Server", type, message, args);
 }
Пример #59
0
        public static void WriteEvent(TSEventLogEventType tsEventLogEventType, HttpRequest httpRequest = null, User user = null, Organization organization = null, string[] extraInfo = null)
        {
            try
            {
                string source = "TeamSupport";
                if (EventLog.SourceExists(source))
                {
                    List <object>     prams             = extraInfo == null ? new List <object>() : new List <object>(extraInfo);
                    EventLogEntryType eventLogEntryType = EventLogEntryType.Information;
                    switch (tsEventLogEventType)
                    {
                    case TSEventLogEventType.LoginSuccess:
                        prams.Add("User logged in");
                        eventLogEntryType = EventLogEntryType.SuccessAudit;
                        break;

                    case TSEventLogEventType.LogoutSuccess:
                        prams.Add("User logged out");
                        eventLogEntryType = EventLogEntryType.SuccessAudit;
                        break;

                    case TSEventLogEventType.FailedLoginAttempt:
                        prams.Add("Failed log in attempt");
                        eventLogEntryType = EventLogEntryType.FailureAudit;
                        break;

                    case TSEventLogEventType.AccountLocked:
                        prams.Add("Account locked out");
                        eventLogEntryType = EventLogEntryType.Warning;
                        break;

                    default:
                        break;
                    }

                    if (httpRequest != null)
                    {
                        prams.Add(string.Format("IPAddress: {0}", httpRequest.UserHostAddress));
                    }

                    if (organization != null)
                    {
                        prams.Add(string.Format("OrganizationID: {0}", organization.OrganizationID.ToString()));
                        prams.Add(string.Format("Account: {0}", organization.Name));
                    }

                    if (user != null)
                    {
                        prams.Add(string.Format("UserID: {0}", user.UserID.ToString()));
                        prams.Add(string.Format("User: {0}", user.FirstLastName));
                        prams.Add(string.Format("Email: {0}", user.Email));
                    }
                    EventLog.WriteEvent(source, new EventInstance((int)tsEventLogEventType, 0, eventLogEntryType), prams.ToArray());
                    //EventLog.WriteEntry(source, message, eventLogEntryType, (int)tsEventLogEventType, (short)tsEventLogCategoryType);
                }
                else
                {
                    //  ExceptionLogs.AddLog(LoginUser.Anonymous, "TeamSupport has not been setup as a source in the event logs.");
                }
            }
            catch (Exception ex)
            {
                ExceptionLogs.LogException(LoginUser.Anonymous, ex, "Event Logs", "Error writing event log");
            }
        }
Пример #60
0
 /// <summary>
 /// Ignoes the Event message.
 /// </summary>
 /// <param name="eventId">The event id to assocuiate with the message.</param>
 /// <param name="eventType">The event type to associate with the message.</param>
 /// <param name="message">The message.</param>
 public void WriteEvent(int eventId, EventLogEntryType eventType, string message)
 {
 }