Ejemplo n.º 1
0
 public ErrorLogViewModel(ErrorLogItem item, List <ErrorLogItem> logs, bool haveId)
 {
     LogItem = item;
     ID      = item?.ID;
     Found   = !haveId ? null : item != null;
     Logs    = logs;
 }
        public async Task <UserActivityLogItem> LogThisActivity(UserActivityLogItem item)
        {
            try
            {
                var result = this._userActivityRepository.CreateLogItem(item);
                if (result == null)
                {
                    var error = new ErrorLogItem();
                    error.Activity     = ActivityTypes.Activities.LogCreated;
                    error.Area         = ActivityTypes.Areas.Logging;
                    error.ErrorMessage = "Could not add Logging item";
                    error.LogType      = ActivityTypes.LogTypes.Error;
                    error.TimeStamp    = DateTime.Now;
                    this._errorLoggerService.LogError(error);
                    return(null);
                }

                return(result);
            }
            catch (Exception e)
            {
                var error = new ErrorLogItem();
                error.Activity     = ActivityTypes.Activities.Error;
                error.Area         = ActivityTypes.Areas.Logging;
                error.ErrorMessage = "Could not add Logging item";
                error.LogType      = ActivityTypes.LogTypes.Error;
                error.TimeStamp    = DateTime.Now;
                this._errorLoggerService.LogError(error);
                return(null);
            }
        }
Ejemplo n.º 3
0
 private BotEmbed CreateGenericErrorEmbed(Exception exception, ErrorLogItem logItem, string source)
 {
     return(new BotEmbed(DiscordClient.CurrentUser, Color.Red, "Došlo k neočekávané chybě.")
            .AddField("ID záznamu", logItem.ID.ToString(), true)
            .AddField("Zdroj", source, true)
            .AddField(exception.GetType().Name, $"```{exception}```", false));
 }
Ejemplo n.º 4
0
        private BotEmbed CreateGenericErrorEmbed(Exception exception, ErrorLogItem logItem)
        {
            var embed = new BotEmbed(DiscordClient.CurrentUser, Color.Red, "Došlo k neočekávané chybě.")
                        .AddField("ID záznamu", logItem.ID.ToString(), false)
                        .AddField(exception.GetType().Name, $"```{exception}```", false);

            return(embed);
        }
Ejemplo n.º 5
0
        public BotEmbed CreateErrorEmbed(LogMessage message, ErrorLogItem logItem)
        {
            if (message.Exception is CommandException commandException)
            {
                return(CreateCommandErrorEmbed(commandException, logItem));
            }

            return(CreateGenericErrorEmbed(message.Exception, logItem));
        }
Ejemplo n.º 6
0
 private BotEmbed CreateCommandErrorEmbed(CommandException exception, ErrorLogItem logItem)
 {
     return(new BotEmbed(DiscordClient.CurrentUser, Color.Red, "Při provádění příkazu došlo k chybě")
            .AddField("ID záznamu", logItem.ID.ToString(), true)
            .AddField("Kanál", $"<#{exception.Context.Channel.Id}>", true)
            .AddField("Uživatel", exception.Context.User.Mention, true)
            .AddField("Zpráva", $"```{exception.Context.Message.Content}```", false)
            .AddField(exception.InnerException.GetType().Name, $"```{exception}```", false));
 }
Ejemplo n.º 7
0
        private void lbErrorItem_SelectedIndexChanged(object sender, EventArgs e)
        {
            ErrorLogItem item = (ErrorLogItem)lbErrorItem.SelectedItem;

            if (item.QueryItem != null)
            {
                txtSQL.Text = item.QueryItem.Text;
            }
            else
            {
                txtSQL.Text = "-";
            }
            txtError.Text   = item.Error.Message;
            lbInstance.Text = (item.Instance == null)?"":item.Instance.Name;
        }
Ejemplo n.º 8
0
        public static void Log(ClientContext context, ErrorLogItem errorLogItem)
        {
            string            LogApplicationURL = System.Configuration.ConfigurationManager.AppSettings["LogApplicationURL"];
            NetworkCredential networkCredential = new NetworkCredential(CommonVariables.AccountName, CommonVariables.Password, "NRES");

            using (ClientContext rootcontext = new ClientContext(LogApplicationURL))
            {
                List olistErrorLog = rootcontext.Web.Lists.GetByTitle(CommonVariables.ErrorLogListTitle);
                ListItemCreationInformation listItemCreationInformation = new ListItemCreationInformation();
                var listItem = olistErrorLog.AddItem(listItemCreationInformation);
                listItem["Title"]          = errorLogItem.MethodName;
                listItem["SubscriptionID"] = errorLogItem.SubscriptionID;
                listItem["Errormessage"]   = errorLogItem.ErrorMessage;
                listItem["StackTrace"]     = errorLogItem.StackTrace;
                listItem.Update();
                rootcontext.ExecuteQuery();
            }
        }
Ejemplo n.º 9
0
        public LogsCollection GetAllErrorLog()
        {
            LogsCollection logss = null;

            if (!this.IsReady)
            {
                base.CurDBEngine = new DatabaseEngine(this.DBType, this.Conn);
                if (this.IsReady = base.CurDBEngine.Connect())
                {
                    this.CurSQLFactory = new SQLFactory(this.DBType);
                }
            }
            if (this.IsReady)
            {
                DatabaseParameters parameters = new DatabaseParameters();
                this.CurSQLFactory.SelectCommand(parameters, this.DataStructure.Tables.LogError.ActualTableName);
                DataTable table = base.CurDBEngine.SelectQuery(this.CurSQLFactory.SQL);
                if (table != null)
                {
                    logss = new LogsCollection();
                    DataRow[] rowArray = table.Select("", this.DataStructure.Tables.LogError.LogDateTime.ActualFieldName);
                    foreach (DataRow row in rowArray)
                    {
                        ErrorLogItem item = new ErrorLogItem {
                            LogID       = row[this.DataStructure.Tables.LogError.LogID.ActualFieldName].ToString(),
                            LogDate     = Convert.ToDateTime(row[this.DataStructure.Tables.LogError.LogDateTime.ActualFieldName]),
                            LoggedBy    = new ApplicationUser(row[this.DataStructure.Tables.LogError.LogBy.ActualFieldName].ToString()),
                            Description = row[this.DataStructure.Tables.LogError.Description.ActualFieldName].ToString()
                        };
                        logss.Add(item);
                    }
                    return(logss);
                }
                this.ErrMsg = "[LogManager.GetAllErrorLog] : Failed at this.CurDBEngine.SelectQuery('" + this.CurSQLFactory.SQL + "') : " + base.CurDBEngine.ErrorMessage;
            }
            return(logss);
        }
 public IHttpActionResult Post(ErrorLogItem value)
 {
     value.Date = DateTime.Now.ToString();
     errors.Add(value);
     return(Ok());
 }