Пример #1
0
 internal Specimen(CollectionEvent ce)
 {
     if (ce != null)
     {
         _parent = ce;
         _csIterator = ce.CollectionSpecimen;
         _csIterator.Reset();
         this.Current = _csIterator.First();
     }
 }
 public IEnumerable<CollectionEventLocalisation> RetrieveLocalisationSystemForCollectionEvent(CollectionEvent ce)
 {
     if (ce != null)
         return ce.CollectionEventLocalisation;
     else
         return new List<CollectionEventLocalisation>();
 }
 public IList<CollectionEventImage> RetrieveImagesForCollectionEvent(String imageType, CollectionEvent ce)
 {
     IList<CollectionEventImage> ceImgList;
     try
     {
         IRestriction idRes = RestrictionFactory.Eq(typeof(CollectionEventImage), "_CollectionEventID", ce.CollectionEventID);
         IRestriction typeRes = RestrictionFactory.Eq(typeof(CollectionEventImage), "_ImageType", imageType);
         IRestriction restrict = RestrictionFactory.And().Add(idRes).Add(typeRes);
         ceImgList = con.LoadList<CollectionEventImage>(restrict);
     }
     catch (Exception)
     {
         ceImgList = new List<CollectionEventImage>();
     }
     return ceImgList;
 }
        public CollectionEventProperty CreateCollectionEventProperty(int propertyID, String text, CollectionEvent ce)
        {
            try
            {
                CollectionEventProperty ceProp = SERIALIZER.CreateISerializableObject<CollectionEventProperty>();
                SERIALIZER.ConnectOneToMany(ce, ceProp);
                ceProp.PropertyID = propertyID;
                ceProp.DisplayText = text;

                try
                {
                    if (UserProfiles.Instance.Current != null)
                    {
                        ceProp.ResponsibleName = UserProfiles.Instance.Current.CombinedNameCache;

                        if (UserProfiles.Instance.Current.AgentURI != null)
                            ceProp.ResponsibleAgentURI = UserProfiles.Instance.Current.AgentURI;
                    }
                }
                catch (ConnectionCorruptedException) { }

                con.Save(ceProp);
                return ceProp;
            }
            catch (Exception)
            {
                throw new DataFunctionsException("New Event Property couldn't be created");
            }
        }
        public CollectionEventLocalisation CreateCollectionEventLocalisation(int LocSystemID, String value, CollectionEvent ce)
        {
            try
            {
                CollectionEventLocalisation ceLoc = SERIALIZER.CreateISerializableObject<CollectionEventLocalisation>();
                //ceLoc.CollectionEventID = this.Current.CollectionEventID;
                SERIALIZER.ConnectOneToMany(ce, ceLoc);
                ceLoc.LocalisationSystemID = LocSystemID;
                ceLoc.Location1 = value;

                try
                {
                    if (UserProfiles.Instance.Current != null)
                    {
                        ceLoc.ResponsibleName = UserProfiles.Instance.Current.CombinedNameCache;

                        if (UserProfiles.Instance.Current.AgentURI != null)
                            ceLoc.ResponsibleAgentURI = UserProfiles.Instance.Current.AgentURI;
                    }
                }
                catch (ConnectionCorruptedException) { }

                con.Save(ceLoc);
                return ceLoc;
            }
            catch (Exception)
            {
                throw new DataFunctionsException("New Localisation couldn't be created");
            }
        }
 public IEnumerable<CollectionEventProperty> RetrievePropertyForCollectionEvent(CollectionEvent ce)
 {
     if (ce != null)
         return ce.CollectionEventProperties;
     else
         return new List<CollectionEventProperty>();
 }
        public bool Find(int id)
        {
            try
            {
                IRestriction restrict = RestrictionFactory.Eq(typeof(CollectionEvent), "_CollectionEventID", id);
                this._currentEvent = con.Load<CollectionEvent>(restrict);

                if (this._currentEvent == null)
                {
                    return false;
                }
                else
                {
                    this._ceIterator.SetIteratorTo(this._currentEvent);
                    return true;
                }
            }
            catch (Exception)
            {
                return false;
            }
        }
        public void parametrizeOnlyEventNode(CollectionEvent ev, TreeNode eventNode)
        {
            if (ev != null && eventNode != null)
            {
                StringBuilder sbEventTitle = new StringBuilder();

                if (ev.CollectorsEventNumber != null && !ev.CollectorsEventNumber.Equals(string.Empty))
                {
                    sbEventTitle.Append(ev.CollectorsEventNumber);
                }

                if (ev.LocalityDescription != null && !ev.LocalityDescription.Equals(string.Empty))
                {
                    sbEventTitle.Append(ev.LocalityDescription);
                }

                if (ev.CollectionDate != null)
                {
                    sbEventTitle.Append(", ");
                    sbEventTitle.Append(ev.CollectionDate.Day);
                    sbEventTitle.Append(".");
                    sbEventTitle.Append(ev.CollectionDate.Month);
                    sbEventTitle.Append(".");
                    sbEventTitle.Append(ev.CollectionDate.Year);
                }

                eventNode.Text = sbEventTitle.ToString();
                eventNode.ImageIndex = eventNode.SelectedImageIndex = (int)TreeViewIconIndex.Event;
                eventNode.Tag = new TreeViewNodeData((int)ev.CollectionEventID, TreeViewNodeTypes.EventNode);
                if(this.expandLvl==ExpandLevel.Event)
                    eventNode.BackColor = System.Drawing.Color.BlanchedAlmond;
            }
        }
 public void CreateNewEvent(int? seriesID)
 {
     CollectionEvent ce = SERIALIZER.CreateISerializableObject<CollectionEvent>();
     // EventSeries
     ce.SeriesID = seriesID;
     if (seriesID != null)
     {
         try
         {
             SERIALIZER.ConnectOneToMany(EventSeriess.Instance.Current, ce);
         }
         catch (ConnectionCorruptedException ex)
         {
             throw ex;
         }
     }
     if (this.LastCollectorsEventNumber != -1)
     {
         ce.CollectorsEventNumber = (this.LastCollectorsEventNumber + 1).ToString();
     }
     try
     {
         con.Save(ce);
         this._currentEvent = this._ceIterator.Last();
     }
     catch (Exception ex)
     {
         throw new DataFunctionsException("New CollectionEvent couldn't be saved. (" + ex.Message + ")");
     }
 }
Пример #10
0
        /// <summary>
        /// Displays an event.
        /// </summary>
        /// <param name="currentEvent">The current event.</param>
        protected void displayEvent(CollectionEvent ev)
        {
            if (ev != null)
            {
                Cursor.Current = Cursors.WaitCursor;
                this.treeViewFieldData.BeginUpdate();
                this.treeViewFieldData.SuspendLayout();
                TreeNode parent = treeViewFieldData.SelectedNode.Parent;
                TreeNode node = treeViewFieldData.SelectedNode;
                try
                {
                    TreeNode evNode = new TreeNode();
                    treeViewFieldData.SelectedNode = null;
                    IList<TreeNode> removeNodes = new List<TreeNode>();
                    int i = 0;
                    if (this._tvOperations.expandLvl <= ExpandLevel.EventSeries)
                    {
                        removeNodes.Add(node);
                        i = node.Index;
                    }
                    else
                    {
                        foreach (TreeNode tn in parent.Nodes)
                        {
                            TreeViewNodeData td = tn.Tag as TreeViewNodeData;
                            if (td.NodeType == TreeViewNodeTypes.EventNode)
                                removeNodes.Add(tn);
                            else
                                i++;
                        }
                    }

                    evNode = _tvOperations.displayEvent(ev);

                    foreach (TreeNode rem in removeNodes)
                    {
                        parent.Nodes.Remove(rem);
                    }
                    parent.Nodes.Insert(i, evNode);
                    this.treeViewFieldData.SelectedNode = evNode;
                    this._expandTrigger = false;
                    if (this._tvOperations.expandLvl <= ExpandLevel.Event)
                        evNode.ExpandAll();
                    else
                        evNode.Expand();
                    this._expandTrigger = true;
                    this._actualLvl = TreeViewNodeTypes.EventNode;
                    this.enableDisableButtons(TreeViewNodeTypes.EventNode);

                }
                catch (Exception ex)
                {
                    this.treeViewFieldData.SelectedNode = parent;
                    afterSelect(parent);
                    this.treeViewFieldData.EndUpdate();
                    this.treeViewFieldData.ResumeLayout();
                    this.treeViewFieldData.Refresh();
                    Cursor.Current = Cursors.Default;
                    MessageBox.Show("DisplayError: " + ex.Message);
                    return;
                }
                this.treeViewFieldData.ResumeLayout();
                this.treeViewFieldData.EndUpdate();
                this.treeViewFieldData.Refresh();
                Cursor.Current = Cursors.Default;
            }
        }
        public void parametrizeEventNode(CollectionEvent ev, TreeNode eventNode, List<ISerializableObject> list)
        {
            if (ev != null && eventNode != null)
            {
                parametrizeOnlyEventNode(ev, eventNode);

                foreach (ISerializableObject iso in list)
                {
                    if (iso != null)
                    {
                        if (iso.GetType().Equals(typeof(CollectionEventProperty)))
                        {
                            CollectionEventProperty cp = (CollectionEventProperty)iso;
                            if (cp.CollectionEventID == ev.CollectionEventID)
                            {
                                TreeNode propNode = new TreeNode();
                                parameterizeCollectionEventPropertyNode(cp, propNode);
                                eventNode.Nodes.Add(propNode);
                            }
                        }
                        else if (iso.GetType().Equals(typeof(CollectionEventLocalisation)))
                        {
                            CollectionEventLocalisation loc = (CollectionEventLocalisation)iso;
                            if (loc.CollectionEventID == ev.CollectionEventID)
                            {
                                TreeNode locNode = new TreeNode();
                                parameterizeCollectionEventLocalisationNode(loc, locNode);
                                eventNode.Nodes.Add(locNode);
                            }
                        }
                    }
                }
            }
        }
        public void parametrizeEventNode(CollectionEvent ev, TreeNode eventNode)
        {
            if (ev != null && eventNode != null)
            {
                parametrizeOnlyEventNode(ev, eventNode);

                IDirectAccessIterator<CollectionEventProperty> properties = ev.CollectionEventProperties;
                if (properties.First() != null)
                {
                    CollectionEventProperty cp = properties.First();
                    TreeNode propNode = new TreeNode();
                    parameterizeCollectionEventPropertyNode(cp, propNode);
                    eventNode.Nodes.Add(propNode);
                    while (properties.HasNext())
                    {
                        CollectionEventProperty next = properties.Next();
                        propNode = new TreeNode();
                        parameterizeCollectionEventPropertyNode(next, propNode);
                        eventNode.Nodes.Add(propNode);
                    }
                }

                IDirectAccessIterator<CollectionEventLocalisation> localisations = ev.CollectionEventLocalisation;
                if (localisations.First() != null)
                {
                    CollectionEventLocalisation loc = localisations.First();
                    TreeNode locNode = new TreeNode();
                    parameterizeCollectionEventLocalisationNode(loc, locNode);
                    eventNode.Nodes.Add(locNode);
                    while (localisations.HasNext())
                    {
                        CollectionEventLocalisation next = localisations.Next();
                        locNode = new TreeNode();
                        parameterizeCollectionEventLocalisationNode(next, locNode);
                        eventNode.Nodes.Add(locNode);
                    }
                }
            }
        }
 public TreeNode displayTopDownEvent(CollectionEvent ev)
 {
     TreeNode eventNode = new TreeNode();
     if (ev != null)
     {
         parametrizeEventNode(ev, eventNode);
         if (ev.CollectionSpecimen.First() != null)
         {
             eventNode.Nodes.Add(displayTopDownSpecimen(ev.CollectionSpecimen.First()));
             while (ev.CollectionSpecimen.HasNext())
             {
                 CollectionSpecimen next = ev.CollectionSpecimen.Next();
                 eventNode.Nodes.Add(displayTopDownSpecimen(next));
             }
         }
     }
     return eventNode;
 }
 public TreeNode displayEvent(CollectionEvent ev)
 {
     TreeNode evNode = new TreeNode();
     if (ev != null)
     {
         if (expandLvl <= ExpandLevel.Event)
         {
             evNode = displayTopDownEvent(ev);
         }
         else
         {
             parametrizeEventNode(ev, evNode);
             if (ev.CollectionSpecimen.First() != null)
             {
                 CollectionSpecimen first = ev.CollectionSpecimen.First();
                 TreeNode specimenNode = new TreeNode();
                 parametrizeOnlySpecimenNode(first, specimenNode);
                 if (first.IdentificationUnits.First() != null)
                     specimenNode.Nodes.Insert(0, new TreeNode());
                 evNode.Nodes.Add(specimenNode);
                 while (ev.CollectionSpecimen.HasNext())
                 {
                     CollectionSpecimen next = ev.CollectionSpecimen.Next();
                     TreeNode nextNode = new TreeNode();
                     parametrizeOnlySpecimenNode(next, nextNode);
                     if (next.IdentificationUnits.First() != null)
                         nextNode.Nodes.Insert(0, new TreeNode());
                     evNode.Nodes.Add(nextNode);
                 }
             }
         }
     }
     return evNode;
 }
        public TreeNode displayBottomUpEvent(CollectionEvent ev, TreeNode childNode)
        {
            TreeNode eventNode = new TreeNode();
            TreeNode subRootNode = null;
            if (ev != null)
            {
                parametrizeEventNode(ev, eventNode);
                if(childNode != null)
                    eventNode.Nodes.Add(childNode);

                //Property und LocalisationSystem werden beim parametrisieren eingebunden
                CollectionEventSeries es = ev.CollectionEventSeries;
                subRootNode = displayBottomUpEventSeries(es, eventNode);
            }
            return subRootNode;
        }
        public void CreateNewEvent(int? seriesID, double altitude, double longitude, double latitude, int countSat, float dilution)
        {
            CollectionEvent ce = SERIALIZER.CreateISerializableObject<CollectionEvent>();
            ce.SeriesID = seriesID;
            if (this.LastCollectorsEventNumber != -1)
            {
                ce.CollectorsEventNumber = (this.LastCollectorsEventNumber + 1).ToString();
            }
            if (seriesID != null)
            {
                try
                {
                    SERIALIZER.ConnectOneToMany(EventSeriess.Instance.Current, ce);
                }
                catch (ConnectionCorruptedException ex)
                {
                    throw ex;
                }
            }

            try
            {
                con.Save(ce);
                this._currentEvent = this._ceIterator.Last();
            }
            catch (Exception ex)
            {
                throw new DataFunctionsException("New CollectionEvent couldn't be saved. (" + ex.Message + ")");
            }

            // Default Localisation: altitude
            CollectionEventLocalisation ceLoc1 = SERIALIZER.CreateISerializableObject<CollectionEventLocalisation>();
            SERIALIZER.ConnectOneToMany(ce, ceLoc1);
            ceLoc1.LocalisationSystemID = 4;
            ceLoc1.AverageAltitudeCache = altitude;
            ceLoc1.Location1 = altitude.ToString("00.00");

            // Notes: automatically changed per GPS
            StringBuilder builder = new StringBuilder();
            builder.AppendLine("GPS Coordinates automatically changed");
            builder.AppendLine("Number of Satellites: " + countSat.ToString());
            builder.AppendLine("Position Dilution: " + dilution.ToString());

            ceLoc1.LocationNotes = builder.ToString();

            try
            {
                if (UserProfiles.Instance.Current != null)
                {
                    ceLoc1.ResponsibleName = UserProfiles.Instance.Current.CombinedNameCache;

                    if (UserProfiles.Instance.Current.AgentURI != null)
                        ceLoc1.ResponsibleAgentURI = UserProfiles.Instance.Current.AgentURI;
                }
            }
            catch (ConnectionCorruptedException)
            { }

            try
            {
                con.Save(ceLoc1);
            }
            catch (Exception ex)
            {
                throw new DataFunctionsException("Associated Localisation (Type Altitude) couldn't be created. (" + ex.Message + ")");
            }

            // Default Localisation: wgs84
            CollectionEventLocalisation ceLoc2 = SERIALIZER.CreateISerializableObject<CollectionEventLocalisation>();
            SERIALIZER.ConnectOneToMany(ce, ceLoc2);
            ceLoc2.LocalisationSystemID = 8;
            ceLoc2.AverageLatitudeCache = latitude;
            ceLoc2.AverageLongitudeCache = longitude;
            ceLoc2.AverageAltitudeCache = altitude;
            ceLoc2.Location1 = longitude.ToString("00.00000000");
            ceLoc2.Location2 = latitude.ToString("00.00000000");

            // Notes: automatically changed per GPS
            ceLoc2.LocationNotes = builder.ToString();

            try
            {
                if (UserProfiles.Instance.Current != null)
                {
                    ceLoc2.ResponsibleName = UserProfiles.Instance.Current.CombinedNameCache;

                    if (UserProfiles.Instance.Current.AgentURI != null)
                        ceLoc2.ResponsibleAgentURI = UserProfiles.Instance.Current.AgentURI;
                }
            }
            catch (ConnectionCorruptedException)
            { }

            try
            {
                con.Save(ceLoc2);
            }
            catch (Exception ex)
            {
                throw new DataFunctionsException("Associated Localisation (Type GPS) couldn't be created. (" + ex.Message + ")");
            }
        }
 public EventVM(CollectionEvent ev)
     : base(ev)
 {
 }
 public CollectionEventForm(CollectionEvent currentEvent)
     : this(true)
 {
     if (currentEvent != null)
     {
         this._event = currentEvent;
         Cursor.Current = Cursors.WaitCursor;
         this.fillEventData();
         Cursor.Current = Cursors.Default;
     }
     else
         this.Close();
 }