Ejemplo n.º 1
1
 /// <summary>
 /// Initializes a new instance of the <see cref="Operation"/> class
 /// using the data read from persistent storage.
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 protected Operation(EditDeserializer editDeserializer)
     : base(editDeserializer)
 {
     editDeserializer.CurrentEdit = this;
     m_Session = editDeserializer.MapModel.LastSession;
     Debug.Assert(m_Session != null);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Operation"/> class that will be
 /// included in the current editing session.
 /// </summary>
 protected Operation()
     : base()
 {
     m_Session = CadastralMapModel.Current.WorkingSession;
     if (m_Session == null)
         throw new ArgumentNullException();
 }
Ejemplo n.º 3
0
        void LoadDataFiles(string folderName, uint[] fileNums)
        {
            Trace.Write("Reading data...");
            EditDeserializer ed = new EditDeserializer(this);
            Session lastSession = null;
            IdManager idMan = m_MapModel.IdManager;

            foreach (uint fileNum in fileNums)
            {
                string editFile = Path.Combine(folderName, ProjectDatabase.GetDataFileName(fileNum));

                using (TextReader tr = File.OpenText(editFile))
                {
                    TextEditReader er = new TextEditReader(tr);

                    // Ignore any empty files altogether
                    while (er.HasNext)
                    {
                        ed.SetReader(er);
                        Change edit = Change.Deserialize(ed);

                        if (edit is NewProjectEvent)
                        {
                            m_ProjectInfo = (NewProjectEvent)edit;

                            // If the project settings don't have default entity types, initialize them with
                            // the layer defaults. This covers a case where the settings file has been lost, and
                            // automatically re-created by ProjectSettings.CreateInstance.

                            var layer = EnvironmentContainer.FindLayerById(m_ProjectInfo.LayerId);
                            m_Settings.SetEntityTypeDefaults(layer);
                        }
                        else if (edit is NewSessionEvent)
                        {
                            lastSession = new Session(this, (NewSessionEvent)edit, editFile);
                            m_MapModel.AddSession(lastSession);
                        }
                        else if (edit is EndSessionEvent)
                        {
                            Debug.Assert(lastSession != null);
                            lastSession.EndTime = edit.When;
                        }
                        else if (edit is IdAllocation)
                        {
                            if (idMan != null)
                            {
                                IdAllocation alloc = (IdAllocation)edit;
                                IdGroup g = idMan.FindGroupById(alloc.GroupId);
                                g.AddIdPacket(alloc);

                                // Remember that allocations have been made in the session (bit of a hack
                                // to ensure the session isn't later removed if no edits are actually
                                // performed).
                                lastSession.AddAllocation(alloc);
                            }

                        }
                        else
                        {
                            Debug.Assert(edit is Operation);
                            Debug.Assert(lastSession != null);
                            lastSession.AddOperation((Operation)edit);
                        }
                    }
                }
            }

            if (m_ProjectInfo == null)
                throw new ApplicationException("Could not locate the project creation event");

            // Apply any forward references
            ed.ApplyForwardRefs();

            // Remember the highest internal ID used by the project
            SetLastItem(fileNums[fileNums.Length - 1]);
        }