Exemple #1
0
        //להכניס נתונים לטבלה
        public static void InsertIntoDatabaseListPerson(Production list1)
        {
            SqlTransaction transaction;

            using (SqlConnection connection = new SqlConnection(ConnectSqlLevel1.connectionString))
            {
                connection.Open();
                transaction = connection.BeginTransaction();
                try
                {
                    list1.ListLevel1.ForEach(p1 => MainLevel1.InsertAllListPerson(p1, list1.RunPlates.NumRun, connection, transaction));
                    list1.ListLevel2.ForEach(p2 => MainLevel2.InsertAllListPerson(p2, list1.RunPlates.NumRun, connection, transaction));
                    list1.ListLevel3.ForEach(p3 => MainLevel3.InsertAllListPerson(p3, list1.RunPlates.NumRun, connection, transaction));
                    list1.ListLevel4.ForEach(p4 => MainLevel4.InsertAllListPerson(p4, list1.RunPlates.NumRun, connection, transaction));
                    list1.ListLevel5.ForEach(p5 => MainLevel5.InsertAllListPerson(p5, list1.RunPlates.NumRun, connection, transaction));
                    list1.ListMpileupInsertions.ForEach(p55 => MainMpileupInsertions.InsertAllListPerson(p55, list1.RunPlates.NumRun, connection, transaction));
                    list1.ListLevel6.ForEach(p6 => MainLevel6.InsertAllListPerson(p6, list1.RunPlates.NumRun, connection, transaction));
                    list1.ListLevel9.ForEach(p9 => MainLevel9.InsertAllListPerson(p9, list1.RunPlates.NumRun, connection, transaction));

                    //   ConnectSqlLevel1.InsertTblMovedLevel(connection, command, transaction, "1111");
                    // ConnectSqlLevel2.UpdateTblMovedLevelToNotMove(connection, command, transaction, "?????");  אחרי שיהיה שלב 1
                    // ConnectSqlLevel2.InsertIntoTblGroupPlates( con, cmd, transaction, idFiles)
                    transaction.Commit();
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    throw e;
                }
                connection.Close();
            }
        }
        public Results GetProduction(int idPath, string barcodePlate)
        {
            Production p        = new Production();
            Results    r        = new Results();
            var        response = new HttpResponseMessage(HttpStatusCode.NotModified)
            {
                ReasonPhrase = ""
            };
            string path = null;

            try
            {
                path = ConnectSqlLevel1.SelectPathFile(idPath);
                var docfiles = new List <string>();
                foreach (string file in Directory.GetFiles(path))
                {
                    var name = System.IO.Path.GetFileName(file);
                    switch (name)
                    {
                    case "genotype_results.txt":
                    {
                        MainLevel1 m1 = new MainLevel1(file, p, barcodePlate);
                        p.ListLevel1 = m1.ListLevel1;
                        break;
                    }

                    case "self-chained.bed":
                    {
                        MainLevel2 m2 = new MainLevel2(file);
                        p.ListLevel2 = m2.ListLevel2;
                        break;
                    }

                    case "insertions_results.txt":
                    {
                        MainLevel3 m3 = new MainLevel3(file);
                        p.ListLevel3 = m3.ListLevel3;
                        break;
                    }

                    case "Hap_insertions_results.txt":
                    {
                        MainLevel4 m4 = new MainLevel4(file);
                        p.ListLevel4 = m4.ListLevel4;
                        break;
                    }

                    case "deletion.bed":
                    {
                        MainLevel5 m5 = new MainLevel5(file);
                        p.ListLevel5 = m5.ListLevel5;
                        break;
                    }

                    case "mpileup_insertions_results.txt":
                    {
                        MainMpileupInsertions mMI = new MainMpileupInsertions(file);
                        p.ListMpileupInsertions = mMI.ListMpileupInsertions;
                        break;
                    }
                    }
                }

                // Files.FileWriterLevel6Excel(p.ListLevel1, "", 1);
                MainLevel6 list6 = new MainLevel6(p);

                //p.RunPlates = ConnectSqlLevel0.SelectBarcodePlates(p.ListLevel1);
                MainLevel9 list9 = new MainLevel9(p);

                foreach (var list in p.GetType().GetProperties())//.Where(p => !p.GetGetMethod().GetParameters().Any() && !p.Name.Equals("BarcodeCantrige") && !p.Name.Equals("NumRun")
                {
                    if (list.GetValue(p, null).ToString() == null)
                    {
                        throw new Exception(list.GetValue(p, null).ToString() + " = null !");
                    }
                }

                if (ConnectSqlLevel0.SamplesNotInStep1 != null)
                {
                    r.MassegeSamplesNotInStep1 = "the samples : " + ConnectSqlLevel0.SamplesNotInStep1 + "not in step 1 ";
                }
                r.ResultProduction = p;
            }
            catch (Exception e)
            {
                response.ReasonPhrase = e.Message;
                throw new HttpResponseException(response);
            }
            finally
            {
                System.IO.Directory.Delete(path, true);
                ConnectSqlLevel1.DeletePathFile(idPath);
            }
            //ConnectSqlLevel2.InsertAllListPerson(m.ListLevel2);
            return(r);
        }