private ICollection <FeatureAction> CloneFeatureActions(Hatfield.EnviroData.Core.Action previousVersionAction, Hatfield.EnviroData.Core.Action newVersionAction) { if (previousVersionAction.FeatureActions == null) { return(null); } else { var newVersionFeatureActions = new List <FeatureAction>(); foreach (var featureAction in previousVersionAction.FeatureActions) { var newFeatureAction = new FeatureAction(); newFeatureAction.Action = newVersionAction; newFeatureAction.SamplingFeatureID = featureAction.SamplingFeatureID; newFeatureAction.SamplingFeature = featureAction.SamplingFeature; newFeatureAction.Results = CloneResults(featureAction, newFeatureAction); newVersionFeatureActions.Add(newFeatureAction); } return(newVersionFeatureActions); } }
public string WebFeatureAction(FeatureDefinition feature, Location location, FeatureAction action, bool elevatedPrivileges, bool force, out ActivatedFeature resultingFeature) { switch (action) { case FeatureAction.Activate: return(SpFeatureAction.WebFeatureAction( feature, location, SpFeatureHelper.ActivateFeatureInFeatureCollection, elevatedPrivileges, force, out resultingFeature)); case FeatureAction.Deactivate: return(SpFeatureAction.WebFeatureAction( feature, location, SpFeatureHelper.DeactivateFeatureInFeatureCollectionReturnsNull, elevatedPrivileges, force, out resultingFeature)); case FeatureAction.Upgrade: return(SpFeatureAction.WebFeatureAction( feature, location, SpFeatureHelper.UpgradeFeatureInFeatureCollection, elevatedPrivileges, force, out resultingFeature)); default: throw new NotImplementedException("This kind of action is not supported!"); } }
public static void Link(FeatureAction featureAction, SamplingFeature samplingFeature) { featureAction.SamplingFeature = samplingFeature; featureAction.SamplingFeatureID = samplingFeature.SamplingFeatureID; samplingFeature.FeatureActions.Add(featureAction); }
public static void Link(Core.Action action, FeatureAction featureAction) { action.FeatureActions.Add(featureAction); featureAction.Action = action; featureAction.ActionID = action.ActionID; }
/// <summary> /// Updates the features which are relevant in the current state of the game. /// </summary> /// <param name="lastActions">Last actions of the current phase</param> /// <param name="phase">Phase of the game</param> /// <param name="aggression">Aggression of the player</param> /// <param name="positioning">Positioning of the player</param> public void UpdateFeaturesAfterAction(List <FeatureAction> lastActions, GamePhase phase, Aggression aggression, Positioning positioning) { //reverse action list to make it easier comparable var reversedActions = new List <FeatureAction>(lastActions.ToArray()); reversedActions.Reverse(); FeatureAction lastAction = reversedActions[0]; reversedActions = reversedActions.Skip(1).ToList(); var featuresToUpdate = Features.Where(x => x.AlreadyIncremented == false && x.Phase == phase && (x.PreCondition == null || ((x.PreCondition.Aggression == Aggression.None || x.PreCondition.Aggression == aggression) && (x.PreCondition.Positioning == Positioning.None || x.PreCondition.Positioning == positioning) && (x.PreCondition.LastActions.Count == 0 || reversedActions.Take(x.PreCondition.LastActions.Count).SequenceEqual <FeatureAction>(x.PreCondition.LastActions))))); foreach (var feature in featuresToUpdate) { if (feature.ActionsToMeasure.Contains(lastAction)) { feature.Count++; feature.AlreadyIncremented = true; } if (!feature.IsGlobal) { feature.CountTotal++; } } }
private void game_PlayerActed(Guid playerId, ActionType action, int amountToCall, int amount) { var actionBucket = ActionAbstracter.MapToBucket(action, amountToCall, currentGame.PotSize, amount); actionHistory.Add(actionBucket); FeatureAction featureAction = FeatureActionAbstracter.FromActionBucket(actionBucket); var currentPhasehistory = actionHistoriesPerPhase.FirstOrDefault(x => x.Phase == currentGame.Phase); currentPhasehistory.ActionHistory.Add(featureAction); if (this.Id != playerId) { Positioning opponentPositioning = Positioning.None; Aggression opponentAggression = Aggression.None; if (currentGame.Phase > GamePhase.PreFlop) { opponentPositioning = getOpponentPositioning(currentPhasehistory.ActionHistory.Count); opponentAggression = getOpponentAggression(opponentPositioning); } opponent.UpdateFeaturesAfterAction(currentPhasehistory.ActionHistory, currentGame.Phase, opponentAggression, opponentPositioning); } }
public void Setup() { var measurementResultValue = new MeasurementResultValue(); measurementResultValue.DataValue = MeasurementValue; var measurementResult = new MeasurementResult(); measurementResult.MeasurementResultValues.Add(measurementResultValue); var result = new Result(); result.ResultDateTime = DateTime.Today; result.MeasurementResult = measurementResult; var samplingFeature = new SamplingFeature(); samplingFeature.SamplingFeatureTypeCV = "Specimen"; var featureAction = new FeatureAction(); featureAction.SamplingFeature = samplingFeature; featureAction.Results.Add(result); var action = new Core.Action(); action.ActionID = ActionId; action.FeatureActions.Add(featureAction); var actions = new List<Core.Action>(); actions.Add(action); supportedData = actions; var mockVersionHelper = new Mock<IDataVersioningHelper>(); mockVersionHelper.Setup(x => x.GetLatestVersionActionData(It.IsAny<Hatfield.EnviroData.Core.Action>())).Returns(action); mockVersionHelper.Setup(x => x.CloneActionData(It.IsAny<Hatfield.EnviroData.Core.Action>())).Returns(cloneAction(action)); var mockRepository = new Mock<IRepository<CV_RelationshipType>>(); testTool = new ChemistryValueCheckingTool(mockVersionHelper.Object, mockRepository.Object); mockChemistryValueCheckingRule = new Mock<ChemistryValueCheckingRule>(); }
public static void Link(FeatureAction featureAction, Result result) { featureAction.Results.Add(result); result.FeatureAction = featureAction; result.FeatureActionID = featureAction.FeatureActionID; }
private void InitialiseMembers() { Feature = new EmptyFdpFeature(); IdentifierPrefix = "Page"; Programmes = Enumerable.Empty <Programme>(); Gateways = Enumerable.Empty <Gateway>(); CarLines = Enumerable.Empty <CarLine>(); ModelYears = Enumerable.Empty <ModelYear>(); CurrentAction = FeatureAction.NotSet; }
public virtual void InsertPermissionRecord(string moduleName, string featureName, string featureActionName) { int displayOrder = 0; var module = _moduleRepository.GetAll().FirstOrDefault(m => m.Name == moduleName); if (module == null) { displayOrder = _moduleRepository.GetAll().Max(m => m.DisplayOrder); module = new Module { Name = moduleName, Description = moduleName + " Module", DisplayOrder = displayOrder + 1 }; _moduleRepository.InsertAndCommit(module); } var feature = _featureRepository.GetAll().FirstOrDefault(f => f.Name == featureName); if (feature == null) { displayOrder = _featureRepository.GetAll().Where(f => f.ModuleId == module.Id).Max(m => m.DisplayOrder); feature = new Feature { Name = moduleName, Description = featureName + " Feature", DisplayOrder = displayOrder + 1 }; _featureRepository.InsertAndCommit(feature); } var featureAction = _featureActionRepository.GetAll().FirstOrDefault(f => f.Name == featureActionName); if (module == null) { displayOrder = _featureActionRepository.GetAll().Where(f => f.FeatureId == feature.Id).Max(m => m.DisplayOrder); featureAction = new FeatureAction { Name = featureActionName, Description = featureActionName, DisplayOrder = displayOrder + 1 }; _featureActionRepository.InsertAndCommit(featureAction); } var permissionRecord = _permissionRecordRepository.GetAll() .FirstOrDefault(p => p.ModuleId == module.Id && p.FeatureId == feature.Id && p.FeatureActionId == featureAction.Id); if (permissionRecord == null) { permissionRecord = new PermissionRecord { ModuleId = module.Id, FeatureId = feature.Id, FeatureActionId = featureAction.Id, Name = string.Format("{0}.{1}.{2}", module.Name.Replace(" ", ""), feature.Name.Replace(" ", ""), featureAction.Name.Replace(" ", "")) }; _permissionRecordRepository.InsertAndCommit(permissionRecord); } }
public string WebFeatureAction(FeatureDefinition feature, Location location, FeatureAction action, bool elevatedPrivileges, bool force, out ActivatedFeature activatedFeature) { switch (action) { case FeatureAction.Activate: return(ActivateFeature(feature, location, elevatedPrivileges, force, out activatedFeature)); case FeatureAction.Deactivate: throw new NotImplementedException("This kind of action is not supported!"); case FeatureAction.Upgrade: return(UpgradeFeature(feature, location, elevatedPrivileges, force, out activatedFeature)); default: throw new NotImplementedException("This kind of action is not supported!"); } }
/// <summary> /// request to activate or deactivate a feature in a location or below /// </summary> /// <param name="featureDefinition">the feature definition</param> /// <param name="location">the location or top location</param> /// <param name="action">Activate, Deactivate or Upgrade</param> /// <remarks>force and elevated privileges are system wide settings</remarks> public FeatureToggleRequest([NotNull] FeatureDefinition featureDefinition, [NotNull] Location location, FeatureAction action, bool?force = null, bool?elevatedPrivileges = null) { FeatureDefinition = featureDefinition; Location = location; Action = action; Force = force; ElevatedPrivileges = elevatedPrivileges; TaskId = Guid.NewGuid(); string locationPrefix = FeatureDefinition.Scope < location.Scope ? "across" : "at"; Title = string.Format("Feature {3} of feature '{0}' {4} {1} '{2}'", featureDefinition.DisplayName, location.Scope.ToString(), location.DisplayName, Action.ToString().ToLower(), locationPrefix); }
private ICollection <Result> CloneResults(FeatureAction previousVersionFeatureAction, FeatureAction newVersionFeatureAction) { if (previousVersionFeatureAction.Results == null) { return(null); } else { var newVersionResults = new List <Result>(); foreach (var previousVersionResult in previousVersionFeatureAction.Results) { var newResult = new Result(); newResult.FeatureAction = newVersionFeatureAction; newResult.ResultTypeCV = previousVersionResult.ResultTypeCV; newResult.CV_ResultType = previousVersionResult.CV_ResultType; newResult.VariableID = previousVersionResult.VariableID; newResult.Variable = previousVersionResult.Variable; newResult.UnitsID = previousVersionResult.UnitsID; newResult.Unit = previousVersionResult.Unit; newResult.TaxonomicClassifierID = previousVersionResult.TaxonomicClassifierID; newResult.TaxonomicClassifier = previousVersionResult.TaxonomicClassifier; newResult.ProcessingLevelID = previousVersionResult.ProcessingLevelID; newResult.ProcessingLevel = previousVersionResult.ProcessingLevel; newResult.ResultDateTime = previousVersionResult.ResultDateTime; newResult.ResultDateTimeUTCOffset = previousVersionResult.ResultDateTimeUTCOffset; newResult.ValidDateTime = previousVersionResult.ValidDateTime; newResult.StatusCV = previousVersionResult.StatusCV; newResult.CV_Status = previousVersionResult.CV_Status; newResult.SampledMediumCV = previousVersionResult.SampledMediumCV; newResult.CV_SampledMedium = previousVersionResult.CV_SampledMedium; newResult.ValueCount = previousVersionResult.ValueCount; //clone measurement result newResult.MeasurementResult = CloneMeasurementResult(previousVersionResult.MeasurementResult, newResult); newResult.ResultExtensionPropertyValues = CloneResultExtensionPropertyValues(newResult, previousVersionResult.ResultExtensionPropertyValues); newVersionResults.Add(newResult); } return(newVersionResults); } }
private ICollection<Result> CloneResults(FeatureAction previousVersionFeatureAction, FeatureAction newVersionFeatureAction) { if (previousVersionFeatureAction.Results == null) { return null; } else { var newVersionResults = new List<Result>(); foreach(var previousVersionResult in previousVersionFeatureAction.Results) { var newResult = new Result(); newResult.FeatureAction = newVersionFeatureAction; newResult.ResultTypeCV = previousVersionResult.ResultTypeCV; newResult.CV_ResultType = previousVersionResult.CV_ResultType; newResult.VariableID = previousVersionResult.VariableID; newResult.Variable = previousVersionResult.Variable; newResult.UnitsID = previousVersionResult.UnitsID; newResult.Unit = previousVersionResult.Unit; newResult.TaxonomicClassifierID = previousVersionResult.TaxonomicClassifierID; newResult.TaxonomicClassifier = previousVersionResult.TaxonomicClassifier; newResult.ProcessingLevelID = previousVersionResult.ProcessingLevelID; newResult.ProcessingLevel = previousVersionResult.ProcessingLevel; newResult.ResultDateTime = previousVersionResult.ResultDateTime; newResult.ResultDateTimeUTCOffset = previousVersionResult.ResultDateTimeUTCOffset; newResult.ValidDateTime = previousVersionResult.ValidDateTime; newResult.StatusCV = previousVersionResult.StatusCV; newResult.CV_Status = previousVersionResult.CV_Status; newResult.SampledMediumCV = previousVersionResult.SampledMediumCV; newResult.CV_SampledMedium = previousVersionResult.CV_SampledMedium; newResult.ValueCount = previousVersionResult.ValueCount; //clone measurement result newResult.MeasurementResult = CloneMeasurementResult(previousVersionResult.MeasurementResult, newResult); newResult.ResultExtensionPropertyValues = CloneResultExtensionPropertyValues(newResult, previousVersionResult.ResultExtensionPropertyValues); newVersionResults.Add(newResult); } return newVersionResults; } }
private string GetContentPartialViewName(FeatureAction forAction) { return(string.Format("_{0}", Enum.GetName(forAction.GetType(), forAction))); }
public FeatureParameters() { Action = FeatureAction.NotSet; }
private void InitialiseMembers() { Feature = new EmptyFdpFeature(); IdentifierPrefix = "Page"; Programmes = Enumerable.Empty<Programme>(); Gateways = Enumerable.Empty<Gateway>(); CarLines = Enumerable.Empty<CarLine>(); ModelYears = Enumerable.Empty<ModelYear>(); CurrentAction = FeatureAction.NotSet; }
public FeatureFilter() { Action = FeatureAction.NotSet; }
private void btnList_Click(object sender, EventArgs e) { SelectedAction = FeatureAction.ListJSON; this.Close(); }
private void btnAnalyze_Click(object sender, EventArgs e) { SelectedAction = FeatureAction.AnalyzeJSON; this.Close(); }
private void btnCalc_Click(object sender, EventArgs e) { SelectedAction = FeatureAction.Calculate; this.Close(); }
private Core.Action cloneAction(Core.Action action) { var measurementResultValueClone = new MeasurementResultValue(); measurementResultValueClone.DataValue = action.FeatureActions.FirstOrDefault().Results.FirstOrDefault() .MeasurementResult.MeasurementResultValues.FirstOrDefault().DataValue; var measurementResultClone = new MeasurementResult(); measurementResultClone.MeasurementResultValues.Add(measurementResultValueClone); var resultClone = new Result(); resultClone.ResultDateTime = action.FeatureActions.FirstOrDefault().Results.FirstOrDefault().ResultDateTime; resultClone.MeasurementResult = measurementResultClone; var samplingFeatureClone = new SamplingFeature(); samplingFeatureClone.SamplingFeatureTypeCV = action.FeatureActions.FirstOrDefault().SamplingFeature.SamplingFeatureTypeCV; var featureActionClone = new FeatureAction(); featureActionClone.SamplingFeature = samplingFeatureClone; featureActionClone.Results.Add(resultClone); var actionClone = new Core.Action(); actionClone.FeatureActions.Add(featureActionClone); return actionClone; }
private ICollection<FeatureAction> CloneFeatureActions(Hatfield.EnviroData.Core.Action previousVersionAction, Hatfield.EnviroData.Core.Action newVersionAction) { if (previousVersionAction.FeatureActions == null) { return null; } else { var newVersionFeatureActions = new List<FeatureAction>(); foreach(var featureAction in previousVersionAction.FeatureActions) { var newFeatureAction = new FeatureAction(); newFeatureAction.Action = newVersionAction; newFeatureAction.SamplingFeatureID = featureAction.SamplingFeatureID; newFeatureAction.SamplingFeature = featureAction.SamplingFeature; newFeatureAction.Results = CloneResults(featureAction, newFeatureAction); newVersionFeatureActions.Add(newFeatureAction); } return newVersionFeatureActions; } }