//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Releases unmanaged resources and optionally releases managed resources. </summary> /// /// <remarks> Aedmonds, 8/25/2017. </remarks> /// /// <param name="disposing"> true to release both managed and unmanaged resources; false to /// release only unmanaged resources. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// protected override void Dispose(bool disposing) { if (disposing) { if (_userManager != null) { _userManager.Dispose(); _userManager = null; } if (_signInManager != null) { _signInManager.Dispose(); _signInManager = null; } if (appDb != null) { appDb.Dispose(); appDb = null; } if (db != null) { db.Dispose(); db = null; } } base.Dispose(disposing); }
private void LoadWorkspaces(long sharedSpaceId) { WorkspaceContext defaultWorkspaceContext = new WorkspaceContext(sharedSpaceId, 1002); LogicalQueryPhrase byName = new LogicalQueryPhrase(WorkspaceUser.NAME_FIELD, txtName.Text); List <QueryPhrase> queries = new List <QueryPhrase>(); queries.Add(byName); EntityListResult <WorkspaceUser> users = EntityService.GetInstance().Get <WorkspaceUser>(defaultWorkspaceContext, queries, null); long userId = users.data[0].Id; SharedSpaceContext context = new SharedSpaceContext(sharedSpaceId); LogicalQueryPhrase byUserId = new LogicalQueryPhrase(WorkspaceUser.ID_FIELD, userId); CrossQueryPhrase byUser = new CrossQueryPhrase(Workspace.USERS_FIELD, byUserId); queries = new List <QueryPhrase>(); queries.Add(byUser); EntityListResult <Workspace> workspaces = EntityService.GetInstance().Get <Workspace>(context, queries, null); //User user = GetSharedSpaceUser(sharedSpaceId, txtName.Text); FillCombo <Workspace>(cmbWorkspace, workspaces.data); }
public static ProjectState Create(string appPath, string configuration, WorkspaceContext workspaceContext, IEnumerable <string> currentSearchPaths) { var projectContextsCollection = workspaceContext.GetProjectContextCollection(appPath); if (!projectContextsCollection.ProjectContexts.Any()) { throw new InvalidOperationException($"Unable to find project.json in '{appPath}'"); } var project = projectContextsCollection.ProjectContexts.First().ProjectFile; var projectDiagnostics = new List <DiagnosticMessage>(projectContextsCollection.ProjectDiagnostics); var projectInfos = new List <ProjectInfo>(); foreach (var projectContext in projectContextsCollection.ProjectContexts) { projectInfos.Add(new ProjectInfo( projectContext, configuration, currentSearchPaths)); } return(new ProjectState(project, projectDiagnostics, projectInfos)); }
public static string GetEntityLink(RestConnector connector, WorkspaceContext context, BaseEntity entity) { string entityType = entity.AggregateType != null ? entity.AggregateType : entity.TypeName; return(string.Format("{0}/ui/entity-navigation?p={1}/{2}&entityType={3}&id={4}", connector.Host, context.SharedSpaceId, context.WorkspaceId, entityType, entity.Id.ToString() )); }
public Program(int port, string hostName, ILoggerFactory loggerFactory) { _port = port; _hostName = hostName; _loggerFactory = loggerFactory; _protocolManager = new ProtocolManager(maxVersion: 4, loggerFactory: _loggerFactory); _workspaceContext = WorkspaceContext.Create(); _projects = new Dictionary <int, ProjectManager>(); }
public Program(int port, string hostName, ILoggerFactory loggerFactory) { _port = port; _hostName = hostName; _loggerFactory = loggerFactory; _protocolManager = new ProtocolManager(maxVersion: 4, loggerFactory: _loggerFactory); _workspaceContext = WorkspaceContext.Create(); _projects = new Dictionary<int, ProjectManager>(); }
public static WorkItemRoot GetWorkItemRoot(EntityService entityService, WorkspaceContext workspaceContext) { List <String> fields = new List <String>() { Phase.NAME_FIELD }; EntityListResult <WorkItemRoot> result = entityService.Get <WorkItemRoot>(workspaceContext, null, fields); WorkItemRoot root = result.data[0]; return(root); }
public static void AssemblyInitialize(TestContext context) { // Check if .runsettings is configured properly EnsurePropertiesSet(context.Properties, "ignoreServerCertificateValidation", "webAppUrl", "userName", "password", "sharedSpaceId", "workspaceId"); var ignoreServerCertificateValidation = context.Properties["ignoreServerCertificateValidation"].ToString(); if (ignoreServerCertificateValidation != null && ignoreServerCertificateValidation.ToLower().Equals("true")) { NetworkSettings.IgnoreServerCertificateValidation(); } NetworkSettings.EnableAllSecurityProtocols(); OctaneConfiguration.Url = context.Properties["webAppUrl"].ToString(); OctaneConfiguration.Username = context.Properties["userName"].ToString(); OctaneConfiguration.Password = context.Properties["password"].ToString(); var connectionInfo = new UserPassConnectionInfo(OctaneConfiguration.Username, OctaneConfiguration.Password); RestConnector.Connect(OctaneConfiguration.Url, connectionInfo); var sharedSpaceId = int.Parse(context.Properties["sharedSpaceId"].ToString()); var workspaceId = int.Parse(context.Properties["workspaceId"].ToString()); WorkspaceContext = new WorkspaceContext(sharedSpaceId, workspaceId); OctaneConfiguration.WorkSpaceId = WorkspaceContext.WorkspaceId; var sharedSpaceContext = new SharedSpaceContext(sharedSpaceId); OctaneConfiguration.SharedSpaceId = sharedSpaceContext.SharedSpaceId; OctaneConfiguration.SsoLogin = bool.Parse(context.Properties["ssoLogin"].ToString()); OctaneConfiguration.CredentialLogin = bool.Parse(context.Properties["credentialLogin"].ToString()); User = GetWorkspaceUser(); CurrentRelease = ReleaseUtilities.CreateRelease(); // create the octaneservices object to be used by the tests OctaneServices.Create(OctaneConfiguration.Url, OctaneConfiguration.SharedSpaceId, OctaneConfiguration.WorkSpaceId); OctaneServices.GetInstance().Connect(); }
public void GetOnlyDefectWithGroupSeverityTest(WorkspaceContext context) { List <String> fields = new List <string>(); fields.Add(WorkItem.NAME_FIELD); fields.Add(WorkItem.SUBTYPE_FIELD); List <QueryPhrase> queries = new List <QueryPhrase>(); LogicalQueryPhrase subtypeQuery = new LogicalQueryPhrase(WorkItem.SUBTYPE_FIELD, WorkItem.SUBTYPE_DEFECT); queries.Add(subtypeQuery); //~work_items/groups?group_by=severity&query="(subtype='defect'); GroupResult result = entityService.GetWithGroupBy <WorkItem>(context, queries, Defect.SEVERITY_FIELD); }
private void LoadReleases(long sharedSpaceId, long workspaceId) { WorkspaceContext context = new WorkspaceContext(sharedSpaceId, workspaceId); EntityListResult <Release> result = EntityService.GetInstance().Get <Release>(context); if (result != null) { FillCombo <Release>(cmbRelease, result.data); EnableLoginButton(true); } else { ClearCombo(cmbRelease); } }
private static void GenerateDefaultWorkspace(ApplicationUser user) { WorkspaceContext db = new WorkspaceContext(); String WHITECOLORSTRING = "255,255,255,1"; Workspace initWorkspace = new Workspace(); initWorkspace.UserId = user.Email; initWorkspace.s = 1; initWorkspace.Filename = Guid.NewGuid().ToString(); db.Workspaces.Add(initWorkspace); ColorSelection initColorSelection = new ColorSelection(); initColorSelection.WorkspaceId = initWorkspace.Id; initColorSelection.InternalColorString = WHITECOLORSTRING; initColorSelection.InternalHSL = "0,0,0"; initColorSelection.Favorite = false; db.ColorSelections.Add(initColorSelection); for (int i = 0; i < 10; i++) { initColorSelection = new ColorSelection(); initColorSelection.WorkspaceId = initWorkspace.Id; initColorSelection.InternalColorString = WHITECOLORSTRING; initColorSelection.InternalHSL = "0,0,0"; initColorSelection.Favorite = true; db.ColorSelections.Add(initColorSelection); } db.SaveChanges(); Grid initGrid = new Grid(); initGrid.WorkspaceId = initWorkspace.Id; initGrid.Width = 10; initGrid.Height = 10; initGrid.HorizontalWeight = 1; initGrid.VerticalWeight = 1; initGrid.s = 1; initGrid.InternalTopLeftColorString = WHITECOLORSTRING; initGrid.InternalTopRightColorString = WHITECOLORSTRING; initGrid.InternalBottomLeftColorString = WHITECOLORSTRING; initGrid.InternalBottomRightColorString = WHITECOLORSTRING; initGrid.Filename = Guid.NewGuid().ToString(); db.Grids.Add(initGrid); db.SaveChanges(); }
public static void InitConnection(TestContext context) { if (!restConnector.IsConnected()) { string host = ConfigurationManager.AppSettings["webAppUrl"]; string password = ConfigurationManager.AppSettings["password"]; userName = ConfigurationManager.AppSettings["userName"]; restConnector.Connect(host, userName, password); sharedSpaceId = int.Parse(ConfigurationManager.AppSettings["sharedSpaceId"]); workspaceId = int.Parse(ConfigurationManager.AppSettings["workspaceId"]); workspaceContext = new WorkspaceContext(sharedSpaceId, workspaceId); sharedSpaceContext = new SharedSpaceContext(sharedSpaceId); } }
//TODO: Fix this - Error is 403 forbidden: EXTENSION_TO_MIME_TYPE is the problem I think, because it says //something regarding the text/plain content type and we try to upload something of type .txt (not sure) public void DetailedItemViewModelTests_HandleImagesInDescription_DownloadImage_Success() { var fileName = "DetailedItemViewModelTests_HandleImagesInDescription_" + Guid.NewGuid() + ".txt"; var fileContentsBytes = new byte[2500]; var rnd = new Random(); rnd.NextBytes(fileContentsBytes); Api.Core.Connector.RestConnector.AwaitContinueOnCapturedContext = false; // simulating uploading a picture; using plain text to also test content randomness var attachment = EntityService.AttachToEntity(WorkspaceContext, _story, fileName, fileContentsBytes, "text/plain", new string[] { "owner_work_item" }); Assert.IsNotNull(attachment.Id, "Attachment id shouldn't be null"); Assert.AreEqual(WorkItem.SUBTYPE_STORY, attachment.owner_work_item.TypeName, "Mismatched attachment parent type"); Assert.AreEqual(_story.Id, attachment.owner_work_item.Id, "Mismatched attachment parent id"); var updatedStory = new Story(_story.Id); updatedStory.SetValue(CommonFields.Description, "<html><body>" + "<div style=\"\">" + "<img data-size-percentage=\"100\" src=\"" + WorkspaceContext.GetPath() + "/attachments/" + attachment.Id + "/" + fileName + "\" style=\"width:437px;height:303px;\" />" + "</div>" + "<p> </p>" + "</body></html>"); updatedStory = EntityService.Update(WorkspaceContext, updatedStory, new[] { "name", "subtype", CommonFields.Description }); var viewModel = new DetailedItemViewModel(updatedStory); viewModel.InitializeAsync().Wait(); var path = DetailedItemViewModel.TempPath + WorkItem.SUBTYPE_STORY + updatedStory.Id + fileName; ValidateFileContents(path, fileContentsBytes); var fileInfo = new FileInfo(path); var expectedLastWriteTime = fileInfo.LastWriteTime; Thread.Sleep(1000); viewModel.RefreshCommand.Execute(null); fileInfo = new FileInfo(path); Assert.AreEqual(expectedLastWriteTime, fileInfo.LastWriteTime, "Downloaded attachement was modified by refresh"); }
public static void InitConnection(TestContext context) { if (!restConnector.IsConnected()) { string ignoreServerCertificateValidation = ConfigurationManager.AppSettings["ignoreServerCertificateValidation"]; if (ignoreServerCertificateValidation != null && ignoreServerCertificateValidation.ToLower().Equals("true")) { NetworkSettings.IgnoreServerCertificateValidation(); } NetworkSettings.EnableAllSecurityProtocols(); host = ConfigurationManager.AppSettings["webAppUrl"]; // If webAppUrl is empty we do not try to connect. if (string.IsNullOrWhiteSpace(host)) { return; } ConnectionInfo connectionInfo; string clientId = ConfigurationManager.AppSettings["clientId"]; if (clientId != null) { userName = clientId; connectionInfo = new APIKeyConnectionInfo(clientId, ConfigurationManager.AppSettings["clientSecret"]); } else { userName = ConfigurationManager.AppSettings["userName"]; password = ConfigurationManager.AppSettings["password"]; connectionInfo = new UserPassConnectionInfo(userName, password); } lwssoAuthenticationStrategy = new LwssoAuthenticationStrategy(connectionInfo); restConnector.Connect(host, lwssoAuthenticationStrategy); var sharedSpaceId = int.Parse(ConfigurationManager.AppSettings["sharedSpaceId"]); var workspaceId = int.Parse(ConfigurationManager.AppSettings["workspaceId"]); workspaceContext = new WorkspaceContext(sharedSpaceId, workspaceId); sharedSpaceContext = new SharedSpaceContext(sharedSpaceId); } }
public void Initalize(IConfiguration configuration) { _logger.LogInformation($"Initializing in {_environment.Path}"); if (!bool.TryParse(configuration["enablePackageRestore"], out _enableRestorePackages)) { _enableRestorePackages = false; } _logger.LogInformation($"Auto package restore: {_enableRestorePackages}"); _workspaceContext = WorkspaceContext.CreateFrom(_environment.Path); if (_workspaceContext == null) { throw new NotImplementedException($"Failed to initialize {typeof(WorkspaceContext)} at {_environment.Path}."); } Update(allowRestore: true); }
public static Phase GetPhaseForEntityByName(WorkspaceContext workspaceContext, String entityTypeName, String name) { List <QueryPhrase> queryPhrases = new List <QueryPhrase>(); LogicalQueryPhrase byEntityPhrase = new LogicalQueryPhrase(Phase.ENTITY_FIELD, entityTypeName); LogicalQueryPhrase byNamePhrase = new LogicalQueryPhrase(Phase.NAME_FIELD, name); queryPhrases.Add(byEntityPhrase); queryPhrases.Add(byNamePhrase); List <String> fields = new List <String>() { Phase.NAME_FIELD, Phase.LOGICAL_NAME_FIELD }; EntityListResult <Phase> result = entityService.Get <Phase>(workspaceContext, queryPhrases, fields); Assert.AreEqual(1, result.total_count); Phase phase = result.data[0]; return(phase); }
private Workspace(string path, bool exists) { if (!exists) { CreateDB(path); } else { FileInfo fi = new FileInfo(path); if (!fi.Exists) { throw new Exception("File not found: " + path); } } this.Path = path; this.Directory = (new FileInfo(path)).DirectoryName; db = WorkspaceContext.GetContext(path); }
private OctaneServices(string url, long sharedspaceId, long workspaceId) { this.url = url; // create the authentication strategy based on saved configurations if (OctaneConfiguration.CredentialLogin) { authenticationStrategy = new LwssoAuthenticationStrategy(new UserPassConnectionInfo(OctaneConfiguration.Username, OctaneConfiguration.Password)); } else if (OctaneConfiguration.SsoLogin) { SsoAuthenticationStrategy ssoAuthenticationStrategy = new SsoAuthenticationStrategy(); ssoAuthenticationStrategy.SetConnectionListener(new SsoConnectionListener()); authenticationStrategy = ssoAuthenticationStrategy; } rest = new RestConnector(); es = new EntityService(rest); workspaceContext = new WorkspaceContext(sharedspaceId, workspaceId); sharedSpaceContext = new SharedSpaceContext(sharedspaceId); }
public static ListNode GetSeverityByName(WorkspaceContext workspaceContext, String name) { List <QueryPhrase> queryPhrases = new List <QueryPhrase>(); LogicalQueryPhrase byLogicalName = new LogicalQueryPhrase(ListNode.LOGICAL_NAME_FIELD, "list_node.severity.*"); queryPhrases.Add(byLogicalName); LogicalQueryPhrase byName = new LogicalQueryPhrase(ListNode.NAME_FIELD, name); queryPhrases.Add(byName); List <String> fields = new List <String>() { Phase.NAME_FIELD, Phase.LOGICAL_NAME_FIELD }; EntityListResult <ListNode> result = entityService.Get <ListNode>(workspaceContext, queryPhrases, fields); Assert.AreEqual(1, result.total_count); ListNode listNode = result.data[0]; return(listNode); }
public static ListNode GetSeverityByName(EntityService entityService, WorkspaceContext workspaceContext, String name) { String suffix = name.ToLower().Replace(" ", "_"); String logicalName = "list_node.severity." + suffix; List <QueryPhrase> queryPhrases = new List <QueryPhrase>(); LogicalQueryPhrase byLogicalName = new LogicalQueryPhrase(ListNode.LOGICAL_NAME_FIELD, logicalName); queryPhrases.Add(byLogicalName); // LogicalQueryPhrase byName = new LogicalQueryPhrase(ListNode.NAME_FIELD, name); //queryPhrases.Add(byName); List <String> fields = new List <String>() { Phase.NAME_FIELD, Phase.LOGICAL_NAME_FIELD }; EntityListResult <ListNode> result = entityService.Get <ListNode>(workspaceContext, queryPhrases, fields); ListNode listNode = result.data[0]; return(listNode); }
public ProjectManager(int contextId, ILoggerFactory loggerFactory, WorkspaceContext workspaceContext, ProtocolManager protocolManager) { Id = contextId; _log = loggerFactory.CreateLogger <ProjectManager>(); _workspaceContext = workspaceContext; _protocolManager = protocolManager; _messengers = new List <Messenger <ProjectContextSnapshot> > { new DependencyDiagnosticsMessenger(Transmit), new DependenciesMessenger(Transmit), new CompilerOptionsMessenger(Transmit), new ReferencesMessenger(Transmit), new SourcesMessenger(Transmit) }; _projectDiagnosticsMessenger = new ProjectDiagnosticsMessenger(Transmit); _globalErrorMessenger = new GlobalErrorMessenger(Transmit); _projectInforamtionMessenger = new ProjectInformationMessenger(Transmit); }
public static ProjectSnapshot Create(string projectDirectory, string configuration, WorkspaceContext workspaceContext, IReadOnlyList<string> projectSearchPaths) { var projectContextsCollection = workspaceContext.GetProjectContextCollection(projectDirectory); if (!projectContextsCollection.ProjectContexts.Any()) { throw new InvalidOperationException($"Unable to find project.json in '{projectDirectory}'"); } GlobalSettings globalSettings; var currentSearchPaths = projectContextsCollection.Project.ResolveSearchPaths(out globalSettings); var snapshot = new ProjectSnapshot(); snapshot.Project = projectContextsCollection.Project; snapshot.ProjectDiagnostics = new List<DiagnosticMessage>(projectContextsCollection.ProjectDiagnostics); snapshot.ProjectSearchPaths = currentSearchPaths.ToList(); snapshot.GlobalJsonPath = globalSettings?.FilePath; foreach (var projectContext in projectContextsCollection.ProjectContexts) { snapshot.ProjectContexts[projectContext.TargetFramework] = ProjectContextSnapshot.Create(projectContext, configuration, currentSearchPaths); } return snapshot; }
public ConnectionContext(Socket acceptedSocket, string hostName, ProtocolManager protocolManager, WorkspaceContext workspaceContext, IDictionary <int, ProjectContextManager> projectContextManagers, ILoggerFactory loggerFactory) { _hostName = hostName; _projectContextManagers = projectContextManagers; _queue = new ProcessingQueue(new NetworkStream(acceptedSocket), loggerFactory); _queue.OnReceive += message => { if (protocolManager.IsProtocolNegotiation(message)) { message.Sender = this; protocolManager.Negotiate(message); } else { message.Sender = this; ProjectContextManager keeper; if (!_projectContextManagers.TryGetValue(message.ContextId, out keeper)) { keeper = new ProjectContextManager(message.ContextId, loggerFactory, workspaceContext, protocolManager); _projectContextManagers[message.ContextId] = keeper; } keeper.OnReceive(message); } }; }
public ConnectionContext(Socket acceptedSocket, string hostName, ProtocolManager protocolManager, WorkspaceContext workspaceContext, IDictionary<int, ProjectManager> projects, ILoggerFactory loggerFactory) { _hostName = hostName; _projects = projects; _queue = new ProcessingQueue(new NetworkStream(acceptedSocket), loggerFactory); _queue.OnReceive += message => { if (protocolManager.IsProtocolNegotiation(message)) { message.Sender = this; protocolManager.Negotiate(message); } else { message.Sender = this; ProjectManager projectManager; if (!_projects.TryGetValue(message.ContextId, out projectManager)) { projectManager = new ProjectManager(message.ContextId, loggerFactory, workspaceContext, protocolManager); _projects[message.ContextId] = projectManager; } projectManager.OnReceive(message); } }; }
public static Phase GetPhaseForEntityByLogicalName(EntityService entityService, WorkspaceContext workspaceContext, string entityTypeName, string logicalName) { List <QueryPhrase> queryPhrases = new List <QueryPhrase>(); LogicalQueryPhrase byEntityPhrase = new LogicalQueryPhrase(Phase.ENTITY_FIELD, entityTypeName); LogicalQueryPhrase byNamePhrase = new LogicalQueryPhrase(Phase.LOGICAL_NAME_FIELD, logicalName); queryPhrases.Add(byEntityPhrase); queryPhrases.Add(byNamePhrase); EntityListResult <Phase> result = entityService.Get <Phase>(workspaceContext, queryPhrases, null); Assert.AreEqual(1, result.total_count); Phase phase = result.data[0]; return(phase); }
public static void init(string sharedSpaceId, string workspaceId, string releaseId) { workspaceContext = GetWorkspaceContext(sharedSpaceId, workspaceId); selectedReleaseId = releaseId; }
private static WorkspaceContext GetWorkspaceContext(string sharedSpaceId, string workspaceId) { return(WorkspaceContext.Create(sharedSpaceId, workspaceId)); }
public static ProjectSnapshot Create(string projectDirectory, string configuration, WorkspaceContext workspaceContext, IReadOnlyList <string> projectSearchPaths) { var projectContextsCollection = workspaceContext.GetProjectContextCollection(projectDirectory); if (!projectContextsCollection.ProjectContexts.Any()) { throw new InvalidOperationException($"Unable to find project.json in '{projectDirectory}'"); } GlobalSettings globalSettings; var currentSearchPaths = projectContextsCollection.Project.ResolveSearchPaths(out globalSettings); var snapshot = new ProjectSnapshot(); snapshot.Project = projectContextsCollection.Project; snapshot.ProjectDiagnostics = new List <DiagnosticMessage>(projectContextsCollection.ProjectDiagnostics); snapshot.ProjectSearchPaths = currentSearchPaths.ToList(); snapshot.GlobalJsonPath = globalSettings?.FilePath; foreach (var projectContext in projectContextsCollection.ProjectContexts) { snapshot.ProjectContexts[projectContext.TargetFramework] = ProjectContextSnapshot.Create(projectContext, configuration, currentSearchPaths); } return(snapshot); }