예제 #1
0
 public HomeController(ApplicationDbContext _applicationDbContext, AccountDbContext _accountDbContext, UserManager <ApplicationUser> _userManager, SignInManager <ApplicationUser> _signInManager, RoleManager <IdentityRole> _roleManager)
 {
     this.applicationDbContext = _applicationDbContext;
     this.accountDbContext     = _accountDbContext;
     this.userManager          = _userManager;
     this.signInManager        = _signInManager;
     this.roleManager          = _roleManager;
 }
예제 #2
0
 public SystemServices(ILogger <SystemServices> logger, AccountDbContext accountDbContext, Emergency common, IActionDescriptorCollectionProvider actionDescriptorCollectionProvider, TaskResponseQueue responseQueue)
 {
     _logger = logger;
     _common = common;
     _actionDescriptorCollectionProvider = actionDescriptorCollectionProvider;
     _accountDbContext = accountDbContext;
     _responseQueue    = responseQueue;
 }
예제 #3
0
        //constructor
        public GenericRepository(AccountDbContext db, IMapper mapper)
        {
            //inject the database
            _context = db ?? throw new ArgumentNullException(nameof(db), "Context cannot be null.");

            //instantiate the mapper
            _mapper = mapper;
        }
 public TenantApplicationLicenseService(AccountDbContext accountDbContext,
                                        MultiTenantPlatformDbContext multiTenantPlatformDbContext,
                                        ITenantInfoService tenantInfoService) : base(accountDbContext)
 {
     _dbContext = accountDbContext;
     _MultiTenantPlatformDbContext = multiTenantPlatformDbContext;
     _tenantInfoService            = tenantInfoService;
 }
예제 #5
0
 public void DeleteRole(List <int> ids)
 {
     using (var dbContext = new AccountDbContext())
     {
         dbContext.Roles.Include("Users").Where(u => ids.Contains(u.ID)).ToList().ForEach(a => { a.Users.Clear(); dbContext.Roles.Remove(a); });
         dbContext.SaveChanges();
     }
 }
 public static void updateSessionForAccount()
 {
     if (account != null)
     {
         account = AccountDbContext.getInstance().findAccountByID(account.AccountID);
     }
     refresh_account_last_activity();
 }
예제 #7
0
 public LogConfigRepository(AccountDbContext context)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     Context = context;
 }
 public InventoryProductRepository(IConfiguration config, ILogger <InventoryProductRepository> ilogger, IHttpContextAccessor httpContextAccessor, AccountDbContext accountDbContext, Management management, DataDbContext datadbContext, UserManager <ApplicationUser> userManager)
     : base(config, ilogger, httpContextAccessor, management, datadbContext, accountDbContext, userManager)
 {
     _accountdbContext = accountDbContext;
     _usermanager      = userManager;
     _datadbContext    = datadbContext;
     _managment        = management;
 }
예제 #9
0
 public void DeleteUser(List <int> ids)
 {
     using (var dbContext = new AccountDbContext())
     {
         dbContext.Users.Where(u => ids.Contains(u.ID)).ToList().ForEach(a => { dbContext.Users.Remove(a); });
         dbContext.SaveChanges();
     }
 }
예제 #10
0
        private void SendActivationEmail(int userId)
        {
            string activationCode = Guid.NewGuid().ToString();

            using (AccountDbContext db = new AccountDbContext())
            {
                // Here first check if the activation code is already present (sent first time to the user) the retrive the same activation code from th table and send email again.
                UserActivation ua = new UserActivation();

                //     ua = db.userActivation.FirstOrDefault(userAct => userAct.ID == userId);

                var checkUser = (from row in db.userActivation
                                 where row.ID == userId
                                 select row).ToList();

                if (checkUser.Count() == 0)
                {
                    // Here add activation code and UserId in activation table
                    ua.ID              = userId;
                    ua.ActivationCode  = activationCode;
                    db.Entry(ua).State = EntityState.Added;
                    db.SaveChanges();
                }
                else
                {
                    activationCode = checkUser[0].ActivationCode;
                }
            }

            AccountDbContext dbContext = new AccountDbContext();
            UserAccount      user      = dbContext.userAccounts.FirstOrDefault(u => u.UserId == userId);
            string           toEmailID = user.Email;
            string           userName  = user.FirstName;
            MailMessage      mm        = new MailMessage("*****@*****.**", toEmailID);

            mm.Subject = "Account Activation";
            string body = "Hello " + userName;

            body += "<br /><br />Please click the following link to activate your account";
            body += "<br /><a href = '" + Request.Url.AbsoluteUri + "?ActivationCode=" + activationCode + "'>Click here to activate your account.</a>";


            body         += "<br /><br />Thanks";
            mm.Body       = body;
            mm.IsBodyHtml = true;
            SmtpClient smtp = new SmtpClient();

            smtp.Host      = "smtp.gmail.com";
            smtp.EnableSsl = true;
            NetworkCredential NetworkCred = new NetworkCredential("*****@*****.**", "");

            smtp.UseDefaultCredentials = false;
            smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
            smtp.Credentials           = NetworkCred;
            smtp.Port = 25;
            smtp.Send(mm);
        }
예제 #11
0
 public void ToPageCacheTest()
 {
     using (var dbContext = new AccountDbContext())
     {
         PageResult<User> _finded = dbContext.Users.ToPageCache(u => u.IsActive == true, new PageCondition(1, 10) { PrimaryKeyField = "ID" }, ent => ent, "word");
         _finded = dbContext.Users.ToPageCache(u => u.IsActive == true, new PageCondition(1, 10) { PrimaryKeyField = "ID" }, ent => ent, "word");
         CollectionAssert.AllItemsAreNotNull(_finded.Data);
     }
 }
예제 #12
0
 public LoginInfo[] GetAllByLogin(string login)
 {
     using (var context = AccountDbContext.CreateFromConnectionString(DatabaseService.ConnectionString))
     {
         var userRepository = context.GetUserRepository();
         var users          = userRepository.QueryAll().Where(t => t.Login == login).ToArray();
         return(users.Select(GetLoginInfo).ToArray());
     }
 }
예제 #13
0
 public LoginInfo GetOneOrNull(Guid accountId, string login)
 {
     using (var context = AccountDbContext.CreateFromConnectionString(DatabaseService.ConnectionString))
     {
         var userRepository = context.GetUserRepository();
         var user           = userRepository.GetOneOrNullByLogin(login);
         return(GetLoginInfo(user));
     }
 }
        SelectList getAccountIDList(int?selectedID = null)
        {
            var items = AccountDbContext.getInstance().findAccounts();

            items.Insert(0, new Models.Account {
                AccountID = 0, Username = ""
            });
            return(new SelectList(items, "AccountID", "Username", selectedID));
        }
예제 #15
0
 protected override SendUnitTestResultRequestData GetResult(
     Guid accountId,
     AccountDbContext accountDbContext,
     UnitTest unitTest,
     ILogger logger,
     CancellationToken token)
 {
     return(CheckSql(unitTest.SqlRule));
 }
예제 #16
0
        public void Init(Guid eventId, UserInfo currentUser, AccountDbContext accountDbContext)
        {
            AccountDbContext = accountDbContext;

            ErrorReasons     = new List <ShowEventModelReason>();
            UnitTestsReasons = new List <ShowEventModelReason>();
            MetricsReasons   = new List <ShowEventModelReason>();
            ChildsReasons    = new List <ShowEventModelReason>();

            var eventRepository = accountDbContext.GetEventRepository();

            Event = eventRepository.GetById(eventId);

            // тип события
            EventType = Event.EventType;

            // событие метрики
            if (Event.Category == EventCategory.MetricStatus)
            {
                var metricRepository = accountDbContext.GetMetricRepository();
                var metric           = metricRepository.GetById(Event.OwnerId);
                Metric    = metric;
                Component = metric.Component;
            }
            // событие юнит-теста
            else if (Event.Category == EventCategory.UnitTestStatus ||
                     Event.Category == EventCategory.UnitTestResult)
            {
                var unitTestRepository = accountDbContext.GetUnitTestRepository();
                var unitTest           = unitTestRepository.GetById(Event.OwnerId);
                UnitTest  = unitTest;
                Component = unitTest.Component;
            }
            else // событие компонента
            {
                var componentRepository = accountDbContext.GetComponentRepository();
                Component = componentRepository.GetById(Event.OwnerId);
            }

            // название страницы
            PageTitle = "Событие - " + GetPageTitle(Event.Category, EventType).ToLowerInvariant();

            // причины статусов
            if (Event.Category.IsStatus())
            {
                LoadReasons(Event, accountDbContext);
            }

            CanChangeImportance = !EventType.IsSystem;
            CanChangeActuality  = Event.Category.IsComponentCategory() && !Event.Category.IsStatus() && (Event.ActualDate > DateTime.Now);

            // Оставим только 100 последних причин, иначе они долго рассчитываются и выводятся
            UnitTestsReasons = UnitTestsReasons.OrderByDescending(t => t.Event.StartDate).Take(100).ToList();
            MetricsReasons   = MetricsReasons.OrderByDescending(t => t.Event.StartDate).Take(100).ToList();
            ChildsReasons    = ChildsReasons.OrderByDescending(t => t.Event.StartDate).Take(100).ToList();
            ErrorReasons     = ErrorReasons.OrderByDescending(t => t.Event.StartDate).Take(100).ToList();
        }
예제 #17
0
 public static void CheckMetricaStatus(Guid accountId, IComponentControl componentControl, string metricName, Core.Api.MonitoringStatus status)
 {
     using (var accountDbContext = AccountDbContext.CreateFromAccountId(accountId))
     {
         var component = accountDbContext.Components.First(x => x.Id == componentControl.Info.Id);
         var metric    = component.Metrics.Single(x => x.MetricType.SystemName == metricName && x.IsDeleted == false);
         Assert.Equal(metric.Bulb.Status, status);
     }
 }
예제 #18
0
        public IActionResult Index(string flag)
        {
            ViewData["Flag"] = flag;
            AccountDbContext dbContext = new AccountDbContext();
            var allusers = dbContext.Accounts.ToList();

            ViewData["Users"] = allusers;
            return(View());
        }
예제 #19
0
 public static void SeedData(IServiceProvider serviceProvider, UserManager <ApplicationUser> userManager, IConfiguration config)
 {
     using (var dbcontext = new AccountDbContext(serviceProvider.GetRequiredService <DbContextOptions <AccountDbContext> >()))
     {
         dbcontext.Database.EnsureCreated();
         AddRoles(dbcontext);
         SeedUsers(userManager, config);
     }
 }
예제 #20
0
 public AuthController(
     UserManager <AccountUser> userManager,
     SignInManager <AccountUser> signInManager,
     AccountDbContext _context)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _dbContext     = _context;
 }
예제 #21
0
        public ActionResult DeleteBuySellRequest_Confirmed(int id = 0)
        {
            AccountDbContext db   = new AccountDbContext();
            BuySellDatabase  user = db.buySellDatabase.Single(us => us.ID == id);

            db.buySellDatabase.Remove(user);
            db.SaveChanges();
            return(RedirectToAction("UserRequestsForBuySell", "Database"));
        }
예제 #22
0
        public Component GetComponentById(Guid id)
        {
            // todo нужно убрать этот метод от сюда
            // для ЛК нужны свои репозитории
            var accountId  = CurrentUser.AccountId;
            var repository = AccountDbContext.GetComponentRepository();

            return(repository.GetById(id));
        }
        public UnitTest GetUnitTest(Guid id)
        {
            var repository = AccountDbContext.GetUnitTestRepository();
            var result     = repository.GetById(id);

            UnitTest = result;
            Id       = id;
            return(result);
        }
예제 #24
0
 public LoginInfo GetOneById(Guid id)
 {
     using (var context = AccountDbContext.CreateFromConnectionString(DatabaseService.ConnectionString))
     {
         var userRepository = context.GetUserRepository();
         var user           = userRepository.GetById(id);
         return(GetLoginInfo(user));
     }
 }
예제 #25
0
        public void ChangeImportanceTest()
        {
            var account      = TestHelper.GetTestAccount();
            var user         = TestHelper.GetAccountAdminUser(account.Id);
            var eventType    = TestHelper.GetTestEventType(account.Id);
            var component    = account.CreateRandomComponentControl();
            var dispatcher   = DispatcherHelper.GetDispatcherService();
            var eventRequest = new SendEventRequest()
            {
                Token = account.GetCoreToken(),
                Data  = new SendEventData()
                {
                    ComponentId    = component.Info.Id,
                    TypeSystemName = eventType.SystemName,
                    Category       = EventCategory.ComponentEvent,
                    Version        = "1.2.3.4",
                    JoinInterval   = TimeSpan.FromSeconds(0).TotalSeconds
                }
            };
            var sendEventResponse = dispatcher.SendEvent(eventRequest);

            Assert.True(sendEventResponse.Success);
            var eventId       = sendEventResponse.Data.EventId;
            var eventResponse = dispatcher.GetEventById(new GetEventByIdRequest()
            {
                Token = account.GetCoreToken(),
                Data  = new GetEventByIdRequestData()
                {
                    EventId = eventId
                }
            });

            Assert.True(eventResponse.Success);
            var event_ = eventResponse.Data;

            ChangeImportanceModel model;

            using (var controller = new EventsController(account.Id, user.Id))
            {
                var result = (ViewResultBase)controller.ChangeImportance(eventId);
                model = (ChangeImportanceModel)result.Model;
            }
            model.Importance = EventImportance.Warning;
            using (var controller = new EventsController(account.Id, user.Id))
            {
                controller.ChangeImportance(model);
            }
            using (var accountContext = AccountDbContext.CreateFromAccountId(account.Id))
            {
                var eventTypeRepository = accountContext.GetEventTypeRepository();
                eventType = eventTypeRepository.GetById(model.EventTypeId);
                Assert.Equal(model.EventTypeId, eventType.Id);
                Assert.Equal(model.Version, event_.Version);
                Assert.Equal(model.Importance, eventType.ImportanceForOld);
            }
        }
예제 #26
0
        protected void LoadReasons(Event eventObj, AccountDbContext accountDbContext)
        {
            var eventRepository = accountDbContext.GetEventRepository();
            var reasons         = eventRepository.GetEventReasons(eventObj.Id).OrderByDescending(t => t.StartDate).Take(MaxEventsReasonCount).ToArray();

            foreach (var reasonsEvent in reasons)
            {
                ProcessReason(reasonsEvent, accountDbContext);
            }
        }
예제 #27
0
        public Account GetAccount(string accountNumber)
        {
            using (AccountDbContext context = _dbContextFactory())
            {
                AccountEntity entity =
                    context.Accounts.SingleOrDefault(a => a.AccountNumber == accountNumber);

                return(MapEntityToAccount(entity));
            }
        }
예제 #28
0
 public User GetById(object id)
 {
     return(CacheHelper.Get(string.Format("{0}_{1}", CacheKey, id), () =>
     {
         using (var dbContext = new AccountDbContext())
         {
             return dbContext.Find <User>(id);
         }
     }));
 }
예제 #29
0
 public FileController(IStorage storage,
                       AccountDbContext accDb,
                       ITokenGenerator tokenGenerator,
                       IConfiguration cfg)
 {
     _storage        = storage;
     _accDb          = accDb;
     _tokenGenerator = tokenGenerator;
     _cfg            = cfg;
 }
        public AccountInformation GetAccounts(string username)
        {
            AccountDbContext context = new AccountDbContext();

            context.Configuration.ProxyCreationEnabled = false;
            var info = new AccountInformation();

            info.Accounts = context.Accounts.Where(row => row.Customer.UserName == username).ToList();
            return(info);
        }