Ejemplo n.º 1
0
        public static void InitCfg()
        {
            if (s_instance == null)
            {
                var file = RealmServerRunDir + ConfigFileName;
                if (File.Exists(file))
                {
                    log.Info("Loading ToolConfig from {0}...", Path.GetFullPath(ConfigFileName));
                    s_instance = Load(file);
                    InitPhase2();

                    if (s_instance.PATool != null)
                    {
                        return;
                    }
                }
                else
                {
                    InitPhase2();
                    s_instance = new ToolConfig
                    {
                        m_filename = file
                    };
                }

                s_instance.PATool = new PATool();
                s_instance.PATool.Init(s_instance,
                                       PAToolLogFile, new DirectoryInfo(PAToolDefaultDir),
                                       new FileStreamTarget(PAToolDefaultOutputFile),
                                       LogConverter.GetParser(LogParserType.Sniffitzt));
                s_instance.Save();
            }
        }
Ejemplo n.º 2
0
        public Log Add(DTO.Log log)
        {
            Log domainLog = LogConverter.DTOToDomain(log);

            _db.Logs.Add(domainLog);
            _db.SaveChanges();
            return(Get(domainLog.LogID));
        }
Ejemplo n.º 3
0
        public void AssertExpectedRecords(string input, params string[] expected)
        {
            var records = LogConverter.SplitRecord(input);

            Assert.AreEqual(expected.Length, records.Length);
            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], records[i]);
            }
        }
Ejemplo n.º 4
0
        //[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2100:SQL クエリのセキュリティ脆弱性を確認")]
        public override IDbCommand GetSqlCommand(StoredFunction function, EventHandler <LogEventArgs> logEvent, IDbConnection connection, IDbTransaction transaction)
        {
            if (connection != null && !(connection is NpgsqlConnection))
            {
                throw new ArgumentException("connectoin");
            }
            if ((transaction != null) && !(transaction is NpgsqlTransaction))
            {
                throw new ArgumentException("transaction");
            }
            StringBuilder buf = new StringBuilder();

            buf.Append("select * from ");
            buf.Append(GetEscapedIdentifier(function.SchemaName, function.Name, null, true));
            buf.Append("(");
            bool needComma           = false;
            List <NpgsqlParameter> l = new List <NpgsqlParameter>();

            foreach (Parameter p in function.Parameters)
            {
                if (p.Direction == ParameterDirection.Output)
                {
                    continue;
                }
                string pName = p.Name ?? p.Index.ToString();
                if (needComma)
                {
                    buf.Append(", ");
                }
                buf.Append(':');
                buf.Append(pName);
                buf.Append("::");
                buf.Append(p.BaseType);
                NpgsqlDbType t;
                if (!TypeToDbType.TryGetValue(p.ValueType, out t))
                {
                    t = NpgsqlDbType.Text;
                }
                NpgsqlParameter np = new NpgsqlParameter(pName, t)
                {
                    Direction = p.Direction
                };
                l.Add(np);
                needComma = true;
            }
            buf.Append(")");
            NpgsqlCommand cmd = new NpgsqlCommand(buf.ToString(), connection as NpgsqlConnection, transaction as NpgsqlTransaction)
            {
                CommandType = CommandType.Text
            };

            cmd.Parameters.AddRange(l.ToArray());
            LogConverter.NewLogConverter(cmd, logEvent);
            return(cmd);
        }
Ejemplo n.º 5
0
 public void AssertExpectedFileInfo(string input, string ns, string function, string filename, int?lineNo, string type = "LazyCompile")
 {
     foreach (var curInput in new[] { input, "\"" + input + "\"" })
     {
         var res = LogConverter.ExtractNamespaceAndMethodName(curInput, false, type);
         Assert.AreEqual(ns, res.Namespace);
         Assert.AreEqual(function, res.Function);
         Assert.AreEqual(filename, res.Filename);
         Assert.AreEqual(lineNo, res.LineNumber);
     }
 }
Ejemplo n.º 6
0
            public static LogConverter NewLogConverter(NpgsqlCommand command, EventHandler <LogEventArgs> logEvent)
            {
                if (logEvent == null)
                {
                    return(null);
                }
                LogConverter conv = new LogConverter()
                {
                    Log = logEvent
                };

                command.Disposed          += conv.Command_Disposed;
                command.Connection.Notice += conv.Notice;
                return(conv);
            }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            var bus = new Bus(new Dispatcher.Dispatcher());
            var printers = new[] { new Printer(bus, 1), new Printer(bus, 2), new Printer(bus, 3), new Printer(bus, 4) };

            var printerPool = printers
                .Select(printer => new WideningHandler<PrintJob, Message>(printer))
                .Select(printer => new QueuedHandler(printer, bus) { MaxQueueLength = 1 })
                .ToArray();

            var refillPool = printers
                .Select(printer => new WideningHandler<RefillPaper, Message>(printer))
                .Select(printer => new QueuedHandler(printer, bus) { MaxQueueLength = 1 })
                .ToArray();

            foreach (var printer in refillPool)
            {
                bus.Subscribe<RefillPaper>(new NarrowingHandler<RefillPaper, Message>(printer));
                // subscribe the printer directly to RefillPaper as we don't want to distribute that with the print jobs
            }

            var office = Enumerable.Range(0, 50)
                .Select(i => new Employee(bus, i))
                .ToArray();

            var loadBalancer = new RoundRobinLoadBalancer(printerPool);
            var printerRetryHandler = new RetryHandler(loadBalancer, bus);
            var retryManager = new RetryManager(bus);
            var timerService = new TimerService(bus);

            bus.Subscribe<FutureMessage>(timerService);
            bus.Subscribe<RetryMessage>(retryManager);
            bus.Subscribe<SuccessMessage>(retryManager);

            bus.Subscribe(new NarrowingHandler<PrintJob, Message>(printerRetryHandler));

            var console = new QueuedHandler(new WideningHandler<LogMessage, Message>(new ConsoleHandler()), bus);
            bus.Subscribe<LogMessage>(new NarrowingHandler<LogMessage, Message>(console));

            var porter = new Porter(bus);
            bus.Subscribe(porter);

            var converter = new LogConverter(bus);
            bus.Subscribe<PrintJob>(converter);
            bus.Subscribe<OutOfPaper>(converter);
            bus.Subscribe<PagePrinted>(converter);
            bus.Subscribe<RetryMessage>(converter);
        }
Ejemplo n.º 8
0
        //[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2100:SQL クエリのセキュリティ脆弱性を確認")]
        public override IDbCommand GetSqlCommand(string sqlCommand, EventHandler <LogEventArgs> logEvent, IDbConnection connection)
        {
            if (connection != null && !(connection is NpgsqlConnection))
            {
                throw new ArgumentException("connectoin");
            }
            NpgsqlConnection conn = connection as NpgsqlConnection;
            NpgsqlCommand    cmd  = new NpgsqlCommand(sqlCommand, connection as NpgsqlConnection);

            LogConverter.NewLogConverter(cmd, logEvent);
            foreach (string s in GetParameterNames(sqlCommand))
            {
                NpgsqlParameter p = new NpgsqlParameter(s, DbType.String)
                {
                    Direction = ParameterDirection.InputOutput
                };
                cmd.Parameters.Add(p);
            }
            return(cmd);
        }
Ejemplo n.º 9
0
        public HttpResponseMessage AddMessage(int ID, DTO.Log log)
        {
            string errorResponse = "";

            try
            {
                log = LogConverter.DomainToDTO(RepositoryProxy.Instance.LogRepository.Add(log));

                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
                JObject             JLog     = JObject.FromObject(log);
                response.Content = new System.Net.Http.StringContent(JLog.ToString());
                response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");

                return(response);
            }
            catch (Exception ex)
            {
                errorResponse = ex.Message;
            }

            return(new HttpResponseMessage(HttpStatusCode.BadRequest));
        }
Ejemplo n.º 10
0
        public static void Main(string[] args)
        {
            try
            {
                var logs = new List <LogFile>();
                var url  = "https://s3.amazonaws.com/uux-itaas-static/minha-cdn-logs/input-01.txt";
                var path = @"d:\agora.txt";

                if (args != null && args.Length == 2)
                {
                    url  = args[0];
                    path = args[1];
                }


                var client = new WebClient();
                using (var stream = client.OpenRead(url))
                    using (var reader = new StreamReader(stream))
                    {
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            ConvertLineToLog(line, logs);
                            Console.WriteLine(line);
                        }

                        var converter = new LogConverter(logs);
                        converter.Write(new AgoraLogWriter(path));
                    }

                Console.ReadLine();
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                Console.ReadKey();
            }
        }
Ejemplo n.º 11
0
        private void buttonConvert_Click(object sender, EventArgs e)
        {
            if (conversionBackgroundWorker.IsBusy)
            {   // Cancel conversion
                conversionBackgroundWorker.CancelAsync();
            }
            else
            {   // Check input and begin converting
                if (textBoxInputFile.Text.Trim().Length == 0)
                {
                    MessageBox.Show(this, "You must specify an input file to convert.", "Invalid input file", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else if (!File.Exists(textBoxInputFile.Text))
                {
                    MessageBox.Show(this, "The input file does not exist.", "Invalid input file", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else if (textBoxOutputFile.Text.Trim().Length == 0)
                {
                    MessageBox.Show(this, "You must specify an output file.", "Invalid output file", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    LogConverter    converter       = LogConverterFactory.create(getConverterType());
                    ColorProcessing colorProcessing = getColorProcessing();

                    object[] args = new object[4];
                    args[0] = converter;
                    args[1] = textBoxInputFile.Text;
                    args[2] = textBoxOutputFile.Text;
                    args[3] = colorProcessing;

                    progressBarConvert.Value = 0;
                    conversionBackgroundWorker.RunWorkerAsync(args);
                }
            }
        }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            DebugHelper.Init();
            LogConverter.ConvertLog(@"F:\coding\C#\WCell\Dumps\GroupDump.txt", "f:/dump.txt");
            //DoPacketAnalyzr();
            //SpellHandler.Initialize();
            //FactionMgr.Initialize();
            //SkillHandler.Initialize();
            //TalentHandler.Initialize();
            //ItemMgr.LoadAll();

            //SpellOutput.WriteAll();

            //SpellOutput.WriteAddModifierFlatSpells();
            //SpellOutput.WriteAddModifierPercentSpells();
            //SpellOutput.DisplayAll((spell) => spell.IsDeprecated);

            // DumpUpdatePackets(@"F:\coding\C#\WCell\ida\samples\uncompressed_lines.txt", "UpdatePackets.txt", false);

            // DumpUpdatePackets(@"F:\coding\C#\WCell\ida\samples\uncompressed_lines.txt", "UpdatePackets.txt", false);
            //var parser = new UpdateFieldParser(@"F:\coding\C#\WCell\ida\samples\character_blocks.txt", false);
            //var parser = new UpdateFieldParser(@"F:\coding\C#\WCell\ida\samples\creature_blocks.txt", false);
            //var parser = new UpdateFieldParser(@"F:\coding\C#\WCell\ida\samples\gameobject_blocks.txt", false);
            //SpellHandler.Initialize();

            //LockEntry.Initialize();
            //SkillHandler.Initialize();
            //FactionMgr.Initialize();
            //TalentHandler.Initialize();

            //// RaceClassMgr.Initialize();

            ////GOMgr.LoadAll();
            ////NPCMgr.LoadAll();

            //ItemMgr.LoadAll();
            //QuestMgr.LoadAll();
            ////SpellOutput.WriteAll();
            //// SpellOutput.WriteSkillSpells();
            //ItemOutput.WriteAll();

            //WorldMgr.Start();
            //var kalimdor = WorldMgr.GetRegion(MapId.Kalimdor);
            //kalimdor.AddMessage(new Message1<Region>((region) => region.AddDefaultObjects(), kalimdor));

            //SpellOutput.WriteSpellsAndEffects();
            //ClassesRaces.WriteClassesRaces(Program.OutputDir, "Races.xml", "Classes.xml", "Archetypes.xml");
            //Ralek.Program.RalekMain();

            //CommandHandler.Initialize();
            //CommandHandler.Mgr.ReactTo(new DefaultCmdTrigger("?"));

            //SkillHandler.Init();

            //ItemMgr.Templates.Where((templ) => {
            //    if (templ.ItemClass != ItemClass.Weapon && templ.Damages.TotalMin() > 0f)
            //    {
            //        Console.WriteLine(templ);
            //    }
            //    return false;
            //});

            //var templs = ItemMgr.Templates.Where((temp) => temp != null && temp.SetId == 700);
            //Console.WriteLine(templs.ToString(", "));

            //var bag = ItemMgr.GetTemplate(4245);
            //Console.WriteLine(bag);

            //Utility.Measure("spawning", 1, () => {
            //    var region = WorldMgr.GetRegion(MapId.EasternKingdoms);
            //    region.Start();
            //    region.AddDefaultObjects(false);
            //});

            //var success = PrivilegeMgr.Instance.CallMethod(null, null, "World.WorldMgr.Objects.Clear", new string[0], out result);

            // DBCEnumBuilder.WriteRideEnum();
            //DBCEnumBuilder.WriteSpellFocusEnum();
            //DBCEnumBuilder.WriteSpellEnums();
            //DBCEnumBuilder.WriteSpellMechanicEnum();
            //DBCEnumBuilder.WriteZoneEnum();
            //SkillOutput.Go();


            //SpellOutput.WriteSpellFocusSpells();
            //SpellOutput.WritePeriodicAreaAuras();
            //SpellOutput.WriteSpellsAndEffects();
            //SpellOutput.WriteAddModifierFlatSpells();
            //SpellOutput.WriteAddModifierPercentSpells();
            //SpellOutput.WriteModRatingSpells();
            //SpellOutput.WriteInvisSpells();
            //SpellOutput.WriteDynamicObjects();
            //SpellOutput.WriteFinishingMoves();
            //SpellOutput.WriteDoubleTargetSpells();
            //SpellOutput.WriteEffectBySpells();
            //SpellOutput.WriteSpellsByEffect();
            //SpellOutput.WritePassiveEffects();
            //SpellOutput.WriteChanneledSpells();
            //SpellOutput.WriteRideSpells();
            //TalentOutput.Go();

            Console.WriteLine("Press ANY key to continue...");
            Console.ReadKey();
        }
Ejemplo n.º 13
0
        private void conversionBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            SetBusyState(true);

            BackgroundWorker worker = (BackgroundWorker)sender;

            object[] args = (object[])e.Argument;

            LogConverter    converter       = (LogConverter)args[0];
            string          inputFileName   = (string)args[1];
            string          outputFileName  = (string)args[2];
            ColorProcessing colorProcessing = (ColorProcessing)args[3];

            FileStream   inputFileStream  = null;
            FileStream   outputFileStream = null;
            StreamReader inputFileReader  = null;
            StreamWriter outputFileWriter = null;

            try
            {
                inputFileStream  = File.OpenRead(inputFileName);
                outputFileStream = File.OpenWrite(outputFileName);
                inputFileReader  = new StreamReader(inputFileStream);
                outputFileWriter = new StreamWriter(outputFileStream);

                // Count the number of lines in input
                int totalLines = 0;
                while (inputFileReader.ReadLine() != null)
                {
                    ++totalLines;
                }

                // Rewind to the beginning of the input file
                inputFileStream.Seek(0, SeekOrigin.Begin);

                // Write header
                outputFileWriter.WriteLine(converter.Header);

                // Convert input to output
                int    currentLines = 0;
                string inputLine;
                while ((inputLine = inputFileReader.ReadLine()) != null)
                {
                    ++currentLines;

                    string outputLine = converter.Convert(inputLine, colorProcessing);
                    outputFileWriter.WriteLine(outputLine);

                    worker.ReportProgress((int)(currentLines * 100.0 / totalLines));

                    if (worker.CancellationPending)
                    {
                        e.Cancel = true;
                        break;
                    }
                }

                // Write footer
                outputFileWriter.WriteLine(converter.Footer);
            }
            finally
            {
                if (outputFileWriter != null)
                {
                    outputFileWriter.Close();
                }
                if (inputFileReader != null)
                {
                    inputFileReader.Close();
                }
                if (outputFileStream != null)
                {
                    outputFileStream.Close();
                }
                if (inputFileStream != null)
                {
                    inputFileStream.Close();
                }
            }
        }