Ejemplo n.º 1
0
        private void addFileToBatchCommand(file toInsert, int thisbatchcnt, SqlCommand cmd)
        {
            Dictionary <string, object> .KeyCollection columnNameList = toInsert.columnNames.Keys;
            StringBuilder columnNames  = new StringBuilder();
            StringBuilder columnValues = new StringBuilder();

            string[] binarycols = { "hash_sha256", "pe_timestamp", "pe_sizeOfCode", "pe_magicType", "contents128b" };
            foreach (string colName in columnNameList)
            {
                if (colName == "wsusFileID")
                {
                    continue;
                }

                columnNames.Append(colName + ",");
                if (binarycols.Count(x => x == colName) > 0)
                {
                    Byte[] asbyte = toInsert.columnNames[colName] as byte[];
                    if (asbyte != null)
                    {
                        columnValues.Append($"CONVERT(varbinary({asbyte.Length}), @{colName}_{thisbatchcnt}, 1),");
                    }
                    else
                    {
                        columnValues.Append($"CONVERT(varbinary(max), @{colName}_{thisbatchcnt}, 1),");
                    }
                }
                else
                {
                    columnValues.Append($"@{colName}_{thisbatchcnt},");
                }
            }

            cmd.CommandText +=
                $" Insert Into @testdata  ({columnNames.ToString().TrimEnd(',')}) values ({columnValues.ToString().TrimEnd(',')}); ";

            foreach (KeyValuePair <string, object> col in toInsert.columnNames)
            {
                addParamWithValue(cmd, $"@{col.Key}_{thisbatchcnt}", col.Value);
            }
        }
Ejemplo n.º 2
0
        public List <file> getFilesByPartialName(string filter)
        {
            List <file> toRet = new List <file>();

            using (SqlCommand cmd = _dbConn.CreateCommand())
            {
                cmd.CommandTimeout = 600;
                cmd.CommandText    = $@"select * from files where filename like @filter";
                addParamWithValue(cmd, "@filter", filter);
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        file newfile = new file(reader);
                        toRet.Add(newfile);
                    }

                    return(toRet);
                }
            }
        }
Ejemplo n.º 3
0
        public List <file> getDeltasFilesByPartialName(string filter)
        {
            List <file> toRet = new List <file>();

            using (SqlCommand cmd = _dbConn.CreateCommand())
            {
                cmd.CommandTimeout = 600;
                cmd.CommandText    = $@"select * from files where filename like @filter and pe_timestamp is null";
                //cmd.CommandText += " and id in (6344568, 8396013, 9002503, 8997300, 8997298, 8802055, 8802046, 8769977, 8769975, 8396005, 7784218, 7784212, 6344512, 6344507, 6343710, 6343699, 6312392, 6312380, 10063047, 10063046, 9933049, 9933048, 9724018, 9724017, 9002506, 10075608, 10075607, 9934777, 9934776, 9730974, 9730973, 10411186, 10411185, 7021093, 7021090, 10391355, 10391354, 8184508, 8184503, 7930372, 7930367, 7780721, 7780718, 8067470, 8067466, 8056866, 9097037, 9097034, 8681086, 8681085, 8365615, 8365611, 8364121, 8364112, 8364109, 8364108, 8056860, 7646739, 7646736, 6824130, 6824087, 6604710, 6604707, 6589837, 6589830, 6576511, 6576499, 6180559, 6180554, 6168349, 6168337, 6150609, 6150591, 10125255, 10125254, 10019176, 10019175, 10014931, 10014929, 9099005, 9099004, 4689408, 4689401, 5815355, 7961964, 7497557, 7497553, 6647098, 6647091, 6506711, 6506706, 5854409, 5815352, 8749336, 8554703, 7961959, 5854403, 10050607, 10050606, 9909295, 9909294, 9907140, 9907139, 9847189, 9847188, 9711190, 9711189, 9707242, 9707241, 9040261, 9040259, 8749333, 8554697, 8545910, 8545907, 8455390, 8455387, 8447865, 8447861, 8216990, 8216982, 8199899, 8199890, 8198652, 8198634, 8135859, 8135853, 8008440, 8008436, 7823754, 7823749, 7814193, 7814189, 7712862, 7712854, 7711866, 7711861, 7698604, 7698600, 7698581, 7698574, 7587326, 7587324, 7566648, 7566645, 7496818, 7496816, 7487294, 7487290, 7386478, 7386474, 7374418, 7374413, 7077668, 7077664, 6736855, 6736847, 6646199, 6646192, 6506491, 6506482, 6406614, 6406604, 6404921, 6404916, 6290887, 6290877, 6032688, 6032679, 6032355, 6032349, 5854071, 5854067, 5814323, 5814315, 10332911, 10332910, 10229275, 10229274, 10221002, 10221001, 10085944, 10085943, 5730051, 5730046, 2817773, 2817772, 7522208, 7522206, 6202794, 10259966, 10259965, 9988605, 9988604, 9810433, 9810432, 9802921, 9802920, 9797879, 9797878, 8882441, 8882440, 8503636, 8503632, 8502367, 8502363, 8499946, 8499944, 7989157, 7989151, 7973505, 7973501, 7618022, 7618020, 7611025, 7611019, 7594223, 7594219, 9793919, 7593723, 7593717, 7324939, 7324931, 6453402, 6453394, 9793920, 6202787, 10296547, 10289439, 10114238, 9964411, 9881443, 9874436, 9751902, 9745552, 10296546, 10289438, 10114237, 9964410, 9881442, 9874435, 9751901, 9745551, 9109894, 9109893, 8672136, 8672132, 8669395, 8669391, 8667818, 8667812, 8657043, 8657039, 8481230, 8481226, 8464799, 8464795, 8258730, 8258725, 8092754, 8092748, 7854025, 7854018, 7536423, 7536416, 7522160, 7522159, 7264375, 7264370, 6973002, 6972997, 6888815, 6888809, 6477803, 6477797, 6211320, 6211316, 6202671, 6202669, 4999664, 4999655, 10240129, 10240128, 10141784, 10141783, 9952767, 9952766, 9947718, 9947717, 9778359, 9778358, 9771961, 9771960, 9769264, 9769263, 8310139, 6617213, 6617206, 5981482, 5981477, 8310133, 10367683, 10367682, 10206303, 10206301, 10165811, 10165810, 9886549, 9886548, 8926273, 8926268, 8924392, 8924390, 8274707, 8274703, 8162872, 8162868, 7765050, 7765043, 7455809, 7455804, 6804038, 6804027, 6686661, 6686656, 5956750, 5956745, 8613900, 8613895, 3910646, 3910641, 9817645, 9817644, 7742661, 7219135, 10039279, 10029165, 9824053, 7220117, 7220110, 10039278, 10029164, 9824051, 9814014, 9814013, 7923350, 7923346, 7746971, 7746967, 7744119, 7744112, 7742656, 7219130, 6094739, 6094731, 10425968, 10425967, 7217787, 7217781)";
                addParamWithValue(cmd, "filter", filter);
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        file newfile = new file(reader);
                        toRet.Add(newfile);
                    }

                    return(toRet);
                }
            }
        }
Ejemplo n.º 4
0
 public file_wimInfo(fileSource_wim parent, file fileInfo)
 {
     this.parent   = parent;
     this.fileInfo = fileInfo;
 }
Ejemplo n.º 5
0
        public file_wimInfo(wsusUpdate grandparent, updateFile source, fileSource_wim parent)
        {
            fileInfo = new file(grandparent, source);

            this.parent = parent;
        }
Ejemplo n.º 6
0
 /// <summary>
 /// This constructor is used for injecting test data.
 /// </summary>
 public file_wimInfo(string filename, Byte[] hash_sha256, byte[] contents, fileSource_wim parent, string location)
 {
     fileInfo    = new file(parent.wimFileID, filename, hash_sha256, contents, location);
     this.parent = parent;
 }
Ejemplo n.º 7
0
 public delta(file delta)
 {
     deltaFileID   = delta.dbID.Value;
     deltaFileSize = delta.size;
 }