コード例 #1
0
    private void ExportProjectToDirectory(OneSkyService oneSkyService, ProjectGroup projectGroup, string ProjectName)
    {
        var project = GetProject(oneSkyService, projectGroup.Name, ProjectName);
        var file = project.UploadedFiles.FirstOrDefault(f => f.Filename == (ProjectName + ".po"));

        //Export
        if (file != null)
        {
            ExportFileToDirectory(file, new DirectoryInfo(CmdEnv.LocalRoot + "/Engine/Content/Localization/" + ProjectName), project.EnabledCultures);
        }
    }
コード例 #2
0
        protected override void ExecuteWorkImplementation()
        {
            var targetProjectGroup  = m_projectRepository.GetProjectGroupWithProjects(m_targetProjectId);
            var currentProjectGroup = m_projectRepository.GetProjectGroupWithProjects(m_selectedProjectId);
            var currentGroupCount   = currentProjectGroup?.Projects.Count;

            if (targetProjectGroup == null)
            {
                // Create new group

                var targetProject   = m_projectRepository.FindById <Project>(m_targetProjectId);
                var selectedProject = m_projectRepository.FindById <Project>(m_selectedProjectId);

                var newProjectGroup = new ProjectGroup
                {
                    CreateTime = DateTime.UtcNow,
                    Projects   = null,
                };

                targetProject.ProjectGroup   = newProjectGroup;
                selectedProject.ProjectGroup = newProjectGroup;

                m_projectRepository.Create(newProjectGroup);
                m_projectRepository.Update(targetProject);
                m_projectRepository.Update(selectedProject);
            }
            else
            {
                // Update group

                var selectedProject = m_projectRepository.FindById <Project>(m_selectedProjectId);

                selectedProject.ProjectGroup = targetProjectGroup;

                m_projectRepository.Update(selectedProject);
            }


            if (currentGroupCount != null && currentGroupCount <= 1)
            {
                m_projectRepository.Delete(currentProjectGroup);
            }
        }
コード例 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (null != Request["id"])
        {
            iProjectGroupID = Convert.ToInt32(Request["id"]);
        }
        if (!IsPostBack && iProjectGroupID > 0)
        {
            ProjectGroup oProjectGroup = new ProjectGroup();
            oProjectGroup.LoadByPrimaryKey(iProjectGroupID);

            this.tbName.Text        = oProjectGroup.Name;
            this.tbDescription.Text = oProjectGroup.Description;
        }
        else
        {
            UpdateLink.Text = "Insert";
        }
    }
コード例 #4
0
ファイル: Program.cs プロジェクト: CADbloke/ProjectSync
        static void Main(string[] args)
        {
            var solution = new Solution(@"C:\src\NUnit\nunit-framework\NUnitFramework.sln");

            var projectgroup = new ProjectGroup("nunit.framework");

            solution.ProjectGroups.Add(projectgroup);

            var project = new Project("nunit-framework-2.0");

            project.Ignore.Add("async.cs");
            project.Ignore.Add("lambda.cs");

            projectgroup.Projects.Add(project);
            projectgroup.Projects.Add(new Project("nunit-framework-3.5"));
            projectgroup.Projects.Add(new Project("nunit-framework-4.0"));
            projectgroup.Projects.Add(new Project("nunit-framework-4.5"));

            solution.SerializeToFile("nunit.xml");
        }
コード例 #5
0
        /// <summary>
        /// Map from a ProjectGroup
        /// </summary>
        /// <param name="fromGroup">From group.</param>
        /// <returns></returns>
        public static ProjectGroupViewModel MapFrom(ProjectGroup fromGroup)
        {
            var group = new ProjectGroupViewModel();

            group.Name       = fromGroup.Name;
            group.Background = fromGroup.Background;
            group.Foreground = fromGroup.Foreground;
            group.Index      = fromGroup.Index;
            group.Expanded   = fromGroup.Expanded;
            foreach (var p in fromGroup.Projects)
            {
                group.Projects.Add(new ProjectViewModel
                {
                    Name     = p.Name,
                    Index    = p.Index,
                    Location = p.Location,
                });
            }
            return(group);
        }
コード例 #6
0
        public async Task<IActionResult> EditReadOnlyUsersInProject([FromBody] Users data)
        {
            Project p = await _context.Projects.FindAsync(data.guid);
            List<ProjectGroup> readOnlyGroups = await _context.ProjectsGroups
                 .Include(m => m.Group).ThenInclude(u => u.GroupUsers).ThenInclude(g => g.User)
                 .Where(m => m.ReadOnly == true && m.ProjectId == data.guid).ToListAsync();
            if (readOnlyGroups?.Count() == 0)
            {
                Group gr = new Group() { GroupName = "Lesende für " + p.ProjectName };
                gr.GroupStatusId = GroupStatusEnum.Gruppendaten_gueltig;
                ProjectGroup newReadonly = new ProjectGroup() { Group = gr, Project = p, ReadOnly = true };
                readOnlyGroups = new List<ProjectGroup>();
                readOnlyGroups.Add(newReadonly);
                _context.ProjectsGroups.Add(newReadonly);
            }
            else
            {
                foreach (GroupUser guOld in readOnlyGroups.First().Group?.GroupUsers)
                {
                    _context.GroupsUsers.Remove(guOld);
                }
            }


            foreach (UserIds userid in data.items)
            {
                DB.Models.Domain.User u = await _context.Users.FindAsync(userid.value);
                if (u != null)
                {
                    GroupUser gu = new GroupUser() { Group = readOnlyGroups.First().Group, User = u };
                    _context.GroupsUsers.Add(gu);
                }

            }


            await _context.SaveChangesAsync();


            return Content("OK", "application/json");
        }
コード例 #7
0
 private void BindToolbar()
 {
     if (ProjectId > 0)
     {
         secHeader.Title = LocRM.GetString("tAddRelProject") + "'" + Task.GetProjectTitle(ProjectId) + "'";
         secHeader.AddLink("<img alt='' src='../Layouts/Images/cancel.gif'/> " + LocRM.GetString("tCancel"), "../Projects/ProjectView.aspx?ProjectId=" + ProjectId);
     }
     else
     {
         string sName = "";
         using (IDataReader reader = ProjectGroup.GetProjectGroups(PGID))
         {
             if (reader.Read())
             {
                 sName = reader["Title"].ToString();
             }
         }
         secHeader.Title = LocRM.GetString("tAddToPortfolio") + " '" + sName + "'";
         secHeader.AddLink("<img alt='' src='../Layouts/Images/cancel.gif'/> " + LocRM.GetString("tCancel"), "../Projects/ProjectGroupView.aspx?ProjectGroupId=" + PGID);
     }
 }
コード例 #8
0
        public ActionResult Delete(string PGID)
        {
            try
            {
                sc.CheckSecurity(AppRoles.Admin, Session[SessionName.UserName.ToString()].ToString());
            }
            catch
            {
                return(RedirectToAction("Login", "Home"));
            }


            ViewBag.ShowPrice         = "none";
            ViewBag.ShowLineItemPrice = "none";


            ProjectGroup prjGroup = pjRepository.GetProjectGroupByID(PGID);

            //Int32 result = pjRepository.Delete(prjGroup);

            return(View(prjGroup));
        }
コード例 #9
0
        public async Task <Unit> Handle(CreateProjectGroupCommand request, CancellationToken cancellationToken)
        {
            var user   = _userAccessor.GetUser();
            var entity = new ProjectGroup();

            entity.CreateEnd(request.Id, request.Name, Guid.Parse(user.FindFirst(ClaimTypes.NameIdentifier).Value));

            await _context.ProjectGroups.AddAsync(entity, cancellationToken);

            await _context.SaveChangesAsync(cancellationToken);

            var notification = new ProjectGroupCreated()
            {
                PrimaryEntityId   = entity.Id,
                PrimaryEntityName = entity.Name,
                UserName          = user.Identity.Name
            };

            await _mediator.Publish(notification, cancellationToken);

            return(Unit.Value);
        }
コード例 #10
0
 public DummySettingsProvider()
 {
     _settings["GroupColumns"] = 2;
     _settings["ProjectWidth"] = 300;
     _settings["ShowIcons"]    = true;
     _settings["StoredGroups"] = ProjectGroup.Serialize(new[]
     {
         new ProjectGroup
         {
             Title    = "MyProject Trunk",
             Projects = new[]
             {
                 new Project(@"C:\GitProjects\MyProject\Test.sln"),
                 new Project(@"C:\GitProjects\MyProject\All.sln"),
                 new Project(@"C:\GitProjects\MyProject\Logging.sln"),
                 new Project(@"C:\GitProjects\MyProject\Tools.sln"),
             }
         },
         new ProjectGroup
         {
             Title    = "MyProject 5.1",
             Projects = new[]
             {
                 new Project(@"C:\GitProjects\MyProject5.1\Logging.sln"),
             }
         },
         new ProjectGroup
         {
             Title    = "MyProject 5.0",
             Projects = new[]
             {
                 new Project(@"C:\GitProjects\MyProject5.0\Test.sln"),
                 new Project(@"C:\GitProjects\MyProject5.0\All.sln"),
                 new Project(@"C:\GitProjects\MyProject5.0\Logging.sln"),
                 new Project(@"C:\GitProjects\MyProject5.0\Tools.sln"),
             }
         }
     });
 }
コード例 #11
0
        public async Task <ServiceResponse <GetSubmissionDto> > AddSubmission(AddSubmissionDto addSubmissionDto)
        {
            ServiceResponse <GetSubmissionDto> response = new ServiceResponse <GetSubmissionDto>();
            ProjectGroup projectGroup = await _context.ProjectGroups
                                        .FirstOrDefaultAsync(u => u.Id == addSubmissionDto.ProjectGroupId);

            Assignment assignment = await _context.Assignments//.Include(a => a.AfilliatedCourse)
                                    .FirstOrDefaultAsync(a => a.Id == addSubmissionDto.AssignmentId);

            if (assignment == null || projectGroup == null)
            {
                response.Data    = null;
                response.Message = "There is etiher no assgnment or no project group with given Id";
                response.Success = false;
                return(response);
            }
            Submission submission = new Submission
            {
                HasSubmission          = false,
                HasFile                = false,
                AffiliatedAssignmentId = assignment.Id,
                CourseId               = assignment.AfilliatedCourseId,
                Description            = addSubmissionDto.Description,
                IsGraded               = false,
                SrsGrade               = 0,
                SectionId              = projectGroup.AffiliatedSectionId,
                AffiliatedGroupId      = projectGroup.Id,
                UpdatedAt              = DateTime.Now,
                FilePath               = "",
            };

            _context.Submissions.Add(submission);
            await _context.SaveChangesAsync();

            response.Data = _mapper.Map <GetSubmissionDto>(submission);
            response.Data.FileEndpoint = string.Format("Submission/File/{0}", submission.Id);
            response.Data.FileName     = submission.HasFile ? submission.FilePath.Split('/').Last() : "";
            return(response);
        }
コード例 #12
0
        public ActionResult Create(int?projectId, [Bind(Include = "GroupName, Accessibility")] ProjectGroup projectGroup)
        {
            // ユーザーとプロジェクトの取得は親クラスで実行ずみ。

            if (!ModelState.IsValid)
            {
                return(View(projectGroup));
            }

            projectGroup.Project = this.Project;

            ParticipantUserGroup pug = new ParticipantUserGroup();

            pug.Group           = projectGroup;
            pug.ParticipantUser = this.CurrentUser;

            this.DbContext.Groups.Add(projectGroup);
            this.DbContext.ParticipantUserGroups.Add(pug);
            this.DbContext.Users.Attach(pug.ParticipantUser);
            this.DbContext.SaveChanges();
            return(RedirectToAction("Index", new { projectId = projectId }));
        }
コード例 #13
0
        public async Task <ServiceResponse <List <ProjectGradeInfoDto> > > GetProjectGradesGivenTo(int projectGroupId)
        {
            ServiceResponse <List <ProjectGradeInfoDto> > response = new ServiceResponse <List <ProjectGradeInfoDto> >();
            ProjectGroup projectGroup = await _context.ProjectGroups.Include(s => s.AffiliatedCourse).ThenInclude(pg => pg.Instructors)
                                        .Include(s => s.ProjectGrades).Include(s => s.AffiliatedSection).FirstOrDefaultAsync(s => s.Id == projectGroupId);

            if (projectGroup == null)
            {
                response.Data    = null;
                response.Message = "There is no such project Group";
                response.Success = false;
                return(response);
            }

            List <ProjectGradeInfoDto> projectGrades = _context.ProjectGrades
                                                       .Include(c => c.GradingUser)
                                                       .Where(c => c.GradedProjectGroupID == projectGroupId)
                                                       .Select(c => new ProjectGradeInfoDto
            {
                Id                    = c.Id,
                MaxGrade              = c.MaxGrade,
                Grade                 = c.Grade,
                Comment               = c.Description,
                LastEdited            = c.LastEdited,
                userInProjectGradeDto = new UserInProjectGradeDto
                {
                    Id    = c.GradingUser.Id,
                    email = c.GradingUser.Email,
                    name  = c.GradingUser.Name
                },
                GradingUserId = c.GradingUserId,

                FileEndpoint         = string.Format("ProjectGrade/DownloadById/{0}", c.Id),
                GradedProjectGroupID = c.GradedProjectGroup.Id
            }).ToList();

            response.Data = projectGrades;
            return(response);
        }
コード例 #14
0
ファイル: CourseService.cs プロジェクト: Ministler/BilHub
        private async Task <GetCourseDto> AddExtraDtos(GetCourseDto dto)
        {
            // CurrentUserSectionId
            // IsInstructorOrTAInCourse
            // IsUserInFormedGroup
            // IsUserAlone
            User dbUser = await _context.Users
                          .Include(c => c.InstructedCourses).ThenInclude(cs => cs.Course)
                          .Include(c => c.ProjectGroups).ThenInclude(cs => cs.ProjectGroup).ThenInclude(css => css.GroupMembers)
                          .FirstOrDefaultAsync(c => c.Id == GetUserId());

            ProjectGroupUser projectGroupUser = dbUser.ProjectGroups.FirstOrDefault(c => c.ProjectGroup.AffiliatedCourseId == dto.Id);

            if (projectGroupUser != null)
            {
                ProjectGroup currentProjectGroup = projectGroupUser.ProjectGroup;
                dto.CurrentUserSectionId = currentProjectGroup.AffiliatedSectionId;
                dto.IsUserInFormedGroup  = currentProjectGroup.ConfirmationState;
                dto.IsUserAlone          = (currentProjectGroup.GroupMembers.Count == 1) ? true : false;
            }
            else
            {
                dto.CurrentUserSectionId = 0;
                dto.IsUserInFormedGroup  = false;
                dto.IsUserAlone          = false;
            }

            if (dbUser.InstructedCourses.Any(c => c.Course.Id == dto.Id))
            {
                dto.IsInstructorOrTAInCourse = true;
            }
            else
            {
                dto.IsInstructorOrTAInCourse = false;
            }

            return(dto);
        }
コード例 #15
0
        private void BindDefaultValues()
        {
            ddPrjGroup.DataSource     = ProjectGroup.GetProjectGroups();
            ddPrjGroup.DataTextField  = "Title";
            ddPrjGroup.DataValueField = "ProjectGroupId";
            ddPrjGroup.DataBind();
            ddPrjGroup.Items.Insert(0, new ListItem(LocRM.GetString("AllFem"), "0"));

            ddPrjPhase.DataSource     = Project.GetListProjectPhases();
            ddPrjPhase.DataTextField  = "PhaseName";
            ddPrjPhase.DataValueField = "PhaseId";
            ddPrjPhase.DataBind();
            ddPrjPhase.Items.Insert(0, new ListItem(LocRM.GetString("AllFem"), "0"));

            ddStatus.DataSource     = Project.GetListProjectStatus();
            ddStatus.DataTextField  = "StatusName";
            ddStatus.DataValueField = "StatusId";
            ddStatus.DataBind();
            ddStatus.Items.Insert(0, new ListItem(LocRM.GetString("All"), "0"));

            btnApplyFilter.Text = LocRM.GetString("Apply");
            btnResetFilter.Text = LocRM.GetString("Reset");
        }
コード例 #16
0
        //Save
        public string Save(ProjectGroup projectGroup)
        {
            try
            {
                connection.Open();
                string query = "usp_project_group_student_cu";
                Command             = new SqlCommand(query, connection);
                Command.CommandType = CommandType.StoredProcedure;

                Command.Parameters.AddWithValue("tbl_student_id", projectGroup.SupportId);
                Command.Parameters.AddWithValue("tbl_project_group_id", projectGroup.TblProjectGroupId);


                Command.ExecuteNonQuery();
                connection.Close();
                return("Save Successful.!");
            }
            catch (Exception ex)
            {
                connection.Close();
                return("Save Failed.! Msg: " + ex);
            }
        }
コード例 #17
0
ファイル: StudentExcel.cs プロジェクト: War0n/Leaping-Cliff
        private void FillDatabase(Dictionary<int, object[]> rowData, Project insertProject)
        {
            BarometerDataAccesLayer.DatabaseClassesDataContext context = DatabaseFactory.getInstance().getDataContext();
            foreach (KeyValuePair<int, object[]> cell in rowData)
            {
                bool userExists = false;

                if (cell.Key != 0 && cell.Value[0].ToString() != "")
                {
                    int studentNumber = int.Parse(cell.Value[0].ToString());
                    BarometerDataAccesLayer.User insertUser = null;
                    var existingUser =
                        from u in context.Users
                        where u.student_number == studentNumber
                        select u;

                    int test = 0;
                    if (!existingUser.Any())
                    {
                        //If doesnt exist, create empty one
                        insertUser = new BarometerDataAccesLayer.User();
                    }
                    else
                    {
                        //If exists, get user
                        userExists = true;
                        insertUser = existingUser.First();
                    }

                    insertUser.student_number = int.Parse(cell.Value[0].ToString());
                    insertUser.firstname = cell.Value[1].ToString();
                    insertUser.lastname = cell.Value[2].ToString();
                    insertUser.email = cell.Value[3].ToString();

                    if (cell.Value[4].ToString() != "")
                    {
                        string[] groups = cell.Value[4].ToString().Split(',');
                        foreach (string groupcode in groups)
                        {
                            bool groupExists = false;
                            var currentGroup =
                                from pg in context.ProjectGroups
                                where pg.group_code == groupcode
                                select pg;

                            ProjectGroup newGroup = null;
                            if (currentGroup.Count() == 0)
                            {
                                //Groep bestaat nog niet, aanmaken
                                newGroup = new ProjectGroup();
                                newGroup.group_code = groupcode;
                            }
                            else
                            {
                                groupExists = true;
                                newGroup = currentGroup.First();
                            }
                            if (insertProject != null)
                            {
                                newGroup.Project = insertProject;
                            }

                            ProjectMember member = new ProjectMember();
                            member.student_user_id = insertUser.id;
                            member.ProjectGroup = newGroup;
                            if (!groupExists)
                            {
                                context.ProjectGroups.InsertOnSubmit(newGroup);
                            }
                            context.ProjectMembers.InsertOnSubmit(member);
                        }
                    }
                    if (!userExists)
                    {
                        context.Users.InsertOnSubmit(insertUser);
                    }
                }
            }
            context.SubmitChanges();
        }
コード例 #18
0
    private void ExportOneSkyProjectToDirectory(string RootWorkingDirectory, OneSkyService OneSkyService, ProjectGroup OneSkyProjectGroup, string OneSkyBranchSuffix, ProjectInfo ProjectInfo)
    {
        var OneSkyFileName = GetOneSkyFilename(ProjectInfo.ImportInfo.PortableObjectName, OneSkyBranchSuffix);
        var OneSkyProject  = GetOneSkyProject(OneSkyService, OneSkyProjectGroup.Name, ProjectInfo.ProjectName);
        var OneSkyFile     = OneSkyProject.UploadedFiles.FirstOrDefault(f => f.Filename == OneSkyFileName);

        //Export
        if (OneSkyFile != null)
        {
            var CulturesToExport = new List <string>();
            foreach (var OneSkyCulture in OneSkyProject.EnabledCultures)
            {
                // Only export the OneSky cultures that we care about for this project
                if (ProjectInfo.ImportInfo.CulturesToGenerate.Contains(OneSkyCulture))
                {
                    CulturesToExport.Add(OneSkyCulture);
                }
            }

            ExportOneSkyFileToDirectory(OneSkyFile, new DirectoryInfo(CombinePaths(RootWorkingDirectory, ProjectInfo.ImportInfo.DestinationPath)), ProjectInfo.ImportInfo.PortableObjectName, CulturesToExport, ProjectInfo.ImportInfo.bUseCultureDirectory);
        }
    }
コード例 #19
0
 public IQueryable<ProjectMember> GetGroupMembers(ProjectGroup group)
 {
     return project.getProjectGroupMembers(group.id);
 }
コード例 #20
0
 private void FillProjectMembers(ProjectGroup projectGroup)
 {
     ProjectMembers = project.getProjectGroupMembers(projectGroup.id);
 }
コード例 #21
0
    private static ProjectGroup GetProjectGroup(OneSkyService oneSkyService, string GroupName)
    {
        var launcherGroup = oneSkyService.ProjectGroups.FirstOrDefault(g => g.Name == GroupName);

        if (launcherGroup == null)
        {
            launcherGroup = new ProjectGroup(GroupName, new CultureInfo("en"));
            oneSkyService.ProjectGroups.Add(launcherGroup);
        }

        return launcherGroup;
    }
コード例 #22
0
ファイル: ProcessRunner.cs プロジェクト: zggl/tye
        private async Task BuildAndRunProjects(Application application)
        {
            var projectGroups = new Dictionary <string, ProjectGroup>();
            var groupCount    = 0;

            foreach (var service in application.Services.Values)
            {
                var serviceDescription = service.Description;

                string path;
                string args;
                var    buildProperties = string.Empty;
                string workingDirectory;
                if (serviceDescription.RunInfo is ProjectRunInfo project)
                {
                    path             = project.RunCommand;
                    workingDirectory = project.ProjectFile.Directory.FullName;
                    args             = project.Args == null ? project.RunArguments : project.RunArguments + " " + project.Args;
                    buildProperties  = project.BuildProperties.Aggregate(string.Empty, (current, property) => current + $";{property.Key}={property.Value}").TrimStart(';');

                    service.Status.ProjectFilePath = project.ProjectFile.FullName;
                }
                else if (serviceDescription.RunInfo is ExecutableRunInfo executable)
                {
                    path             = executable.Executable;
                    workingDirectory = executable.WorkingDirectory !;
                    args             = executable.Args ?? "";
                }
                else
                {
                    continue;
                }

                // If this is a dll then use dotnet to run it
                if (Path.GetExtension(path) == ".dll")
                {
                    args = $"\"{path}\" {args}".Trim();
                    path = "dotnet";
                }

                service.Status.ExecutablePath   = path;
                service.Status.WorkingDirectory = workingDirectory;
                service.Status.Args             = args;

                // TODO instead of always building with projects, try building with sln if available.
                if (service.Status.ProjectFilePath != null &&
                    service.Description.RunInfo is ProjectRunInfo project2 &&
                    project2.Build &&
                    _options.BuildProjects)
                {
                    if (!projectGroups.TryGetValue(buildProperties, out var projectGroup))
                    {
                        projectGroup = new ProjectGroup("ProjectGroup" + groupCount);
                        projectGroups[buildProperties] = projectGroup;
                        groupCount++;
                    }

                    projectGroup.Services.Add(service);
                }
            }

            if (projectGroups.Count > 0)
            {
                using var directory = TempDirectory.Create();

                var projectPath = Path.Combine(directory.DirectoryPath, Path.GetRandomFileName() + ".proj");

                var sb = new StringBuilder();
                sb.AppendLine(@"<Project DefaultTargets=""Build"">
    <ItemGroup>");

                foreach (var group in projectGroups)
                {
                    foreach (var p in group.Value.Services)
                    {
                        sb.AppendLine($"        <{group.Value.GroupName} Include=\"{p.Status.ProjectFilePath}\" />");
                    }
                    sb.AppendLine(@"    </ItemGroup>");
                }

                sb.AppendLine($@"    <Target Name=""Build"">");
                foreach (var group in projectGroups)
                {
                    sb.AppendLine($@"        <MsBuild Projects=""@({group.Value.GroupName})"" Properties=""{group.Key}"" BuildInParallel=""true"" />");
                }

                sb.AppendLine("    </Target>");
                sb.AppendLine("</Project>");
                File.WriteAllText(projectPath, sb.ToString());

                _logger.LogInformation("Building projects");

                var buildResult = await ProcessUtil.RunAsync("dotnet", $"build \"{projectPath}\" /nologo", throwOnError : false, workingDirectory : application.ContextDirectory);

                if (buildResult.ExitCode != 0)
                {
                    _logger.LogInformation("Building projects failed with exit code {ExitCode}: \r\n" + buildResult.StandardOutput, buildResult.ExitCode);
                    return;
                }

                foreach (var s in application.Services)
                {
                    switch (s.Value.ServiceType)
                    {
                    case ServiceType.Executable:
                        LaunchService(application, s.Value);
                        break;

                    case ServiceType.Project:
                        LaunchService(application, s.Value);
                        break;
                    }
                    ;
                }
            }
        }
コード例 #23
0
	private static ProjectGroup GetLauncherGroup(OneSkyService oneSkyService)
	{
		var launcherGroup = oneSkyService.ProjectGroups.FirstOrDefault(g => g.Name == "Launcher");

		if (launcherGroup == null)
		{
			launcherGroup = new ProjectGroup("Launcher", "en");
			oneSkyService.ProjectGroups.Add(launcherGroup);
		}

		return launcherGroup;
	}
コード例 #24
0
 public static ProjectGroupIncludeModel Create(ProjectGroup projectGroup, string searchValue)
 {
     return(Projection.Compile().Invoke(projectGroup, searchValue));
 }
コード例 #25
0
ファイル: Profiles.ascx.cs プロジェクト: alex765022/IBN
        /// <summary>
        /// Default data bind.
        /// </summary>
        private void DefaultDataBind()
        {
            //FieldSet
            ddFieldSets.Items.Clear();
            ddFieldSets.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "StandardFieldSet").ToString(), Project.ProjectFieldSet.ProjectsDefault.ToString()));
            ddFieldSets.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "TimelineFieldSet").ToString(), Project.ProjectFieldSet.ProjectsLight.ToString()));

            //Grouping
            ddGroupField.Items.Clear();
            ddGroupField.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "NoGroupBy").ToString(), Project.AvailableGroupField.NotSet.ToString()));
            ddGroupField.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Project", "GroupByPortfolio").ToString(), Project.AvailableGroupField.Portfolio.ToString()));
            if (PortalConfig.GeneralAllowClientField)
            {
                ddGroupField.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.Project", "GroupByContacts").ToString(), Project.AvailableGroupField.Client.ToString()));
            }

            //Filters

            //StartDate
            dtcStartDate.SelectedDate = DateTime.Today;
            ddSDType.Items.Clear();
            ddSDType.Items.Add(new ListItem(LocRM.GetString("Any"), "0"));
            ddSDType.Items.Add(new ListItem(LocRM.GetString("GE"), "1"));
            ddSDType.Items.Add(new ListItem(LocRM.GetString("LE"), "2"));
            ddSDType.Items.Add(new ListItem(LocRM.GetString("Equal"), "3"));

            //EndDate
            dtcEndDate.SelectedDate = DateTime.Now;
            ddFDType.Items.Clear();
            ddFDType.Items.Add(new ListItem(LocRM.GetString("Any"), "0"));
            ddFDType.Items.Add(new ListItem(LocRM.GetString("GE"), "1"));
            ddFDType.Items.Add(new ListItem(LocRM.GetString("LE"), "2"));
            ddFDType.Items.Add(new ListItem(LocRM.GetString("Equal"), "3"));

            //Status
            ddStatus.Items.Clear();
            ddStatus.DataSource     = Project.GetListProjectStatus();
            ddStatus.DataTextField  = "StatusName";
            ddStatus.DataValueField = "StatusId";
            ddStatus.Items.Insert(0, new ListItem(LocRM.GetString("All"), "0"));
            ddStatus.Items.Insert(1, new ListItem(LocRM.GetString("tOnlyActive"), "-1"));
            ddStatus.Items.Insert(2, new ListItem(LocRM.GetString("tOnlyInactive"), "-2"));

            // Phase
            ddPrjPhases.Items.Clear();
            ddPrjPhases.Items.Add(new ListItem(LocRM.GetString("All"), "0"));
            using (IDataReader rdr = Project.GetListProjectPhases())
            {
                while (rdr.Read())
                {
                    ddPrjPhases.Items.Add(new ListItem(rdr["PhaseName"].ToString(), rdr["PhaseId"].ToString()));
                }
            }

            // Type
            ddType.Items.Clear();
            ddType.Items.Add(new ListItem(LocRM.GetString("All"), "0"));
            using (IDataReader rdr = Project.GetListProjectTypes())
            {
                while (rdr.Read())
                {
                    ddType.Items.Add(new ListItem((string)rdr["TypeName"], rdr["TypeId"].ToString()));
                }
            }

            // Mananger
            ddManager.Items.Clear();
            ddManager.DataSource     = Project.GetListProjectManagers();
            ddManager.DataTextField  = "UserName";
            ddManager.DataValueField = "ManagerId";
            ddManager.DataBind();
            ddManager.Items.Insert(0, new ListItem(LocRM.GetString("All"), "0"));
            ListItem lItem = new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "CurrentUser").ToString(), "-5");

            ddManager.Items.Insert(1, lItem);

            // ExeMananger
            ddExeManager.Items.Clear();
            ddExeManager.DataSource     = Project.GetListExecutiveManagers();
            ddExeManager.DataTextField  = "UserName";
            ddExeManager.DataValueField = "ExecutiveManagerId";
            ddExeManager.DataBind();
            ddExeManager.Items.Insert(0, new ListItem(LocRM.GetString("All"), "0"));
            lItem = new ListItem(GetGlobalResourceObject("IbnFramework.Incident", "CurrentUser").ToString(), "-5");
            ddExeManager.Items.Insert(1, lItem);

            // Priority
            ddPriority.Items.Clear();
            ddPriority.Items.Add(new ListItem(LocRM.GetString("All"), "-1"));
            using (IDataReader rdr = Project.GetListPriorities())
            {
                while (rdr.Read())
                {
                    ddPriority.Items.Add(new ListItem((string)rdr["PriorityName"], rdr["PriorityId"].ToString()));
                }
            }

            //Client
            ClientControl.ObjectType = String.Empty;
            ClientControl.ObjectId   = PrimaryKeyId.Empty;

            // Project Groups
            ddPrjGrpType.Items.Clear();
            ddPrjGrpType.Items.Add(new ListItem(LocRM.GetString("Any2"), "0"));
            ddPrjGrpType.Items.Add(new ListItem(LocRM.GetString("SelectedOnly"), "1"));
            ddPrjGrpType.Items.Add(new ListItem(LocRM.GetString("ExcludeSelected"), "2"));

            lbPrjGrps.Items.Clear();
            lbPrjGrps.DataSource     = ProjectGroup.GetProjectGroups();
            lbPrjGrps.DataTextField  = "Title";
            lbPrjGrps.DataValueField = "ProjectGroupId";
            lbPrjGrps.DataBind();

            // General Categories
            ddGenCatType.Items.Clear();
            ddGenCatType.Items.Add(new ListItem(LocRM.GetString("Any2"), "0"));
            ddGenCatType.Items.Add(new ListItem(LocRM.GetString("SelectedOnly"), "1"));
            ddGenCatType.Items.Add(new ListItem(LocRM.GetString("ExcludeSelected"), "2"));

            lbGenCats.Items.Clear();
            lbGenCats.DataSource     = Project.GetListCategoriesAll();
            lbGenCats.DataTextField  = "CategoryName";
            lbGenCats.DataValueField = "CategoryId";
            lbGenCats.DataBind();

            // Project Categories
            ddPrjCatType.Items.Clear();
            ddPrjCatType.Items.Add(new ListItem(LocRM.GetString("Any2"), "0"));
            ddPrjCatType.Items.Add(new ListItem(LocRM.GetString("SelectedOnly"), "1"));
            ddPrjCatType.Items.Add(new ListItem(LocRM.GetString("ExcludeSelected"), "2"));

            lbPrjCats.Items.Clear();
            lbPrjCats.DataSource     = Project.GetListProjectCategories();
            lbPrjCats.DataTextField  = "CategoryName";
            lbPrjCats.DataValueField = "CategoryId";
            lbPrjCats.DataBind();

            if (Mediachase.IBN.Business.Security.IsUserInGroup(InternalSecureGroups.Partner))
            {
                trPrGroups.Visible = false;
            }

            cbIsPublic.Visible = Mediachase.IBN.Business.Security.IsUserInGroup(InternalSecureGroups.Administrator);

            trGenCats.Visible  = PortalConfig.GeneralAllowGeneralCategoriesField;
            trClient.Visible   = PortalConfig.GeneralAllowClientField;
            trPriority.Visible = PortalConfig.GeneralAllowPriorityField;
        }
コード例 #26
0
 private void FillTutors(ProjectGroup projectGroup)
 {
     Tutors = project.GetTutor(projectGroup.id);
 }
コード例 #27
0
        private void BindInitialValues()
        {
            ddPrjGroup.DataSource     = ProjectGroup.GetProjectGroups();
            ddPrjGroup.DataTextField  = "Title";
            ddPrjGroup.DataValueField = "ProjectGroupId";
            ddPrjGroup.DataBind();
            ddPrjGroup.Items.Insert(0, new ListItem(LocRM.GetString("AllFem"), "0"));
            ddPrjGroup.Items.Add(new ListItem(LocRM.GetString("tCustom"), "-1"));
            switch (ProjectListType)
            {
            case "All":
                if (ddPrjGroup.Items.FindByValue("0") != null)
                {
                    ddPrjGroup.SelectedValue = "0";
                }
                break;

            case "Custom":
                if (ddPrjGroup.Items.FindByValue("-1") != null)
                {
                    ddPrjGroup.SelectedValue = "-1";
                }
                break;

            case "Portfolio":
                if (ddPrjGroup.Items.FindByValue(ProjectListData) != null)
                {
                    ddPrjGroup.SelectedValue = ProjectListData;
                }
                break;
            }


            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Id", typeof(int)));
            dt.Columns.Add(new DataColumn("Name", typeof(string)));

            dt.Rows.Add(new object[] { 1, LocRM.GetString("tWeekYear") });
            dt.Rows.Add(new object[] { 2, LocRM.GetString("tMonthQuarterYear") });
            dt.Rows.Add(new object[] { 3, LocRM.GetString("tQuarterYear") });
            dt.Rows.Add(new object[] { 4, LocRM.GetString("tYear") });
            dt.Rows.Add(new object[] { 5, LocRM.GetString("tTotalSum") });

            ddFinanceType.DataSource     = dt;
            ddFinanceType.DataTextField  = "Name";
            ddFinanceType.DataValueField = "Id";
            ddFinanceType.DataBind();
            ddFinanceType.SelectedValue = FinanceType;

            DataTable dt1 = new DataTable();

            dt1.Columns.Add(new DataColumn("Id", typeof(int)));
            dt1.Columns.Add(new DataColumn("Name", typeof(string)));
            foreach (BasePlanSlot bps in BasePlanSlot.List())
            {
                DataRow dr = dt1.NewRow();
                dr["Id"]   = bps.BasePlanSlotId;
                dr["Name"] = bps.Name;
                dt1.Rows.Add(dr);
            }
            dt1.Rows.Add(new object[] { "-1", LocRM.GetString("tFact") });
            dt1.Rows.Add(new object[] { "0", LocRM.GetString("tCurrent") });
            DataView dv = dt1.DefaultView;

            dv.Sort = "Id ASC";
            ddBasePlan1.DataSource     = dv;
            ddBasePlan1.DataTextField  = "Name";
            ddBasePlan1.DataValueField = "Id";
            ddBasePlan1.DataBind();
            ddBasePlan1.SelectedValue = BasePlan1.ToString();

            dt1.Rows.Add(new object[] { "-2", LocRM.GetString("tNotSelected") });
            dv      = dt1.DefaultView;
            dv.Sort = "Id ASC";
            ddBasePlan2.DataSource     = dv;
            ddBasePlan2.DataTextField  = "Name";
            ddBasePlan2.DataValueField = "Id";
            ddBasePlan2.DataBind();
            ddBasePlan2.SelectedValue = BasePlan2.ToString();

            tbFromYear.Text = FromYear.ToString();
            tbToYear.Text   = ToYear.ToString();


            ddGroupBy.Items.Clear();
            ddGroupBy.Items.Add(new ListItem(LocRM.GetString("tByProject"), "false"));
            ddGroupBy.Items.Add(new ListItem(LocRM.GetString("tByBusinessScore"), "true"));
            ddGroupBy.SelectedValue = Reverse.ToString().ToLower();
        }
コード例 #28
0
        public async Task <ServiceResponse <string> > CancelMergeRequest(CancelMergeRequestDto mergeRequestDto)
        {
            ServiceResponse <string> response = new ServiceResponse <string>();

            User user = await _context.Users
                        .Include(u => u.ProjectGroups)
                        .FirstOrDefaultAsync(u => u.Id == GetUserId());

            MergeRequest mergeRequest = await _context.MergeRequests
                                        .FirstOrDefaultAsync(mr => mr.Id == mergeRequestDto.Id);

            if (mergeRequest == null)
            {
                response.Data    = "Not allowed";
                response.Message = "There is no merge request with this Id";
                response.Success = false;
                return(response);
            }

            if (user == null)
            {
                response.Data    = "Not allowed";
                response.Message = "There is no user with this Id";
                response.Success = false;
                return(response);
            }

            ProjectGroup senderGroup = await _context.ProjectGroups
                                       .FirstOrDefaultAsync(sg => sg.Id == mergeRequest.SenderGroupId);

            ProjectGroup receiverGroup = await _context.ProjectGroups
                                         .FirstOrDefaultAsync(rg => rg.Id == mergeRequest.ReceiverGroupId);

            bool isUserInSender = senderGroup.GroupMembers.Any(pgu => pgu.UserId == GetUserId());



            if (!isUserInSender)
            {
                response.Data    = "Not allowed";
                response.Message = "You are not authorized to cancel this merge request";
                response.Success = false;
                return(response);
            }

            if (mergeRequest.Accepted)
            {
                response.Data    = "Not allowed";
                response.Message = "The merge request is already accepted. So you can't cancel it";
                response.Success = false;
                return(response);
            }

            if (mergeRequest.Resolved)
            {
                response.Data    = "Not allowed";
                response.Message = "The merge request is already resolved. So you can't cancel it";
                response.Success = false;
                return(response);
            }

            _context.MergeRequests.Remove(mergeRequest);
            await _context.SaveChangesAsync();

            if (senderGroup != null)
            {
                _context.ProjectGroups.Update(senderGroup);
                await _context.SaveChangesAsync();
            }

            if (receiverGroup != null)
            {
                _context.ProjectGroups.Update(receiverGroup);
                await _context.SaveChangesAsync();
            }

            response.Data    = "Successful";
            response.Message = "Merge request is successfully cancelled";
            response.Success = true;

            return(response);
        }
コード例 #29
0
 public IQueryable<User> GetTutor(ProjectGroup group)
 {
     return project.GetTutor(group.id);
 }
コード例 #30
0
    private void UploadProjectToOneSky(string RootWorkingDirectory, OneSkyService OneSkyService, ProjectGroup OneSkyProjectGroup, string OneSkyBranchSuffix, ProjectInfo ProjectInfo)
    {
        var OneSkyProject = GetOneSkyProject(OneSkyService, OneSkyProjectGroup.Name, ProjectInfo.ProjectName);

        Func <string, FileInfo> GetPathForCulture = (string Culture) =>
        {
            if (ProjectInfo.ExportInfo.bUseCultureDirectory)
            {
                return(new FileInfo(Path.Combine(RootWorkingDirectory, ProjectInfo.ExportInfo.DestinationPath, Culture, ProjectInfo.ExportInfo.PortableObjectName)));
            }
            else
            {
                return(new FileInfo(Path.Combine(RootWorkingDirectory, ProjectInfo.ExportInfo.DestinationPath, ProjectInfo.ExportInfo.PortableObjectName)));
            }
        };

        // Upload the .po file for the native culture first
        UploadFileToOneSky(OneSkyProject, OneSkyBranchSuffix, GetPathForCulture(ProjectInfo.ExportInfo.NativeCulture), ProjectInfo.ExportInfo.NativeCulture);

        // Upload the remaining .po files for the other cultures
        foreach (var Culture in ProjectInfo.ExportInfo.CulturesToGenerate)
        {
            // Skip native culture as we uploaded it above
            if (Culture != ProjectInfo.ExportInfo.NativeCulture)
            {
                UploadFileToOneSky(OneSkyProject, OneSkyBranchSuffix, GetPathForCulture(Culture), Culture);
            }
        }
    }
コード例 #31
0
 private void FillProjectMembers(ProjectGroup projectGroup)
 {
     ProjectMembers = project.getUsersInGroup(projectGroup.id);
 }
コード例 #32
0
	private ProjectGroup GetOneSkyProjectGroup(string ProjectGroupName)
	{
		var OneSkyProjectGroup = OneSkyService.ProjectGroups.FirstOrDefault(g => g.Name == ProjectGroupName);

		if (OneSkyProjectGroup == null)
		{
			OneSkyProjectGroup = new ProjectGroup(ProjectGroupName, "en");
			OneSkyService.ProjectGroups.Add(OneSkyProjectGroup);
		}

		return OneSkyProjectGroup;
	}
コード例 #33
0
 private void FillProjectDetails(Project p, ProjectGroup pg)
 {
     CurrentProjectId = p.id;
     CurrentProjectSummary = p.description;
     CurrentProjectName = p.name;
     CurrentProjectDate = (Convert.ToDateTime(p.start_date).Date.ToString() + " tot " + Convert.ToDateTime(p.end_date).Date.ToString());
     CurrentProjectGroupGrade = student.getEndGradeGroup(studentNumber, pg.id);
     CurrentProjectIndividualGrade = student.getEndGradeIndividual(studentNumber, p.id);
 }
コード例 #34
0
 private void FillCurrentProjectOwners(ProjectGroup projectGroup)
 {
     CurrentProjectOwners = project.GetProjectOwners(projectGroup.project_id);
 }
コード例 #35
0
 private void FillProjectMembers(ProjectGroup projectGroup)
 {
     ProjectMembers = project.getUsersInGroup(projectGroup.id);
 }
コード例 #36
0
        private void ProcessWatchers(List<IssueDto> issues, DateTime lastChecked)
        {
            var lastCheckedLocal = lastChecked.ToLocal(_issueManager.UserContext.User.TimeZone);

            Dictionary<int, WatcherData> targets = new Dictionary<int, WatcherData>();
            Dictionary<string, WatcherData> emailTargets = new Dictionary<string, WatcherData>();
            var userManager = new UserManager(_issueManager);
            List<int> projectsMissingFollowerTemplate = new List<int>();
            int emailWatchers = -3;

            // Build array of users that are watching issues
            foreach (var issue in issues)
            {
                //Safety check
                if (issue.Watchers.Count == 0) continue;
                if (issue.Revised == issue.Created) continue;
                if (issue.Revised.ToUtc(_issueManager.UserContext.User.TimeZone) <= lastChecked) continue;

                var history = _issueManager.GetHistory(issue);

                issue.History = new List<IssueAuditDto>(history);

                history.RemoveAll(h => h.Entity.Created <= lastCheckedLocal);

                foreach (var watcher in issue.Watchers)
                {
                    if (watcher.Entity.UserId != null)
                    {
                        if (targets.ContainsKey(watcher.Entity.UserId.Value))
                        {
                            WatcherData data = targets[watcher.Entity.UserId.Value];

                            var permissionManager = new PermissionsManager(data.User, _types, _permissionSets, _organizations, _issueManager.UserContext.Config.HelpDeskModeGroup, false);

                            if (!permissionManager.CanSeeItem(issue.Project, issue)) continue;

                            if (!data.User.Entity.EmailMeMyChanges && IsUserOnlyChange(history, data.User.Entity.Id)) continue;

                            data.IssueId.Add(issue.Entity.Id);
                        }
                        else
                        {
                            WatcherData data = new WatcherData();

                            data.User = userManager.Get(watcher.Entity.UserId.Value);

                            if (data.User.Entity.Active)
                            {
                                var permissionManager = new PermissionsManager(data.User, _types, _permissionSets, _organizations, _issueManager.UserContext.Config.HelpDeskModeGroup, false);

                                if (!permissionManager.CanSeeItem(issue.Project, issue)) continue;

                                if (!data.User.Entity.EmailMeMyChanges && IsUserOnlyChange(history, data.User.Entity.Id)) continue;

                                data.IssueId.Add(issue.Entity.Id);

                                targets.Add(watcher.Entity.UserId.Value, data);
                            }
                        }
                    }
                    else
                    {
                        if (emailTargets.ContainsKey(watcher.Entity.Email.ToLower()))
                        {
                            WatcherData data = emailTargets[watcher.Entity.Email.ToLower()];
                            data = targets[data.User.Entity.Id];
                            data.IssueId.Add(issue.Entity.Id);
                        }
                        else
                        {
                            WatcherData data = new WatcherData();
                            data.User = new UserDto(new User());
                            data.User.Entity.Id = emailWatchers--;
                            data.User.Entity.Email = watcher.Entity.Email;
                            data.User.Entity.EmailMe = true;
                            data.User.Entity.EmailMeMyChanges = true;
                            data.User.Entity.ProjectGroups.Add(new ProjectGroupMembership() { ProjectGroupId = Constants.GlobalGroupEveryone, UserId = data.User.Entity.Id });
                            UserSettings settings = new UserSettings();
                            settings.IndividualFollowerAlerts = true;
                            data.User.Entity.Settings = settings.ToJson();
                            var group = new ProjectGroup() { Id = Constants.GlobalGroupEveryone, Members = new List<ProjectGroupMembership>() };
                            group.Members2.Add(new ProjectGroupMembership() { UserId = data.User.Entity.Id, ProjectGroupId = Constants.GlobalGroupEveryone });
                            data.User.ProjectGroups.Add(group);
                            data.IssueId.Add(issue.Entity.Id);
                            emailTargets.Add(watcher.Entity.Email.ToLower(), data);
                            targets.Add(data.User.Entity.Id, data);
                        }
                    }
                }
            }

            AlertsTemplateHelper alerts = new AlertsTemplateHelper(_templates, GetUrl(_issueManager));

            // Now loop through users sending them watcher summary email
            Dictionary<int, List<IssueCommentDto>> originalComments = new Dictionary<int, List<IssueCommentDto>>();
            List<int> processedProjects;

            foreach (var target in targets)
            {
                processedProjects = new List<int>();

                if (originalComments.Count > 0)
                {
                    foreach (var kv in originalComments)
                    {
                        IssueDto issue = issues.Find(i => i.Entity.Id == kv.Key);

                        // Safety check
                        if (issue == null || issue.Entity.IsNew) continue;

                        issue.Comments = kv.Value;
                    }

                    originalComments = new Dictionary<int, List<IssueCommentDto>>();
                }

                var recipient = target.Value;

                // Safety check
                if (!recipient.User.Entity.EmailMe || recipient.User.Entity.Email.IsEmpty()) continue;

                AlertTypeWatchersTemplateModel model = new AlertTypeWatchersTemplateModel();

                model.TheRecipient = recipient.User;

                model.Version = GeminiVersion.Version;

                model.GeminiUrl = alerts.GeminiUrl;

                foreach (int issueId in recipient.IssueId)
                {
                    IssueDto issue = issues.Find(i => i.Entity.Id == issueId);

                    // Safety check
                    if (issue == null || issue.Entity.IsNew) continue;

                    issue.ChangeLog = _issueManager.GetChangeLog(issue, _issueManager.UserContext.User, recipient.User, lastCheckedLocal);

                    var permissionManager = new PermissionsManager(recipient.User, _types, _permissionSets, _organizations, _issueManager.UserContext.Config.HelpDeskModeGroup, false);

                    foreach (var comment in issue.Comments)
                    {
                        if (!permissionManager.CanSeeComment(issue, comment))
                        {
                            originalComments.Add(issueId, issue.Comments);

                            List<IssueCommentDto> comments = new List<IssueCommentDto>(issue.Comments);

                            comments.RemoveAll(c => !permissionManager.CanSeeComment(issue, c));

                            issue.Comments = comments;

                            break;
                        }
                    }

                    if (issue.ChangeLog.Count == 0) continue;

                    if (recipient.User.GetSettings().IndividualFollowerAlerts)
                    {
                        var template = alerts.FindTemplateForProject(AlertTemplateType.Updated, issue.Entity.ProjectId);

                        if (template == null)
                        {
                            LogDebugMessage("No update notification template found");
                            continue;
                        }

                        var indModel = new AlertTypeIndividualTemplateModel();

                        indModel.GeminiUrl = model.GeminiUrl;

                        indModel.LinkViewItem = NavigationHelper.GetIssueUrl(_issueManager.UserContext, issue.Entity.ProjectId, issue.EscapedProjectCode, issue.Entity.Id);

                        indModel.TheItem = issue;

                        indModel.TheRecipient = recipient.User;

                        indModel.Version = GeminiVersion.Version;

                        indModel.IsNewItem = false;

                        string html = alerts.GenerateHtml(template, indModel);

                        if (GeminiApp.GeminiLicense.IsFree) html = alerts.AddSignature(html);

                        string log;

                        string subject = template.Options.Subject.HasValue() ? alerts.GenerateHtml(template, indModel, true) : string.Format("[{0}] {1} {2} ({3})", issue.IssueKey, issue.Type, "Updated", issue.Title, issue.IsClosed ? "Closed" : string.Empty);

                        EmailHelper.Send(_issueManager.UserContext.Config, subject, html, recipient.User.Entity.Email, recipient.User.Fullname, true, out log);
                    }
                    else
                    {
                        model.TheItemsUpdated.Add(issue);
                    }

                }

                if (recipient.User.GetSettings().IndividualFollowerAlerts) continue;

                // Safety check!
                if (model.ChangeCount > 0)
                {
                    var watcherAlertTemplates = alerts.Templates.FindAll(s => s.AlertType == AlertTemplateType.Watchers);

                    if (watcherAlertTemplates.Count == 0)
                    {
                        LogDebugMessage("No follower notification template found");
                        continue;
                    }

                    if (!watcherAlertTemplates.Any(p => p.GetAssociatedProjectValue().IsEmpty()))
                    {
                        List<Project> allItemProjects = model.TheItemsUpdated.Select(s => s.Project).ToList();
                        allItemProjects = allItemProjects.Where(s => !watcherAlertTemplates.Any(a => a.GetAssociatedProjects().Contains(s.Id))).ToList();

                        if (projectsMissingFollowerTemplate.Count > 0)
                        {
                            allItemProjects = allItemProjects.Where(s => !projectsMissingFollowerTemplate.Contains(s.Id)).ToList();
                        }

                        if (allItemProjects.Count > 0)
                        {
                            LogDebugMessage(string.Concat("No follower notification template found for project ", string.Join(", ", allItemProjects.Select(s => s.Name).Distinct())));
                            projectsMissingFollowerTemplate.AddRange(allItemProjects.Select(s => s.Id).Distinct());
                        }
                    }

                    watcherAlertTemplates.Sort((x, y) => y.GetAssociatedProjectValue().CompareTo(x.GetAssociatedProjectValue()));

                    foreach(var watcherTemplate in watcherAlertTemplates)
                    {
                        var allTemplateProjects = watcherTemplate.GetAssociatedProjects();

                        var issuesTemplate = allTemplateProjects.Count == 0 ? model.TheItemsUpdated : model.TheItemsUpdated.FindAll(s => allTemplateProjects.Contains(s.Entity.ProjectId));

                        if (issuesTemplate.Count == 0) continue;

                        var projectIds = issuesTemplate.Select(s => s.Entity.ProjectId).Distinct();

                        if (processedProjects.Count > 0)
                        {
                            projectIds = projectIds.Where(s => !processedProjects.Contains(s));
                            issuesTemplate = issuesTemplate.Where(s => !processedProjects.Contains(s.Entity.ProjectId)).ToList();
                        }

                        if (processedProjects.Contains(0) || projectIds.Count() == 0 || issuesTemplate.Count == 0) continue;

                        AlertTypeWatchersTemplateModel projectTemplateModel = new AlertTypeWatchersTemplateModel();

                        projectTemplateModel.TheItemsUpdated.AddRange(issuesTemplate);
                        projectTemplateModel.TheRecipient = model.TheRecipient;
                        projectTemplateModel.Version = model.Version;
                        projectTemplateModel.GeminiUrl = model.GeminiUrl;

                        AlertTemplate template = alerts.FindTemplateForProject(AlertTemplateType.Watchers, issuesTemplate.First().Entity.ProjectId);

                        if (template.Id == 0)
                        {

                            continue;
                        }

                        // Generate email template
                        string html = alerts.GenerateHtml(template, projectTemplateModel);

                        if (GeminiApp.GeminiLicense.IsFree) html = alerts.AddSignature(html);

                        string subject = template.Options.Subject.HasValue() ? alerts.GenerateHtml(template, projectTemplateModel, true) : string.Format("{0} {1}", projectTemplateModel.ChangeCount, "Gemini Updates");

                        // Send email
                        string log;

                        EmailHelper.Send(_issueManager.UserContext.Config, subject, html, recipient.User.Entity.Email, recipient.User.Entity.Fullname, true, out log);

                        if (allTemplateProjects.Count == 0)
                        {
                            processedProjects.Add(0);
                        }
                        else
                        {
                            processedProjects.AddRange(projectIds);
                        }
                    }
                }
            }
        }
コード例 #37
0
 private void FillTutors(ProjectGroup projectGroup)
 {
     Tutors = project.GetTutor(projectGroup.id);
 }
コード例 #38
0
        public async Task <ServiceResponse <PeerGradeInfoDto> > GetPeerGradeByUsersAndGroup(GetPeerGradeDto getPeerGradeDto)
        {
            ServiceResponse <PeerGradeInfoDto> response = new ServiceResponse <PeerGradeInfoDto>();
            User user = await _context.Users
                        .Include(u => u.InstructedCourses)
                        .FirstOrDefaultAsync(u => u.Id == GetUserId());

            ProjectGroup projectGroup = await _context.ProjectGroups.Include(g => g.AffiliatedCourse).ThenInclude(c => c.PeerGradeAssignment)
                                        .Include(g => g.GroupMembers)
                                        .FirstOrDefaultAsync(rg => rg.Id == getPeerGradeDto.ProjectGroupId);


            if (projectGroup == null)
            {
                response.Data    = null;
                response.Message = "There is no project group with this id";
                response.Success = false;
                return(response);
            }

            if (!IsUserInGroup(projectGroup, getPeerGradeDto.ReviewerId))
            {
                response.Data    = null;
                response.Message = "There is no user with reviewerId in group";
                response.Success = false;
                return(response);
            }

            if (!IsUserInGroup(projectGroup, getPeerGradeDto.RevieweeId))
            {
                response.Data    = null;
                response.Message = "There is no user with revieweeId in group";
                response.Success = false;
                return(response);
            }

            PeerGradeAssignment pga = await _context.PeerGradeAssignments
                                      .FirstOrDefaultAsync(pga => pga.CourseId == projectGroup.AffiliatedCourseId);

            if (pga == null)
            {
                response.Data    = null;
                response.Message = "Course doesn't have a peer grade assignment";
                response.Success = false;
                return(response);
            }



            if (user == null || (!doesUserInstruct(user, projectGroup.AffiliatedCourseId) && user.Id != getPeerGradeDto.ReviewerId))
            {
                response.Data    = null;
                response.Message = "You are not authorized to see this peer grade";
                response.Success = false;
                return(response);
            }


            PeerGrade peerGrade = await _context.PeerGrades
                                  .FirstOrDefaultAsync(pg => pg.ReviewerId == getPeerGradeDto.ReviewerId && pg.RevieweeId == getPeerGradeDto.RevieweeId && pg.ProjectGroupId == getPeerGradeDto.ProjectGroupId);

            if (peerGrade == null)
            {
                response.Data    = null;
                response.Message = "There is no such peer grade";
                response.Success = false;
                return(response);
            }

            PeerGradeInfoDto dto = new PeerGradeInfoDto
            {
                Id             = peerGrade.Id,
                ProjectGroupId = peerGrade.ProjectGroupId,
                ReviewerId     = peerGrade.ReviewerId,
                RevieweeId     = peerGrade.RevieweeId,
                MaxGrade       = peerGrade.MaxGrade,
                Grade          = peerGrade.Grade,
                Comment        = peerGrade.Comment,
                LastEdited     = peerGrade.LastEdited
            };

            response.Data    = dto;
            response.Message = "Success";
            response.Success = true;

            return(response);
        }
コード例 #39
0
 public void AddGroup(ProjectGroup group)
 {
     project.AddGroup(group);
 }
コード例 #40
0
        public async Task <ServiceResponse <AddMergeRequestDto> > SendMergeRequest(AddMergeRequestDto newMergeRequest)
        {
            ServiceResponse <AddMergeRequestDto> response = new ServiceResponse <AddMergeRequestDto>();
            User user = await _context.Users.Include(u => u.ProjectGroups)
                        .ThenInclude(g => g.ProjectGroup)
                        .ThenInclude(g => g.AffiliatedSection)
                        .FirstOrDefaultAsync(u => u.Id == GetUserId());

            ProjectGroup receiverGroup = await _context.ProjectGroups.Include(g => g.AffiliatedSection)
                                         .Include(g => g.GroupMembers).Include(g => g.IncomingMergeRequest)
                                         .Include(g => g.OutgoingMergeRequest)
                                         .FirstOrDefaultAsync(rg => rg.Id == newMergeRequest.ReceiverGroupId);

            if (receiverGroup == null)
            {
                response.Data    = null;
                response.Message = "There is no group with receiverGroup's id";
                response.Success = false;
                return(response);
            }

            Section section = await _context.Sections.FirstOrDefaultAsync(s => (s.Id == receiverGroup.AffiliatedSection.Id));

            if (user == null)
            {
                response.Data    = null;
                response.Message = "There is no user with this Id";
                response.Success = false;
                return(response);
            }
            if (section == null)
            {
                response.Data    = null;
                response.Message = "There is no section with this Id ";
                response.Success = false;
                return(response);
            }


            ProjectGroup senderGroup = new ProjectGroup {
                AffiliatedSectionId = -1
            };

            foreach (ProjectGroupUser pgu in user.ProjectGroups)
            {
                if (pgu.ProjectGroup.AffiliatedCourseId == receiverGroup.AffiliatedCourseId && pgu.ProjectGroup.AffiliatedSectionId == receiverGroup.AffiliatedSectionId)
                {
                    senderGroup = pgu.ProjectGroup;
                    break;
                }
            }
            if (senderGroup.AffiliatedSectionId == -1)
            {
                response.Data    = null;
                response.Message = "You are not in the same section with this group";
                response.Success = false;
                return(response);
            }
            if (senderGroup.Id == receiverGroup.Id)
            {
                response.Data    = null;
                response.Message = "You are already in this group";
                response.Success = false;
                return(response);
            }

            if (senderGroup.ConfirmationState == true)
            {
                response.Data    = null;
                response.Message = "Your group is finalized.";
                response.Success = false;
                return(response);
            }
            if (receiverGroup.ConfirmationState == true)
            {
                response.Data    = null;
                response.Message = "The group you want to merge with is finalized.";
                response.Success = false;
                return(response);
            }
            ProjectGroup senderGroupOriginal = await _context.ProjectGroups
                                               .Include(g => g.GroupMembers)
                                               .FirstOrDefaultAsync(rg => rg.Id == senderGroup.Id);

            int maxSize = (await _context.Courses.FirstOrDefaultAsync(c => c.Id == senderGroup.AffiliatedCourseId)).MaxGroupSize;

            if (receiverGroup.GroupMembers.Count + senderGroupOriginal.GroupMembers.Count > maxSize)
            {
                response.Data    = null;
                response.Message = "You would exceed the max allowed group size if you merged.";
                response.Success = false;
                return(response);
            }
            if (receiverGroup.GroupMembers.Count == 0)
            {
                response.Data    = null;
                response.Message = "The group you want to merge with is empty";
                response.Success = false;
                return(response);
            }


            foreach (MergeRequest mr in receiverGroup.IncomingMergeRequest)
            {
                if (mr.SenderGroupId == senderGroup.Id && !mr.Resolved)
                {
                    response.Data    = null;
                    response.Message = "Your group has already sent a merge request to this group that is not resolved yet.";
                    response.Success = false;
                    return(response);
                }
            }

            foreach (MergeRequest mr in receiverGroup.OutgoingMergeRequest)
            {
                if (mr.ReceiverGroupId == senderGroup.Id && !mr.Resolved)
                {
                    response.Data    = null;
                    response.Message = "The group has already sent a merge request to your group that is not resolved yet.";
                    response.Success = false;
                    return(response);
                }
            }

            MergeRequest createdMergeRequest = new MergeRequest
            {
                SenderGroup     = senderGroup,
                SenderGroupId   = senderGroup.Id,
                ReceiverGroup   = receiverGroup,
                ReceiverGroupId = receiverGroup.Id,
                VotedStudents   = GetUserId().ToString(),
                CreatedAt       = newMergeRequest.CreatedAt,
                Accepted        = false,
                Resolved        = false,
                Description     = newMergeRequest.Description
            };

            receiverGroup.IncomingMergeRequest.Add(createdMergeRequest);
            senderGroup.OutgoingMergeRequest.Add(createdMergeRequest);

            _context.ProjectGroups.Update(receiverGroup);
            _context.ProjectGroups.Update(senderGroup);
            _context.MergeRequests.Add(createdMergeRequest);
            await _context.SaveChangesAsync();

            response.Data    = newMergeRequest;
            response.Message = "Merge request is successfully sent " + senderGroup.GroupMembers.Count + " " + receiverGroup.GroupMembers.Count;
            response.Success = true;

            return(response);
        }
コード例 #41
0
        public async Task <ServiceResponse <AddPeerGradeDto> > AddPeerGrade(AddPeerGradeDto addPeerGradeDto)
        {
            ServiceResponse <AddPeerGradeDto> response = new ServiceResponse <AddPeerGradeDto>();
            User user = await _context.Users.Include(u => u.ProjectGroups)
                        .ThenInclude(g => g.ProjectGroup)
                        .FirstOrDefaultAsync(u => u.Id == GetUserId());

            ProjectGroup projectGroup = await _context.ProjectGroups
                                        .Include(g => g.AffiliatedCourse)
                                        .Include(g => g.GroupMembers)
                                        .FirstOrDefaultAsync(rg => rg.Id == addPeerGradeDto.ProjectGroupId);

            if (projectGroup == null)
            {
                response.Data    = null;
                response.Message = "There is no project group with this id";
                response.Success = false;
                return(response);
            }

            if (!IsUserInGroup(projectGroup, GetUserId()))
            {
                response.Data    = null;
                response.Message = "You are not in this group";
                response.Success = false;
                return(response);
            }

            if (!IsUserInGroup(projectGroup, addPeerGradeDto.RevieweeId))
            {
                response.Data    = null;
                response.Message = "You are not in the same group with the reviewee ";
                response.Success = false;
                return(response);
            }

            PeerGradeAssignment pga = await _context.PeerGradeAssignments.Include(pg => pg.PeerGrades)
                                      .FirstOrDefaultAsync(pga => pga.CourseId == projectGroup.AffiliatedCourseId);

            if (pga == null)
            {
                response.Data    = null;
                response.Message = "Course doesn't have a peer grade assignment";
                response.Success = false;
                return(response);
            }

            if (pga.DueDate < addPeerGradeDto.LastEdited)
            {
                response.Data    = null;
                response.Message = "Due date has passed for the peer grade assignment";
                response.Success = false;
                return(response);
            }

            PeerGrade peerGrade = await _context.PeerGrades
                                  .FirstOrDefaultAsync(pg => pg.ReviewerId == GetUserId() && pg.RevieweeId == addPeerGradeDto.RevieweeId && pg.ProjectGroupId == addPeerGradeDto.ProjectGroupId);

            if (peerGrade != null)
            {
                response.Data    = null;
                response.Message = "You have already peer graded this group member";
                response.Success = false;
                return(response);
            }


            if (pga.MaxGrade < addPeerGradeDto.Grade)
            {
                response.Data    = null;
                response.Message = "Grade should be less than or equal to the max grade";
                response.Success = false;
                return(response);
            }


            PeerGrade createdPeerGrade = new PeerGrade
            {
                MaxGrade       = pga.MaxGrade,
                Grade          = addPeerGradeDto.Grade,
                Comment        = addPeerGradeDto.Comment,
                LastEdited     = addPeerGradeDto.LastEdited,
                ProjectGroupId = addPeerGradeDto.ProjectGroupId,
                ReviewerId     = GetUserId(),
                RevieweeId     = addPeerGradeDto.RevieweeId
            };

            pga.PeerGrades.Add(createdPeerGrade);

            _context.ProjectGroups.Update(projectGroup);
            _context.PeerGrades.Add(createdPeerGrade);
            await _context.SaveChangesAsync();

            response.Data    = addPeerGradeDto;
            response.Message = "You successfully entered peer grade";
            response.Success = true;

            return(response);
        }
        public ActionResult Index(ProjectGroup projectGroup, string submitButton)
        {
            if (ModelState.IsValid)
            {
                if (submitButton.Equals("Create"))
                {
                    ViewBag.Response = ProjectGroupManager.Save(projectGroup);
                    ModelState.Clear();
                    ViewBag.Programs = GetProgramsForDropDown();
                    //ViewBag.Departments = GetAllDepartment();
                    ViewBag.Supervisors = GetAllTeachersbyUserId(Convert.ToInt32(Session["UserId"]));
                    return(View(projectGroup));
                }
                //for Supervisor
                else if (submitButton.Equals("AddSupervisor"))
                {
                    ViewBag.Response = SupervisorManager.AddSupervisor(projectGroup);
                    ModelState.Clear();
                    ViewBag.Programs = GetProgramsForDropDown();
                    //ViewBag.Departments = GetAllDepartment();
                    ViewBag.Supervisors = GetAllTeachersbyUserId(Convert.ToInt32(Session["UserId"]));
                    return(View(projectGroup));
                }
                else if (submitButton.Equals("RemoveSupervisor"))
                {
                    ViewBag.Response = RemoveSupervisor(projectGroup.Id);
                    ModelState.Clear();
                    ViewBag.Programs = GetProgramsForDropDown();
                    //ViewBag.Departments = GetAllDepartment();
                    ViewBag.Supervisors = GetAllTeachersbyUserId(Convert.ToInt32(Session["UserId"]));
                    return(View(projectGroup));
                }

                //for student
                else if (submitButton.Equals("Addstudent"))
                {
                    ViewBag.Response = StudentManager.AddStudent(projectGroup);
                    ModelState.Clear();
                    ViewBag.Programs    = GetProgramsForDropDown();
                    ViewBag.Supervisors = GetAllTeachersbyUserId(Convert.ToInt32(Session["UserId"]));
                    return(View(projectGroup));
                }
                else if (submitButton.Equals("RemoveStudent"))
                {
                    ViewBag.Response = RemoveStudent(projectGroup.Id);
                    ModelState.Clear();
                    ViewBag.Programs    = GetProgramsForDropDown();
                    ViewBag.Supervisors = GetAllTeachersbyUserId(Convert.ToInt32(Session["UserId"]));
                    return(View(projectGroup));
                }

                else
                {
                    ModelState.Clear();
                    ViewBag.Programs    = GetProgramsForDropDown();
                    ViewBag.Supervisors = GetAllTeachersbyUserId(Convert.ToInt32(Session["UserId"]));
                    return(View(projectGroup));
                }
            }
            else
            {
                ViewBag.Response = "Fill up all fields correctly";
                ViewBag.Programs = GetProgramsForDropDown();
                //ViewBag.Departments = GetAllDepartment();
                return(View());
            }
        }
コード例 #43
0
        public ActionResult MakeProject(HttpPostedFileBase file)
        {
            if (!IsAuthenticated())
            {
                return(RedirectToAction("Index", "Main"));
            }

            string path = null;

            List <Student> students = new List <Student>();

            if (Request.Form["projectName"].Count() == 0)
            {
                return(RedirectToAction("Error", "Main", new { errorMessage = "Er is geen projectnaam ingevuld" }));
            }
            if (file != null)
            {
                var fileName = Path.GetFileName(file.FileName);
                path = AppDomain.CurrentDomain.BaseDirectory + "upload\\" + fileName;
                file.SaveAs(path);

                // Read the CSV file data
                StreamReader sr    = new StreamReader(path);
                string       line  = sr.ReadLine();
                string[]     value = line.Split(';');
                DataTable    dt    = new DataTable();
                DataRow      row;
                int          columnCount = 0;
                foreach (string dc in value)
                {
                    if (dc.Equals("FirstName") || dc.Equals("LastName") || dc.Equals("StudentNr") || dc.Equals("Year") || dc.Equals("ProjectGroup"))
                    {
                        dt.Columns.Add(new DataColumn(dc));
                        columnCount++;
                    }
                    else
                    {
                        return(RedirectToAction("Error", "Main", new { errorMessage = "Één kolom header is niet correct" }));
                    }
                }
                if (columnCount != 5)
                {
                    return(RedirectToAction("Error", "Main", new { errorMessage = "Het aantal kolommen is niet correct" }));
                }
                while (!sr.EndOfStream)
                {
                    value = sr.ReadLine().Split(';');
                    if (value.Length == dt.Columns.Count)
                    {
                        row           = dt.NewRow();
                        row.ItemArray = value;
                        dt.Rows.Add(row);
                    }
                }

                Project             currentProject = new Project(Request.Form["projectName"], null, new DateTime(2014, 1, 1), new DateTime(2014, 1, 1), null);
                ProjectGroup        currentGroup   = null;
                Student             currentStudent = null;
                List <ProjectGroup> groupsToAdd    = new List <ProjectGroup>();
                List <Student>      studentsToAdd  = new List <Student>();
                var myEnumerable = dt.AsEnumerable();
                foreach (var item in myEnumerable)
                {
                    string pgroup = item.Field <String>("ProjectGroup");
                    int    studnr = int.Parse(item.Field <String>("StudentNr"));

                    currentStudent = _db.Students.Find(studnr);

                    //var groupModel = from r in _db.ProjectGroups
                    //                 where r.ClassCode == pgroup
                    //                 select r;
                    //dbGroup = groupModel.FirstOrDefault();


                    if (currentGroup == null)
                    {
                        ProjectGroup newGroup = new ProjectGroup(pgroup, currentProject);
                        groupsToAdd.Add(newGroup);
                        currentGroup = newGroup;
                    }
                    else
                    {
                        if (!currentGroup.ClassCode.Equals(pgroup))
                        {
                            ProjectGroup newGroup = new ProjectGroup(pgroup, currentProject);
                            currentProject.ProjectGroups.Add(newGroup);
                            groupsToAdd.Add(newGroup);
                            currentGroup = newGroup;
                        }
                    }


                    if (currentStudent == null)
                    {
                        Student newStudent = new Student(
                            int.Parse(item.Field <String>("StudentNr")),
                            item.Field <String>("FirstName"),
                            item.Field <String>("LastName"),
                            int.Parse(item.Field <String>("Year")),
                            null); // mentor

                        studentsToAdd.Add(newStudent);
                        currentStudent = newStudent;
                    }

                    if (currentStudent != null && currentGroup != null)
                    {
                        StudentProjectGroups spg = new StudentProjectGroups(currentStudent, currentGroup);
                        currentStudent.StudentProjectGroup.Add(spg);
                        if (currentGroup.StudentProjectGroup == null)
                        {
                            currentGroup.StudentProjectGroup = new List <StudentProjectGroups>();
                        }
                        currentGroup.StudentProjectGroup.Add(spg);
                    }
                }

                _db.Projects.Add(currentProject);

                foreach (Student stud in studentsToAdd)
                {
                    _db.Students.Add(stud);
                }
                foreach (ProjectGroup group in groupsToAdd)
                {
                    _db.ProjectGroups.Add(group);
                }
                sr.Close();
                file = null;
                System.IO.File.Delete(path);

                _db.SaveChanges();

                return(RedirectToAction("CheckProjectGroup"));
            }
            return(RedirectToAction("Error", "Main", new { errorMessage = "Er is geen bestand geselecteerd" }));
        }
コード例 #44
0
ファイル: ProjectEdit.ascx.cs プロジェクト: alex765022/IBN
        private void BindValues()
        {
            ddlTemplate.DataSource     = ProjectTemplate.GetListProjectTemplate();
            ddlTemplate.DataTextField  = "TemplateName";
            ddlTemplate.DataValueField = "TemplateId";
            ddlTemplate.DataBind();
            ddlTemplate.Items.Insert(0, new ListItem(LocRM.GetString("NotSet"), "0"));
            if (Request["TemplateId"] != null)
            {
                CommonHelper.SafeSelect(ddlTemplate, Request["TemplateId"].ToString());
            }

            ddlStatus.DataSource     = Project.GetListProjectStatus();
            ddlStatus.DataTextField  = "StatusName";
            ddlStatus.DataValueField = "StatusId";
            ddlStatus.DataBind();

            ddPrjPhases.DataSource     = Project.GetListProjectPhases();
            ddPrjPhases.DataTextField  = "PhaseName";
            ddPrjPhases.DataValueField = "PhaseId";
            ddPrjPhases.DataBind();

            ddInitialPhase.DataSource     = Project.GetListProjectPhases();
            ddInitialPhase.DataTextField  = "PhaseName";
            ddInitialPhase.DataValueField = "PhaseId";
            ddInitialPhase.DataBind();

            ddlType.DataValueField = "TypeId";
            ddlType.DataTextField  = "TypeName";
            ddlType.DataSource     = Project.GetListProjectTypes();
            ddlType.DataBind();

            ddlBlockType.DataTextField  = "Title";
            ddlBlockType.DataValueField = "primaryKeyId";
            ddlBlockType.DataSource     = Mediachase.IbnNext.TimeTracking.TimeTrackingBlockType.List(Mediachase.Ibn.Data.FilterElement.EqualElement("IsProject", "1"));
            ddlBlockType.DataBind();

            ddlOverallStatus.Items.Clear();
            for (int i = 0; i <= 100; i++)
            {
                ddlOverallStatus.Items.Add(new ListItem(i.ToString() + " %", i.ToString()));
            }

            BindGeneralCategories();
            BindProjectCategories();
            BindPortfolios();

            ddlCalendar.DataTextField  = "CalendarName";
            ddlCalendar.DataValueField = "CalendarId";
            ddlCalendar.DataSource     = Project.GetListCalendars(PID);
            ddlCalendar.DataBind();

            ddlPriority.DataTextField  = "PriorityName";
            ddlPriority.DataValueField = "PriorityId";
            ddlPriority.DataSource     = Project.GetListPriorities();
            ddlPriority.DataBind();

            ddlRiskLevel.DataTextField  = "RiskLevelName";
            ddlRiskLevel.DataValueField = "RiskLevelId";
            ddlRiskLevel.DataSource     = Project.GetListRiskLevels();
            ddlRiskLevel.DataBind();

            dtcTargetStartDate.SelectedDate = UserDateTime.UserToday;
            dtcTargetEndDate.SelectedDate   = UserDateTime.UserToday.AddMonths(1);

            ddCurrency.DataTextField  = "CurrencySymbol";
            ddCurrency.DataValueField = "CurrencyId";
            ddCurrency.DataSource     = Project.GetListCurrency();
            ddCurrency.DataBind();

            // Managers
            ListItem  li;
            ArrayList alManagers = new ArrayList();

            using (IDataReader iManagers = SecureGroup.GetListAllUsersInGroup((int)InternalSecureGroups.ProjectManager))
            {
                while (iManagers.Read())
                {
                    li = new ListItem(iManagers["LastName"].ToString() + " " + iManagers["FirstName"].ToString(), iManagers["UserId"].ToString());
                    alManagers.Add(li);
                }
            }

            if (Security.IsUserInGroup(InternalSecureGroups.PowerProjectManager))
            {
                int CurrentUserID = Security.UserID;
                for (int i = 0; i < alManagers.Count; i++)
                {
                    ddlManager.Items.Add((ListItem)alManagers[i]);
                }

                li = ddlManager.Items.FindByValue(CurrentUserID.ToString());
                if (li != null)
                {
                    li.Selected = true;
                }
            }
            else
            {
                lblManager.Visible = true;
                ddlManager.Visible = false;
                lblManager.Text    = CommonHelper.GetUserStatus((Security.CurrentUser.UserID));
                iManagerId.Value   = Security.CurrentUser.UserID.ToString();
            }

            // Exec Managers
            li = new ListItem(LocRM.GetString("NotSet"), "0");
            ddlExecManager.Items.Add(li);

            using (IDataReader iManagers = SecureGroup.GetListAllUsersIn2Group((int)InternalSecureGroups.ProjectManager, (int)InternalSecureGroups.ExecutiveManager))
            {
                while (iManagers.Read())
                {
                    ddlExecManager.Items.Add(new ListItem(iManagers["LastName"].ToString() + " " + iManagers["FirstName"].ToString(), iManagers["UserId"].ToString()));
                }
            }


            if (PID != 0)
            {
                //				ddlBlockType.Enabled = false;

                using (IDataReader reader = Project.GetProject(PID))
                {
                    if (reader.Read())
                    {
                        if (reader["OrgUid"] != DBNull.Value)
                        {
                            ClientControl.ObjectType = OrganizationEntity.GetAssignedMetaClassName();
                            ClientControl.ObjectId   = PrimaryKeyId.Parse(reader["OrgUid"].ToString());
                        }
                        else if (reader["ContactUid"] != DBNull.Value)
                        {
                            ClientControl.ObjectType = ContactEntity.GetAssignedMetaClassName();
                            ClientControl.ObjectId   = PrimaryKeyId.Parse(reader["ContactUid"].ToString());
                        }

                        txtTitle.Text        = HttpUtility.HtmlDecode(reader["Title"].ToString());
                        txtGoals.Text        = HttpUtility.HtmlDecode(reader["Goals"].ToString());
                        txtScope.Text        = HttpUtility.HtmlDecode(reader["Scope"].ToString());
                        txtDescription.Text  = HttpUtility.HtmlDecode(reader["Description"].ToString());
                        txtDeliverables.Text = HttpUtility.HtmlDecode(reader["Deliverables"].ToString());

                        CommonHelper.SafeSelect(ddlType, reader["TypeId"].ToString());
                        CommonHelper.SafeSelect(ddlCalendar, reader["CalendarId"].ToString());
                        CommonHelper.SafeSelect(ddCurrency, reader["CurrencyId"].ToString());
                        CommonHelper.SafeSelect(ddlPriority, reader["PriorityId"].ToString());
                        CommonHelper.SafeSelect(ddlRiskLevel, reader["RiskLevelId"].ToString());
                        CommonHelper.SafeSelect(ddlOverallStatus, reader["PercentCompleted"].ToString());
                        if (reader["BlockTypeId"] != DBNull.Value)
                        {
                            CommonHelper.SafeSelect(ddlBlockType, reader["BlockTypeId"].ToString());
                        }

                        ddlExecManager.Items.FindByText(LocRM.GetString("NotSet")).Selected = true;
                        if (reader["ExecutiveManagerId"] != DBNull.Value)
                        {
                            string str = "";
                            str = reader["ExecutiveManagerId"].ToString();
                            ListItem liExec = ddlExecManager.Items.FindByValue(reader["ExecutiveManagerId"].ToString());
                            if (liExec != null)
                            {
                                ddlExecManager.ClearSelection();
                                liExec.Selected = true;
                            }
                        }

                        if (reader["ManagerId"] != DBNull.Value)
                        {
                            if (ddlManager.Visible)
                            {
                                ListItem liClient = ddlManager.Items.FindByValue(reader["ManagerId"].ToString());
                                if (liClient != null)
                                {
                                    ddlManager.ClearSelection();
                                    liClient.Selected = true;
                                }
                            }
                            else
                            {
                                int iManager = (int)reader["ManagerId"];
                                iManagerId.Value = iManager.ToString();
                                lblManager.Text  = CommonHelper.GetUserStatus(iManager);
                            }
                        }
                        if (reader["StatusId"] != DBNull.Value)
                        {
                            ListItem liStatus = ddlStatus.Items.FindByValue(reader["StatusId"].ToString());
                            if (liStatus != null)
                            {
                                ddlStatus.ClearSelection();
                                liStatus.Selected = true;
                            }
                        }

                        if (reader["PhaseId"] != DBNull.Value)
                        {
                            ListItem liPhase = ddPrjPhases.Items.FindByValue(reader["PhaseId"].ToString());
                            if (liPhase != null)
                            {
                                ddPrjPhases.ClearSelection();
                                liPhase.Selected = true;
                            }
                        }

                        if (reader["InitialPhaseId"] != DBNull.Value)
                        {
                            ListItem liPhase = ddInitialPhase.Items.FindByValue(reader["InitialPhaseId"].ToString());
                            if (liPhase != null)
                            {
                                ddInitialPhase.ClearSelection();
                                liPhase.Selected = true;
                            }
                        }

                        dtcTargetStartDate.SelectedDate = (DateTime)reader["TargetStartDate"];
                        dtcTargetEndDate.SelectedDate   = (DateTime)reader["TargetFinishDate"];

                        if (reader["ActualStartDate"] != DBNull.Value && reader["ActualStartDate"].ToString() != "")
                        {
                            dtcActualStartDate.SelectedDate = (DateTime)reader["ActualStartDate"];
                        }
                        if (reader["ActualFinishDate"] != DBNull.Value && reader["ActualFinishDate"].ToString() != "")
                        {
                            dtcActualFinishDate.SelectedDate = (DateTime)reader["ActualFinishDate"];
                        }
                    }
                }

                using (IDataReader reader = Project.GetListCategories(PID))
                {
                    while (reader.Read())
                    {
                        for (int i = 0; i < lbCategory.Items.Count; i++)
                        {
                            ListItem lItem = lbCategory.Items.FindByText(reader["CategoryName"].ToString());
                            if (lItem != null)
                            {
                                lItem.Selected = true;
                            }
                        }
                    }
                }

                using (IDataReader reader = Project.GetListProjectCategoriesByProject(PID))
                {
                    while (reader.Read())
                    {
                        for (int i = 0; i < lbProjectCategory.Items.Count; i++)
                        {
                            ListItem lItem = lbProjectCategory.Items.FindByText(reader["CategoryName"].ToString());
                            if (lItem != null)
                            {
                                lItem.Selected = true;
                            }
                        }
                    }
                }

                using (IDataReader reader = ProjectGroup.ProjectGroupsGetByProject(PID))
                {
                    while (reader.Read())
                    {
                        for (int i = 0; i < lbPortfolios.Items.Count; i++)
                        {
                            ListItem lItem = lbPortfolios.Items.FindByValue(reader["ProjectGroupId"].ToString());
                            if (lItem != null)
                            {
                                lItem.Selected = true;
                            }
                        }
                    }
                }
            }
            else
            {
                // Client
                PrimaryKeyId org_id     = PrimaryKeyId.Empty;
                PrimaryKeyId contact_id = PrimaryKeyId.Empty;
                Common.GetDefaultClient(PortalConfig.ProjectDefaultValueClientField, out contact_id, out org_id);
                if (contact_id != PrimaryKeyId.Empty)
                {
                    ClientControl.ObjectType = ContactEntity.GetAssignedMetaClassName();
                    ClientControl.ObjectId   = contact_id;
                }
                else if (org_id != PrimaryKeyId.Empty)
                {
                    ClientControl.ObjectType = OrganizationEntity.GetAssignedMetaClassName();
                    ClientControl.ObjectId   = org_id;
                }

                // Priority
                Util.CommonHelper.SafeSelect(ddlPriority, PortalConfig.ProjectDefaultValuePriorityField);

                // Currency
                Util.CommonHelper.SafeSelect(ddCurrency, PortalConfig.ProjectDefaultValueCurrencyField);

                // Categories
                ArrayList list = Common.StringToArrayList(PortalConfig.ProjectDefaultValueGeneralCategoriesField);
                foreach (int i in list)
                {
                    CommonHelper.SafeMultipleSelect(lbCategory, i.ToString());
                }
                list = Common.StringToArrayList(PortalConfig.ProjectDefaultValueProjectCategoriesField);
                foreach (int i in list)
                {
                    CommonHelper.SafeMultipleSelect(lbProjectCategory, i.ToString());
                }

                // texts
                txtGoals.Text        = PortalConfig.ProjectDefaultValueGoalsField;
                txtDeliverables.Text = PortalConfig.ProjectDefaultValueDeliverablesField;
                txtScope.Text        = PortalConfig.ProjectDefaultValueScopeField;
            }

            if (PID > 0)
            {
                EditControl.ObjectId = PID;
            }
            EditControl.MetaClassName = String.Concat("ProjectsEx_", ddlType.SelectedValue);
            EditControl.BindData();

            trPriority.Visible          = PortalConfig.CommonProjectAllowEditPriorityField;
            trClient.Visible            = PortalConfig.CommonProjectAllowEditClientField;
            trCategories.Visible        = PortalConfig.CommonProjectAllowEditGeneralCategoriesField;
            trProjectCategories.Visible = PortalConfig.ProjectAllowEditProjectCategoriesField;
            GoalsRow.Visible            = PortalConfig.ProjectAllowEditGoalsField;
            DeleverablesRow.Visible     = PortalConfig.ProjectAllowEditDeliverablesField;
            ScopeRow.Visible            = PortalConfig.ProjectAllowEditScopeField;
            LeftTextCell.Visible        = GoalsRow.Visible || DeleverablesRow.Visible;
        }
コード例 #45
0
ファイル: DAOProject.cs プロジェクト: War0n/Leaping-Cliff
 public void AddGroup(ProjectGroup group)
 {
 }