Exemplo n.º 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"));
        }
Exemplo n.º 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"));
        }
Exemplo n.º 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"));
        }
Exemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //初始化
            GlobalBLL.HttpContextBase hcb = new GlobalBLL.HttpContextBase(context);
            //获取键值
            if (WebCommandRun.GetInstance._command == null)
            {
                WebCommandRun.GetInstance._command = new SuperCommand.CommandRun <WebCommandVOBase>(this.GetType());
            }

            string cmd = hcb.GetValue("action");            //直接命令

            string       subcmd   = hcb.GetValue("subcmd"); //子命令
            MessageState cmdstate = null;

            if (cmd.StrIsNotNull())
            {
                //进行初始化
                cmdstate = WebCommandRun.GetInstance._command.Run <MessageState>(new WebCommandVOBase()
                {
                    Cmd    = cmd,
                    SubCmd = subcmd,
                    web    = hcb
                });
                if (cmdstate == null)
                {
                    return;
                }
            }
            else
            {
                cmdstate = new MessageState()
                {
                    state = MessageEnum.MsgError.EnumToInt(),
                    data  = "参数Action错误!",
                    flag  = false
                };
            }
            //显示数据
            string msg           = MessageState.OutPutShow(cmdstate.key, cmdstate.data, cmdstate.state.ConvertData <MessageEnum>());
            string jsonpCallback = hcb.GetValue("jsonpcallback");
            string JumpUrl       = hcb.GetValue("JumpUrl");
            string OutPutMsg     = string.Empty;


            if (jsonpCallback.StrIsNull())
            {
                Tools.SaveLog.AddLog("没有获取到:jsonpcallback 内容:" + msg, "jsonpCallback是空的");
                context.Response.Headers.Add("content-type", "application:json;charset=utf8");
                context.Response.Headers.Add("Access-Control-Allow-Origin", context?.Request?.Headers["Origin"] ?? "*");
                context.Response.Headers.Add("Access-Control-Allow-Methods", "GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH");
                context.Response.Headers.Add("Access-Control-Allow-Headers", "Session, X-Requested-With, accept, content-type");
                context.Response.Headers.Add("Access-Control-Allow-Credentials", "true");

                OutPutMsg = msg;
            }
            else
            {
                OutPutMsg = jsonpCallback + "(" + msg + ");";
            }
            if (JumpUrl.StrIsNotNull())
            {
                context.Response.Redirect(JumpUrl + "?data=" + System.Web.HttpUtility.UrlEncode(OutPutMsg));
            }
            else
            {
                context.Response.Write(OutPutMsg);
            }
            Tools.SaveLog.AddLog(msg, "OutPutMsg");
        }