private string GetTargetStringForExport(IqTargetDms iqTarget)
        {
            var sb = new StringBuilder();

            var delim = "\t";

            sb.Append(iqTarget.ID);
            sb.Append(delim);
            sb.Append(iqTarget.Code);
            sb.Append(delim);
            sb.Append(iqTarget.EmpiricalFormula);
            sb.Append(delim);
            sb.Append(iqTarget.MonoMassTheor);
            sb.Append(delim);
            sb.Append(iqTarget.ElutionTimeTheor);
            sb.Append(delim);
            sb.Append(iqTarget.QualityScore);
            sb.Append(delim);
            sb.Append(iqTarget.PmtQualityScore);

            return(sb.ToString());
        }
        private List <IqTarget> GetMassTagDataFromDb(List <int> massTagsToBeRetrivedList)
        {
            var iqTargetList = new List <IqTarget>();

            var fact           = DbProviderFactories.GetFactory("System.Data.SqlClient");
            var currentListPos = 0;

            using (var cnn = fact.CreateConnection())
            {
                cnn.ConnectionString = BuildConnectionString();
                cnn.Open();

                var progressCounter = 0;
                while (currentListPos < massTagsToBeRetrivedList.Count)
                {
                    var nextGroupOfMassTagIDs = massTagsToBeRetrivedList.Skip(currentListPos).Take(ChunkSize).ToList();// GetRange(currentIndex, 5000);
                    currentListPos += (ChunkSize - 1);

                    var queryString = CreateQueryString(nextGroupOfMassTagIDs);
                    //Console.WriteLine(queryString);


                    using (var command = cnn.CreateCommand())
                    {
                        command.CommandText    = queryString;
                        command.CommandTimeout = 120;
                        var reader = command.ExecuteReader();


                        while (reader.Read())
                        {
                            var target = new IqTargetDms();

                            progressCounter++;

                            if (!reader[0].Equals(DBNull.Value))
                            {
                                target.ID = Convert.ToInt32(reader[0]);
                            }
                            if (!reader[1].Equals(DBNull.Value))
                            {
                                target.MonoMassTheor = Convert.ToDouble(reader[1]);
                            }
                            if (!reader[2].Equals(DBNull.Value))
                            {
                                target.ElutionTimeTheor = Convert.ToDouble(reader[2]);
                            }

                            if (!reader[3].Equals(DBNull.Value))
                            {
                                target.ElutionTimeTheorVariation = Convert.ToDouble(reader[3]);
                            }

                            //if (!reader[4].Equals(DBNull.Value))
                            //    target.ElutionTimeTheor = Convert.ToDouble(reader[4]);

                            if (!reader[5].Equals(DBNull.Value))
                            {
                                target.QualityScore = Convert.ToDouble(reader[5]);
                            }
                            if (!reader[6].Equals(DBNull.Value))
                            {
                                target.ModDescription = Convert.ToString(reader[6]);
                            }
                            if (!reader[7].Equals(DBNull.Value))
                            {
                                target.PmtQualityScore = Convert.ToInt32(reader[7]);
                            }
                            if (!reader[8].Equals(DBNull.Value))
                            {
                                target.Code = Convert.ToString(reader[8]);
                            }


                            iqTargetList.Add(target);


                            if (progressCounter % 100 == 0)
                            {
                                Console.WriteLine(progressCounter + " records loaded; " + reader[0]);
                            }
                        }
                        reader.Close();
                    }
                }
            }


            return(iqTargetList);
        }
        private List <IqTarget> GetMassTagDataFromDb()
        {
            var iqTargetList = new List <IqTarget>();

            var fact = DbProviderFactories.GetFactory("System.Data.SqlClient");

            using (var cnn = fact.CreateConnection())
            {
                cnn.ConnectionString = BuildConnectionString();
                cnn.Open();

                var progressCounter = 0;

                var queryString = CreateQueryString(MinPmtQualityScore);
                //Console.WriteLine(queryString);


                using (var command = cnn.CreateCommand())
                {
                    command.CommandText    = queryString;
                    command.CommandTimeout = 120;
                    var reader = command.ExecuteReader();


                    while (reader.Read())
                    {
                        var target = new IqTargetDms();

                        progressCounter++;

                        if (!reader[0].Equals(DBNull.Value))
                        {
                            target.ID = Convert.ToInt32(reader[0]);
                        }
                        if (!reader[1].Equals(DBNull.Value))
                        {
                            target.MonoMassTheor = Convert.ToDouble(reader[1]);
                        }
                        if (!reader[2].Equals(DBNull.Value))
                        {
                            target.ElutionTimeTheor = Convert.ToDouble(reader[2]);
                        }

                        if (!reader[3].Equals(DBNull.Value))
                        {
                            target.ElutionTimeTheorVariation = Convert.ToDouble(reader[3]);
                        }

                        //if (!reader[4].Equals(DBNull.Value))
                        //    target.ElutionTimeTheor = Convert.ToDouble(reader[4]);

                        if (!reader[5].Equals(DBNull.Value))
                        {
                            target.QualityScore = Convert.ToDouble(reader[5]);
                        }
                        if (!reader[6].Equals(DBNull.Value))
                        {
                            target.ModDescription = Convert.ToString(reader[6]);
                        }
                        if (!reader[7].Equals(DBNull.Value))
                        {
                            target.PmtQualityScore = Convert.ToInt32(reader[7]);
                        }
                        if (!reader[8].Equals(DBNull.Value))
                        {
                            target.Code = Convert.ToString(reader[8]);
                        }


                        if (!string.IsNullOrEmpty(target.ModDescription))
                        {
                            _targetsContainingMods.Add(target.ID);
                        }


                        iqTargetList.Add(target);


                        if (progressCounter % 100 == 0)
                        {
                            IqLogger.Log.Debug(progressCounter + " records loaded; " + reader[0]);
                        }
                    }
                    reader.Close();

                    IqLogger.Log.Debug("Total targets= " + iqTargetList.Count);
                    IqLogger.Log.Debug("Targets with mods = " + _targetsContainingMods.Count);
                }
            }

            return(iqTargetList);
        }