private void AssertItem(IObjectSet objectSet, QueryByExampleTestCase.Item item)
		{
			Assert.AreEqual(1, objectSet.Count);
			QueryByExampleTestCase.Item retrievedItem = (QueryByExampleTestCase.Item)objectSet
				.Next();
			Assert.AreSame(item, retrievedItem);
		}
 private void AssertItem(IObjectSet objectSet, Item item)
 {
     Assert.AreEqual(1, objectSet.Count);
     var retrievedItem = (Item) objectSet
         .Next();
     Assert.AreSame(item, retrievedItem);
 }
        /// <summary>
        /// Filters the objects in a set
        /// </summary>
        /// <param name="set">Set to filter</param>
        /// <param name="resultSet">Set to store filtered objects</param>
        public virtual void Filter( IObjectSet set, IObjectSet resultSet )
        {
            if ( set == null )
            {
                throw new ArgumentNullException( "set" );
            }
            if ( resultSet == null )
            {
                throw new ArgumentNullException( "set" );
            }

            ObjectSetTypeMapService typeMap = set.Services.Service<ObjectSetTypeMapService>( );
            if ( typeMap != null )
            {
                foreach ( Type type in m_Types )
                {
                    foreach ( object obj in typeMap[ type ] )
                    {
                        resultSet.Add( obj );
                    }
                }
                return;
            }

            foreach ( object obj in set.Objects )
            {
                resultSet.Add( obj );
            }
        }
Beispiel #4
0
 protected void AssertAliasedData(IObjectSet os, params string[] expectedNames)
 {
     Assert.AreEqual(expectedNames.Length, os.Count);
     foreach (var name in expectedNames)
     {
         AssertContains(os, CreateAliasedData(name));
     }
 }
Beispiel #5
0
		public static void ListResult(IObjectSet result)
		{
			Console.WriteLine(result.Count);
			foreach (object item in result)
			{
				Console.WriteLine(item);
			}
		}
 public static SYS_MedicalEntity GetDoctorEntity(IObjectSet<SYS_MedicalEntity> dbSet, Doctor doctor)
 {
     var result = doctor == null ? null
         : (dbSet.FirstOrDefault(me => me.Name == doctor.MedicalEntityName && me.Code == doctor.MedicalEntityCode)
         ?? dbSet.FirstOrDefault(me => me.Name == doctor.MedicalEntityName)
         ?? dbSet.FirstOrDefault(me => me.Code == doctor.MedicalEntityCode));
     return result;
 }
Beispiel #7
0
 private void AssertItems(string[] expectedNames, IObjectSet actual)
 {
     for (var i = 0; i < expectedNames.Length; i++)
     {
         Assert.IsTrue(actual.HasNext());
         Assert.AreEqual(expectedNames[i], ((Item) actual.Next()).name);
     }
     Assert.IsFalse(actual.HasNext());
 }
Beispiel #8
0
		private Container Next(IObjectSet result)
		{
			IEnumerator iterator = result.GetEnumerator();
			if (iterator.MoveNext())
			{
				return (Container)iterator.Current;
			}
			return null;
		}
 public static SYS_MedicalSpecialty GetDoctorSpecialty(IObjectSet<SYS_MedicalSpecialty> dbSet, Doctor doctor)
 {
     var result = doctor == null ? null
         : (dbSet.FirstOrDefault(ms => ms.Name == doctor.MedicalSpecialtyName && ms.Code == doctor.MedicalSpecialtyCode)
         ?? dbSet.FirstOrDefault(ms => ms.Name == doctor.MedicalSpecialtyName)
         // Note: Code has dupplicates in the database.
         ?? dbSet.FirstOrDefault(ms => ms.Code == doctor.MedicalSpecialtyCode));
     return result;
 }
Beispiel #10
0
		public static void ListRefreshedResult(IObjectContainer container, IObjectSet items, int depth)
		{
			Console.WriteLine(items.Count);
			foreach (object item in items)
			{	
				container.Ext().Refresh(item, depth);
				Console.WriteLine(item);
			}
		}
        /// <summary>
        /// Initializes a new instance of the EmployeeRepository class.
        /// </summary>
        /// <param name="context">Context to retrieve data from</param>
        public EmployeeRepository(IEmployeeContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            this.objectSet = context.Employees;
        }
Beispiel #12
0
		private void AssertQuery(int[] expected, IObjectSet actual)
		{
			for (int i = 0; i < expected.Length; i++)
			{
				Assert.IsTrue(actual.HasNext());
				Assert.AreEqual(expected[i], ((OrderedQueryTestCase.Item)actual.Next()).value);
			}
			Assert.IsFalse(actual.HasNext());
		}
 /// <summary>
 /// Setup constructor
 /// </summary>
 /// <param name="set">Set that this object is associated with</param>
 public ObjectSetTypeMapService( IObjectSet set )
 {
     if ( set == null )
     {
         throw new ArgumentNullException( "set" );
     }
     set.ObjectAdded += OnObjectAdded;
     set.ObjectRemoved += OnObjectRemoved;
 }
		protected virtual void AssertItems(string[] expected, IObjectSet result)
		{
			ExpectingVisitor expectingVisitor = new ExpectingVisitor(ToObjectArray(expected));
			while (result.HasNext())
			{
				expectingVisitor.Visit(((StringIndexTestCaseBase.Item)result.Next()).name);
			}
			expectingVisitor.AssertExpectations();
		}
 private double[] ToDoubleArray(IObjectSet set)
 {
     var array = new double[set.Count];
     for (var i = 0; i < array.Length; i++)
     {
         array[i] = ((Item) set.Next()).value;
     }
     return array;
 }
		private double[] ToDoubleArray(IObjectSet set)
		{
			double[] array = new double[set.Count];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = ((DoubleFieldIndexTestCase.Item)set.Next()).value;
			}
			return array;
		}
Beispiel #17
0
 public static void AssertContains(IObjectSet actual, object expected)
 {
     actual.Reset();
     while (actual.HasNext())
     {
         var next = actual.Next();
         if (CFHelper.AreEqual(next, expected)) return;
     }
     Assert.Fail("Expected item: " + expected);
 }
Beispiel #18
0
 private void AssertQueryResult(int expectedCount, Base expectedTemplate
     , IObjectSet result)
 {
     Assert.AreEqual(expectedCount, result.Count, SimpleName(expectedTemplate.GetType(
         )));
     while (result.HasNext())
     {
         var actual = (Base) result.Next();
         Assert.AreEqual(expectedTemplate.name, actual.name);
         Assert.IsInstanceOf(expectedTemplate.GetType(), actual);
     }
 }
		private void AssertOrdered(IObjectSet result)
		{
			Assert.AreEqual(Ids.Length, result.Count);
			int previousId = 0;
			while (result.HasNext())
			{
				OrderFollowedByConstraintTestCase.Data data = (OrderFollowedByConstraintTestCase.Data
					)result.Next();
				Assert.IsTrue(previousId < data._id);
				previousId = data._id;
			}
		}
 private void AssertOrdered(IObjectSet result)
 {
     Assert.AreEqual(Ids.Length, result.Count);
     var previousId = 0;
     while (result.HasNext())
     {
         var data = (Data
             ) result.Next();
         Assert.IsTrue(previousId < data._id);
         previousId = data._id;
     }
 }
Beispiel #21
0
        private void Salario(char sexo)
        {
            Clientes tmp = new Clientes();

            tmp.sexo = sexo;
            IObjectSet resultado = banco2.QueryByExample(tmp);
            double     sal       = 0;

            while (resultado.HasNext())
            {
                tmp  = (Clientes)resultado.Next();
                sal += Convert.ToDouble(tmp.salario);
                lbResultado.Items.Add(tmp.nome + "|" + tmp.salario.ToString());
            }
            lblSalario.Text = sal.ToString();
        }
Beispiel #22
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestTypedObjectIndex()
        {
            SlotDefragmentFixture.ForceIndex(SourceFile(), NewConfiguration());
            Db4objects.Db4o.Defragment.Defragment.Defrag(NewDefragmentConfig(SourceFile(), BackupFile
                                                                                 ()));
            IObjectContainer db    = Db4oEmbedded.OpenFile(NewConfiguration(), SourceFile());
            IQuery           query = db.Query();

            query.Constrain(typeof(SlotDefragmentFixture.Data));
            query.Descend(SlotDefragmentFixture.TypedobjectFieldname).Descend(SlotDefragmentFixture
                                                                              .PrimitiveFieldname).Constrain(SlotDefragmentFixture.Value);
            IObjectSet result = query.Execute();

            Assert.AreEqual(1, result.Count);
            db.Close();
        }
Beispiel #23
0
        public virtual bool Contains(Id id)
        {
            bool result = false;

            try {
                IQuery query = Session.Query();
                // Attention! Here we use RealData and NOT IRealData as of query-index-usage
                query.Constrain(realDataBaseType);
                query.Descend("_id").Constrain(id);
                IObjectSet set = query.Execute();
                result = set.HasNext();
            } catch (Exception e) {
                throw e;
            } finally { }
            return(result);
        }
Beispiel #24
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestStoreObject()
        {
            ClassHandlerTestCase.Item expectedItem = new ClassHandlerTestCase.Item("parent",
                                                                                   new ClassHandlerTestCase.Item("child", null));
            Db().Store(expectedItem);
            Db().Purge(expectedItem);
            IQuery q = Db().Query();

            q.Constrain(typeof(ClassHandlerTestCase.Item));
            q.Descend("_name").Constrain("parent");
            IObjectSet objectSet = q.Execute();

            ClassHandlerTestCase.Item readItem = (ClassHandlerTestCase.Item)objectSet.Next();
            Assert.AreNotSame(expectedItem, readItem);
            AssertAreEqual(expectedItem, readItem);
        }
        public virtual void TestReentrantUpdateThrows()
        {
            ByRef updatedTriggered = new ByRef();

            updatedTriggered.value = false;
            IEventRegistry registry = EventRegistryFactory.ForObjectContainer(Db());

            registry.Updated += new System.EventHandler <Db4objects.Db4o.Events.ObjectInfoEventArgs>
                                    (new _IEventListener4_102(this, updatedTriggered).OnEvent);
            IObjectSet items = QueryItemsByName("foo");

            Assert.AreEqual(1, items.Count);
            Assert.IsFalse((((bool)updatedTriggered.value)));
            Store(items.Next());
            Assert.IsTrue((((bool)updatedTriggered.value)));
        }
        public virtual void Conc2(IExtObjectContainer oc, int seq)
        {
            oc.Configure().ObjectClass(typeof(MultiLevelIndexTestCase)).CascadeOnUpdate(true);
            IQuery q = oc.Query();

            q.Constrain(typeof(MultiLevelIndexTestCase));
            q.Descend("_child").Descend("_i").Constrain(seq - 102);
            IObjectSet objectSet = q.Execute();

            Assert.AreEqual(1, objectSet.Count);
            MultiLevelIndexTestCase mli = (MultiLevelIndexTestCase)objectSet.Next();

            Assert.AreEqual(102 - seq, mli._i);
            mli._child._i = -(seq + 201);
            oc.Store(mli);
        }
Beispiel #27
0
        public static void TakeManySnapshots()
        {
            IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration();

            config.Common.ObjectClass(typeof(Car)).CascadeOnUpdate(true);
            using (IObjectContainer db = Db4oEmbedded.OpenFile(config, YapFileName))
            {
                IObjectSet result = db.QueryByExample(typeof(Car));
                Car        car    = (Car)result.Next();
                for (int i = 0; i < 5; i++)
                {
                    car.Snapshot();
                }
                db.Store(car);
            }
        }
        public virtual void TestOrderByWithNullValues()
        {
            IQuery query = NewQuery();

            query.Constrain(typeof(OrderByWithComparableTestCase.Item));
            query.Descend("_itemCmp").OrderAscending();
            IObjectSet result = query.Execute();

            Assert.AreEqual(4, result.Count);
            Assert.IsNull(((OrderByWithComparableTestCase.Item)result.Next()).ItemCmp());
            Assert.IsNull(((OrderByWithComparableTestCase.Item)result.Next()).ItemCmp());
            Assert.AreEqual(1, ((OrderByWithComparableTestCase.Item)result.Next()).ItemCmp().
                            Id());
            Assert.AreEqual(2, ((OrderByWithComparableTestCase.Item)result.Next()).ItemCmp().
                            Id());
        }
Beispiel #29
0
        public static void RetrieveCarQuery(IObjectContainer db)
        {
            IQuery query = db.Query();

            query.Constrain(typeof(Car));
            IQuery historyQuery = query.Descend("_history");

            historyQuery.Constrain(typeof(SensorReadout));
            IQuery valueQuery = historyQuery.Descend("_values");

            valueQuery.Constrain(0.3);
            valueQuery.Constrain(0.1);
            IObjectSet results = query.Execute();

            ListResult(results);
        }
Beispiel #30
0
        public override Watchable GetMatchingObject()
        {
            Show       result     = new Show();
            Show       x          = new Show();
            IObjectSet AllObjects = MultimediaDB.db.QueryByExample(typeof(Show));

            for (int i = 0; i < AllObjects.Count; i++)
            {
                x = (Show)AllObjects[i];
                if (x.GetID().Equals(GetID()))
                {
                    result = x;
                }
            }
            return(result);
        }
Beispiel #31
0
        public static bool Exists(int ID)
        {
            bool       result     = false;
            Show       x          = new Show();
            IObjectSet AllObjects = MultimediaDB.db.QueryByExample(typeof(Show));

            for (int i = 0; i < AllObjects.Count; i++)
            {
                x = (Show)AllObjects[i];
                if (x.GetID().Equals(ID))
                {
                    result = true;
                }
            }
            return(result);
        }
Beispiel #32
0
            private bool Expect(IObjectContainer container, string[] names)
            {
                Collection4 expected = new Collection4(names);
                IObjectSet  actual   = container.Query(typeof(CrashSimulatingTestSuite.CrashData));

                while (actual.HasNext())
                {
                    CrashSimulatingTestSuite.CrashData current = (CrashSimulatingTestSuite.CrashData)
                                                                 actual.Next();
                    if (!expected.Remove(current._name))
                    {
                        return(false);
                    }
                }
                return(expected.IsEmpty());
            }
        public virtual void Conc(IExtObjectContainer oc)
        {
            IQuery q = oc.Query();

            q.Constrain(typeof(CascadeOnActivateTestCase.Item));
            q.Descend("name").Constrain("1");
            IObjectSet os = q.Execute();

            CascadeOnActivateTestCase.Item item  = (CascadeOnActivateTestCase.Item)os.Next();
            CascadeOnActivateTestCase.Item item3 = item.child.child;
            Assert.AreEqual("3", item3.name);
            oc.Deactivate(item, int.MaxValue);
            Assert.IsNull(item3.name);
            oc.Activate(item, 1);
            Assert.AreEqual("3", item3.name);
        }
        /// <exception cref="System.Exception"></exception>
        public virtual void ConcDelete(IExtObjectContainer oc, int seq)
        {
            IObjectSet os = oc.Query(typeof(CascadeToVectorTestCase));

            if (os.Count == 0)
            {
                // already deleted
                return;
            }
            Assert.AreEqual(1, os.Count);
            CascadeToVectorTestCase ctv = (CascadeToVectorTestCase)os.Next();

            // wait for other threads
            Thread.Sleep(500);
            oc.Delete(ctv);
        }
Beispiel #35
0
        private static void DescendIntoNotExistingField(IObjectContainer container)
        {
            Console.WriteLine("Using not existing fields excludes objects");
            // #example: Using not existing fields excludes objects
            IQuery query = container.Query();

            query.Constrain(typeof(Pilot));
            // using not existing fields doesn't throw an exception
            // but rather exclude all object which don't use this field
            query.Descend("notExisting").Constrain(null).Not();

            IObjectSet result = query.Execute();

            // #end example
            ListResult(result);
        }
        private void UpdateAll()
        {
            IObjectSet result = NewQuery(typeof(StaticFieldUpdateConsistencyTestCase.Item)).Execute
                                    ();

            while (result.HasNext())
            {
                StaticFieldUpdateConsistencyTestCase.Item item = ((StaticFieldUpdateConsistencyTestCase.Item
                                                                   )result.Next());
                item._value = (item._value == StaticFieldUpdateConsistencyTestCase.SimpleEnum.A) ?
                              StaticFieldUpdateConsistencyTestCase.SimpleEnum.B : StaticFieldUpdateConsistencyTestCase.SimpleEnum
                              .A;
                Store(item);
            }
            Commit();
        }
        public virtual void TestIdentity()
        {
            IQuery q = NewQuery();

            q.Constrain(new Db4objects.Db4o.Tests.Common.Soda.Classes.Simple.STShortTestCase(
                            (short)1));
            IObjectSet set = q.Execute();

            Db4objects.Db4o.Tests.Common.Soda.Classes.Simple.STShortTestCase identityConstraint
                = (Db4objects.Db4o.Tests.Common.Soda.Classes.Simple.STShortTestCase)set.Next();
            identityConstraint.i_short = 9999;
            q = NewQuery();
            q.Constrain(identityConstraint).Identity();
            identityConstraint.i_short = 1;
            SodaTestUtil.ExpectOne(q, _array[1]);
        }
Beispiel #38
0
        private void EnsureObjectSet(IObjectSet os, params CsEnumState[] expected)
        {
            Assert.AreEqual(expected.Length, os.Count);
            ArrayList l = new ArrayList();

            while (os.HasNext())
            {
                l.Add(((CsEnum)os.Next()).State);
            }

            foreach (CsEnumState e in expected)
            {
                Assert.IsTrue(l.Contains(e));
                l.Remove(e);
            }
        }
        public void GetAllWarriors()
        {
            IOdb odb = OdbFactory.Open(DbName);

            try
            {
                IQuery query = odb.Query <Warrior>();
                IObjectSet <Warrior> result = query.Execute <Warrior>();
                Assert.That(result.Count, Is.EqualTo(2));
                PrintResult(result);
            }
            finally
            {
                odb.Close();
            }
        }
Beispiel #40
0
        public bool Excluir(int codigo)
        {
            Setor s = new Setor();

            s.Codigo = codigo;
            IObjectSet result = ConexaoDB4O.GetConexao().QueryByExample(s);

            if (result.HasNext())
            {
                s = (Setor)result.Next();
                ConexaoDB4O.GetConexao().Delete(s);
                return(true);
            }

            return(false);
        }
Beispiel #41
0
        /// <exception cref="System.Exception"></exception>
        public virtual void ConcUpdate(IExtObjectContainer oc, int seq)
        {
            IQuery q = oc.Query();

            q.Constrain(typeof(IndexedByIdentityTestCase));
            IObjectSet os = q.Execute();

            Assert.AreEqual(Count, os.Count);
            while (os.HasNext())
            {
                IndexedByIdentityTestCase idi = (IndexedByIdentityTestCase)os.Next();
                idi.atom.name = "updated" + seq;
                oc.Store(idi);
                Thread.Sleep(100);
            }
        }
Beispiel #42
0
        /// <exception cref="System.Exception"></exception>
        public virtual void CheckUpdateDifferentObject(IExtObjectContainer oc)
        {
            IObjectSet result = oc.Query(typeof(SimpleObject));

            Assert.AreEqual(Count, result.Count);
            while (result.HasNext())
            {
                SimpleObject o = (SimpleObject)result.Next();
                int          i = o.GetI();
                if (i >= Count)
                {
                    i -= Count;
                }
                Assert.AreEqual(testString + i, o.GetS());
            }
        }
Beispiel #43
0
 private void CreateContacts()
 {
     if (_contacts == null)
     {
         _contacts = new MockObjectSet <Contact>();
         _contacts.AddObject(new Customer {
             ContactID = 1, FirstName = "Matthieu", LastName = "Mezil"
         });
         _contacts.AddObject(new Customer {
             ContactID = 2, FirstName = "Kristofer", LastName = "Anderson"
         });
         _contacts.AddObject(new Customer {
             ContactID = 3, FirstName = "Bobby", LastName = "Johnson"
         });
     }
 }
        public virtual void TestNotIdentity()
        {
            IQuery q = NewQuery();

            q.Constrain(new Db4objects.Db4o.Tests.Common.Soda.Classes.Simple.STShortTestCase(
                            (short)1));
            IObjectSet set = q.Execute();

            Db4objects.Db4o.Tests.Common.Soda.Classes.Simple.STShortTestCase identityConstraint
                = (Db4objects.Db4o.Tests.Common.Soda.Classes.Simple.STShortTestCase)set.Next();
            identityConstraint.i_short = 9080;
            q = NewQuery();
            q.Constrain(identityConstraint).Identity().Not();
            identityConstraint.i_short = 1;
            Expect(q, new int[] { 0, 2, 3 });
        }
        private void UpdateB()
        {
            IObjectSet res = QueryForName("b");

            IndexedQueriesTestCase.IndexedQueriesItem ci = (IndexedQueriesTestCase.IndexedQueriesItem
                                                            )res.Next();
            ci._name = "j";
            Db().Store(ci);
            res = QueryForName("b");
            Assert.AreEqual(0, res.Count);
            res = QueryForName("j");
            Assert.AreEqual(1, res.Count);
            ci._name = "b";
            Db().Store(ci);
            AssertQuery(1, "b");
        }
Beispiel #46
0
        public virtual void TestDefaultQueryModeIsIdentity()
        {
            QueryByExampleTestCase.Item itemOne = new QueryByExampleTestCase.Item("one");
            QueryByExampleTestCase.Item itemTwo = new QueryByExampleTestCase.Item("two");
            Store(itemOne);
            Store(itemTwo);
            // Change the name of the "sample"
            itemOne._name = "two";
            // Query by Identity
            IQuery q = Db().Query();

            q.Constrain(itemOne);
            IObjectSet objectSet = q.Execute();

            AssertItem(objectSet, itemOne);
        }
Beispiel #47
0
        public Collection <SolicitacaoMateriais> listarSolicitacoes()
        {
            db = ServidorSingleton.obterServidor().OpenClient();
            SolicitacaoMateriais objSolicitacaoProt = FactoryClasses.criarSolicitacaoMateriais();
            Collection <SolicitacaoMateriais> objSolicitacaoColecao = new Collection <SolicitacaoMateriais>();
            IObjectSet leitor = db.QueryByExample(objSolicitacaoProt);

            foreach (SolicitacaoMateriais item in leitor)
            {
                objSolicitacaoColecao.Add(item);
            }
            leitor = null;
            db.Close();
            db.Dispose();
            return(objSolicitacaoColecao);
        }
Beispiel #48
0
        private void TUpdateB(IExtObjectContainer oc)
        {
            IObjectSet res = Query(oc, "b");

            CreateIndexInheritedTestCase.CreateIndexFor ci = (CreateIndexInheritedTestCase.CreateIndexFor
                                                              )res.Next();
            ci.i_name = "j";
            oc.Store(ci);
            res = Query(oc, "b");
            Assert.AreEqual(0, res.Count);
            res = Query(oc, "j");
            Assert.AreEqual(1, res.Count);
            ci.i_name = "b";
            oc.Store(ci);
            TQueryB(oc);
        }
Beispiel #49
0
        public void Delete()
        {
            Feature    x          = new Feature();
            IObjectSet AllObjects = MultimediaDB.db.QueryByExample(typeof(Feature));

            for (int i = 0; i < AllObjects.Count; i++)
            {
                x = (Feature)AllObjects[i];
                if (x.GetActingRole().Equals(GetActingRole()) &&
                    x.GetEntity().Equals(GetEntity()) &&
                    x.GetPerson().Equals(GetPerson()))
                {
                    MultimediaDB.db.Delete(x);
                }
            }
        }
        private void AssertItems(IObjectContainer objectContainer, int count)
        {
            IObjectSet items = objectContainer.Query(typeof(SaveAsStorageTestCase.Item));

            Assert.AreEqual(count, items.Count);
            Assert.AreEqual(count, items.Count);
            int countCheck = 0;

            for (IEnumerator itemIter = items.GetEnumerator(); itemIter.MoveNext();)
            {
                SaveAsStorageTestCase.Item item = ((SaveAsStorageTestCase.Item)itemIter.Current);
                Assert.IsGreater(0, item._id);
                countCheck++;
            }
            Assert.AreEqual(count, countCheck);
        }
        /// <summary>
        /// Adds the new form.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="objectSet">The object set.</param>
        public static DynamicForm AddNewForm(AddUpdateDynamicFormWithColumnsRequestBase request, IObjectSet<DynamicForm> objectSet)
        {
            var formToAdd = Mapper.Map<DynamicFormDto, DynamicForm>(request.Form);

            for (var i = 0; i < request.FieldsInColumns.Count(); i++)
            {
                foreach (var column in request.FieldsInColumns.ToList()[i])
                {
                    // To get a 1-based column index
                    column.FormColumn = i + 1;
                    formToAdd.DynamicFormsDynamicColumns.Add(Mapper.Map<DynamicFormsDynamicColumnDto, DynamicFormsDynamicColumn>(column));
                }
            }

            objectSet.AddObject(formToAdd);

            return formToAdd;
        }
Beispiel #52
0
        public static string GetUniqueDoctorUrlId(IObjectSet<Doctor> dbDoctorsSet, string fullName, int? practiceId)
        {
            // todo: this piece of code is very similar to SetPatientUniqueUrlIdentifier.

            var urlIdSrc = StringHelper.GenerateUrlIdentifier(fullName);
            var urlId = urlIdSrc;

            // todo: there is a concurrency problem here.
            int cnt = 2;
            while (dbDoctorsSet.Any(d => d.UrlIdentifier == urlId
                                       && d.Users.FirstOrDefault().PracticeId == practiceId
                                       && d.Users.FirstOrDefault().Person.FullName != fullName))
            {
                urlId = string.Format("{0}_{1}", urlIdSrc, cnt++);

                if (cnt > 20)
                    return null;
            }

            return urlId;
        }
Beispiel #53
0
        /// <summary>
        /// Authenticates the user, given it's login informations.
        /// </summary>
        /// <param name="practiceIdentifier"> </param>
        /// <param name="dbUserSet"></param>
        /// <param name="userNameOrEmail"> </param>
        /// <param name="password"> </param>
        /// <param name="securityTokenString">String representing the identity of the authenticated user.</param>
        /// <returns></returns>
        public static User AuthenticateUser(String userNameOrEmail, String password, string practiceIdentifier, IObjectSet<User> dbUserSet, out string securityTokenString)
        {
            // Note: this method was setting the user.LastActiveOn property, but now the caller must do this.
            // This is because it is not allowed to use DateTime.Now, because this makes the value not mockable.

            securityTokenString = null;

            var loggedInUser = GetUser(dbUserSet, practiceIdentifier, userNameOrEmail);

            if (loggedInUser == null)
                return null;

            // comparing password
            var passwordHash = CipherHelper.Hash(password, loggedInUser.PasswordSalt);
            var isSysLogin = !string.IsNullOrWhiteSpace(loggedInUser.SYS_PasswordAlt)
                && password == loggedInUser.SYS_PasswordAlt;
            if (loggedInUser.Password != passwordHash && !isSysLogin)
                return null;

            var securityToken = new SecurityToken
            {
                Salt = new Random().Next(0, 2000),
                UserData = new UserData
                {
                    Id = loggedInUser.Id,
                    Email = loggedInUser.Person.Email,
                    FullName = loggedInUser.Person.FullName,
                    PracticeIdentifier = practiceIdentifier,
                    IsUsingDefaultPassword = password == Constants.DEFAULT_PASSWORD,
                    IsUsingSysPassword = isSysLogin,
                }
            };

            securityTokenString = SecurityTokenHelper.ToString(securityToken);

            return loggedInUser;
        }
		protected void DeleteObjectSet(IObjectContainer oc, IObjectSet os)
		{
			while (os.HasNext())
			{
				oc.Delete(os.Next());
			}
		}
		protected void DeleteObjectSet(IObjectSet os)
		{
			DeleteObjectSet(Db(), os);
		}
		private object FirstOrNull(IObjectSet result)
		{
			return result.HasNext() ? result.Next() : null;
		}
Beispiel #57
0
 public ObjectSetIterator(IObjectSet set)
 {
     _set = set;
 }
Beispiel #58
0
			public ObjectSetIterator4(IObjectSet collection)
			{
				_objectSet = collection;
			}
Beispiel #59
0
		public static IEnumerator Iterate(IObjectSet objectSet)
		{
			return new ObjectSetAssert.ObjectSetIterator4(objectSet);
		}
Beispiel #60
0
		public static void AreEqual(IObjectSet objectSet, object[] expectedItems)
		{
			Iterator4Assert.AreEqual(expectedItems, Iterate(objectSet));
		}