Пример #1
0
        public static void SetActivityProperties(IContextualResourceModel resource, ref DsfActivity activity)
        {
            if (resource.WorkflowXaml != null && resource.WorkflowXaml.Length > 0)
            {
                var startIdx = resource.WorkflowXaml.IndexOf("<HelpLink>", 0, true);

                if (startIdx >= 0)
                {
                    var endIdx = resource.WorkflowXaml.IndexOf("</HelpLink>", startIdx, true);

                    if (endIdx > 0)
                    {
                        startIdx += 10;
                        var len = endIdx - startIdx;

                        activity.HelpLink = resource.WorkflowXaml.Substring(startIdx, len);
                    }
                }
            }

            if (resource.Environment != null)
            {
                activity.FriendlySourceName = resource.Environment.Name;
            }
            activity.IsWorkflow = true;
            activity.Type       = "Workflow";
        }
 public void ShowResourceChanged(IContextualResourceModel resource, IList<string> numberOfDependants, IResourceChangedDialog resourceChangedDialog = null)
 {
     if(resource == null)
     {
         throw new ArgumentNullException("resource");
     }
     if(numberOfDependants == null)
     {
         throw new ArgumentNullException("numberOfDependants");
     }
     if(resourceChangedDialog == null)
     {
         resourceChangedDialog = new ResourceChangedDialog(resource, numberOfDependants.Count);
     }
     resourceChangedDialog.ShowDialog();
     if(resourceChangedDialog.OpenDependencyGraph)
     {
         if(numberOfDependants.Count == 1)
         {
             var resourceModel = resource.Environment.ResourceRepository.FindSingle(model => model.ResourceName == numberOfDependants[0]);
             if(resourceModel != null)
             {
                 WorkflowDesignerUtils.EditResource(resourceModel, _eventPublisher);
             }
         }
         else
         {
             Dev2Logger.Log.Info("Publish message of type - " + typeof(ShowReverseDependencyVisualizer));
             _eventPublisher.Publish(new ShowReverseDependencyVisualizer(resource));
         }
     }
 }
 public SaveUnsavedWorkflowMessage(IContextualResourceModel resourceModel, string resourceName, string resourceCategory, bool keepTabOpen)
 {
     ResourceModel    = resourceModel;
     ResourceName     = resourceName;
     ResourceCategory = resourceCategory;
     KeepTabOpen      = keepTabOpen;
 }
Пример #4
0
 public void ShowResourceChanged(IContextualResourceModel resource, IList <string> numberOfDependants, IResourceChangedDialog resourceChangedDialog = null)
 {
     if (resource == null)
     {
         throw new ArgumentNullException("resource");
     }
     if (numberOfDependants == null)
     {
         throw new ArgumentNullException("numberOfDependants");
     }
     if (resourceChangedDialog == null)
     {
         resourceChangedDialog = new ResourceChangedDialog(resource, numberOfDependants.Count);
     }
     resourceChangedDialog.ShowDialog();
     if (resourceChangedDialog.OpenDependencyGraph)
     {
         if (numberOfDependants.Count == 1)
         {
             var resourceModel = resource.Environment.ResourceRepository.FindSingle(model => model.ResourceName == numberOfDependants[0]);
             if (resourceModel != null)
             {
                 WorkflowDesignerUtils.EditResource(resourceModel, _eventPublisher);
             }
         }
         else
         {
             Dev2Logger.Log.Info("Publish message of type - " + typeof(ShowReverseDependencyVisualizer));
             _eventPublisher.Publish(new ShowReverseDependencyVisualizer(resource));
         }
     }
 }
        public void AddWorkspaceItem(IContextualResourceModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            var workspaceItem = WorkspaceItems.FirstOrDefault(wi => wi.ID == model.ID && wi.EnvironmentID == model.Environment.EnvironmentID);

            if (workspaceItem != null)
            {
                return;
            }

            var context = model.Environment.Connection;

            WorkspaceItems.Add(new WorkspaceItem(context.WorkspaceID, context.ServerID, model.Environment.EnvironmentID, model.ID)
            {
                ServiceName     = model.ResourceName,
                IsWorkflowSaved = model.IsWorkflowSaved,
                ServiceType     =
                    model.ResourceType == ResourceType.Source
                        ? WorkspaceItem.SourceServiceType
                        : WorkspaceItem.ServiceServiceType,
            });
            Write();
            model.OnResourceSaved += UpdateWorkspaceItemIsWorkflowSaved;
        }
 public static void SetAttachedProperties(WorkflowDesignerWindow workflowDesignerWindow,
                                           IContextualResourceModel resource, string iconPath)
 {
     UIElementTitleProperty.SetTitle(workflowDesignerWindow, resource.ResourceName);
     UIElementTabActionContext.SetTabActionContext(workflowDesignerWindow, WorkSurfaceContext.Workflow);
     UIElementImageProperty.SetImage(workflowDesignerWindow, iconPath);
 }
Пример #7
0
        public static Uri GetWorkflowUri(IContextualResourceModel resourceModel, string xmlData, UrlType urlType)
        {
            if (resourceModel == null || resourceModel.Environment == null || resourceModel.Environment.Connection == null || !resourceModel.Environment.IsConnected)
            {
                return(null);
            }
            var environmentConnection = resourceModel.Environment.Connection;

            string urlExtension = "xml";

            switch (urlType)
            {
            case UrlType.XML:
                break;

            case UrlType.JSON:
                urlExtension = "json";
                break;

            default:
                throw new ArgumentOutOfRangeException("urlType");
            }

            var relativeUrl = string.Format("/services/{0}.{1}?", resourceModel.Category, urlExtension);

            relativeUrl += xmlData;
            relativeUrl += "&wid=" + environmentConnection.WorkspaceID;
            Uri url;

            Uri.TryCreate(environmentConnection.WebServerUri, relativeUrl, out url);
            return(url);
        }
Пример #8
0
        public static Uri GetWorkflowUri(this IContextualResourceModel resourceModel, string xmlData, UrlType urlType, bool addworkflowId)
        {
            if (resourceModel?.Environment?.Connection == null || !resourceModel.Environment.IsConnected)
            {
                return(null);
            }
            var environmentConnection = resourceModel.Environment.Connection;

            var urlExtension = GetUriExtension(urlType);

            var category = resourceModel.Category;

            if (string.IsNullOrEmpty(category))
            {
                category = resourceModel.ResourceName;
            }
            var relativeUrl = $"/secure/{category}.{urlExtension}";

            if (urlType != UrlType.API && urlType != UrlType.Tests)
            {
                relativeUrl += "?" + xmlData;
                if (addworkflowId)
                {
                    relativeUrl += "&wid=" + environmentConnection.WorkspaceID;
                }
            }

            Uri.TryCreate(environmentConnection.WebServerUri, relativeUrl, out Uri url);
            return(url);
        }
Пример #9
0
        public static string GetIconPath(IContextualResourceModel resource)
        {
            string iconPath = resource.IconPath;

            if (string.IsNullOrEmpty(resource.UnitTestTargetWorkflowService))
            {
                if (string.IsNullOrEmpty(resource.IconPath))
                {
                    iconPath = ResourceType.WorkflowService.GetIconLocation();
                }
                else if (!resource.IconPath.Contains(StringResources.Pack_Uri_Application_Image))
                {
                    var imageUriConverter = new ContextualResourceModelToImageConverter();
                    var iconUri           = imageUriConverter.Convert(resource, null, null, null) as Uri;
                    if (iconUri != null)
                    {
                        iconPath = iconUri.ToString();
                    }
                }
            }
            else
            {
                iconPath = string.IsNullOrEmpty(resource.IconPath)
                               ? string.Empty
                               : resource.IconPath;
            }
            return(iconPath);
        }
Пример #10
0
        public static void Send(IContextualResourceModel resourceModel, string payload, IAsyncWorker asyncWorker)
        {
            if (resourceModel?.Environment == null || !resourceModel.Environment.IsConnected)
            {
                return;
            }

            var clientContext = resourceModel.Environment.Connection;

            if (clientContext == null)
            {
                return;
            }
            asyncWorker.Start(() =>
            {
                var controller = new CommunicationController
                {
                    ServiceName    = string.IsNullOrEmpty(resourceModel.Category) ? resourceModel.ResourceName : resourceModel.Category,
                    ServicePayload =
                    {
                        ResourceID = resourceModel.ID
                    },
                };
                controller.AddPayloadArgument("DebugPayload", payload);
                controller.ExecuteCommand <string>(clientContext, clientContext.WorkspaceID);
            }, () => { });
        }
Пример #11
0
 public void BringItemIntoView(IContextualResourceModel item)
 {
     if (item != null && item.Environment != null)
     {
         BringItemIntoView(item.Environment.ID, item.ID);
     }
 }
Пример #12
0
        public IServiceTestModelTO ExecuteTest(IContextualResourceModel resourceModel, string testName)
        {
            if (resourceModel?.Environment == null || !resourceModel.Environment.IsConnected)
            {
                var testRunReuslt = new ServiceTestModelTO {
                    TestFailing = true
                };
                return(testRunReuslt);
            }

            var clientContext = resourceModel.Environment.Connection;

            if (clientContext == null)
            {
                var testRunReuslt = new ServiceTestModelTO {
                    TestFailing = true
                };
                return(testRunReuslt);
            }
            var controller = new CommunicationController
            {
                ServiceName    = string.IsNullOrEmpty(resourceModel.Category) ? resourceModel.ResourceName : resourceModel.Category,
                ServicePayload = { ResourceID = resourceModel.ID }
            };

            controller.AddPayloadArgument("ResourceID", resourceModel.ID.ToString());
            controller.AddPayloadArgument("IsDebug", true.ToString());
            controller.ServicePayload.TestName = testName;
            var res = controller.ExecuteCommand <IServiceTestModelTO>(clientContext, GlobalConstants.ServerWorkspaceID);

            return(res);
        }
        public static DsfActivity CreateDsfActivity(IContextualResourceModel resource, DsfActivity activity,
                    bool ifNullCreateNew, IEnvironmentRepository environmentRepository, bool isDesignerLocalhost)
        {
            var activityToUpdate = activity;
            if(activityToUpdate == null)
            {
                if(ifNullCreateNew)
                {
                    activityToUpdate = new DsfActivity();
                }
                else
                {
                    return null;
                }
            }

            if(resource != null)
            {
                var activeEnvironment = environmentRepository.ActiveEnvironment;
                activityToUpdate.ResourceID = resource.ID;
                SetCorrectEnvironmentId(resource, activityToUpdate, isDesignerLocalhost, activeEnvironment);
                activityToUpdate = SetActivityProperties(resource, activityToUpdate);
            }

            activityToUpdate.ExplicitDataList = null;
            return activityToUpdate;
        }
Пример #14
0
        public DebugOutputViewModel(IEventPublisher serverEventPublisher, IServerRepository serverRepository, IDebugOutputFilterStrategy debugOutputFilterStrategy, IContextualResourceModel contextualResourceModel)
        {
            VerifyArgument.IsNotNull("serverEventPublisher", serverEventPublisher);
            VerifyArgument.IsNotNull("environmentRepository", serverRepository);
            VerifyArgument.IsNotNull("debugOutputFilterStrategy", debugOutputFilterStrategy);
            _serverRepository          = serverRepository;
            _debugOutputFilterStrategy = debugOutputFilterStrategy;
            if (contextualResourceModel != null)
            {
                _contextualResourceModel = contextualResourceModel;
                ResourceID = _contextualResourceModel.ID;
            }
            IsTestView      = false;
            _contentItems   = new List <IDebugState>();
            _contentItemMap = new Dictionary <Guid, IDebugTreeViewItemViewModel>();
            _debugWriterSubscriptionService = new SubscriptionService <DebugWriterWriteMessage>(serverEventPublisher);
            _debugWriterSubscriptionService.Subscribe(msg =>
            {
                Append(msg.DebugState);
            });

            SessionID = Guid.NewGuid();
            _popup    = CustomContainer.Get <IPopupController>();
            ClearSearchTextCommand = new Microsoft.Practices.Prism.Commands.DelegateCommand(() => SearchText = "");
            AddNewTestCommand      = new DelegateCommand(o => AddNewTest(EventPublishers.Aggregator), o => CanAddNewTest());
            _outputViewModelUtil   = new DebugOutputViewModelUtil(SessionID);
        }
Пример #15
0
 public ConflictModelFactory(IContextualResourceModel resourceModel)
 {
     _resourceModel = resourceModel;
     WorkflowName   = _resourceModel.ResourceName;
     ServerName     = _resourceModel.Environment.Name;
     GetDataList(_resourceModel);
 }
Пример #16
0
        static DsfActivity SetActivityProperties(IContextualResourceModel resource, DsfActivity activity)
        {
            switch (resource.ResourceType)
            {
            case ResourceType.WorkflowService:
                WorkflowPropertyInterigator.SetActivityProperties(resource, ref activity);
                break;

            case ResourceType.Service:
                WorkerServicePropertyInterigator.SetActivityProperties(resource, ref activity, resource.Environment.ResourceRepository);
                break;

            case ResourceType.Source:
                break;

            case ResourceType.Unknown:
                break;

            case ResourceType.Server:
                break;

            default:
                break;
            }
            return(activity);
        }
Пример #17
0
        public bool HasDependencies(IContextualResourceModel resourceModel)
        {
            var uniqueList = GetUniqueDependencies(resourceModel);

            uniqueList.RemoveAll(res => res.ID == resourceModel.ID);
            return(uniqueList.Count > 0);
        }
Пример #18
0
        public static Uri GetWorkflowUri(IContextualResourceModel resourceModel, string xmlData, UrlType urlType)
        {
            if(resourceModel == null || resourceModel.Environment == null || resourceModel.Environment.Connection == null || !resourceModel.Environment.IsConnected)
            {
                return null;
            }
            var environmentConnection = resourceModel.Environment.Connection;

            string urlExtension = "xml";
            switch(urlType)
            {
                case UrlType.XML:
                    break;
                case UrlType.JSON:
                    urlExtension = "json";
                    break;
                default:
                    throw new ArgumentOutOfRangeException("urlType");
            }

            var relativeUrl = string.Format("/secure/{0}.{1}?", resourceModel.Category, urlExtension);
            relativeUrl += xmlData;
            relativeUrl += "&wid=" + environmentConnection.WorkspaceID;
            Uri url;
            Uri.TryCreate(environmentConnection.WebServerUri, relativeUrl, out url);
            return url;
        }
Пример #19
0
 public void ShowResourceChanged(IContextualResourceModel resource, IList <string> numberOfDependants, IResourceChangedDialog resourceChangedDialog)
 {
     if (resource == null)
     {
         throw new ArgumentNullException("resource");
     }
     if (numberOfDependants == null)
     {
         throw new ArgumentNullException("numberOfDependants");
     }
     if (resourceChangedDialog == null)
     {
         resourceChangedDialog = new ResourceChangedDialog(resource, numberOfDependants.Count);
     }
     resourceChangedDialog.ShowDialog();
     if (resourceChangedDialog.OpenDependencyGraph)
     {
         if (numberOfDependants.Count == 1)
         {
             var shellViewModel = CustomContainer.Get <IShellViewModel>();
             shellViewModel.OpenResourceAsync(Guid.Parse(numberOfDependants[0]), shellViewModel.ActiveServer);
         }
         else
         {
             Dev2Logger.Info("Publish message of type - " + typeof(ShowReverseDependencyVisualizer), "Warewolf Info");
             _eventPublisher.Publish(new ShowReverseDependencyVisualizer(resource));
         }
     }
 }
Пример #20
0
        public WorkflowInputDataViewModel(IServiceDebugInfoModel input, Guid sessionId)
        {
            VerifyArgument.IsNotNull(@"input", input);
            CanDebug         = true;
            CanViewInBrowser = true;

            DebugTo = new DebugTO
            {
                DataList = !string.IsNullOrEmpty(input.ResourceModel.DataList)
                               ? input.ResourceModel.DataList
                               : @"<DataList></DataList>",
                ServiceName    = input.ResourceModel.ResourceName,
                WorkflowID     = input.ResourceModel.ResourceName,
                WorkflowXaml   = string.Empty,
                XmlData        = input.ServiceInputData,
                ResourceID     = input.ResourceModel.ID,
                ServerID       = input.ResourceModel.ServerID,
                RememberInputs = input.RememberInputs,
                SessionID      = sessionId
            };

            if (input.DebugModeSetting == DebugMode.DebugInteractive)
            {
                DebugTo.IsDebugMode = true;
            }

            _resourceModel = input.ResourceModel;

            DisplayName = @"Debug input data";

            _popupController = CustomContainer.Get <IPopupController>();
        }
Пример #21
0
        public void OnPaneClosing(object sender, PaneClosingEventArgs e)
        {
            ContentPane contentPane = sender as ContentPane;

            if (contentPane != null)
            {
                var pane = contentPane;

                WorkSurfaceContextViewModel model = pane.DataContext as WorkSurfaceContextViewModel;
                if (model != null)
                {
                    var workflowVm = model.WorkSurfaceViewModel as IWorkflowDesignerViewModel;
                    IContextualResourceModel resource = workflowVm?.ResourceModel;

                    if (resource != null && !resource.IsWorkflowSaved)
                    {
                        CloseCurrent(e, model);
                    }
                    else
                    {
                        var sourceView = model.WorkSurfaceViewModel as IStudioTab;
                        if (sourceView != null)
                        {
                            CloseCurrent(e, model);
                        }
                    }
                }
            }
        }
Пример #22
0
 public SaveUnsavedWorkflowMessage(IContextualResourceModel resourceModel, string resourceName, string resourceCategory, bool keepTabOpen)
 {
     ResourceModel = resourceModel;
     ResourceName = resourceName;
     ResourceCategory = resourceCategory;
     KeepTabOpen = keepTabOpen;
 }
Пример #23
0
        public async Task <ExecuteMessage> GetDependenciesXmlAsync(IContextualResourceModel resourceModel, bool getDependsOnMe)
        {
            if (resourceModel == null)
            {
                return(new ExecuteMessage {
                    HasError = false
                });
            }

            var comsController = new CommunicationController {
                ServiceName = "FindDependencyService"
            };

            comsController.AddPayloadArgument("ResourceId", resourceModel.ID.ToString());
            comsController.AddPayloadArgument("GetDependsOnMe", getDependsOnMe.ToString());

            var workspaceId = resourceModel.Environment.Connection.WorkspaceID;
            var payload     = await comsController.ExecuteCommandAsync <ExecuteMessage>(resourceModel.Environment.Connection, workspaceId);

            if (payload == null)
            {
                throw new Exception(string.Format(GlobalConstants.NetworkCommunicationErrorTextFormat, "FindDependencyService"));
            }

            return(payload);
        }
Пример #24
0
        public WorkflowInputDataViewModel(IServiceDebugInfoModel input, Guid sessionId)
        {
            VerifyArgument.IsNotNull("input", input);
            CanDebug         = true;
            CanViewInBrowser = true;

            DebugTo = new DebugTO
            {
                DataList = !string.IsNullOrEmpty(input.ResourceModel.DataList)
                               ? input.ResourceModel.DataList
                               : "<DataList></DataList>",
                ServiceName  = input.ResourceModel.ResourceName,
                WorkflowID   = input.ResourceModel.ResourceName,
                WorkflowXaml = string.Empty,
                //WorkflowXaml = input.ResourceModel.WorkflowXaml, - 05.12.2013 ;)
                XmlData        = input.ServiceInputData,
                ResourceID     = input.ResourceModel.ID,
                ServerID       = input.ResourceModel.ServerID,
                RememberInputs = input.RememberInputs,
                SessionID      = sessionId
            };

            if (input.DebugModeSetting == DebugMode.DebugInteractive)
            {
                DebugTo.IsDebugMode = true;
            }

            _resourceModel = input.ResourceModel;
            // ReSharper disable DoNotCallOverridableMethodsInConstructor
            DisplayName = "Debug input data";
            // ReSharper restore DoNotCallOverridableMethodsInConstructor
            _dataListConversionUtils = new DataListConversionUtils();
        }
        public static void SetActivityProperties(IContextualResourceModel resource, ref DsfActivity activity)
        {
            if(resource.WorkflowXaml != null && resource.WorkflowXaml.Length > 0)
            {
                var startIdx = resource.WorkflowXaml.IndexOf("<HelpLink>", 0, true);

                if(startIdx >= 0)
                {
                    var endIdx = resource.WorkflowXaml.IndexOf("</HelpLink>", startIdx, true);

                    if(endIdx > 0)
                    {
                        startIdx += 10;
                        var len = (endIdx - startIdx);

                        activity.HelpLink = resource.WorkflowXaml.Substring(startIdx, len);
                    }
                }

            }

            if(resource.Environment != null) activity.FriendlySourceName = resource.Environment.Name;
            activity.IsWorkflow = true;
            activity.Type = "Workflow";
        }
        void ViewInBrowserInternal(IContextualResourceModel model)
        {
            var workflowInputDataViewModel = GetWorkflowInputDataViewModel(model, false);

            workflowInputDataViewModel.LoadWorkflowInputs();
            workflowInputDataViewModel.ViewInBrowser();
        }
Пример #27
0
 public static void SetAttachedProperties(WorkflowDesignerWindow workflowDesignerWindow,
                                          IContextualResourceModel resource, string iconPath)
 {
     UIElementTitleProperty.SetTitle(workflowDesignerWindow, resource.ResourceName);
     UIElementTabActionContext.SetTabActionContext(workflowDesignerWindow, WorkSurfaceContext.Workflow);
     UIElementImageProperty.SetImage(workflowDesignerWindow, iconPath);
 }
Пример #28
0
        public static Uri GetWorkflowUrl(IContextualResourceModel resourceModel)
        {
            var relativeUrl = String.Format("/services/{0}?wid={1}", resourceModel.ResourceName,
                                            resourceModel.Environment.Connection.WorkspaceID);

            return(new Uri(resourceModel.Environment.Connection.WebServerUri, relativeUrl));
        }
        public static DsfActivity CreateDsfActivity(IContextualResourceModel resource, DsfActivity activity,
                                                    bool ifNullCreateNew, IEnvironmentRepository environmentRepository, bool isDesignerLocalhost)
        {
            var activityToUpdate = activity;

            if (activityToUpdate == null)
            {
                if (ifNullCreateNew)
                {
                    activityToUpdate = new DsfActivity();
                }
                else
                {
                    return(null);
                }
            }

            if (resource != null)
            {
                var activeEnvironment = environmentRepository.ActiveEnvironment;
                activityToUpdate.ResourceID = resource.ID;
                SetCorrectEnvironmentId(resource, activityToUpdate, isDesignerLocalhost, activeEnvironment);
                activityToUpdate = SetActivityProperties(resource, activityToUpdate);
            }

            activityToUpdate.ExplicitDataList = null;
            return(activityToUpdate);
        }
        WorkflowInputDataViewModel GetWorkflowInputDataViewModel(IContextualResourceModel resourceModel, bool isDebug)
        {
            var mode = isDebug ? DebugMode.DebugInteractive : DebugMode.Run;
            var inputDataViewModel = WorkflowInputDataViewModel.Create(resourceModel, DebugOutputViewModel.SessionID, mode);

            inputDataViewModel.Parent = this;
            return(inputDataViewModel);
        }
 public WorkflowDesignerViewModelMock(IContextualResourceModel resource, IWorkflowHelper workflowHelper, IPopupController popupController, IExternalProcessExecutor processExecutor, bool createDesigner = false)
     : base(
         new Mock <IEventAggregator>().Object,
         resource, workflowHelper,
         popupController, new SynchronousAsyncWorker(), createDesigner, false)
 {
     _wd = _moq.Object;
 }
Пример #32
0
 public static void OpenInBrowser(IContextualResourceModel resourceModel, string xmlData)
 {
     Uri url = GetWorkflowUri(resourceModel, xmlData, UrlType.XML);
     if(url != null)
     {
         Process.Start("explorer.exe", "\"" + url+ "\"");
     }
 }
Пример #33
0
 public DeleteResourceDialog(IContextualResourceModel model)
 {
     InitializeComponent();
     Owner          = Application.Current.MainWindow;
     Title          = String.Format(StringResources.DialogTitle_HasDependencies, model.ResourceType.GetDescription());
     tbDisplay.Text = String.Format(StringResources.DialogBody_HasDependencies, model.ResourceName,
                                    model.ResourceType.GetDescription());
 }
Пример #34
0
 public static IWebActivity CreateWebActivity(object webActivityWrappingObject, IContextualResourceModel resourceModel, string serviceName)
 {
     IWebActivity activity = CreateWebActivity();
     activity.WebActivityObject = webActivityWrappingObject;
     activity.ResourceModel = resourceModel;
     activity.ServiceName = serviceName;
     return activity;
 }
 public RenameResourceDialog(IContextualResourceModel model, string newName, Window owner)
 {
     InitializeComponent();
     Owner          = owner ?? Application.Current.MainWindow;
     Title          = string.Format(StringResources.DialogTitle_HasDuplicateName, newName);
     tbDisplay.Text = string.Format(StringResources.DialogBody_HasDuplicateName,
                                    model.ResourceType.GetDescription(), model.ResourceName);
 }
 public DeleteResourceDialog(IContextualResourceModel model)
 {
     InitializeComponent();
     Owner = Application.Current.MainWindow;
     Title = String.Format(StringResources.DialogTitle_HasDependencies, model.ResourceType.GetDescription());
     tbDisplay.Text = String.Format(StringResources.DialogBody_HasDependencies, model.ResourceName,
                                             model.ResourceType.GetDescription());
 }
 public WorkflowDesignerViewModelMock(IContextualResourceModel resource, IWorkflowHelper workflowHelper, IPopupController popupController, bool createDesigner = false)
     : base(new Mock<IEventAggregator>().Object,
         resource, workflowHelper,
         popupController, new TestAsyncWorker(), createDesigner, false, false)
 {
     _moq.SetupAllProperties();
     _wd = _moq.Object;
 }
 public RenameResourceDialog(IContextualResourceModel model, string newName, Window owner)
 {
     InitializeComponent();
     Owner = owner ?? Application.Current.MainWindow;
     Title = string.Format(StringResources.DialogTitle_HasDuplicateName, newName);
     tbDisplay.Text = string.Format(StringResources.DialogBody_HasDuplicateName,
                         model.ResourceType.GetDescription(), model.ResourceName);
 }
Пример #39
0
 public static void OpenInBrowser(WebServerMethod post, IContextualResourceModel resourceModel, string xmlData)
 {
     Uri url = GetWorkflowUri(resourceModel, xmlData, UrlType.XML);
     if(url != null)
     {
         Process.Start(url.ToString());
     }
 }
        /// <summary>
        /// Gets the dependencies XML for the given <see cref="IResourceModel"/>.
        /// </summary>
        /// <param name="resourceModel">The resource model to be queried.</param>
        /// <returns>The dependencies XML.</returns>
        public string GetDependenciesXml(IContextualResourceModel resourceModel)
        {
            if(resourceModel == null)
            {
                return string.Empty;
            }

            return resourceModel.Environment.ResourceRepository.GetDependenciesXml(resourceModel);
            }
Пример #41
0
        /// <summary>
        /// Gets the dependencies XML for the given <see cref="IResourceModel"/>.
        /// </summary>
        /// <param name="resourceModel">The resource model to be queried.</param>
        /// <returns>The dependencies XML.</returns>
        public string GetDependenciesXml(IContextualResourceModel resourceModel)
        {
            if (resourceModel == null)
            {
                return(string.Empty);
            }

            return(resourceModel.Environment.ResourceRepository.GetDependenciesXml(resourceModel));
        }
        public static void SetActivityProperties(IContextualResourceModel resource, ref DsfActivity activity, IResourceRepository resourceRepository)
        {
            activity.IsWorkflow = false;

            if (resource.WorkflowXaml != null && resource.WorkflowXaml.Length > 0)
            {
                var startIdx = resource.WorkflowXaml.IndexOf("<Action ", 0, true);

                if (startIdx >= 0)
                {
                    var endIdx = resource.WorkflowXaml.IndexOf(">", startIdx, true);
                    if (endIdx > 0)
                    {
                        var len      = (endIdx - startIdx) + 1;
                        var fragment = resource.WorkflowXaml.Substring(startIdx, len);

                        fragment += "</Action>";
                        fragment  = fragment.Replace("&", "&amp;");
                        XmlDocument document = new XmlDocument();

                        document.LoadXml(fragment);

                        if (document.DocumentElement != null)
                        {
                            XmlNode node = document.SelectSingleNode("//Action");
                            if (node != null)
                            {
                                if (node.Attributes != null)
                                {
                                    var attr = node.Attributes["SourceName"];
                                    if (attr != null)
                                    {
                                        if (resourceRepository != null && node.Attributes["SourceID"] != null)
                                        {
                                            Guid sourceId;
                                            Guid.TryParse(node.Attributes["SourceID"].Value, out sourceId);
                                            activity.FriendlySourceName = resourceRepository.FindSingle(a => !(a.ID.ToString() != sourceId.ToString()), false).DisplayName;
                                        }
                                        else
                                        {
                                            activity.FriendlySourceName = attr.Value;
                                        }
                                    }

                                    attr = node.Attributes["SourceMethod"];
                                    if (attr != null)
                                    {
                                        activity.ActionName = attr.Value;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            activity.Type = resource.ServerResourceType;
        }
 public static IServiceDebugInfoModel CreateServiceDebugInfoModel(IContextualResourceModel resourceModel, string serviceInputData, DebugMode debugSetting)
 {
     IServiceDebugInfoModel serviceDebugInfoModel = new ServiceDebugInfoModel();
     serviceDebugInfoModel.ResourceModel = resourceModel;
     serviceDebugInfoModel.DebugModeSetting = debugSetting;
     serviceDebugInfoModel.ServiceInputData = serviceInputData;
     serviceDebugInfoModel.RememberInputs = true;
     return serviceDebugInfoModel;
 }
 public void ClearWorkspaceItems(IContextualResourceModel resourceModel)
 {
     if (resourceModel == null)
     {
         return;
     }
     WorkspaceItems.Clear();
     resourceModel.Environment.ResourceRepository.DeleteResourceFromWorkspace(resourceModel);
 }
        public static void SetActivityProperties(IContextualResourceModel resource, ref DsfActivity activity, IResourceRepository resourceRepository)
        {
            activity.IsWorkflow = false;

            if(resource.WorkflowXaml != null && resource.WorkflowXaml.Length > 0)
            {

                var startIdx = resource.WorkflowXaml.IndexOf("<Action ", 0, true);

                if(startIdx >= 0)
                {
                    var endIdx = resource.WorkflowXaml.IndexOf(">", startIdx, true);
                    if(endIdx > 0)
                    {
                        var len = endIdx - startIdx + 1;
                        var fragment = resource.WorkflowXaml.Substring(startIdx, len);

                        fragment += "</Action>";
                        fragment = fragment.Replace("&", "&amp;");
                        XmlDocument document = new XmlDocument();

                        document.LoadXml(fragment);

                        if(document.DocumentElement != null)
                        {
                            XmlNode node = document.SelectSingleNode("//Action");
                            if(node != null)
                            {
                                if(node.Attributes != null)
                                {
                                    var attr = node.Attributes["SourceName"];
                                    if(attr != null)
                                    {
                                        if (resourceRepository != null && node.Attributes["SourceID"] != null)
                                        {
                                            Guid sourceId;
                                            Guid.TryParse( node.Attributes["SourceID"].Value, out sourceId);
                                            activity.FriendlySourceName = resourceRepository.FindSingle(a => !(a.ID.ToString() != sourceId.ToString()),false).DisplayName;
                                        }
                                        else
                                        activity.FriendlySourceName = attr.Value;
                                    }

                                    attr = node.Attributes["SourceMethod"];
                                    if(attr != null)
                                    {
                                        activity.ActionName = attr.Value;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            activity.Type = resource.ServerResourceType;
        }
Пример #46
0
        public CompileMessageList GetCompileMessagesFromServer(IContextualResourceModel resourceModel)
        {
            var comsController = new CommunicationController { ServiceName = "FetchDependantCompileMessagesService" };

            var workspaceID = GlobalConstants.ServerWorkspaceID;

            comsController.AddPayloadArgument("ServiceID", resourceModel.ID.ToString());
            comsController.AddPayloadArgument("WorkspaceID", workspaceID.ToString());
            var con = resourceModel.Environment.Connection;
            var result = comsController.ExecuteCommand<CompileMessageList>(con, GlobalConstants.ServerWorkspaceID);

            return result;
        }
Пример #47
0
        public static void CheckIfRemoteWorkflowAndSetProperties(DsfActivity dsfActivity, IContextualResourceModel resource, IEnvironmentModel contextEnv)
        {
            if(resource != null && resource.ResourceType == ResourceType.WorkflowService && contextEnv != null)
            {
                if(contextEnv.ID != resource.Environment.ID)
                {
                    dsfActivity.ServiceUri = resource.Environment.Connection.WebServerUri.AbsoluteUri;
                    dsfActivity.ServiceServer = resource.Environment.ID;

                }
                dsfActivity.FriendlySourceName = new InArgument<string>(resource.Environment.Connection.WebServerUri.Host);
            }
        }
 static DsfActivity SetActivityProperties(IContextualResourceModel resource, DsfActivity activity)
 {
     
     switch(resource.ResourceType)
     {
         case ResourceType.WorkflowService:
             WorkflowPropertyInterigator.SetActivityProperties(resource, ref activity);
             break;
         case ResourceType.Service:
             WorkerServicePropertyInterigator.SetActivityProperties(resource, ref activity,resource.Environment.ResourceRepository);
             break;
     }
     return activity;
 }
        static void SetCorrectEnvironmentId(IContextualResourceModel resource, DsfActivity activity, bool isDesignerLocalhost, IEnvironmentModel activeEnvironment)
        {
            if(resource.Environment != null)
            {
                var idToUse = resource.Environment.ID;

                //// when we have an active remote environment that we are designing against, set it as local to that environment ;)
                if(activeEnvironment.ID == resource.Environment.ID && idToUse != Guid.Empty && !isDesignerLocalhost)
                {
                    idToUse = Guid.Empty;
                }

                activity.EnvironmentID = idToUse;
            }
        }
        public static IDebugState Create(string message, IContextualResourceModel resourceModel)
        {
            var state = new DebugState
                {
                    Message = message,
                };

            if(resourceModel != null)
            {
                state.ServerID = resourceModel.ServerID;
                state.OriginatingResourceID = resourceModel.ID;
            }
            state.StateType = String.IsNullOrWhiteSpace(message) ? StateType.Clear : StateType.Message;

            return state;
        }
 /// <summary>
 /// Gets the display name associated with a specific resource and environment - used for tab headers
 /// </summary>
 /// <param name="resourceModel">The resource model.</param>
 /// <returns></returns>
 /// <author>Jurie.smit</author>
 /// <date>2013/06/03</date>
 public static string GetDisplayName(IContextualResourceModel resourceModel)
 {
     if(resourceModel == null)
     {
         return String.Empty;
     }
     string displayName = resourceModel.ResourceName;
     if(resourceModel.Environment != null && !resourceModel.Environment.IsLocalHost)
     {
         displayName += " - " + resourceModel.Environment.Name;
     }
     if(!resourceModel.IsWorkflowSaved)
     {
         displayName += " *";
     }
     return displayName;
 }
        public DesignerManagementService(IContextualResourceModel rootModel, IResourceRepository resourceRepository)
        {
            if(rootModel == null)
            {
                throw new ArgumentNullException("rootModel");
            }
            if(resourceRepository == null)
            {
                throw new ArgumentNullException("resourceRepository");
            }
            //VerifyArgument.IsNotNull("rootModel", rootModel);
            //VerifyArgument.IsNotNull("resourceRepository", resourceRepository);

            _rootModel = rootModel;

            EventPublishers.Aggregator.Subscribe(this);
        }
 public ResourceChangedDialog(IContextualResourceModel model, int numOfDependances)
 {
     InitializeComponent();
     Owner = Application.Current.MainWindow;
     if(numOfDependances <= 1)
     {
         tbDisplay.Text = String.Format("{0} is used by another workflow. That instance needs to be updated.", model.ResourceName);
         button3.Content = "Open Affected Workflow";
         button3.SetValue(AutomationProperties.AutomationIdProperty, "UI_ShowAffectedWorkflowsButton_AutoID");
     }
     else
     {
         tbDisplay.Text = String.Format("{0} is used in {1} instances. Those instances need to be updated.", model.ResourceName, numOfDependances);
         button3.Content = "Show Affected Workflows";
         button3.SetValue(AutomationProperties.AutomationIdProperty, "UI_ShowAffectedWorkflowsButton_AutoID");
     }
 }
 public static string GetIconPath(IContextualResourceModel resource)
 {
     string iconPath = resource.IconPath;
     if(string.IsNullOrEmpty(resource.UnitTestTargetWorkflowService))
     {
         if(string.IsNullOrEmpty(resource.IconPath))
         {
             iconPath = ResourceType.WorkflowService.GetIconLocation();
         }
     }
     else
     {
         iconPath = string.IsNullOrEmpty(resource.IconPath)
                        ? string.Empty
                        : resource.IconPath;
     }
     return iconPath;
 }
Пример #55
0
 public static bool IsServerUp(IContextualResourceModel resourceModel)
 {
     string host = resourceModel.Environment.Connection.WebServerUri.AbsoluteUri;
     int port = resourceModel.Environment.Connection.WebServerUri.Port;
     try
     {
         // Do NOT use TcpClient(ip, port) else it causes a 1 second delay when you initially resolve to an IPv6 IP
         // http://msdn.microsoft.com/en-us/library/115ytk56.aspx - Remarks
         using(TcpClient client = new TcpClient())
         {
             client.Connect(host, port);
             return true;
         }
     }
     catch
     {
         return false;
     }
 }
Пример #56
0
        public static void Send(WebServerMethod method, IContextualResourceModel resourceModel, string payload, IAsyncWorker asyncWorker)
        {
            if(resourceModel == null || resourceModel.Environment == null || !resourceModel.Environment.IsConnected)
            {
                return;
            }

            var clientContext = resourceModel.Environment.Connection;
            if(clientContext == null)
            {
                return;
            }
            asyncWorker.Start(() =>
            {
                var controller = new CommunicationController { ServiceName = resourceModel.Category };
                controller.AddPayloadArgument("DebugPayload", payload);
                controller.ExecuteCommand<string>(clientContext, clientContext.WorkspaceID);
            }, () => { });

        }
         //<summary>
         //Gets a list of unique dependencies for the given <see cref="IResourceModel"/>.
         //</summary>
         //<param name="resourceModel">The resource model to be queried.</param>
         //<returns>A list of <see cref="IResourceModel"/>'s.</returns>
        public List<IResourceModel> GetUniqueDependencies(IContextualResourceModel resourceModel)
        {
            if(resourceModel == null || resourceModel.Environment == null || resourceModel.Environment.ResourceRepository == null)
            {
                return new List<IResourceModel>();
            }

            var xml = XElement.Parse(GetDependenciesXml(resourceModel));
            var nodes = from node in xml.DescendantsAndSelf("node") // this is case-sensitive!
                        select node.Attribute("id")
                            into idAttr
                            where idAttr != null
                            select idAttr.Value;

            var resources = from r in resourceModel.Environment.ResourceRepository.All()
                            join n in nodes on r.ResourceName equals n
                            select r;

            var returnList = resources.ToList().Distinct().ToList();
            return returnList;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ShowDependenciesMessage"/> class.
 /// </summary>
 /// <param name="resourceModel">The resource model.</param>
 /// <param name="showDependentOnMe">if set to <c>true</c> [show dependent on me].</param>
 /// <author>Jurie.smit</author>
 /// <date>2013/06/26</date>
 public ShowDependenciesMessage(IContextualResourceModel resourceModel, bool showDependentOnMe = false) 
     : base(resourceModel)
 {
     ShowDependentOnMe = showDependentOnMe;
 }
Пример #59
0
 public ResourceDesignerViewModel(IContextualResourceModel model, IEnvironmentModel environmentModel)
 {
     _contexttualResourceModel = model;
     _environmentModel = environmentModel;
 }
 public IExplorerItemModel FindChild(IContextualResourceModel resource)
 {
     var explorerItemModels = ExplorerItemModels.SelectMany(explorerItemModel => explorerItemModel.Descendants()).ToList();
     return resource != null ? explorerItemModels.FirstOrDefault(model => model.ResourceId == resource.ID && model.EnvironmentId == resource.Environment.ID) : null;
 }