示例#1
0
        public static CloudEnv GetDefaultEnv()
        {
            var list = select("select * from DBCONF order by updateDate desc");

            if (list.Count <= 0)
            {
                return(CloudEnv.GetDefault());
            }
            return(CloudEnv.FromDict(list[0]));
        }
示例#2
0
        public static void Save(CloudEnv env)
        {
            var id   = env.dbType.ToString() + env.dbHost + env.dbPort + env.dbName;
            var list = select("select * from DBCONF where id='" + id + "'");
            var dict = env.ToDictionary();

            dict.Add("id", id);
            dict.Add("updateDate", DateTime.Now);
            dict.Remove("envPath");
            if (list.Count > 0)
            {
                var cond = new Dictionary <string, object>();
                cond.Add("id", id);
                db.Update("DBCONF", dict, cond);
            }
            else
            {
                db.Insert("DBCONF", dict);
            }
        }
示例#3
0
        public static CloudEnv GetEnvByHostAndDbType(String host, int dbtype, ref int index)
        {
            var list = select("select * from DBCONF where dbHost='" + host + "' and dbType='" + dbtype + "' order by updateDate desc");

            if (list.Count <= 0 && index == 0)
            {
                return(null);
            }
            if (list.Count <= 0)
            {
                index++;
                return(GetEnvByHostAndDbType(host, dbtype, ref index));
            }
            if (index >= list.Count)
            {
                index = 0;
                var env = CloudEnv.FromDict(list[index]);
                index = -1;
                return(env);
            }
            return(CloudEnv.FromDict(list[index]));
        }
示例#4
0
        public static void DeleteEnv(CloudEnv env)
        {
            var id = env.dbType.ToString() + env.dbHost + env.dbPort + env.dbName;

            ExecuteNoneQuery("delete from DBCONF where id='" + id + "'");
        }