Example #1
0
        public void RemoveStudy(Guid idOfStudyToRemove)
        {
            //SiliconStudio.DebugManagers.DebugReporter.Report(
            //			 SiliconStudio.DebugManagers.MessageType.Information,
            //			 "EjpLib - ejpAssignment",
            //			 "Removing Study" +
            //			 "\nStudy ID: " + idOfStudyToRemove.ToString());

            ejpStudy studyToRemove = new ejpStudy();

            foreach (ejpStudy study in this._studies)
            {
                if (study.MetaData.Id == idOfStudyToRemove)
                {
                    studyToRemove = study;
                }
            }

            foreach (ejpXpsDocument xpsD in studyToRemove.XpsDocuments)
            {
                EjpLib.AssignmentOperations.LocalAssignmentFileOperations.RemoveXpsDocumentFromPackage(
                    xpsD,
                    EjpLib.Enumerations.AssignmentPackagePartRelationship.XPSDocument_v1,
                    studyToRemove.MetaData.Id);
            }

            this._studies.Remove(studyToRemove);
        }
Example #2
0
        public ejpStudy CreateNewStudy()
        {
            //SiliconStudio.DebugManagers.DebugReporter.Report(
            //			 SiliconStudio.DebugManagers.MessageType.Information,
            //			 "EjpLib - ejpAssignment",
            //			 "Adding new (Empty) Study");

            //Add a number to the new study title if there are already
            //unnamed studies in the assignment.
            int nameCounter = 0;

            foreach (ejpStudy existingStudy in this._studies)
            {
                if (existingStudy.Title.Contains("名称未設定 (") ||
                    existingStudy.Title == "名称未設定")
                {
                    nameCounter += 1;
                }
            }
            string newStudyTitle = "名称未設定";

            if (nameCounter != 0)
            {
                newStudyTitle += " (" + nameCounter.ToString() + ")";
            }

            ejpStudy s = new ejpStudy(this._metaData.Id, Helpers.IdManipulation.GetNewGuid(), newStudyTitle, -1);

            s.AddKnowledgeMap();
            s.AddReport();
            this._studies.Add(s);
            return(s);
        }
Example #3
0
        public ejpStudy CreateNewStudy()
        {
            //Add a number to the new study title if there are already
            //unnamed studies in the assignment.
            string unnamed     = Application.Current.Resources["Str_UnnamedStudyTitle"] as string;
            int    nameCounter = 0;

            foreach (ejpStudy existingStudy in this._studies)
            {
                if (existingStudy.Title.Contains(unnamed + " (") ||
                    existingStudy.Title == unnamed)
                {
                    nameCounter += 1;
                }
            }
            string newStudyTitle = unnamed;

            if (nameCounter != 0)
            {
                newStudyTitle += " (" + nameCounter.ToString() + ")";
            }

            ejpStudy s = new ejpStudy(this._metaData.Id, Helpers.IdManipulation.GetNewGuid(), newStudyTitle, -1);

            s.AddKnowledgeMap();
            s.AddReport();
            this._studies.Add(s);
            return(s);
        }
Example #4
0
        internal ejpStudy CreateNewStudy(string firstXpsDocumentPath, string xpsDocumentTitle, Guid xpsDocumentId)
        {
            string   unnamed = Application.Current.Resources["Str_UnnamedStudyTitle"] as string;
            ejpStudy s       = new ejpStudy(this._metaData.Id, Helpers.IdManipulation.GetNewGuid(),
                                            unnamed, -1, firstXpsDocumentPath, true, xpsDocumentId, xpsDocumentTitle);

            s.AddReport();
            s.AddKnowledgeMap();
            this._studies.Add(s);
            return(s);
        }
Example #5
0
        internal ejpStudy CreateNewStudy(string firstXpsDocumentPath, string xpsDocumentTitle, Guid xpsDocumentId)
        {
            //SiliconStudio.DebugManagers.DebugReporter.Report(
            //			 SiliconStudio.DebugManagers.MessageType.Information,
            //			 "EjpLib - ejpAssignment",
            //			 "Adding new Study" +
            //			 "\nFirst XPS Document Path :" + firstXpsDocumentPath +
            //			 "\nFirst XPS Document Title :" + xpsDocumentTitle);

            ejpStudy s = new ejpStudy(this._metaData.Id, Helpers.IdManipulation.GetNewGuid(),
                                      "名称未設定", -1, firstXpsDocumentPath, true, xpsDocumentId, xpsDocumentTitle);

            s.AddReport();
            s.AddKnowledgeMap();
            this._studies.Add(s);
            return(s);
        }
Example #6
0
        public void RemoveStudy(Guid idOfStudyToRemove)
        {
            ejpStudy studyToRemove = new ejpStudy();

            foreach (ejpStudy study in this._studies)
            {
                if (study.MetaData.Id == idOfStudyToRemove)
                {
                    studyToRemove = study;
                }
            }

            foreach (ejpXpsDocument xpsD in studyToRemove.XpsDocuments)
            {
                EjpLib.AssignmentOperations.LocalAssignmentFileOperations.RemoveXpsDocumentFromPackage(
                    xpsD,
                    EjpLib.Enumerations.AssignmentPackagePartRelationship.XPSDocument_v1,
                    studyToRemove.MetaData.Id);
            }

            this._studies.Remove(studyToRemove);
        }
Example #7
0
        }//end: Import()

        private void UpdateStudyItemsParentIdReference(ejpStudy study, Guid parentStudyId)
        {
        }
Example #8
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()