public override void OnInspectorGUI() { LogicHandler script = (LogicHandler)target; EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("ContentHolder: "); script.listHolder = (GameObject)EditorGUILayout.ObjectField(script.listHolder, typeof(Object), true); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Row Prefab: "); script.listElementPref = (GameObject)EditorGUILayout.ObjectField(script.listElementPref, typeof(Object), true); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("InputField: "); script.textField = (InputField)EditorGUILayout.ObjectField(script.textField, typeof(InputField), true); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("AddButton: "); script.bttnAdd = (Button)EditorGUILayout.ObjectField(script.bttnAdd, typeof(Button), true); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); serializedObject.Update(); viewlist.DoLayoutList(); serializedObject.ApplyModifiedProperties(); }
/// <summary> /// Unregister the handler to all events /// </summary> /// <param name="handler">Handler.</param> public static void UnRegisterAll(LogicHandler handler) { for (int i = 0; i < logicEvents.Length; ++i) { logicEvents [i] -= handler; } }
public override async Task Execute() { var token = new WriteToken { UserId = Login.Id, JwtKey = Settings.Value.JwtKey }; await LogicHandler.Execute(token); if (token.Result) { Result.Success = true; Result.Id = Login.Id; Result.Verification = token.Verification; Result.Config = Config; Result.Key = EncryptHelper.Encrypt(Login.Id + Keys.Salty); Result.User.Id = Login.Id; Result.User.Name = Login.Name; Result.User.Email = Login.Email; Result.User.HasProfile = Login.HasProfile; Result.User.HasPhone = !string.IsNullOrEmpty(Login.EncryptedPhone); Result.User.ProfileThumbUrl = Login.ProfileThumbUrl; Result.Right = Login.Right; Result.Success = true; if (Tenant != null) { Result.User.TenantId = Tenant.Id; Result.User.ClientHasProfile = Tenant.HasProfile; Result.User.TenantName = Tenant.Name; Result.User.ClientProfileThumbUrl = Tenant.ProfileThumbUrl; } } await Task.CompletedTask; }
protected override void OnStart(string[] args) { LogicHandler handler = new LogicHandler(); httpListener = new NonblockingHttpListener(Config.Urls, handler.FileUpload); httpListener.Start(); }
static void Main(string[] args) { var path = Path.Combine(Environment.CurrentDirectory, @"..\..\", "input.json"); InputModel inputModel = JsonHandler <InputModel> .ReadJson(path); // Calculates how many days were suspende per year var suspendedDaysPerYear = LogicHandler.GetSuspendedDaysPerYear(inputModel.SuspensionPeriodList); foreach (var period in suspendedDaysPerYear) { Console.WriteLine($"{period.Key} -> {period.Value} days"); } var holidayDaysPerYear = LogicHandler.GetDaysOffPerYear(suspendedDaysPerYear, inputModel.EmploymentStartDate.Year); foreach (var period in holidayDaysPerYear) { Console.WriteLine($"{period.Key} -> {period.Value} days"); } var outputModel = new OutputModel { ErrorMessage = "No Error!", HolidayRightsPerYearList = holidayDaysPerYear }; JsonHandler <OutputModel> .WriteJson(path, outputModel); Console.Read(); }
public async Task <IActionResult> Post([FromBody] SignupViewModel viewModel) { var query = new UserByEmail { Email = viewModel.Email }; await DataHandler.Execute(query); if (query.Result == null) { var signup = new SignupUser() { DataHandler = DataHandler, Input = viewModel, LogicHandler = LogicHandler, CloudHandler = CloudHandler }; await LogicHandler.Execute(signup); return(Ok(signup.ResultAuth)); } return(Ok(new FailViewModel { Message = "Email already in use" })); }
public async Task <IActionResult> Reset([FromBody] ForgotResetViewModel viewModel) { var query = new UserByEmail { Email = viewModel.Email }; await DataHandler.Execute(query); if (query.Result != null && query.Result.IsActive && (query.ResultTenant == null || query.ResultTenant.IsActive)) { var config = query.ResultConfig; if (!string.IsNullOrEmpty(config.ForgotCode) && !string.IsNullOrEmpty(config.ResetCode) && config.ForgotCode == viewModel.Code && config.ResetCode == viewModel.ResetCode) { var user = query.Result; user.EncryptedPwd = EncryptHelper.Encrypt(viewModel.ResetPassword); config.ResetAuth = string.Empty; config.ResetCode = string.Empty; config.ForgotCode = string.Empty; config.ForgotCounter = 0; var persistUser = new Persist <User>() { Model = user }; await DataHandler.Execute(persistUser); var persistConfig = new Persist <UserConfig>() { Model = config }; await DataHandler.Execute(persistConfig); if (persistUser.Confirm.Success) { await DataHandler.Commit(); } var logic = new SigninAuth { Login = query.Result, Config = query.ResultConfig, Tenant = query.ResultTenant, Settings = CloudHandler.Settings }; await LogicHandler.Execute(logic); return(Ok(logic.Result)); } return(Ok(new FailViewModel { Message = "Code does not match" })); } return(Ok(new FailViewModel { Message = "Email not found" })); }
public async Task <IActionResult> Reconnect([FromBody] ReconnectViewModel viewModel) { if (viewModel.Key.Equals(EncryptHelper.Encrypt(viewModel.Id + Keys.Salty))) { var query = new UserById { Id = viewModel.Id }; await DataHandler.Execute(query); if (query.Result != null && query.Result.IsActive && (query.ResultTenant == null || query.ResultTenant.IsActive)) { var logic = new SigninAuth { Login = query.Result, Config = query.ResultConfig, Tenant = query.ResultTenant, Settings = CloudHandler.Settings }; await LogicHandler.Execute(logic); return(Ok(logic.Result)); } } return(Ok(new FailViewModel { Message = "Reconnect failed" })); }
public async Task <IActionResult> Stats() { const int back = 30; var data = new StatsComposite() { CurrentUser = CurrentUser, Back = back }; await DataHandler.Execute(data); var meetingDays = new DayDisplay <MeetingDisplay>() { DateFrom = DateHelper.FormatDayStart(DateTime.UtcNow.AddDays(-back)), Days = back, Source = data.Result.Meetings }; await LogicHandler.Execute(meetingDays); var msgDays = new DayDisplay <MsgDisplay>() { DateFrom = DateHelper.FormatDayStart(DateTime.UtcNow.AddDays(-back)), Days = back, Source = data.Result.Msgs }; await LogicHandler.Execute(msgDays); return(Ok(new StatsViewModel() { Meetings = meetingDays.Result, Messages = msgDays.Result, Tenant = data.Result.Tenant, Success = true })); }
public async Task <IActionResult> Delete(string id) { var query = new Loader <VisibleFile> { Id = id }; await DataHandler.Execute(query); if (query.Result != null && AuthoriseWrite(query.Result)) { var delete = new FileDelete { CloudHandler = CloudHandler, File = query.Result }; await LogicHandler.Execute(delete); if (delete.Result.Success) { await DataHandler.Commit(); return(Ok(ConfirmViewModel.CreateSuccess(id))); } return(Ok(ConfirmViewModel.CreateFailure("Failed to delete file"))); } return(Unauthorized()); }
public void Draw(SpriteBatch sb, LogicHandler logic, ResourceManager resourceManager, int screenWidth, int screenHeight) { var screenRatioX = ((float)screenWidth) / GameConstants.SCREEN_SIZE_IN_GAME_UNITS.X; var screenRatioY = ((float)screenHeight) / GameConstants.SCREEN_SIZE_IN_GAME_UNITS.Y; _screenRatio = new Vector2(screenRatioX, screenRatioY); if (logic.GameState == GameStates.StartMenu) { } else if (logic.GameState == GameStates.ExitMenu) { lock (resourceManager.Loading.Sync) { DrawExitMenu(sb, resourceManager); DrawRoam(sb, logic, resourceManager); } } else if (logic.GameState == GameStates.Roam) { lock (resourceManager.Loading.Sync) { DrawRoam(sb, logic, resourceManager); } } }
//Fyller i TB's med en användare man valt att uppdatera ur Listan private void listBoxUsers_SelectionChanged(object sender, SelectionChangedEventArgs e) { tbUserID.IsEnabled = true; tbUsername.IsEnabled = true; tbBoss.IsEnabled = true; var logic = new LogicHandler(); var selected = listBoxUsers.SelectedValue.ToString(); var u = logic.getInfoOnSelectedUser(); var val = logic.checkIfDigits(selected); foreach (var user in u.Where(user => val.Equals(user.UID))) { tbFirstName.Text = user.FirstName; tbLastNamne.Text = user.LastName; tbEmail.Text = user.Email; tbPassword.Text = user.PW; tbUsername.Text = user.Username; tbSsn.Text = user.SSN; tbBoss.Text = user.BID.ToString(); tbUserID.Text = user.UID.ToString(); } }
private void btnSaveStartCountry_Click(object sender, RoutedEventArgs e) { LogicHandler l = new LogicHandler(); var dayinfo = ""; var breakfast = CHBBreakfast.IsChecked.Value; var lunch = CHBLunch.IsChecked.Value; var dinner = CHBDinner.IsChecked.Value; double subsistenceDouble = Convert.ToDouble(LbTraktamente.Content.ToString()); var subsistence = l.CalculateSubsistenceDeduction(breakfast, lunch, dinner, subsistenceDouble); try { if (CHBVacationday.IsChecked == true) { dayinfo = listBoxDays.SelectedItem.ToString() + " - " + CbCountries.SelectedItem.ToString() + " - " + " LEDIG"; listBoxDays.Items[listBoxDays.SelectedIndex] = dayinfo; } else { dayinfo = listBoxDays.SelectedItem.ToString() + " - " + CbCountries.SelectedItem.ToString() + " - " + subsistence + " kr"; listBoxDays.Items[listBoxDays.SelectedIndex] = dayinfo; } } catch { MessageBox.Show("Du måste välja en dag samt fylla i information att spara."); } }
public void ShowFrame() { TimeModule.Instance.RemoveTimeaction(OnPostHideFrame); TimeModule.Instance.RemoveTimeaction(DestroyFrame); if (!Visible) { this.Visible = true; float duration = 0; if (OpenFrameParam.OpenUIWithAnimation) { foreach (UITweenerBase ut in uiTweens) { if (ut.gameObject.activeInHierarchy && ut.m_triggerType == UITweenerBase.TweenTriggerType.OnShow) { duration = Mathf.Max(duration, ut.Duration + ut.Delay); ut.ResetAndPlay(); } } } if (LogicHandler != null) { LogicHandler.OnShow(OpenFrameParam.Param, false); } TimeModule.Instance.SetTimeout(OnAfterShowFrameFinish, duration, false, false); if (OpenFrameParam.IsBlur) { EngineCoreEvents.UIEvent.BlurUIBackground(true); } } }
public void HideFrame() { if (LogicHandler != null) { TimeModule.Instance.RemoveTimeaction(OnAfterShowFrameFinish); LogicHandler.OnHide(); } if (Visible) { OnBeforeFrameDestroyEvent?.Invoke(this); float duration = 0; if (m_hideFrameParam.HideFrameWithAnimation) { foreach (UITweenerBase ut in uiTweens) { if (ut.gameObject.activeInHierarchy && ut.m_triggerType == UITweenerBase.TweenTriggerType.OnHide) { duration = Mathf.Max(duration, ut.Duration + ut.Delay); ut.ResetAndPlay(); } } } TimeModule.Instance.SetTimeout(OnPostHideFrame, duration, false, false); //窗口在这里被没真正的隐藏,因为有Tween 没执行,遵循开闭原则,对外暴露已经关闭,对内等到真正Tween之后才进行关闭渲染 this.m_frameVisible = false; } }
public override async Task <IActionResult> Post([FromBody] MeetingViewModel viewModel) { var model = await Parse(viewModel); if (AuthoriseWrite(model)) { model.Participants = viewModel.Attendees.Select(f => f.Id).ToList(); var attendCheck = new AttendCheck() { CurrentUser = CurrentUser, DataHandler = DataHandler, LogicHandler = LogicHandler, Meeting = model }; await LogicHandler.Execute(attendCheck); if (attendCheck.Result) { await DataHandler.Commit(); return(Ok(ConfirmViewModel.CreateSuccess(attendCheck.Meeting))); } else { return(Ok(ConfirmViewModel.CreateFailure("Failed to save Meeting"))); } } return(Unauthorized()); }
public void Draw(SpriteBatch sb, LogicHandler logic, ResourceManager resourceManager) { resourceManager.CheckLoad(); resourceManager.CheckUnload(); var state = GameStateHelper.CurrentState; if (state == GameStates.Start) { _menuGraphicsHandler.DrawStart(sb, logic, resourceManager); } else if (state == GameStates.StartMenu) { _menuGraphicsHandler.DrawStartMenu(sb, logic, resourceManager); } else if (state == GameStates.Roam) { _roamGraphicsHandler.DrawRoam(sb, logic, resourceManager); } else if (state == GameStates.ExitMenu) { _roamGraphicsHandler.DrawRoam(sb, logic, resourceManager); _menuGraphicsHandler.DrawExitMenu(sb, logic, resourceManager); } }
private void BtnLogin_Click(object sender, RoutedEventArgs e) { LogicHandler l = new LogicHandler(); var username = TbUsername.Text; var password = TbPassword.Text; var loggedUser = l.loginUser(username, password); var loggedBoss = l.loginBoss(username, password); if (loggedUser != null && source == 2) //source, chef eller vanlig användare { MainWindow.main.Status = loggedUser.Username; MainWindow.main.btnLogOut.Visibility = Visibility.Visible; MainWindow.main.BtnLogIn.Visibility = Visibility.Hidden; this.Close(); } else if (loggedBoss != null && source == 1) { var isBoss = String.Format(loggedBoss.Username + " (Chef)"); MainWindow.main.BossStatus = isBoss; MainWindow.main.btnLogOutChef.Visibility = Visibility.Visible; MainWindow.main.btnLogInChef.Visibility = Visibility.Hidden; this.Close(); } else { lbError.Content = "Misslyckad inloggning! Försök igen tack å hej"; } }
private void btnInactive_Click(object sender, RoutedEventArgs e) { var logic = new LogicHandler(); logic.changeStatus(listBoxUsers.SelectedValue.ToString()); }
void Start() { var ran = Random.Range(0, 2); _direction = ran == 0 ? 1 : -1; _startingPoint = transform.position; _logic = GameObject.FindGameObjectWithTag("LogicHandler").GetComponent<LogicHandler>(); }
private void OnTriggerEnter(Collider other) { //todo 2nd game: remove this class. it should be dead code var gameObjWrapper = GameEngineInterface.FindGameObject(other.gameObject.name); LogicHandler.OnCollision(this, gameObjWrapper); //Debug.Log("OnTriggerEnter"); }
public void GetMovieById_ShouldThrowException() { var logicHandler = new LogicHandler(); var testMovies = GetTestMovies(); var testId = "dsak"; Assert.ThrowsException <ArgumentNullException>(() => logicHandler.GetSingleMovie(testMovies, testId)); }
//Uppdatera Användare private void btnUpdateInfo_Click(object sender, RoutedEventArgs e) { LogicHandler updateUserHandler = new LogicHandler(); Validator validate = new Validator(); var bossID = tbBoss.Text; var userID = tbUserID.Text; var id = Int32.Parse(userID); var username = tbUsername.Text; var firstname = tbFirstName.Text; var lastname = tbLastNamne.Text; var password = tbPassword.Text; var boss = Int32.Parse(bossID); var ssn = tbSsn.Text; var mail = tbEmail.Text; if (validate.ControllFiledNotEmpty(tbUsername)) { MessageBox.Show("Du måste ange ett användarnamn!"); } else if (validate.ControllFiledNotEmpty(tbFirstName)) { MessageBox.Show("Du måste ange ett förnamn!"); } else if (validate.ControllFiledNotEmpty(tbLastNamne)) { MessageBox.Show("Du måste ange ett efternamn!"); } else if (validate.ControllFiledNotEmpty(tbPassword)) { MessageBox.Show("Du måste ange ett lösenord!"); } else if (validate.ControllFiledNotEmpty(tbSsn)) { MessageBox.Show("Du måste ange ett personnummer!"); } else if (validate.ControllFiledNotEmpty(tbEmail)) { MessageBox.Show("Du måste ange en email-adress!"); } else if (validate.ControllFiledNotEmpty(tbBoss)) { MessageBox.Show("Du måste ange vem som är chef för användaren!"); } else if (validate.ControllFiledNotEmpty(tbUserID)) { MessageBox.Show("Användaren måste ha ett anställnigsnummer!"); } else { updateUserHandler.uppdateUser(id, username, firstname, lastname, password, ssn, mail, boss); MessageBox.Show(tbFirstName.Text + " " + tbLastNamne.Text + " har uppdaterats!"); listBoxUsers.SelectedValue = tbUsername.Text; listBoxUsers.Items.Clear(); PopulateListViewUsers(); } }
public async Task LogicHandlerTestInit() { var command = new FakeLogicCommand(); var logic = new LogicHandler() { User = StandardUser }; await logic.Execute(command); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { _resourceManager = new ResourceManager(Content.ServiceProvider, Content.RootDirectory); _resourceManager.LoadPreferenceData(); _inputHandler = new InputHandler(_resourceManager.LastUsedPreferenceData); _logicHandler = new LogicHandler(_resourceManager, _inputHandler); _graphicsHandler = new GraphicsHandler(); base.Initialize(); }
public async Task <IActionResult> Code([FromBody] ForgotViewModel viewModel) { var query = new UserByEmail { Email = viewModel.Email }; await DataHandler.Execute(query); if (query.Result != null && query.Result.IsActive && (query.ResultTenant == null || query.ResultTenant.IsActive)) { var config = query.ResultConfig; if (config.ForgotCounter < 10) { config.ForgotCode = StringHelper.GenerateCode(12); config.ResetAuth = Convert.ToString(EncryptHelper.Randomizer(100000, 999999)); config.ForgotCounter += 1; var persist = new Persist <UserConfig>() { Model = config }; await DataHandler.Execute(persist); if (persist.Confirm.Success) { await DataHandler.Commit(); } var notify = new SimpleNotify { CloudHandler = CloudHandler, DataHandler = DataHandler, CurrentUser = query.Result, LogicHandler = LogicHandler, Model = persist.Model, TemplateName = "forgot" }; await LogicHandler.Execute(notify); return(Ok(new ForgotCodeViewModel() { Email = viewModel.Email, Code = config.ForgotCode, Success = true })); } return(Ok(new FailViewModel { Message = "Too many Forgot Password attempts -> " + config.ForgotCounter })); } return(Ok(new FailViewModel { Message = "Email not found" })); }
public Program() { Console.WriteLine("Core Component Started"); LogicHandler lh = new LogicHandler(new MessageInformer(NewMessageReceived)); while (true) { Thread.Sleep(100); } }
private void OnEnterSceneClick(GameObject imgScene) { //EngineCoreEvents.UIEvent.ShowUIEventWithParam.SafeInvoke(new FrameMgr.OpenUIParams(UIDefine.UI_ENGER_GAME_UI) //{ // Param = this.m_sceneID //}); CommonHelper.OpenEnterGameSceneUI(this.m_sceneID); LogicHandler.CloseFrame(); }
public void LogicHandlerTestInvalid() { var command = new TenantByEntryKey(); var logic = new LogicHandler() { User = StandardUser }; Assert.That(() => logic.Execute(command), Throws.TypeOf <ArgumentException>()); }
//Fyllar listview med användare private void PopulateListViewUsers() { var logic = new LogicHandler(); var users = logic.getInfoOnSelectedUser(); foreach (var user in users) { listBoxUsers.Items.Add("Anst nr: " + user.UID + " " + user.FirstName + " " + user.LastName); } }
private static void StartMatch() { LogicHandler gameLogic = new LogicHandler(); GameMap map = gameLogic.GetMap(); int[,] spielFeld = new Int32[10, 10]; while (firedShots < maxShots && hits < maxHits) { Console.WriteLine("\n\n\n\n"); DrawMap(map); Console.WriteLine("_____ Treffer: " + hits + "/" + maxHits + " __________ Kanonenkugeln: " + (maxShots - firedShots) + " _____"); int x, y; Console.Write("Wir brauchen die Koordinaten Kaept'n!\nX:"); x = Int32.Parse(Console.ReadLine()); Console.Write("Y:"); y = Int32.Parse(Console.ReadLine()); Console.WriteLine("Arrrr! Feuer auf [" + x + " , " + y + "]!"); firedShots++; switch (map[y, x]) { case 0: map[y, x] = -2; Console.WriteLine("Verfehlt!"); break; case 1: hits++; map[y, x] = -1; Console.WriteLine("Treffer!"); break; case -1: Console.WriteLine("Kaept'n, da hatten wir bereits getroffen..."); break; case -2: Console.WriteLine("Kaept'n, da ist immer noch nur Wasser..."); break; } } if (hits == maxHits) { Console.WriteLine("\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Console.WriteLine("~~~~~~~~~~~~~~~~~GEWONNEN! (" + firedShots + " Kugeln benoetigt)~~~~~~~~~~~~~~~~"); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n"); } else { Console.WriteLine("\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~NIEDERLAGE!~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n"); } }
// Use this for initialization void Start() { LH = GetComponent<LogicHandler>(); CC = GetComponent<CharacterController>(); isAtTarget = false; }
void Start() { _logic = GameObject.FindGameObjectWithTag("LogicHandler").GetComponent<LogicHandler>(); _rg = GetComponent<Rigidbody2D>(); }