Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            var timeOld   = DateTime.Now;
            var resultMsg = string.Empty;
            var criteria  = new CriteriaTestuser();

            criteria.UName = null;
            criteria.Count = Convert.ToInt32(textBox1.Text);

            OperateClass ope = new OperateClass();

            ope.Assembly   = "Library.Facade.SoaTest";
            ope.Class      = string.Format("{0}.{1}", ope.Assembly, "FacadeTestUser");
            ope.Method     = "QueryTestuserList";
            ope.Parameters = new object[] { resultMsg, criteria };

            ClientProxy proxy     = new ClientProxy();
            var         resultOpc = proxy.Operate(ope);
            var         list      = (IList <ModelTestuser>)resultOpc.ResultObj;

            var timeNew  = DateTime.Now;
            var timeSpan = timeNew - timeOld;
            var msg      = string.Format("返回数据:{0} 条,耗时 {1} 秒!", list.Count, timeSpan.TotalSeconds);

            MessageBox.Show(msg);
        }
Пример #2
0
        public void QueryTestuserListTest()
        {
            IFacadeTestUser facade    = new Factories().InstanceTestUser();
            var             resultMsg = string.Empty;
            var             criteria  = new CriteriaTestuser();
            var             list      = facade.QueryTestuserList(out resultMsg, criteria);

            if (list.Count > 0)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.IsTrue(false);
            }
        }
Пример #3
0
        /// <summary>
        /// 数据查询
        /// </summary>
        /// <param name="resultMsg">执行结果</param>
        /// <param name="criteria">查询条件</param>
        /// <returns>泛型</returns>
        public IList <Models.SoaTest.ModelTestuser> QueryTestuserList(out string resultMsg, CriteriaTestuser criteria)
        {
            resultMsg = string.Empty;
            IList <ModelTestuser> list = new List <ModelTestuser>();

            try
            {
                //存储过程名称
                string sql = string.Format("SELECT TOP {0} * FROM [TestUser]  WHERE (@uname IS NULL OR [UName] =@uname)", criteria.Count);

                //参数添加
                IList <DBParameter> parm = new List <DBParameter>();
                parm.Add(new DBParameter()
                {
                    ParameterName = "uname", ParameterValue = criteria.UName, ParameterInOut = BaseDict.ParmIn, ParameterType = DbType.String
                });

                //查询执行
                using (IDataReader dr = DBHelper.ExecuteReader(sql, false, parm))
                {
                    //DataReader 转换成 List
                    list = GetModel(dr);
                }
            }
            catch (Exception ex)
            {
                resultMsg = string.Format("{0} {1}", BaseDict.ErrorPrefix, ex.ToString());
            }

            return(list);
        }