public void SetScreenEffect(ActionArguments args, WarUnit doer, Point2 center, IEnumerable<Point2> areaPoints, IEnumerable<Point2> validAreaPoints, int times, Action<int, int> callbackFunc)
 {
     args.Model.SetFrameAnimationOnScreen(_surfaces, 150, () => {
         for (int i = 1; i <= times; i++)
             callbackFunc(i, times);
     });
 }
		public void OnFinish (ActionArguments arguments, ActionResult result)
		{
			if (callback != null)
			{
				callback.Invoke (arguments, result);
			}
		}
Esempio n. 3
0
        public void CodeCoverageProcessExitsAndCodeCoverageFileExistsCausesCodeCoverageResultsToBeReadFromFile()
        {
            ActionArguments <CodeCoverageResults> actionArgs =
                CreateTestRunnerAndFireCodeCoverageProcessExitEvent();

            CodeCoverageResults result = actionArgs.Arg;

            Assert.AreEqual("MyTests", result.Modules[0].Name);
        }
        public void FirstSafeAsyncMethodCallWithArgsIsMadeOnRunTestCommandShowResultsMethod()
        {
            ActionArguments <TestResult> actionArgs = new ActionArguments <TestResult>();

            actionArgs.Action = runTestCommand.ShowResultAction;
            actionArgs.Arg    = errorTestResult;

            Assert.AreEqual(actionArgs, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCallsWithArguments[0]);
        }
Esempio n. 5
0
        public async Task <ActionResult> SendInvitation([FromBody] List <int> ids, [FromQuery] ActionArguments args)
        {
            var serverTime = DateTimeOffset.UtcNow;
            var result     = await _service.SendInvitation(ids, args);

            var response = TransformToEntitiesResponse(result, serverTime, cancellation: default);

            return(Ok(response));
        }
Esempio n. 6
0
        public void CodeCoverageProcessExitsAndCodeCoverageFileExistsCausesCodeCoverageResultsToBeDisplayed()
        {
            ActionArguments <CodeCoverageResults> actionArgs =
                CreateTestRunnerAndFireCodeCoverageProcessExitEvent();

            Action <CodeCoverageResults> expectedAction = CodeCoverageService.ShowResults;

            Assert.AreEqual(expectedAction, actionArgs.Action);
        }
Esempio n. 7
0
            public Boolean Apply(ActionArguments arguments)
            {
                Boolean result = false;

                if (predicate != null)
                {
                    result = predicate.Invoke((ActionArguments)arguments);
                }
                return(result);
            }
		public void MethodWithParameterStoredInSafeThreadAsyncMethodCallsCollectionAfterSafeThreadAsyncCallMethodCalled()
		{
			TestResult result = new TestResult("abc");
			workbench.SafeThreadAsyncCall(this.ShowResults, result);
			
			ActionArguments<TestResult> actionArgs = new ActionArguments<TestResult>();
			actionArgs.Action = this.ShowResults;
			actionArgs.Arg = result;
			
			Assert.AreEqual(actionArgs, workbench.SafeThreadAsyncMethodCallsWithArguments[0]);
		}
Esempio n. 9
0
		public void MethodWithParameterStoredInSafeThreadAsyncMethodCallsCollectionAfterSafeThreadAsyncCallMethodCalled()
		{
			TestResult result = new TestResult("abc");
			workbench.SafeThreadAsyncCall(this.ShowResults, result);
			
			ActionArguments<TestResult> actionArgs = new ActionArguments<TestResult>();
			actionArgs.Action = this.ShowResults;
			actionArgs.Arg = result;
			
			Assert.AreEqual(actionArgs, workbench.SafeThreadAsyncMethodCallsWithArguments[0]);
		}
Esempio n. 10
0
        public HttpActionContextResemblance(HttpActionContext actionContext)
            : base(actionContext.ControllerContext, actionContext.ActionDescriptor)
        {
            foreach (var kvp in actionContext.ActionArguments)
            {
                ActionArguments.Add(kvp.Key, kvp.Value);
            }

            foreach (var kvp in actionContext.ModelState)
            {
                ModelState.Add(kvp);
            }

            Response = actionContext.Response;
        }
Esempio n. 11
0
 public void SetScreenEffect(ActionArguments args, WarUnit doer, Point2 center, IEnumerable<Point2> areaPoints, IEnumerable<Point2> validAreaPoints, int times, Action<int, int> callbackFunc)
 {
     var model = args.Model;
     int delay = 0;
     for (int i = 1; i <= times; i++)
     {
         foreach (var p in areaPoints)
         {
             var anime = model.CreateDirectedUniformMotionAnimationOnMap(_surfaces, doer.Location, p, 0.125f);
             anime = new ExtendTimeAnimationSprite(anime, delay, 0);
             model.ChipAnimations.Add(anime, callbackFunc.GetCurrying(i, times));
             delay += 300;
         }
     }
 }
Esempio n. 12
0
        public void CodeCoverageProcessExitsAndCodeCoverageFileDoesNotExistsAddsErrorTaskToTaskList()
        {
            command.ParsedStringToReturn = "No code coverage results file generated.";
            ActionArguments <Task> args = CreateTestRunnerAndFirePartCoverProcessExitEventWhenNoCoverageFileProduced();
            Task task = args.Arg;

            string description  = @"No code coverage results file generated. c:\projects\MyTests\OpenCover\coverage.xml";
            int    column       = 1;
            int    line         = 1;
            Task   expectedTask = new Task(null, description, column, line, TaskType.Error);

            TaskComparison comparison = new TaskComparison(expectedTask, task);

            Assert.IsTrue(comparison.IsMatch, comparison.MismatchReason);
        }
Esempio n. 13
0
        public bool Equals(HttpActionContext other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(ControllerContext.ControllerDescriptor.ControllerType
                   == other.ControllerContext.ControllerDescriptor.ControllerType &&
                   ActionDescriptor.ActionName == other.ActionDescriptor.ActionName &&
                   ActionArguments.OrderBy(x => x.Key).SequenceEqual(other.ActionArguments.OrderBy(x => x.Key)));
        }
        public Task <StepActionResult> Publish(
            Guid id,
            SyncPublisherAction action,
            ActionArguments args)
        {
            if (args?.Options == null)
            {
                throw new ArgumentNullException(nameof(args));
            }

            try
            {
                if (id == Guid.Empty)
                {
                    id = Guid.NewGuid();
                }

                var config = _publisherSearchConfigs.ConfigsByServerName.TryGetValue(args.Target, out var sc) ? sc : null;
                _staticSitePublisherExtensions.Keys.ToList().ForEach(e => _staticSitePublisherExtensions[e] = e.BeginPublish(id, _syncRoot, action, args, config));
                var itemDependencies = _outgoingService.GetItemDependencies(args.Options.Items, args.Callbacks)?.ToList() ?? new List <uSyncDependency>();
                var itemPaths        = new Dictionary <string, string>(itemDependencies.Count)
                {
                    [new GuidUdi(Umbraco.Core.Constants.UdiEntityType.Document, Guid.Empty).ToString()] = "/"
                };
                RunExtension((e, s) => e.AddCustomDependencies(s, itemDependencies));

                MoveToNextStep(action, args);
                GenerateHtml(itemDependencies, id, args, itemPaths);
                MoveToNextStep(action, args);
                GatherMedia(itemDependencies, id, args);
                MoveToNextStep(action, args);
                GatherFiles(id, args);
                RunExtension((e, s) => e.BeforeFinalPublish(s));
                MoveToNextStep(action, args);
                Publish(id, args, config, itemPaths);
                RunExtension((e, s) => e.EndPublish(s));

                var result = new StepActionResult(true, id, args.Options, Enumerable.Empty <uSyncAction>());
                return(Task.FromResult(result));
            }
            catch (Exception ex)
            {
                logger.Error <ExtensibleStaticPublisher>(ex, $"Could not publish");
                throw;
            }
        }
Esempio n. 15
0
 public async Task <ActionResult> DoAction(ActionArguments arguments)
 {
     switch (arguments.ActionName)
     {
     case "GenerateStatistics":
         return(new PicAndCaptionResult()
         {
             Caption = "Статистика посещения конференции",
             Pic = File.ReadAllBytes("Content/Gen.png"),
             NameGoes = new NameGo[]
             {
                 ("В разработке", "underconstruction"),
                 ("Сервис", "service"),
                 ("Старт", "start"),
                 ("Хорошо", "service"),
             },
             Column = 3
         });
Esempio n. 16
0
        public async override Task LoadViewModel()
        {
            LoadOptions();

            if (ActionIdentifier.HasValue)
            {
                var action = _actionRepository.GetDescriptionByIdentifier(ActionIdentifier.Value);
                if (action != null)
                {
                    await DispatcherHelper.RunAsync(() =>
                    {
                        SelectedActionTrigger  = ActionTriggers.FirstOrDefault(t => t == action.ActionTrigger);
                        SelectedDevice         = Devices.FirstOrDefault(d => d.Identifier == action.DeviceIdentifier);
                        SelectedActionType     = ActionTypes.FirstOrDefault(t => t.Identifer == action.ActionTypeIdentifier);
                        SelectedActionArgument = ActionArguments.FirstOrDefault(a => a.Identifer == action.ActionArgumentIdentifier);
                    });
                }
            }
        }
        private void Publish(Guid id, ActionArguments args, IPublisherSearchConfig config, Dictionary <string, string> itemPaths)
        {
            var folder = $"{_syncRoot}/{id}";

            if (config.Deployer != null && args.Options.DeleteMissing)
            {
                // Find all items being published that are publishing their children as well
                var roots = args.Options.Items.Select(i => i.flags.HasFlag(DependencyFlags.IncludeChildren) && itemPaths.TryGetValue(i.Udi?.ToString(), out var path) ? path : null).Where(i => i != null).ToList();

                // Remove any that are sub-folders of another one in the list
                roots.RemoveAll(r => roots.Any(rt => r != rt && r.StartsWith(rt)));

                if (roots.Count > 0)
                {
                    config.Deployer.RemovePathsIfExist(config.DeployerConfig, roots);
                }
            }
            config.LimitedDeployer.Deploy(folder, config.DeployerConfig, args.Callbacks?.Update);
        }
Esempio n. 18
0
        private void UpdateActionArguments()
        {
            ActionArguments.Clear();

            if (SelectedActionType == null)
            {
                return;
            }

            foreach (var actionArgument in SelectedActionType.ActionArguments)
            {
                ActionArguments.Add(actionArgument);
            }

            if (ActionArguments.Count == 1)
            {
                SelectedActionArgument = ActionArguments.First();
            }
        }
Esempio n. 19
0
        public async Task <ActionResult> DoAction(ActionArguments arguments)
        {
            switch (arguments.ActionName)
            {
            case "HelloGenerated":
                return(new PicAndCaptionResult()
                {
                    Caption = "Генерируем какие-то бизнес данные, строим графики",

                    // this pic can be generated depends on business logic
                    Pic = File.ReadAllBytes("Bot/Gen/Gen.png"),

                    NameGoes = new NameGo[]
                    {
                        ("Статус", "underconstruction"),
                        ("Меню", "HelloBot"),
                        ("Старт", "start"),
                        ("Хорошо", "HelloBot"),
                    },
                    ColumnsCount = 3
                });
Esempio n. 20
0
        private void UpdateActionTypes()
        {
            ActionTypes.Clear();
            ActionArguments.Clear();

            if (SelectedDevice == null)
            {
                return;
            }

            var actionTypes = _actionTypeRepository.GetByDeviceTypeId(SelectedDevice.Capability);

            foreach (var actionType in actionTypes)
            {
                ActionTypes.Add(actionType);
            }

            if (ActionTypes.Count == 1)
            {
                SelectedActionType = ActionTypes.First();
            }
        }
        private void GatherFiles(Guid id, ActionArguments args)
        {
            if (!args.Options.IncludeFileHash)
            {
                return;
            }

            var folders = new List <string> {
                "~/css", "~/scripts"
            };
            var files = new Dictionary <string, Stream>();

            RunExtension((e, s) => e.AddCustomFilesAndFolders(s, folders, files));

            if (folders.Count > 0)
            {
                _staticSiteService.SaveFolders(id, folders.ToArray());
            }
            if (files.Count > 0)
            {
                foreach (var file in files)
                {
                    try
                    {
                        var path = $"{_syncRoot}/{id}/{file.Key}".Replace("/", "\\");
                        _syncFileService.SaveFile(path, file.Value);
                    }
                    catch (Exception ex)
                    {
                        logger.Warn <ExtensibleStaticPublisher>($"Error saving file {file.Key}", ex);
                    }
                    finally
                    {
                        file.Value?.Dispose();
                    }
                }
            }
        }
Esempio n. 22
0
        protected async Task BeginAction(params Argument[] arguments)
        {
            if (!IsAvailable)
            {
                throw new InvalidOperationException("Workflow is no longer available");
            }

            await _actioningEvent.WaitAsync();

            await _endWaitActionEvent.WaitAsync();

            if (IsComplete)
            {
                throw new InvalidOperationException("Workflow is no longer available");
            }

            IsInAction = true;
            ActionArguments.Clear();

            foreach (var arg in arguments)
            {
                ActionArguments.Add(arg);
            }
        }
Esempio n. 23
0
 public Task <(List <Currency>, Extras)> Deactivate(List <string> ids, ActionArguments args)
 {
     return(SetIsActive(ids, args, isActive: false));
 }
Esempio n. 24
0
 public Task <EntitiesResult <AccountType> > Activate(List <int> ids, ActionArguments args)
 {
     return(SetIsActive(ids, args, isActive: true));
 }
Esempio n. 25
0
        private async Task <EntitiesResult <AccountType> > SetIsActive(List <int> ids, ActionArguments args, bool isActive)
        {
            await Initialize();

            // Check user permissions
            var action       = "IsActive";
            var actionFilter = await UserPermissionsFilter(action, cancellation : default);

            ids = await CheckActionPermissionsBefore(actionFilter, ids);

            // Execute and return
            using var trx = TransactionFactory.ReadCommitted();
            OperationOutput output = await _behavior.Repository.AccountTypes__Activate(
                ids : ids,
                isActive : isActive,
                validateOnly : ModelState.IsError,
                top : ModelState.RemainingErrors,
                userId : UserId);

            AddErrorsAndThrowIfInvalid(output.Errors);

            var result = (args.ReturnEntities ?? false) ?
                         await GetByIds(ids, args, action, cancellation : default) :
                         EntitiesResult <AccountType> .Empty();

            // Check user permissions again
            await CheckActionPermissionsAfter(actionFilter, ids, result.Data);

            trx.Complete();
            return(result);
        }
Esempio n. 26
0
        public async Task <ActionResult <EntitiesResponse <Document> > > Uncancel([FromBody] List <int> ids, [FromQuery] ActionArguments args)
        {
            var serverTime = DateTimeOffset.UtcNow;
            var result     = await GetService().Uncancel(ids, args);

            if (args.ReturnEntities ?? false)
            {
                var response = TransformToEntitiesResponse(result, serverTime, cancellation: default);
                return(Ok(response));
            }
            else
            {
                return(Ok());
            }
        }
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            base.OnActionExecuted(context);
            Stopwatch.Stop();

            IHeaderDictionary headersDictionary = context.HttpContext.Request.Headers;
            string            Browser           = headersDictionary[HeaderNames.UserAgent].ToString();
            string            Server            = context.HttpContext.Request.Host.ToString();
            string            Path        = context.HttpContext.Request.Path.ToString();
            string            QueryString = context.HttpContext.Request.QueryString.ToString();
            var     description           = (Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor)context.ActionDescriptor;
            string  ApiGroup   = description.ControllerName;
            string  ActionName = description.ActionName;
            string  Method     = context.HttpContext.Request.Method;
            string  Name       = _app._loginInfo.Name;
            string  Ip         = context.HttpContext.Connection.RemoteIpAddress.ToString();
            string  Request    = ActionArguments.Replace("\r", "").Replace("\n", "");
            dynamic dresult    = (context.Result == null ? null : (context.Result.GetType().Name == "EmptyResult" ? new { Value = "无返回结果" } : context.Result as dynamic));

            string Response = "在返回结果前发生了异常";

            try
            {
                if (dresult != null)
                {
                    Response = FormatResponse(Newtonsoft.Json.JsonConvert.SerializeObject(dresult.Value));
                }
            }
            catch (Exception)
            {
                Response = "";
            }

            bool   bResult = GetResponseResult(Response);
            string Result  = "成功";
            int    Flag    = 1;

            if (!bResult)
            {
                Result = "失败";
                Flag   = GetReSendFlag(ActionName);
            }

            _app.Add(new SysInterfaceLog()
            {
                Type              = "接收",
                System            = "WMS",
                Method            = Method,
                Server            = Server,
                Path              = Path,
                ActionName        = ActionName,
                QueryString       = QueryString,
                ApiGroup          = ApiGroup,
                Request           = Request,
                Response          = Response,
                TotalMilliseconds = Stopwatch.Elapsed.TotalMilliseconds,
                LogTime           = DateTime.Now,
                Name              = Name,
                Ip      = Ip,
                Browser = Browser,
                Result  = Result,
                Flag    = Flag,
            });;
        }
 public void SetScreenEffect(ActionArguments args, WarUnit doer, Point2 center, IEnumerable<Point2> areaPoints, IEnumerable<Point2> validAreaPoints, Action callbackFunc)
 {
     args.Model.SetFrameAnimationOnScreen(_surfaces, 150, callbackFunc);
 }
Esempio n. 29
0
        public override void OnActionExecuted(ActionExecutedContext context)
        {
            base.OnActionExecuted(context);
            Stopwatch.Stop();

            IHeaderDictionary headersDictionary = context.HttpContext.Request.Headers;
            string            request           = headersDictionary[HeaderNames.UserAgent].ToString();

            string url = context.HttpContext.Request.Host + context.HttpContext.Request.Path + context.HttpContext.Request.QueryString;

            var description =
                (Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor)context.ActionDescriptor;

            var actionName = description.ActionName;

            Dictionary <string, string> OperType = new Dictionary <string, string>();

            OperType.Add("Index", "查看");
            OperType.Add("Ins", "增加");
            OperType.Add("Upd", "更新");
            OperType.Add("DelByIds", "删除");

            var otype = "";

            if (OperType.ContainsKey(actionName))
            {
                otype = OperType[actionName];
            }
            else
            {
                otype = "其他";
            }

            string method = context.HttpContext.Request.Method;

            string Name = _app._loginInfo.Name;
            string Ip   = context.HttpContext.Connection.RemoteIpAddress.ToString();

            string  parameter = ActionArguments.Replace("\r", "").Replace("\n", "");
            dynamic result    = (context.Result == null ? null : (context.Result.GetType().Name == "EmptyResult" ? new { Value = "无返回结果" } : context.Result as dynamic));

            string response = "在返回结果前发生了异常";

            try
            {
                if (result != null)
                {
                    response = Newtonsoft.Json.JsonConvert.SerializeObject(result.Value).Replace("\r", "").Replace("\n", "");
                }
            }
            catch (System.Exception)
            {
                response = "";
            }

            _app.Add(new SysOperLog()
            {
                Url               = url,
                OperType          = otype,
                Method            = method,
                Request           = request,
                Parameter         = parameter,
                Response          = response,
                TotalMilliseconds = Stopwatch.Elapsed.TotalMilliseconds,
                LogTime           = System.DateTime.Now,
                Name              = Name,
                Ip = Ip
            });;
        }
Esempio n. 30
0
 public Task <EntitiesResult <EntryType> > Deactivate(List <int> ids, ActionArguments args)
 {
     return(SetIsActive(ids, args, isActive: false));
 }
Esempio n. 31
0
 public Task <EntitiesResult <Currency> > Activate(List <string> ids, ActionArguments args)
 {
     return(SetIsActive(ids, args, isActive: true));
 }
Esempio n. 32
0
        private async Task <EntitiesResult <Currency> > SetIsActive(List <string> ids, ActionArguments args, bool isActive)
        {
            await Initialize();

            // Check user permissions
            var action       = "IsActive";
            var actionFilter = await UserPermissionsFilter(action, cancellation : default);

            ids = await CheckActionPermissionsBefore(actionFilter, ids);

            var settings = await _behavior.Settings();

            foreach (var(id, index) in ids.Indexed())
            {
                if (ids.Any(id => id != null && id == settings.FunctionalCurrencyId))
                {
                    string path = $"[{index}]";
                    string msg  = _localizer["Error_CannotDeactivateTheFunctionalCurrency"];

                    ModelState.AddError(path, msg);
                }
            }

            // Execute and return
            using var trx = TransactionFactory.ReadCommitted();
            OperationOutput output = await _behavior.Repository.Currencies__Activate(
                ids : ids,
                isActive : isActive,
                validateOnly : ModelState.IsError,
                top : ModelState.RemainingErrors,
                userId : UserId);

            AddErrorsAndThrowIfInvalid(output.Errors);

            var result = (args.ReturnEntities ?? false) ?
                         await GetByIds(ids, args, action, cancellation : default) :
                         EntitiesResult <Currency> .Empty();

            // Check user permissions again
            await CheckActionPermissionsAfter(actionFilter, ids, result.Data);

            trx.Complete();
            return(result);
        }
		public void FirstSafeAsyncMethodCallWithArgsIsMadeOnRunTestCommandShowResultsMethod()
		{
			ActionArguments<TestResult> actionArgs = new ActionArguments<TestResult>();
			actionArgs.Action = runTestCommand.ShowResultAction;
			actionArgs.Arg = errorTestResult;
			
			Assert.AreEqual(actionArgs, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCallsWithArguments[0]);
		}
Esempio n. 34
0
        private async Task <(List <Currency>, Extras)> SetIsActive(List <string> ids, ActionArguments args, bool isActive)
        {
            // Check user permissions
            var action       = "IsActive";
            var actionFilter = await UserPermissionsFilter(action, cancellation : default);

            ids = await CheckActionPermissionsBefore(actionFilter, ids);

            // Execute and return
            using var trx = ControllerUtilities.CreateTransaction();
            await _repo.Currencies__Activate(ids, isActive);

            List <Currency> data   = null;
            Extras          extras = null;

            if (args.ReturnEntities ?? false)
            {
                (data, extras) = await GetByIds(ids, args, action, cancellation : default);
            }

            // Check user permissions again
            await CheckActionPermissionsAfter(actionFilter, ids, data);

            trx.Complete();
            return(data, extras);
        }
Esempio n. 35
0
 public void SetScreenEffect(ActionArguments args, WarUnit doer, Point2 center, IEnumerable<Point2> areaPoints, IEnumerable<Point2> validAreaPoints, Action callbackFunc)
 {
     args.Model.SetDirectedUniformMotionAnimationOnMap(_surfaces, center, areaPoints.First(), 32, callbackFunc);
 }
Esempio n. 36
0
 public Task <(List <EntryType>, Extras)> Activate(List <int> ids, ActionArguments args)
 {
     return(SetIsActive(ids, args, isActive: true));
 }
Esempio n. 37
0
 public Task <(List <Unit>, Extras)> Deactivate(List <int> ids, ActionArguments args)
 {
     return(SetIsActive(ids, args, isActive: false));
 }
 public static void Uninstall(ActionArguments args)
 {
 }