Esempio n. 1
0
 public override void Complete(WorkItem workItem, WorkflowProvider provider)
 {
     completed.Add(workItem);
     started.Remove(workItem);
     processing.Remove(workItem);
     provider.EndWorkItem(this, workItem);
 }
Esempio n. 2
0
        public void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            Tracer.Browse        -= Tracer_Browse;
            Session.AfterRequest -= Session_AfterRequest;
            Session.Disconnected -= Session_Disconnected;

            var sessionProvider = WorkflowProvider.GetOrCreate().RSessions;

            sessionProvider.BrokerChanged -= SessionProvider_BrokerChanged;

            _events  = null;
            _program = null;

            MainThread.Dispose();
            MainThread = null;

            Tracer = null;

            ExitBrowserAsync(Session).DoNotWait();
            Session = null;

            IsDisposed = true;
        }
Esempio n. 3
0
        public MainWindow()
        {
            InitializeComponent();

            var eventBroker       = new EventBroker();
            var messageRepository = new FileMessageProvider();

            Type[] events =
            {
                typeof(MessageNofiticationEvent),
                typeof(VisualNotificationEvent)
            };
            var eventAgent = new EventAgent();

            foreach (var eventType in events)
            {
                eventAgent.Register(eventType);
            }

            var debugTracking = new DebugTrackingParticipant();
            var agent         = new MessageAgent();

            IPrototype[] messages =
            {
                new MessageInfo(messageRepository),
                new PowerSupplayVisualComponent(eventBroker,agent,         eventAgent),
                new MessageError(messageRepository,         eventBroker),
            };

            foreach (var message in messages)
            {
                agent.RegisterPrototype(message);
            }

            RegisterComponentTemplate(messages);

            var workflowProvide = new WorkflowProvider(SynchronizationContext.Current, eventBroker, debugTracking, agent, eventAgent);

            var model = new WorkflowRunner(workflowProvide, eventBroker);

            var componentViewCollection = new ComponentViewCollection();
            var userNotificationView    = new UserNotificationView();

            var view = new EnableViewModel(model, componentViewCollection, userNotificationView, eventBroker);

            eventBroker.Register(componentViewCollection);
            eventBroker.Register(userNotificationView);
            eventBroker.Register(view);
            eventBroker.Register(model);

            // ioc for each IStartable.Start()

            //this.Closing += view.ViewClosing;
            //this.Closed += view.ViewClosed;

            DataContext = view;
        }
Esempio n. 4
0
        int IDebugEngine2.Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms, IDebugEventCallback2 pCallback, enum_ATTACH_REASON dwReason)
        {
            ThrowIfDisposed();

            if (rgpPrograms.Length != 1)
            {
                throw new ArgumentException("Zero or more than one programs", nameof(rgpPrograms));
            }

            _program = rgpPrograms[0] as RDebugPortSupplier.DebugProgram;
            if (_program == null)
            {
                throw new ArgumentException("rgpPrograms[0] must be an " + nameof(RDebugPortSupplier.DebugProgram), nameof(rgpPrograms));
            }
            Marshal.ThrowExceptionForHR(_program.GetProgramId(out _programId));

            _events     = pCallback;
            Session     = _program.Session;
            Tracer      = TaskExtensions.RunSynchronouslyOnUIThread(ct => Session.TraceExecutionAsync(ct));
            MainThread  = new AD7Thread(this);
            IsConnected = true;

            // Enable breakpoint instrumentation.
            TaskExtensions.RunSynchronouslyOnUIThread(ct => Tracer.EnableBreakpointsAsync(true, ct));

            // Send notification after acquiring the session - we need it in case there were any breakpoints pending before
            // the attach, in which case we'll immediately get breakpoint creation requests as soon as we send these, and
            // we will need the session to process them.
            AD7EngineCreateEvent.Send(this);
            AD7ProgramCreateEvent.Send(this);
            Send(new AD7LoadCompleteEvent(), AD7LoadCompleteEvent.IID);

            var sessionProvider = WorkflowProvider.GetOrCreate().RSessions;

            sessionProvider.BrokerChanged += SessionProvider_BrokerChanged;

            // Register event handlers after notifying VS that debug engine has loaded. This order is important because
            // we may get a Browse event immediately, and we want to raise a breakpoint notification in response to that
            // to pause the debugger - but it will be ignored unless the engine has reported its creation.
            // Also, AfterRequest must be registered before Browse, so that we never get in a situation where we get
            // Browse but not AfterRequest that follows it because of a race between raising and registration.
            Session.AfterRequest += Session_AfterRequest;
            Session.Disconnected += Session_Disconnected;

            // If we're already at the Browse prompt, registering the handler will result in its immediate invocation.
            // We want to handle that fully before we process any following AfterRequest event to avoid concurrency issues
            // where we pause and never resume, so hold the lock while adding the handler.
            lock (_browseLock) {
                Tracer.Browse += Tracer_Browse;
            }

            return(VSConstants.S_OK);
        }
Esempio n. 5
0
        public AD7Engine()
        {
            var compModel = (IComponentModel)Package.GetGlobalService(typeof(SComponentModel));

            if (compModel == null)
            {
                throw new InvalidOperationException(Invariant($"{typeof(AD7Engine).FullName} requires {nameof(IComponentModel)} global service"));
            }

            compModel.DefaultCompositionService.SatisfyImportsOnce(this);
            _workflow = WorkflowProvider.GetOrCreate();
        }
Esempio n. 6
0
 public NewSessionFormUi(SessionProvider sessionProvider)
 {
     InitializeComponent();
     _sessionProvider  = sessionProvider;
     _workflowProvider = new WorkflowProvider();
 }
Esempio n. 7
0
        public override Workflow Get(Repository repository, string name)
        {
            Workflow workflow = new Workflow(repository, name);

            return(WorkflowProvider.Get(workflow));
        }
Esempio n. 8
0
 public virtual IEnumerable <Workflow> All(Repository repository)
 {
     return(WorkflowProvider.All(repository));
 }
Esempio n. 9
0
 public EntryStation(ILogger logger, IMosaicSampleWorkflowFactory workflowFactory, WorkflowProvider workflowProvider)
 {
     _logger           = logger;
     _workflowFactory  = workflowFactory;
     _workflowProvider = workflowProvider;
 }
        public EntityWorkflow CreateWorkflow()
        {
            WorkflowProvider workflowProvider = new WorkflowProvider
            {
                Guid                 = _guid,
                Name                 = _name,
                PropertyName         = _propertyName,
                EntitySet            = _entitySet,
                StageListGuid        = _stageListGuid,
                StagePropertyGuid    = _stagePropertyGuid,
                Types                = _types.ToArray(),
                ShowInLinks          = new HashSet <Guid>(_showInLinks),
                HistoryConfiguration = _historyCofiguration
            };

            EntityWorkflow result = new EntityWorkflow(workflowProvider);

            ValueList valueList;

            if (_stageListGuid == Guid.Empty)
            {
                EntitySetScheme scheme = _entitySet.GetScheme();
                if (_types.Count == 0)
                {
                    valueList = (scheme.Properties.Find(_stagePropertyGuid)?.Format as ValueListPropertyFormat)?.ValueList?.GetList();
                }
                else
                {
                    EntityType type = _types.SelectMany(t => t.GetTypes(scheme.Types)).FirstOrDefault();
                    valueList = (type?.Properties.Find(_stagePropertyGuid)?.Format as ValueListPropertyFormat)?.ValueList?.GetList();
                }
            }
            else
            {
                valueList = ValueList.GetValueList(_entitySet.Connection, _stageListGuid);
                if (valueList == null)
                {
                    throw new ModelException(ErrorLevel.Warning, "Не найден список значений {0}", _stageListGuid);
                }
            }

            ILookup <object, ValueListItem> items = valueList?.ToLookup(i => i.WorkflowValue);

            List <EntityWorkflowStage> stages = new List <EntityWorkflowStage>();

            foreach (KeyValuePair <object, IEntityWorkflowStage> source in _stages)
            {
                StageProvider stageProvider = new StageProvider
                {
                    Id   = source.Key,
                    Item = items?[source.Key].FirstOrDefault()
                };
                stages.Add(new EntityWorkflowStage(result, stageProvider));
            }
            result.Stages = stages;

            Dictionary <object, List <EntityWorkflowTransition> > transitionsTo   = stages.ToDictionary(s => s.Id, s => new List <EntityWorkflowTransition>());
            Dictionary <object, List <EntityWorkflowTransition> > transitionsFrom = stages.ToDictionary(s => s.Id, s => new List <EntityWorkflowTransition>());

            result.Transitions = _transitions.OfType <TransitionInfo>().Select(
                t => t.CreateTransition(result, workflowProvider, transitionsTo, transitionsFrom)).ToList();

            foreach (EntityWorkflowStage stage in stages)
            {
                stage.SetTransitionsTo(transitionsTo[stage.Id]);
                stage.SetTransitionsFrom(transitionsFrom[stage.Id]);
            }

            return(result);
        }
        public override System.Collections.ICollection Scan()
        {
            System.Collections.ArrayList result = new System.Collections.ArrayList();

            DateTime dt = DateTime.Now.AddDays(-Days);


            WorkflowProvider wProvider = Sitecore.Context.ContentDatabase.WorkflowProvider as WorkflowProvider;

            if (wProvider == null)
            {
                return(result);
            }

            string stConnection =
                Sitecore.Configuration.Settings.GetConnectionString(Sitecore.Context.ContentDatabase.Name);

            SqlConnection conn    = null;
            SqlCommand    command = null;
            SqlDataReader reader  = null;

            try
            {
                conn                = new SqlConnection(stConnection);
                command             = conn.CreateCommand();
                command.CommandText = "SELECT DISTINCT ItemID FROM WorkflowHistory WHERE Date > @date";
                command.Parameters.Add(
                    new SqlParameter("@date", System.Data.SqlDbType.DateTime)).Value = dt;

                conn.Open();
                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    Guid gId = reader.GetGuid(0);

                    Item item = Sitecore.Context.ContentDatabase.GetItem(new Sitecore.Data.ID(gId));

                    foreach (var wEvent in wProvider.HistoryStore.GetHistory(item).Where(hi => hi.Date > dt && hi.NewState != hi.OldState))
                    {
                        WorkflowEventCustom wec = new WorkflowEventCustom(item, wEvent);
                        result.Add(wec);
                    }
                }
            }
            catch (Exception ex)
            {
                Sitecore.Diagnostics.Log.Error(ex.Message, this);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (conn != null)
                {
                    conn.Close();
                }
            }

            return(result);
        }
Esempio n. 12
0
 public RHostScript(IServiceContainer services, bool async)
 {
     Services         = services;
     WorkflowProvider = Services.GetService <IRInteractiveWorkflowProvider>();
     Workflow         = WorkflowProvider.GetOrCreate();
 }
Esempio n. 13
0
            public EntityWorkflowTransition CreateTransition(EntityWorkflow workflow, WorkflowProvider workflowProvider,
                                                             Dictionary <object, List <EntityWorkflowTransition> > transitionsTo,
                                                             Dictionary <object, List <EntityWorkflowTransition> > transitionsFrom)
            {
                if (_toStage == null)
                {
                    throw new ModelException(ErrorLevel.Warning, "Не указана стадия для перехода");
                }

                TransitionProvider transitionProvider = new TransitionProvider
                {
                    Workflow                 = workflowProvider,
                    FromStageIds             = new HashSet <object>(_fromStages.Select(s => s.StageId)),
                    ToStage                  = (StageProvider)workflow.GetStage(_toStage.StageId).Provider,
                    CommandText              = _commandText,
                    IconImageGuid            = _iconImageGuid.GetValueOrDefault(),
                    IconImageColor           = _iconImageColor,
                    CommandPlacement         = _commandPlacement,
                    MultipleSelectionEnabled = _multipleSelectionEnabled,
                    Roles = _roles ?? new IEntityWorkflowRole[0],
                    ConfirmationTextProvider = _confirmationTextProvider,
                    InputFormGenerate        = _inputFormGenerate,
                    CanExecute      = _canExecute,
                    Validators      = _validators,
                    OnChanging      = _onChanging,
                    OnChangingAsync = _onChangingAsync,
                    OnChanged       = _onChanged,
                    OnLog           = _onLog
                };

                EntityWorkflowTransition result = new EntityWorkflowTransition(workflow, transitionProvider);

                transitionsTo[_toStage.StageId].Add(result);
                foreach (IEntityWorkflowStage stage in _fromStages)
                {
                    transitionsFrom[stage.StageId].Add(result);
                }
                return(result);
            }
Esempio n. 14
0
 public override void Unsuspend(WorkItem item, WorkflowProvider provider)
 {
     provider.Send("WorkItemAction Unsuspend " + this.YawlId + " " + item.taskID);
 }
Esempio n. 15
0
 public override void Delegate(WorkItem item, WorkAgent other, WorkflowProvider provider)
 {
     delegated.Add(item);
     provider.Send("WorkItemAction Delegate " + this.YawlId + " " + item.taskID + " " + other.AgentId);
 }
Esempio n. 16
0
 public override void Accept(WorkItem item, WorkflowProvider provider)
 {
     provider.Send("WorkItemAction Accept " + this.YawlId + " " + item.taskID);
 }