Esempio n. 1
0
        /// <summary>
        /// Notify a Unity log message if it the client has been configured to
        /// notify at the specified level, if not leave a breadcrumb with the log
        /// message.
        /// </summary>
        /// <param name="condition"></param>
        /// <param name="stackTrace"></param>
        /// <param name="logType"></param>
        void Notify(string condition, string stackTrace, LogType logType)
        {
            if (Configuration.AutoNotify && logType.IsGreaterThanOrEqualTo(Configuration.NotifyLevel))
            {
                var logMessage = new UnityLogMessage(condition, stackTrace, logType);

                if (UniqueCounter.ShouldSend(logMessage))
                {
                    if (LogTypeCounter.ShouldSend(logMessage))
                    {
                        var severity          = Configuration.LogTypeSeverityMapping.Map(logType);
                        var backupStackFrames = new System.Diagnostics.StackTrace(1, true).GetFrames();
                        var forceUnhandled    = logType == LogType.Exception && !Configuration.ReportUncaughtExceptionsAsHandled;
                        var exception         = Exception.FromUnityLogMessage(logMessage, backupStackFrames, severity, forceUnhandled);
                        Notify(new Exception[] { exception }, exception.HandledState, null, logType);
                    }
                }
            }
            else
            {
                Breadcrumbs.Leave(logType.ToString(), BreadcrumbType.Log, new Dictionary <string, string> {
                    { "message", condition },
                });
            }
        }
        public ActionResult MyAction(string button)
        {
            string words        = Request.Form["words"];
            string countedWords = UniqueCounter.countUnique(words);

            ViewBag.Message = countedWords;
            return(View());
        }
Esempio n. 3
0
        public static bool TryFoundAddWall()
        {
            World.FindDistance = 20;
            List <UOItem> itemsAll = World.Ground.Where(i =>
                                                        i.Graphic == VAL_WoS ||
                                                        i.Graphic == VAL_EF1 ||
                                                        i.Graphic == VAL_EF2 //||
                                                                             /*i.Graphic == VAL_PF1*/
                                                        ).ToList();


            if (Game.Debug)
            {
                Game.PrintMessage("TryFoundAddWall " + itemsAll.Count);
            }

            bool result = false;


            List <UOItem> items = new List <UOItem>();

            foreach (UOItem allItem in itemsAll)
            {
                string positionKey = allItem.X + "|" + allItem.Y;

                try
                {
                    if (UniqueCounter.ContainsKey(allItem.Serial) && !UniqueCounter[allItem.Serial].Contains(positionKey))
                    {
                        UniqueCounter[allItem.Serial].Add(positionKey);

                        if (Game.Debug)
                        {
                            Game.PrintMessage("Duplicate ID " + allItem.Serial);
                        }
                    }
                    else if (!UniqueCounter.ContainsKey(allItem.Serial))
                    {
                        UniqueCounter.Add(allItem.Serial, new List <string>()
                        {
                            positionKey
                        });
                    }
                }
                catch (Exception ex)
                {
                    if (Game.Debug)
                    {
                        Game.PrintMessage(ex.Message);
                    }
                }

                bool isExisting = false;
                //  RemoveUnusedWalls();
                for (int i = Walls.Count - 1; i >= 0; i--)
                {
                    WallOfField wof = Walls[i];
                    for (int b = 0; b < wof.Bricks.Length; b++)//each (//uint s in wof.Bricks)
                    {
                        //UOItem brick = new UOItem(s);
                        if (wof.BrickExist(b) && allItem.Serial == wof.Bricks[b])
                        {
                            isExisting = true;
                            break;
                        }
                    }

                    if (isExisting)
                    {
                        break;
                    }
                }
                if (!isExisting)
                {
                    items.Add(allItem);
                }
            }

            if (Game.Debug)
            {
                Game.PrintMessage("TryFoundAddWall 1 " + items.Count);
            }

            if (items.Count > 0)
            {
                List <ushort> xs = new List <ushort>();
                List <ushort> ys = new List <ushort>();

                foreach (UOItem itm in items)
                {
                    if (!xs.Contains(itm.X))
                    {
                        xs.Add(itm.X);
                    }

                    if (!ys.Contains(itm.Y))
                    {
                        ys.Add(itm.Y);
                    }
                }

                Dictionary <string, List <UOItem> > posibleWalls = new Dictionary <string, List <UOItem> >();

                foreach (ushort x in xs)
                {
                    posibleWalls.Add("X:" + x, items.Where(i => i.X == x /*&& i.Graphic == xItem.Graphic*/).OrderBy(i => i.Y).ToList());
                }

                foreach (ushort y in ys)
                {
                    posibleWalls.Add("Y:" + y, items.Where(i => i.Y == y /*&& i.Graphic == yItem.Graphic*/).OrderBy(i => i.X).ToList());
                }

                //List<UOItem> snItems = items.Where(i => i.X == items[0].X && i.Graphic == items[0].Graphic).OrderBy(i => i.Y).ToList();
                //List<UOItem> weItems = items.Where(i => i.Y == items[0].Y && i.Graphic == items[0].Graphic).OrderBy(i => i.X).ToList();

                if (Game.Debug)
                {
                    Game.PrintMessage("TryFoundAddWall 3 " + posibleWalls.Count);
                }

                foreach (KeyValuePair <string, List <UOItem> > kvp in posibleWalls)
                {
                    try
                    {
                        WallOfField wof = null;
                        WallType    wt  = kvp.Key.StartsWith("X") ? WallType.SN : WallType.WE;

                        if (Game.Debug)
                        {
                            Game.PrintMessage("TryFoundAddWall 4 [" + kvp.Key + "] " + kvp.Value.Count);
                        }

                        if (kvp.Value.Count > 2)
                        {
                            wof      = new WallOfField(++WallIDCounter);
                            wof.Type = wt;

                            for (int i = 0; i < kvp.Value.Count; i++)
                            {
                                wof.Bricks[i]          = kvp.Value[i];
                                wof.BricksPositions[i] = kvp.Value[i].X + "." + kvp.Value[i].Y;
                            }
                        }

                        if (wof != null)
                        {
                            Walls.Add(wof);
                            wof.PrintInit();
                        }
                    }
                    catch (Exception ex)
                    {
                        if (Game.Debug)
                        {
                            Game.PrintMessage("Ex: " + ex);
                        }
                    }
                }
            }

            return(result);
        }
 public ActionResult Index()
 {
     UniqueCounter.countUnique("This is a kingsley kingsley");
     return(View());
 }