/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { Settler settler; string newCityName; OnInvoking(); ClientApplication client = ClientApplication.Instance; GameRoot root = client.ServerInstance; if (root.ActiveUnit == null) { throw new InvalidOperationException(ClientResources.GetExceptionString("Unit_Null")); } if (!root.ActiveUnit.CanSettle) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, ClientResources.GetExceptionString("Unit_CannotSettle"), root.ActiveUnit.Name)); } INewCityControl newCityWindow = (INewCityControl)client.GetControl(typeof(INewCityControl)); settler = (Settler)root.ActiveUnit; newCityWindow.ShowSimilizationControl(); newCityName = newCityWindow.CityName; _city = settler.Settle(newCityName); OnInvoked(); }
/// <summary> /// Gets the <see cref="McKnight.Similization.Server.City"/>, and if necessary, /// the <see cref="McKnight.Similization.Server.DiplomaticTie"/> from the user. /// </summary> protected virtual void SelectCity(string cityPickerTitle) { ClientApplication ca = ClientApplication.Instance; IDiplomaticTiePicker picker = (IDiplomaticTiePicker)ca.GetControl(typeof(IDiplomaticTiePicker)); picker.PickerTitle = ClientResources.GetString("espionageTiePickerTitle"); Collection <DiplomaticTie> ties = new Collection <DiplomaticTie>(); foreach (DiplomaticTie t in ca.Player.DiplomaticTies) { //TODO: account for needed improvements if (t.HasEmbassy) { ties.Add(t); } } picker.InitializePicker(ties); picker.ShowSimilizationControl(); this.tie = picker.DiplomaticTie; ICityPicker cityPicker = (ICityPicker)ca.GetControl(typeof(ICityPicker)); cityPicker.PickerTitle = cityPickerTitle; cityPicker.InitializePicker(this.DiplomaticTie.ForeignCountry); cityPicker.ShowSimilizationControl(); this.city = cityPicker.City; }
/// <summary> /// Paints the GridCell onto the screen. /// </summary> public override void Paint() { ClientApplication client = ClientApplication.Instance; Country player = client.Player; if (this.paintOption == GridCellPaintOption.UnexploredCell) { this.Graphics.FillRectangle(Brushes.Black, this.Bounds); return; } foreach (GridCellLayerPainter painter in this.painters) { painter.Graphics = this.Graphics; painter.GridCell = this.gridCell; painter.Bounds = this.Bounds; painter.Paint(); } if (this.PaintOption == GridCellPaintOption.ExploredUninhabited) { Brush brush = new SolidBrush(Color.FromArgb(50, Color.Black)); this.Graphics.FillRectangle(brush, this.Bounds); } }
public void createPolicyHolder(int appID) { var CArepo = new ClientApplicationRepository(); try { ClientApplication client = CArepo.Find(x => x.applicationID == appID).SingleOrDefault(); // find client in the applications table PolicyHolder ph = new PolicyHolder() //initialise the client as policy holder { IDNumber = client.IDNumber, title = client.title, firstName = client.firstName, lastName = client.lastName, province = client.province, contactNumber = client.contactNumber, emailAdress = client.emailAdress, physicalAddress = client.physicalAddress, postalAddress = client.postalAddress, packageID = client.packageID, dateStarted = DateTime.Now, status = "Active" }; using (var polRepo = new PolicyHolderRepository()) { polRepo.Insert(ph); //Save as policy holder var rolb = new RoleBusiness(); rolb.AddUserToRole(ph.IDNumber, "Policy Holder"); } } catch (Exception ex) { feedback = "Request unsuccessfull"; } }
public void ValidationPassedWhenProjectDiffersButNameIsSame() { Store store = new Store(typeof(CoreDesignSurfaceDomainModel), typeof(HostDesignerDomainModel)); using (Transaction t = store.TransactionManager.BeginTransaction()) { ClientApplication clientApp1 = new ClientApplication(store, new PropertyAssignment(ClientApplication.ImplementationProjectDomainPropertyId, "Project1")); ClientApplication clientApp2 = new ClientApplication(store, new PropertyAssignment(ClientApplication.ImplementationProjectDomainPropertyId, "AnotherProject")); HostDesignerModel model = new HostDesignerModel(store); model.ClientApplications.Add(clientApp1); model.ClientApplications.Add(clientApp2); Proxy proxy1 = new Proxy(store, new PropertyAssignment(Proxy.NameDomainPropertyId, "Proxy1")); Proxy proxy2 = new Proxy(store, new PropertyAssignment(Proxy.NameDomainPropertyId, "Proxy1")); clientApp1.Proxies.Add(proxy1); clientApp2.Proxies.Add(proxy2); TestableHostModelContainsUniqueProxyNamesAcrossClientsValidator validator = new TestableHostModelContainsUniqueProxyNamesAcrossClientsValidator(); t.Rollback(); } }
public void ValidationOnlyAppliesToServicesReferencesInDifferentHosts() { Store store = new Store(typeof(CoreDesignSurfaceDomainModel), typeof(HostDesignerDomainModel)); using (Transaction t = store.TransactionManager.BeginTransaction()) { ClientApplication clientApp = new ClientApplication(store, new PropertyAssignment(ClientApplication.ImplementationProjectDomainPropertyId, "Project1")); HostDesignerModel model = new HostDesignerModel(store); model.ClientApplications.Add(clientApp); Proxy proxy1 = new Proxy(store, new PropertyAssignment(Proxy.NameDomainPropertyId, "Proxy1")); Proxy proxy2 = new Proxy(store, new PropertyAssignment(Proxy.NameDomainPropertyId, "Proxy1")); clientApp.Proxies.Add(proxy1); clientApp.Proxies.Add(proxy2); TestableHostModelContainsUniqueProxyNamesAcrossClientsValidator validator = new TestableHostModelContainsUniqueProxyNamesAcrossClientsValidator(); Assert.IsTrue(validator.IsValid(model)); t.Rollback(); } }
internal BaseActionReturnModel AuthorizeApplicationtoClient(ClientApplication ClientApp, ApplicationUser User, SecurityDataContext ctx) { try { // Prevent double assignation if (ctx.UserAuthorizationAssignations.Count(p => p.ClientApplication.id == ClientApp.id && p.User.Id == User.Id) == 0) { UserClientAppAssignation r = new UserClientAppAssignation(); r.User = User; r.Blocked = false; r.App = ClientApp; ctx.UserClientAppAssignations.Add(r); return(BaseActionReturnModel.CreateSuccededResult("OK", false, null, false)); } else { return(BaseActionReturnModel.CreateSuccededResult("Application already assigned to client", false, null, true)); } } catch (Exception exc) { return(BaseActionReturnModel.CreateException(exc, false)); } }
/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { OnInvoking(); ClientApplication ca = ClientApplication.Instance; IDiplomaticTiePicker picker = (IDiplomaticTiePicker)ca.GetControl(typeof(IDiplomaticTiePicker)); Collection <DiplomaticTie> ties = new Collection <DiplomaticTie>(); foreach (DiplomaticTie t in ca.Player.DiplomaticTies) { //TODO: account for needed improvements if (t.HasEmbassy) { ties.Add(t); } } picker.InitializePicker(ties); picker.ShowSimilizationControl(); this.DiplomaticTie = picker.DiplomaticTie; this.City = this.DiplomaticTie.ForeignCountry.CapitalCity; string text = string.Empty; EspionageResult result = this.DiplomaticTie.StealWorldMap(); switch (result) { case EspionageResult.ImmuneToEspionage: text = ClientResources.GetString("stealworldmap_immune"); text = string.Format( CultureInfo.CurrentCulture, text, this.DiplomaticTie.ForeignCountry.Civilization.Adjective); break; case EspionageResult.Success: text = ClientResources.GetString("stealworldmap_success"); text = string.Format( CultureInfo.CurrentCulture, text, this.DiplomaticTie.ForeignCountry.Civilization.Noun); break; case EspionageResult.Failure: text = ClientResources.GetString("stealworldmap_failure"); text = string.Format( CultureInfo.CurrentCulture, text, this.City.Name); break; case EspionageResult.SpyCaught: text = ClientResources.GetString("stealworldmap_spycaught"); text = string.Format( CultureInfo.CurrentCulture, text, this.City.Name, this.DiplomaticTie.ForeignCountry.Government.LeaderTitle, this.DiplomaticTie.ForeignCountry.LeaderName); break; } OnInvoked(); }
internal IClientApplication CreateClientApplication(string name) { Guard.NotNullOrEmpty(() => name, name); // Get the app IEnumerable <IClientApplication> apps = Storage.Find(Storage.BuildQuery( Reflector <ClientApplication> .GetPropertyName(x => x.Name), QueryOperator.EQ, name)); if (apps.Any()) { throw LogicErrorThrower.ResourceConflict( Resources.ClientApplicationsManager_ApplicationByNameExists, name); } // Construct a new identifier and a secret var app = new ClientApplication { Name = name, ClientIdentifier = Guid.NewGuid().ToString("D"), ClientSecret = Guid.NewGuid().ToString("D"), }; return(RegisterClientApplication(app)); }
/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { OnInvoking(); ClientApplication client = ClientApplication.Instance; Unit unit = client.ServerInstance.ActiveUnit; GridCell unitCell = client.ServerInstance.Grid.GetCell(unit.Coordinates); if (unit == null) { throw new InvalidOperationException(ClientResources.GetString("Unit_Null")); } if (unitCell.City == null) { throw new InvalidOperationException(ClientResources.GetString("Unit_MergeNoCity")); } if (!unit.CanMergeWithCity) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, ClientResources.GetString("Unit_CannotMerge"), unit.Name)); } unit.MergeWithCity(); OnInvoked(); }
/// <summary> /// Unsets the app instance if the given instance is the same /// (called from app dispose function) /// </summary> /// <param name="app"></param> public static void UnsetIfEqualsGiven(ClientApplication app) { if (ReferenceEquals(app, clientApp)) { clientApp = null; } }
/// <summary> /// Fires the <i>CenterCellChanged</i> event. /// </summary> /// <remarks>This method is overriden to ensure that the <c>MiniMap</c> is /// redrawn with new and accurate graphics reflecting the visible area of the map.</remarks> protected override void OnCenterCellChanged() { ClientApplication client = ClientApplication.Instance; client.MiniMap.VisibleBounds = this.visibleBounds; base.OnCenterCellChanged(); }
private static void DrawCell(GridCell cell, Graphics g) { Rectangle rect; Color color; ClientApplication client = ClientApplication.Instance; if (cell.HasBeenExploredBy(client.Player)) { if (cell.City == null) { if (cell.Owner == null) { color = cell.IsDry ? Color.Green : Color.Blue; } else { color = cell.Owner.Color; } } else { color = Color.White; } } else { color = Color.Black; } rect = new Rectangle(new Point(cell.Coordinates.X * CellSize, cell.Coordinates.Y * CellSize), new Size(CellSize, CellSize)); g.FillRectangle(new SolidBrush(color), rect); }
public void createDocuments(int appID) { var CADocRepo = new ClientApplicationDocumentRepository(); var docList = (from x in CADocRepo.GetAll() where x.applicationID == appID select x).ToList(); var CArepo = new ClientApplicationRepository(); ClientApplication client = CArepo.Find(x => x.applicationID == appID).SingleOrDefault(); // find client in the applications table var polRepo = new PolicyHolderRepository(); foreach (var doc in docList) { using (var polDocRepo = new PolicyDocumentRepository()) { PolicyDocument pd = new PolicyDocument() { policyNo = polRepo.Find(x => x.IDNumber == client.IDNumber).SingleOrDefault().policyNo, IDNumber = doc.IDNumber, fullname = doc.fullname, documentName = doc.documentName, document = doc.document }; polDocRepo.Insert(pd); } } }
private static string GetAdvisorText() { string text = string.Empty; ClientApplication client = ClientApplication.Instance; Country player = client.Player; if (player.Government.Fallback) { text = ClientResources.GetString("domesticAdvisor_anarchy"); } else { if (RandomNumber.GetRandomNumber(10) > 5) { //tell them we need more cities. text = ClientResources.GetString("domesticAdvisor_needCities"); } else { //say something about a city. int count = player.Cities.Count; int idx = RandomNumber.GetRandomNumber(count - 1); City city = client.Player.Cities[idx]; string format = ClientResources.GetString("domesticAdvisor_cityHappiness"); text = string.Format(CultureInfo.CurrentCulture, format, player.Government.LeaderTitle, city.Name, ""); } } return(text); }
public async Task BadClientId() { var someClientEntity = new ClientApplication { Name = "Postman", }; this.dbContext.ClientApplications.Add(someClientEntity); await this.dbContext.SaveChangesAsync().ConfigureAwait(true); var user = await this.identityInstance.CreateUserAsync(UserName).ConfigureAwait(true); var(_, tokenStr) = await this.CreateRefreshTokenForUser(user.Id, appId : someClientEntity.Id) .ConfigureAwait(true); var authenticationResult = await this.authenticationFlow.TryAuthenticateUsingRefreshTokenAsync( tokenStr, false, this.identityInstance.ClientId, string.Empty, CancellationToken.None) .ConfigureAwait(true); authenticationResult.Should().BeNull(because: "the client id was not equivalent to the id saved with the token"); }
/// <summary> /// Validate that all configuration properties are set. /// </summary> public void Validate(string parentProperty) { // If any of ApplicationRegistration properties is provided, // then we will require that all are provided. if (null == ServiceApplication) { throw new Exception($"{parentProperty}.ServiceApplication" + " configuration property is missing."); } ServiceApplication.Validate($"{parentProperty}.ServiceApplication"); if (null == ServiceApplicationSP) { throw new Exception($"{parentProperty}.ServiceApplicationSP" + " configuration property is missing."); } ServiceApplicationSP.Validate($"{parentProperty}.ServiceApplicationSP"); if (null == ClientApplication) { throw new Exception($"{parentProperty}.ClientApplication" + " configuration property is missing."); } ClientApplication.Validate($"{parentProperty}.ClientApplication"); if (null == ClientApplicationSP) { throw new Exception($"{parentProperty}.ClientApplicationSP" + " configuration property is missing."); } ClientApplicationSP.Validate($"{parentProperty}.ClientApplicationSP"); if (null == AksApplication) { throw new Exception($"{parentProperty}.AksApplication" + " configuration property is missing."); } AksApplication.Validate($"{parentProperty}.AksApplication"); if (null == AksApplicationSP) { throw new Exception($"{parentProperty}.AksApplicationSP" + " configuration property is missing."); } AksApplicationSP.Validate($"{parentProperty}.AksApplicationSP"); if (string.IsNullOrEmpty(AksApplicationRbacSecret)) { throw new Exception($"{parentProperty}.AksApplicationRbacSecret" + " configuration property is missing or is empty."); } }
private void RefreshGovernment() { string format = ClientResources.GetString("rejectGovernmentChange"); ClientApplication client = ClientApplication.Instance; Government gov = client.Player.Government; btnNo.Text = string.Format(CultureInfo.CurrentCulture, format, gov.Name); }
/** * Check authz before performing action. * * @param action desired action * @throws NotAuthorizedException thrown if user does not have role. */ public void checkAuthorization(Action action, IncomingWebRequestContext context) // throws NotAuthorizedException { string clientApplicationName = (string)context.GetType().GetProperty(RequestHandler.APPSENSOR_CLIENT_APPLICATION_IDENTIFIER_ATTR).ToString(); ClientApplication clientApplication = appSensorServer.getConfiguration().findClientApplication(clientApplicationName); appSensorServer.getAccessController().assertAuthorized(clientApplication, action, new Context()); }
public UpdateSolutionClientApplicationRequest(string id, ClientApplication clientApplication) { SolutionId = id; ClientApplication = JsonConvert.SerializeObject(clientApplication, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, }); }
/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { OnInvoking(); ClientApplication client = ClientApplication.Instance; client.GameWindow.BeginBombardProcess(); OnInvoked(); }
public Factory() { var factory = new UIFactory(); var clientApplication = new ClientApplication(factory); clientApplication.DrawUI(); clientApplication.ClickUI(); }
// Databinds the players' researchable technologies to the // technology combobox. private void FillTechCombo() { ClientApplication client = ClientApplication.Instance; Country c = client.Player; _technologyCombo.DataSource = c.ResearchableTechnologies; }
public void updateAppStatus(int appID, string stat) { using (var CArepo = new ClientApplicationRepository()) { ClientApplication x = CArepo.GetById(appID); x.status = stat; CArepo.Update(x); } }
private void cboGovernment_SelectedIndexChanged(object sender, System.EventArgs e) { ClientApplication client = ClientApplication.Instance; if (cboGovernment.SelectedItem != client.Player.Government) { //they have chosen a different government... } }
/// <exception cref="XMLException"></exception> private Collection <ClientApplication> readClientApplications(XmlReader xmlReader) { Collection <ClientApplication> clientApplications = new Collection <ClientApplication>(); bool finished = false; ClientApplication clientApplication = null; while (!finished && xmlReader.Read()) { //int Event = xmlReader.next(); string name = XmlUtils.getElementQualifiedName(xmlReader, namespaces); switch (xmlReader.NodeType) { case XmlNodeType.Element: if ("config:client-application".Equals(name)) { clientApplication = new ClientApplication(); } else if ("config:name".Equals(name)) { clientApplication.setName(xmlReader.ReadString().Trim()); } else if ("config:role".Equals(name)) { // clientApplication.getRoles().add(Role.valueOf(xmlReader.getElementText().trim())); clientApplication.getRoles().Add((Role)Enum.Parse(typeof(Role), xmlReader.ReadString().Trim())); } else { /** unexpected start element **/ } break; case XmlNodeType.EndElement: if ("config:client-application".Equals(name)) { clientApplications.Add(clientApplication); } else if ("config:client-applications".Equals(name)) { finished = true; } else { /** unexpected end element **/ } break; default: /** unused xml element - nothing to do **/ break; } } return(clientApplications); }
/// <summary> /// Invokes the command. /// </summary> public override void Invoke() { OnInvoking(); ClientApplication client = ClientApplication.Instance; this.optionsControl = client.GetControl(typeof(IOptionsControl)) as IOptionsControl; this.optionsControl.Closed += new EventHandler <ControlClosedEventArgs>(OptionsControlClosed); this.optionsControl.ShowSimilizationControl(); }
/// <summary> /// Shows the Similization Control. /// </summary> public void ShowSimilizationControl() { ClientApplication client = ClientApplication.Instance; cboTechnology.DataSource = client.Player.ResearchableTechnologies; cboTechnology.DisplayMember = "Name"; cboTechnology.DataBindings.Add("SelectedItem", this, "ChosenTechnology"); ShowDialog(); }
private void OnDisable() { OnRefresh -= PerformRefresh; ClientApplication .GetInstance() .Resolve <EmulatedFacetCaller>() .OnFacetCalled -= PerformRefresh; }
protected override void Initialize() { _mainMenu = new MainMenu(); _server = new ServerApplication(_graphics.GraphicsDevice, Content); _client = new ClientApplication(_graphics.GraphicsDevice, Content); base.Initialize(); }
/** * {@inheritDoc} */ //public override void assertAuthorized(clientApplication clientApplication, Action action, Context context) { public void assertAuthorized(ClientApplication clientApplication, Action action, Context context) { //throws NotAuthorizedException { /// <exception cref="NotAuthorizedException"></exception> if (! isAuthorized(clientApplication, action, context)) { throw new NotAuthorizedException("Access is not allowed for client application: " + clientApplication + //throw new AuthenticationException("Access is not allowed for client application: " + clientApplication + " when trying to perform action : " + action + " using context: " + context); } }
/** * {@inheritDoc} */ //public override bool isAuthorized(clientApplication clientApplication, Action Action, Context Context) { public bool isAuthorized(ClientApplication clientApplication, Action Action, Context Context) { bool authorized = false; //if (clientApplication != null && Action != null && Action.ToString() != null && Action.ToString().Trim().Length() > 0) { if (clientApplication != null && Action != null && Action.ToString() != null && Action.ToString().Trim().Length > 0) { foreach (Role role in clientApplication.getRoles()) { //simple check to make sure that //the value of the action matches the value of one of the roles (exact match) if (role != null && role.ToString() != null && role.ToString().Equals(Action.ToString())) { authorized = true; break; } } } return authorized; }