Exemple #1
0
        private static void Log(string requestId, EnLogLevel logLevel, string className, string methodName, string message, string exception = "", bool skipNotification = false)
        {
            Task.Run(() =>
            {
                const string LOG_FORMAT = "{0}:{1}:{2}";
                const int MAX_LEN       = 3850;
                message = string.Format(LOG_FORMAT, className, methodName, message);

                if (message.Length > MAX_LEN)
                {
                    message = message.Substring(0, MAX_LEN);
                }

                TeamDbContext dbContext = new TeamDbContext();
                dbContext.AppLogEntries.Add(new AppLogEntry
                {
                    RequestId        = requestId,
                    Date             = DateTime.Now,
                    User             = Utility.CurrentUserId,
                    Level            = logLevel.ToString(),
                    Message          = message,
                    ExceptionMessage = exception,
                    AdminNotified    = skipNotification
                });

                dbContext.SaveChanges();
            });
        }
Exemple #2
0
 private static void AddConnection(DBConnection dbconnection)
 {
     using (TeamDbContext dbContext = new TeamDbContext())
     {
         dbContext.DBConnections.Add(dbconnection);
         dbContext.SaveChanges();
     }
 }
Exemple #3
0
 private static void AddChart(ChartType charttype)
 {
     using (TeamDbContext dbContext = new TeamDbContext())
     {
         dbContext.ChartTypes.Add(charttype);
         dbContext.SaveChanges();
     }
 }
Exemple #4
0
 private static void AddUserDashboard(UserDashboard userdashboard)
 {
     using (TeamDbContext dbContext = new TeamDbContext())
     {
         dbContext.UserDashboards.Add(userdashboard);
         dbContext.SaveChanges();
     }
 }
Exemple #5
0
 private static void AddTransactions(Transactions transactions)
 {
     using (TeamDbContext dbContext = new TeamDbContext())
     {
         dbContext.Transactions.Add(transactions);
         dbContext.SaveChanges();
     }
 }
Exemple #6
0
        internal static ApiLogEntry SaveApiLogEntry(ApiLogEntry apiLogEntry)
        {
            using (TeamDbContext dbContext = new TeamDbContext())
            {
                dbContext.ApiLogEntries.Add(apiLogEntry);
                dbContext.SaveChanges();

                return(apiLogEntry);
            }
        }
Exemple #7
0
 private static void EditUserDatabase(User existinguser)
 {
     using (TeamDbContext dbContext = new TeamDbContext())
     {
         if (dbContext.Users.AsNoTracking().FirstOrDefault(e => e.Id == existinguser.Id && e.Deleted == false) != null)
         {
             dbContext.Users.UpdateRange(existinguser);
             dbContext.SaveChanges();
         }
     }
 }
Exemple #8
0
 private static void UpdateSchedulerDatabase(Scheduler updatescheduler)
 {
     using (TeamDbContext dbContext = new TeamDbContext())
     {
         if (dbContext.Schedulers.AsNoTracking().FirstOrDefault(e => e.Id == updatescheduler.Id) != null)
         {
             dbContext.Schedulers.UpdateRange(updatescheduler);
             dbContext.SaveChanges();
         }
     }
 }
Exemple #9
0
 private static void EditReport(ReportConfig editreport)
 {
     using (TeamDbContext dbContext = new TeamDbContext())
     {
         if (dbContext.ReportConfigs.AsNoTracking().FirstOrDefault(e => e.Id == editreport.Id) != null)
         {
             dbContext.ReportConfigs.UpdateRange(editreport);
             dbContext.SaveChanges();
         }
     }
 }
Exemple #10
0
 private static void AddReport(ReportConfig addreport)
 {
     using (TeamDbContext dbContext = new TeamDbContext())
     {
         if (dbContext.ReportConfigs.FirstOrDefault(e => e.Id == addreport.Id) == null)
         {
             dbContext.ReportConfigs.Add(addreport);
             dbContext.SaveChanges();
         }
     }
 }
 private static void AddUserDashboard(UserDashboard userdashboard)
 {
     using (TeamDbContext dbContext = new TeamDbContext())
     {
         if (dbContext.UserDashboards.FirstOrDefault(e => e.Id == userdashboard.Id) == null)
         {
             dbContext.UserDashboards.Add(userdashboard);
             dbContext.SaveChanges();
         }
     }
 }
Exemple #12
0
 private static void AddUserDatabase(User newuser)
 {
     using (TeamDbContext dbContext = new TeamDbContext())
     {
         if (dbContext.Users.FirstOrDefault(e => e.Id == newuser.Id) == null)
         {
             dbContext.Users.Add(newuser);
             dbContext.SaveChanges();
         }
     }
 }
 private static void UpdateUserDashboard(UserDashboard userdashboard)
 {
     using (TeamDbContext dbContext = new TeamDbContext())
     {
         if (dbContext.UserDashboards.AsNoTracking().FirstOrDefault(e => e.Id == userdashboard.Id && e.Deleted == false) != null)
         {
             dbContext.UserDashboards.UpdateRange(userdashboard);
             dbContext.SaveChanges();
         }
     }
 }
Exemple #14
0
 private static void AddUser(User user)
 {
     user.UserId = user.UserId.ToUpper(CultureInfo.InvariantCulture);
     using (TeamDbContext dbContext = new TeamDbContext())
     {
         if (dbContext.Users.FirstOrDefault(e => e.UserId == user.UserId) == null)
         {
             dbContext.Users.Add(user);
             dbContext.SaveChanges();
         }
     }
 }
Exemple #15
0
        public void CreatePlayer(CreatePlayerViewModel player)
        {
            Player dbPlayer = new Player
            {
                FirstName = player.FirstName,
                LastName  = player.LastName,
                TeamId    = player.SelectedTeamId.Value
            };

            _db.Players.Add(dbPlayer);
            _db.SaveChanges();
        }
Exemple #16
0
        internal static void UpdateApiLogEntry(ApiLogEntry logEntry, IRestResponse restResponse)
        {
            using (TeamDbContext dbContext = new TeamDbContext())
            {
                ApiLogEntry dbEntry = dbContext.ApiLogEntries.Find(logEntry.ApiLogEntryId);
                dbEntry.ResponseHeaders     = LoggerService.SerializeHeaders(restResponse.Headers);
                dbEntry.ResponseContentType = restResponse.ContentType;
                dbEntry.ResponseContentBody = restResponse.Content;
                dbEntry.ResponseStatusCode  = (int)restResponse.StatusCode;
                dbEntry.ResponseTimestamp   = DateTime.Now;

                dbContext.SaveChanges();
            }
        }
Exemple #17
0
        internal static void SettingSet(string keyName, string value)
        {
            keyName = keyName.ToUpper(CultureInfo.InvariantCulture);
            using (TeamDbContext dbContext = new TeamDbContext())
            {
                Setting setting = dbContext.Settings.FirstOrDefault(e => e.Key == keyName && !e.Deleted);

                if (setting == null)
                {
                    dbContext.Settings.Add(new Setting
                    {
                        Key   = keyName,
                        Value = value
                    });
                }
                else
                {
                    setting.Value = value;
                }
                dbContext.SaveChanges();
            }
        }