Ejemplo n.º 1
0
 public static List<string> GenerateUrls(string Mask, DataServer srv, string MD5, string[] extList )
 {
     if (string.IsNullOrWhiteSpace(Mask)) return null;
     var urls = new List<string>();
     var um = Mask.ToUpper();
     if (um.Contains(CMD_SUBSERVER))
         foreach (var s in srv.subServers)
             urls.AddRange(GenerateUrls(s, MD5, srv.Ext, Mask, extList));
     else
         urls.AddRange(GenerateUrls(srv.Server, MD5, srv.Ext, Mask, extList));
     return urls;
 }
Ejemplo n.º 2
0
 public DataRecord getInfo(int MD5id)
 {
     try
     {
         lock (_conr)
         {
             if (_conr.State == System.Data.ConnectionState.Closed) return DataRecord.Empty;
             using (var c = _conr.CreateCommand())
             using (c.Transaction = _conr.BeginTransaction(_readTransactionOptions))
                 try
                 {
                     c.CommandText = "select m.MD5, m.rating, (select list(tl.tag, ' ') MD5_TAGS from tags t join tags_list tl on tl.tag_id=t.tag_id where md5_id=m.md5_id) from md5_list m where m.md5_id = " + MD5id.ToString();
                     var rdr = c.ExecuteReader();
                     if (!rdr.Read()) return null;
                     var md5 = rdr.GetString(0);
                     var rating = rdr.IsDBNull(1) ? DataRating.Questionable : (DataRating)rdr.GetString(1)[0];
                     var tags = rdr.IsDBNull(2) ? string.Empty : rdr.GetString(2);
                     var r = new DataRecord()
                     {
                         MD5 = md5,
                         Rating = rating,
                         Tags = tags.Split(' ')
                     };
                     c.CommandText = "select sl.server_name, el.ext, di.data_size, di.data_post_number, sl.server_id from data_info di left join servers_list sl on sl.server_id = di.data_server_id left join ext_list el on el.ext_id=di.data_ext_id where di.data_md5_id = " + MD5id.ToString();
                     var srvs = new List<DataServer>();
                     var ids = new List<int>();
                     rdr = c.ExecuteReader();
                     while (rdr.Read())
                     {
                         var srv = new DataServer();
                         srv.Server = rdr.GetString(0);
                         srv.Ext = rdr.IsDBNull(1) ? string.Empty : rdr.GetString(1);
                         srv.Size = rdr.IsDBNull(2) ? -1 : rdr.GetInt32(2);
                         srv.Post = rdr.IsDBNull(3) ? -1 : rdr.GetInt32(3);
                         ids.Add(rdr.GetInt32(4));
                         srvs.Add(srv);
                     }
                     r.Servers = srvs.ToArray();
                     for (int i = 0; i < ids.Count; i++)
                     {
                         c.CommandText = "select server_name from servers_list where SERVER_GROUP_ID = " + ids[i].ToString();
                         List<string> l = new List<string>();
                         rdr = c.ExecuteReader();
                         while (rdr.Read())
                             l.Add(rdr.GetString(0));
                         srvs[i].subServers = l.ToArray();
                     }
                     return r;
                 }
                 finally
                 {
                     c.Transaction.Rollback();
                 }
         }
     }
     catch
     {
         return null;
     }
 }