Exemplo n.º 1
0
        public static void Write(
            Element element,
            LogEventAccess eventAccess,
            LogEventType eventType,
            LogEventStatus eventStatus,
            String eventInfo)
        {
            Initialize();

            try
            {
                //lock (logWriter)
                //{
                    string logEntry = String.Empty;

                    const string SPACE = "\t";

                    // Date Time
                    var unixTime = DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                    logEntry += System.Convert.ToInt64(unixTime.TotalSeconds) + SPACE
                        + DateTime.Now.ToShortDateString() + " "
                        + DateTime.Now.ToLongTimeString() + SPACE;

                    // Log Op
                    logEntry += eventAccess.ToString() + SPACE +
                        eventType.ToString() + SPACE +
                        eventStatus.ToString() + SPACE;

                    // Element
                    if (element != null)
                    {
                        logEntry +=
                            element.ID.ToString() + SPACE +
                            element.Path.ToString() + SPACE +
                            element.Type.ToString() + SPACE +
                            element.Position.ToString() + SPACE +
                            element.NoteText.Substring(0, Math.Min(element.NoteText.Length, 50)).Replace("\r\n", "#EOL") + SPACE +
                            element.AssociationType.ToString() + SPACE;

                        String url = String.Empty;
                        try
                        {
                            switch (element.AssociationType)
                            {
                                case ElementAssociationType.Email:
                                    url = element.AssociationURIFullPath;
                                    break;
                                case ElementAssociationType.File:
                                    url = "file:///" + element.AssociationURIFullPath;
                                    break;
                                case ElementAssociationType.FileShortcut:
                                    url = "file:///" + GetShortcut(element).TargetPath;
                                    break;
                                case ElementAssociationType.FolderShortcut:
                                    url = "file:///" + GetShortcut(element).TargetPath;
                                    break;
                                case ElementAssociationType.Tweet:
                                    url = GetShortcut(element).Description;
                                    break;
                                case ElementAssociationType.Web:
                                    url = GetShortcut(element).Description;
                                    break;
                            }
                        }
                        catch (Exception)
                        {
                        }

                        logEntry += url + SPACE;
                    }

                    // Log Comment
                    logEntry += eventInfo;

                    if (logWriter != null)
                    {
                        logWriter.WriteLine(logEntry);
                        logWriter.Flush();
                    }
                //}
            }
            catch (Exception ex)
            {

            }
            Close();
        }
Exemplo n.º 2
0
        public static void Write(
            Element element,
            LogEventAccess eventAccess,
            LogEventType eventType,
            LogEventStatus eventStatus,
            String eventInfo)
        {
            Initialize();

            try
            {
                //lock (logWriter)
                //{
                string logEntry = String.Empty;

                const string SPACE = "\t";

                // Date Time
                var unixTime = DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                logEntry += System.Convert.ToInt64(unixTime.TotalSeconds) + SPACE
                            + DateTime.Now.ToShortDateString() + " "
                            + DateTime.Now.ToLongTimeString() + SPACE;

                // Log Op
                logEntry += eventAccess.ToString() + SPACE +
                            eventType.ToString() + SPACE +
                            eventStatus.ToString() + SPACE;

                // Element
                if (element != null)
                {
                    logEntry +=
                        element.ID.ToString() + SPACE +
                        element.Path.ToString() + SPACE +
                        element.Type.ToString() + SPACE +
                        element.Position.ToString() + SPACE +
                        element.NoteText.Substring(0, Math.Min(element.NoteText.Length, 50)).Replace("\r\n", "#EOL") + SPACE +
                        element.AssociationType.ToString() + SPACE;

                    String url = String.Empty;
                    try
                    {
                        switch (element.AssociationType)
                        {
                        case ElementAssociationType.Email:
                            url = element.AssociationURIFullPath;
                            break;

                        case ElementAssociationType.File:
                            url = "file:///" + element.AssociationURIFullPath;
                            break;

                        case ElementAssociationType.FileShortcut:
                            url = "file:///" + GetShortcut(element).TargetPath;
                            break;

                        case ElementAssociationType.FolderShortcut:
                            url = "file:///" + GetShortcut(element).TargetPath;
                            break;

                        case ElementAssociationType.Tweet:
                            url = GetShortcut(element).Description;
                            break;

                        case ElementAssociationType.Web:
                            url = GetShortcut(element).Description;
                            break;
                        }
                    }
                    catch (Exception)
                    {
                    }

                    logEntry += url + SPACE;
                }

                // Log Comment
                logEntry += eventInfo;

                if (logWriter != null)
                {
                    logWriter.WriteLine(logEntry);
                    logWriter.Flush();
                }
                //}
            }
            catch (Exception ex)
            {
            }
            Close();
        }