/// <summary>
        /// 开始
        /// </summary>
        /// <param name="programStartInfos">程序启动信息集合</param>
        public static void Start(ProgramStartInfo[] programStartInfos = null)
        {
            if (programStartInfos == null)
            {
                if (ProgramConfigReader == null)
                {
                    return;
                }

                programStartInfos = ProgramConfigReader.Reader();
            }

            if (programStartInfos.IsNullOrLength0())
            {
                return;
            }

            IProgramStart[] programStarts = new IProgramStart[programStartInfos.Length];
            for (int i = 0; i < programStarts.Length; i++)
            {
                programStarts[i] = ReflectUtil.CreateInstance <IProgramStart>(programStartInfos[i].FullClass);
            }

            for (int i = 0; i < programStarts.Length; i++)
            {
                programStarts[i].Start(programStartInfos[i].Args);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 执行查询SQL,返回列表object
        /// 前置条件: 必须是映射的SQL语句,且必须指定SQL语句的返回参数类
        /// </summary>
        /// <param name="sqlName"></param>
        /// <param name="pageSize"></param>
        /// <param name="curPage"></param>
        /// <param name="paramValues"></param>
        /// <returns></returns>
        public List <T> ExecuteListObject <T>(string sqlName, int pageSize, int curPage, params object[] paramValues)
        {
            int         i;
            int         recordStart = 0;
            int         recordEnd   = 0;
            List <T>    objs        = new List <T>();
            T           obj;
            IDataReader idr         = null;
            Type        returnClass = null;

            // 如果未指定SQL语句的返回参数类, 将抛出异常
            returnClass = SqlMap.GetSqlReturnClass(sqlName);
            if (returnClass == null)
            {
                throw new Exception(string.Format("未指定SQL语句的返回参数类异常:{0}", sqlName));
            }

            // 计算获取的记录编号范围(当前页)
            CalcRecordRange(pageSize, curPage, ref recordStart, ref recordEnd);

            try
            {
                // 执行查询
                string sql = SqlMap.GetSql(_isql, sqlName, paramValues);
                idr = _db.ExecuteReaderBySql(sql);

                // 获取指定范围的数据
                i = 0;
                while (idr.Read())
                {
                    i++;
                    if (i < recordStart)
                    {
                    }
                    else if (i <= recordEnd)
                    {
                        obj = (T)ReflectUtil.CreateInstance(returnClass);
                        for (int j = 0; j < idr.FieldCount; j++)
                        {
                            ReflectUtil.SetPropertyValue(obj, idr.GetName(j), idr.GetValue(j));
                        }
                        objs.Add(obj);
                    }
                    else //if (i > recordEnd)
                    {
                        break;
                    }
                }
            }
            finally
            {
                if (idr != null)
                {
                    idr.Close();
                }
            }

            return(objs);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 创建一个简单连接
        /// </summary>
        /// <returns>简单连接</returns>
        private static IMessageQueueConnection CreateSimpleConnection()
        {
            string classFullPath = AppConfig["MessageQueue:ConnectionClassFullPath"];

            if (string.IsNullOrWhiteSpace(classFullPath))
            {
                throw new Exception("请在配置文件里配置[MessageQueue:ConnectionClassFullPath]连接执行类路径");
            }

            return(ReflectUtil.CreateInstance <IMessageQueueConnection>(classFullPath));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 执行查询SQL,返回列表object
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="pageSize"></param>
        /// <param name="curPage"></param>
        /// <param name="returnClass">不能为null</param>
        /// <returns></returns>
        public List <T> ExecuteListObjectByType <T>(string sql, int pageSize, int curPage, Type returnClass)
        {
            int         i;
            int         recordStart = 0;
            int         recordEnd   = 0;
            List <T>    objs        = new List <T>();
            T           obj;
            IDataReader idr = null;

            // 计算获取的记录编号范围(当前页)
            CalcRecordRange(pageSize, curPage, ref recordStart, ref recordEnd);

            try
            {
                // 执行查询
                idr = _db.ExecuteReaderBySql(sql);

                // 获取指定范围的数据
                i = 0;
                while (idr.Read())
                {
                    i++;
                    if (i < recordStart)
                    {
                    }
                    else if (i <= recordEnd)
                    {
                        obj = (T)ReflectUtil.CreateInstance(returnClass);

                        for (int j = 0; j < idr.FieldCount; j++)
                        {
                            ReflectUtil.SetPropertyValue(obj, idr.GetName(j), idr.GetValue(j));
                        }
                        objs.Add(obj);
                    }
                    else // (i > reocrdEnd)
                    {
                        break;
                    }
                }
            }
            finally
            {
                if (idr != null)
                {
                    idr.Close();
                }
            }

            return(objs);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 执行查询SQL,返回列表object
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="pageSize"></param>
        /// <param name="curPage"></param>
        /// <param name="returnClass">不能为null</param>
        /// <returns></returns>
        public PageList <T> ExecutePageListObjectByType <T>(string sql, string orderKey, int pageSize, int curPage, Type returnClass)
        {
            PageList <T> objs = new PageList <T>();
            T            obj;
            IDataReader  idr = null;

            // 计算获取的记录编号范围(当前页)
            objs.SetPage(pageSize, curPage);

            try
            {
                // 获取总记录数
                if (pageSize != -1)
                {
                    objs.TotalCount = ParamUtil.getint(_db.ExecuteScalarBySql(_isql.CountSql(sql)));
                }
                string pageSql = _isql.PageSql(sql, orderKey, objs.StartRecord, objs.EndRecord);
                // 执行查询
                idr = _db.ExecuteReaderBySql(pageSql);

                // 获取指定范围的数据
                while (idr.Read())
                {
                    obj = (T)ReflectUtil.CreateInstance(returnClass);

                    // 第一列为COL_ROWNUM(记录号),不设置属性值
                    for (int i = 1; i < idr.FieldCount; i++)
                    {
                        ReflectUtil.SetPropertyValue(obj, idr.GetName(i), idr.GetValue(i));
                    }
                    objs.Add(obj);
                }

                // 如果未分页,则设置总数为当前页记录数
                if (pageSize == -1)
                {
                    objs.TotalCount = objs.CurPageCount;
                }
            }
            finally
            {
                if (idr != null)
                {
                    idr.Close();
                }
            }

            return(objs);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 创建实例
 /// </summary>
 /// <typeparam name="T">实例类型</typeparam>
 /// <param name="classFullPath">类全路径</param>
 /// <returns>实例</returns>
 public T CreateInstance <T>(string classFullPath)
     where T : class
 {
     return(ReflectUtil.CreateInstance <T>(classFullPath));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 创建实例
 /// </summary>
 /// <param name="classFullPath">类全路径</param>
 /// <returns>实例</returns>
 public object CreateInstance(string classFullPath)
 {
     return(ReflectUtil.CreateInstance(classFullPath));
 }