コード例 #1
0
        private IExplorerItemModel MapData(IExplorerItem item, IEnvironmentRepository environmentRepository, Guid environmentId)
        {
            if (item == null)
            {
                return(null);
            }
            string displayname = item.DisplayName;
            // ReSharper disable ImplicitlyCapturedClosure
            // ReSharper disable RedundantAssignment
            IEnvironmentModel environmentModel = environmentRepository.FindSingle(model => GetEnvironmentModel(model, item, environmentId));

            if ((item.ResourceType == ResourceType.Server && environmentId != Guid.Empty) || (environmentId == Guid.Empty && displayname.ToLower() == Environment.MachineName.ToLower()))
            {
                environmentModel = environmentRepository.FindSingle(model => GetEnvironmentModel(model, item, environmentId));
                if (environmentModel != null && environmentModel.Connection != null)
                {
                    displayname = environmentModel.DisplayName;
                }
            }

            return(new ExplorerItemModel
            {
                Children = item.Children == null ? new ObservableCollection <IExplorerItemModel>() : new ObservableCollection <IExplorerItemModel>(item.Children.Select(i => MapData(i, environmentRepository, environmentId))),
                DisplayName = displayname,
                ResourceType = item.ResourceType,
                ResourceId = item.ResourceId,
                Permissions = item.Permissions,
                ResourcePath = item.ResourcePath,
                VersionInfo = item.VersionInfo
            });
            // ReSharper restore ImplicitlyCapturedClosure
        }
コード例 #2
0
        // BUG 9735 - 2013.06.22 - TWR : refactored
        void AddItemToTree(IDebugState content)
        {
            var environmentId = content.EnvironmentID;
            var isRemote      = environmentId != Guid.Empty;

            if (isRemote)
            {
                Thread.Sleep(500);
            }
            if (isRemote)
            {
                var remoteEnvironmentModel = _environmentRepository.FindSingle(model => model.ID == environmentId);
                if (remoteEnvironmentModel != null)
                {
                    if (!remoteEnvironmentModel.IsConnected)
                    {
                        remoteEnvironmentModel.Connect();
                    }
                    if (content.ParentID != Guid.Empty)
                    {
                        if (remoteEnvironmentModel.AuthorizationService != null)
                        {
                            var remoteResourcePermissions = remoteEnvironmentModel.AuthorizationService.GetResourcePermissions(content.OriginatingResourceID);
                            if (!remoteResourcePermissions.HasFlag(Permissions.View))
                            {
                                return;
                            }
                        }
                    }
                }
            }
            _contentItems.Add(content);

            lock (_syncContext)
            {
                if (_isRebuildingTree)
                {
                    return;
                }
            }

            var application = Application.Current;

            if (application != null)
            {
                var dispatcher        = application.Dispatcher;
                var contentToDispatch = content;
                if (dispatcher != null && dispatcher.CheckAccess())
                {
                    dispatcher.Invoke(() => AddItemToTreeImpl(contentToDispatch));
                }
            }
            else
            {
                AddItemToTreeImpl(content);
            }
        }
コード例 #3
0
        public ServiceDesignerViewModel(ModelItem modelItem, IContextualResourceModel rootModel, IEnvironmentRepository environmentRepository, IEventAggregator eventPublisher, IAsyncWorker asyncWorker)
            : base(modelItem)
        {
            AddTitleBarEditToggle();
            AddTitleBarMappingToggle();

            // PBI 6690 - 2013.07.04 - TWR : added
            // BUG 9634 - 2013.07.17 - TWR : resourceModel may be null if it is a remote resource whose environment is not connected!
            VerifyArgument.IsNotNull("rootModel", rootModel);
            VerifyArgument.IsNotNull("environmentRepository", environmentRepository);
            VerifyArgument.IsNotNull("eventPublisher", eventPublisher);
            VerifyArgument.IsNotNull("asyncWorker", asyncWorker);

            _worker         = asyncWorker;
            _eventPublisher = eventPublisher;
            eventPublisher.Subscribe(this);
            ButtonDisplayValue = DoneText;

            ShowExampleWorkflowLink = Visibility.Collapsed;
            RootModel = rootModel;
            DesignValidationErrors = new ObservableCollection <IErrorInfo>();
            FixErrorsCommand       = new DelegateCommand(o =>
            {
                FixErrors();
                IsFixed = IsWorstErrorReadOnly;
            });
            DoneCommand          = new DelegateCommand(o => Done());
            DoneCompletedCommand = new DelegateCommand(o => DoneCompleted());

            InitializeDisplayName();
            InitializeProperties();
            InitializeImageSource();

            IsAsyncVisible       = ActivityTypeToActionTypeConverter.ConvertToActionType(Type) == Common.Interfaces.Core.DynamicServices.enActionType.Workflow;
            OutputMappingEnabled = !RunWorkflowAsync;

            // When the active environment is not local, we need to get smart around this piece of logic.
            // It is very possible we are treating a remote active as local since we cannot logically assign
            // an environment id when this is the case as it will fail with source not found since the remote
            // does not contain localhost's connections ;)
            var activeEnvironment = environmentRepository.ActiveEnvironment;

            if (EnvironmentID == Guid.Empty && !activeEnvironment.IsLocalHostCheck())
            {
                _environment = activeEnvironment;
            }
            else
            {
                var environment = environmentRepository.FindSingle(c => c.ID == EnvironmentID);
                if (environment == null)
                {
                    IList <IEnvironmentModel> environments = EnvironmentRepository.Instance.LookupEnvironments(activeEnvironment);
                    environment = environments.FirstOrDefault(model => model.ID == EnvironmentID);
                }
                _environment = environment;
            }


            InitializeValidationService(_environment);
            if (!InitializeResourceModel(_environment))
            {
                return;
            }
            if (!IsDeleted)
            {
                // MUST InitializeMappings() first!
                InitializeMappings();
                InitializeLastValidationMemo(_environment);
                if (IsItemDragged.Instance.IsDragged)
                {
                    Expand();
                    IsItemDragged.Instance.IsDragged = false;
                }
            }
            if (_environment != null)
            {
                _environment.AuthorizationServiceSet += OnEnvironmentOnAuthorizationServiceSet;
                AuthorizationServiceOnPermissionsChanged(null, null);
            }
        }
コード例 #4
0
        private IExplorerItemModel MapData(IExplorerItem item, IEnvironmentRepository environmentRepository, Guid environmentId)
        {
            if(item == null)
            {
                return null;
            }
            string displayname = item.DisplayName;
            // ReSharper disable ImplicitlyCapturedClosure
            // ReSharper disable RedundantAssignment
            IEnvironmentModel environmentModel = environmentRepository.FindSingle(model => GetEnvironmentModel(model, item, environmentId));
            if((item.ResourceType == ResourceType.Server && environmentId != Guid.Empty) || (environmentId == Guid.Empty && displayname.ToLower() == Environment.MachineName.ToLower()))
            {
                environmentModel = environmentRepository.FindSingle(model => GetEnvironmentModel(model, item, environmentId));
                if(environmentModel != null && environmentModel.Connection != null)
                {
                    displayname = environmentModel.DisplayName;
                }
            }

            return new ExplorerItemModel
            {
                Children = item.Children == null ? new ObservableCollection<IExplorerItemModel>() : new ObservableCollection<IExplorerItemModel>(item.Children.Select(i => MapData(i, environmentRepository, environmentId))),
                DisplayName = displayname,
                ResourceType = item.ResourceType,
                ResourceId = item.ResourceId,
                Permissions = item.Permissions,
                ResourcePath = item.ResourcePath,
                VersionInfo = item.VersionInfo
            };
            // ReSharper restore ImplicitlyCapturedClosure
        }
コード例 #5
0
        // BUG 9735 - 2013.06.22 - TWR : refactored
        void AddItemToTree(IDebugState content)
        {
            if (content.StateType == StateType.Duration)
            {
                var item = _contentItems.FirstOrDefault(a => a.WorkSurfaceMappingId == content.WorkSurfaceMappingId);

                if (item != null)
                {
                    item.EndTime = content.EndTime;
                    //RebuildTree();
                }
            }
            else
            {
                var environmentId = content.EnvironmentID;
                var isRemote      = environmentId != Guid.Empty;
                if (isRemote)
                {
                    Thread.Sleep(500);
                }
                if (isRemote)
                {
                    var remoteEnvironmentModel = _environmentRepository.FindSingle(model => model.ID == environmentId);
                    if (remoteEnvironmentModel != null)
                    {
                        if (content.Server == "localhost")
                        {
                            content.Server = remoteEnvironmentModel.Name;
                        }
                        if (!remoteEnvironmentModel.IsConnected)
                        {
                            remoteEnvironmentModel.Connect();
                        }
                        if (content.ParentID != Guid.Empty)
                        {
                            if (remoteEnvironmentModel.AuthorizationService != null)
                            {
                                var remoteResourcePermissions = remoteEnvironmentModel.AuthorizationService.GetResourcePermissions(content.OriginatingResourceID);
                                if (!remoteResourcePermissions.HasFlag(Permissions.View))
                                {
                                    return;
                                }
                            }
                        }
                    }
                }
                var debugState = _contentItems.FirstOrDefault(state => state.DisconnectedID == content.DisconnectedID);
                if (debugState == null)
                {
                    _contentItems.Add(content);
                }
                else
                {
                    return;
                }
                lock (_syncContext)
                {
                    if (_isRebuildingTree)
                    {
                        return;
                    }
                }

                var application = Application.Current;
                if (application != null)
                {
                    var dispatcher        = application.Dispatcher;
                    var contentToDispatch = content;
                    if (dispatcher != null && dispatcher.CheckAccess())
                    {
                        dispatcher.Invoke(() => AddItemToTreeImpl(contentToDispatch));
                    }
                }
                else
                {
                    AddItemToTreeImpl(content);
                }
            }
        }