aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFileJavaExtension.cshtml
blob: 8498f331134da3c8ae778b24b54a08749f0aac05 (plain)
1
2
3
4
5
6
7
8
9
10
11
package com.twine.tango.dal.entities;

import com.raizlabs.android.dbflow.annotation.Table;
import com.twine.tango.dal.TangoDB;

@@Table(name = "@(Model.TableName)", database = TangoDB.class, cachingEnabled = true)
public class @(Model.Name) extends @(Model.Extends)
{

    
}
.mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Tango.Logging;

namespace Tango.MachineStudio.Logging.Parsing
{
    public class ApplicationLogFileParser : ILogFileParser<LogItemBase>
    {
        public List<LogFile> GetLogFiles()
        {
            List<LogFile> logFiles = new List<LogFile>();

            FileLogger logger = LogManager.Default.RegisteredLoggers.FirstOrDefault(x => x.GetType() == typeof(FileLogger)) as FileLogger;

            String logFile = logger != null ? logger.LogFile : null;

            foreach (var file in Directory.GetFiles(FileLogger.DefaultLogsFolder, "*.log").Where(x => Path.GetFileName(x).StartsWith("Tango.MachineStudio.UI") && x != logger.LogFile))
            {
                String dateString = Path.GetFileNameWithoutExtension(file).Replace("Tango.MachineStudio.UI-", "");
                DateTime date = DateTime.ParseExact(dateString, "dd-MM-yyyy_HH-mm-ss", CultureInfo.InvariantCulture);
                logFiles.Add(new LogFile() { DateTime = date, File = file });
            }

            return logFiles;
        }

        public List<LogItemBase> Parse(LogFile logFile)
        {
            List<LogItemBase> logItems = new List<LogItemBase>();

            String text = File.ReadAllText(logFile.File);
            var logs = Regex.Split(text, @"(\[\d{2}:\d{2}:\d{2}.\d{2}\])");

            for (int i = 1; i < logs.Length; i += 2)
            {
                try
                {
                    DateTime date = DateTime.ParseExact(logs[i].Replace("[", "").Replace("]", ""), "HH:mm:ss.ff", CultureInfo.InvariantCulture);
                    String rest = logs[i + 1];

                    var entries = Regex.Split(rest, @"\[(.*?)\]");

                    MessageLogItem item = new MessageLogItem();
                    item.TimeStamp = new DateTime(logFile.DateTime.Year, logFile.DateTime.Month, logFile.DateTime.Day, date.Hour, date.Minute, date.Second, date.Millisecond);
                    item.Category = (LogCategory)Enum.Parse(typeof(LogCategory), entries[1]);
                    item.CallerFile = entries[3];
                    item.CallerMethodName = entries[5];
                    item.CallerLineNumber = int.Parse(entries[7]);
                    item.Message = new String(entries[8].Skip(2).ToArray());

                    logItems.Add(item);
                }
                catch (Exception ex)
                {
                    LogManager.Default.Log(ex, "Could not parse log line: " + logs[i]);
                }
            }

            return logItems;
        }
    }
}