public void NotifyProductsChanged(Dictionary <int, int[]> affectedProductIdsByContentId)
        {
            var settingService = ObjectFactoryBase.Resolve <ISettingsService>();

            int productContentId = int.Parse(settingService.GetSetting(SettingsTitles.PRODUCTS_CONTENT_ID));

            if (!affectedProductIdsByContentId.ContainsKey(productContentId))
            {
                return;
            }

            var taskService = ObjectFactoryBase.Resolve <ITaskService>();

            const int userId = 1;

            string taskData =
                ActionData.Serialize(new ActionData
            {
                ActionContext =
                    new ActionContext {
                    ContentItemIds = affectedProductIdsByContentId[productContentId], ContentId = productContentId, Parameters = new Dictionary <string, string>()
                }
            });

            var taskKey = typeof(ProductRelevanceAction).Name;

            taskService.AddTask(taskKey, taskData, userId, "Админ", "Обновление статусов на витрине");
        }
Esempio n. 2
0
        protected ActionTaskResult ProcessTask(ActionContext context)
        {
            var task        = _getTask(TaskKey);
            var taskContext = new EmptyTaskExecutionContext();
            var actionData  = new ActionData {
                ActionContext = context
            };

            task.Run(ActionData.Serialize(actionData), null, null, taskContext);
            return(taskContext.Result);
        }
Esempio n. 3
0
        public override ActionTaskResult Process(ActionContext context)
        {
            var productIds = _freezeService.GetUnfrozenProductIds();

            if (productIds.Any())
            {
                int productContentId = int.Parse(_settingsService.GetSetting(SettingsTitles.PRODUCTS_CONTENT_ID));

                var publishContext = new ActionContext
                {
                    BackendSid     = context.BackendSid,
                    CustomerCode   = context.CustomerCode,
                    ContentId      = productContentId,
                    ContentItemIds = productIds,
                    Parameters     = context.Parameters,
                    UserId         = context.UserId,
                    UserName       = context.UserName,
                };

                /*
                 * string actionAdapter = null;
                 * context.Parameters.TryGetValue(AdapterKey, out actionAdapter);
                 * var publishAction = _getAction(PublishAction, actionAdapter);
                 * publishAction.Process(publishContext);
                 */

                var dataForQueue = new ActionData
                {
                    ActionContext = publishContext,
                    Description   = null,
                    IconUrl       = null
                };

                string data = ActionData.Serialize(dataForQueue);

                _taskService.AddTask(PublishAction, data, publishContext.UserId, publishContext.UserName, TaskStrings.Unfreezing);

                return(ActionTaskResult.Success(new ActionTaskResultMessage()
                {
                    ResourceClass = nameof(TaskStrings),
                    ResourceName = nameof(TaskStrings.ProductsUnfreezed),
                    Extra = string.Join(", ", productIds)
                }));
            }

            return(ActionTaskResult.Success(new ActionTaskResultMessage()
            {
                ResourceClass = nameof(TaskStrings),
                ResourceName = nameof(TaskStrings.NoProductsToUnfreeze),
            }));
        }
Esempio n. 4
0
        public ActionResult Send(string idsStr, bool proceedIgnoredStatus, string[] ignoredStatus, bool stageOnly, bool localize = false)
        {
            int[] ids = null;
            ignoredStatus = ignoredStatus ?? Enumerable.Empty <string>().ToArray();

            ids = idsStr
                  .Split(new[] { ' ', ';', ',', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
                  .Select(int.Parse)
                  .Distinct()
                  .ToArray();

            ViewBag.IgnoredStatus = ignoredStatus;
            ViewBag.Localize      = localize;

            int    userId   = _userProvider.GetUserId();
            string userName = _userProvider.GetUserName();

            var parameters = new Dictionary <string, string>();

            if (!proceedIgnoredStatus)
            {
                parameters.Add("IgnoredStatus", string.Join(",", ignoredStatus));
            }

            if (stageOnly)
            {
                parameters.Add("skipPublishing", true.ToString());
                parameters.Add("skipLive", true.ToString());
            }

            parameters.Add("Localize", localize.ToString());

            string taskData = ActionData.Serialize(new ActionData
            {
                ActionContext = new A.ActionContext()
                {
                    ContentItemIds = ids, ContentId = 288, Parameters = parameters, UserId = userId, UserName = userName
                }
            });

            var taskKey = typeof(SendProductAction).Name;
            int taskId  = _taskService.AddTask(taskKey, taskData, userId, userName, TaskStrings.PartialSend);

            return(Json(new { taskId }));
        }
Esempio n. 5
0
        protected void RegisterTask(ActionContext context)
        {
            try
            {
                var customAction = _customActionService.ReadByCode(context.ActionCode);

                var dataForQueue = new ActionData
                {
                    ActionContext = context,
                    Description   = customAction.Description,
                    IconUrl       = customAction.IconUrl
                };

                _taskService.AddTask(TaskKey, ActionData.Serialize(dataForQueue), _userProvider.GetUserId(), _userProvider.GetUserName(), customAction.Name);
            }
            catch (Exception ex)
            {
                throw new ActionException(TaskStrings.ActionErrorMessage, context.ContentItemIds.Select(id => new ProductException(id, TaskStrings.ErrorActionEnqueue, ex)), context);
            }
        }