コード例 #1
0
ファイル: EngineScene.cs プロジェクト: KatekovAnton/Game
        public EngineScene()
        {
            //инит ФизиХ-а
            var coreDesc = new CoreDescription();
            var output = new UserOutput();

            Core = new Core(coreDesc, output);
            Core.SetParameter(PhysicsParameter.ContinuousCollisionDetection, false);
            Core.SetParameter(PhysicsParameter.ContinuousCollisionDetectionEpsilon, 0.01f);

            var sceneDesc = new SceneDescription
            {
                SimulationType = SimulationType.Software, //Hardware,
                MaximumBounds = new Bounds3(-1000, -1000, -1000, 1000, 1000, 1000),
                UpAxis = 2,
                Gravity = new StillDesign.PhysX.MathPrimitives.Vector3(0.0f, -9.81f * 1.7f, 0.0f),
                GroundPlaneEnabled = false
            };
            Scene = Core.CreateScene(sceneDesc);
            //для обработки столкновений
            Scene.UserContactReport = new ContactReport(MyGame.Instance);

            _objects = new MyContainer<PivotObject>(100, 10, true);
            _visibleObjects = new MyContainer<PivotObject>(100, 2);
            _shadowObjects = new MyContainer<PivotObject>(100, 2);
            _sceneGraph = new SceneGraph.SceneGraph(this);
        }
コード例 #2
0
        private string GenerateJSONWebToken(UserOutput userInfo)
        {
            if (userInfo == null)
            {
                return(string.Empty);
            }
            SymmetricSecurityKey securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Jwt:Key"]));
            SigningCredentials   credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);
            string fullName = string.IsNullOrEmpty(userInfo.FullName) ? userInfo.Username : userInfo.FullName;

            string   tokenGuid = Guid.NewGuid().ToString();
            DateTime expried   = Clock.Now.AddMinutes(Math.Max(Convert.ToDouble(_config["Config:TokenExpiryTimeInMinutes"]), 5));

            Claim[] claims = new[] {
                new Claim(JwtRegisteredClaimNames.Sub, userInfo.Username),
                new Claim("Username", userInfo.Username),
                new Claim("Fullname", fullName),
                new Claim("UserType", userInfo.UserType),
                new Claim("ExpiredPassword", userInfo.ExpiredPassword),
                new Claim("UserId", userInfo.Id.ToString()),
                new Claim(JwtRegisteredClaimNames.Jti, tokenGuid)
            };

            JwtSecurityToken token       = new JwtSecurityToken(_config["Jwt:Issuer"], _config["Jwt:Issuer"], claims, signingCredentials: credentials);
            string           tokenString = new JwtSecurityTokenHandler().WriteToken(token);

            _userService.UpdateToken(userInfo.Id, tokenString, tokenGuid);

            return(tokenString);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            ConsoleKeyInfo consoleKeyInfo;

            Console.WriteLine("Compression Stocking Configuration");
            Console.WriteLine("A:   Air compression mechanism");
            Console.WriteLine("Z:   Laces compresison mechanism");
            Console.WriteLine("ESC: Terminate application");
            var configOk = false;

            // Read user input and create the applicable compression mechanism
            ICompressionMechanism compressionMechanism = null;  // Will be initiated below according to user's choice

            do
            {
                consoleKeyInfo = Console.ReadKey(true); // true = do not echo character

                if (consoleKeyInfo.Key == ConsoleKey.A)
                {
                    compressionMechanism = new AirCompressionMechanism(new Pump(), 5000, 2000);
                    configOk             = true;
                }
                if (consoleKeyInfo.Key == ConsoleKey.Z)
                {
                    compressionMechanism = new LaceCompressionMechanism(40, 100, new LaceTighteningDevice());
                    configOk             = true;
                }
                if (consoleKeyInfo.Key == ConsoleKey.Escape)
                {
                    return;
                }
            } while (!configOk);

            // Create the Stocking Controller using the factory corresponding to user's choice
            IUserOutput  userOutput   = new UserOutput(new LED(), new LED(), new Vibrator());
            StockingCtrl stockingCtrl = new StockingCtrl(compressionMechanism, userOutput);

            compressionMechanism.CompressionEventListener = stockingCtrl;   // Set up call-back receiver


            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Compression Stocking Control User Interface");
            Console.WriteLine("A:   Compress");
            Console.WriteLine("Z:   Decompress");
            Console.WriteLine("ESC: Terminate application");

            do
            {
                consoleKeyInfo = Console.ReadKey(true); // true = do not echo character
                if (consoleKeyInfo.Key == ConsoleKey.A)
                {
                    stockingCtrl.StartBtnPushed();
                }
                if (consoleKeyInfo.Key == ConsoleKey.Z)
                {
                    stockingCtrl.StopBtnPushed();
                }
            } while (consoleKeyInfo.Key != ConsoleKey.Escape);
        }
コード例 #4
0
        public virtual IList <TimePointStats> start(UserOutput output)
        {
            Thread.CurrentThread.Name = "Main engine execution thread";
            double result = 1;

            initPopulation();
            TimePoint timePoint = new TimePoint(engineSettings.startTimePoint);
            IList <TimePointStats> timePointStats = new List <TimePointStats>();

            while (engineSettings.endTimePoint.CompareTo(timePoint) >= 0)
            {
                TimePointStats stat = executeTimePoint(timePoint, output);
                if (stat != null)
                {
                    timePointStats.Add(stat);
                    result *= (stat.PercentEarned / 100 + 1);
                    profitRecorder.recordProfit(stat.PercentEarned);
                    output.reportProfitForTimePoint(timePoint, (result - 1) * 100, stat.PercentEarned);
                }
                timePoint = timePoint.next();
            }
            if (engineSettings.performTraining)
            {
                savePopulation(output);
            }
            showSummary(output);
            return(timePointStats);
        }
コード例 #5
0
        /// <summary>
        /// Метод получает сумму средств на балансе текущего пользователя.
        /// </summary>
        /// <param name="account">Логин текущего пользователя.</param>
        /// <returns>Сумма баланса.</returns>
        public async Task <UserOutput> GetBalanceAsync(string account)
        {
            try
            {
                var userId = await _userService.GetUserIdByLogin(account);

                var balanceAmount = await _postgre.Invoices
                                    .Where(a => a.UserId
                                           .Equals(userId))
                                    .Select(res => res.InvoiceAmount)
                                    .FirstOrDefaultAsync();

                var result = new UserOutput
                {
                    Amount = balanceAmount
                };

                return(result);
            }

            catch (Exception e)
            {
                Console.WriteLine(e);
                Logger logger = new Logger(_db, e.GetType().FullName, e.Message, e.StackTrace);
                await logger.LogCritical();

                throw;
            }
        }
コード例 #6
0
        public void FillUserOuput()
        {
            this.Invoke(new MethodInvoker(delegate()
            {
                Double[] d  = new Double[UserInput.GetArray().Length];
                Boolean[] b = new Boolean[UserOutput.GetArray().Length];
                for (int i = 0; i < d.Length; i++)
                {
                    if (UserInput.GetArray()[i])
                    {
                        d[i] = 1;
                    }
                    else
                    {
                        d[i] = 0;
                    }
                }

                for (int i = 0; i < pm.weight.Length; i++)
                {
                    if (d * pm.weight[i] >= pm.threshold)
                    {
                        b[i] = true;
                    }
                    else
                    {
                        b[i] = false;
                    }
                }

                UserOutput.DrawByValue(b);
            }));
        }
コード例 #7
0
        public async Task <UserOutput> GetUserInfo(UserInput input)
        {
            var result = new UserOutput();

            if (input.id == 1)
            {
                result.name = "小明";
                result.year = "19岁";
            }
            //远程调用学校服务获取学校信息
            var schoolinfo = await schoolService.GetSchoolInfo(new UserSchoolInfoInput()
            {
                id = 1
            });

            if (schoolinfo != null)
            {
                result.schoolname = schoolinfo.schoolname;
            }
            else
            {
                result.schoolname = "RPC调用失败,请查看日志";
            }
            return(result);
        }
コード例 #8
0
        public override MainSettings getSettings(UserOutput output)
        {
            ISet <string> parsedKeys = new HashSet <string>();

            try
            {
                IDictionary <string, string> map = buildFileMap();
                MainSettings settings            = MainSettings.Settings;
                MainAppData  data = createData(map, parsedKeys, output);
                settings.startTimePoint = data.FirstTimePoint;
                settings.endTimePoint   = data.LastTimePoint;
                settings.dataSettings   = getDataDir(map, parsedKeys);
                applySettingsFromMap(settings, map, parsedKeys);
                checkAllSettingsParsed(map, parsedKeys);
                return(settings);
            }
            catch (IOException e)
            {
                throw new Exception("Unable to read file " + fileName, e);
            }
            catch (IllegalAccessException e)
            {
                throw new Exception(e);
            }
        }
コード例 #9
0
        /// <summary>
        /// Метод получит роль пользователя по его логину.
        /// </summary>
        /// <param name="account">Логин пользователя.</param>
        /// <returns>Роль пользователя.</returns>
        public async Task <UserOutput> GetUserRoleByLoginAsync(string account)
        {
            try
            {
                var role = await(from u in _postgre.Users
                                 where u.UserName.Equals(account)
                                 select u.UserRole)
                           .FirstOrDefaultAsync();

                // Если нет роли, значит назначить гостя.
                if (string.IsNullOrEmpty(role))
                {
                    role = "G";
                }

                var result = new UserOutput
                {
                    UserRole = role
                };

                return(result);
            }

            catch (Exception e)
            {
                Console.WriteLine(e);
                var logger = new Logger(_db, e.GetType().FullName, e.Message, e.StackTrace);
                await logger.LogCritical();

                throw;
            }
        }
コード例 #10
0
ファイル: UserService.cs プロジェクト: trunghieufsoft/API
        private void CheckExpiredPass(ref UserOutput user)
        {
            var key    = user.UserType == UserTypeEnum.Employee.ToString() ? SystemConfigEnum.AppPassExpDate.ToString() : SystemConfigEnum.WebPassExpDate.ToString();
            var config = _configService.GetSystemConfig(key);

            if (config == null || (config.LastUpdateDate.HasValue && config.LastUpdateDate.Value.Date == Clock.Now.Date))
            {
                user.ExpiredPassword = "******";
                return;
            }
            if (!user.InitializeInfo.PasswordLastUpdate.HasValue)
            {
                var account = _userRepository.GetById(user.Id);
                if (account != null)
                {
                    account.PasswordLastUdt = user.InitializeInfo.PasswordLastUpdate = Clock.Now;
                    _unitOfWork.Update(account);
                    _unitOfWork.Commit();
                }
            }
            var expiredDate = user.InitializeInfo.PasswordLastUpdate.Value.AddDays((CaculateDayOfConfig(config)));
            var now         = Clock.Now;

            if (expiredDate.Date < now.Date && user.UserType == UserTypeEnum.Employee.ToString())
            {
                throw new DefinedException(ErrorCodeEnum.PasswordExpired, user.Username);
            }
            else
            {
                user.ExpiredPassword = Math.Round((expiredDate - now).TotalDays, 0).ToString();
            }
        }
コード例 #11
0
        public IActionResult View(Guid id)
        {
            _sessionService.CheckSession(GetToken(), GetCurrentUser());
            UserOutput data = _userService.View(id);

            return(Json(data));
        }
コード例 #12
0
        public IActionResult GetProfile()
        {
            _sessionService.CheckSession(GetToken(), GetCurrentUser());
            Guid?      userId = GetUserIdFromHeader();
            UserOutput result = _userService.View(userId.Value);

            return(Json(result));
        }
コード例 #13
0
 public static string GetUserOutputText(this UserOutput userOutputMock)
 {
     return
         (userOutputMock.ReceivedCalls()
          .Select(x => x.GetArguments().First())
          .Aggregate((x, y) => $"{x}{y}")
          .ToString());
 }
コード例 #14
0
        public JsonResult GetUserInfoById()
        {
            int        Id         = (int)HttpContext.Session.GetInt32("UpdateId");
            UserOutput userOutput = _userManageService.GetUserById(Id);

            HttpContext.Session.Remove("UpdateId");
            return(Json(userOutput));
        }
コード例 #15
0
        public SimpleTimePointExecutor(UserOutput output)
        {
            int cores = Runtime.Runtime.availableProcessors();

            executorService = Executors.newFixedThreadPool(cores * 2, new DaemonThreadFactory());
            robotInfos      = Collections.synchronizedList(new List <RobotInfo>());
            this.output     = output;
        }
コード例 #16
0
 public GameInterfaceManager(IVectorProvider vectorProvider,
                             UserOutput userOutput,
                             IConsoleWrapper consoleWrapper)
 {
     _vectorProvider = vectorProvider;
     _userOutput     = userOutput;
     _consoleWrapper = consoleWrapper;
 }
コード例 #17
0
        private IUserOutput CreateSut()
        {
            var sut = new UserOutput(m_Console,
                                     m_DisplayPlayingFieldFactory,
                                     m_HintField,
                                     m_PlayingField);

            return(sut);
        }
コード例 #18
0
 public GameMediator(UserInput userInput, UserOutput userOutput,
                     IUserInputParser userInputParser,
                     IGameInterfaceManager gameInterfaceManager)
 {
     _userInput            = userInput;
     _userOutput           = userOutput;
     _userInputParser      = userInputParser;
     _gameInterfaceManager = gameInterfaceManager;
 }
コード例 #19
0
 public ApiResult <RoleOuput> Login([FromBody] UserOutput userOutput)
 {
     return(null);
     //var result = Resolve<IEmployeeService>().Login(userOutput, () => {
     //    var storeInfo = Resolve<IStoreService>().GetSingle(s => s.UserId == userOutput.Id);
     //    return (storeInfo != null, FilterType.Store);
     //});
     //return ZKCloud.Open.ApiBase.Models.ApiResult.Success(result);
 }
コード例 #20
0
ファイル: UserDetailService.cs プロジェクト: adteven/alabo
        /// <summary>
        ///     获取角色
        ///     参数中带有ref ,返回执行结果即可
        /// </summary>
        /// <param name="userOutput"></param>
        /// <param name="filterType"></param>
        /// <returns></returns>
        public ServiceResult GetUserRoles(ref UserOutput userOutput, FilterType filterType)
        {
            return(null);
            //userOutput.Roles = new UserOutputRoles();
            //// 后台管理员判断
            //if (filterType == FilterType.Admin)
            //{
            //    var isAdmin = Resolve<IUserService>().IsAdmin(userOutput.Id);
            //    if (isAdmin == false)
            //    {
            //        return ServiceResult.Failure("非管理员不能登录");
            //    }
            //    userOutput.Roles.AdminMenus = Resolve<IEmployeeService>().GetAdminMenus(userOutput.Id);
            //    if (userOutput.Roles.AdminMenus == null)
            //    {
            //        return ServiceResult.Failure("非管理员不能登录");
            //    }
            //    userOutput.Roles.FilterType = FilterType.Admin;
            //    return ServiceResult.Success;

            //}
            //else if (filterType == FilterType.Store)// 供应商
            //{
            //    var store = EntityDynamicService.GetStore(userOutput.Id);
            //    if (store == null) return ServiceResult.Failure("你的账号并非供应商,请联系管客服或者管理员");
            //    userOutput.Roles.FilterType = FilterType.Store;
            //    return ServiceResult.Success;
            //}
            //else if (filterType == FilterType.City)//城市运营中心
            //{
            //    var city = EntityDynamicService.GetCity(userOutput.Id);
            //    if (city == null) return ServiceResult.Failure("你的账号并非城市运营中心,请联系管客服或者管理员");
            //    userOutput.Roles.FilterType = FilterType.City;

            //    return ServiceResult.Success;
            //}
            //else if (filterType == FilterType.Market)//营销中心
            //{
            //    //通过会员等级来判断
            //    //var userGrades = Resolve<IAutoConfigService>().GetList<UserGradeConfig>();
            //    //var userGradeId = userOutput.GradeId;
            //    //营销中心的id
            //    if (userOutput.GradeId != Guid.Parse("cc873faa-749b-449b-b85a-c7d26f626feb"))
            //        return ServiceResult.Failure("你的账号并非营销中心,请联系管客服或者管理员");

            //    userOutput.Roles.FilterType = FilterType.Market;

            //    return ServiceResult.Success;
            //}
            //else
            //{
            //    userOutput.Roles.FilterType = FilterType.User;

            //    return ServiceResult.Success;
            //}
        }
コード例 #21
0
 public static void ShowUserOutput(Player player)
 {
     PlayerHelper.DisplayPlayerStats(player);
     RoomHelper.Rooms[player.PlayerLocation].ShowCommands();
     MapDisplay    = BuildMap(player, Settings.GetMiniMapHeight(), Settings.GetMiniMapWidth());
     EffectDisplay = ShowEffects(player);
     QuestDisplay  = ShowQuests(player);
     Display.BuildUserOutput();
     Display.RetrieveUserOutput();
 }
コード例 #22
0
 public ApiResult <RoleOuput> Login([FromBody] UserOutput userOutput)
 {
     return(null);
     ////Todo 城市合伙人登录
     //var result = Resolve<IEmployeeService>().Login(userOutput, () =>
     //{
     //    return (true, FilterType.City);
     //});
     //return Open.ApiBase.Models.ApiResult.Success(result);
 }
コード例 #23
0
        private void fixFile(string name, UserOutput output)
        {
            output.infoMessage("Fixing file: " + name);
            IList <Number[]> originalList = buildOriginalList(name);

            originalList.Reverse();
            IList <IList <Number> > newList = fixList(originalList);

            saveListToFile(newList, name);
        }
コード例 #24
0
ファイル: ApiMarketController.cs プロジェクト: adteven/alabo
 public ApiResult <RoleOuput> Login([FromBody] UserOutput userOutput)
 {
     return(null);
     //var result = Resolve<IEmployeeService>().Login(userOutput, () =>
     //{
     //    var isMarker = userOutput.GradeId == Guid.Parse("cc873faa-749b-449b-b85a-c7d26f626feb");
     //    return (isMarker, FilterType.Market);
     //});
     //return ZKCloud.Open.ApiBase.Models.ApiResult.Success(result);
 }
コード例 #25
0
 public ConsoleCommandExecutor(UserInput userInput,
                               UserOutput userOutput,
                               ILogger <ConsoleCommandExecutor> logger,
                               IConsoleWrapper consoleWrapper)
 {
     _userInput      = userInput;
     _userOutput     = userOutput;
     _logger         = logger;
     _consoleWrapper = consoleWrapper;
 }
コード例 #26
0
 public ReservationsOutput(ReservationEntity reservation)
 {
     Id           = reservation.Id;
     User         = new UserOutput(reservation.User);
     Room         = new RoomOutput(reservation.Room);
     ReservedFrom = reservation.ReservedFrom;
     ReservedTo   = reservation.ReservedTo;
     Cost         = reservation.Cost;
     Services     = reservation.Services.Select(s => new ServiceOutput(s));
 }
コード例 #27
0
        public virtual void fixFiles(UserOutput output)
        {
            string         extension = ".csv";
            IList <string> names     = DataUtils.listFiles(extension, path);

            foreach (string name in names)
            {
                fixFile(name, output);
            }
        }
コード例 #28
0
ファイル: HttpService.cs プロジェクト: eosvil/AntennaChat
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="input"></param>
        /// <param name="output"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public bool GetUserInfo(UserInput input, ref UserOutput output, ref string errMsg)
        {
            bool doResult = HttpCommonMethod <UserInput, UserOutput>("/antuser/user.getUser.do", GlobalVariable.RequestMethod.POST, input, ref output, ref errMsg);

            if (doResult && output.result == (int)GlobalVariable.Result.Failure)
            {
                errMsg = string.IsNullOrEmpty(output.errorCode) ? "获取用户信息失败" : resources.GetString("E_" + output.errorCode);
                return(false);
            }
            return(doResult);
        }
コード例 #29
0
        public ApiResult <RoleOuput> Login([FromBody] UserOutput userOutput)
        {
            if (!this.IsFormValid())
            {
                return(ApiResult.Failure <RoleOuput>(this.FormInvalidReason(), MessageCodes.ParameterValidationFailure));
            }

            var result = Resolve <IEmployeeService>().Login(userOutput);

            return(ToResult(result));
        }
コード例 #30
0
        public async Task <IActionResult> taskDetails([FromBody] DetailsTaskInput detailsTaskInput)
        {
            string token = HttpContext.Request.Headers["Authorization"];

            if (token != null)
            {
                try
                {
                    Guid taskIDAsGuid     = new Guid(detailsTaskInput.TaskID);
                    DetailsTaskOutput DTO = new DetailsTaskOutput();


                    ProjectTask task = await _context.ProjectTasks.SingleOrDefaultAsync(x => x.ID == taskIDAsGuid);

                    if (task == null)
                    {
                        return(NotFound());
                    }

                    ApplicationUser user = await _userManager.FindByEmailAsync(_jwtService.GetClaimValue(token, "email"));

                    //Gets all the users on the task
                    List <Guid> userIDs = await _context.ProjectTaskUsers.Where(UT => UT.ProjectTaskID == taskIDAsGuid).Select(UT => UT.UserID).ToListAsync();

                    List <ApplicationUser> UsersOnTask = await _context.Users.ToListAsync();

                    UsersOnTask     = UsersOnTask.Where(u => userIDs.Contains(u.Id)).ToList();
                    DTO.UsersOnTask = new List <UserOutput>();
                    UsersOnTask.ForEach(u =>
                    {
                        UserOutput UO = new UserOutput();
                        UO.Username   = u.UserName;
                        UO.Email      = u.Email;
                        UO.Avatar     = "https://www.suitdoctors.com/wp-content/uploads/2016/11/dummy-man-570x570.png";
                        DTO.UsersOnTask.Add(UO);
                    });

                    DTO.Remarks = await _context.Remarks.Where(Remark => Remark.ProjectTaskID == taskIDAsGuid).ToListAsync();

                    DTO.Remarks = DTO.Remarks.OrderBy(x => x.Created).ToList();
                    return(Json(DTO));
                }
                catch (ApplicationException e)
                {
                    return(Unauthorized());
                }
                catch (Exception e)
                {
                    return(NotFound());
                }
            }
            return(Unauthorized());
        }
コード例 #31
0
 public MainMenu(IWordsProvider wordsProvider,
                 UserOutput userOutput,
                 IUserInputParser userInputParser,
                 IGameInterfaceManager gameInterfaceManager,
                 IGameMediator gameMediator)
 {
     _wordsProvider        = wordsProvider;
     _userOutput           = userOutput;
     _userInputParser      = userInputParser;
     _gameInterfaceManager = gameInterfaceManager;
     _gameMediator         = gameMediator;
 }