예제 #1
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var model = new SideBarUserAreaViewModel
            {
                LoginInformations = await _sessionAppService.GetCurrentLoginInformations()
            };

            return(View(model));
        }
        public int GetUserId()
        {
            var model = new SideBarUserAreaViewModel
            {
                LoginInformations = AsyncHelper.RunSync(() => _sessionAppService.GetCurrentLoginInformations())
            };

            return((int)model.LoginInformations.User.Id);
        }
        public async Task <ActionResult> TenantChangeModal()
        {
            var loginInfo = await _sessionAppService.GetCurrentLoginInformations();

            return(View("/Views/Shared/Components/TenantChange/_ChangeModal.cshtml", new ChangeModalViewModel
            {
                TenancyName = loginInfo.Tenant?.TenancyName
            }));
        }
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var footerModel = new FooterViewModel
            {
                LoginInformations = await _sessionAppService.GetCurrentLoginInformations()
            };

            return(View(footerModel));
        }
예제 #5
0
        public PartialViewResult SideNavbar()
        {
            var model = new SideBarUserAreaViewModel()
            {
                LoginInformations = AsyncHelper.RunSync(() => _sessionAppService.GetCurrentLoginInformations()),
            };

            return(PartialView("_SideNavbar", model));
        }
예제 #6
0
        public async Task <GetCurrentLoginInformationsOutput> GetCurrentLoginInformationsAsync()
        {
            var httpContext = _httpContextAccessor.HttpContext;

            if (httpContext == null)
            {
                return(await _sessionAppService.GetCurrentLoginInformations());
            }

            if (!(httpContext.Items["__PerRequestSessionCache"] is GetCurrentLoginInformationsOutput cachedValue))
            {
                cachedValue = await _sessionAppService.GetCurrentLoginInformations();

                httpContext.Items["__PerRequestSessionCache"] = cachedValue;
            }

            return(cachedValue);
        }
예제 #7
0
        public async Task <IActionResult> EditMyFlowPhase(string taskCode, string phaseCode)
        {
            var userName = (await _sessionAppService.GetCurrentLoginInformations()).User.UserName;

            ViewBag.TaskCode   = taskCode;
            ViewBag.PhaseCode  = phaseCode;
            ViewBag.Originator = userName;

            return(View("_EditMyFlowPhaseModal"));
        }
예제 #8
0
        public PartialViewResult SideBarUserArea()
        {
            var model = new SideBarUserAreaViewModel
            {
                LoginInformations     = AsyncHelper.RunSync(() => _sessionAppService.GetCurrentLoginInformations()),
                IsMultiTenancyEnabled = _multiTenancyConfig.IsEnabled,
            };

            return(PartialView("_SideBarUserArea", model));
        }
예제 #9
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var model = new SideBarUserAreaViewModel
            {
                LoginInformations     = await _sessionAppService.GetCurrentLoginInformations(),
                IsMultiTenancyEnabled = _multiTenancyConfig.IsEnabled,
            };

            return(View(model));
        }
예제 #10
0
 public OrdersController(ISessionAppService sessionAppService, OrdersAppService ordersAppService, UserAppService userAppService, IAccountAppService accountAppService)
 {
     _ordersAppService  = ordersAppService;
     _userAppService    = userAppService;
     _accountAppService = accountAppService;
     _user        = sessionAppService.GetCurrentLoginInformations().Result.User;
     _inputSearch = new InputSearch {
         ClientId = _user.UserType == UserType.User ? _user.Id : 0
     };
 }
        public override async Task <PagedResultDto <ProductInfoDto> > GetAll(PagedResultRequestDto input)
        {
            var user = await _sessionAppService.GetCurrentLoginInformations();

            var all = from x in _productInfoRepository.GetAll().Where(x => x.UserId == user.User.Id)
                      select ObjectMapper.Map <ProductInfoDto>(x);

            var pagedResultDto = new PagedResultDto <ProductInfoDto>();

            pagedResultDto.Items = all.ToList().AsReadOnly();

            foreach (var item in pagedResultDto.Items)
            {
                item.QRCodeImage = $"{_defaultUrl}codepage/{user.User.UserName}/label/{item.Code}.png";
            }

            pagedResultDto.TotalCount = all.Count();

            return(await Task.FromResult(pagedResultDto));
        }
예제 #12
0
        /// <summary>
        /// 修改皮肤
        /// </summary>
        /// <param name="skin"></param>
        /// <returns></returns>
        public JsonResult ModifySkin(string skin)
        {
            var loginInfo = AsyncHelper.RunSync(() => _sessionAppService.GetCurrentLoginInformations());

            _userAppService.UpdateUser(new UpdateUserInput
            {
                Id    = loginInfo.User.Id,
                Theme = skin
            });
            return(Json(new { Success = true, Msg = "修改成功!" }));
        }
예제 #13
0
 public ActionResult Index()
 {
     //这里要判断一下用户是否登录
     if (AbpSession.UserId.HasValue)
     {
         var model = new HeaderViewModel
         {
             LoginInformations     = AsyncHelper.RunSync(() => _sessionAppService.GetCurrentLoginInformations()),
             Languages             = _languageManager.GetLanguages(),
             CurrentLanguage       = _languageManager.CurrentLanguage,
             IsMultiTenancyEnabled = _multiTenancyConfig.IsEnabled,
             IsImpersonatedLogin   = AbpSession.ImpersonatorUserId.HasValue
         };
         return(View(model));
     }
     else
     {
         return(View());
     }
 }
예제 #14
0
        public PartialViewResult Nav(string activeMenu = "")
        {
            var loginInformations = AsyncHelper.RunSync(() => _sessionAppService.GetCurrentLoginInformations());
            var menu = new TopMenuViewModel
            {
                MainMenu           = AsyncHelper.RunSync(() => _userNavigationManager.GetMenuAsync("MainMenu", AbpSession.ToUserIdentifier())),
                ActiveMenuItemName = activeMenu
            };

            return(PartialView("_Nav", Tuple.Create <TopMenuViewModel, GetCurrentLoginInformationsOutput>(menu, loginInformations)));
        }
예제 #15
0
        public async Task <ActionResult> Index()
        {
            var loginInfo = await _sessionAppService.GetCurrentLoginInformations();

            var model = new SubscriptionDashboardViewModel
            {
                LoginInformations = loginInfo
            };

            return(View(model));
        }
        public async Task <ActionResult> InvoiceRegisterperSalesman()
        {
            var model = new AllInOneReportsViewModel
            {
                LoginInformations = await _sessionAppService.GetCurrentLoginInformations(),
                Invoices          = await _invoiceAppService.GetAllInvoices(),
                Salesmans         = (await _salesmanAppService.GetSalesman()).Items
            };

            return(View("InvoiceRegisterperSalesman", model));
        }
예제 #17
0
        public PartialViewResult UserMenuOrLoginLink()
        {
            UserMenuOrLoginLinkViewModel model = new UserMenuOrLoginLinkViewModel {
                IsMultiTenancyEnabled = _multiTenancyConfig.IsEnabled
            };

            if (AbpSession.UserId.HasValue)
            {
                model.LoginInformations = AsyncHelper.RunSync(() => _sessionAppService.GetCurrentLoginInformations());
            }
            return(PartialView("_UserMenuOrLoginLink", model));
        }
예제 #18
0
        public ActionResult HomeHead()
        {
            bool isLogin = AbpSession.UserId == null ? false : true;
            GetCurrentLoginInformationsOutput userInfo = new GetCurrentLoginInformationsOutput();

            if (isLogin)
            {
                userInfo = AsyncHelper.RunSync(() => _sessionAppService.GetCurrentLoginInformations());
            }
            ViewBag.IsLogin = isLogin;
            return(PartialView(userInfo));
        }
        public async Task <ListResultDto <OrganizationUnitDto> > GetUserOrganizationUnits()
        {
            var user = await _sessionAppService.GetCurrentLoginInformations();

            // var userOrganizationUnitsData = await _userOrganizationUnitRepository.GetAll().AsNoTracking().Where(r => r.UserId == user.User.Id).ToListAsync();
            List <OrganizationUnitDto> result = new List <OrganizationUnitDto>();

            Logger.Info("登录的用户名: " + user.User.UserName + "    名字:" + user.User.Name);

            //foreach (var item in userOrganizationUnitsData)
            //{
            //    var OrganizationData = await _organizationUnitRepository.GetAll().AsNoTracking()
            //        .Where(r => r.Id == item.OrganizationUnitId).FirstOrDefaultAsync();
            //    if (OrganizationData != null)
            //    {
            //        var data = _organizationUnitRepository.GetAll().AsNoTracking()
            //            .Where(r => r.Code == OrganizationData.Code || r.Code.Contains(OrganizationData.Code + ","));
            //        foreach (var dataItem in data)
            //        {
            //            OrganizationUnitDto dto = new OrganizationUnitDto
            //            {
            //                Id = dataItem.Id,
            //                DisplayName = dataItem.DisplayName,
            //                Code = dataItem.Code
            //            };
            //            result.Add(dto);
            //        }
            //    }
            //}


            var data = from a in _userOrganizationUnitRepository.GetAll().AsNoTracking()
                       join b in _organizationRepository.GetAll().AsNoTracking()
                       on a.OrganizationUnitId equals b.Id
                       where a.UserId == user.User.Id
                       select b;

            foreach (var item in data)
            {
                var itData = _organizationRepository.GetAll().AsNoTracking().Where(r => r.Code == item.Code || r.Code.Contains(item.Code + ","));
                foreach (var itemc in itData)
                {
                    OrganizationUnitDto dto = new OrganizationUnitDto
                    {
                        Id          = itemc.Id,
                        DisplayName = itemc.DisplayName,
                        Code        = itemc.Code
                    };
                    result.Add(dto);
                }
            }
            return(new ListResultDto <OrganizationUnitDto>(result));
        }
예제 #20
0
        public async Task <IViewComponentResult> InvokeAsync(string activeMenu = "")
        {
            var model = new TopBarViewModel
            {
                MainMenu              = await _userNavigationManager.GetMenuAsync("MainMenu", _abpSession.ToUserIdentifier()),
                ActiveMenuItemName    = activeMenu,
                LoginInformations     = await _sessionAppService.GetCurrentLoginInformations(),
                IsMultiTenancyEnabled = _multiTenancyConfig.IsEnabled,
            };

            return(View(model));
        }
예제 #21
0
        /// <summary>
        /// The send notification async.
        /// </summary>
        /// <param name="transactionId">
        /// The transaction id.
        /// </param>
        /// <param name="notificationType"></param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task SendNotificationAsync(Guid transactionId, NotificationTypes notificationType)
        {
            var transaction = await _transactionRepository.GetAll()
                              .Include(t => t.Account)
                              .ThenInclude(account => account.Currency)
                              .Include(t => t.Category)
                              .Include(t => t.CreatorUser)
                              .Where(t => t.Id == transactionId)
                              .FirstOrDefaultAsync();

            var transactionPreviewDto = ObjectMapper.Map <TransactionPreviewDto>(transaction);

            var contentHeading = transaction.Amount > 0 ? "🐷 Inflow" : "🔥 Outflow";
            var notificationHeadingFromOrTo = transaction.Amount > 0 ? "to" : "from";
            var amount = transaction.Amount > 0 ? transaction.Amount : -transaction.Amount;

            contentHeading += $" of {transaction.Account.Currency.Symbol} {amount} {notificationHeadingFromOrTo} {transaction.CreatorUser.UserName.ToPascalCase()}'s {transaction.Account.Name}";

            var notificationHeading = notificationType switch
            {
                NotificationTypes.NewTransaction => $"New Transaction By {transaction.CreatorUser.UserName.ToPascalCase()}",
                NotificationTypes.UpdateTransaction => $"Transaction Updated By {transaction.CreatorUser.UserName.ToPascalCase()}",
                _ => "New Activity",
            };

            var currentUser = await _sessionAppService.GetCurrentLoginInformations();

            await _backgroundJobManager.EnqueueAsync <SendPushNotificationJob, SendPushNotificationJobArgs>(
                new SendPushNotificationJobArgs
            {
                Contents  = $"{contentHeading}{Environment.NewLine}{transaction.Description}",
                Data      = GetTransactionDataInDictionary(transactionPreviewDto),
                Headings  = notificationHeading,
                ChannelId = notificationType == NotificationTypes.NewTransaction
                        ? _settings.OneSignal.Channels.NewTransaction
                        : _settings.OneSignal.Channels.UpdateTransaction,
                TenancyName = currentUser.Tenant.TenancyName.Trim().ToLowerInvariant()
            });
        }
예제 #22
0
        public async Task <IActionResult> Index()
        {
            var UserInfo = await _sessionAppService.GetCurrentLoginInformations();

            ViewData["discount"] = 10;
            var s = await _storeAppService.GetByIdAsync(UserInfo.User.ChainStoreId);

            if (s != null)
            {
                ViewData["discount"] = s.OffLineDiscount;
            }
            return(View());
        }
예제 #23
0
 public CartController(ISessionAppService sessionAppService, OrdersAppService ordersAppService, UserAppService userAppService, OrdersHistoryAppService ordersHistoryAppService)
 {
     _ordersAppService        = ordersAppService;
     _userAppService          = userAppService;
     _ordersHistoryAppService = ordersHistoryAppService;
     _user        = sessionAppService.GetCurrentLoginInformations().Result.User;
     _inputSearch = new InputSearch {
         ClientId = _user.Id
     };
     _userDto = new UserDto {
         Id = _user.Id
     };
 }
예제 #24
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var model = new AdminTopBarViewModel()
            {
                LoginInformations     = await _sessionAppService.GetCurrentLoginInformations(),
                Languages             = _languageManager.GetLanguages().Where(l => !l.IsDisabled).ToList(),
                CurrentLanguage       = _languageManager.CurrentLanguage,
                IsMultiTenancyEnabled = _multiTenancyConfig.IsEnabled,
                IsImpersonatedLogin   = _abpSession.ImpersonatorUserId.HasValue,
            };

            return(View(model));
        }
예제 #25
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var headerModel = new HeaderViewModel
            {
                LoginInformations     = await _sessionAppService.GetCurrentLoginInformations(),
                Languages             = _languageManager.GetLanguages(),
                CurrentLanguage       = _languageManager.CurrentLanguage,
                IsMultiTenancyEnabled = _multiTenancyConfig.IsEnabled,
                IsImpersonatedLogin   = _abpSession.ImpersonatorUserId.HasValue
            };

            return(View(headerModel));
        }
예제 #26
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var model = new TopBarLanguageSwitchViewModel
            {
                CurrentLanguage = _languageManager.CurrentLanguage,
                Languages       = _languageManager.GetLanguages().Where(l => !l.IsDisabled).ToList()
            };

            ViewBag.LoginInfo = await _sessionAppService.GetCurrentLoginInformations();

            return(View("TopBar", model));
            //  return Task.FromResult(View(model) as IViewComponentResult);
        }
예제 #27
0
        public async Task Should_Get_Current_User_And_Tenant_When_Logged_In_As_Tenant()
        {
            // Act
            var output = await _sessionAppService.GetCurrentLoginInformations();

            // Assert
            var currentUser = await GetCurrentUserAsync();

            var currentTenant = await GetCurrentTenantAsync();

            output.User.ShouldNotBe(null);
            output.User.Name.ShouldBe(currentUser.Name);
        }
        public async Task Should_Get_Current_User_When_Logged_In_As_Host()
        {
            //Arrange
            LoginAsHostAdmin();

            //Act
            var output = await _sessionAppService.GetCurrentLoginInformations();

            //Assert
            var currentUser = await GetCurrentUserAsync();

            output.User.ShouldNotBe(null);
            output.User.Name.ShouldBe(currentUser.Name);
            output.User.Surname.ShouldBe(currentUser.Surname);
            if (IsMultiTenancyEnabled)
            {
                output.Tenant.ShouldBe(null);
            }
            else
            {
                output.Tenant.ShouldNotBe(null);
            }
        }
        public async Task <ActionResult> Print()
        {
            List <string> dups   = new List <string>();
            var           brands = (await _productService.GetProduct()).Items;

            foreach (var dups1 in brands)
            {
                dups.Add(dups1.Brand);
            }
            var dups2 = dups.GroupBy(x => x)
                        .Where(g => g.Count() > 1)
                        .Select(x => x.Key)
                        .ToList();
            var model = new BadStockListViewModel
            {
                StockListDtos     = (await _badStockService.GetStocks()).Items,
                Total             = await _badStockService.GetTotal(),
                LoginInformations = await _sessionAppService.GetCurrentLoginInformations(),
                ProductBrands     = dups2
            };

            return(View(model));
        }
예제 #30
0
        public async Task <ActionResult> Create()
        {
            var customers = (await _customerService.GetCustomer()).Items;
            var products  = (await _productService.GetProduct()).Items;

            var model = new CreateExtruckSaleViewModel
            {
                Customers         = customers,
                Products          = products,
                LoginInformations = await _sessionAppService.GetCurrentLoginInformations(),
            };

            return(View("Create", model));
        }