protected void AddTeamToProject(Project project, List <Guid> team) { foreach (var user in team.Select(r => ParticipantEngine.GetByID(r))) { ProjectEngine.AddToTeam(project, user, false); } }
public RazorTagHelperParsingBenchmark() { var current = new DirectoryInfo(AppContext.BaseDirectory); while (current != null && !File.Exists(Path.Combine(current.FullName, "taghelpers.json"))) { current = current.Parent; } var root = current; var tagHelpers = ReadTagHelpers(Path.Combine(root.FullName, "taghelpers.json")); var tagHelperFeature = new StaticTagHelperFeature(tagHelpers); var blazorServerTagHelpersFilePath = Path.Combine(root.FullName, "BlazorServerTagHelpers.razor"); var fileSystem = RazorProjectFileSystem.Create(root.FullName); ProjectEngine = RazorProjectEngine.Create(RazorConfiguration.Default, fileSystem, b => { RazorExtensions.Register(b); b.Features.Add(tagHelperFeature); }); BlazorServerTagHelpersDemoFile = fileSystem.GetItem(Path.Combine(blazorServerTagHelpersFilePath), FileKinds.Component); ComponentDirectiveVisitor = new ComponentDirectiveVisitor(blazorServerTagHelpersFilePath, tagHelpers, currentNamespace: null); var codeDocument = ProjectEngine.ProcessDesignTime(BlazorServerTagHelpersDemoFile); SyntaxTree = codeDocument.GetSyntaxTree(); }
public void ReassignTeam() { Project.Private = true; Project = ProjectEngine.SaveOrUpdate(Project, false); ProjectEngine.SetTeamSecurity(Project, From, ProjectTeamSecurity.Contacts | ProjectTeamSecurity.Files | ProjectTeamSecurity.Messages | ProjectTeamSecurity.Milestone | ProjectTeamSecurity.Tasks); ProjectsReassign.Reassign(From, To); var team = ProjectEngine.GetTeam(Project.ID).Select(r => r.ID).ToList(); Assert.That(team, Has.No.Member(From)); Assert.That(team, Has.Member(To)); var security = ProjectEngine.GetTeamSecurity(Project, To); Assert.That(security & ProjectTeamSecurity.Tasks, Is.EqualTo(ProjectTeamSecurity.Tasks)); Assert.That(security & ProjectTeamSecurity.Contacts, Is.EqualTo(ProjectTeamSecurity.Contacts)); Assert.That(security & ProjectTeamSecurity.Files, Is.EqualTo(ProjectTeamSecurity.Files)); Assert.That(security & ProjectTeamSecurity.Messages, Is.EqualTo(ProjectTeamSecurity.Messages)); Assert.That(security & ProjectTeamSecurity.Milestone, Is.EqualTo(ProjectTeamSecurity.Milestone)); }
/// <summary> /// Parses the template specified by <paramref name="projectItem"/>. /// </summary> /// <param name="projectItem">The <see cref="RazorLightProjectItem"/>.</param> /// <returns>The <see cref="IGeneratedRazorTemplate"/>.</returns> public async Task <IGeneratedRazorTemplate> GenerateCodeAsync(RazorLightProjectItem projectItem) { if (projectItem == null) { throw new ArgumentNullException(nameof(projectItem)); } if (!projectItem.Exists) { throw new InvalidOperationException($"{nameof(RazorLightProjectItem)} of type " + $"{projectItem.GetType().FullName} with key {projectItem.Key} does not exist."); } RazorCodeDocument codeDocument = await CreateCodeDocumentAsync(projectItem); ProjectEngine.Process(codeDocument); RazorCSharpDocument document = codeDocument.GetCSharpDocument(); if (document.Diagnostics.Count > 0) { var builder = new StringBuilder(); builder.AppendLine("Failed to generate Razor template. See \"Diagnostics\" property for more details"); foreach (RazorDiagnostic d in document.Diagnostics) { builder.AppendLine($"- {d.GetMessage()}"); } throw new TemplateGenerationException(builder.ToString(), document.Diagnostics); } return(new GeneratedRazorTemplate(projectItem, document)); }
public async Task <IGeneratedRazorTemplate> GenerateCodeAsync(TkRazorProjectItem projectItem) { TkDebug.AssertArgumentNull(projectItem, nameof(projectItem), this); if (!projectItem.Exists) { throw new ToolkitException($"Project can not find template with key {projectItem.Key}", this); } RazorCodeDocument codeDocument = await CreateCodeDocumentAsync(projectItem); ProjectEngine.Process(codeDocument); RazorCSharpDocument document = codeDocument.GetCSharpDocument(); if (document.Diagnostics.Count > 0) { var builder = new StringBuilder(); builder.AppendLine("Failed to generate Razor template. See \"Diagnostics\" property for more details"); foreach (RazorDiagnostic d in document.Diagnostics) { builder.AppendLine($"- {d.GetMessage()}"); } throw new TemplateGenerationException(builder.ToString(), document.Diagnostics, this); } return(new GeneratedRazorTemplate(projectItem, document)); }
//Ładowanie fomratki private void Form2_Load(object sender, EventArgs e) { //Inicjalizacja obiektów niezbędnych do działania formatki pictureBox1.Image = ImageToShow; pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize; pictureOriginal = (Bitmap)ImageToShow.Clone(); directBitmap = new DirectBitmap(pictureOriginal); directBitmapOrig = new DirectBitmap(directBitmap); directBitmapPost = new DirectBitmap(directBitmap); histogramDataLineRGB = new HistogramData(); directBitmapOrig.generateHSVBits(); formCaller.histogramDataRGBMainProp = directBitmap.generateHistogram(); formCaller.histogramDataHSVProp = directBitmap.generateHistogramHSV(); projectEngine = new ProjectEngine(); formCaller.ser1.IsVisibleInLegend = true; formCaller.ser2.IsVisibleInLegend = true; formCaller.ser3.IsVisibleInLegend = true; formCaller.seriesHExt.IsVisibleInLegend = true; formCaller.seriesSExt.IsVisibleInLegend = true; formCaller.seriesVExt.IsVisibleInLegend = true; }
private void AddToTeam(Project project, Guid userId) { if (!FromUserProjects.Exists(r => r.ID == project.ID) && !ToUserProjects.Exists(r => r.ID == project.ID)) { ProjectEngine.AddToTeam(project, userId, false); ToUserProjects.Add(project); } }
private RazorCodeDocument CreateDocument(string content) { // Normalize newlines since we are testing lengths of things. content = content.Replace("\r", ""); content = content.Replace("\n", "\r\n"); var source = RazorSourceDocument.Create(content, "test.cshtml"); return(ProjectEngine.CreateCodeDocumentCore(source, FileKinds.Component)); }
public void ReassignProjectManager() { Project.Responsible = From; ProjectEngine.SaveOrUpdate(Project, false); ProjectsReassign.Reassign(From, To); Project = ProjectEngine.GetByID(Project.ID); Assert.That(Project.Responsible, Is.EqualTo(To)); }
public static void Init(TestContext context) { WebItemManager.Instance.LoadItems(); CoreContext.TenantManager.SetCurrentTenant(0); var tenant = CoreContext.TenantManager.GetCurrentTenant(); SecurityContext.AuthenticateMe(tenant.OwnerId); OwnerId = tenant.OwnerId; ProjectEngine = new EngineFactory("test", TenantProvider.CurrentTenantID).ProjectEngine; }
public void CodeGeneration_Runtime_LargeStaticFile() { var codeDocument = ProjectEngine.Process(MSN); var generated = codeDocument.GetCSharpDocument(); if (generated.Diagnostics.Count != 0) { throw new Exception("Error!" + Environment.NewLine + string.Join(Environment.NewLine, generated.Diagnostics)); } }
public void Reassign(Guid fromUserId, Guid toUserId) { FromUserProjects = ProjectEngine.GetByParticipant(fromUserId).ToList(); ToUserProjects = ProjectEngine.GetByParticipant(toUserId).ToList(); ReplaceTeam(fromUserId, toUserId); ReassignProjectManager(fromUserId, toUserId); ReassignMilestones(fromUserId, toUserId); ReassignTasks(fromUserId, toUserId); ReassignSubtasks(fromUserId, toUserId); }
private void ReplaceTeam(Guid fromUserId, Guid toUserId) { foreach (var project in FromUserProjects) { var teamSecurity = ProjectEngine.GetTeamSecurity(project, fromUserId); if (!ToUserProjects.Exists(r => r.ID == project.ID)) { ProjectEngine.AddToTeam(project, toUserId, false); ProjectEngine.SetTeamSecurity(project, toUserId, teamSecurity); } ProjectEngine.RemoveFromTeam(project, fromUserId, false); } }
private void ReassignProjectManager(Guid fromUserId, Guid toUserId) { var filter = new TaskFilter { UserId = fromUserId, ProjectStatuses = new List <ProjectStatus> { ProjectStatus.Open, ProjectStatus.Paused } }; var projects = ProjectEngine.GetByFilter(filter); foreach (var project in projects) { project.Responsible = toUserId; ProjectEngine.SaveOrUpdate(project, false); } }
public void Execute_DuplicatedIdentifiers_ColumnFilterped(string id1, string id2) { var rs = new NBi.Core.ResultSet.ResultSet(); rs.Load("a;1;120"); rs.Columns[0].ColumnName = "Foo"; rs.Columns[1].ColumnName = "Col1"; rs.Columns[2].ColumnName = "Col2"; var factory = new ColumnIdentifierFactory(); var filter = new ProjectEngine(new ProjectArgs(new[] { factory.Instantiate(id1), factory.Instantiate(id2) })); filter.Execute(rs); Assert.That(rs.Columns.Count, Is.EqualTo(1)); }
public void Execute_MultipleIdentifiersNotSameOrder_ColumnFilteredOrderChanged(string id1, string id2) { var rs = new NBi.Core.ResultSet.ResultSet(); rs.Load("a;1;120"); rs.Columns[0].ColumnName = "Foo"; rs.Columns[1].ColumnName = "Col1"; rs.Columns[2].ColumnName = "Bar"; var factory = new ColumnIdentifierFactory(); var project = new ProjectEngine(new ProjectArgs(new[] { factory.Instantiate(id1), factory.Instantiate(id2) })); project.Execute(rs); Assert.That(rs.Columns.Count, Is.EqualTo(2)); Assert.That(rs.Columns[0].ColumnName, Is.EqualTo("Bar")); Assert.That(rs.Columns[1].ColumnName, Is.EqualTo("Foo")); }
public void Reassign(Guid fromUserId, Guid toUserId) { using (var scope = DIHelper.Resolve(true)) { var factory = scope.Resolve <EngineFactory>(); ProjectEngine = factory.ProjectEngine; MilestoneEngine = factory.MilestoneEngine; TaskEngine = factory.TaskEngine; SubtaskEngine = factory.SubtaskEngine; FromUserProjects = ProjectEngine.GetByParticipant(fromUserId).ToList(); ToUserProjects = ProjectEngine.GetByParticipant(toUserId).ToList(); ReplaceTeam(fromUserId, toUserId); ReassignProjectManager(fromUserId, toUserId); ReassignMilestones(fromUserId, toUserId); ReassignTasks(fromUserId, toUserId); ReassignSubtasks(fromUserId, toUserId); } }
protected Project SaveOrUpdate(Project project) { return(ProjectEngine.SaveOrUpdate(project, false)); }
protected Project Get(Project project) { return(ProjectEngine.GetByID(project.ID)); }
protected List <Guid> GetTeam(int projectId) { return(ProjectEngine.GetTeam(projectId).Select(r => r.ID).ToList()); }
public void CleanupTest() { ProjectEngine.Delete(Project.ID); }
public void InitTest() { Project = ProjectEngine.SaveOrUpdate(DataGenerator.GenerateProject(Admin), false); ProjectEngine.AddToTeam(Project, From, false); }
protected void Delete(Project project) { ProjectEngine.Delete(project.ID); }
protected void RestrictAccess(Guid userID, ProjectTeamSecurity projectTeamSecurity, bool visible) { SecurityContext.AuthenticateMe(Owner); ProjectEngine.SetTeamSecurity(Project, ParticipantEngine.GetByID(userID), projectTeamSecurity, visible); }
public void TagHelper_ProcessDesignTime() { _ = ProjectEngine.ProcessDesignTime(BlazorServerTagHelpersDemoFile); }
private RazorCodeDocument CreateDocument(string content) { var source = RazorSourceDocument.Create(content, "test.cshtml"); return(ProjectEngine.CreateCodeDocumentCore(source, FileKinds.Component)); }
public ProjectController() { projectEngine = new ProjectEngine(); }