Example #1
0
 public MemoryDatabase(
     PersonModelTable PersonModelTable,
     QuestMasterTable QuestMasterTable,
     ItemMasterTable ItemMasterTable,
     QuestMasterEmptyValidateTable QuestMasterEmptyValidateTable,
     ItemMasterEmptyValidateTable ItemMasterEmptyValidateTable,
     SequentialCheckMasterTable SequentialCheckMasterTable,
     SingleMasterTable SingleMasterTable,
     FailTable FailTable,
     SampleTable SampleTable,
     SkillMasterTable SkillMasterTable,
     TestMasterTable TestMasterTable,
     UserLevelTable UserLevelTable
     )
 {
     this.PersonModelTable = PersonModelTable;
     this.QuestMasterTable = QuestMasterTable;
     this.ItemMasterTable  = ItemMasterTable;
     this.QuestMasterEmptyValidateTable = QuestMasterEmptyValidateTable;
     this.ItemMasterEmptyValidateTable  = ItemMasterEmptyValidateTable;
     this.SequentialCheckMasterTable    = SequentialCheckMasterTable;
     this.SingleMasterTable             = SingleMasterTable;
     this.FailTable        = FailTable;
     this.SampleTable      = SampleTable;
     this.SkillMasterTable = SkillMasterTable;
     this.TestMasterTable  = TestMasterTable;
     this.UserLevelTable   = UserLevelTable;
 }
Example #2
0
        public void GetSTDByPlateNumber_ShouldReturnSeven()
        {
            var plate       = "X1";
            var sampleTable = new SampleTable
            {
                PlateNumber = new List <string>
                {
                    plate,
                },
                Samples = new List <Sample>
                {
                    new Sample("STD0", "", plate, "B1", "2", "Not Used"),
                    new Sample("STD1", "", plate, "C1", "2", "Not Used"),
                    new Sample("STD2", "", plate, "D1", "2", "Not Used"),
                    new Sample("STD3", "", plate, "E1", "2", "Not Used"),
                    new Sample("STD4", "", plate, "F1", "2", "Not Used"),
                    new Sample("STD5", "", plate, "G1", "2", "Not Used"),
                    new Sample("STD6", "", plate, "H1", "2", "Not Used"),
                }
            };

            var result = sampleTable.GetSTDByPlateNumber(plate);

            Assert.Equal(7, result.Count);
        }
        public static ImportRun RunTest(EntityType entityType, string fileName, ImportFormat importFormat, string sheetName = null)
        {
            string fileToken;

            using (Stream stream = SheetTestHelper.GetStream(fileName))
            {
                fileToken = FileRepositoryHelper.AddTemporaryFile(stream);
            }


            EntityType   type         = entityType;
            ImportConfig importConfig = CreateImportConfig(type, importFormat, sheetName);

            ImportRun importRun = CreateImportRun(importConfig, fileToken);

            ISpreadsheetInspector inspector = Factory.Current.Resolve <ISpreadsheetInspector>( );
            SpreadsheetInfo       info      = inspector.GetSpreadsheetInfo(fileToken, importFormat);
            SampleTable           sample    = inspector.GetSampleTable(fileToken, importFormat, sheetName, 1, 2, null);

            AddAllFields(importConfig, sample);

            // Run import
            IImportRunWorker worker = Factory.Current.Resolve <IImportRunWorker>( );

            worker.StartImport(importRun.Id);

            return(importRun);
        }
Example #4
0
        public void Test_NoHeadingRow( )
        {
            string csv =
                "\nA,B\nC,D";

            var service  = new CsvFileReaderService( );
            var settings = new DataFileReaderSettings( );

            settings.FirstDataRowNumber = 1;
            settings.HeadingRowNumber   = 0;
            SampleDataCreator creator = new SampleDataCreator( );

            using (Stream stream = SheetTestHelper.GetCsvStream(csv))
            {
                SampleTable table = creator.CreateSample(stream, settings, service);

                Assert.That(table, Is.Not.Null);
                Assert.That(table.Columns, Has.Count.EqualTo(2));
                Assert.That(table.Rows, Has.Count.EqualTo(2));

                SampleColumn column = table.Columns [0];
                Assert.That(column.ColumnName, Is.EqualTo("1"));
                Assert.That(column.Name, Is.EqualTo("1"));
                column = table.Columns [1];
                Assert.That(column.ColumnName, Is.EqualTo("2"));
                Assert.That(column.Name, Is.EqualTo("2"));
            }
        }
Example #5
0
        public void Test_Excel_Test2_NoHeadingRow( )
        {
            var service = new ExcelFileReaderService( );
            SampleDataCreator creator = new SampleDataCreator( );

            using (Stream stream = SheetTestHelper.GetStream("SampleDataTests.xlsx"))     // IMPORTANT: Ensure TestRowNumbers has the right number of rows
            {
                var settings = new DataFileReaderSettings( );
                settings.SheetId            = SheetTestHelper.GetSheetId("SampleDataTests.xlsx", "Test2");
                settings.HeadingRowNumber   = 0;
                settings.FirstDataRowNumber = 3;

                SampleTable table = creator.CreateSample(stream, settings, service);

                Assert.That(table, Is.Not.Null);
                Assert.That(table.Columns, Has.Count.EqualTo(3));
                Assert.That(table.Rows, Has.Count.EqualTo(2));

                SampleColumn column = table.Columns [0];
                Assert.That(column.ColumnName, Is.EqualTo("A"));
                Assert.That(column.Name, Is.EqualTo("A"));
                column = table.Columns [2];
                Assert.That(column.ColumnName, Is.EqualTo("C"));
                Assert.That(column.Name, Is.EqualTo("C"));

                SampleRow row = table.Rows [0];
                Assert.That(row.Values, Has.Count.EqualTo(3));
                Assert.That(row.Values [2], Is.EqualTo("3"));
            }
        }
Example #6
0
        public void GetClinicSamplesByPlateNumber_ShouldBeEmpty()
        {
            var plate       = "X1";
            var sampleTable = new SampleTable
            {
                PlateNumber = new List <string>
                {
                    plate,
                },
                Samples = new List <Sample>
                {
                    new Sample("STD0", "", plate, "B1", "2", "Not Used"),
                    new Sample("STD1", "", plate, "C1", "2", "Not Used"),
                    new Sample("STD2", "", plate, "D1", "2", "Not Used"),
                    new Sample("STD3", "", plate, "E1", "2", "Not Used"),
                    new Sample("STD4", "", plate, "F1", "2", "Not Used"),
                    new Sample("STD5", "", plate, "G1", "2", "Not Used"),
                    new Sample("STD6", "", plate, "H1", "2", "Not Used"),
                }
            };

            var result = sampleTable.GetClinicSamplesByPlateNumber(plate);

            Assert.Empty(result);
        }
 public RequestInfo Delete()
 {
     return(Request.DoTry((RequestInfo info) => {
         SampleTable model = Request.Get <SampleTable>();
         info.Sql = QueryManager.Delete(model);
         info.Add(model);
     }));
 }
Example #8
0
 private static Sample Adapt(SampleTable source)
 {
     return(new Sample
     {
         Id = source.Id,
         IndexedColumn = source.IndexedColumn,
         CustomTypeColumn = source.CustomTypeColumn
     });
 }
Example #9
0
 private void SetDataContent(SampleTable data)
 {
     this.StartDate          = data.PeriodStart.Value;
     this.EndDate            = data.PeriodEnd.Value;
     this.VisibleStartDate   = data.VisiblePeriodStart.Value;
     this.VisibleEndDate     = data.VisiblePeriodEnd.Value;
     this.SelectionStartDate = data.SelectionStart.Value;
     this.SelectionEndDate   = data.SelectionEnd.Value;
 }
Example #10
0
 public MemoryDatabase(
     SampleTable SampleTable,
     SkillMasterTable SkillMasterTable,
     UserLevelTable UserLevelTable
     )
 {
     this.SampleTable      = SampleTable;
     this.SkillMasterTable = SkillMasterTable;
     this.UserLevelTable   = UserLevelTable;
 }
        internal List <string> SelectColumns(SampleTable x)
        {
            var list = new List <string>();

            foreach (var column in Columns)
            {
                var value = x.GetType().GetProperty(column).GetValue(x);
                list.Add(value?.ToString());
            }
            return(list);
        }
        public void ReplaceAll(System.Collections.Generic.IList <Sample> data)
        {
            var newData = CloneAndSortBy(data, x => x.Id, System.Collections.Generic.Comparer <int> .Default);
            var table   = new SampleTable(newData);

            memory = new MemoryDatabase(
                table,
                memory.SkillMasterTable,
                memory.UserLevelTable

                );
        }
 internal bool AdaptWhereClause(SampleTable x)
 {
     foreach (var condition in WhereClause)
     {
         var value = x.GetType().GetProperty(condition.ColumnName).GetValue(x);
         if (condition.ComparedOpe == "=" && value?.ToString() != condition.Condition)
         {
             return(false);
         }
     }
     return(true);
 }
Example #14
0
 public string Post([FromBody] SampleTable value)
 {
     try
     {
         DbSet.Add(value);
         _dbcontext.SaveChanges();
         return("OK");
     }
     catch (Exception e)
     {
         return("Erro: " + e.Message);
     }
 }
        public void RemoveSample(int[] keys)
        {
            var data    = RemoveCore(memory.SampleTable.GetRawDataUnsafe(), keys, x => x.Id, System.Collections.Generic.Comparer <int> .Default);
            var newData = CloneAndSortBy(data, x => x.Id, System.Collections.Generic.Comparer <int> .Default);
            var table   = new SampleTable(newData);

            memory = new MemoryDatabase(
                table,
                memory.SkillMasterTable,
                memory.UserLevelTable

                );
        }
Example #16
0
        // GET api/sample
        public IHttpActionResult Get()
        {
            try
            {
                SampleTable st = testDomain.GetFirst();

                return(Ok(st));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
        public void Diff(Sample[] addOrReplaceData)
        {
            var data    = DiffCore(memory.SampleTable.GetRawDataUnsafe(), addOrReplaceData, x => x.Id, System.Collections.Generic.Comparer <int> .Default);
            var newData = CloneAndSortBy(data, x => x.Id, System.Collections.Generic.Comparer <int> .Default);
            var table   = new SampleTable(newData);

            memory = new MemoryDatabase(
                table,
                memory.SkillMasterTable,
                memory.UserLevelTable

                );
        }
Example #18
0
 public string Put(int id, [FromBody] SampleTable value)
 {
     try
     {
         SampleTable t = DbSet.Where(c => c.Id == id).FirstOrDefault();
         t.Name = value.Name;
         _dbcontext.Entry <SampleTable>(t).State = EntityState.Modified;
         _dbcontext.SaveChanges();
         return("OK");
     }
     catch (Exception e)
     {
         return("Erro: " + e.Message);
     }
 }
Example #19
0
        public override void ResetDB()
        {
            using (EFSampleTableContext context = new EFSampleTableContext(ConnectionString))
            {
                var resetStmt = EmbeddedResourceLoader.ReadFullContent("Scripts", "resetDB.sql");
                context.Database.ExecuteSqlRaw(resetStmt);
                context.SaveChanges();

                SampleTable newEnt = new SampleTable {
                    NAME = "Test"
                };
                context.SampleTable.Add(newEnt);
                context.SaveChanges();
            }
        }
Example #20
0
        public string Delete(int id)
        {
            SampleTable t = DbSet.Where(c => c.Id == id).FirstOrDefault();

            if (t != null)
            {
                DbSet.Remove(t);
                _dbcontext.SaveChanges();
                return("OK");
            }
            else
            {
                return("Não encontrado");
            }
        }
Example #21
0
        public SampleReader(TrackMetadata track)
        {
            MediaInformation mi = track.info.mediaInformation;

            sampleCount         = mi.sampleTable.sampleSize.sampleCount;
            sampleSize          = mi.sampleTable.sampleSize;
            timeToSampleEntries = mi.sampleTable.timeToSample;
            sampleToChunk       = mi.sampleTable.sampleToChunk;
            chunkOffset         = mi.sampleTable.chunkOffset;
            timeScale           = track.info.timeScale;
            duration            = track.info.duration;
            sampleTable         = mi.sampleTable;
            timeDeltas          = mi.sampleTable.compositionToSample;
            editList            = track.editList;
            rewind();
        }
Example #22
0
        public static int DeleteSampleTableById(SampleTable pData, VerticaConnection pConnection)
        {
            using (var comm = new VerticaCommand())
            {
                comm.Connection = pConnection;
                comm.CommandText = Queries.DeleteSampleTableById;

                comm.Parameters.AddRange(new[]
                {
                    new VerticaParameter("@pID", VerticaType.Numeric, pData.Id)

                }
                    );

                return comm.ExecuteNonQuery();
            }
        }
Example #23
0
        public static int UpdateSampleTable(SampleTable pData, VerticaConnection pConnection)
        {
            using (var comm = new VerticaCommand())
            {
                comm.Connection = pConnection;
                comm.CommandText = Queries.UpdateSampleTable;

                comm.Parameters.AddRange(new[]
                {
                    new VerticaParameter("@pID", VerticaType.Numeric, pData.Id),
                    new VerticaParameter("@pText", VerticaType.VarChar, pData.Text)
                }
                    );

                return comm.ExecuteNonQuery();
            }
        }
Example #24
0
        public void Test_CSV_NoData( )
        {
            string csv = "";

            var service  = new CsvFileReaderService( );
            var settings = new DataFileReaderSettings( );
            SampleDataCreator creator = new SampleDataCreator( );

            using (Stream stream = SheetTestHelper.GetCsvStream(csv))
            {
                SampleTable table = creator.CreateSample(stream, settings, service);

                Assert.That(table, Is.Not.Null);
                Assert.That(table.Columns, Has.Count.EqualTo(0));
                Assert.That(table.Rows, Has.Count.EqualTo(0));
            }
        }
Example #25
0
 public ServiceResult <SampleTable> Edit(SampleTable obj)
 {
     try
     {
         IMediator    service     = _container.GetInstance <IMediator>();
         IUserContext currentUser = _container.GetInstance <IUserContext>();
         var          query       = new SampleTableEditQuery();
         obj.UpdatedDate      = DateTime.Now;
         obj.UpdatedUserId    = currentUser.CurrentUserIdentity.UserID;
         obj.UpdatedIpAddress = currentUser.CurrentUserIdentity.IpAddress;
         query.SampleTable    = obj;
         return(new ServiceResult <SampleTable>(service.Proccess(query), message: ClientErrorMessage.Success(), state: ServiceResultStates.SUCCESS));
     }
     catch (ExceptionLog ex)
     {
         LoggerService.Logger.Log(_container, ex);
         return(new ServiceResult <SampleTable>(result: null, message: ClientErrorMessage.Error(), state: ServiceResultStates.ERROR));
     }
 }
Example #26
0
        public void ReplaceAll(System.Collections.Generic.IList <Sample> data)
        {
            var newData = CloneAndSortBy(data, x => x.Id, System.Collections.Generic.Comparer <int> .Default);
            var table   = new SampleTable(newData);

            memory = new MemoryDatabase(
                memory.QuestMasterTable,
                memory.ItemMasterTable,
                memory.QuestMasterEmptyValidateTable,
                memory.ItemMasterEmptyValidateTable,
                memory.SequentialCheckMasterTable,
                memory.SingleMasterTable,
                memory.FailTable,
                table,
                memory.SkillMasterTable,
                memory.TestMasterTable,
                memory.UserLevelTable

                );
        }
Example #27
0
        public void GetGroupTwoQCByPlateNumber_ShouldBeReturnThree()
        {
            var plate       = "X1";
            var sampleTable = new SampleTable
            {
                PlateNumber = new List <string>
                {
                    plate,
                },
                Samples = new List <Sample>
                {
                    new Sample("QC1", "", plate, "E2", "0", "Correct pipetting"),
                    new Sample("QC2", "", plate, "F2", "0", "Correct pipetting"),
                    new Sample("QC3", "", plate, "G2", "0", "Correct pipetting"),
                }
            };

            var result = sampleTable.GetGroupTwoQCByPlateNumber(plate);

            Assert.Equal(3, result.Count);
        }
Example #28
0
        public void GetGroupTwoQCByPlateNumber_ShouldBeReturnEmpty()
        {
            var plate       = "X1";
            var sampleTable = new SampleTable
            {
                PlateNumber = new List <string>
                {
                    plate,
                },
                Samples = new List <Sample>
                {
                    new Sample("QC1", "", plate, "B2", "0", "Correct pipetting"),
                    new Sample("QC2", "", plate, "C2", "0", "Correct pipetting"),
                    new Sample("QC3", "", plate, "D2", "0", "Correct pipetting"),
                }
            };

            var result = sampleTable.GetGroupTwoQCByPlateNumber(plate);

            Assert.Empty(result);
        }
Example #29
0
        public void GetSTDByPlateNumber_ShouldBeReturnEmpty()
        {
            var plate       = "X1";
            var sampleTable = new SampleTable
            {
                PlateNumber = new List <string>
                {
                    plate,
                },
                Samples = new List <Sample>
                {
                    new Sample("AD001", "123", plate, "C3", "0", "Correct pipetting"),
                    new Sample("AD002", "456", plate, "D3", "0", "Correct pipetting"),
                    new Sample("AD003", "789", plate, "E3", "0", "Correct pipetting"),
                }
            };

            var result = sampleTable.GetSTDByPlateNumber(plate);

            Assert.Empty(result);
        }
Example #30
0
        public void Diff(Sample[] addOrReplaceData)
        {
            var data    = DiffCore(memory.SampleTable.GetRawDataUnsafe(), addOrReplaceData, x => x.Id, System.Collections.Generic.Comparer <int> .Default);
            var newData = CloneAndSortBy(data, x => x.Id, System.Collections.Generic.Comparer <int> .Default);
            var table   = new SampleTable(newData);

            memory = new MemoryDatabase(
                memory.QuestMasterTable,
                memory.ItemMasterTable,
                memory.QuestMasterEmptyValidateTable,
                memory.ItemMasterEmptyValidateTable,
                memory.SequentialCheckMasterTable,
                memory.SingleMasterTable,
                memory.FailTable,
                table,
                memory.SkillMasterTable,
                memory.TestMasterTable,
                memory.UserLevelTable

                );
        }
Example #31
0
        public void RemoveSample(int[] keys)
        {
            var data    = RemoveCore(memory.SampleTable.GetRawDataUnsafe(), keys, x => x.Id, System.Collections.Generic.Comparer <int> .Default);
            var newData = CloneAndSortBy(data, x => x.Id, System.Collections.Generic.Comparer <int> .Default);
            var table   = new SampleTable(newData);

            memory = new MemoryDatabase(
                memory.PersonModelTable,
                memory.QuestMasterTable,
                memory.ItemMasterTable,
                memory.QuestMasterEmptyValidateTable,
                memory.ItemMasterEmptyValidateTable,
                memory.SequentialCheckMasterTable,
                memory.SingleMasterTable,
                memory.FailTable,
                table,
                memory.SkillMasterTable,
                memory.TestMasterTable,
                memory.UserLevelTable

                );
        }
Example #32
0
        public void Test_Excel_Test5_GapsInColumns( )
        {
            var service = new ExcelFileReaderService( );
            SampleDataCreator creator = new SampleDataCreator( );

            using (Stream stream = SheetTestHelper.GetStream("SampleDataTests.xlsx"))     // IMPORTANT: Ensure TestRowNumbers has the right number of rows
            {
                var settings = new DataFileReaderSettings( );
                settings.SheetId            = SheetTestHelper.GetSheetId("SampleDataTests.xlsx", "Test5");
                settings.HeadingRowNumber   = 3;
                settings.FirstDataRowNumber = 4;

                SampleTable table = creator.CreateSample(stream, settings, service);

                Assert.That(table, Is.Not.Null);
                Assert.That(table.Columns, Has.Count.EqualTo(2));
                Assert.That(table.Rows, Has.Count.EqualTo(2));

                Assert.That(table.Columns [0].ColumnName, Is.EqualTo("A"));
                Assert.That(table.Columns [0].Name, Is.EqualTo("Heading1"));
                Assert.That(table.Columns [1].ColumnName, Is.EqualTo("C"));
                Assert.That(table.Columns [1].Name, Is.EqualTo("Heading2"));
            }
        }
Example #33
0
        /// <summary>
        /// Удаление строки из таблицы SampleTable.
        /// </summary>
        /// <param name="pData">Объект SampleTable, который нужно удалить</param>
        /// <returns></returns>
        public static int DeleteSampleTableById(SampleTable pData)
        {
            switch (Db.CurrDbType)
            {
                case DbType.Vertica:
                    return DbVertica.DeleteSampleTableById(pData, Connection as VerticaConnection);

                default: throw new NotImplementedException("Нет реализации для данного типа СУБД");

            }
        }