/// <summary>
        /// Load workspaces for the given Workspace Collection Name
        /// </summary>
        /// <param name="workspaceCollectionName"></param>
        /// <param name="accessKey"></param>
        /// <returns></returns>
        public async Task LoadWorkspacesAsync(string workspaceCollectionName, string accessKey)
        {
            Status    = "Loading...";
            IsLoading = true;
            IsLoaded  = false;

            Workspaces.Clear();

            using (var client = CreateClient(accessKey))
            {
                var response = await client.Workspaces.GetWorkspacesByCollectionNameAsync(workspaceCollectionName);

                if (response.Value != null)
                {
                    foreach (var workspace in response.Value)
                    {
                        Workspaces.Add(new Models.Workspace()
                        {
                            WorkspaceId = workspace.WorkspaceId
                        });
                    }

                    Status   = "Loaded.";
                    IsLoaded = true;
                }
                else
                {
                    Status = "Failed. Cannot get workspaces";
                }
            }

            IsLoading = false;
        }
示例#2
0
        public MainWindowViewModel()
        {
            /*Adding PathList view model to workspaces collection*/
            ViewModelBase pathList = new PathListViewModel();

            Workspaces.Add(pathList);
        }
示例#3
0
        /// <summary>
        ///   Gets all newly created windows, not handled by the desktop manager yet.
        /// </summary>
        /// <returns>A list with all new windows.</returns>
        List <WindowSnapshot> GetNewWindows()
        {
            List <WindowInfo> newWindows = WindowManager.GetWindows().Except(
                Workspaces.SelectMany(d => d.WindowSnapshots).Concat(WindowClipboard)
                .Select(w => w.Info)
                .Concat(_invalidWindows)).ToList();

            var validWindows = new List <WindowSnapshot>();

            foreach (var w in newWindows)
            {
                var snapshot = new WindowSnapshot(CurrentWorkspace, w);
                if (IsValidWindow(snapshot))
                {
                    validWindows.Add(snapshot);
                }
                else
                {
                    lock ( _invalidWindows )
                    {
                        _invalidWindows.Add(w);
                    }
                }
            }
            return(validWindows);
        }
        public async Task <string> CreateWorkspaceAsync(string workspaceCollectionName, string accessKey)
        {
            string ret = null;

            Status    = "Loading...";
            IsLoading = true;
            IsLoaded  = false;

            using (var client = CreateClient(accessKey))
            {
                var workspace = await client.Workspaces.PostWorkspaceAsync(workspaceCollectionName);

                if (workspace != null)
                {
                    ret = workspace.WorkspaceId;
                    Workspaces.Add(new Models.Workspace()
                    {
                        WorkspaceId = ret
                    });
                }
            }

            IsLoading = false;
            IsLoaded  = true;
            return(ret);
        }
        public MainWindowViewModel()
        {
            try
            {
                Characters = TokenRepo <Character> .Load($"Resources{Path.DirectorySeparatorChar}{_charactermap}");
            }
            catch
            {
            }

            try
            {
                Vehicles = TokenRepo <Vehicle> .Load($"Resources{Path.DirectorySeparatorChar}{_vehiclemap}");
            }
            catch
            {
            }

            var tokenVm  = new TokenSelectionViewModel(Characters, Vehicles);
            var deviceVm = new DeviceViewModel();
            var cryptoVm = new CryptoViewModel();

            Workspaces.Add(cryptoVm);
            Workspaces.Add(tokenVm);
            Workspaces.Add(deviceVm);
            SetActiveWorkspace(cryptoVm);
        }
        public void Show(LaytonFormShell shell)
        {
            this.formShell = shell;

            LaytonSettingsWorkItem settingsWorkItem = this.WorkItems.AddNew <LaytonSettingsWorkItem>(WorkItemNames.SettingsWorkItem);

            settingsWorkItem.Show();
            Workspaces.Add(settingsWorkItem.TabWorkspace, Layton.Cab.Interface.WorkspaceNames.SettingsTabWorkspace);

            LaytonToolbarsWorkItem toolbarsWorkItem = this.WorkItems.AddNew <LaytonToolbarsWorkItem>(WorkItemNames.ToolbarsWorkItem);

            toolbarsWorkItem.Show();

            LaytonProductKey productKey = LoadProductKey();

            if (productKey.IsTrial)
            {
                LaytonRegistrationForm registerForm = new LaytonRegistrationForm(productKey);
                registerForm.ShowDialog();
                productKey = registerForm.ProductKey;
            }

            this.Items.Add(productKey, MiscStrings.ProductKey);
            this.Activate();
        }
示例#7
0
 /// <summary>
 /// This event handler is called if 'markNodesAsDirty' in a
 /// prior call to RevitDynamoModel.ResetEngine was set to 'true'.
 /// </summary>
 /// <param name="markNodesAsDirty"></param>
 private void OnResetMarkNodesAsDirty(bool markNodesAsDirty)
 {
     foreach (var workspace in Workspaces.OfType <HomeWorkspaceModel>())
     {
         workspace.ResetEngine(EngineController, markNodesAsDirty);
     }
 }
示例#8
0
        /// <summary>
        /// Handler Revit's DocumentOpened event.
        /// It is called when a document is opened, but NOT when a document is
        /// created from a template.
        /// </summary>
        private void HandleApplicationDocumentOpened()
        {
            // If the current document is null, for instance if there are
            // no documents open, then set the current document, and
            // present a message telling us where Dynamo is pointing.
            if (DocumentManager.Instance.CurrentUIDocument == null)
            {
                var activeUIDocument = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument;

                DocumentManager.Instance.CurrentUIDocument = activeUIDocument;
                if (activeUIDocument != null)
                {
                    DocumentManager.Instance.HandleDocumentActivation(activeUIDocument.ActiveView);
                }

                OnRevitDocumentChanged();

                foreach (HomeWorkspaceModel ws in Workspaces.OfType <HomeWorkspaceModel>())
                {
                    ws.RunSettings.RunEnabled = true;
                }

                ResetForNewDocument();
            }
        }
示例#9
0
        void AggiungiSchedaRisultatiRicercaDipendentePerFigura(FiguraProfessionale figura)
        {
            RisultatiDipendentePerFiguraViewModel visualizza = new RisultatiDipendentePerFiguraViewModel(figura);

            Workspaces.Add(visualizza);
            SetActiveWorkspace(visualizza);
        }
示例#10
0
        public static async Task UpdateRunningTask()
        {
            if (ActualRunningTaskData == default(TaskPresentationLayout))
            {
                ActualRunningTaskData = new TaskPresentationLayout();
            }

            UpdateWorkspaces();
            UpdateProjects();
            RunningTask = (await RestApi.GetCurrentTimeEntries()).data;

            if (RunningTask == default(TimeEntries))
            {
                ActualRunningTaskData.Update();
                return;
            }

            var startTime     = DateTime.Parse(RunningTask.start, null, DateTimeStyles.RoundtripKind);
            var projectName   = RunningTask.pid == 0 ? default(string) : Projects.FirstOrDefault(p => p.id == RunningTask.pid).name;
            var workspaceName = Workspaces.FirstOrDefault(w => w.id == RunningTask.wid).name;

            ActualRunningTaskData.Update(
                workspaceName,
                projectName,
                RunningTask.description,
                startTime);
        }
        async void Delete()
        {
            if (
                MessageBox.Show(string.Format("You're about to delete {0} workspaces, and {1} shelvesets\n** Caution: There’s no way to recover a shelveset or workspace once it is deleted. **\nClick OK to continue.", Workspaces.Count, Shelvesets.Count), "Delete Confirmation",
                                MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.Cancel)
            {
                return;
            }

            TotalItemToDelete = Workspaces.Count + Shelvesets.Count;
            CompletedItems    = 0;

            Working = true;

            await Task.Run(() =>
            {
                foreach (var ws in Workspaces)
                {
                    ws.Delete();
                    CompletedItems++;
                }

                foreach (var sh in Shelvesets)
                {
                    TfsShared.Instance.Vcs.DeleteShelveset(sh);
                    CompletedItems++;
                }
            });

            Workspaces.Clear();
            Shelvesets.Clear();
            Working = false;
        }
        public async void LoadWorkspaces()
        {
#if DEBUG
            var watch = Stopwatch.StartNew();
#endif
            foreach (var workspace in WorkspaceManagement.Workspaces)
            {
                Workspaces.Add(new WorkspaceViewModel(workspace));
            }

            Messenger.Default.Register <CloseAddWorkspaceFlyoutMessage>(this, message => IsAddingWorkspace = false);
            Messenger.Default.Register <AddWorkspaceMessage>(this, message =>
            {
                if (message.Workspace != null)
                {
                    Workspaces.Add(new WorkspaceViewModel(message.Workspace));
                }
            });

            foreach (var workspace in Workspaces)
            {
                await workspace.Init();
            }


#if DEBUG
            Logger.Trace("Loaded all workspaces: {0} ms", watch.ElapsedMilliseconds);
#else
            Logger.Debug("Loaded all workspaces");
#endif
        }
        void CopyToClipboard()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(string.Format("List of Workspaces & Shelvesets older than {0}", DateTime.Now.AddDays(-this.MaxDays)));

            if (Workspaces.Count > 0)
            {
                sb.AppendLine("Workspaces:");
                TableBuilder table = new TableBuilder();
                table.AddHeaders(new Header("Name"), new Header("Computer"), new Header("Last Access Date"), new Header("Comment", 35));
                foreach (var ws in Workspaces.OrderBy(o => o.OwnerName))
                {
                    table.AddValues(ws.DisplayName, ws.Computer, ws.LastAccessDate.ToString(), ws.Comment);
                }

                sb.Append(table.ToString());
            }

            if (Shelvesets.Count > 0)
            {
                sb.AppendLine("Shelvesets:");
                TableBuilder table = new TableBuilder();
                table.AddHeaders(new Header("Name"), new Header("Creation Date"), new Header("Comment", 35));
                foreach (var ws in Shelvesets.OrderBy(o => o.OwnerName))
                {
                    table.AddValues(ws.DisplayName, ws.CreationDate.ToString(), ws.Comment);
                }
                sb.Append(table.ToString());
            }

            Clipboard.SetText(sb.ToString());
        }
示例#14
0
        void OnWorkspaceRequestClose(object sender, EventArgs e)
        {
            var senderType = sender.GetType();
            WorkspaceViewModel workspace = (WorkspaceViewModel)sender;

            this.Workspaces.Remove(workspace);
            if (senderType == typeof(AuthenticationViewModel))
            {
                HandleAuthorisationClose();
            }
            else if (senderType == typeof(CreateNewUserViewModel))
            {
                HandleCreateNewUserClose((CreateNewUserViewModel)workspace);
            }
            else if (senderType == typeof(CloudDirectoryViewModel))
            {
                ((CloudDirectoryViewModel)sender).OnSave -= CloudVmSaved;
            }
            if (Workspaces.Any())
            {
                ICollectionView collectionView = CollectionViewSource.GetDefaultView(this.Workspaces);

                DisplayName = ((ViewModelBase)collectionView.CurrentItem).DisplayName;
            }
            else
            {
                DisplayName = Strings.MainWindowViewModel_WorkspaceName;
            }
        }
示例#15
0
 private void TryLoadLastWorkspace()
 {
     if (Settings != null && IsConnected)
     {
         var name = Settings.Get(SettingsKeys.LastWorkspaceKey, string.Empty);
         if (!string.IsNullOrEmpty(name))
         {
             Workspace workspace = Workspaces.FirstOrDefault(w => w.Name == name);
             if (workspace != null && SelectedWorkspace != workspace)
             {
                 SelectedWorkspace = workspace;
             }
         }
     }
     if (SelectedWorkspace == null || Workspaces.Select(workspace => workspace.Name).All(s => s != SelectedWorkspace.Name))
     {
         if (!TfsContext.IsLocalConnected)
         {
             var versionControlExt = serviceProvider.Get <VersionControlExt>();
             if (versionControlExt.PendingChanges.Workspace != null)
             {
                 SelectedWorkspace = versionControlExt.PendingChanges.Workspace;
             }
             else if (versionControlExt.SolutionWorkspace != null)
             {
                 SelectedWorkspace = versionControlExt.SolutionWorkspace;
             }
             else
             {
                 SelectedWorkspace = Workspaces.FirstOrDefault();
             }
         }
     }
 }
示例#16
0
        void AggiungiSchedaRisultatiRicercaFiguraPerDipendente(Dipendente dipendente)
        {
            RisultatiFiguraPerDipendenteViewModel visualizza = new RisultatiFiguraPerDipendenteViewModel(dipendente);

            Workspaces.Add(visualizza);
            SetActiveWorkspace(visualizza);
        }
        public StringBuilder Execute(Dictionary<string, StringBuilder> values, Workspaces.IWorkspace theWorkspace)
        {
            try
            {


                StringBuilder tmp;
                values.TryGetValue("Resource", out tmp);
                var serializer = new Dev2JsonSerializer();

                if (tmp != null)
                {
                    var res = serializer.Deserialize<IScheduledResource>(tmp);
                    Dev2Logger.Log.Info("Get Scheduled History. " +tmp);
                    IList<IResourceHistory> resources;
                    using (var model = SchedulerFactory.CreateModel(GlobalConstants.SchedulerFolderId, SecurityWrapper))
                    {
                        resources = model.CreateHistory(res);
                    }
                    return serializer.SerializeToBuilder(resources);
                }
                Dev2Logger.Log.Debug("No resource Provided");
                return serializer.SerializeToBuilder(new List<IResourceHistory>());
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error(e);
                throw;
            }
        }
        private void AddTask(object sender)
        {
            if (IsBlockingProgress)
            {
                return;
            }

            if (Workspaces.Count == 0)
            {
                new MessageDialog("No workspaces - refresh data").ShowAsync();
                return;
            }

            AsanaWorkspace workspace = null;

            if (SettingsService.DefaultWorkspaceId.HasValue)
            {
                workspace = Workspaces.FirstOrDefault(x => x.id == SettingsService.DefaultWorkspaceId.Value);
            }
            if (workspace == null)
            {
                workspace = Workspaces.FirstOrDefault();
            }

            if (workspace == null)
            {
                return;
            }

            //ExNavigationService.Navigate<AddEditTask>("workspaceId", workspace.id);
        }
 private void OnWorkspaceRequestClose(object sender, EventArgs e)
 {
     if (sender is WorkspaceViewModel workspace)
     {
         workspace.Dispose();
         Workspaces.Remove(workspace);
     }
 }
示例#20
0
 /// <summary>
 /// Sets the concrete type registration for all contained ManagedObjectCollections
 /// </summary>
 /// <param name="concreteType"></param>
 /// <param name="registerAs"></param>
 public void RegisterType <TConcrete, TRegisterAs>()
 {
     WorkItems.RegisterType <TConcrete, TRegisterAs>();
     Items.RegisterType <TConcrete, TRegisterAs>();
     SmartParts.RegisterType <TConcrete, TRegisterAs>();
     Workspaces.RegisterType <TConcrete, TRegisterAs>();
     Services.RegisterType <TConcrete, TRegisterAs>();
 }
示例#21
0
        private void EditLog(object obj)
        {
            Workspaces.Clear();
            EditLogViewModel workspace = new EditLogViewModel(_workspaces);

            Workspaces.Add(workspace);
            SetActiveWorkspace(workspace);
        }
示例#22
0
        private void AddNewLog(object obj)
        {
            Workspaces.Clear();
            AddLogViewModel workspace = new AddLogViewModel(Workspaces);

            Workspaces.Add(workspace);
            SetActiveWorkspace(workspace);
        }
示例#23
0
 public override void Loaded(QFrameworkContainer container)
 {
     if (CurrentWorkspace == null && InvertGraphEditor.Prefs != null)
     {
         CurrentWorkspace = Workspaces.FirstOrDefault(p => p.Identifier == InvertGraphEditor.Prefs.GetString("LastLoadedWorkspace", string.Empty));
     }
     Configurations = container.ResolveAll <WorkspaceConfiguration>().ToDictionary(p => p.WorkspaceType);
 }
示例#24
0
 /// <summary>
 /// Sets the concrete type registration for all contained ManagedObjectCollections
 /// </summary>
 /// <param name="concreteType"></param>
 /// <param name="registerAs"></param>
 public void RegisterType(Type concreteType, Type registerAs)
 {
     WorkItems.RegisterType(concreteType, registerAs);
     Items.RegisterType(concreteType, registerAs);
     SmartParts.RegisterType(concreteType, registerAs);
     Workspaces.RegisterType(concreteType, registerAs);
     Services.RegisterType(concreteType, registerAs);
 }
 public void Remove(WorkspaceViewModel workspace)
 {
     if (workspace == SelectedWorkspace && lastSelection != workspace && Workspaces.Contains(lastSelection))
     {
         SelectedWorkspace = lastSelection;
     }
     Workspaces.Remove(workspace);
 }
示例#26
0
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     BigDataPools                                = new BigDataPools(this);
     Operations                                  = new Operations(this);
     IpFirewallRules                             = new IpFirewallRules(this);
     SqlPools                                    = new SqlPools(this);
     SqlPoolMetadataSyncConfigs                  = new SqlPoolMetadataSyncConfigs(this);
     SqlPoolOperationResults                     = new SqlPoolOperationResults(this);
     SqlPoolGeoBackupPolicies                    = new SqlPoolGeoBackupPolicies(this);
     SqlPoolDataWarehouseUserActivities          = new SqlPoolDataWarehouseUserActivities(this);
     SqlPoolRestorePoints                        = new SqlPoolRestorePoints(this);
     SqlPoolReplicationLinks                     = new SqlPoolReplicationLinks(this);
     SqlPoolTransparentDataEncryptions           = new SqlPoolTransparentDataEncryptions(this);
     SqlPoolBlobAuditingPolicies                 = new SqlPoolBlobAuditingPolicies(this);
     SqlPoolOperations                           = new SqlPoolOperations(this);
     SqlPoolUsages                               = new SqlPoolUsages(this);
     SqlPoolSensitivityLabels                    = new SqlPoolSensitivityLabels(this);
     SqlPoolSchemas                              = new SqlPoolSchemas(this);
     SqlPoolTables                               = new SqlPoolTables(this);
     SqlPoolTableColumns                         = new SqlPoolTableColumns(this);
     SqlPoolConnectionPolicies                   = new SqlPoolConnectionPolicies(this);
     SqlPoolVulnerabilityAssessments             = new SqlPoolVulnerabilityAssessments(this);
     SqlPoolVulnerabilityAssessmentScans         = new SqlPoolVulnerabilityAssessmentScans(this);
     SqlPoolSecurityAlertPolicies                = new SqlPoolSecurityAlertPolicies(this);
     SqlPoolVulnerabilityAssessmentRuleBaselines = new SqlPoolVulnerabilityAssessmentRuleBaselines(this);
     Workspaces                                  = new Workspaces(this);
     WorkspaceAadAdmins                          = new WorkspaceAadAdmins(this);
     WorkspaceManagedIdentitySqlControlSettings  = new WorkspaceManagedIdentitySqlControlSettings(this);
     BaseUri = new System.Uri("https://management.azure.com");
     SerializationSettings = new JsonSerializerSettings
     {
         Formatting            = Newtonsoft.Json.Formatting.Indented,
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new  List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     SerializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
     DeserializationSettings.Converters.Add(new TransformationJsonConverter());
 }
示例#27
0
        public async Task OnGet()
        {
            var teams = await _teamRepo.GetAllTeams();

            foreach (var t in teams)
            {
                Workspaces.Add(t);
            }
        }
示例#28
0
        /// <summary>
        ///     Clears all element collections on nodes and resets the visualization manager and the old value.
        /// </summary>
        private void ResetForNewDocument()
        {
            foreach (var ws in Workspaces.OfType <HomeWorkspaceModel>())
            {
                ws.MarkNodesAsModifiedAndRequestRun(ws.Nodes);
            }

            OnRevitDocumentChanged();
        }
示例#29
0
        protected void ReleaseWorkspace(TWorkspace workspace)
        {
            var poppedWorkspace = Workspaces.Pop();

            if (!poppedWorkspace.Equals(workspace))
            {
                throw new InvalidOperationException();
            }
        }
示例#30
0
        public void AddWorkspace(Workspace workspace)
        {
            if (Workspaces.Any(w => w.Name == workspace.Name))
            {
                throw new InvalidOperationException("Workspace name must be unique");
            }

            Workspaces.Add(workspace);
        }
        private void SetProcessCount(int count)
        {
            Workspaces.Clear();
            foreach (var workspace in Enumerable.Range(0, count).Select(index => new ProcessContainerViewModel((uint)index)))
            {
                Workspaces.Add(workspace);
            }

            SetActiveWorkspace(Workspaces.FirstOrDefault());
        }
示例#32
0
        //Overrides
        public override void Init()
        {
            _workspaces = new Workspaces();

            //Redirect modeling output to our (debug) logger
            ModelTrace.Enabled = false;
            ModelTrace.Out = new TestLogWriter(TestLogFlags.Trace | TestLogFlags.Ignore);

            //Delegate
            base.Init();

            HashSet<string> interestingPropertyNames = new HashSet<string>()
            {
                "AstoriaBuild",
                "Host",
                "Client",
                "DataLayerProviderKinds",
                "HostAuthenicationMethod",
                "ServerVersion",
                "ClientVersion",
                "DesignVersion",
                "UseOpenTypes"
            };

            IEnumerable<PropertyInfo> properties = typeof(AstoriaTestProperties).GetProperties(BindingFlags.Public | BindingFlags.Static).OrderBy(p => p.Name);
            IEnumerable<PropertyInfo>[] subsets = new IEnumerable<PropertyInfo>[] 
            {
                properties.Where(p =>  interestingPropertyNames.Contains(p.Name)),
                properties.Where(p => !interestingPropertyNames.Contains(p.Name))
            };
            foreach (IEnumerable<PropertyInfo> subset in subsets)
            {
                foreach (PropertyInfo property in subset)
                {
                    Type type = property.PropertyType;
                    object value = property.GetValue(null, null);
                    if (type.IsValueType || type.IsPrimitive || type == typeof(string))
                        AstoriaTestLog.WriteLineIgnore(property.Name + ": " + value);
                    else if (type.IsArray)
                        AstoriaTestLog.WriteLineIgnore(property.Name + ": {" + string.Join(", ", ((Array)value).OfType<object>().Select(o => o.ToString()).ToArray()) + "}");
                }
                AstoriaTestLog.WriteLineIgnore("");
            }

            Workspace.CreateNewWorkspaceEvent += this.HandleWorkspaceCreationEvent;
        }
        public StringBuilder Execute(Dictionary<string, StringBuilder> values, Workspaces.IWorkspace theWorkspace)
        {
            string resourceIdString = null;

            StringBuilder tmp;
            values.TryGetValue("ResourceID", out tmp);
            
            if (tmp != null)
            {
                resourceIdString = tmp.ToString();
            }

            if(resourceIdString == null)
            {
                throw new InvalidDataContractException("ResourceID is missing");
            }

            var res = new ExecuteMessage { HasError = false };

            Guid resourceId;
            var hasResourceId = Guid.TryParse(resourceIdString, out resourceId);
            if(!hasResourceId)
            {
                res.SetMessage(Resources.CompilerError_TerminationFailed);
                res.HasError = true;
            }
            var service = ExecutableServiceRepository.Instance.Get(theWorkspace.ID, resourceId);
            if(service == null)
            {
                res.SetMessage(Resources.CompilerError_TerminationFailed);
                res.HasError = true;
            }

            if(service != null)
            {
                service.Terminate();
                res.SetMessage(Resources.CompilerMessage_TerminationSuccess);
            }

            Dev2JsonSerializer serializer = new Dev2JsonSerializer();
            return serializer.SerializeToBuilder(res);
        }
        public string Execute(IDictionary<string, string> values, Workspaces.IWorkspace theWorkspace)
        {
            string roles;
            string resourceDefinition;

            values.TryGetValue("Roles", out roles);
            values.TryGetValue("ResourceXml", out resourceDefinition);

            resourceDefinition = resourceDefinition.Unescape();

            if (string.IsNullOrEmpty(roles) || string.IsNullOrEmpty(resourceDefinition))
            {
                throw new InvalidDataContractException("Roles or ResourceXml is missing");
            }

            var compiledResources = DynamicObjectHelper.GenerateObjectGraphFromString(resourceDefinition);
            if (compiledResources.Count == 0)
            {
                return string.Format("<{0}>{1}</{0}>", "Result", Resources.CompilerError_TerminationFailed);
            }

            var resource = compiledResources.First() as DynamicService;
            if (resource == null)
            {
                return string.Format("<{0}>{1}</{0}>", "Result", Resources.CompilerError_TerminationFailed);
            }

            var service = ExecutableServiceRepository.Instance.Get(theWorkspace.ID, resource.ID);
            if (service == null)
            {
                return string.Format("<{0}>{1}</{0}>", "Result", Resources.CompilerError_TerminationFailed);
            }

            var task = service.Terminate();
            task.Wait();

            return string.Format("<{0}>{1}</{0}>", "Result", Resources.CompilerMessage_TerminationSuccess);
        }
示例#35
0
        public static void SimpleTestOnSpecificContainerType(Workspaces workspaces, string containerName, string resourceTypeName, Action<ResourceContainer, ResourceType> action)
        {
            bool testRun = false;
            bool testSkipped = false;

            foreach (Workspace workspace in workspaces)
            {
                ResourceType resourceType = null;
                ResourceContainer container = null;
                IEnumerable<ResourceContainer> containers = workspace.ServiceContainer.ResourceContainers.Where(rc => rc.Name == containerName);
                if (containers.Count() > 0)
                    container = containers.First();
                if (container != null)
                {
                    if (!container.Workspace.Settings.SupportsUpdate)
                    {
                        testSkipped = true;
                        continue;
                    }
                    IEnumerable<ResourceType> resourceTypes = container.ResourceTypes.Where(rt => rt.Name == resourceTypeName).ToList();
                    if (resourceTypes.Count() > 0)
                        resourceType = resourceTypes.First();
                    action.Invoke(container, resourceType);
                    testRun = true;
                }
            }
            //Test likely to be more of a one off type of test on a specific resourceType
            if ((testRun == false) && (!testSkipped))
                throw new TestFailedException("Couldn't find a container:" + containerName + " with a type:" + resourceTypeName + " to run test with");
            else
            {
                if (testSkipped)
                    throw new TestSkippedException("Container: " + containerName + " in this workspace does not support update");
            }

        }
 public StringBuilder Execute(Dictionary<string, StringBuilder> values, Workspaces.IWorkspace theWorkspace)
 {
     Dev2JsonSerializer serialiser = new Dev2JsonSerializer();
     return serialiser.SerializeToBuilder(GetVersion().ToString());
 }
示例#37
0
        private async Task<Tuple<Solution, Solution>> TestOperationAsync(
            Workspaces.TestWorkspace workspace,
            string expectedCode,
            string operation,
            bool compareTokens)
        {
            var actions = await GetCodeActionsAsync(workspace, fixAllActionEquivalenceKey: null);
            var action = actions.Single(a => a.Title.Equals(operation, StringComparison.CurrentCulture));
            var operations = await action.GetOperationsAsync(CancellationToken.None);

            return await TestOperationsAsync(workspace,
                expectedText: expectedCode,
                operations: operations,
                conflictSpans: null,
                renameSpans: null,
                warningSpans: null,
                compareTokens: compareTokens,
                expectedChangedDocumentId: null);
        }