protected override void AddInstantiatingObjectsToInstance(object sender, IWorkflowInstance inst)
 {
     if (TheHelper.HasProperty(sender, "Id"))
     {
         ((UmbracoWorkflowInstance)inst).CmsNodes.Add(TheHelper.GetProperty <int>(sender, "Id"));
     }
 }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            SaveTaskPropertiesButton.Text = TheGlobalisationService.GetString("save_task_properties");

            var taskType = Request["AssemblyQualifiedTypeName"];
            var task     = TheTaskFactory.CreateTask(taskType);

            var queryItems = Request.QueryString.Keys.Cast <string>().ToDictionary <string, string, object>(queryStringKey => queryStringKey, queryStringKey => Request.QueryString[queryStringKey]);

            if (queryItems.ContainsKey("Id"))
            {
                queryItems["Id"] = new Guid((string)queryItems["Id"]);
            }

            TheHelper.SetProperties(task, queryItems);

            _ui = TheWorkflowEntityUiResolver.Resolve(task);

            foreach (var c in _ui.Render(task))
            {
                TaskPropertiesUiPanel.Controls.Add(c);
            }
        }
        public ActionResult Index(string id)
        {
            var formCollection = new FormCollection(Request.QueryString);

            ViewBag.Id = id;

            var taskType = formCollection["AssemblyQualifiedTypeName"];

            ViewBag.TaskType = taskType;

            var task = TheTaskFactory.CreateTask(taskType);

            var ui = TheWorkflowEntityUiResolver.Resolve(task);

            var values = new Dictionary <string, object>();

            foreach (var prop in ui.UiProperties)
            {
                values[prop.PropertyName] = ControlExtensions.ControlValue(prop.RenderControl,
                                                                           formCollection[prop.PropertyName]);
            }
            if (values.ContainsKey("Id"))
            {
                values["Id"] = new Guid((string)values["Id"]);
            }

            TheHelper.SetProperties(task, values);
            ViewBag.PropertiesJson = TheHelper.JsSerializer.Serialize(values);

            return(View(ui.Render(task)));
        }
        protected override bool OtherInstancesRunning(IWorkflowInstance workflowInstance, object sender)
        {
            var senderId = (int)TheHelper.GetPropertyValue(sender, "Id");
            var typeName = workflowInstance.GetType().FullName;
            var umbracoWorkflowInstance = (UmbracoWorkflowInstance)workflowInstance;

            // var tenSecondsAgo = DateTime.Now.Subtract(TimeSpan.FromSeconds(10));

            var otherInstances = TheWorkflowInstanceService.ListInstances().Where(
                i => (i.GetType().FullName == typeName) &&
                (((UmbracoWorkflowInstance)i).Instantiator == umbracoWorkflowInstance.Instantiator) &&
                (i.Id != workflowInstance.Id) &&
                (((UmbracoWorkflowInstance)i).CmsNodes.Contains(senderId))
                // && (i.InstantiationTime > tenSecondsAgo)

                );

            return(otherInstances.Count() > 0);
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var taskType = Request["AssemblyQualifiedTypeName"];
            var task     = TheTaskFactory.CreateTask(taskType);

            var queryItems = new Dictionary <string, object>();

            foreach (string key in Request.QueryString.Keys)
            {
                if (key.Contains("[]"))
                {
                    var dictKey = key.Replace("[]", "");
                    var items   = Request.QueryString[key].Split(',');

                    try
                    {
                        queryItems.Add(dictKey, items.ToList().ConvertAll(Convert.ToInt32));
                    } catch
                    {
                        queryItems.Add(dictKey, items.ToList().ConvertAll(Convert.ToString));
                    }
                }
                else
                {
                    queryItems.Add(key, Request.QueryString[key]);
                }
            }

            if (queryItems.ContainsKey("Id"))
            {
                queryItems["Id"] = new Guid((string)queryItems["Id"]);
            }

            TheHelper.SetProperties(task, queryItems);
            _ui = TheWorkflowEntityUiResolver.Resolve(task);

            foreach (var c in _ui.Render(task))
            {
                TaskPropertiesUiPanel.Controls.Add(c);
            }
        }
Example #6
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);



            WorkflowConfigGridView.DataSource = TheWorkflowConfigurationService.ListConfigurations();
            WorkflowConfigGridView.DataBind();

            if (IsPostBack)
            {
                return;
            }

            WorkflowConfigsDropDownList.DataSource = TheHelper.WorkflowConfigurationTypes();

            WorkflowConfigsDropDownList.DataTextField  = "Name";
            WorkflowConfigsDropDownList.DataValueField = "AssemblyQualifiedName";

            WorkflowConfigsDropDownList.DataBind();
            WorkflowConfigsDropDownList.Visible = WorkflowConfigsDropDownList.Items.Count > 1;
            // EventService.Instance.OnChanged(EventArgs.Empty);
        }