Beispiel #1
0
 public string GetNew()
 {
     using (var conn = DataSourceUtil.GetConnection(DataSource, ConnectString))
     {
         string connectString = "";
         var    cmd           = conn.CreateCommand();
         cmd.CommandText = QueryString;
         cmd.CommandType = CommandType.Text;
         conn.Open();
         var reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             connectString = reader.GetString(0);
         }
         return(connectString);
     }
 }
        protected List <Dictionary <string, object> > PrepareDatas()
        {
            List <Dictionary <string, object> > list = new List <Dictionary <string, object> >();

            NetworkCenter.Current.Execute("db-pstu", () =>
            {
                using (var conn = DataSourceUtil.GetConnection(Source, ConnectString))
                {
                    conn.Open();
                    var command            = conn.CreateCommand();
                    command.CommandText    = QueryString;
                    command.CommandTimeout = 60000;
                    command.CommandType    = CommandType.Text;

                    var reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        Dictionary <string, object> data = new Dictionary <string, object>();
                        int count = reader.FieldCount;
                        for (int i = 0; i < count; ++i)
                        {
                            string name = reader.GetName(i);
                            data.Add(name, reader.GetValue(i));
                        }

                        if (Extras != null)
                        {
                            foreach (var extra in Extras)
                            {
                                data.Add(extra.Key, extra.Value);
                            }
                        }
                        list.Add(data);
                    }
#if !NET_CORE
                    reader.Close();
#else
                    reader.Dispose();
#endif
                }
            });

            return(list);
        }