Exemplo n.º 1
0
 public void Initialize()
 {
     featureContext = new FeatureContext(null);
     scenarioContext = new ScenarioContext(featureContext, null);
     stepContext = new StepContext(featureContext, scenarioContext);
     sut = new ContextHandler(featureContext, scenarioContext, stepContext);
 }
Exemplo n.º 2
0
        public void Execute(RequestContext requestContext)
        {
            var urlType = requestContext.UrlStrongTypeFromRoute();
              using (log4net.NDC.Push(urlType.FullName))
              {
            var steps = StepsFor(requestContext, urlType);
            var stepContext = new StepContext(requestContext, urlType);

            if (!steps.Any())
            {
              HandleNoSteps(stepContext);
              return;
            }

            var lastContinuation = Continuation.Continue;
            foreach (var step in steps)
            {
              _log.Info("Step: " + step);
              lastContinuation = _stepInvoker.Invoke(step, stepContext);
              if (lastContinuation != Continuation.Continue)
              {
            break;
              }
            }

            if (lastContinuation == Continuation.Continue)
            {
              HandleNoEndingStep(stepContext);
              return;
            }

            _log.Info("Completed");
              }
        }
Exemplo n.º 3
0
 public static StepContext Increment(StepContext ctx, int numberOfItemsReceived, int numberOfItemsProcessed, bool skipped)
 {
     long nextIndex = ctx.StepIndex + ctx.ChunkSize;
     return new StepContext(ctx.StepName, nextIndex, numberOfItemsProcessed, false, ctx.ChunkSize)
            {
                NumberOfItemsReceived = numberOfItemsReceived,
                Skip = skipped,
            };
 }
Exemplo n.º 4
0
        public Continuation Invoke(IStep step, StepContext stepContext)
        {
            if (step == null) throw new ArgumentNullException("step");
              if (stepContext == null) throw new ArgumentNullException("stepContext");

              var handler = _locator.GetStepHandler(step.GetType());

              if (handler == null) throw new ArgumentException("No handler for Step: " + step.GetType(), "step");

              return handler.Handle(step, stepContext);
        }
Exemplo n.º 5
0
        public void RenderViewData(StepContext stepContext, ViewDataDictionary viewData, string viewName, bool skipLayout)
        {
            var view = _factory.FindView(stepContext.RequestContext, stepContext.UrlStrongPath, viewName, String.Empty, !skipLayout, true);
              if (view.View == null)
              {
            var locations = new StringBuilder();
            foreach (var location in view.SearchedLocations)
            {
              locations.AppendLine();
              locations.Append(location);
            }
            throw new InvalidOperationException("No view could be found in: " + locations);
              }

              stepContext.Fill(viewData);

              var controllerContext = new ControllerContext(stepContext.RequestContext, FakeController);
              var viewContext = new ViewContext(controllerContext, view.View, viewData, new TempDataDictionary(), stepContext.Response.Output);
              view.View.Render(viewContext, stepContext.Response.Output);
        }
Exemplo n.º 6
0
 static void HandleNoEndingStep(StepContext context)
 {
     _log.Info("No Ending Step");
       context.Response.StatusCode = (Int32)HttpStatusCode.NoContent;
       context.Response.StatusDescription = "No Content";
 }
        public StepChallengeMutation(StepContext db, StepsService stepsService)
        {
            Name = "Mutation";

            Field <StepsType>(
                "creatStepsEntry",
                arguments:  new QueryArguments(
                    new QueryArgument <NonNullGraphType <StepInputType> > {
                Name = "steps"
            }),
                resolve: context =>
            {
                var steps    = context.GetArgument <StepsInputs>("steps");
                var stepsDay = new DateTime(steps.DateOfSteps.Year, steps.DateOfSteps.Month, steps.DateOfSteps.Day, 0, 0, 0);

                var existingStepCount = db.Steps
                                        .Where(s => s.ParticipantId == steps.ParticipantId)
                                        .FirstOrDefault(s => s.DateOfSteps == stepsDay);

                if (existingStepCount != null)
                {
                    return(stepsService.Update(existingStepCount, steps));
                }

                return(stepsService.Create(steps));
            });

            Field <ChallengeSettingsType>(
                "updateChallengeSettings",
                arguments:  new QueryArguments(
                    new QueryArgument <NonNullGraphType <ChallengeSettingsInputType> > {
                Name = "settings"
            }),
                resolve: context =>
            {
                var newSettings = context.GetArgument <ChallengeSettingsInput>("settings");

                var existingSettings = db.ChallengeSettings
                                       .FirstOrDefault();

                if (existingSettings != null)
                {
                    existingSettings.ShowLeaderBoard           = newSettings.ShowLeaderBoard;
                    existingSettings.ShowLeaderBoardStepCounts = newSettings.ShowLeaderBoardStepCounts;
                }

                db.SaveChanges();

                return(existingSettings);
            });

            Field <TeamType>(
                "updateTeam",
                arguments:  new QueryArguments(
                    new QueryArgument <NonNullGraphType <TeamInputType> > {
                Name = "team"
            }),
                resolve: context =>
            {
                var newTeamInfo = context.GetArgument <TeamInput>("team");

                var team = db.Team
                           .FirstOrDefault(t => t.TeamId == newTeamInfo.TeamId);

                if (team != null)
                {
                    team.TeamName             = newTeamInfo.TeamName;
                    team.NumberOfParticipants = newTeamInfo.NumberOfParticipants;
                }

                db.SaveChanges();
                return(team);
            });
        }
Exemplo n.º 8
0
 public UpsheetSteps(UpsheetContext context,StepContext stepContext,IWebDriverFactory f,IConfiguration config)
     : base(f,config)
 {
     _context = context;
     _stepContext = stepContext;
 }
 List<string> GetActionList(StepContext context)
 {
     return context.Load<List<string>>()
            ?? context.Save(new List<string>());
 }
Exemplo n.º 10
0
 public void SaveStepContext(StepContext stepContext)
 {
     _dbIndexes.Add(stepContext.StepIndex);
 }
Exemplo n.º 11
0
		private static void CopyMembers(bool copyMembers, AU.AUAdminScope item, AU.AUAdminScope targetScope, StepContext context)
		{
			if (copyMembers)
			{
				context.Logger.WriteLine(ProcessProgress.Current.StatusText = "正在复制管理范围固定成员");
				ProcessProgress.Current.Response();
				var memberIDs = AU.AUCommon.DoDbProcess(() => PC.Adapters.SCMemberRelationAdapter.Instance.LoadByContainerID(item.ID, item.ScopeSchemaType)).ToIDArray();
				var actualMembers = AU.Adapters.AUSnapshotAdapter.Instance.LoadScopeItems(memberIDs, item.ScopeSchemaType, true, DateTime.MinValue);
				context.ResetInnerSteps(actualMembers.Count);

				foreach (AU.AUAdminScopeItem scopeItem in actualMembers)
				{
					context.Logger.WriteLine("正在添加" + scopeItem.AUScopeItemName);
					AU.Operations.Facade.InstanceWithPermissions.AddObjectToScope(scopeItem, targetScope);
					context.InnerStep++;
					context.Response();
				}
			}
		}
Exemplo n.º 12
0
 public void RenderModel(StepContext stepContext, object model, string viewName, bool skipLayout)
 {
     var viewData = new ViewDataDictionary();
       viewData.Model = model;
       RenderViewData(stepContext, viewData, viewName, skipLayout);
 }
Exemplo n.º 13
0
        public StepInstanceTemplate(ScenarioStep scenarioStep, ScenarioOutline scenarioOutline, Feature feature, StepContext stepContext, INativeSuggestionItemFactory <TNativeSuggestionItem> nativeSuggestionItemFactory)
        {
            StepDefinitionType = (StepDefinitionType)scenarioStep.ScenarioBlock;
            Language           = stepContext.Language;

            NativeSuggestionItem = nativeSuggestionItemFactory.Create(scenarioStep.Text, StepInstance <TNativeSuggestionItem> .GetInsertionText(scenarioStep), 1, StepDefinitionType.ToString().Substring(0, 1) + "-t", this);
            instances            = new StepSuggestionList <TNativeSuggestionItem>(nativeSuggestionItemFactory);
            AddInstances(scenarioStep, scenarioOutline, feature, stepContext, nativeSuggestionItemFactory);

            var match = paramRe.Match(scenarioStep.Text);

            StepPrefix = match.Success ? scenarioStep.Text.Substring(0, match.Index) : scenarioStep.Text;
        }
 public GherkinStep(StepDefinitionType stepDefinitionType, StepDefinitionKeyword stepDefinitionKeyword, string stepText, StepContext stepContext, string keyword, int blockRelativeLine)
     : base(stepDefinitionType, stepDefinitionKeyword, keyword, stepText, stepContext)
 {
     BlockRelativeLine = blockRelativeLine;
     BindingStatus     = BindingStatus.UnknownBindingStatus;
 }
Exemplo n.º 15
0
 public TeamService(StepContext stepContext)
 {
     _stepContext = stepContext;
 }
Exemplo n.º 16
0
 public ProductSteps(StepContext context, IApiClient apiClient)
 {
     _context   = context;
     _apiClient = apiClient;
 }
Exemplo n.º 17
0
 List <string> GetActionList(StepContext context)
 {
     return(context.Load <List <string> >()
            ?? context.Save(new List <string>()));
 }
Exemplo n.º 18
0
        private void AddInstances(ScenarioStep scenarioStep, ScenarioOutline scenarioOutline, Feature feature, StepContext stepContext, INativeSuggestionItemFactory <TNativeSuggestionItem> nativeSuggestionItemFactory)
        {
            foreach (var exampleSet in scenarioOutline.Examples.ExampleSets)
            {
                foreach (var row in exampleSet.Table.Body)
                {
                    var replacedText = paramRe.Replace(scenarioStep.Text,
                                                       match =>
                    {
                        string param    = match.Groups["param"].Value;
                        int headerIndex = Array.FindIndex(exampleSet.Table.Header.Cells, c => c.Value.Equals(param));
                        if (headerIndex < 0)
                        {
                            return(match.Value);
                        }
                        return(row.Cells[headerIndex].Value);
                    });

                    var newStep = scenarioStep.Clone();
                    newStep.Text = replacedText;
                    instances.Add(new StepInstance <TNativeSuggestionItem>(newStep, feature, stepContext, nativeSuggestionItemFactory, 2)
                    {
                        ParentTemplate = this
                    });
                }
            }
        }
Exemplo n.º 19
0
 public string GetUrl(StepContext stepContext)
 {
     return _getUrl(stepContext);
 }
Exemplo n.º 20
0
        private static long RetryPreviousIfFailed(StepContext ctx, int chunkSize)
        {
            long index = ctx.StepIndex;
            if (ctx.NumberOfItemsProcessed == 0 && (ctx.StepIndex - chunkSize) > 0)
                index = ctx.StepIndex - chunkSize;

            return index;
        }
Exemplo n.º 21
0
 public void SaveStepContext(StepContext stepContext)
 {
     _dbIndexes.Add(stepContext.StepIndex);
 }
        public StepChallengeQuery(StepContext db, StepsService stepsService)
        {
            // TODO these should be set in the db and able to change
            var startDate = new DateTime(2019, 09, 16, 0, 0, 0);
            var endDate   = new DateTime(2019, 12, 05, 0, 0, 0);

            Field <ParticipantType>(
                "Participant",
                arguments: new QueryArguments(
                    new QueryArgument <IdGraphType> {
                Name = "participantId", Description = "The ID of the Participant"
            }),
                resolve: context =>
            {
                var id          = context.GetArgument <int>("participantId");
                var participant = db.Participants
                                  .Include("Team")
                                  .FirstOrDefault(i => i.ParticipantId == id);

                var steps = db.Steps
                            .Where(s => s.ParticipantId == id)
                            .Where(s => s.DateOfSteps >= startDate && s.DateOfSteps < endDate)
                            .OrderBy(s => s.DateOfSteps)
                            .ToList();

                if (participant != null)
                {
                    participant.Steps = steps;
                }

                return(participant);
            });

            Field <ListGraphType <UserType> >(
                "Users",
                resolve: context =>
            {
                var participants = db.Participants
                                   .Include("IdentityUser")
                                   .Include("Team");

                return(participants);
            });

            Field <ListGraphType <StepsType> >(
                "TeamSteps",
                arguments: new QueryArguments(
                    new QueryArgument <IdGraphType> {
                Name = "teamId", Description = "The ID of the Team"
            }),
                resolve: context =>
            {
                var id   = context.GetArgument <int>("teamId");
                var team = db.Team
                           .Include("Participants")
                           .FirstOrDefault(i => i.TeamId == id);

                var teamSteps = db.Steps
                                .Where(s => team.Participants.Any(t => t.ParticipantId == s.ParticipantId))
                                .Where(s => s.DateOfSteps >= startDate && s.DateOfSteps < endDate)
                                .GroupBy(s => s.DateOfSteps)
                                .Select(s => new Steps
                {
                    DateOfSteps = s.First().DateOfSteps,
                    StepCount   = s.Sum(st => st.StepCount)
                })
                                .OrderBy(s => s.DateOfSteps)
                                .ToList();

                return(teamSteps);
            });

            Field <TeamType>(
                "Team",
                arguments: new QueryArguments(
                    new QueryArgument <IdGraphType> {
                Name = "teamId", Description = "The ID of the Team"
            }),
                resolve: context =>
            {
                var teamId = context.GetArgument <int>("teamId");
                var team   = db.Team
                             .Include("Participants")
                             .FirstOrDefault(t => t.TeamId == teamId);

                return(team);
            });

            Field <ListGraphType <TeamType> >(
                "Teams",
                resolve: context =>
            {
                var teams = db.Team
                            .Include("Participants")
                            .Include("Participants.Steps");

                return(teams);
            });

            Field <LeaderBoardType>(
                "LeaderBoard",
                resolve: context =>
            {
                var leaderBoard = new LeaderBoard();

                var teamSteps = db.Team
                                .Select(t => new TeamScores
                {
                    TeamId        = t.TeamId,
                    TeamName      = t.TeamName,
                    TeamStepCount = t.Participants.Sum(u => u.Steps.Sum(s => s.StepCount))
                }).ToList();

                leaderBoard.TeamScores = teamSteps;

                return(leaderBoard);
            });
        }
Exemplo n.º 23
0
        public static StepContext InitialRun(StepContext ctx, int chunkSize)
        {
            long index = RetryPreviousIfFailed(ctx, chunkSize);

            return new StepContext(ctx.StepName, index, ctx.NumberOfItemsProcessed, true, chunkSize);
        }
Exemplo n.º 24
0
		private static void DoCopyUnit(StepContext context, AU.AdminUnit fromUnit, AU.AdminUnit targetParent, string newName, string newCodeName, bool copyRoleMembers, bool copyScopeMembers, bool copyScopeConditions)
		{
			AU.AdminUnit newUnit = CreateUnit(fromUnit, newName, newCodeName);

			int totalSteps = 1;
			if (copyRoleMembers)
				totalSteps++;
			if (copyScopeConditions)
				totalSteps++;
			if (copyScopeMembers)
				totalSteps++;

			context.TotalSteps = totalSteps;
			context.PassedSteps = 0;
			context.Div = 100.0 / totalSteps;

			ProcessProgress.Current.MinStep = 1;
			ProcessProgress.Current.CurrentStep = 1;
			ProcessProgress.Current.MaxStep = 100;

			context.Logger.WriteLine(ProcessProgress.Current.StatusText = "正在添加管理单元");

			AU.Operations.Facade.InstanceWithPermissions.AddAdminUnit(newUnit, targetParent);
			context.ResetInnerSteps();
			context.PassedSteps++;
			context.Response();

			CopyRoleMembers(fromUnit, copyRoleMembers, newUnit, context);
			context.PassedSteps++;
			context.ResetInnerSteps();
			context.Response();

			if (copyScopeMembers || copyScopeConditions)
			{
				var srcScopes = fromUnit.GetNormalScopes();
				var scopes = newUnit.GetNormalScopes();

				if (copyScopeMembers)
				{
					foreach (AU.AUAdminScope srcScope in srcScopes)
					{
						var targetScope = scopes.GetScope(srcScope.ScopeSchemaType);
						if (targetScope != null)
						{
							CopyMembers(copyScopeMembers, srcScope, targetScope, context);
						}
					}
					context.PassedSteps++;
					context.ResetInnerSteps();
					context.Response();
				}

				if (copyScopeConditions)
				{
					foreach (AU.AUAdminScope srcScope in srcScopes)
					{
						var targetScope = scopes.GetScope(srcScope.ScopeSchemaType);
						if (targetScope != null)
						{
							CopyConditions(copyScopeConditions, srcScope, targetScope, context);
							context.PassedSteps++;
							context.ResetInnerSteps();
							context.Response();
						}
					}
					context.PassedSteps++;
					context.ResetInnerSteps();
				}
			}
		}
Exemplo n.º 25
0
 public override bool ConditionIsSatisfied(StepContext stepContext)
 {
     return !base.ConditionIsSatisfied(stepContext);
 }
Exemplo n.º 26
0
        public void Step(string keyword, StepKeyword stepKeyword, Parser.Gherkin.ScenarioBlock scenarioBlock, string text, GherkinBufferSpan stepSpan)
        {
            var editorLine  = stepSpan.StartPosition.Line;
            var tags        = FeatureTags.Concat(CurrentFileBlockBuilder.Tags).Distinct();
            var stepContext = new StepContext(FeatureTitle, CurrentFileBlockBuilder.BlockType == typeof(IBackgroundBlock) ? null : CurrentFileBlockBuilder.Title, tags.ToArray(), gherkinFileScope.GherkinDialect.CultureInfo);

            currentStep = new GherkinStep((StepDefinitionType)scenarioBlock, (StepDefinitionKeyword)stepKeyword, text, stepContext, keyword, editorLine - CurrentFileBlockBuilder.KeywordLine);
            CurrentFileBlockBuilder.Steps.Add(currentStep);

            var bindingMatchService = projectScope.BindingMatchService;

            if (enableStepMatchColoring && bindingMatchService != null && bindingMatchService.Ready)
            {
                List <BindingMatch>           candidatingMatches;
                StepDefinitionAmbiguityReason ambiguityReason;
                CultureInfo bindingCulture = projectScope.SpecFlowConfiguration.BindingCulture ?? currentStep.StepContext.Language;
                var         match          = bindingMatchService.GetBestMatch(currentStep, bindingCulture, out ambiguityReason, out candidatingMatches);

                if (match.Success)
                {
                    ColorizeKeywordLine(keyword, stepSpan, classifications.StepText);

                    var regexMatch = match.StepBinding.Regex.Match(text);
                    if (regexMatch.Success)
                    {
                        var textStart = KeywordAndWhitespaceLength(keyword, stepSpan, editorLine);
                        foreach (Group matchGroup in regexMatch.Groups.Cast <Group>().Skip(1))
                        {
                            var captures    = matchGroup.Captures;
                            var lastCapture = captures[captures.Count - 1];
                            var partStart   = textStart + captures[0].Index;
                            var partEnd     = textStart + lastCapture.Index + lastCapture.Length;
                            ColorizeLinePart(partStart, partEnd, stepSpan, classifications.StepArgument);
                        }
                    }
                    else
                    {
                        // this should never happen
                    }
                }
                else if (CurrentFileBlockBuilder.BlockType == typeof(IScenarioOutlineBlock) && placeholderRe.Match(text).Success)
                {
                    ColorizeKeywordLine(keyword, stepSpan, classifications.StepText); // we do not show binding errors in placeholdered scenario outline steps
                    //TODO: check match based on the scenario examples - unfortunately the steps are parsed earlier than the examples, so we would need to delay the colorization somehow
                }
                else
                {
                    ColorizeKeywordLine(keyword, stepSpan, classifications.UnboundStepText);
                }
            }
            else
            {
                ColorizeKeywordLine(keyword, stepSpan, classifications.StepText);
            }

            if (CurrentFileBlockBuilder.BlockType == typeof(IScenarioOutlineBlock))
            {
                var matches   = placeholderRe.Matches(text);
                var textStart = KeywordAndWhitespaceLength(keyword, stepSpan, editorLine);
                foreach (Match match in matches)
                {
                    var capture = match.Groups[0].Captures[0];
                    var start   = textStart + capture.Index;
                    ColorizeLinePart(start, start + capture.Length, stepSpan, classifications.Placeholder);
                }
            }
        }
Exemplo n.º 27
0
		protected void Processing(object sender, MCS.Web.WebControls.PostProgressDoPostedDataEventArgs e)
		{
			ProcessProgress.Current.MinStep = 0;
			ProcessProgress.Current.MaxStep = ProcessProgress.Current.CurrentStep = 1;
			StepContext context = new StepContext();

			try
			{
				string fromUnitID = (string)e.Steps[0];
				string newName = (string)e.Steps[1];
				string newCodeName = (string)e.Steps[2];
				string toUnitID = (string)e.Steps[3];
				bool copyRoleMembers = (bool)e.Steps[4];
				bool copyScopeMembers = (bool)e.Steps[5];
				bool copyScopeConditions = (bool)e.Steps[6];

				var fromUnit = DbUtil.GetEffectiveObject<AU.AdminUnit>(fromUnitID);
				string schemaID = fromUnit.AUSchemaID;
				if (string.IsNullOrEmpty(schemaID))
					throw new AUObjectException("无法获取要复制单元的架构ID");

				var targetParent = toUnitID == schemaID ? null : DbUtil.GetEffectiveObject<AU.AdminUnit>(toUnitID);
				if (targetParent != null && fromUnit.AUSchemaID != targetParent.AUSchemaID)
					throw new AU.AUObjectException("选择的目标父级单元与子级单元架构不同");


				DoCopyUnit(context, fromUnit, targetParent, newName, newCodeName, copyRoleMembers, copyScopeMembers, copyScopeConditions);
			}
			catch (AUObjectValidationException vex)
			{
				ProcessProgress.Current.Output.WriteLine(vex.Message);
			}
			catch (Exception ex)
			{
				ProcessProgress.Current.Output.WriteLine(ex.ToString());
			}

			e.Result.ProcessLog = context.Logger.ToString();
			ProcessProgress.Current.StatusText = "结束";
			ProcessProgress.Current.Response();
			SCCacheHelper.InvalidateAllCache();

			e.Result.DataChanged = true;
			e.Result.CloseWindow = false;
			e.Result.ProcessLog = ProcessProgress.Current.GetDefaultOutput();
		}
Exemplo n.º 28
0
 public static Response Step3(StepContext context)
 {
     Thread.Sleep(5000);
     return(Response.Ok(context.Data));
 }
Exemplo n.º 29
0
		private static void CopyConditions(bool copyScopeConditions, AU.AUAdminScope srcScope, AU.AUAdminScope targetScope, StepContext context)
		{
			if (copyScopeConditions)
			{
				context.Logger.WriteLine(ProcessProgress.Current.StatusText = "正在复制管理范围条件成员");
				ProcessProgress.Current.Response();

				var srcCondition = AU.Adapters.AUConditionAdapter.Instance.Load(srcScope.ID, AU.AUCommon.ConditionType).Where(m => m.Status == SchemaObjectStatus.Normal).FirstOrDefault();
				if (srcCondition != null)
				{
					AU.Operations.Facade.InstanceWithPermissions.UpdateScopeCondition(targetScope, new PC.Conditions.SCCondition()
					{
						Condition = srcCondition.Condition,
						Description = srcCondition.Description,
						OwnerID = targetScope.ID,
						Type = AU.AUCommon.ConditionType,
						SortID = 0
					});
				}
			}
		}
Exemplo n.º 30
0
        public override async Task <bool> OnNavigatedToAsync(IProgress <string> progress, StepContext ctx)
        {
            if (!IsTargetDirectoryValid(ctx))
            {
                return(false);
            }

            var templateDefinitionFile = Path.Combine(ctx.TargetDirectory, "TemplateDefinition.xml");

            if (!File.Exists(templateDefinitionFile))
            {
                return(false);
            }

            var templateDefinition = await Task.Run(() => TemplateDefinitionHelper.Parse(templateDefinitionFile));

            if (templateDefinition == null)
            {
                return(false);
            }

            try
            {
                File.Delete(templateDefinitionFile);
            }
            catch (Exception ex)
            {
                theLogger.Error($"Unable to delete template definition file: '{templateDefinitionFile}'.", ex);
            }

            foreach (var placeholderDefinition in templateDefinition.Placeholders)
            {
                var placeholder = new PlaceholderViewModel()
                {
                    Name          = placeholderDefinition.Name,
                    TextToReplace = string.IsNullOrEmpty(placeholderDefinition.TextToReplace)
                        ? placeholderDefinition.Name
                        : placeholderDefinition.TextToReplace,
                    Replacement = placeholderDefinition.DefaultValue,
                    Suggestions = TemplateDefinitionHelper.SplitEscapedString(placeholderDefinition.SuggestionList),
                    Description = placeholderDefinition.Description
                };

                placeholder.PropertyChanged += (s, e) =>
                {
                    foreach (var example in Examples)
                    {
                        example.UpdateText(Placeholders);
                    }
                };

                Placeholders.Add(placeholder);
            }

            foreach (var example in templateDefinition.Examples ?? new Example[0])
            {
                Examples.Add(new ExampleViewModel(example));
            }

            return(true);
        }
Exemplo n.º 31
0
		private static void CopyRoleMembers(AU.AdminUnit fromUnit, bool copyRoleMembers, AU.AdminUnit newUnit, StepContext context)
		{
			if (copyRoleMembers)
			{
				var roles = AU.Adapters.AUSnapshotAdapter.Instance.LoadAURoles(new string[] { fromUnit.ID }, true, DateTime.MinValue);
				var schemaRoles = AU.Adapters.AUSnapshotAdapter.Instance.LoadAUSchemaRoles(fromUnit.AUSchemaID, true, DateTime.MinValue);
				double allCount = roles.Count;
				foreach (AU.AURole r in roles)
				{
					var schemaRole = schemaRoles[r.SchemaRoleID];
					if (schemaRole == null)
						throw new AUObjectException(string.Format("未能找到对应角色{0}的管理架构角色{1}", r.ID, r.SchemaRoleID));

					context.Logger.WriteLine(ProcessProgress.Current.StatusText = string.Format("正在设置管理单元角色 {0} 成员", schemaRole.Name));
					ProcessProgress.Current.Response();
					var targetRole = AU.Adapters.AUSnapshotAdapter.Instance.LoadAURole(r.SchemaRoleID, newUnit.ID, true, DateTime.MinValue);

					if (targetRole != null)
					{
						var usersIDs = AU.AUCommon.DoDbProcess(() => PC.Adapters.SCMemberRelationAdapter.Instance.LoadByContainerID(r.ID, "Users")).FilterByStatus(SchemaObjectStatusFilterTypes.Normal).ToIDArray();

						var users = (from p in usersIDs select new PC.SCUser() { ID = p, Name = "Demo", CodeName = "Demo" }).ToArray();

						AU.Operations.Facade.InstanceWithPermissions.ReplaceUsersInRole(users, newUnit, DbUtil.GetEffectiveObject<AU.AUSchemaRole>(targetRole.SchemaRoleID));
						context.Logger.Write("已经添加{0}个人员\r\n", users.Length);
					}
				}
			}
		}
Exemplo n.º 32
0
 private static CellMatrix CreateCellMatrix(StepContext ctx)
 {
     return(new CellMatrix(ctx.Width, ctx.Height, ctx.BorderSize));
 }
Exemplo n.º 33
0
 public ContextHandler(FeatureContext featureContext, ScenarioContext scenarioContext, StepContext stepContext)
 {
     this.featureContext = featureContext;
     this.scenarioContext = scenarioContext;
     this.stepContext = stepContext;
 }
Exemplo n.º 34
0
 public SearchSteps(StepContext context)
 {
     _context   = context;
     _searchApi = new SearchApi();
 }
Exemplo n.º 35
0
        public StepChallengeQuery(StepContext db, StepsService stepsService, TeamService teamService)
        {
            // TODO these should be set in the db and able to change
            var startDate = new DateTime(2019, 09, 16, 0, 0, 0);
            var endDate   = new DateTime(2019, 12, 05, 0, 0, 0);

            Field <ParticipantType>(
                "Participant",
                arguments: new QueryArguments(
                    new QueryArgument <IdGraphType> {
                Name = "participantId", Description = "The ID of the Participant"
            }),
                resolve: context =>
            {
                var id = context.GetArgument <int>("participantId");

                var participant = db.Participants
                                  .Include("Team")
                                  .FirstOrDefault(i => i.ParticipantId == id);

                return(stepsService.GetParticipantSteps(participant));
            });

            Field <ListGraphType <UserType> >(
                "Users",
                resolve: context =>
            {
                var participants = db.Participants
                                   .Include("IdentityUser")
                                   .Include("Team")
                                   .OrderBy(u => u.ParticipantName);

                return(participants);
            });

            Field <ListGraphType <TeamScoreBoardType> >(
                "TeamSteps",
                arguments: new QueryArguments(
                    new QueryArgument <IdGraphType> {
                Name = "teamId", Description = "The ID of the Team"
            }),
                resolve: context =>
            {
                var id        = context.GetArgument <int>("teamId");
                var teamSteps = teamService.GetTeamScoreBoard(id);

                return(teamSteps);
            });

            Field <TeamType>(
                "Team",
                arguments: new QueryArguments(
                    new QueryArgument <IdGraphType> {
                Name = "teamId", Description = "The ID of the Team"
            }),
                resolve: context =>
            {
                var teamId = context.GetArgument <int>("teamId");
                var team   = db.Team
                             .Include("Participants")
                             .FirstOrDefault(t => t.TeamId == teamId);

                return(team);
            });

            Field <ListGraphType <TeamType> >(
                "Teams",
                resolve: context =>
            {
                var teams = db.Team
                            .Include("Participants")
                            .Include("Participants.Steps");

                return(teams);
            });

            Field <LeaderBoardType>(
                "LeaderBoard",
                resolve: context =>
            {
                var leaderBoard = new LeaderBoard();
                var settings    = db.ChallengeSettings
                                  .FirstOrDefault();

                if (settings == null || !settings.ShowLeaderBoard)
                {
                    leaderBoard.TeamScores = new List <TeamScores>();
                    return(leaderBoard);
                }

                var teams   = db.Team;
                leaderBoard = stepsService.GetLeaderBoard(teams);

                var teamSteps = leaderBoard.TeamScores.Select(t => new TeamScores
                {
                    TeamId        = t.TeamId,
                    TeamName      = t.TeamName,
                    TeamStepCount = settings.ShowLeaderBoardStepCounts ? t.TeamStepCount : 0
                }).ToList();

                leaderBoard.TeamScores = teamSteps;

                return(leaderBoard);
            });

            Field <AdminLeaderBoardType>(
                "AdminLeaderBoard",
                resolve: context =>
            {
                var teams = db.Team;

                var leaderBoard = stepsService.GetLeaderBoard(teams);

                return(leaderBoard);
            });

            Field <ChallengeSettingsType>(
                "ChallengeSettings",
                resolve: context =>
            {
                var settings = db.ChallengeSettings
                               .FirstOrDefault();

                return(settings);
            });

            FieldAsync <AdminParticipantsOverviewType>("AdminParticipantsOverview",
                                                       resolve: async context =>
            {
                var overview = await stepsService.GetTeamsOverview();

                return(overview);
            });
        }
Exemplo n.º 36
0
 public object CreateDefault(StepContext stepContext)
 {
     return _createDefault(stepContext);
 }
Exemplo n.º 37
0
 static void HandleNoSteps(StepContext context)
 {
     _log.Info("No Steps");
       context.Response.StatusCode = (Int32)HttpStatusCode.MethodNotAllowed;
       context.Response.StatusDescription = "Method Not Allowed";
 }
Exemplo n.º 38
0
 public StepResult(StepContext context)
 {
     Step = context.Step;
 }