示例#1
0
        public void TestAtGetCollectionHenterDataProxies()
        {
            using (IMySqlDataProvider sut = CreateSut())
            {
                Assert.That(sut, Is.Not.Null);

                MySqlCommand queryCommand = new MySqlCommand("SELECT SystemNo,Title FROM Systems ORDER BY SystemNo")
                {
                    CommandType = CommandType.Text
                };
                IEnumerable <MyDataProxy> result = sut.GetCollection <MyDataProxy>(queryCommand);
                // ReSharper disable PossibleMultipleEnumeration
                Assert.That(result, Is.Not.Null);
                // ReSharper restore PossibleMultipleEnumeration

                // ReSharper disable PossibleMultipleEnumeration
                List <MyDataProxy> proxyCollection = result.ToList();
                // ReSharper restore PossibleMultipleEnumeration
                Assert.That(proxyCollection, Is.Not.Null);
                Assert.That(proxyCollection.Count, Is.GreaterThan(0));

                proxyCollection.ForEach(proxy =>
                {
                    Assert.That(proxy.MapDataIsCalled, Is.True);
                    Assert.That(proxy.MapRelationsIsCalled, Is.True);
                });
            }
        }
 /// <summary>
 /// Henter alle kalenderaftaler fra en given dato til et system under OSWEBDB.
 /// </summary>
 /// <param name="system">Unik identifikation af systemet under OSWEBDB.</param>
 /// <param name="fromDate">Datoen, hvorfra kalenderaftaler skal hentes.</param>
 /// <returns>Liste indeholdende kalenderaftaler til systemer.</returns>
 public IEnumerable <IAftale> AftaleGetAllBySystem(int system, DateTime fromDate)
 {
     try
     {
         MySqlCommand command = new CalenderCommandBuilder("SELECT ca.SystemNo,ca.CalId,ca.Date,ca.FromTime,ca.ToTime,ca.Properties,ca.Subject,ca.Note,s.Title AS SystemTitle,s.Properties AS SystemProperties FROM Calapps AS ca FORCE INDEX(IX_Calapps_SystemNo_Date) INNER JOIN Systems AS s ON s.SystemNo=ca.SystemNo WHERE ca.SystemNo=@systemNo AND ca.Date>=@date ORDER BY ca.Date DESC,ca.FromTime DESC,ca.ToTime DESC,ca.CalId DESC")
                                .AddSystemNoParameter(system)
                                .AddAppointmentDateParameter(fromDate)
                                .Build();
         return(_mySqlDataProvider.GetCollection <AftaleProxy>(command));
     }
     catch (IntranetRepositoryException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new IntranetRepositoryException(Resource.GetExceptionMessage(ExceptionMessage.RepositoryError, MethodBase.GetCurrentMethod().Name, ex.Message), ex);
     }
 }
示例#3
0
        /// <summary>
        /// Gets the appointment users for a given appointment.
        /// </summary>
        /// <param name="appointment">The appointment for which to get the appointment users.</param>
        /// <param name="dataProvider">The data provider which should be used to get the appointment users.</param>
        /// <returns>The appointment users.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="appointment"/> or <paramref name="dataProvider"/>is null.</exception>
        internal static IEnumerable <IBrugeraftaleProxy> GetAppointmentUsers(IAftaleProxy appointment, IDataProviderBase <MySqlDataReader, MySqlCommand> dataProvider)
        {
            ArgumentNullGuard.NotNull(appointment, nameof(appointment))
            .NotNull(dataProvider, nameof(dataProvider));

            using (IMySqlDataProvider subDataProvider = (IMySqlDataProvider)dataProvider.Clone())
            {
                MySqlCommand command = new CalenderCommandBuilder("SELECT cm.SystemNo,cm.CalId,cm.UserId,cm.Properties,ca.Date,ca.FromTime,ca.ToTime,ca.Properties AS AppointmentProperties,ca.Subject,ca.Note,cu.UserName,cu.Name AS UserFullname,cu.Initials AS UserInitials,s.Title AS SystemTitle,s.Properties AS SystemProperties FROM Calmerge AS cm INNER JOIN Calapps AS ca ON ca.SystemNo=cm.SystemNo AND ca.CalId=cm.CalId INNER JOIN Calusers AS cu ON cu.SystemNo=cm.SystemNo AND cu.UserId=cm.UserId INNER JOIN Systems AS s ON s.SystemNo=cm.SystemNo WHERE cm.SystemNo=@systemNo AND cm.CalId=@calId")
                                       .AddSystemNoParameter(appointment.System.Nummer)
                                       .AddAppointmentIdParameter(appointment.Id)
                                       .Build();
                return(subDataProvider.GetCollection <BrugeraftaleProxy>(command));
            }
        }
 /// <summary>
 /// Henter alle systemer under OSWEBDB.
 /// </summary>
 /// <returns>Liste af systemer under OSWEBDB.</returns>
 public IEnumerable <ISystem> SystemGetAll()
 {
     try
     {
         MySqlCommand command = new CommonCommandBuilder("SELECT SystemNo,Title,Properties FROM Systems ORDER BY SystemNo").Build();
         return(_mySqlDataProvider.GetCollection <SystemProxy>(command));
     }
     catch (IntranetRepositoryException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new IntranetRepositoryException(Resource.GetExceptionMessage(ExceptionMessage.RepositoryError, MethodBase.GetCurrentMethod().Name, ex.Message), ex);
     }
 }
示例#5
0
        public void TestAtGetCollectionKasterMySqlExceptionHvisQueryIkkeKanUdføres()
        {
            using (IMySqlDataProvider sut = CreateSut())
            {
                Assert.That(sut, Is.Not.Null);

                MySqlCommand queryCommand = new MySqlCommand("SELECT SystemNo,Title FROM XYZSystems WHERE SystemNo=@systemNo ORDER BY SystemNo")
                {
                    CommandType = CommandType.Text
                };
                MySqlParameter systemNoParameter = queryCommand.Parameters.AddWithValue("@systemNo", _random.Next(90, 99));
                systemNoParameter.MySqlDbType = MySqlDbType.Int16;
                systemNoParameter.IsNullable  = false;

                Assert.Throws <MySqlException>(() => sut.GetCollection <MyDataProxy>(queryCommand));
            }
        }
示例#6
0
        public void TestAtGetCollectionKasterArgumenutNullExceptionHvisQueryCommandErNull()
        {
            using (IMySqlDataProvider sut = CreateSut())
            {
                Assert.That(sut, Is.Not.Null);

                ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.GetCollection <MyDataProxy>(null));

                TestHelper.AssertArgumentNullExceptionIsValid(result, "queryCommand");
            }
        }