Example #1
0
                public IRestriction GetRestrictionForType(Type t)
                {
                    if (IsEnabled)
                    {
                        switch (this.Type)
                        {
                        case RestrictionType.Equals:
                            return(RestrictionFactory.Eq(t, property, Value));

                            break;

                        case RestrictionType.Like:
                            string search = (!string.IsNullOrEmpty(Value))? Value.Trim('%', ' '):"";
                            search = "%" + search + "%";

                            return(RestrictionFactory.Like(t, property, search));

                            break;

                        case RestrictionType.BetweenDates:
                            return(RestrictionFactory.Btw(t, property, StartTime, EndTime));

                            break;

                        default:
                            break;
                        }
                    }
                    return(null);
                }
Example #2
0
        public CollectionEvent getEventForIU(int iuID)
        {
            IdentificationUnit iu;

            try
            {
                IRestriction restrict = RestrictionFactory.Eq(typeof(IdentificationUnit), "_IdentificationUnitID", iuID);
                iu = con.Load <IdentificationUnit>(restrict);
            }
            catch (Exception)
            {
                return(null);
            }

            //SERIALIZER.ConnectOneToMany(iu, cs);
            //return this.getEventForSpecimen((int)iu.CollectionSpecimenID);
            if (iu != null)
            {
                return(iu.CollectionSpecimen.CollectionEvent);
            }
            else
            {
                return(null);
            }
        }
Example #3
0
        private SyncItem FetchSyncItem(Guid guid)
        {
            IRestriction r        = RestrictionFactory.Eq(typeof(SyncItem), "_SyncGuid", guid);
            SyncItem     siSource = (SyncItem)_syncSerializer.Connector.Load(typeof(SyncItem), r);

            return(siSource);
        }
Example #4
0
        private UserProfiles()
        {
            IRestriction restrict = RestrictionFactory.TypeRestriction(typeof(UserProfile));

            _userList            = con.LoadList <UserProfile>(restrict);
            this._currentProfile = SERIALIZER.CreateISerializableObject <UserProfile>();
        }
Example #5
0
            public IRestriction GetQueryRestriction()
            {
                IRestriction projectRestriction    = RestrictionFactory.Eq(typeof(CollectionProject), "_ProjectID", ConnectionsAccess.Profile.ProjectID);
                IRestriction selectionRestrictions = null;

                foreach (var restrictionSpecification in Restrictions)
                {
                    var currentRestriction = restrictionSpecification.GetRestrictionForType(ObjectType);
                    if (currentRestriction != null)
                    {
                        if (selectionRestrictions != null)
                        {
                            selectionRestrictions = RestrictionFactory.And().Add(selectionRestrictions).Add(currentRestriction);
                        }
                        else
                        {
                            selectionRestrictions = currentRestriction;
                        }
                    }
                }
                if (selectionRestrictions != null)
                {
                    return(RestrictionFactory.And().Add(projectRestriction).Add(selectionRestrictions));
                }
                else
                {
                    return(projectRestriction);
                }
            }
Example #6
0
        public T Next()
        {
            InitializeList();


            this._readerPosition++;

            if (this._readerPosition > this._keyList.Count - 1)
            {
                TryExtendEnd();
            }

            T ret = default(T);

            while (ret == null)
            {
                CsvPimaryKey key = this._keyList[this._readerPosition];
                IRestriction r   = RestrictionFactory.CsvKeyRestriction(typeof(T), key);

                ret = this._serializer.Connector.Load <T>(r);

                if (ret == null)
                {
                    _readerPosition++;
                }
            }

            return(ret);
        }
        public void Load(Type t, Serializer serializer)
        {
            IRestriction r = RestrictionFactory.TypeRestriction(t);
            IList <ISerializableObject> list = serializer.Connector.LoadList(t, r);

            addList(list);
        }
Example #8
0
        //Beim Iterieren über die EventSeries muss beachtet werden, dass
        //die EmptyEventSeries manuell zur Auswahl zugefügt werden muss.(noch nicht erledigt)
        private EventSeriess()
        {
            IRestriction restrict = RestrictionFactory.TypeRestriction(typeof(CollectionEventSeries));

            _ceIterator             = new DirectAccesIteratorImpl <CollectionEventSeries>();
            _ceIterator.Serializer  = SERIALIZER;
            _ceIterator.Restriction = restrict;
            this.Current            = _ceIterator.First();
        }
Example #9
0
        //internal CollectionEvents()
        //{
        //    IRestriction restrict = RestrictionFactory.TypeRestriction(typeof(CollectionEvent));
        //    _ceIterator = new DirectAccesIteratorImpl<CollectionEvent>();
        //    _ceIterator.Serializer = SERIALIZER;
        //    _ceIterator.Restriction = restrict;
        //    this.Current = _ceIterator.First();
        //}

        public CollectionEvents(int?seriesID)
        {
            IRestriction restrict = null;

            restrict                = RestrictionFactory.Eq(typeof(CollectionEvent), "_SeriesID", seriesID);
            _ceIterator             = new DirectAccesIteratorImpl <CollectionEvent>();
            _ceIterator.Serializer  = SERIALIZER;
            _ceIterator.Restriction = restrict;
            this.Current            = _ceIterator.First();
        }
Example #10
0
        private void buttonLoad_Click(object sender, RoutedEventArgs e)
        {
            IRestriction r = RestrictionFactory.TypeRestriction(typeof(CollectionEventLocalisation));
            IList <CollectionEventLocalisation> spec = mobSer.Connector.LoadList <CollectionEventLocalisation>(r);
            CollectionEventLocalisation         ce   = spec.First();
            Guid g = ce.Rowguid;

            r    = RestrictionFactory.Eq(typeof(CollectionEventLocalisation), "_guid", g);
            obj2 = repSer.Connector.Load <CollectionEventLocalisation>(r);
        }
Example #11
0
        private UserProfile createProfile()
        {
            UserProfile newProfile;
            UserProxy   proxy;
            int         i = 0;

            try
            {
                newProfile = ConnectionsAccess.MobileDB.CreateISerializableObject <UserProfile>();
                i++;
                //Zuerst korrespondierenden Userproxy holen
                IRestriction r = RestrictionFactory.Eq(typeof(UserProxy), "_LoginName", OptionsAccess.RepositoryOptions.LastUsername);
                //IRestriction r = RestrictionFactory.Eq(typeof(UserProxy), "_LoginName", @"TestEditor");
                proxy = ConnectionsAccess.RepositoryDB.Connector.Load <UserProxy>(r);
                i++;
                newProfile.LoginName = OptionsAccess.RepositoryOptions.LastUsername;
                //newProfile.LoginName = @"TestEditor";
                string agentName = null;
                i++;//3
                using (var conn = ConnectionsAccess.RepositoryDefinitions.CreateConnection())
                {
                    try
                    {
                        conn.Open();
                        i++;
                        var cmd = conn.CreateCommand();
                        cmd.CommandText = "SELECT [AgentName] FROM [" + OptionsAccess.RepositoryOptions.TaxonNamesInitialCatalog + "].[dbo].[IBFagents] WHERE [AgentURI] = '" + proxy.AgentURI + "'";
                        _Log.DebugFormat("Select AgentName Command: [{0}]", cmd.CommandText);
                        i++;//5
                        agentName = cmd.ExecuteScalar() as string;
                        _Log.DebugFormat("AgentName: [{0}]", agentName);
                        i++;
                    }
                    finally
                    {
                        conn.Close();
                        i++;//7
                    }
                }

                newProfile.CombinedNameCache = (!string.IsNullOrEmpty(agentName)) ? agentName : proxy.CombinedNameCache;
                i++;
                newProfile.HomeDB = OptionsAccess.RepositoryOptions.InitialCatalog;
                i++;//9
                newProfile.AgentURI = proxy.AgentURI;
                i++;
            }
            catch (Exception ex)
            {
                newProfile = null;

                _Log.ErrorFormat("Error Creating Profile: {0}", ex);
            }
            return(newProfile);
        }
Example #12
0
        public void Load(Type t)
        {
            IRestriction r = RestrictionFactory.TypeRestriction(t);

            IList <ISerializableObject> list = this._serializer.Connector.LoadList(t, r);

            foreach (ISerializableObject iso in list)
            {
                this._pool.AddISerializableObject(iso);
            }
        }
Example #13
0
        private ISerializableObject FetchObject(Serializer s, Guid guid)
        {
            FieldInfo     fi  = AttributeWorker.RowGuid(_synchronizedType);
            String        col = AttributeWorker.GetInstance(s.Target).GetColumnMapping(fi);
            StringBuilder tmp = new StringBuilder();

            tmp.Append(col).Append("='").Append(guid).Append("'");;
            IRestriction        res = RestrictionFactory.SqlRestriction(_synchronizedType, tmp.ToString());
            ISerializableObject iso = s.Connector.Load(_synchronizedType, res);

            return(iso);
        }
Example #14
0
        private void buttonIdentifications_Click(object sender, EventArgs e)
        {
            IRestriction r = RestrictionFactory.TypeRestriction(typeof(IdentificationUnit));
            IList <IdentificationUnit> units = mobileDBSerializer.Connector.LoadList <IdentificationUnit>(r);

            foreach (IdentificationUnit iu in units)
            {
                Identification id = iu.Identifications.First();
                id.TaxonomicName = iu.LastIdentificationCache;
                mobileDBSerializer.Connector.Save(id);
            }
            MessageBox.Show("Success");
        }
Example #15
0
            private IRestriction fromTextRestriction(TextRestriction res)
            {
                string value = res.Value ?? "";

                if (res.ExactMatch)
                {
                    return(RestrictionFactory.Eq(_configuredSearch.ObjectType, res.Property, value));
                }
                else
                {
                    return(RestrictionFactory.Like(_configuredSearch.ObjectType, res.Property, string.Format("%{0}%", value.Trim('%'))));
                }
            }
Example #16
0
        public UserProfile RetrieveUserProfile(int UserProfileID)
        {
            IRestriction restrict = RestrictionFactory.Eq(typeof(UserProfile), "_UserProfileID", UserProfileID);
            UserProfile  up       = null;

            try
            {
                up = con.Load <UserProfile>(restrict);
            }
            catch (Exception)
            {
                throw new UserProfileCorruptedException("User Profile for ID: " + UserProfileID + " couldn't be loaded.");
            }
            return(up);
        }
Example #17
0
        public List <ListViewItem> searchIUResults(Dictionary <String, String> searchStrings, bool strategyAND)
        {
            List <ListViewItem> items = new List <ListViewItem>();

            try
            {
                LogicalRestriction restrict = null;

                if (strategyAND)
                {
                    restrict = RestrictionFactory.And();
                }
                else
                {
                    restrict = RestrictionFactory.Or();
                }

                foreach (String key in searchStrings.Keys)
                {
                    if (key != null)
                    {
                        IRestriction r = RestrictionFactory.Like(typeof(IdentificationUnit), key, searchStrings[key]);
                        restrict.Add(r);
                    }
                }

                foreach (IdentificationUnit iu in con.LoadList <IdentificationUnit>(restrict))
                {
                    if (iu != null)
                    {
                        ListViewItem item = new ListViewItem();
                        item.Text = iu.IdentificationUnitID.ToString();
                        item.SubItems.Add(iu.LastIdentificationCache);
                        item.SubItems.Add(iu.TaxonomicGroup);
                        item.SubItems.Add(iu.UnitIdentifier);
                        item.Tag = iu.IdentificationUnitID;

                        items.Add(item);
                    }
                }
            }
            catch (Exception)
            {
                items.Clear();
            }

            return(items);
        }
Example #18
0
        //Problem: Wenn ncht alle Fremdschlüssel in registered Types liegen, werden hier Null-Werte eingatreagen.
        //Dies tritt auf, wenn nicht alle DataItems die beim Serialiszer registriert sind, synchronisiert werden sollen.
        public SyncPool CreateSyncPool()
        {
            SyncPool pool = new SyncPool(_serializer, _syncSerializer);

            foreach (Type t in _registeredTypes)
            {
                IRestriction r = RestrictionFactory.TypeRestriction(t);
                IList <ISerializableObject> list = _serializer.Connector.LoadList(t, r);
                foreach (ISerializableObject iso in list)
                {
                    pool.AddISerializableObject(iso);
                }
            }
            pool.Intialize();
            return(pool);
        }
Example #19
0
        public CollectionEvent getEvent(int eventID)
        {
            CollectionEvent ce;

            try
            {
                IRestriction restrict = RestrictionFactory.Eq(typeof(CollectionEvent), "_CollectionEventID", eventID);
                ce = con.Load <CollectionEvent>(restrict);
            }
            catch (Exception)
            {
                ce = null;
            }

            return(ce);
        }
        private void updateProfile()
        {
            _profile = null;
            if (Connections != null)
            {
                if (Settings != null && (_settings = Settings.getOptions()) != null)
                {
                    if ((_mobileSerializer = Connections.MobileDB) != null)
                    {
                        MessengerInstance.Send <StatusNotification>("Services_UserProfile_SearchingProfile");
                        //Prüfen ob ein UserProfile zum LoginNamen existiert.
                        IList <UserProfile> profiles = new List <UserProfile>();

                        IRestriction r = RestrictionFactory.Eq(typeof(UserProfile), "_LoginName", _settings.Username);
                        //IRestriction r = RestrictionFactory.Eq(typeof(UserProfile), "_LoginName", "TestEditor");
                        profiles = _mobileSerializer.Connector.LoadList <UserProfile>(r);

                        if (profiles.Count > 0)
                        {
                            _profile = profiles[0];
                        }
                        else
                        {
                            MessengerInstance.Send <StatusNotification>("Services_UserProfile_CreatingNew");
                            _profile = createProfile();
                        }

                        MessengerInstance.Send <StatusNotification>("Services_UserProfile_Loaded");
                        _operation.success();
                    }
                    else
                    {
                        _Log.Error("Mobile DB not connected");
                    }
                }
                else
                {
                    _Log.Error("Settings N/A");
                }
            }
            else
            {
                _Log.Error("Connections N/A");
            }

            _operation.failure("Services_UserProfile_Error_MissingConnectivitiy", "");
        }
Example #21
0
        public IList <ListViewItem> searchEventResults(Dictionary <String, String> searchStrings, bool strategyAND)
        {
            List <ListViewItem> items = new List <ListViewItem>();

            try
            {
                LogicalRestriction restrict = null;

                if (strategyAND)
                {
                    restrict = RestrictionFactory.And();
                }
                else
                {
                    restrict = RestrictionFactory.Or();
                }

                foreach (String key in searchStrings.Keys)
                {
                    if (key != null)
                    {
                        IRestriction r = RestrictionFactory.Like(typeof(CollectionEvent), key, searchStrings[key]);
                        restrict.Add(r);
                    }
                }

                foreach (CollectionEvent ce in con.LoadList <CollectionEvent>(restrict))
                {
                    if (ce != null)
                    {
                        ListViewItem item = new ListViewItem();
                        item.Text = ce.CollectionEventID.ToString();
                        item.SubItems.Add(ce.CollectorsEventNumber);
                        item.SubItems.Add(ce.CollectionDate.ToShortDateString());
                        item.Tag = ce.CollectionEventID;

                        items.Add(item);
                    }
                }
            }
            catch (Exception) {
                items.Clear();
            }

            return(items);
        }
Example #22
0
        public List <ListViewItem> searchSpecimenResults(Dictionary <String, String> searchStrings, bool strategyAND)
        {
            List <ListViewItem> items = new List <ListViewItem>();

            try
            {
                LogicalRestriction restrict = null;

                if (strategyAND)
                {
                    restrict = RestrictionFactory.And();
                }
                else
                {
                    restrict = RestrictionFactory.Or();
                }

                foreach (String key in searchStrings.Keys)
                {
                    if (key != null)
                    {
                        IRestriction r = RestrictionFactory.Like(typeof(CollectionSpecimen), key, searchStrings[key]);
                        restrict.Add(r);
                    }
                }

                foreach (CollectionSpecimen cs in con.LoadList <CollectionSpecimen>(restrict))
                {
                    if (cs != null)
                    {
                        ListViewItem item = new ListViewItem();
                        item.Text = cs.CollectionSpecimenID.ToString();
                        item.Tag  = cs.CollectionSpecimenID;

                        items.Add(item);
                    }
                }
            }
            catch (Exception)
            {
                items.Clear();
            }

            return(items);
        }
Example #23
0
        public int CountItems()
        {
            int position = -1;

            foreach (CsvPimaryKey key in this._keyList)
            {
                IRestriction r = RestrictionFactory.CsvKeyRestriction(typeof(T), key);

                T tmp = this._serializer.Connector.Load <T>(r);

                if (tmp != null)
                {
                    position++;
                }
            }

            return(position + 1);
        }
Example #24
0
            private IRestriction GetQueryRestriction()
            {
                IRestriction projectRestriction    = RestrictionFactory.Eq(typeof(CollectionProject), "_ProjectID", _currentProjectID);
                IRestriction selectionRestrictions = null;

                foreach (var restrictionSpecification in _configuredSearch.Restrictions)
                {
                    if (restrictionSpecification == null || !restrictionSpecification.IsEnabled)
                    {
                        continue;
                    }

                    IRestriction currRes = null;
                    if (restrictionSpecification is TextRestriction)
                    {
                        currRes = fromTextRestriction(restrictionSpecification as TextRestriction);
                    }
                    else if (restrictionSpecification is DateRangeRestriction)
                    {
                        currRes = fromDateRangeRestriction(restrictionSpecification as DateRangeRestriction);
                    }

                    if (currRes != null)
                    {
                        if (selectionRestrictions != null)
                        {
                            selectionRestrictions = RestrictionFactory.And().Add(selectionRestrictions).Add(currRes);
                        }
                        else
                        {
                            selectionRestrictions = currRes;
                        }
                    }
                }
                if (selectionRestrictions != null)
                {
                    return(RestrictionFactory.And().Add(projectRestriction).Add(selectionRestrictions));
                }
                else
                {
                    return(projectRestriction);
                }
            }
Example #25
0
        public T[] ToArray()
        {
            InitializeList();
            TryExtendEnd();

            List <T> tmpList = new List <T>();

            foreach (CsvPimaryKey key in this._keyList)
            {
                IRestriction r = RestrictionFactory.CsvKeyRestriction(typeof(T), key);

                T tmp = this._serializer.Connector.Load <T>(r);

                if (tmp != null)
                {
                    tmpList.Add(tmp);
                }
            }

            return(tmpList.ToArray());
        }
Example #26
0
        public bool Find(int id)
        {
            CollectionSpecimen cs;

            try
            {
                IRestriction restrict = RestrictionFactory.Eq(typeof(CollectionSpecimen), "_CollectionSpecimenID", id);
                cs = con.Load <CollectionSpecimen>(restrict);
            }
            catch (Exception)
            {
                return(false);
            }

            if (cs != null)
            {
                this.Current = cs;
                this._csIterator.SetIteratorTo(this._currentSpecimen);
                return(true);
            }
            return(false);
        }
Example #27
0
        public bool Find(int id)
        {
            try
            {
                IRestriction restrict = RestrictionFactory.Eq(typeof(CollectionEventSeries), "_SeriesID", id);
                this._currentSeries = con.Load <CollectionEventSeries>(restrict);

                if (this._currentSeries == null)
                {
                    return(false);
                }
                else
                {
                    this._ceIterator.SetIteratorTo(this._currentSeries);
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
Example #28
0
        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            IRestriction               rIds       = RestrictionFactory.TypeRestriction(typeof(Identification));
            IRestriction               rUnits     = RestrictionFactory.TypeRestriction(typeof(IdentificationUnit));
            IList <Identification>     idents_mob = mobileDBSerializer.Connector.LoadList <Identification>(rIds);
            IList <Identification>     idents_rep = new List <Identification>();
            IList <IdentificationUnit> units_mob  = mobileDBSerializer.Connector.LoadList <IdentificationUnit>(rUnits);
            IList <IdentificationUnit> units_rep  = new List <IdentificationUnit>();

            foreach (Identification mobi in idents_mob)
            {
                IRestriction   r       = RestrictionFactory.Eq(typeof(Identification), "_guid", mobi.Rowguid);
                Identification partner = repositorySerializer.Connector.Load <Identification>(r);
                if (partner == null)
                {
                    MessageBox.Show(mobi.Rowguid.ToString());
                }
                else
                {
                    if (mobi.IdentificationDate != partner.IdentificationDate)
                    {
                        idents_rep.Add(partner);
                    }
                }
            }
            //foreach (IdentificationUnit mobi in units_mob)
            //{

            //    IRestriction r = RestrictionFactory.Eq(typeof(IdentificationUnit), "_guid", mobi.Rowguid);
            //    IdentificationUnit partner = repositorySerializer.Connector.Load<IdentificationUnit>(r);
            //    if (partner == null)
            //        MessageBox.Show(mobi.Rowguid.ToString());
            //    else
            //    {
            //        units_rep.Add(partner);
            //    }
            //}
            MessageBox.Show("Success");
        }
Example #29
0
        public T Prev()
        {
            InitializeList();

            this._readerPosition--;

            T ret = default(T);

            while (ret == null)
            {
                CsvPimaryKey key = this._keyList[this._readerPosition];
                IRestriction r   = RestrictionFactory.CsvKeyRestriction(typeof(T), key);

                ret = this._serializer.Connector.Load <T>(r);

                if (ret == null)
                {
                    _readerPosition--;
                }
            }

            return(ret);
        }
Example #30
0
        public bool FindTopLevelIU(int id)
        {
            try
            {
                IRestriction r1       = RestrictionFactory.Eq(typeof(IdentificationUnit), "_IdentificationUnitID", id);
                IRestriction r2       = RestrictionFactory.Eq(typeof(IdentificationUnit), "_RelatedUnitID", null);
                IRestriction restrict = RestrictionFactory.And().Add(r1).Add(r2);
                this._currentIdentificationUnit = con.Load <IdentificationUnit>(restrict);

                if (this._currentIdentificationUnit == null)
                {
                    return(false);
                }
                else
                {
                    this._identificationUnitIterator.SetIteratorTo(this._currentIdentificationUnit);
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }