Exemplo n.º 1
0
        public void AddAction()
        {
            if (SelectedStateDefinition != null)
            {
                var dlg = ViewModelFactory.CreateViewModel <DataObjectSelectionTaskViewModel.Factory>().Invoke(DataContext, this,
                                                                                                               (ObjectClass)NamedObjects.Base.Classes.Zetbox.Basic.Workflow.Action.Find(FrozenContext),
                                                                                                               null,
                                                                                                               (lst) =>
                {
                    wf.ParameterizedActionDefinition actionToSelect = null;
                    foreach (var action in lst.Select(i => i.Object).Cast <wf.Action>())
                    {
                        var paramAction             = (wf.ParameterizedActionDefinition)DataContext.Create(DataContext.GetInterfaceType(action.ParameterType.GetDataType()));
                        paramAction.Action          = action;
                        paramAction.Module          = WFDefinition.Module;
                        paramAction.Name            = action.Name;
                        paramAction.IsVisible       = action.IsVisibleDefault;
                        paramAction.IsOnEnterAction = action.IsOnEnterActionDefault;
                        SelectedStateDefinition.StateDefinition.Actions.Add(paramAction);

                        if (actionToSelect == null)
                        {
                            actionToSelect = paramAction;
                        }
                    }
                    if (actionToSelect != null)
                    {
                        SelectedAction = ToActionViewModel(actionToSelect);
                    }
                    ResetStateDefinitionGraph();
                },
                                                                                                               null);
                ViewModelFactory.ShowDialog(dlg);
            }
        }
Exemplo n.º 2
0
        public bool Forward(wf.Action action, wf.ParameterizedActionDefinition parameter, wf.State current, Identity identity)
        {
            var ctx    = current.Context;
            var retVal = false;
            var dlg    = _vmf.CreateViewModel <DataObjectSelectionTaskViewModel.Factory>()
                         .Invoke(
                ctx,
                _vmf.GetWorkspace(ctx),
                (ObjectClass)NamedObjects.Base.Classes.Zetbox.App.Base.Identity.Find(_frozenCtx),
                null,
                (lst) =>
            {
                foreach (Identity id in lst.Select(i => i.Object))
                {
                    current.Instance.AddLogEntry("Forwared to " + id.ToString());
                    if (!current.Persons.Contains(id))
                    {
                        current.Persons.Add(id);
                    }
                }
                retVal = true;
            },
                null);

            _vmf.ShowDialog(dlg);
            return(retVal);
        }
Exemplo n.º 3
0
 private ActionGraphViewModel ToActionViewModel(wf.ParameterizedActionDefinition action)
 {
     if (!_actionViewModels.ContainsKey(action))
     {
         var vm = _actionViewModels[action] = ViewModelFactory.CreateViewModel <ActionGraphViewModel.Factory>().Invoke(DataContext, this, action);
         vm.IsSelectedChanged += (s, e) =>
         {
             var sender = (ActionGraphViewModel)s;
             if (sender.IsSelected)
             {
                 _actionViewModels.Values.Except(new[] { sender }).ForEach(i => i.IsSelected = false);
                 SelectedAction = sender;
             }
             else if (SelectedAction == sender)
             {
                 SelectedAction = null;
             }
         };
         vm.Action.PropertyChanged += (s, e) =>
         {
             switch (e.PropertyName)
             {
             case "InvokeAction":
                 ResetStateDefinitionGraph();
                 break;
             }
         };
     }
     return(_actionViewModels[action]);
 }
Exemplo n.º 4
0
        public bool SendReminder(wf.Action action, wf.ParameterizedActionDefinition parameter, wf.State current, Identity identity)
        {
            var body = string.Format(@"Hello Arthur!

This is an reminder of an open workflow item in your inbox.

Best regards, your Workflow System");
            var msg  = new MailMessage("*****@*****.**", "*****@*****.**", "Reminder", body);

            _mail.Send(msg);
            return(true);
        }
Exemplo n.º 5
0
        public static bool Schedule(wf.Action action, wf.ParameterizedActionDefinition parameter, wf.State current, Identity identity)
        {
            var sAction    = (wf.SchedulerAction)action;
            var sParameter = (wf.ScheduledActionDefinition)parameter;

            DateTime dt = sAction.Schedule.GetNext(new DateTime(DateTime.Today.Year, 1, 1));

            dt = sParameter.Schedule.GetRelative(dt);

            current.ScheduleAction(dt, sParameter.InvokeAction);

            return(true);
        }
Exemplo n.º 6
0
        public bool CreateReceipt(wf.Action action, wf.ParameterizedActionDefinition parameter, wf.State current, Identity identity)
        {
            var ctx     = current.Context;
            var payload = current.Instance.Payload.GetObject(ctx);

            if (payload is ReceiptTemplate)
            {
                var template = (ReceiptTemplate)current.Instance.Payload.GetObject(ctx);
                template.CreateReceipt();
                return(true);
            }
            else
            {
                var msg = string.Format("Payload {0} is not a ReceiptTemplate", payload);
                Logging.Log.Warn(msg);
                current.Instance.AddLogEntry(msg);
                return(false);
            }
        }
Exemplo n.º 7
0
        public static bool AddResponsibles(wf.Action action, wf.ParameterizedActionDefinition parameter, wf.State current, Identity identity)
        {
            var sParameter = (wf.AddResponsiblesActionDefinition)parameter;

            if (sParameter.ClearResponsibles)
            {
                current.Groups.Clear();
                current.Persons.Clear();
            }

            foreach (var grp in sParameter.Groups)
            {
                current.Groups.Add(grp);
            }

            foreach (var person in sParameter.Persons)
            {
                current.Persons.Add(person);
            }

            return(true);
        }
 public ActionGraphViewModel(IViewModelDependencies appCtx, IZetboxContext dataCtx, ViewModel parent, wf.ParameterizedActionDefinition action)
     : base(appCtx, dataCtx, parent)
 {
     Action = action;
 }
Exemplo n.º 9
0
 public void ExecuteAction(wf.ParameterizedActionDefinition action)
 {
     action.Action.Execute(action, State);
 }