Exemple #1
0
        internal List <IValidation> GetValidations()
        {
            if (string.IsNullOrEmpty(ConnectString) || string.IsNullOrEmpty(EmailTo) || string.IsNullOrEmpty(EmailPassword) || string.IsNullOrEmpty(EmailSmtpServer) || string.IsNullOrEmpty(EmailUser))
            {
                return(null);
            }

            var conn = DataSourceUtil.GetConnection(Source, ConnectString);
            List <IValidation> results = new List <IValidation>();

            foreach (var rule in Rules)
            {
                results.Add(rule.GetValidation(conn));
            }
            return(results);
        }
Exemple #2
0
        protected List <Dictionary <string, object> > PrepareDatas()
        {
            List <Dictionary <string, object> > list = new List <Dictionary <string, object> >();

            using (var conn = DataSourceUtil.GetConnection(Source, ConnectString))
            {
                string sql = QueryString;
                conn.Open();
                var command = conn.CreateCommand();
                command.CommandText    = sql;
                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);
        }