Пример #1
0
        public static ModelBase[] GetLogList(string modelTypeName, DateTime beginTime, DateTime endTime, out Exception ex)
        {
            ex = null;
            Type modelType = null;

            foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
            {
                foreach (Type t in asm.GetTypes())
                {
                    if (t.Name == modelTypeName)
                    {
                        modelType = t;
                    }
                }
            }
            if (modelType == null)
            {
                return(null);
            }
            ModelEnumerator reader = null;;

            try
            {
                string where;
                if (modelType.Name == "UserLoginLog")
                {
                    where = "logDateTime>'" + beginTime.ToString() + "' and logDateTime<'" + endTime.ToString() + "'";
                }
                else
                {
                    where = "ChangeDatetime>'" + beginTime.ToString() + "' and ChangeDatetime<'" + endTime.ToString() + "'";
                }
                reader = new ModelEnumerator(modelType, where);
            }
            catch (Exception e)
            {
                ex = e;
            }
            if (reader != null)
            {
                return(reader.ToArray());
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        private static void InternalLoad(Type type)
        {
            DateTime time = DateTime.Now;

            Console.Write("加载{0}到存根:", type.Name);
            int count = 0;

            ModelFactoryCollection.BuildFactories(type);
            ModelEnumerator reader = new ModelEnumerator(type);

            ModelCacheManager.Instance.CreateModelCollection(type);
            foreach (ModelBase model in reader)
            {
                ModelCacheManager.Instance.Save(model);
                count++;
            }
            Console.Write("{0}个记录 用时", count);
            Console.WriteLine(DateTime.Now.Subtract(time));
        }