コード例 #1
0
        public void SetUp()
        {
            _pizzaSizeRepository = new Mock <IPizzaSizeRepository>();
            _pizzaSizeRepository.Setup(x => x.GetByIds(It.IsAny <int>(), It.IsAny <int>())).Returns(() =>
                                                                                                    new GetPizzaSizeResponse
            {
                HasError = true,
                Error    = new Error
                {
                    UserMessage = "An error has occured"
                }
            });

            _toppingSizeRepository = new Mock <IToppingSizeRepository>();
            _voucherService        = new Mock <IVoucherService>();

            _subject = new UserSessionService(_pizzaSizeRepository.Object, _toppingSizeRepository.Object, _voucherService.Object);
            _result  = _subject.NewUser();

            var basketData = new BasketData
            {
                PizzaId         = 1,
                SizeId          = 2,
                ExtraToppingIds = new List <int>
                {
                    3,
                    4
                }
            };

            _subject.AddItemToBasket(_result, basketData);
            _basket = _subject.GetBasketForUser(_result);
        }
コード例 #2
0
ファイル: ShellViewModel.cs プロジェクト: hypnot1c/iVM
        public ShellViewModel(
            WinRTContainer container,
            IEventAggregator eventAggregator,
            UserSessionService userSessionService
            )
        {
            this.PropertyChanged     += ShellViewModel_PropertyChanged;
            this._container           = container;
            this._eventAggregator     = eventAggregator;
            this.userSessionService   = userSessionService;
            this.CollapsedPanelLength = 0;

            this.NavMenuItems = new List <NavMenuItem>
            {
                new NavMenuItem {
                    Icon = Symbol.Home, Title = "Home", TargetViewModel = typeof(PivotViewModel)
                }
                //new NavMenuItem { Icon = Symbol.Home, Title = "Home", TargetViewModel = typeof(EventListViewModel) },
                //new NavMenuItem { Icon = Symbol.Calendar, Title = "Events", TargetViewModel = typeof(EventListViewModel) }
            };
            this._selectedNavMenuItem = this.NavMenuItems.First();
            // Register a handler for BackRequested events and set the
            // visibility of the Back button
            SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
        }
コード例 #3
0
        public ShellApplication(object password, UserSessionService userSessionService, EventWaitHandle loadedEvent, string securityTokenXml)
        {
            if (password != null)
            {
                _password = SecureStringHelper.GetSecureString(Marshal.PtrToStringBSTR((IntPtr)password));
                SecureStringHelper.FreeString((IntPtr)password);
            }

            _userSessionService = userSessionService;
            _loadedEvent        = loadedEvent;

            if (securityTokenXml != null)
            {
                _tokenCache = Imi.Framework.UX.Identity.SecurityTokenCache.Deserialize(securityTokenXml);
            }
            else
            {
                _tokenCache = new Imi.Framework.UX.Identity.SecurityTokenCache();
            }

            _settingsLoadedEvent = new EventWaitHandle(false, EventResetMode.AutoReset);

            Thread.CurrentThread.CurrentUICulture = userSessionService.UICulture;

            Run();
        }
コード例 #4
0
        public void SetUp()
        {
            var subject   = new UserSessionService(null, null, null);
            var userToken = subject.NewUser();

            _result = subject.GetBasketTotalForUser(userToken);
        }
コード例 #5
0
        protected void AddServices()
        {
            _userSessionService = new UserSessionService();

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                _userSessionService.ActivationUri = ApplicationDeployment.CurrentDeployment.ActivationUri;

                NameValueCollection args = HttpUtility.ParseQueryString(_userSessionService.ActivationUri.Query);

                _userSessionService.InstanceName   = args["instance"];
                _userSessionService.HostName       = args["HostServerName"];
                _userSessionService.HostPort       = Convert.ToInt32(args["HostPort"]);
                _userSessionService.CurrentVersion = ApplicationDeployment.CurrentDeployment.CurrentVersion;
            }
            else
            {
                ShellConfigurationSection config = ConfigurationManager.GetSection(ShellConfigurationSection.SectionKey) as ShellConfigurationSection;
                _userSessionService.InstanceName   = config.InstanceNameLocalInstall;
                _userSessionService.HostName       = config.HostName;
                _userSessionService.HostPort       = config.HostPort;
                _userSessionService.CurrentVersion = Assembly.GetExecutingAssembly().GetName().Version;
            }

            _userSessionService.TerminalId = Environment.MachineName;
            _hyperlinkService = new HyperlinkService(_userSessionService);
        }
コード例 #6
0
        public IActionResult SignIn([FromBody] SignInRequest request)
        {
            var user = UserService.FindByPhoneNumber(request.PhoneNumber);

            if (user == null)
            {
                return(NotFound(new ResponseModel
                {
                    Success = false,
                    Message = "Номер телефона не зарегистрирован"
                }));
            }

            if (UserSessionService.GetUserActiveSession(user) != null)
            {
                UserSessionService.CloseUserActiveSession(user);
            }

            var session = UserSessionService.CreateSession(user);

            SmscHelper.SendSms(user.PhoneNumber, $"Код для входа: {session.AuthCode}");

            return(Ok(new SignInResponse
            {
                UserID = user.ID
            }));
        }
コード例 #7
0
        public IActionResult ResendConfirmCode([FromBody] ResendConfirmCodeRequest request)
        {
            var user = UserService.Get(request.UserID);

            if (user == null)
            {
                return(NotFound(new ResponseModel
                {
                    Success = false,
                    Message = "Пользователь не найден"
                }));
            }

            var session = UserSessionService.GetUserActiveSession(user);

            if (session == null)
            {
                return(NotFound(new ResponseModel
                {
                    Success = false,
                    Message = "Сессия не найдена"
                }));
            }

            UserSessionService.CloseUserActiveSession(user);
            session = UserSessionService.CreateSession(user);

            SmscHelper.SendSms(user.PhoneNumber, $"Код для входа: {session.AuthCode}");

            return(Ok(new SignInResponse
            {
                UserID = user.ID
            }));
        }
コード例 #8
0
        public void SetUp()
        {
            var subject   = new UserSessionService(null, null, null);
            var userToken = subject.NewUser();

            _result = subject.GetUserByUserToken(userToken);
        }
コード例 #9
0
        public void SetUp()
        {
            _subject = new UserSessionService(null, null, null);
            _subject.NewUser();

            _result = _subject.GetUserByUserToken(Guid.NewGuid().ToString());
        }
コード例 #10
0
        public async Task ScriptIsProfitableOrNot()
        {
            //Get All Candles according to
            MAStrategy mAStrategy         = new MAStrategy();
            var        symbolService      = new SymbolService();
            var        userSessionService = new UserSessionService();
            var        symbol             = await symbolService.GetAsync(21108);

            var userSession = await userSessionService.GetCurrentSession();

            PositionTestModel positionTestModel = null;

            if (userSession != null)
            {
                var zeropdhaService = new ZerodhaBroker(new UserSessionModel()
                {
                    AccessToken = userSession.AccessToken,
                    ApiKey      = userSession.ApiKey,
                    AppSecret   = userSession.AppSecret,
                    PublicToken = userSession.PublicToken,
                    UserId      = userSession.UserId
                });
                var candles = zeropdhaService.GetData(
                    symbol, mAStrategy._HistoricalDataTimeframe,
                    DateTime.Now.AddDays(-7),
                    DateTime.Now.AddDays(-2), false);
                positionTestModel = GetProfitOfDay(symbol, candles);
            }
            Assert.IsTrue(positionTestModel.Profit > 1, "Symbol is Not Profitable");
        }
コード例 #11
0
        public void SetUp()
        {
            _subject = new UserSessionService(null, null, null);
            _subject.NewUser();

            _result = _subject.GetUserByUserToken("NOT_A_VALID_GUID");
        }
コード例 #12
0
 public MacdMAStrategy()
 {
     _jobService         = new JobService();
     _watchlistService   = new WatchlistService();
     _userSessionService = new UserSessionService();
     _strategyService    = new StrategyService();
 }
コード例 #13
0
        private void SetCLIENTTokenInSession(int userId)
        {
            string clientTokenValue;

            //SessionCacheData sessionCacheData = WebApiApplication.SessionCacheService.Get(userName);
            //if (sessionCacheData != null && !string.IsNullOrWhiteSpace(sessionCacheData.XCSRFTokenValue))
            //{
            //    clientTokenValue = sessionCacheData.XCSRFTokenValue;
            //}
            //else
            //{
            clientTokenValue = Guid.NewGuid().ToString();
            //}
            //SessionDataProvider.SetXCSRFToken(xcsrfTokenValue);
            var httpContextWrapper = GetHttpContextWrapper();


            HttpCookie clientToken = new HttpCookie(WebApiApplication.CLIENT_Token, clientTokenValue);

            HttpContext.Current.Response.Cookies.Add(clientToken);
            UserSession userSession = new UserSession();

            userSession.UserId       = userId;
            userSession.UserToken    = clientTokenValue;
            userSession.LastPingTime = DateTime.Now;
            userSession.MachineName  = httpContextWrapper.Request.UserHostName;
            UserSessionService userSessionService = new UserSessionService();

            userSessionService.AddSession(userSession);

            //HttpContext.Current.Session.Contents.Add(WebApiApplication.CLIENT_Token, clientTokenValue);
            //HttpContext.Current.Session.Add(WebApiApplication.CLIENT_Token, clientTokenValue);
        }
        public void SetUp()
        {
            var pizzaSizeRepository = new Mock <IPizzaSizeRepository>();

            pizzaSizeRepository.Setup(x => x.GetByIds(It.IsAny <int>(), It.IsAny <int>())).Returns(() =>
                                                                                                   new GetPizzaSizeResponse {
                PizzaSize = new PizzaSizeRecord {
                    Price = 1500
                }
            });

            var toppingSizeRepository = new Mock <IToppingSizeRepository>();

            toppingSizeRepository.Setup(x => x.GetByIds(It.IsAny <List <int> >(), It.IsAny <int>()))
            .Returns(() => new GetToppingSizeResponse());

            var voucherService = new Mock <IVoucherService>();

            var subject   = new UserSessionService(pizzaSizeRepository.Object, toppingSizeRepository.Object, voucherService.Object);
            var userToken = subject.NewUser();

            subject.AddItemToBasket(userToken, new BasketData {
                PizzaId = 1, SizeId = 1
            });

            _result = subject.GetBasketTotalForUser(userToken);
        }
コード例 #15
0
        private async void button1_Click(object sender, EventArgs e)
        {
            UserSessionService userSessionService = UserSessionService.GetInstance();

            if (!isLogedIn_)
            {
                if (!short.TryParse(textBox3.Text, out short port))
                {
                    port          = 9000;
                    textBox3.Text = "" + port;
                }

                try {
                    button1.Enabled = false;
                    await userSessionService.LoginAsync(new NvrSessionInfo()
                    {
                        IPAddress    = textBox4.Text,
                        PortNumber   = port,
                        UserName     = textBox1.Text,
                        UserPassword = textBox2.Text
                    });
                } catch (Exception ex) {
                    appendLogOnUiThread(null, $"{ex.Message}\n\n");
                    return;
                } finally {
                    button1.Enabled = true;
                }

                comboBox1.Items.Clear();
                userSessionService.CameraChannels.ForEach(chan => comboBox1.Items.Add(chan));
                comboBox1.SelectedIndex = userSessionService.CameraSelectedChannel;

                isLogedIn_           = true;
                button1.Text         = "Logout";
                previewPanel.Enabled = isLogedIn_;
                updateAppConfiguration("NvrIp", textBox4.Text);
                updateAppConfiguration("NvrPort", textBox3.Text);
                updateAppConfiguration("NvrUserName", textBox1.Text);
                updateAppConfiguration("NvrUserPassword", textBox2.Text);
            }
            else
            {
                button1.Enabled = false;

                {
                    if (isPreviewRunning_)
                    {
                        await stopLiveViewAsync();
                    }

                    userSessionService.Logout();
                    isLogedIn_           = false;
                    button1.Text         = "Login";
                    previewPanel.Enabled = isLogedIn_;
                }

                button1.Enabled = true;
            }
        }
コード例 #16
0
        public void SetUp()
        {
            var subject = new UserSessionService(null, null, null);

            subject.NewUser();

            _result = subject.IsLoggedIn(Guid.NewGuid().ToString());
        }
コード例 #17
0
        public void SetUp()
        {
            _subject   = new UserSessionService(null, null, null);
            _userToken = _subject.NewUser();
            _subject.LogIn(_userToken, 1);

            _subject.LogOut("NOT_A_VALID_GUID");
        }
コード例 #18
0
 public WelcomeViewModel(
     INavigationService navigationService,
     UserSessionService userSessionService
     )
 {
     this.navigationService  = navigationService;
     this.userSessionService = userSessionService;
 }
コード例 #19
0
        public void SetUp()
        {
            var subject = new UserSessionService(null, null, null);

            subject.NewUser();

            _result = subject.GetBasketTotalForUser(Guid.NewGuid().ToString());
        }
コード例 #20
0
        public void SetUp()
        {
            _subject   = new UserSessionService(null, null, null);
            _userToken = _subject.NewUser();
            _subject.LogIn(_userToken, 1);

            _subject.LogOut(Guid.NewGuid().ToString());
        }
コード例 #21
0
        /// <summary>
        /// Vista base ha sido cargada
        /// </summary>
        /// <param name="module"></param>
        public override void OnLoaded(ProjectModuleDescription module)
        {
            base.OnLoaded(module);
            var unitOfWork = CreateUnitOfWork();

            UserSessionService.Login(LoggedUser, LoginDialogService, unitOfWork);
            LoggedUser = UserSessionService.LoggedUser;
            Messenger.Default.Send("Logged!");
        }
コード例 #22
0
 public DiagnoseIssuesController(IHostingEnvironment hostingEnvironment, ILogger <DiagnoseIssuesController> logger, DiagnozeService diagnozeService, UserSessionService userSessionService, LogAnalyticsService logAnalyticsService, CommonService commonService)
 {
     _commonService       = commonService;
     _hostingEnvironment  = hostingEnvironment;
     _logger              = logger;
     _diagnozeService     = diagnozeService;
     _userSessionService  = userSessionService;
     _logAnalyticsService = logAnalyticsService;
 }
コード例 #23
0
        public void SetUp()
        {
            var subject   = new UserSessionService(null, null, null);
            var userToken = subject.NewUser();

            subject.LogIn(userToken, 1);

            _result = subject.IsLoggedIn(userToken);
        }
コード例 #24
0
        public IActionResult SignUp([FromBody] SignUpRequest request)
        {
            var user = UserService.FindByPhoneNumber(request.PhoneNumber);

            if (user != null)
            {
                return(BadRequest(new ResponseModel
                {
                    Success = false,
                    Message = "Номер телефона уже используется"
                }));
            }

            user = UserService.FindByEmail(request.Email);
            if (user != null)
            {
                return(BadRequest(new ResponseModel
                {
                    Success = false,
                    Message = "Email уже используется"
                }));
            }

            user = new User
            {
                FirstName    = request.FirstName,
                LastName     = request.LastName,
                PhoneNumber  = request.PhoneNumber,
                Email        = request.Email,
                Role         = UserRole.Client,
                RegisteredAt = DateTime.UtcNow
            };

            UserService.Create(user);

            UserWalletService.Create(new UserWallet
            {
                User    = user,
                Balance = 0
            });

            ProblemService.Create(new Problem
            {
                User        = user,
                ProblemText = request.Problem
            });

            var session = UserSessionService.CreateSession(user);

            SmscHelper.SendSms(user.PhoneNumber, $"Код для входа: {session.AuthCode}");

            return(Ok(new SignInResponse
            {
                UserID = user.ID
            }));
        }
コード例 #25
0
        private UserSessionService GetService()
        {
            _mockSettingsManager    = new Mock <ISettingsManager>();
            _mockUserRepo           = new Mock <IUserRepository>();
            _mockUserSessionRepo    = new Mock <IUserSessionRepository>();
            _mockSecurityLogService = new Mock <ISecurityLogService>();
            var service = new UserSessionService(_mockSettingsManager.Object, _mockUserRepo.Object, _mockUserSessionRepo.Object, _mockSecurityLogService.Object);

            return(service);
        }
コード例 #26
0
 public FillUpAddViewModel(
     IEventAggregator eventAggregator,
     INavigationService navigationService,
     UserSessionService userSessionService,
     MasterContext masterContext
     ) : base(eventAggregator, userSessionService, masterContext)
 {
     this._navService = navigationService;
     this.DateOffset  = DateTimeOffset.Now;
 }
コード例 #27
0
        public void SetUp()
        {
            var subject   = new UserSessionService(null, null, null);
            var userToken = subject.NewUser();

            subject.SetBasketForUser(userToken, new Data.Services.UserSession.Basket {
                Total = Money.From(5000)
            });
            _result = subject.GetBasketForUser(userToken);
        }
コード例 #28
0
        public void SetUp()
        {
            var subject   = new UserSessionService(null, null, null);
            var userToken = subject.NewUser();

            subject.SetBasketForUser("SOME_INVALID_USER_TOKEN", new ShoppingCart.Services.UserSession.Basket {
                Total = Money.From(5000)
            });

            _result = subject.GetBasketForUser(userToken);
        }
コード例 #29
0
 public FillUpAddViewModelBase(
     IEventAggregator eventAggregator,
     UserSessionService userSessionService,
     MasterContext masterContext
     ) : base(eventAggregator)
 {
     this.Date               = DateTime.Now;
     this.masterContext      = masterContext;
     this.userSessionService = userSessionService;
     this.Mileage            = this.userSessionService.CurrentVehicle.Mileage;
 }
コード例 #30
0
        public async Task <ActionResult> Sync()
        {
            var userSessionService = new UserSessionService();
            var userSession        = await userSessionService.GetCurrentSession();

            var _zerodhaBroker = new ZerodhaBroker(AutoMapper.Mapper.Map <UserSessionModel>(userSession));
            var instruments    = _zerodhaBroker._kite.GetInstruments().Where(x => x.Exchange == "NSE" || x.Exchange == "BSE").ToList();

            await _symbolService.DataRefereshAsync(instruments);

            return(View());
        }