コード例 #1
0
ファイル: IATIImportController.cs プロジェクト: BD-IATI/edi
        public ProjectMapModelMinified ToMinifiedProjectMapModel(ProjectMapModel projectMapModel)
        {
            return new ProjectMapModelMinified
            {
                selected = projectMapModel.selected,

                MatchedProjects = ToMinifiedProjectFieldMapModel(projectMapModel.MatchedProjects),
                IatiActivitiesNotInAims = ToMinifiedIatiActivitiesModel(projectMapModel.IatiActivitiesNotInAims),
                AimsProjectsNotInIati = ToMinifiedIatiActivitiesModel(projectMapModel.AimsProjectsNotInIati),
                NewProjectsToAddInAims = ToMinifiedIatiActivitiesModel(projectMapModel.NewProjectsToAddInAims),
                ProjectsOwnedByOther = ToMinifiedIatiActivitiesModel(projectMapModel.ProjectsOwnedByOther)

            };
        }
コード例 #2
0
ファイル: IATIImportController.cs プロジェクト: BD-IATI/edi
        public bool SubmitManualMatching(ProjectMapModel projectMapModel)
        {
            Sessions.ProjectMapModel.AimsProjectsNotInIati = projectMapModel?.AimsProjectsNotInIati;

            Sessions.ProjectMapModel.MatchedProjects.RemoveAll(r => r.IsManuallyMapped);

            //add manually matched projects
            foreach (var project in Sessions.ProjectMapModel?.AimsProjectsNotInIati)
            {
                if (project.MatchedProjects.Count > 0)
                {
                    Sessions.ProjectMapModel.MatchedProjects.Add(new ProjectFieldMapModel(project.MatchedProjects.First(), project) { IsManuallyMapped = true });
                }
            }

            foreach (var project in projectMapModel?.NewProjectsToAddInAims)
            {
                project.IsCommitmentIncluded = true;
                project.IsDisbursmentIncluded = true;
                project.IsPlannedDisbursmentIncluded = true;

                Sessions.ProjectMapModel.NewProjectsToAddInAims.Add(project);
            }

            return true;
        }
コード例 #3
0
ファイル: IATIImportController.cs プロジェクト: BD-IATI/edi
        public ProjectMapModelMinified GetProjectsToMap(ProjectFieldMapModel GeneralPreference)
        {
            Sessions.GeneralPreferences = GeneralPreference ?? Sessions.GeneralPreferences ?? GetGeneralPreferences();

            if (Sessions.ProjectMapModel.MatchedProjects.IsEmpty() && Sessions.ProjectMapModel.NewProjectsToAddInAims.IsEmpty())
            {

                Sessions.activitiesContainer = aimsDbIatiDAL.GetMappedActivities(Sessions.DP.ID);
                var heirarchyModel = CalculateHierarchyMatching();

                var filterBDModel = SubmitHierarchy(heirarchyModel);
                var iOrgs = GetAllImplementingOrg(filterBDModel);
                var relevantActivities = FilterDP(iOrgs.Orgs);
                var projectMapModel = SubmitActivities(relevantActivities);

            }

            ImportLogic.SetFieldMappingPreferences(Sessions.ProjectMapModel.MatchedProjects, Sessions.GeneralPreferences);

            Sessions.CurrentStage = Stage.ReviewAdjustment;
            var returnResult = new ProjectMapModel
            {
                MatchedProjects = Sessions.ProjectMapModel.MatchedProjects,
                IatiActivitiesNotInAims = null,
                AimsProjectsNotInIati = null,
                NewProjectsToAddInAims = Sessions.ProjectMapModel.NewProjectsToAddInAims,
                ProjectsOwnedByOther = null
            };

            Sessions.ProjectsToMap = returnResult;



            return ToMinifiedProjectMapModel(returnResult);
        }
コード例 #4
0
ファイル: IATIImportController.cs プロジェクト: BD-IATI/edi
        public ProjectMapModelMinified SubmitActivities(List<iatiactivityModel> relevantActivies)
        {
            if (relevantActivies != null)
            {
                UpdateActivities(relevantActivies, Sessions.activitiesContainer?.RelevantActivities);
            }
            var relevantActiviesSession = Sessions.activitiesContainer?.RelevantActivities;

            //SetStatics();//since we have no access to session at library project, so we pass it in a static variables

            var ProjectsOwnedByOther = relevantActiviesSession.FindAll(f => f.IATICode != Sessions.DP.ID);

            relevantActiviesSession.RemoveAll(f => f.IATICode != Sessions.DP.ID);

            var AimsProjects = Sessions.activitiesContainer?.AimsProjects;

            var MatchedProjects = (GetMatchedProjects(relevantActiviesSession, AimsProjects)).ToList();

            //for showing mathced projects side by side And field mapping later
            var MatchedProjects2 = (from i in relevantActiviesSession
                                    from a in AimsProjects.Where(k => i.OriginalIatiIdentifier == k.OriginalIatiIdentifier)
                                    orderby i.IatiIdentifier
                                    select new ProjectFieldMapModel(i, a)
                                    ).ToList();

            var IatiActivityNotInAims = relevantActiviesSession.Except(MatchedProjects).ToList();


            var AimsProjectNotInIati = AimsProjects
                .ExceptBy(MatchedProjects, f => f.OriginalIatiIdentifier)
                .ExceptBy(ProjectsOwnedByOther, f => f.OriginalIatiIdentifier)
                .ToList();

            var returnResult = new ProjectMapModel
            {
                MatchedProjects = MatchedProjects2,
                IatiActivitiesNotInAims = IatiActivityNotInAims,
                AimsProjectsNotInIati = AimsProjectNotInIati,
                NewProjectsToAddInAims = new List<iatiactivity>(),
                ProjectsOwnedByOther = ProjectsOwnedByOther
            };
            Sessions.ProjectMapModel = returnResult;

            Sessions.CurrentStage = Stage.ShowProjects;

            var r = ToMinifiedProjectMapModel(returnResult);

            r.AimsProjectsDrpSrc = (from p in AimsProjects
                                    select new LookupItem
                                    {
                                        ID = p.ProjectId,
                                        Name = p.Title
                                    }).ToList();
            return r;
        }