Esempio n. 1
0
        public static ejpAssignment Open(string path)
        {
            ejpAssignment a = AssignmentOperations.LocalAssignmentFileOperations.OpenAssignment(path);

            a.IsPersisted = true;
            return(a);
        }        //end: Open()
Esempio n. 2
0
        /// <summary>
        /// Create a new Assignment with a study based on an XPS document.
        /// </summary>
        /// <remarks>UC-36</remarks>
        /// <param name="title">Title of the Assignment.</param>
        /// <param name="firstXPSDocumentPath">Path to the first XPS document to add to the Assignment.</param>
        /// <param name="owner">The owner of this Assignment.</param>
        /// <returns>A new Assignment Object.</returns>
        public static ejpAssignment Create(
            string title, string firstXPSDocumentPath, string firstXpsDocumentTitle,
            ejpUser owner, bool isManagedByEJournalServer,
            Guid xpsDocumentId, string tempFilePath)
        {
            try
            {
                //TODO: Improve.
                ejpAssignment a = new ejpAssignment(Helpers.IdManipulation.GetNewGuid(), title,
                                                    isManagedByEJournalServer, owner.Id);
                a.CreateNewStudy(firstXPSDocumentPath, firstXpsDocumentTitle, xpsDocumentId);

                //string tempFilePath = @"c:\Windows\Temp\TempEjpPackage"+DateTime.Now.Ticks.ToString()+".ejp";
                AssignmentOperations.LocalAssignmentFileOperations.SaveTemporaryAssignment(a, tempFilePath);
                a.Dispose();

                ejpAssignment b = AssignmentOperations.LocalAssignmentFileOperations.OpenAssignment(tempFilePath);
                b.tempFilePath    = tempFilePath;
                b.FilePackagePath = "";

                return(b);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Esempio n. 3
0
        public static ejpAssignment Open(string path)
        {
            //SiliconStudio.DebugManagers.DebugReporter.Report(
            //		SiliconStudio.DebugManagers.MessageType.Information,
            //		"EjpLib - ejpAssignment",
            //		"Opening an Assignment" +
            //		"\nPath: " + path);

            ejpAssignment a = AssignmentOperations.LocalAssignmentFileOperations.OpenAssignment(path);

            a.IsPersisted = true;
            return(a);
        }        //end: Open()
Esempio n. 4
0
        /// <summary>
        /// Create a new Assignment with a study based on an XPS document.
        /// </summary>
        /// <remarks>UC-36</remarks>
        /// <param name="title">Title of the Assignment.</param>
        /// <param name="firstXPSDocumentPath">Path to the first XPS document to add to the Assignment.</param>
        /// <param name="owner">The owner of this Assignment.</param>
        /// <returns>A new Assignment Object.</returns>
        public static ejpAssignment Create(
            string title, string firstXPSDocumentPath, string firstXpsDocumentTitle,
            ejpUser owner, bool isManagedByEJournalServer,
            Guid xpsDocumentId, string tempFilePath)
        {
            try
            {
                //SiliconStudio.DebugManagers.DebugReporter.Report(
                //	SiliconStudio.DebugManagers.MessageType.Information,
                //	"EjpLib - ejpAssignment",
                //	"Creating Assignment" +
                //	"\nTitle: " + title +
                //	"\nFirst XPS Document Path: " + firstXPSDocumentPath +
                //	"\nTemp File Path: " + tempFilePath);

                //TODO: Improve.
                ejpAssignment a = new ejpAssignment(Helpers.IdManipulation.GetNewGuid(), title,
                                                    isManagedByEJournalServer, owner.Id);
                a.CreateNewStudy(firstXPSDocumentPath, firstXpsDocumentTitle, xpsDocumentId);

                //string tempFilePath = @"c:\Windows\Temp\TempEjpPackage"+DateTime.Now.Ticks.ToString()+".ejp";
                AssignmentOperations.LocalAssignmentFileOperations.SaveTemporaryAssignment(a, tempFilePath);
                a.Dispose();

                ejpAssignment b = AssignmentOperations.LocalAssignmentFileOperations.OpenAssignment(tempFilePath);
                b.tempFilePath    = tempFilePath;
                b.FilePackagePath = "";

                return(b);
            }
            catch (Exception ex)
            {
                //SiliconStudio.DebugManagers.DebugReporter.Report(
                //	SiliconStudio.DebugManagers.MessageType.Error,
                //	"EjpLib - ejpAssignment",
                //	"Creating Assignment Failed" +
                //	"\nTitle: " + title +
                //	"\nFirst XPS Document Path: " + firstXPSDocumentPath +
                //	"\nTemp File Path: " + tempFilePath +
                //	"\nError :" + ex.Message);
                System.Diagnostics.Debug.WriteLine(ex.Message);

                return(null);
            }
        }
Esempio n. 5
0
        public static ejpAssignment CreateEmpty(string title, ejpStudent ownerUser, bool isManagedByEJournalServer,
                                                string tempFilePath)
        {
            try
            {
                //SiliconStudio.DebugManagers.DebugReporter.Report(
                //	SiliconStudio.DebugManagers.MessageType.Information,
                //	"EjpLib - ejpAssignment",
                //	"Creating Empty Assignment" +
                //	"\nTitle: " + title +
                //	"\nTemp File Path: " + tempFilePath);

                //TODO: Improve.
                ejpAssignment a = new ejpAssignment(Helpers.IdManipulation.GetNewGuid(), title,
                                                    isManagedByEJournalServer, ownerUser.Id);

                AssignmentOperations.LocalAssignmentFileOperations.SaveTemporaryAssignment(a, tempFilePath);
                a.Dispose();

                ejpAssignment b = AssignmentOperations.LocalAssignmentFileOperations.ImportAssignment(tempFilePath, true);
                b.tempFilePath    = tempFilePath;
                b.FilePackagePath = "";

                return(b);
            }
            catch (Exception ex)
            {
                //SiliconStudio.DebugManagers.DebugReporter.Report(
                //	SiliconStudio.DebugManagers.MessageType.Error,
                //	"EjpLib - ejpAssignment",
                //	"Creating Empty Assignment Failed" +
                //	"\nTitle: " + title +
                //	"\nTemp File Path: " + tempFilePath +
                //	"\nError :" + ex.Message);
                System.Diagnostics.Debug.WriteLine(ex.Message);

                return(null);
            }
        }
Esempio n. 6
0
        public static ejpAssignment CreateEmpty(string title, ejpStudent ownerUser, bool isManagedByEJournalServer,
                                                string tempFilePath)
        {
            try
            {
                //TODO: Improve.
                ejpAssignment a = new ejpAssignment(Helpers.IdManipulation.GetNewGuid(), title,
                                                    isManagedByEJournalServer, ownerUser.Id);

                AssignmentOperations.LocalAssignmentFileOperations.SaveTemporaryAssignment(a, tempFilePath);
                a.Dispose();

                ejpAssignment b = AssignmentOperations.LocalAssignmentFileOperations.ImportAssignment(tempFilePath, true);
                b.tempFilePath    = tempFilePath;
                b.FilePackagePath = "";

                return(b);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Esempio n. 7
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()