Ejemplo n.º 1
0
        private async Task WriteExceptionAsync(HttpContext context, Exception exception)
        {
            //返回友好的提示 Agent
            HttpResponse response = context.Response;

            string ipAddress   = Net.Ip;
            string scheme      = response.HttpContext.Request.Scheme;
            string host        = response.HttpContext.Request.Host.Value;
            string pathBase    = response.HttpContext.Request.PathBase.Value;
            string path        = response.HttpContext.Request.Path.Value;
            string queryString = response.HttpContext.Request.QueryString.Value;
            string url         = string.Format("{0}://{1}{2}{3}{4}", scheme, host, pathBase, path, queryString);
            string message     = exception.Message.Replace("\n", "");

            bool result = SaveErrorRecord(url, message, ipAddress);

            LogsManager.LogPath = string.Empty;
            LogsManager.WriteLog(LogsFile.Error, string.Format("--全局异常过滤器捕获的异常--开始------------"));
            LogsManager.WriteLog(LogsFile.Error, string.Format("系统编号:{0}", BaseSystemConfig.SystemID));
            LogsManager.WriteLog(LogsFile.Error, string.Format("访问网址:{0}", url));
            LogsManager.WriteLog(LogsFile.Error, string.Format("异常信息:{0}", message));
            LogsManager.WriteLog(LogsFile.Error, string.Format("IP地址:{0}", ipAddress));
            LogsManager.WriteLog(LogsFile.Error, string.Format("保存结果:{0}", result));
            LogsManager.WriteLog(LogsFile.Error, string.Format("--全局异常过滤器捕获的异常--结束------------"));

            var data = new
            {
                status  = response.StatusCode,
                message = exception.Message,
            };

            response.Redirect("/home/error");
            response.ContentType = "application/json";
            await response.WriteAsync(JsonConvert.SerializeObject(data)).ConfigureAwait(false);
        }
Ejemplo n.º 2
0
    public void SendNewOracleData()
    {
        oracleDataLog.Add(oracleData);
        LogsManager.SendLogDirectly(new Log(
                                        LogType.GotOracleInfo,
                                        new Dictionary <string, string>()
        {
            { "itemName", oracleData.itemName },
            { "hour", (oracleData.bestPriceIndex * 3).ToString() },
            { "maxHour", (oracleData.bestPriceIndex * 3 + 3).ToString() }
        }
                                        ));

        string json = JsonConvert.SerializeObject(oracleDataLog);

        FirebaseCommunicator.instance.SendObject(json, new string[] { oracleReferenceName, FirebaseCommunicator.instance.FamilyId.ToString(), DateTime.Today.ToString(dateFormat) }, (task) =>
        {
            if (task.IsFaulted)
            {
                Debug.LogError("Failed to send oracle data: " + task.Exception.Message);
            }
            else if (task.IsCompleted)
            {
                Debug.Log("yey sent oracle data");
            }
        });
    }
Ejemplo n.º 3
0
        /// <summary>
        /// Method load all files from folder with specyfied extension
        /// </summary>
        /// <param name="filesCollection"></param>
        /// <param name="dir"></param>
        /// <param name="searchPattern"></param>
        private void GetFilesFromFolder(List <FileProperties> filesCollection, DirectoryInfo dir, string searchPattern, string dirName)
        {
            filesCollection.Add(new FileProperties(dir.Name));

            // get list of files
            try
            {
                foreach (FileInfo f in dir.GetFiles(searchPattern))
                {
                    if (_extManager.Extensions.Contains(f.Extension))
                    {
                        // Get information about files
                        filesCollection.Last().children.Add(new FileProperties(f, dirName));
                        filesCollection.Last().children.Last().fileData.AddRange(_fileManager.LoadAndReadFile(f.FullName));
                    }
                }
            }
            catch (Exception ex)
            {
                LogsManager.SaveErrorToLogFile(ex.Message);
            }

            // process each directory
            // If I have been able to see the files in the directory I should also be able
            // to look at its directories so I dont think I should place this in a try catch block
            foreach (DirectoryInfo d in dir.GetDirectories())
            {
                GetFilesFromFolder(filesCollection.Last().children, d, searchPattern, dirName);
            }
        }
    public IEnumerator SetUp(int[,] matrix)
    {
        //cG.alpha = 1;
        this.matrix = matrix;
        yield return(null);

        int[] strategyA = (matrix.GetLength(0) == 2) ? GetRow(0) : GetColumn(0);
        int[] strategyB = (matrix.GetLength(0) == 2) ? GetRow(1) : GetColumn(1);

        #region Wyszukiwanie najmniejszej i największej wartości
        int min, max;

        int minA = strategyA.Min();
        int minB = strategyB.Min();

        int maxA = strategyA.Max();
        int maxB = strategyB.Max();

        min = (minA < minB) ? minA : minB;
        max = (maxA > maxB) ? maxA : maxB;
        #endregion

        LogsManager.ins.AddLog("Trwa wypisywanie wartości dla gracza, który posiada dokładnie dwie strategie.");
        yield return(LogsManager.Wait());

        WriteValues(min, max);

        yield return(WriteLines(strategyA, strategyB));
    }
 public CreateTimeCardManager()
 {
     logcycle    = new LogsManager();
     geotabCalls = new GeotabAPIAdapter();
     lastRunTime = new LastRecordedTime();
     paycomCalls = new PaycomAPIAdapter();
 }
Ejemplo n.º 6
0
    void CreateManagerQuest()
    {
        Dictionary <string, int> questItems = new Dictionary <string, int>();
        List <Item> items = ItemManager.instance.itemsData.Items.FindAll((item) => item.Unlocked && item.IsSellable());

        for (int i = 0; i < ManagerQuest.amountOfItems; i++)
        {
            int  randomIndex = UnityEngine.Random.Range(0, items.Count);
            Item item        = items[randomIndex];
            while (questItems.ContainsKey(item.ItemNameKey))
            {
                randomIndex = (randomIndex + 1) % items.Count;
                item        = items[randomIndex];
            }

            questItems.Add(item.ItemNameKey, UnityEngine.Random.Range(1, ManagerQuest.maxItemQuantity));
        }

        managerQuest = new ManagerQuest(questItems, DateTime.Today.ToString(dateFormat));

        LogsManager.SendLogDirectly(new Log(
                                        LogType.ManagerQuestCreated,
                                        new Dictionary <string, string>()
        {
            { "itemsToSell", JsonConvert.SerializeObject(questItems) }
        }
                                        ));
    }
    private IEnumerator WriteLines(int[] strA, int[] strB)
    {
        LogsManager.ins.AddLog("Trwa wypisywanie strategii drugiego gracza w postaci prostych.");
        yield return(LogsManager.Wait());

        Rect rect = valuesList.GetComponent <RectTransform>().rect;

        int   valA, valB;
        float height = rect.height / leftValues.childCount;
        float width  = rect.width;

        float halfOnce = height / 2;

        for (int i = 0; i < strA.Length; i++)
        {
            valA = strA[i];
            valB = strB[i];

            UILineRenderer lR = Instantiate(linePrefab, valuesList).GetComponent <UILineRenderer>();

            lR.Points[0] = new Vector2(0, rect.height - (GetChildID(valA) * height) - halfOnce);
            lR.Points[1] = new Vector2(width, rect.height - (GetChildID(valB) * height) - halfOnce);

            lines.Add(lR);

            LogsManager.ins.AddLog("Wypisano strategię.");
            yield return(LogsManager.Wait());
        }
    }
        public IEnumerator SolveGame(Game game)
        {
            sbyte minInRow, maxInCol;
            byte  cellID = 0;

            LogsManager.ins.AddLog("Zaznaczanie punktów siodłowych.");

            yield return(MinMaxPanel.ins.SetUp(true));

            yield return(LogsManager.Wait());

            TableManager.ins.SelectCell(0, EColors.Default, true);

            for (byte i = 0; i < game.gameData.matrix.GetLength(0); i++)
            {
                for (byte j = 0; j < game.gameData.matrix.GetLength(1); j++)
                {
                    if (game.gameData.matrix[i, j] == (sbyte)valueOfGame)
                    {
                        minInRow = game.GetRow(i).Min();
                        maxInCol = game.GetColumn(j).Max();

                        if (minInRow == maxInCol)
                        {
                            LogsManager.ins.AddLog("Zaznaczono punkt siodłowy.");
                            yield return(LogsManager.Wait());

                            TableManager.ins.SelectCell(cellID, EColors.Green);
                        }
                    }

                    cellID++;
                }
            }
        }
Ejemplo n.º 9
0
        public void Send(string to, string subject, string body, bool isBodyHtml)
        {
            try
            {
                using (var msg = new MailMessage(_EmailFrom, to))
                {
                    msg.Subject    = subject;
                    msg.Body       = body;
                    msg.IsBodyHtml = isBodyHtml;

                    SmtpClient smtpClient = new SmtpClient(_SMPTHosValue, _SMPTPortValue);

                    smtpClient.EnableSsl             = true;
                    smtpClient.Timeout               = 120000;
                    smtpClient.UseDefaultCredentials = false;
                    smtpClient.DeliveryMethod        = SmtpDeliveryMethod.Network;
                    smtpClient.Credentials           = new System.Net.NetworkCredential(_EmailFrom, _EmailFromDecodedPasswordValue);
                    smtpClient.Send(msg);
                }
            }
            catch (SmtpException ex)
            {
                if (ex.HResult == -2146233088)
                {
                    LogsManager.Error(ex);
                    throw new BusinessException("Operation timed out, please try again");
                }
                throw;
            }
        }
Ejemplo n.º 10
0
    void Awake()
    {
        if (instance != null)
        {
            Destroy(this);
        }
        else
        {
            instance = this;
        }
        logsManager = LogsManager.instance;


        DontDestroyOnLoad(this);

        LoadSceneAdditivelyAndSetActive(1);

        FirebaseCommunicator.LoggedIn.AddListener(OnLoggedIn);
        FirebaseCommunicator.GameStarted.AddListener(OnGameStarted);

        SceneManager.sceneLoaded   += OnSceneLoaded;
        SceneManager.sceneUnloaded += OnSceneUnloaded;

        Localisation.SetLanguage((Language)PlayerPrefs.GetInt("Language", 0));

        SceneManager.sceneLoaded += OnSceneLoaded;
    }
Ejemplo n.º 11
0
        public IEnumerator SolveGame(Game game)
        {
            yield return(null);

            LogsManager.ins.AddLog(string.Format("{0} ma dokładnie dwie strategie.", game.gameData.playerB));
            LogsManager.ins.AddLog("Wyszukiwanie strategii dającej największą przegraną dla gracza");
            yield return(LogsManager.Wait());

            id = IDTheLargestVal(game.gameData);
            yield return(CrossOverMax(id, game.gameData));

            subGame[1, 0] = game.gameData.matrix[point.strategyA_ID, 0];
            subGame[1, 1] = game.gameData.matrix[point.strategyA_ID, 1];

            subGame[0, 0] = game.gameData.matrix[point.strategyB_ID, 0];
            subGame[0, 1] = game.gameData.matrix[point.strategyB_ID, 1];

            char[] useingStrategies = new char[2] {
                game.gameData.rowStrategies[point.strategyA_ID],
                game.gameData.rowStrategies[point.strategyB_ID]
            };
            game.gameData.rowStrategies = useingStrategies.ToList();

            game.gameData.matrix = subGame;
        }
Ejemplo n.º 12
0
        public Settings(MainWindow _window)
        {
            try
            {
                logsManager = new LogsManager();

                InitializeComponent();

                var settings = SettingsManager.GetSettings();
                mainWindow = _window;
                mainWindow.SettingsButton.IsEnabled = false;

                if (settings == null)
                {
                    return;
                }

                UserNameTextBox.Text = settings.User;
                PathTextBox.Text     = settings.Path;
            }
            catch (Exception exception)
            {
                logsManager.Log(exception.ToString());
            }
        }
Ejemplo n.º 13
0
    protected override void ActivateZone()
    {
        base.ActivateZone();

        LogsManager.SendLogDirectly(new Log(
                                        LogType.SecretDoorInteracted,
                                        null
                                        ));

        if (!doorTime.IsDecrypted())
        {
            // Door still hasn't been requested or expired
            if (!doorTime.IsValid() || doorTime.HasExpired())
            {
                CreateNewRequest();

                SendDoorTime(doorTime);
            }
            else
            {
                Debug.Log("Already requested!");
            }
        }

        if (!doorTime.unlocked)
        {
            secretDoorUI.Init(this);
        }
    }
Ejemplo n.º 14
0
        public void Process(Exception ex1)
        {
            var ex = ex1.GetMostInnerException();

            if (ex is BusinessException)
            {
                if (ex is BusinessHttpResponseException)
                {
                    throw new HttpResponseException(new HttpResponseMessage((ex as BusinessHttpResponseException).StatusCode)
                    {
                        Content      = new OneAppStringContent((ex as BusinessHttpResponseException).ErrorResponse),
                        ReasonPhrase = "Business Error"
                    });
                }
                else
                {
                    throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                    {
                        Content      = new OneAppStringContent(new ErrorResponse((ex as BusinessException).Message)),
                        ReasonPhrase = "Business Error"
                    });
                }
            }
            //Log Critical errors
            LogsManager.Error(ex);
            string message = OneAppConfigurationKeys.ShowException ? ex.Message : "An error occurred, please try again or contact the administrator.";

            throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
            {
                Content      = new OneAppStringContent(new ErrorResponse(message)),
                ReasonPhrase = "Unexpect Error"
            });
        }
Ejemplo n.º 15
0
        private IEnumerator ColumnsDomination()
        {
            sbyte[] colA, colB;
            yield return(LogsManager.Wait());

            for (byte i = 0; i < gameData.matrix.GetLength(1) - 1; i++)
            {
                colA = GetColumn(i);

                for (byte j = (byte)(i + 1); j < gameData.matrix.GetLength(1); j++)
                {
                    colB = GetColumn(j);
                    LogsManager.ins.AddLog(string.Format("Porównuję strategię gracza: {2} - {0} z {1}", gameData.colStrategies[i].ToString(), gameData.colStrategies[j].ToString(), gameData.playerB));


                    TableManager.ins.SelectColumn((byte)gameData.matrix.GetLength(1), i, EColors.Green, true);
                    yield return(LogsManager.Wait());

                    TableManager.ins.SelectColumn((byte)gameData.matrix.GetLength(1), j, EColors.Blue);
                    yield return(LogsManager.Wait());

                    // 1 = colA dominuje colB; 1 = colB dominuje colA; 0 = brak dominacji
                    sbyte domination = Compare(colA, colB);

                    if (domination == 1)
                    {
                        LogsManager.ins.AddLog(string.Format("Strategia {0} jest dominowana przez {1}", gameData.colStrategies[j].ToString(), gameData.colStrategies[i].ToString()));
                        TableManager.ins.SelectColumn((byte)gameData.matrix.GetLength(1), j, EColors.Red, true);
                        yield return(LogsManager.Wait());

                        gameData.matrix = RemoveColumnFromMatrix(j--);
                        TableManager.ins.DisplayTable(gameData);
                        yield return(LogsManager.Wait());
                    }
                    else if (domination == -1)
                    {
                        LogsManager.ins.AddLog(string.Format("Strategia {0} dominuje strategię {1}", gameData.colStrategies[j].ToString(), gameData.colStrategies[i]).ToString());
                        TableManager.ins.SelectColumn((byte)gameData.matrix.GetLength(1), i, EColors.Red, true);
                        yield return(LogsManager.Wait());

                        gameData.matrix = RemoveColumnFromMatrix(i--);
                        TableManager.ins.DisplayTable(gameData);
                        yield return(LogsManager.Wait());

                        break;
                    }
                    else
                    {
                        TableManager.ins.SelectCell(0, EColors.Default, true);
                        LogsManager.ins.AddLog("Brak dominacji pomiędzy strategiami");
                        yield return(LogsManager.Wait());
                    }
                }
            }

            yield return(null);
        }
Ejemplo n.º 16
0
        private IEnumerator RowsDomination()
        {
            sbyte[] rowA, rowB;
            yield return(LogsManager.Wait());

            for (byte i = 0; i < gameData.matrix.GetLength(0) - 1; i++)
            {
                rowA = GetRow(i);

                for (byte j = (byte)(i + 1); j < gameData.matrix.GetLength(0); j++)
                {
                    LogsManager.ins.AddLog(string.Format("Porównuję strategię gracza: {2} - {0} z {1}", gameData.rowStrategies[i].ToString(), gameData.rowStrategies[j].ToString(), gameData.playerA));
                    rowB = GetRow(j);

                    TableManager.ins.SelectRow((byte)gameData.matrix.GetLength(0), i, EColors.Green, true);
                    yield return(LogsManager.Wait());

                    TableManager.ins.SelectRow((byte)gameData.matrix.GetLength(0), j, EColors.Blue);
                    yield return(LogsManager.Wait());

                    // -1 = rowA  dominuje rowB; 1 = rowB dominuje rowA; 0 = brak dominacji
                    sbyte domination = Compare(rowA, rowB);

                    if (domination == -1)
                    {
                        LogsManager.ins.AddLog(string.Format("Strategia {0} jest dominowana przez {1}", gameData.rowStrategies[j].ToString(), gameData.rowStrategies[i].ToString()));
                        TableManager.ins.SelectRow((byte)gameData.matrix.GetLength(0), j, EColors.Red, true);
                        yield return(LogsManager.Wait());

                        gameData.matrix = RemoveRowFromMatrix(j--);
                        TableManager.ins.DisplayTable(gameData);
                        yield return(LogsManager.Wait());
                    }
                    else if (domination == 1)
                    {
                        LogsManager.ins.AddLog(string.Format("Strategia {0} dominuje strategię {1}", gameData.rowStrategies[j].ToString(), gameData.rowStrategies[i].ToString()));

                        TableManager.ins.SelectRow((byte)gameData.matrix.GetLength(0), i, EColors.Red, true);
                        yield return(LogsManager.Wait());

                        gameData.matrix = RemoveRowFromMatrix(i--);
                        TableManager.ins.DisplayTable(gameData);
                        yield return(LogsManager.Wait());

                        break;
                    }
                    else
                    {
                        LogsManager.ins.AddLog("Brak dominacji pomiędzy strategiami.");
                        TableManager.ins.SelectCell(0, EColors.Default, true);
                        yield return(LogsManager.Wait());
                    }
                }
            }

            yield return(null);
        }
Ejemplo n.º 17
0
        public void StartBotAsync()
        {
            using var cts = new CancellationTokenSource();

            // StartReceiving does not block the caller thread. Receiving is done on the ThreadPool.
            Bot.StartReceiving(new DefaultUpdateHandler(HandleUpdateAsync, HandleErrorAsync), cts.Token);

            LogsManager.CreateLogSync($"Start listening for @{Bot.GetMeAsync().Result.Username}", LogLevel.Info);
        }
Ejemplo n.º 18
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            _eventAggregator.Unsubscribe(this);
            Log log = new Log();

            log.Text = "Program forceblly closed";
            log.Type = LogType.ProgramClosed;
            LogsManager.GetLogsManager().AddLog(log);
        }
Ejemplo n.º 19
0
    public void FailedMission()
    {
        LogsManager.SendLogDirectly(new Log(LogType.MissionFail, null));
        UpdateBaseDifficulty(difficultyDeathModifier);

        stats.stats.numberOfMissions++;
        stats.stats.numberOfDeaths++;

        UpdateStats();
    }
Ejemplo n.º 20
0
    public void SuccessfulMission()
    {
        LogsManager.SendLogDirectly(new Log(LogType.MissionSuccess, null));
        UpdateBaseDifficulty(difficultyWinModifier);

        stats.stats.numberOfMissions++;
        stats.stats.numberOfSuccessfulMissions++;

        UpdateStats();
    }
Ejemplo n.º 21
0
 private void OnSceneUnloaded(Scene arg0)
 {
     LogsManager.SendLogDirectly(new Log(
                                     LogType.SceneUnloaded,
                                     new Dictionary <string, string>()
     {
         { "scene", arg0.name }
     }
                                     ));
 }
    IEnumerator LateStart()
    {
        yield return(new WaitForSeconds(0.1f));

        LogsManager.SendLogDirectly(new Log(LogType.MissionStart, new Dictionary <string, string>()
        {
            { "Class", GameManager.instance.currentSelectedClass.ClassName }
        }));
        MissionStarted.Invoke(LanternTimeLimit);
    }
Ejemplo n.º 23
0
 public void AddFile(BinaryFile file)
 {
     files.Enqueue(file);
     LogsManager.LogToTextFile(new Log
     {
         Severity = LogSeverity.Low,
         Type     = LogType.FileCreated,
         Text     = "New data file created."
     });
 }
Ejemplo n.º 24
0
 private void OnPlayerEnteredRoomFirstTime()
 {
     LogsManager.SendLogDirectly(new Log(
                                     LogType.RoomExplored,
                                     new Dictionary <string, string>()
     {
         { "RoomName", gameObject.name },
         { "RoomType", type.ToString() }
     }
                                     ));
 }
Ejemplo n.º 25
0
    public IEnumerator SetUp(bool succes)
    {
        CanvasGroup panel = (succes) ? successPanel : failedPanel;

        panel.alpha       = 1;
        blurImage.enabled = true;
        yield return(LogsManager.Wait(3));

        blurImage.enabled = false;
        panel.alpha       = 0;
    }
Ejemplo n.º 26
0
 internal void Check()
 {
     IsChecked = true;
     LogsManager.SendLogDirectly(new Log(
                                     LogType.ManagerQuestChecked,
                                     new Dictionary <string, string>()
     {
         { "StartDay", StartDay }
     }
                                     ));
 }
Ejemplo n.º 27
0
    private void Start()
    {
        LogsManager.SendLogDirectly(new Log(
                                        LogType.GameStarted,
                                        new Dictionary <string, string>(),
                                        DateTime.Now
                                        ));

        // Setup listener for new missions
        FirebaseCommunicator.instance.SetupListenForChildAddedEvents(new string[] { Mission.firebaseReferenceName, FirebaseCommunicator.instance.FamilyId.ToString() }, OnMissionAdded);
    }
    public void Logout()
    {
        PlayerPrefs.DeleteKey(PlayerSettingsKeys.familyId);
        FileUtils.DeleteFile(FileUtils.GetPathToPersistent(FirebaseCommunicator.familyIDSavePath));

        IsLoggedIn = false;
        LogsManager.SendLogDirectly(new Log(
                                        LogType.LoggedOut,
                                        null
                                        ));
    }
Ejemplo n.º 29
0
 public LogsManager()
 {
     if (instance == null)
     {
         instance = this;
         logs     = new List <Log>();
     }
     else
     {
         Debug.LogError("LogsManager already initialized");
     }
 }
Ejemplo n.º 30
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (targetHealth == null)
        {
            targetHealth = other.GetComponent <Health>();
        }

        LogsManager.SendLogDirectly(new Log(
                                        LogType.HealingReceived,
                                        null
                                        ));
    }