Exemplo n.º 1
0
        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 + ")");
            }
        }
Exemplo n.º 2
0
        private void InternalDispatchEvent(CollectionEventKind kind, object item /* = null*/, int location /* = -1*/)
        {
            // copied from ArrayList
            //Debug.Log(string.Format("InternalDispatchEvent: {0}, {1}, {2}", kind, item, location));
            if (HasEventListener(CollectionEvent.COLLECTION_CHANGE))
            {
                var ce = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE)
                {
                    Kind = kind
                };
                ce.Items.Add(item);
                ce.Location = location;
                DispatchEvent(ce);
            }

            // now dispatch a complementary PropertyChangeEvent
            if (HasEventListener(PropertyChangeEvent.PROPERTY_CHANGE) &&
                (kind == CollectionEventKind.ADD || kind == CollectionEventKind.REMOVE))
            {
                var objEvent = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE)
                {
                    Property = location.ToString()
                };
                if (kind == CollectionEventKind.ADD)
                {
                    objEvent.NewValue = item;
                }
                else
                {
                    objEvent.OldValue = item;
                }
                DispatchEvent(objEvent);
            }
        }
Exemplo n.º 3
0
        private bool InternalRefresh(bool dispatch)
        {
            if (null != _sort || null != _filterFunction)
            {
                try
                {
                    PopulateLocalIndex();
                }
                catch (Exception ex)
                {
                    /*pending.addResponder(new ItemResponder(
                     *  function(data:Object, token:Object = null):void
                     *  {
                     *      internalRefresh(dispatch);
                     *  },
                     *  function(info:Object, token:Object = null):void
                     *  {
                     *      //no-op
                     *  }));*/
                    return(false);
                }

                if (null != _filterFunction)
                {
                    var tmp = new List <object>();
                    var len = _localIndex.Count;
                    for (int i = 0; i < len; i++)
                    {
                        var item = _localIndex[i];
                        if (FilterFunction(item))
                        {
                            tmp.Add(item);
                        }
                    }
                    _localIndex = tmp;
                }
                if (null != _sort)
                {
                    _sort.DoSort(_localIndex);
                    dispatch = true;
                }
            }
            else //if (_localIndex)
            {
                _localIndex = null;
            }

            //revision++;
            //pendingUpdates = null;
            if (dispatch)
            {
                var refreshEvent = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE)
                {
                    Kind = CollectionEventKind.REFRESH
                };
                DispatchEvent(refreshEvent);
            }
            return(true);
        }
Exemplo n.º 4
0
 private static bool AllRecordsAfterOf(DateTime d, CollectionEvent @event)
 {
     using (
         MetricsDataContext context =
             new MetricsDataContext(ConfigHelper.GetConnectionString(ConfigFileName, ConnectionName)))
     {
         return(!context.Registries.Any(r => r.Time > d && r.Event != (uint)@event));
     }
 }
Exemplo n.º 5
0
 internal Specimen(CollectionEvent ce)
 {
     if (ce != null)
     {
         _parent     = ce;
         _csIterator = ce.CollectionSpecimen;
         _csIterator.Reset();
         this.Current = _csIterator.First();
     }
 }
Exemplo n.º 6
0
        public void Remove(CollectionEventSeries cs)
        {
            try
            {
                CollectionEventSeries newSeries;
                if (cs.CollectionEvents.First() != null)
                {
                    CollectionEvent ev = cs.CollectionEvents.First();
                    ev.SeriesID = null;
                    try
                    {
                        DataFunctions.Instance.Update(ev);

                        while (cs.CollectionEvents.HasNext())
                        {
                            ev          = cs.CollectionEvents.Next();
                            ev.SeriesID = null;
                            DataFunctions.Instance.Update(ev);
                        }
                    }
                    catch (DataFunctionsException ex)
                    {
                        throw ex;
                    }
                }
                if (!this.HasNext)
                {
                    if (this.HasPrevious)
                    {
                        newSeries    = this.Previous;
                        this.Current = newSeries;
                    }
                    else
                    {
                        newSeries    = this.First;
                        this.Current = newSeries;
                    }
                }
                else
                {
                    newSeries    = this.Next;
                    this.Current = newSeries;
                }

                con.Delete(cs);
            }
            catch (ConnectionCorruptedException ex)
            {
                throw ex;
            }
            catch (DataFunctionsException ex)
            {
                throw ex;
            }
        }
        public virtual void UpdateData(CollectionEvent itemEvent, object data)
        {
            switch (itemEvent)
            {
            case CollectionEvent.Update:
                FlushView();
                break;

            default:
                Debug.LogError("UpdateData Fail.....Not Define " + itemEvent);
                break;
            }
        }
Exemplo n.º 8
0
        /**
         *  Place the item at the specified index.
         *  If an item was already at that index the new item will replace it and it
         *  will be returned.
         *
         *  Param:  item the new value for the index
         *  Param:  index the index at which to place the item
         *  Returns: the item that was replaced, null if none
         *  @throws RangeError if index is less than 0 or greater than or equal to length
         */
        public virtual object SetItemAt(object item, int index)
        {
            if (index < 0 || index >= Length)
            {
                throw new IndexOutOfRangeException("Range error");
            }

            object oldItem = Source[index];

            Source[index] = item;
            StopTrackUpdates(oldItem);
            StartTrackUpdates(item);

            //dispatch the appropriate events
            if (_dispatchEvents == 0)
            {
                var hasCollectionListener      = HasEventListener(CollectionEvent.COLLECTION_CHANGE);
                var hasPropertyListener        = HasEventListener(PropertyChangeEvent.PROPERTY_CHANGE);
                PropertyChangeEvent updateInfo = null;

                if (hasCollectionListener || hasPropertyListener)
                {
                    updateInfo = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE)
                    {
                        Kind     = PropertyChangeEventKind.UPDATE,
                        OldValue = oldItem,
                        NewValue = item,
                        Property = index.ToString()
                    };
                }

                if (hasCollectionListener)
                {
                    CollectionEvent ce = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE)
                    {
                        Kind     = CollectionEventKind.REPLACE,
                        Location = index
                    };
                    ce.Items.Add(updateInfo);
                    DispatchEvent(ce);
                }

                if (hasPropertyListener)
                {
                    DispatchEvent(updateInfo);
                }
            }
            return(oldItem);
        }
Exemplo n.º 9
0
        public void AddSorted()
        {
            listen();

            int[] items;
            CollectionEvent <int>[] expectedEvents;

            if (!collection.AllowsDuplicates)
            {
                items          = new int[] { 31, 62, 93 };
                expectedEvents = new CollectionEvent <int>[]
                {
                    new CollectionEvent <int>(EventTypeEnum.Added, new ItemCountEventArgs <int>(31, 1), collection),
                    new CollectionEvent <int>(EventTypeEnum.Added, new ItemCountEventArgs <int>(62, 1), collection),
                    new CollectionEvent <int>(EventTypeEnum.Added, new ItemCountEventArgs <int>(93, 1), collection),
                    new CollectionEvent <int>(EventTypeEnum.Changed, new EventArgs(), collection)
                };
            }
            else if (collection.DuplicatesByCounting)
            {
                items          = new int[] { 31, 62, 62, 93 };
                expectedEvents = new CollectionEvent <int>[]
                {
                    new CollectionEvent <int>(EventTypeEnum.Added, new ItemCountEventArgs <int>(31, 1), collection),
                    new CollectionEvent <int>(EventTypeEnum.Added, new ItemCountEventArgs <int>(62, 1), collection),
                    new CollectionEvent <int>(EventTypeEnum.Added, new ItemCountEventArgs <int>(62, 1), collection),
                    new CollectionEvent <int>(EventTypeEnum.Added, new ItemCountEventArgs <int>(93, 1), collection),
                    new CollectionEvent <int>(EventTypeEnum.Changed, new EventArgs(), collection)
                };
            }
            else
            {
                items          = new int[] { 31, 62, 63, 93 };
                expectedEvents = new CollectionEvent <int>[]
                {
                    new CollectionEvent <int>(EventTypeEnum.Added, new ItemCountEventArgs <int>(31, 1), collection),
                    new CollectionEvent <int>(EventTypeEnum.Added, new ItemCountEventArgs <int>(62, 1), collection),
                    new CollectionEvent <int>(EventTypeEnum.Added, new ItemCountEventArgs <int>(63, 1), collection),
                    new CollectionEvent <int>(EventTypeEnum.Added, new ItemCountEventArgs <int>(93, 1), collection),
                    new CollectionEvent <int>(EventTypeEnum.Changed, new EventArgs(), collection)
                };
            }

            collection.AddSorted(items);
            seen.Check(expectedEvents);

            collection.AddSorted(new int[] { });
            seen.Check(new CollectionEvent <int>[] { });
        }
Exemplo n.º 10
0
 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();
     }
 }
Exemplo n.º 11
0
 public static ObservableCollection<CollectionEvent> ToUx(List<Event> itemsIn)
 {
     ObservableCollection<CollectionEvent> itemsOut = new ObservableCollection<CollectionEvent>();
     foreach (Event i in itemsIn)
     {
         CollectionEvent o = new CollectionEvent
         {
             Id = i.Id,
             Message = i.Message.Trim(),
             Time = i.Time.ToString("G")
         };
         itemsOut.Add(o);
     }
     return itemsOut;
 }
Exemplo n.º 12
0
        private static Registry MakeRegistry(CollectionEvent @event)
        {
            IntPtr winId = WinAPI.GetForegroundWindowId();
            string foregroundWinTitle = WinAPI.GetTextOfForegroundWindow();
            string path = WinAPI.GetForegroundWindowExeModulePath();
            string process = WinAPI.GetForegroundWindowProcessName();
            string ip, mac;

            WinAPI.GetAdapters(out ip, out mac);
            string username = WinAPI.GetSystemUserName();

            string url = null;

            if (process.Contains("chrome"))
            {
                url = WinAPI.GetChormeUrl();
                //WinAPI.Tabs(out a);
                //url = Convert.ToString(a);
            }

            var r = new Registry()
            {
                Event         = (ushort)@event,
                WindowTitle   = foregroundWinTitle,
                ExeModulePath = path,
                ProcessName   = process,
                Time          = DateTime.Now,
                Username1     = new Username()
                {
                    Value = username
                },
                IpAddress = new IpAddress()
                {
                    Value = ip
                },
                MacAddress = new MacAddress()
                {
                    Value = mac
                },
                WindowId  = winId.ToString(),
                Url       = url,
                Processed = false
            };

            return(r);
        }
Exemplo n.º 13
0
        static CollectionEvent EnsureCollectionEventExists(StudyUnit study)
        {
            var dc = EnsureDataCollectionExists(study);

            var collectionEvent = dc.CollectionEvents.FirstOrDefault();

            if (collectionEvent == null)
            {
                collectionEvent = new CollectionEvent()
                {
                    AgencyId = study.AgencyId
                };
                dc.CollectionEvents.Add(collectionEvent);
            }

            return(collectionEvent);
        }
Exemplo n.º 14
0
        void OnDataBaseChange_Signal(FriendCfg oldData, FriendCfg newData, int _dex, CollectionEvent action)
        {
            switch (action)
            {
            case CollectionEvent.AddSignal:
                m_LayoutScrollViewScript.DataModelChangeSignal(action, newData, _dex, oldData, bindContex.CurViewBindDataBase);
                break;

            case CollectionEvent.DeleteSignal:
                m_LayoutScrollViewScript.DataModelChangeSignal(action, newData, _dex, oldData, bindContex.CurViewBindDataBase);
                break;

            case CollectionEvent.Update:
                m_LayoutScrollViewScript.DataModelChangeSignal(action, newData, _dex, oldData, bindContex.CurViewBindDataBase);
                break;

            default:
                Debug.LogError("Miss  EnumType " + action);
                break;
            }
        }
Exemplo n.º 15
0
        public void ShowCollectionEvent(CollectionEvent collectionEvent = CollectionEvent.GameStart, Player player = null)
        {
            DebugLog("[COLLECTION] " + collectionEvent);
            Crashlytics.Log($"Collection event: {collectionEvent}");
            //StartCoroutine(ShowingCollectionEvent(collectionEvent, player));

            switch (collectionEvent)
            {
            case CollectionEvent.GameStart:
                collectionEventCoroutine = StartCoroutine(GameStartCoroutine());
                break;

            case CollectionEvent.NextLevelInOrderComplete:
                collectionEventCoroutine = StartCoroutine(NextLevelInOrderCompleteCoroutine());
                break;

            case CollectionEvent.NewLocationUnlocked:
                if (player.GroupIndex > 1)
                {
                    collectionEventCoroutine = StartCoroutine(NewLocationUnlockedCoroutine());
                }
                else
                {
                    collectionEventCoroutine = StartCoroutine(FirstEverLocationUnlockedCoroutine());
                }
                break;

            case CollectionEvent.GoldLevelComplete:
                collectionEventCoroutine = StartCoroutine(GoldLevelCompleteCoroutine());
                break;

            case CollectionEvent.CollectionComplete:
                collectionEventCoroutine = StartCoroutine(CollectionCompleteCoroutine());
                break;

            case CollectionEvent.GameComplete:
                collectionEventCoroutine = StartCoroutine(GameCompleteCoroutine());
                break;
            }
        }
Exemplo n.º 16
0
        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);
            }
        }
Exemplo n.º 17
0
 bool isRoot(ISerializableObject iso)
 {
     if (iso is CollectionEventSeries)
     {
         return(true);
     }
     if (iso is CollectionEvent)
     {
         CollectionEvent ce = (CollectionEvent)iso;
         if (ce.SeriesID == null)
         {
             return(true);
         }
     }
     if (iso is CollectionSpecimen)
     {
         CollectionSpecimen spec = (CollectionSpecimen)iso;
         if (spec.CollectionEventID == null)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 18
0
        /// <summary>
        /// Dispatches a collection event with the specified information.
        /// </summary>
        /// <param name="kind"></param>
        /// <param name="item"></param>
        /// <param name="location"></param>
        private void InternalDispatchEvent(CollectionEventKind kind, object item = null, int location= -1)
        {
            //Debug.Log(string.Format("InternalDispatchEvent: {0}, {1}, {2}", kind, item, location));
            if (_dispatchEvents == 0)
            {
                if (HasEventListener(CollectionEvent.COLLECTION_CHANGE))
                {
                    var ce = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE) { Kind = kind };
                    ce.Items.Add(item);
                    ce.Location = location;
                    DispatchEvent(ce);
                }

                // now dispatch a complementary PropertyChangeEvent
                if (HasEventListener(PropertyChangeEvent.PROPERTY_CHANGE) && 
                   (kind == CollectionEventKind.ADD || kind == CollectionEventKind.REMOVE))
                {
                    var objEvent = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE) {Property = location.ToString()};
                    if (kind == CollectionEventKind.ADD)
                        objEvent.NewValue = item;
                    else
                        objEvent.OldValue = item;
                    DispatchEvent(objEvent);
                }
            }
        }
Exemplo n.º 19
0
 public EntityCollectionEventHandler(CollectionEvent eventType, IEntityObject item)
 {
     EventType = eventType;
     Item      = item;
 }
Exemplo n.º 20
0
        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 + ")");
            }
        }
Exemplo n.º 21
0
        public void transferPicture(ISerializableObject iso)
        {
            resetInformation();

            _service = new DiversityMediaServiceClient();


            if (_service.State != System.ServiceModel.CommunicationState.Opened)
            {
                try
                {
                    _service.Open();
                }
                catch (Exception e)
                {
                    StringBuilder sb = new StringBuilder("Cant Open Connection: ").Append(e.Message);
                    if (e.InnerException != null)
                    {
                        sb.Append(",");
                        sb.Append(e.InnerException.Message);
                    }

                    throw new Exception(sb.ToString());
                }
            }
            _author    = this._userName;
            _projectId = this._project;
            //Fallunterscheidung nach ImageTypeClasse um benötigte informationen zu bekommen
            try
            {
                if (iso is CollectionEventImage)
                {
                    CollectionEventImage cei = (CollectionEventImage)iso;
                    _rowGuid = cei.Rowguid.ToString();
                    string        pureFileName = System.IO.Path.GetFileName(cei.URI);
                    string        path         = System.IO.Directory.GetCurrentDirectory();
                    StringBuilder sb           = new StringBuilder(_pictureDirectory);
                    sb.Append("\\");
                    sb.Append(pureFileName);
                    _pathName = sb.ToString();
                    _type     = cei.ImageType;
                    IRestriction                re  = RestrictionFactory.Eq(typeof(CollectionEvent), "_CollectionEventID", cei.CollectionEventID);
                    CollectionEvent             ce  = _sourceSerializer.Connector.Load <CollectionEvent>(re);
                    IRestriction                r1  = RestrictionFactory.Eq(typeof(CollectionEventLocalisation), "_CollectionEventID", cei.CollectionEventID);
                    IRestriction                r2  = RestrictionFactory.Eq(typeof(CollectionEventLocalisation), "_LocalisationSystemID", 8);
                    IRestriction                r   = RestrictionFactory.And().Add(r1).Add(r2);
                    CollectionEventLocalisation cel = _sourceSerializer.Connector.Load <CollectionEventLocalisation>(r);
                    if (cel != null)
                    {
                        if (cel.AverageAltitudeCache != null)
                        {
                            _longitude = (float)cel.AverageLongitudeCache;
                        }
                        if (cel.AverageLatitudeCache != null)
                        {
                            _latitude = (float)cel.AverageLatitudeCache;
                        }
                        if (cel.AverageLongitudeCache != null)
                        {
                            _altitude = (float)cel.AverageAltitudeCache;
                        }
                    }
                    _timestamp = cei.LogTime.ToString();
                }
                else if (iso.GetType().Equals(typeof(CollectionSpecimenImage)))
                {
                    CollectionSpecimenImage csi = (CollectionSpecimenImage)iso;
                    _rowGuid = csi.Rowguid.ToString();
                    string        pureFileName = System.IO.Path.GetFileName(csi.URI);
                    string        path         = System.IO.Directory.GetCurrentDirectory();
                    StringBuilder sb           = new StringBuilder(_pictureDirectory);
                    sb.Append("\\");
                    sb.Append(pureFileName);
                    _pathName = sb.ToString();
                    _type     = csi.ImageType;
                    IRestriction                re  = RestrictionFactory.Eq(typeof(CollectionSpecimen), "_CollectionSpecimenID", csi.CollectionSpecimenID);
                    CollectionSpecimen          cs  = _sourceSerializer.Connector.Load <CollectionSpecimen>(re);
                    CollectionEvent             ce  = cs.CollectionEvent;
                    IRestriction                r1  = RestrictionFactory.Eq(typeof(CollectionEventLocalisation), "_CollectionEventID", ce.CollectionEventID);
                    IRestriction                r2  = RestrictionFactory.Eq(typeof(CollectionEventLocalisation), "_LocalisationSystemID", 8);
                    IRestriction                r   = RestrictionFactory.And().Add(r1).Add(r2);
                    CollectionEventLocalisation cel = _sourceSerializer.Connector.Load <CollectionEventLocalisation>(r);
                    if (cel != null)
                    {
                        if (cel.AverageAltitudeCache != null)
                        {
                            _longitude = (float)cel.AverageLongitudeCache;
                        }
                        else
                        {
                            _longitude = 0;
                        }
                        if (cel.AverageLatitudeCache != null)
                        {
                            _latitude = (float)cel.AverageLatitudeCache;
                        }
                        else
                        {
                            _latitude = 0;
                        }
                        if (cel.AverageLongitudeCache != null)
                        {
                            _altitude = (float)cel.AverageAltitudeCache;
                        }
                        else
                        {
                            _altitude = 0;
                        }
                    }
                    else
                    {
                        _latitude = _longitude = _altitude = 0;
                    }
                    _timestamp = csi.LogTime.ToString();
                }
                else
                {
                    throw new TransferException("ImageClass not Supported");
                }
            }
            catch (Exception e)
            {
                StringBuilder sb = new StringBuilder("Corresponding data not found: ").Append(e.Message);
                if (e.InnerException != null)
                {
                    sb.Append(",");
                    sb.Append(e.InnerException.Message);
                }

                throw new Exception(sb.ToString());
            }
            FileStream   fileStrm = null;
            BinaryReader rdr      = null;

            byte[]   data      = null;
            DateTime start     = DateTime.Now;
            String   retString = String.Empty;

            try
            {
                // Create stream and reader for file data
                fileStrm = new FileStream(_pathName, FileMode.Open, FileAccess.Read);
                rdr      = new BinaryReader(fileStrm);
            }
            catch (Exception e)
            {
                StringBuilder sb = new StringBuilder("Picture not found: ").Append(e.Message);
                if (e.InnerException != null)
                {
                    sb.Append(",");
                    sb.Append(e.InnerException.Message);
                }
                if (rdr != null)
                {
                    rdr.Close();
                }
                throw new Exception(sb.ToString());
            }
            try
            {
                // Number of bytes to be transferred
                long numBytes = fileStrm.Length;

                // Package counter
                int count = 0;
                // Return string
                _fileName = Path.GetFileName(_pathName);

                if (numBytes > 0)
                {
                    data = rdr.ReadBytes((int)numBytes);
                    count++;
                    //retString = f.ReadFileAndTransfer(pathName);
                    retString = _service.Submit(_fileName, _fileName, _type, _latitude, _longitude, _altitude, _author, _timestamp, _projectId, data); // IDs 372, 373, 374
                }
                TimeSpan dif = DateTime.Now - start;

                if (retString.StartsWith("http"))
                {
                    MessageBox.Show(retString);
                    MessageBox.Show(dif.ToString() + " msec  -  " + count.ToString() + " packets transmitted");
                }
                else
                {
                    MessageBox.Show("ERROR: " + retString);
                }

                // Close reader and stream
                rdr.Close();
                fileStrm.Close();
            }
            catch (Exception e)
            {
                StringBuilder sb = new StringBuilder("Transfer Error: ").Append(e.Message);
                if (e.InnerException != null)
                {
                    sb.Append(",");
                    sb.Append(e.InnerException.Message);
                }
                if (rdr != null)
                {
                    rdr.Close();
                }
                if (fileStrm != null)
                {
                    fileStrm.Close();
                }
                throw new Exception(sb.ToString());
            }
            finally
            {
                // Abort faulted proxy
                if (_service.State == System.ServiceModel.CommunicationState.Faulted)
                {
                    // Webservice method call
                    // proxy.Rollback();
                    _service.Abort();
                }
                // Close proxy
                else if (_service.State == System.ServiceModel.CommunicationState.Opened)
                {
                    _service.Close();
                }
            }
            if (iso.GetType().Equals(typeof(CollectionEventImage)))
            {
                CollectionEventImage cei = (CollectionEventImage)iso;
                cei.URI = retString;
            }
            if (iso.GetType().Equals(typeof(CollectionSpecimenImage)))
            {
                CollectionSpecimenImage csi = (CollectionSpecimenImage)iso;
                csi.URI = retString;
            }
            // Close reader and stream
            rdr.Close();
            fileStrm.Close();
        }
Exemplo n.º 22
0
 public async Task LogCollectionEventAsync(Collection collection, EventType type)
 {
     var e = new CollectionEvent(collection, _currentContext.UserId.Value, type);
     await _eventRepository.CreateAsync(e);
 }
Exemplo n.º 23
0
        public void HandleEvent(CollectionEvent evt)
        {
            foreach (var asset in evt.Assets)
            {
                asset.State = AssetState.NeedsCleaning;
                asset.WithCustomerId = null;
                asset.History.Add(new AssetEventInfo
                {
                    AssetId = asset.Id,
                    EventId = evt.Id,
                    EventType = AssetEventType.Collected,
                });

                _assets.Update(asset, commit: false);
            }

            _events.Add(evt);
        }
Exemplo n.º 24
0
 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);
         }
     }
 }
Exemplo n.º 25
0
        void OnDataBaseChange_Multiple(IList <FriendCfg> oldData, IList <FriendCfg> newData, CollectionEvent action)
        {
            switch (action)
            {
            case CollectionEvent.AddRang:
                m_LayoutScrollViewScript.DataModelChange(action, newData, 0, bindContex.CurViewBindDataBase);
                break;

            case CollectionEvent.DeleteRangle:
                m_LayoutScrollViewScript.DataModelChange(action, newData, 0, bindContex.CurViewBindDataBase);
                break;

            case CollectionEvent.Clear:
                m_LayoutScrollViewScript.DataModelChange(action, newData, 0, bindContex.CurViewBindDataBase);
                break;

            case CollectionEvent.Flush:
                Debug.Log("Flush View");
                m_LayoutScrollViewScript.DataModelChange(action, newData, 0, bindContex.CurViewBindDataBase);
                break;

            default:
                Debug.LogError("Miss  EnumType " + action);
                break;
            }
        }
Exemplo n.º 26
0
            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;
                }
            }
        public virtual void DataModelChange <T>(CollectionEvent collEvent, IList <T> _newData, int _dex, IList <T> _dataSource)
        {
            int maxValue = 0;

            if (m_HorizontalLayout)
            {
                maxValue = (m_InitialItemCount + RowNumber - 1) / RowNumber * RowNumber;
            }
            else
            {
                maxValue = (m_InitialItemCount + ColumnNumber - 1) / ColumnNumber * ColumnNumber;
            }

            maxValue = Mathf.Max(maxValue, ColumnNumber * RowNumber);

            List <object> _ShowDataList = new List <object>(_dataSource.Count);

            for (int dex = 0; dex < _dataSource.Count; ++dex)
            {
                _ShowDataList.Add(_dataSource[dex]);
            }

            //Debug.Log(minValue + "    " + maxVaue + "   " + m_InitialItemCount);
            switch (collEvent)
            {
            case CollectionEvent.AddRang:
                if (m_LayoutState != LayoutState.Idle)
                {    //Record
                    Scroll_ForceStopScroll();
                    DataModelChange <T>(collEvent, _newData, _dex, _dataSource);
                    return;
                }
                if (m_ListPanelRectTrans == null)
                {    //*************************未知原因
                    Debug.Log("*************************Not expected    *****************  m_ListPanelRectTrans=null " + gameObject);
                    return;
                }
                ReBuildView(_ShowDataList.Count, true, true);
                break;

            case CollectionEvent.DeleteRangle:
                if (m_LayoutState != LayoutState.Idle)
                {    //Record
                    Scroll_ForceStopScroll();
                    DataModelChange <T>(collEvent, _newData, _dex, _dataSource);
                    return;
                }
                ReBuildView(_ShowDataList.Count, true, true);
                break;

            case CollectionEvent.Clear:
                ReBuildView(_ShowDataList.Count, true, true);
                Scroll_ForceStopScroll();
                break;

            case CollectionEvent.Flush:
                for (int dex = 0; dex < AllViewItemBtnRefences.Count; ++dex)
                {
                    AllViewItemBtnRefences[dex].FlushView();
                }
                break;
            }
        }
Exemplo n.º 28
0
 /**
  *  Place the item at the specified index.  
  *  If an item was already at that index the new item will replace it and it 
  *  will be returned.
  *
  *  Param:  item the new value for the index
  *  Param:  index the index at which to place the item
  *  Returns: the item that was replaced, null if none
  *  @throws RangeError if index is less than 0 or greater than or equal to length
  */
 public virtual object SetItemAt(object item, int index)
 {
     if (index < 0 || index >= Length) 
     {
         throw new IndexOutOfRangeException("Range error");
     }
     
     object oldItem = Source[index];
     Source[index] = item;
     StopTrackUpdates(oldItem);
     StartTrackUpdates(item);
     
     //dispatch the appropriate events 
     if (_dispatchEvents == 0)
     {
         var hasCollectionListener = HasEventListener(CollectionEvent.COLLECTION_CHANGE);
         var hasPropertyListener = HasEventListener(PropertyChangeEvent.PROPERTY_CHANGE);
         PropertyChangeEvent updateInfo = null; 
         
         if (hasCollectionListener || hasPropertyListener)
         {
             updateInfo = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE)
                              {
                                  Kind = PropertyChangeEventKind.UPDATE,
                                  OldValue = oldItem,
                                  NewValue = item,
                                  Property = index.ToString()
                              };
         }
         
         if (hasCollectionListener)
         {
             CollectionEvent ce = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE)
                                      {
                                          Kind = CollectionEventKind.REPLACE,
                                          Location = index
                                      };
             ce.Items.Add(updateInfo);
             DispatchEvent(ce);
         }
         
         if (hasPropertyListener)
         {
             DispatchEvent(updateInfo);
         }
     }
     return oldItem;    
 }
 public EventVM(CollectionEvent ev)
     : base(ev)
 {
 }
        /// <summary>
        /// 数据层有一个对象改变时候
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="collEvent"></param>
        /// <param name="newData"></param>
        /// <param name="_dex"></param>
        /// <param name="_data"></param>
        /// <param name="sourceData"></param>
        public virtual void DataModelChangeSignal <T>(CollectionEvent collEvent, T newData, int _dex, T _data, IList <T> sourceData)
        {
            int maxVaue = 0;  //获得当前能显示的数据最大数量(在这个范围内的数据改变需要刷新,否则只需要更新数据源数据即可)

            if (m_HorizontalLayout)
            {
                maxVaue = (m_InitialItemCount + RowNumber - 1) / RowNumber * RowNumber;
            }
            else
            {
                maxVaue = (m_InitialItemCount + ColumnNumber - 1) / ColumnNumber * ColumnNumber;
            }

            maxVaue = Mathf.Max(maxVaue, ColumnNumber * RowNumber); //最小的显示区域既是初始设置的显示区域

            RectTransform item = null;

            //   Debug.Log(_dex+ " maxVaue= " +maxVaue + "   " + m_InitialItemCount);
            switch (collEvent)
            {
            case CollectionEvent.AddSignal:
                #region AddSignal
                if (m_LayoutState != LayoutState.Idle)
                {
                    Scroll_ForceStopScroll();
                    DataModelChangeSignal <T>(collEvent, newData, _dex, _data, sourceData);
                    return;
                }
                #region AddSignal
                if (_dex >= maxVaue)
                {
                    //Debug.Log("新数据不再显示区域不需要重构" + _dex + " m_InitialItemCount=" + m_InitialItemCount);
                    SavaDataSource(sourceData.Count);
                    return;
                }     //新数据不再显示区域不需要重构
                ReBuildView(sourceData.Count, true, true);
                #endregion
                #endregion
                break;

            case CollectionEvent.DeleteSignal:
                #region DeleteSignal
                if (m_LayoutState != LayoutState.Idle)
                {
                    Scroll_ForceStopScroll();
                    DataModelChangeSignal <T>(collEvent, newData, _dex, _data, sourceData);
                    return;
                }
                if (_dex > maxVaue)
                {
                    //    Debug.Log("新数据不再显示区域不需要重构" + _dex + " m_InitialItemCount=" + m_InitialItemCount);
                    Reset_ClearData(true, true, false);      //重构数据源
                    SavaDataSource(sourceData.Count);
                    return;
                }     //新数据不再显示区域不需要重构
                ReBuildView(sourceData.Count, true, true);
                #endregion
                break;

            case CollectionEvent.Update:
                BaseLayoutButton button = GetItemBaseLayoutButtonComponent(_dex);
                if (button == null)
                {
                    Debug.LogError("Update Fail Miss " + _dex);
                    return;
                }
                if (button.gameObject.activeSelf)
                {
                    button.UpdateData(collEvent, newData);
                    return;
                }

                #region 旧的处理方式


                //#region Horizontal
                //if (m_HorizontalLayout)
                //{
                //    for (int row = 0; row < RowNumber; ++row)
                //    {
                //        for (int _column = 0; _column < ColumnNumber + m_ScrollSpeed; ++_column)
                //        {
                //            item = m_ListPanelRectTrans.Getchild_Ex(row * (ColumnNumber + m_ScrollSpeed) + _column);
                //            BaseLayoutButton button = GetItemBaseLayoutButtonComponent(item);
                //            if (button == null)
                //            {
                //                Debug.LogError("Miss " + _dex);
                //                continue;
                //            }

                //            if (button.m_DataIndex == _dex && item.gameObject.activeSelf)
                //            {
                //                button.UpdateData(collEvent, newData);
                //                //     Debug.Log(_column + "更新数据 " + item.gameObject.name);
                //                return;
                //            }
                //        }
                //    }
                //    return;
                //}
                //#endregion

                //#region Vertical
                //for (int _column = 0; _column < ColumnNumber; ++_column)
                //{
                //    for (int row = 0; row < RowNumber; ++row)
                //    {
                //        item = m_ListPanelRectTrans.Getchild_Ex(_column * (RowNumber + m_ScrollSpeed) + row);
                //        BaseLayoutButton button = GetItemBaseLayoutButtonComponent(item);
                //        if (button == null)
                //        {
                //            Debug.LogError("Miss " + _dex);
                //            continue;
                //        }

                //        if (button.m_DataIndex == _dex && item.gameObject.activeSelf)
                //        {
                //            //   Debug.Log(_column + "更新数据 " + item.gameObject.name);
                //            button.UpdateData(collEvent, newData);
                //            return;
                //        }
                //    }
                //}
                //#endregion
                #endregion

                break;
            }
        }
        public async Task <List <CollectionEvent> > LoadEventsAsync(List <Town> towns, CancellationToken cancellationToken)
        {
            var events         = new List <CollectionEvent>();
            var streetEvents   = new List <CollectionEvent>();
            var berlinTimeZone = TZConvert.GetTimeZoneInfo("Europe/Berlin");

#if DEBUG
            var index = 1;
#endif

            foreach (var town in towns)
            {
                if (town.Streets == null)
                {
                    continue;
                }

#if DEBUG
                this.logger.LogDebug($"Scraping event {index}");
#endif

                foreach (var street in town.Streets)
                {
                    if (street.Categories == null)
                    {
                        continue;
                    }

                    foreach (var year in street.AvailableYears)
                    {
                        cancellationToken.ThrowIfCancellationRequested();

                        var icalText = await this.documentLoader.LoadEventsIcalTextAsync(town.Id, street.Id, year, cancellationToken).ConfigureAwait(false);

                        var calendar = Ical.Net.Calendar.Load(icalText);

                        foreach (var calEvent in calendar.Events)
                        {
    #if DEBUG
                            index++;
    #endif
                            if (streetEvents.Any(e => e.Id == calEvent.Uid))
                            {
                                // Some ics files contain duplicate uids
                                continue;
                            }

                            var category = street.Categories.First(c => calEvent.Summary.Contains(c.Name, StringComparison.InvariantCulture));

                            // iCal file does not specify timezone. So we have to convert from Berlin to UTC manually.
                            var start    = calEvent.DtStart.AsUtc;
                            var diff     = berlinTimeZone.GetUtcOffset(start) - TimeZoneInfo.Local.GetUtcOffset(start);
                            var startUtc = start - diff;

                            var collectionEvent = new CollectionEvent
                            {
                                Id       = calEvent.Uid,
                                TownId   = town.Id,
                                StreetId = street.Id,
                                Category = category,
                                Start    = startUtc,
                                Stamp    = calEvent.DtStamp.AsUtc,
                            };

                            streetEvents.Add(collectionEvent);
                        }

                        events.AddRange(streetEvents);
                        streetEvents.Clear();

                        await this.DelayBeforeNextRequest().ConfigureAwait(false);
                    }
                }
            }

            return(events);
        }
Exemplo n.º 32
0
 //collection event that's the key
 private void OnCollectionEvent(CollectionEvent evt)
 {
     Debug.Log("we collect something!");
 }
Exemplo n.º 33
0
 //这是要传的Action事件
 private void OnCollectionEvent(CollectionEvent evt)
 {
     Debug.Log("collect something!");
     Destroy(evt.Collectable.gameObject);
 }