예제 #1
0
        public IEnumerable <object> Get()
        {
            logData.Info("Get Assay Function is called");
            // getting back the assaytypes from the database table( AssayTypes)
            using (var repo = new AssayRepository())
            {
                try
                {
                    List <DisplayClass> objectAssay = new List <DisplayClass>();
                    var assaynamesobj = repo.GetAssay();
                    foreach (var assaytype in assaynamesobj)
                    {
                        DisplayClass ds = new DisplayClass();
                        ds.Id        = assaytype.ID;
                        ds.TypeId    = assaytype.TypeId;
                        ds.AssayName = assaytype.AssayName;
                        objectAssay.Add(ds);
                    }

                    logData.Info("Get Assay Function is finished");
                    return(objectAssay);
                }

                catch (SqlException odbcEx)
                {
                    Console.WriteLine(odbcEx.Message);
                    logData.Error(odbcEx.Message);
                    return(null);
                }
            }
        }
        public string Get()
        {
            log.Info("getAssay method is called");
            IEnumerable <AssayType> container = null;
            var toReturn = new List <AssayCount>();

            var repo      = new AssayRepository();
            var curveRepo = new CurveFilesRepository();

            container = repo.GetAssay();
            foreach (var item in container)
            {
                toReturn.Add(new AssayCount
                {
                    assay     = item,
                    fileCount = curveRepo.GetCountOfCurve(item.TypeId)
                });
            }
            log.Info("getAssay method is finished");
            return(JsonConvert.SerializeObject(toReturn));
        }
예제 #3
0
        // POST: api/ExtractAssayName
        public IEnumerable <string> Post()
        {
            /*  lock (ControllerSync)
             * {
             */
            List <string> assayNames = new List <string>();

            for (var i = 0; i < HttpContext.Current.Request.Files.Count; i++)
            {
                int flag = 0;
                logData.Info("Get all files from the staged area to extract assayname");
                HttpPostedFile file            = HttpContext.Current.Request.Files.Get(i);
                string         filename        = file.FileName;
                var            tempPathToStore = Path.GetTempPath();
                tempPathToStore += "assaynames";
                System.IO.Directory.CreateDirectory(tempPathToStore);
                //save the file in temp folder
                file.SaveAs(tempPathToStore + file.FileName);
                //getting the path of stored file
                var    tempStoredPath = tempPathToStore + file.FileName;
                var    tempfilename   = filename.Replace(".pdf", ".txt");
                string pathToText     = System.IO.Path.Combine(tempPathToStore, tempfilename);
                //Convert PDF file to Text file
                SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
                f.OpenPdf(tempStoredPath);
                if (f.PageCount > 0)
                {
                    int count = 0;
                    try
                    {
                        string line;
                        //getting assaynames from database
                        var           repo       = new AssayRepository();
                        List <string> assaylist1 = new List <string>();
                        //string[] assayFromDb;
                        var assaynamesobj = repo.GetAssay();
                        foreach (var assaytype in assaynamesobj)
                        {
                            string assayname = assaytype.AssayShortName;
                            assaylist1.Add(assayname);
                        }
                        string[] assaylistFromDB = assaylist1.ToArray();
                        foreach (var ind in assaylistFromDB)
                        {
                            Debug.WriteLine(ind);
                        }
                        //string[] assaylist1 = { "AC2", "AC2 250  (1)", "AdV/hMPV/RV", "Babesia", "C. diff", "CT", "CT 250", "DENV", "dHBV", "dHCV", "dHIV", "DNA60", "Flu A/B/RSV", "GBS", "GC", "GC 250  (6)", "GT HPV", "HEV", "HPV", "HPV 250  (14)", "HSV 1&2", "LDT RT TMA-1", "LDT RT TMA-2", "LDT RT TMA-3", "LDT TMA-1", "LDT TMA-2", "LDT TMA-3", "LDT1", "M gen", "MRSA", "OADNA55", "OADNA58", "OADNA62", "OADNA65", "Paraflu", "Parvo/HAV", "PSA 100", "QCDNAIC", "QCFluPPR", "QCRNAIC", "qHBV", "qHCV", "qHIV-1", "RNA60", "RNA60-10uL", "TRICH", "TRICH 250  (10)", "Ultrio Elite", "WNV", "ZIKV", "ZIKV  (51)" };
                        string[] assaylist2 = { "AC2 100  (21)", "AC2 250  (1)", "AdV/hMPV/RV  (102)", "Babesia  (50)", "C. diff  (108)", "CT 100  (22)", "CT 250  (5)", "DENV  (36)", "dHBV  (97)", "dHCV  (98)", "dHIV  (99)", "DNA60  (1507)", "Flu A/B/RSV  (101)", "GBS  (106)", "GC 100  (23)", "GC 250  (6)", "GT HPV  (20)", "HEV  (39)", "HPV 100  (24)", "HPV 250  (14)", "HSV 1&2  (40)", "LDT RT TMA-1  (90)", "LDT RT TMA-2  (91)", "LDT RT TMA-3  (92)", "LDT TMA-1  (95)", "LDT TMA-2  (88)", "LDT TMA-3  (89)", "LDT1  (1001)", "M gen  (43)", "MRSA  (107)", "OADNA55  (1505)", "OADNA58  (1506)", "OADNA62  (1508)", "OADNA65  (1509)", "Paraflu  (103)", "Parvo/HAV  (29)", "PSA 100  (31)", "QCDNAIC  (1501)", "QCFluPPR  (1503)", "QCRNAIC  (1502)", "qHBV  (34)", "qHCV  (32)", "qHIV-1  (28)", "RNA60  (1510)", "RNA60-10uL  (1512)", "TRICH 100  (9)", "TRICH 250  (10)", "Ultrio Elite  (25)", "WNV  (4)", "ZIKV  (52)", "ZIKV  (51)" };
                        int      result     = f.ToText(pathToText);
                        if (result == 0)
                        {
                            var lineCount = File.ReadLines(pathToText).Count();
                            Debug.WriteLine(lineCount);
                            FileStream inFile = new FileStream(pathToText, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                            using (StreamReader sr = new StreamReader(inFile))
                            {
                                while ((line = sr.ReadLine()) != null)
                                {
                                    count++;
                                    foreach (string word in assaylist1)
                                    {
                                        if (line.Contains(word))
                                        {
                                            var indexOfAssay       = Array.IndexOf(assaylistFromDB, word);
                                            var assayNameExtracted = assaylist2[indexOfAssay];
                                            assayNames.Add(assayNameExtracted);
                                            flag = 1;
                                            break;
                                        }
                                    }
                                    if (flag == 1)
                                    {
                                        break;
                                    }
                                }
                                Debug.WriteLine(count);
                                if (count == lineCount)
                                {
                                    var assayNameExtracted = "Choose AssayName";
                                    assayNames.Add(assayNameExtracted);
                                }
                            }
                            if (assayNames[i] == "")
                            {
                                assayNames.Add("Choose AssayName");
                            }
                        }
                        logData.Info("Returning the assay name");
                    }
                    catch (Exception e)
                    {
                        logData.Error(e.Message);
                    }
                    f.ClosePdf();
                }
                else
                {
                    assayNames.Add("Choose AssayName");
                }
            }
            return(assayNames);
            // }
        }