コード例 #1
0
 public List <SupportSessionLog> Add(List <SupportSessionLog> supportSessionLog, int callerId)
 {
     using (UBContext ubc = new UBContext())
     {
         try
         {
             ubc.Add(supportSessionLog);
             ubc.SaveChanges();
             return(supportSessionLog);
         }
         catch (Exception ex)
         {
             if (ex.InnerException != null)
             {
                 Utils.Logging.AddLog(new SystemLog()
                 {
                     LoggerName = "Unifiedban.Data",
                     Date       = DateTime.Now,
                     Function   = "Unifiedban.Data.SupportSessionLogService.Add",
                     Level      = SystemLog.Levels.Warn,
                     Message    = ex.InnerException.Message,
                     UserId     = callerId
                 });
             }
         }
         return(null);
     }
 }
コード例 #2
0
ファイル: ButtonService.cs プロジェクト: unified-ban/Data
        public Button Update(Button button, int callerId)
        {
            using (UBContext ubc = new UBContext())
            {
                Button exists = ubc.Buttons
                                .Where(x => x.ButtonId == button.ButtonId)
                                .FirstOrDefault();
                if (exists == null)
                {
                    return(null);
                }

                try
                {
                    exists.Name    = button.Name;
                    exists.Content = button.Content;
                    exists.Scope   = button.Scope;
                    exists.GroupId = button.GroupId;

                    ubc.SaveChanges();
                    return(button);
                }
                catch (Exception ex)
                {
                    Utils.Logging.AddLog(new SystemLog()
                    {
                        LoggerName = "Unifiedban",
                        Date       = DateTime.Now,
                        Function   = "Unifiedban.Data.ButtonService.Update",
                        Level      = SystemLog.Levels.Warn,
                        Message    = ex.Message,
                        UserId     = callerId
                    });
                    if (ex.InnerException != null)
                    {
                        Utils.Logging.AddLog(new SystemLog()
                        {
                            LoggerName = "Unifiedban.Data",
                            Date       = DateTime.Now,
                            Function   = "Unifiedban.Data.ButtonService.Update",
                            Level      = SystemLog.Levels.Warn,
                            Message    = ex.InnerException.Message,
                            UserId     = callerId
                        });
                    }
                }
                return(null);
            }
        }
コード例 #3
0
        public Language UpdateLanguage(Language language, int callerId)
        {
            using (UBContext ubc = new UBContext())
            {
                Language exists = ubc.Languages
                                  .Where(x => x.LanguageId == language.LanguageId)
                                  .FirstOrDefault();
                if (exists == null)
                {
                    return(null);
                }

                try
                {
                    exists.Name          = language.Name;
                    exists.UniversalCode = language.UniversalCode;
                    exists.Status        = language.Status;

                    ubc.SaveChanges();
                    return(language);
                }
                catch (Exception ex)
                {
                    Utils.Logging.AddLog(new SystemLog()
                    {
                        LoggerName = "Unifiedban",
                        Date       = DateTime.Now,
                        Function   = "Unifiedban.Data.LanguageService.UpdateLanguage",
                        Level      = SystemLog.Levels.Warn,
                        Message    = ex.Message,
                        UserId     = callerId
                    });
                    if (ex.InnerException != null)
                    {
                        Utils.Logging.AddLog(new SystemLog()
                        {
                            LoggerName = "Unifiedban.Data",
                            Date       = DateTime.Now,
                            Function   = "Unifiedban.Data.LanguageService.UpdateLanguage",
                            Level      = SystemLog.Levels.Warn,
                            Message    = ex.InnerException.Message,
                            UserId     = callerId
                        });
                    }
                }
                return(null);
            }
        }
コード例 #4
0
        public Operator Update(Operator oper, int callerId)
        {
            using (UBContext ubc = new UBContext())
            {
                Operator exists = ubc.Operators
                                  .Where(x => x.OperatorId == oper.OperatorId)
                                  .FirstOrDefault();
                if (exists == null)
                {
                    return(null);
                }

                try
                {
                    exists.TelegramUserId = oper.TelegramUserId;
                    exists.Level          = oper.Level;

                    ubc.SaveChanges();
                    return(oper);
                }
                catch (Exception ex)
                {
                    Utils.Logging.AddLog(new SystemLog()
                    {
                        LoggerName = "Unifiedban",
                        Date       = DateTime.Now,
                        Function   = "Unifiedban.Data.OperatorService.Update",
                        Level      = SystemLog.Levels.Warn,
                        Message    = ex.Message,
                        UserId     = callerId
                    });
                    if (ex.InnerException != null)
                    {
                        Utils.Logging.AddLog(new SystemLog()
                        {
                            LoggerName = "Unifiedban.Data",
                            Date       = DateTime.Now,
                            Function   = "Unifiedban.Data.OperatorService.Update",
                            Level      = SystemLog.Levels.Warn,
                            Message    = ex.InnerException.Message,
                            UserId     = callerId
                        });
                    }
                }
                return(null);
            }
        }
コード例 #5
0
        public Entry UpdateEntry(Entry entry, int callerId)
        {
            using (UBContext ubc = new UBContext())
            {
                Entry exists = ubc.TranslationEntries
                               .Where(x => x.KeyId == entry.KeyId)
                               .FirstOrDefault();
                if (exists == null)
                {
                    return(null);
                }

                try
                {
                    exists.LanguageId  = entry.LanguageId;
                    exists.Translation = entry.Translation;

                    ubc.SaveChanges();
                    return(entry);
                }
                catch (Exception ex)
                {
                    Utils.Logging.AddLog(new SystemLog()
                    {
                        LoggerName = "Unifiedban",
                        Date       = DateTime.Now,
                        Function   = "Unifiedban.Data.LanguageService.UpdateEntry",
                        Level      = SystemLog.Levels.Warn,
                        Message    = ex.Message,
                        UserId     = callerId
                    });
                    if (ex.InnerException != null)
                    {
                        Utils.Logging.AddLog(new SystemLog()
                        {
                            LoggerName = "Unifiedban.Data",
                            Date       = DateTime.Now,
                            Function   = "Unifiedban.Data.LanguageService.UpdateEntry",
                            Level      = SystemLog.Levels.Warn,
                            Message    = ex.InnerException.Message,
                            UserId     = callerId
                        });
                    }
                }
                return(null);
            }
        }
コード例 #6
0
        public SystemLog.ErrorCodes Remove(DashboardSession dashboardSession, int callerId)
        {
            using (UBContext ubc = new UBContext())
            {
                DashboardSession exists = ubc.DashboardSessions
                                          .Where(x => x.DashboardSessionId == dashboardSession.DashboardSessionId &&
                                                 x.DashboardUserId == dashboardSession.DashboardUserId &&
                                                 x.DeviceId == dashboardSession.DeviceId)
                                          .FirstOrDefault();
                if (exists == null)
                {
                    return(SystemLog.ErrorCodes.Error);
                }

                try
                {
                    ubc.Remove(exists);
                    ubc.SaveChanges();
                    return(SystemLog.ErrorCodes.OK);
                }
                catch (Exception ex)
                {
                    Utils.Logging.AddLog(new SystemLog()
                    {
                        LoggerName = "Unifiedban",
                        Date       = DateTime.Now,
                        Function   = "Unifiedban.Data.DashboardSessionService.Remove",
                        Level      = SystemLog.Levels.Warn,
                        Message    = ex.Message,
                        UserId     = callerId
                    });
                    if (ex.InnerException != null)
                    {
                        Utils.Logging.AddLog(new SystemLog()
                        {
                            LoggerName = "Unifiedban.Data",
                            Date       = DateTime.Now,
                            Function   = "Unifiedban.Data.DashboardSessionService.Remove",
                            Level      = SystemLog.Levels.Warn,
                            Message    = ex.InnerException.Message,
                            UserId     = callerId
                        });
                    }
                }
                return(SystemLog.ErrorCodes.Error);
            }
        }
コード例 #7
0
ファイル: SysConfigService.cs プロジェクト: unified-ban/Data
        public SysConfig Update(SysConfig sysConfig, int callerId)
        {
            using (UBContext ubc = new UBContext())
            {
                SysConfig exists = ubc.SysConfigs
                                   .Where(x => x.SysConfigId == sysConfig.SysConfigId)
                                   .FirstOrDefault();
                if (exists == null)
                {
                    return(null);
                }

                try
                {
                    exists.Value = sysConfig.Value;

                    ubc.SaveChanges();
                    return(sysConfig);
                }
                catch (Exception ex)
                {
                    Utils.Logging.AddLog(new SystemLog()
                    {
                        LoggerName = "Unifiedban",
                        Date       = DateTime.Now,
                        Function   = "Unifiedban.Data.SysConfigService.Update",
                        Level      = SystemLog.Levels.Warn,
                        Message    = ex.Message,
                        UserId     = callerId
                    });
                    if (ex.InnerException != null)
                    {
                        Utils.Logging.AddLog(new SystemLog()
                        {
                            LoggerName = "Unifiedban.Data",
                            Date       = DateTime.Now,
                            Function   = "Unifiedban.Data.SysConfigService.Update",
                            Level      = SystemLog.Levels.Warn,
                            Message    = ex.InnerException.Message,
                            UserId     = callerId
                        });
                    }
                }
                return(null);
            }
        }
コード例 #8
0
        public ActionType Update(ActionType actionType, int callerId)
        {
            using (UBContext ubc = new UBContext())
            {
                ActionType exists = ubc.ActionTypes
                                    .Where(x => x.ActionTypeId == actionType.ActionTypeId)
                                    .FirstOrDefault();
                if (exists == null)
                {
                    return(null);
                }

                try
                {
                    exists.Name = actionType.Name;
                    ubc.SaveChanges();
                    return(actionType);
                }
                catch (Exception ex)
                {
                    Utils.Logging.AddLog(new SystemLog()
                    {
                        LoggerName = "Unifiedban",
                        Date       = DateTime.Now,
                        Function   = "Unifiedban.Data.ActionTypeService.Update",
                        Level      = SystemLog.Levels.Warn,
                        Message    = ex.Message,
                        UserId     = callerId
                    });
                    if (ex.InnerException != null)
                    {
                        Utils.Logging.AddLog(new SystemLog()
                        {
                            LoggerName = "Unifiedban.Data",
                            Date       = DateTime.Now,
                            Function   = "Unifiedban.Data.ActionTypeService.Update",
                            Level      = SystemLog.Levels.Warn,
                            Message    = ex.InnerException.Message,
                            UserId     = callerId
                        });
                    }
                }
                return(null);
            }
        }
コード例 #9
0
        public SystemLog.ErrorCodes RemoveKey(Key key, int callerId)
        {
            using (UBContext ubc = new UBContext())
            {
                Key exists = ubc.TranslationKeys
                             .Where(x => x.KeyId == key.KeyId)
                             .FirstOrDefault();
                if (exists == null)
                {
                    return(SystemLog.ErrorCodes.Error);
                }

                try
                {
                    ubc.SaveChanges();
                    return(SystemLog.ErrorCodes.OK);
                }
                catch (Exception ex)
                {
                    Utils.Logging.AddLog(new SystemLog()
                    {
                        LoggerName = "Unifiedban",
                        Date       = DateTime.Now,
                        Function   = "Unifiedban.Data.LanguageService.RemoveKey",
                        Level      = SystemLog.Levels.Warn,
                        Message    = ex.Message,
                        UserId     = callerId
                    });
                    if (ex.InnerException != null)
                    {
                        Utils.Logging.AddLog(new SystemLog()
                        {
                            LoggerName = "Unifiedban.Data",
                            Date       = DateTime.Now,
                            Function   = "Unifiedban.Data.LanguageService.RemoveKey",
                            Level      = SystemLog.Levels.Warn,
                            Message    = ex.InnerException.Message,
                            UserId     = callerId
                        });
                    }
                }
                return(SystemLog.ErrorCodes.Error);
            }
        }
コード例 #10
0
        /// <summary>
        /// Creates a new DashboardSession
        /// </summary>
        /// <param name="dashboardSession"></param>
        /// <param name="callerId"></param>
        /// <returns>DashboardSession or Response</returns>
        public object Add(DashboardSession dashboardSession, int callerId)
        {
            using (UBContext ubc = new UBContext())
            {
                try
                {
                    ubc.Add(dashboardSession);
                    ubc.SaveChanges();

                    return(dashboardSession);
                }
                catch (Exception ex)
                {
                    Utils.Logging.AddLog(new SystemLog()
                    {
                        LoggerName = "Unifiedban",
                        Date       = DateTime.Now,
                        Function   = "Unifiedban.Data.DashboardSessionService.Add",
                        Level      = SystemLog.Levels.Warn,
                        Message    = ex.Message,
                        UserId     = callerId
                    });
                    if (ex.InnerException != null)
                    {
                        Utils.Logging.AddLog(new SystemLog()
                        {
                            LoggerName = "Unifiedban.Data",
                            Date       = DateTime.Now,
                            Function   = "Unifiedban.Data.DashboardSessionService.Add",
                            Level      = SystemLog.Levels.Warn,
                            Message    = ex.InnerException.Message,
                            UserId     = callerId
                        });
                    }
                }

                return(new Response()
                {
                    StatusCode = 4006,
                    StatusDescription = "Error creating DashboardSession on database."
                });
            }
        }
コード例 #11
0
 public List <TrustFactorLog> Add(List <TrustFactorLog> trustFactorLog, int callerId)
 {
     using (UBContext ubc = new UBContext())
     {
         try
         {
             foreach (var log in trustFactorLog)
             {
                 ubc.Add(log);
             }
             ubc.SaveChanges();
             return(trustFactorLog);
         }
         catch (Exception ex)
         {
             Utils.Logging.AddLog(new SystemLog()
             {
                 LoggerName = "Unifiedban",
                 Date       = DateTime.Now,
                 Function   = "Unifiedban.Data.TrustFactorLogService.Add",
                 Level      = SystemLog.Levels.Warn,
                 Message    = ex.Message,
                 UserId     = callerId
             });
             if (ex.InnerException != null)
             {
                 Utils.Logging.AddLog(new SystemLog()
                 {
                     LoggerName = "Unifiedban.Data",
                     Date       = DateTime.Now,
                     Function   = "Unifiedban.Data.TrustFactorLogService.Add",
                     Level      = SystemLog.Levels.Warn,
                     Message    = ex.InnerException.Message,
                     UserId     = callerId
                 });
             }
         }
         return(null);
     }
 }
コード例 #12
0
 public Operator Add(Operator oper, int callerId)
 {
     using (UBContext ubc = new UBContext())
     {
         try
         {
             ubc.Add(oper);
             ubc.SaveChanges();
             return(oper);
         }
         catch (Exception ex)
         {
             Utils.Logging.AddLog(new SystemLog()
             {
                 LoggerName = "Unifiedban",
                 Date       = DateTime.Now,
                 Function   = "Unifiedban.Data.OperatorService.Add",
                 Level      = SystemLog.Levels.Warn,
                 Message    = ex.Message,
                 UserId     = callerId
             });
             if (ex.InnerException != null)
             {
                 Utils.Logging.AddLog(new SystemLog()
                 {
                     LoggerName = "Unifiedban.Data",
                     Date       = DateTime.Now,
                     Function   = "Unifiedban.Data.OperatorService.Add",
                     Level      = SystemLog.Levels.Warn,
                     Message    = ex.InnerException.Message,
                     UserId     = callerId
                 });
             }
         }
         return(null);
     }
 }