Ejemplo n.º 1
0
        public bool CheckSourceMissing()
        {
            if (ResourceModel != null && _environment != null)
            {
                var    resourceModel = ResourceModel;
                string srcId;
                var    workflowXml = resourceModel?.WorkflowXaml;
                try
                {
                    var xe = workflowXml?.Replace("&", "&").ToXElement();
                    srcId = xe?.AttributeSafe("SourceID");
                }
                catch (XmlException xe)
                {
                    Dev2Logger.Error(xe);
                    srcId = workflowXml.ExtractXmlAttributeFromUnsafeXml("SourceID=\"");
                }

                Guid sourceId;
                if (Guid.TryParse(srcId, out sourceId))
                {
                    SourceId = sourceId;
                    var sourceResource = _environment.ResourceRepository.LoadContextualResourceModel(sourceId);
                    if (sourceResource == null)
                    {
                        ValidationMemoManager.UpdateLastValidationMemoWithSourceNotFoundError();
                        return(false);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
 private void Done()
 {
     if (!IsWorstErrorReadOnly)
     {
         ValidationMemoManager.FixErrors();
     }
 }
Ejemplo n.º 3
0
 public override void Validate()
 {
     Errors = new List <IActionableErrorInfo>();
     if (HasNoPermission())
     {
         var errorInfos = ValidationMemoManager.DesignValidationErrors.Where(info => info.FixType == FixType.InvalidPermissions);
         Errors = new List <IActionableErrorInfo> {
             new ActionableErrorInfo(errorInfos.ToList()[0], () => { })
         };
     }
     else
     {
         ValidationMemoManager.RemovePermissionsError();
     }
 }
Ejemplo n.º 4
0
        void UpdateDesignerAfterResourceLoad(IServerRepository serverRepository)
        {
            if (!IsDeleted)
            {
                MappingManager.InitializeMappings();
                ValidationMemoManager.InitializeLastValidationMemo(_environment);
                if (IsItemDragged.Instance.IsDragged)
                {
                    Expand();
                    IsItemDragged.Instance.IsDragged = false;
                }
            }
            var environmentModel = serverRepository.Get(EnvironmentID);

            if (EnvironmentID == Guid.Empty)
            {
                environmentModel = serverRepository.ActiveServer;
            }
            if (environmentModel?.Connection?.WebServerUri != null)
            {
                var servUri = new Uri(environmentModel.Connection.WebServerUri.ToString());
                var host    = servUri.Host;
                if (!host.Equals(FriendlySourceName, StringComparison.InvariantCultureIgnoreCase))
                {
                    FriendlySourceName = host;
                }
            }

            InitializeProperties();
            if (_environment != null)
            {
                _environment.AuthorizationServiceSet += OnEnvironmentOnAuthorizationServiceSet;
                AuthorizationServiceOnPermissionsChanged(null, null);
            }
            IsLoading = false;
            if (ResourceModel == null)
            {
                ValidationMemoManager.UpdateLastValidationMemoWithSourceNotFoundError();
            }
        }
Ejemplo n.º 5
0
        private void AuthorizationServiceOnPermissionsChanged(object sender, EventArgs eventArgs)
        {
            ValidationMemoManager.RemovePermissionsError();

            var hasNoPermission = HasNoPermission();

            if (hasNoPermission)
            {
                var memo = new DesignValidationMemo
                {
                    InstanceID = UniqueID,
                    IsValid    = false,
                };
                memo.Errors.Add(new ErrorInfo
                {
                    InstanceID = UniqueID,
                    ErrorType  = ErrorType.Critical,
                    FixType    = FixType.InvalidPermissions,
                    Message    = ErrorResource.NoPermissionToExecuteTool
                });
                MappingManager.UpdateLastValidationMemo(memo);
            }
        }
Ejemplo n.º 6
0
        public ServiceDesignerViewModel(ModelItem modelItem, IContextualResourceModel rootModel, IServerRepository serverRepository, IEventAggregator eventPublisher, IAsyncWorker asyncWorker)
            : base(modelItem)
        {
            ValidationMemoManager = new ValidationMemoManager(this);
            MappingManager        = new MappingManager(this);
            if (modelItem.ItemType != typeof(DsfDatabaseActivity) && modelItem.ItemType != typeof(DsfPluginActivity) && modelItem.ItemType != typeof(DsfWebserviceActivity))
            {
                AddTitleBarEditToggle();
            }
            AddTitleBarMappingToggle();

            VerifyArgument.IsNotNull("rootModel", rootModel);
            VerifyArgument.IsNotNull("environmentRepository", serverRepository);
            VerifyArgument.IsNotNull("eventPublisher", eventPublisher);
            VerifyArgument.IsNotNull("asyncWorker", asyncWorker);

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

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

            InitializeDisplayName();

            InitializeImageSource();

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

            var activeEnvironment = serverRepository.ActiveServer;

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

            ValidationMemoManager.InitializeValidationService(_environment);
            IsLoading = true;
            _worker.Start(() => InitializeResourceModel(_environment), b =>
            {
                if (b)
                {
                    UpdateDesignerAfterResourceLoad(serverRepository);
                }
            });

            ViewComplexObjectsCommand = new RelayCommand(item =>
            {
                ViewJsonObjects(item as IComplexObjectItemModel);
            }, CanViewComplexObjects);
        }