Esempio n. 1
0
        /// <summary>
        /// 获取学生成绩
        /// </summary>
        /// <returns></returns>
        public TransResponse <StuSubGrade> GetSudentGrades()
        {
            var response = new TransResponse <StuSubGrade>();
            var sg       = studentBll.GetsubGrade();

            response.Result = new StuSubGrade()
            {
                stu = sg.Item1, sub = sg.Item2, subGrade = sg.Item3
            };
            return(response);
        }
        private TransResponse CreateResponse(out object[] outputParams)
        {
            List <object> outParams = new List <object>();

            PropertyInfo prop = invoker.GetType().GetProperty("Method");

            if (prop != null)
            {
                MethodInfo operationMethod = prop.GetValue(invoker) as MethodInfo;

                if (operationMethod != null)
                {
                    ParameterInfo[] ps = operationMethod.GetParameters();

                    foreach (var pi in ps)
                    {
                        if (pi.IsOut)
                        {
                            var piType = pi.ParameterType.GetElementType();

                            if (piType.IsValueType)
                            {
                                if (piType == typeof(bool))
                                {
                                    outParams.Add(false);
                                }
                                else if (piType == typeof(DateTime))
                                {
                                    outParams.Add(DateTime.MinValue);
                                }
                                else
                                {
                                    outParams.Add(0);
                                }
                            }
                            else
                            {
                                outParams.Add(null);
                            }
                        }
                    }

                    Type trType = typeof(TransResponse <>);
                    trType = trType.MakeGenericType(operationMethod.ReturnType.GenericTypeArguments);
                    TransResponse response = Activator.CreateInstance(trType) as TransResponse;
                    outputParams = outParams.ToArray();
                    return(response);
                }
            }

            outputParams = outParams.ToArray();
            return(null);
        }
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
        {
            object returnedValue = null;

            object[] outputParams = { };

            try
            {
                returnedValue = invoker.InvokeEnd(instance, out outputs, result);
                outputs       = outputParams;
                return(returnedValue);
            }
            catch (PropValiException pv)
            {
                TransResponse response = this.CreateResponse(out outputParams);

                if (response != null)
                {
                    response.Status  = TransStatus.ValidateError;
                    response.Message = pv.Message;
                    returnedValue    = response;
                }
                else
                {
                    returnedValue = null;
                }
            }
            catch (Exception ex)
            {
                TransResponse response = this.CreateResponse(out outputParams);

                if (response != null)
                {
                    response.Status  = TransStatus.Error;
                    response.Message = ex.Message;
                    returnedValue    = response;
                }
                else
                {
                    returnedValue = null;
                }
            }

            outputs = outputParams;
            return(returnedValue);
        }
Esempio n. 4
0
 //SuccessResponse
 public ProcessTransactionResponse(TransResponse response) : this(true, string.Empty, response)
 {
 }
Esempio n. 5
0
        //public string ErrorSource { get; set; } = null;

        //Private
        private ProcessTransactionResponse(bool success, string message, TransResponse response) : base(success, message)
        {
            TransResponse = response;
        }