Example #1
0
        }        //end: Constructor()

        #endregion

        #region Internal Methods

        /// <summary>
        /// Import a Knowledge Map to the Study.
        /// </summary>
        internal void ImportKnowledgeMap(ejpKnowledgeMap map)
        {
            if (this._knowledgeMaps.Count == 2)
            {
                throw new Exception(Application.Current.Resources["EX_KMCount"] as string);                //Properties.Resources.EX_KMCount);
            }
            this._knowledgeMaps.Add(map);
        }
Example #2
0
        }        //end: Constructor()

        #endregion

        #region Internal Methods

        /// <summary>
        /// Import a Knowledge Map to the Study.
        /// </summary>
        internal void ImportKnowledgeMap(ejpKnowledgeMap map)
        {
            if (this._knowledgeMaps.Count == 2)
            {
                throw new Exception("No more than 2 knowledgemaps are allowed.");
            }

            this._knowledgeMaps.Add(map);
        }
Example #3
0
        /// <summary>
        /// Adds a new Knowledge Map to the study.
        /// </summary>
        /// <returns>The new Knowledge Map</returns>
        public ejpKnowledgeMap AddKnowledgeMap()
        {
            if (this._knowledgeMaps.Count == 2)
            {
                throw new Exception(Application.Current.Resources["EX_KMCount"].ToString());                //Properties.Resources.EX_KMCount);
            }
            ejpKnowledgeMap m = new ejpKnowledgeMap(this.MetaData.Id);

            this._knowledgeMaps.Add(m);
            return(m);
        }
Example #4
0
        /// <summary>
        /// Adds a new Knowledge Map to the study.
        /// </summary>
        /// <returns>The new Knowledge Map</returns>
        public ejpKnowledgeMap AddKnowledgeMap()
        {
            if (this._knowledgeMaps.Count == 2)
            {
                throw new Exception("No more than 2 knowledgemaps are allowed.");
            }

            ejpKnowledgeMap m = new ejpKnowledgeMap(this.MetaData.Id);

            this._knowledgeMaps.Add(m);
            return(m);
        }
Example #5
0
        /// <summary>
        /// Import a local image file into the current study
        /// </summary>
        public ejpExternalImageEntityWrapper ImportImageFileToStudy(string filePath, ejpKnowledgeMap targetKM)
        {
            ejpExternalImageEntityWrapper wrapper =
                EjpLib.AssignmentOperations.LocalAssignmentFileOperations.ImportImageFileToPackage(
                    Enumerations.AssignmentPackagePartRelationship.KnowledgeMapImageObject_v1,
                    filePath,
                    targetKM.PackageRelationshipIDString,
                    this,
                    targetKM.Id,
                    Helpers.IdManipulation.GetNewGuid());

            return(wrapper);
        }
Example #6
0
        public List <ejpStudy> Import(string path)
        {
            //SiliconStudio.DebugManagers.DebugReporter.Report(
            //		SiliconStudio.DebugManagers.MessageType.Information,
            //		"EjpLib - ejpAssignment",
            //		"Importing an Assignment Package" +
            //		"\nPath: " + path);

            ejpAssignment a = AssignmentOperations.LocalAssignmentFileOperations.ImportAssignment(path, false);

            List <ejpStudy> importedStudies = new List <ejpStudy>();

            Dictionary <Guid, Guid> oldEntityIdToNewIdMapping = new Dictionary <Guid, Guid>();
            Dictionary <Guid, Guid> oldStudyIdToNewIdMapping  = new Dictionary <Guid, Guid>();
            List <ejpKMTextEntity>  allKMTextEntities         = new List <ejpKMTextEntity>();
            List <ejpKMImageEntity> allKMImageEntities        = new List <ejpKMImageEntity>();

            foreach (ejpStudy study in a.Studies)
            {
                //Update the Ids of all studies that are merged
                //more than once. Also, set all the parentId properties of all the objects
                //in the study.
                int mergedNumToTitle = 1;
                foreach (ejpStudy old_study in this._studies)
                {
                    if (old_study.IdString == study.IdString)
                    {
                        study.MetaData.Id = Helpers.IdManipulation.GetNewGuid();
                    }

                    if (study.Title == old_study.Title)
                    {
                        mergedNumToTitle += 1;
                    }
                }

                if (mergedNumToTitle != 0)
                {
                    // study.Title = study.Title + "(" + mergedNumToTitle.ToString() + ")";
                }

                //This will be the new study added to the current assignment
                ejpStudy newStudy = new ejpStudy(this._metaData.Id, study.MetaData.Id, study.Title, study.MetaData.EJSDatabaseId);

                //We also need to update all the parentObject references.
                //Dictionary<Guid, Guid> oldIdToNewIdMapping = new Dictionary<Guid, Guid>();

                //Add all the XpsDocuments
                foreach (ejpXpsDocument xpsD in study.XpsDocuments)
                {
                    Guid oldId = xpsD.InternalDocumentId;
                    Guid newId = Helpers.IdManipulation.GetNewGuid();

                    xpsD.XpsDocument.CoreDocumentProperties.Identifier = newId.ToString();
                    EjpLib.AssignmentOperations.LocalAssignmentFileOperations.AddXPSDocumentToPackage(
                        SiliconStudio.Meet.EjpLib.AssignmentOperations.LocalAssignmentFileOperations.targetPackage,
                        xpsD, Enumerations.AssignmentPackagePartRelationship.XPSDocument_v1, TargetMode.Internal,
                        SiliconStudio.Meet.EjpLib.AssignmentOperations.AssignmentSaveMode.Save,
                        this._filePackagePath, newStudy.MetaData.Id, true);

                    //we have to do this twice. Once to get the package Uri right, and a second
                    //time here since the package returned by LocalAssignmentOps is a copy of the
                    //old one which still has the old Id.
                    xpsD.XpsDocument.CoreDocumentProperties.Identifier = newId.ToString();
                    newStudy.XpsDocuments.Add(xpsD);

                    //Update the references for all the lines in the document.
                    foreach (ejpDocumentLine docLine in xpsD.DocumentLines)
                    {
                        docLine.ParentDocumentId = xpsD.InternalDocumentId;
                        docLine.ParentStudyId    = newStudy.MetaData.Id;
                    }

                    foreach (ejpDocumentImageBorder docImB in xpsD.DocumentImageBorders)
                    {
                        docImB.ParentDocumentId = xpsD.InternalDocumentId;
                        docImB.ParentStudyId    = newStudy.MetaData.Id;
                    }

                    oldEntityIdToNewIdMapping.Add(oldId, xpsD.InternalDocumentId);
                    oldStudyIdToNewIdMapping.Add(oldId, newStudy.MetaData.Id);
                }

                //Fill the new Study with the data from the old imported one.
                foreach (ejpKnowledgeMap km in study.KnowledgeMaps)
                {
                    ejpKnowledgeMap nKm = new ejpKnowledgeMap(newStudy.MetaData.Id);
                    nKm.Id = km.Id;

                    foreach (ejpKMLabel label in km.Labels)
                    {
                        nKm.Labels.Add(label);
                    }

                    foreach (ejpKMConnectedStroke connS in km.ConnectedStrokes)
                    {
                        nKm.ConnectedStrokes.Add(connS);
                    }

                    foreach (ejpKMShape shape in km.ShapeEntities)
                    {
                        nKm.ShapeEntities.Add(shape);
                    }

                    foreach (ejpKMTextEntity textE in km.TextEntities)
                    {
                        if (textE.EntityType != 1) //1 == original to map = no source reference!
                        {
                            allKMTextEntities.Add(textE);
                            //textE.SourceReference.DocumentId = oldIdToNewIdMapping[textE.SourceReference.DocumentId];
                            //textE.SourceReference.DocumentParentStudyId = newStudy.MetaData.Id;
                        }
                        nKm.TextEntities.Add(textE);
                    }

                    foreach (ejpKMImageEntity kmi in km.ImageEntities)
                    {
                        if (kmi.EntityType != 1)
                        {
                            allKMImageEntities.Add(kmi);
                            //kmi.SourceReference.DocumentId = oldIdToNewIdMapping[kmi.SourceReference.DocumentId];
                            //kmi.SourceReference.DocumentParentStudyId = newStudy.MetaData.Id;
                        }
                        nKm.ImageEntities.Add(kmi);
                    }

                    newStudy.ImportKnowledgeMap(nKm);
                }

                foreach (ejpReport report in study.Reports)
                {
                    report.ParentStudyId = newStudy.MetaData.Id;
                    newStudy.Reports.Add(report);
                }

                importedStudies.Add(newStudy);
                this._studies.Add(newStudy);
            }

            //Update the sourceID references of all the KM entities.
            //We do it here because there might be references that point
            //to other-study documents, so we first have to iterate over
            //all the available xps document above to get all the IDs...
            foreach (ejpKMTextEntity textE in allKMTextEntities)
            {
                Guid key = textE.SourceReference.DocumentId;
                textE.SourceReference.DocumentId            = oldEntityIdToNewIdMapping[key];
                textE.SourceReference.DocumentParentStudyId = oldStudyIdToNewIdMapping[key];
            }

            foreach (ejpKMImageEntity kmi in allKMImageEntities)
            {
                Guid key = kmi.SourceReference.DocumentId;
                kmi.SourceReference.DocumentId            = oldEntityIdToNewIdMapping[key];
                kmi.SourceReference.DocumentParentStudyId = oldStudyIdToNewIdMapping[key];
            }



            ejpAssignment._importedAssignments.Add(a);
            return(importedStudies);
        }//end: Import()
Example #7
0
        /// <summary>
        /// Import a local image file into the current study and set it as Guide for the
        /// given KnowledgeMap
        /// </summary>
        public ejpExternalImageEntityWrapper ImportKnowledgeMapGuideToStudy(string filePath, ejpKnowledgeMap targetKM)
        {
            //DebugManagers.DebugReporter.ReportMethodEnter();

            ejpExternalImageEntityWrapper wrapper =
                EjpLib.AssignmentOperations.LocalAssignmentFileOperations.ImportImageFileToPackage(
                    Enumerations.AssignmentPackagePartRelationship.KnowledgeMapImageObject_v1,
                    filePath,
                    targetKM.PackageRelationshipIDString,
                    this,
                    targetKM.Id,
                    Helpers.IdManipulation.GetNewGuid());

            //Let the KM now the source Uri of the image
            //designated as Guide. Until the map is saved,
            //the only data saved here is the source Uri and
            //and empty Id. The rest of the fields get set
            //when the KM is saved...
            targetKM.Guide = new ejpKMGuide()
            {
                Id        = Guid.Empty,
                SourceUri = wrapper.SourceUri
            };

            //DebugManagers.DebugReporter.ReportMethodLeave();

            return(wrapper);
        }