Beispiel #1
0
        /// <summary>
        /// 显示输出
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="me"></param>
        /// <returns></returns>
        public static string OutPutShow(string key, object data = null, MessageEnum me = MessageEnum.Success)
        {
            if (data == null)
            {
                data = "";
            }
            string       mestr = me.ToString();
            MessageState ms    = new MessageState()
            {
                key = key
            };

            System.Type t      = me.GetType();
            FieldInfo[] filist = t.GetFields();
            foreach (var fi in filist)
            {
                if (fi.Name == mestr)
                {
                    MsgStateAttribute ai = (MsgStateAttribute)System.Attribute.GetCustomAttribute(fi, typeof(MsgStateAttribute), false);
                    ms.SetMsgState(ai.GetMsg());
                    break;
                }
            }
            ms.data  = data;
            ms.state = me.ConvertData <int>();
            return(MakeJson.ObjectToJson(new
            {
                ms.state,
                ms.key,
                ms.data
            }, "yyyy-MM-dd HH:mm:ss"));
        }
Beispiel #2
0
        /// <summary>
        /// 输出文本
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static string OutPutShow(string msg)
        {
            MessageState ms = new MessageState()
            {
                data = msg
            };

            ms.SetMsgState("成功");
            ms.state = MessageEnum.Success.ConvertData <int>();
            return(MakeJson.ObjectToJson(new
            {
                ms.state,
                ms.key,
                ms.data
            }, "yyyy-MM-dd HH:mm:ss"));
        }
Beispiel #3
0
        /// <summary>
        /// 显示输出
        /// </summary>
        /// <param name="data"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static string OutPutShow(object data, string msg)
        {
            MessageState ms = new MessageState()
            {
                data = data
            };

            ms.SetMsgState(msg);
            ms.state = MessageEnum.OtherError.ConvertData <int>();
            return(MakeJson.ObjectToJson(new
            {
                ms.state,
                ms.key,
                ms.data
            }, "yyyy-MM-dd HH:mm:ss"));
        }