public CollectionSpecimen CreateSpecimen() { CollectionSpecimen cs = null; try { cs = SERIALIZER.CreateISerializableObject <CollectionSpecimen>(); SERIALIZER.ConnectOneToMany(_parent, cs); cs.CollectionEventID = _parent.CollectionEventID; con.Save(cs); } catch (Exception) { throw new DataFunctionsException("New Specimen couldn't be created."); } try { if (UserProfiles.Instance.Current != null) { try { CollectionAgent agent = SERIALIZER.CreateISerializableObject <CollectionAgent>(); SERIALIZER.ConnectOneToMany(cs, agent); agent.CollectionSpecimenID = cs.CollectionSpecimenID; agent.CollectorsName = UserProfiles.Instance.Current.CombinedNameCache; if (UserProfiles.Instance.Current.AgentURI != null) { agent.CollectorsAgentURI = UserProfiles.Instance.Current.AgentURI; } con.Save(agent); } catch (Exception) { throw new DataFunctionsException("Associated Agent of new Specimen couldn't be created."); } try { CollectionProject csProject = SERIALIZER.CreateISerializableObject <CollectionProject>(); csProject.CollectionSpecimenID = cs.CollectionSpecimenID; csProject.ProjectID = (int)UserProfiles.Instance.Current.ProjectID; con.Save(csProject); } catch (Exception) { throw new DataFunctionsException("Associated Project of new Specimen couldn't be created."); } } } catch (ConnectionCorruptedException) { } this._currentSpecimen = this._csIterator.Last(); return(cs); }
public AgentForm(CollectionAgent agent) : this(true) { if (agent != null) { Cursor.Current = Cursors.WaitCursor; this._agent = agent; // fill Form this.textBoxCollectorsName.Text = _agent.CollectorsName; if (_agent.CollectorsNumber != null && !_agent.CollectorsNumber.Equals(String.Empty)) { this.textBoxNumber.Text = _agent.CollectorsNumber; } if (_agent.Notes != null && !_agent.Notes.Equals(String.Empty)) { this.textBoxNotes.Text = _agent.Notes; } Cursor.Current = Cursors.Default; } }
public AgentForm(CollectionAgent agent) : this(true) { if (agent != null) { Cursor.Current = Cursors.WaitCursor; this._agent = agent; // fill Form this.textBoxCollectorsName.Text = _agent.CollectorsName; if (_agent.CollectorsNumber != null && !_agent.CollectorsNumber.Equals(String.Empty)) this.textBoxNumber.Text = _agent.CollectorsNumber; if (_agent.Notes != null && !_agent.Notes.Equals(String.Empty)) this.textBoxNotes.Text = _agent.Notes; Cursor.Current = Cursors.Default; } }
public AgentVM(CollectionAgent a) : base(a) { }
private void bottomUp(ISerializableObject iso, List <ISerializableObject> parents) { if (iso.GetType().Equals(typeof(IdentificationUnitAnalysis))) { IdentificationUnitAnalysis iua = (IdentificationUnitAnalysis)iso; IdentificationUnit iu = iua.IdentificationUnit; if (iu != null) { parents.Add(iu); bottomUp(iu, parents); } else { throw new Exception(); } } else if (iso.GetType().Equals(typeof(IdentificationUnit))) { IdentificationUnit iu = (IdentificationUnit)iso; /* * IDirectAccessIterator<Identification> identifications = iu.Identifications; * short i = 0; * Identification ident = null; * foreach (Identification id in identifications) * { * if (id.IdentificationSequence != null && id.IdentificationSequence > i) * { * i = (short)id.IdentificationSequence; * ident = id; * } * } * if (ident != null) * parents.Add(ident);*/ IdentificationUnit relatedUnit = iu.RelatedUnit; if (relatedUnit != null) { parents.Add(relatedUnit); bottomUp(relatedUnit, parents); } else { CollectionSpecimen spec = iu.CollectionSpecimen; if (spec != null) { parents.Add(spec); bottomUp(spec, parents); } else { throw new Exception(); } } } else if (iso.GetType().Equals(typeof(CollectionSpecimen))) { CollectionSpecimen spec = (CollectionSpecimen)iso; CollectionAgent ca = spec.CollectionAgent.First(); if (ca != null) { parents.Add(ca); } CollectionEvent ce = spec.CollectionEvent; if (ce != null) { parents.Add(ce); bottomUp(ce, parents); } else { this.root = spec; }; //Warnung dass das Specimen nicht angezeigt werden kann } else if (iso.GetType().Equals(typeof(CollectionEvent))) { CollectionEvent ce = (CollectionEvent)iso; IDirectAccessIterator <CollectionEventLocalisation> locations = ce.CollectionEventLocalisation; foreach (CollectionEventLocalisation loc in locations) { parents.Add(loc); } IDirectAccessIterator <CollectionEventProperty> properties = ce.CollectionEventProperties; foreach (CollectionEventProperty prop in properties) { parents.Add(prop); } CollectionEventSeries cs = ce.CollectionEventSeries; if (cs != null) { parents.Add(cs); this.root = cs; } else { this.root = ce; } } else if (iso.GetType().Equals(typeof(CollectionEventSeries))) { CollectionEventSeries cs = (CollectionEventSeries)iso; this.root = cs; } }
private void topDown(ISerializableObject iso, List <ISerializableObject> children) { if (iso.GetType().Equals(typeof(CollectionEventSeries))) { CollectionEventSeries cs = (CollectionEventSeries)iso; IDirectAccessIterator <CollectionEvent> events = cs.CollectionEvents; foreach (CollectionEvent ce in events) { children.Add(ce); topDown(ce, children); } } if (iso.GetType().Equals(typeof(CollectionEvent))) { CollectionEvent ce = (CollectionEvent)iso; IDirectAccessIterator <CollectionEventLocalisation> locations = ce.CollectionEventLocalisation; foreach (CollectionEventLocalisation loc in locations) { children.Add(loc); } IDirectAccessIterator <CollectionEventProperty> properties = ce.CollectionEventProperties; foreach (CollectionEventProperty prop in properties) { children.Add(prop); } IDirectAccessIterator <CollectionSpecimen> specimen = ce.CollectionSpecimen; foreach (CollectionSpecimen spec in specimen) { children.Add(spec); topDown(spec, children); } } if (iso.GetType().Equals(typeof(CollectionSpecimen))) { CollectionSpecimen spec = (CollectionSpecimen)iso; CollectionAgent ca = spec.CollectionAgent.First(); if (ca != null) { children.Add(ca); } IDirectAccessIterator <CollectionProject> projects = spec.CollectionProject; foreach (CollectionProject pr in projects) { children.Add(pr); } IDirectAccessIterator <IdentificationUnit> units = spec.IdentificationUnits; foreach (IdentificationUnit iu in units) { if (iu.RelatedUnit == null)//Hier kann der Aufwand optimiert werden indem gleich alle IdentificationUnits angehängt werden, alerdings muss dann der Fall von einer IU als Startpunkt gesondert behandelt werden { children.Add(iu); topDown(iu, children); } } } if (iso.GetType().Equals(typeof(IdentificationUnit))) { IdentificationUnit iu = (IdentificationUnit)iso; IDirectAccessIterator <IdentificationUnitAnalysis> analyses = iu.IdentificationUnitAnalysis; IDirectAccessIterator <IdentificationUnitGeoAnalysis> geoAnalyses = iu.IdentificationUnitGeoAnalysis; IDirectAccessIterator <Identification> ids = iu.Identifications; foreach (IdentificationUnitAnalysis iua in analyses) { children.Add(iua); } foreach (IdentificationUnitGeoAnalysis iuga in geoAnalyses) { children.Add(iuga); } foreach (Identification id in ids) { children.Add(id); } IDirectAccessIterator <IdentificationUnit> units = iu.ChildUnits; foreach (IdentificationUnit childUnit in units) { children.Add(childUnit); topDown(childUnit, children); } } }
public void parameterizeCollectionAgentNode(CollectionAgent agent, TreeNode node) { if (agent != null && node != null) { node.Text = agent.CollectorsName; node.ImageIndex = node.SelectedImageIndex = (int)TreeViewIconIndex.Agent; node.Tag = new TreeViewNodeData(agent.CollectorsName, (int)agent.CollectionSpecimenID); } }
public AgentVM(CollectionAgent a) : base(a) { }