Example #1
0
        protected override void Page_Init(System.Object sender, System.EventArgs e)
        {
            if (!String.IsNullOrEmpty(Token))
            {
                ServiceDB serDB = ServiceDBItem;

                if (serDB != null && !String.IsNullOrEmpty(serDB.Token))
                {
                    //编辑权限验证
                    if (serDB.Validate)
                    {
                        base.Page_Init(sender, e);
                    }
                }
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    if (!String.IsNullOrEmpty(Token))
                    {
                        ServiceDB serDB = ServiceDBItem;

                        if (serDB != null && !String.IsNullOrEmpty(serDB.Token))
                        {
                            //登录验证
                            if (serDB.Login && UserId <= 0)
                            {
                                Response.Redirect(Globals.LoginURL(HttpUtility.UrlEncode(HttpContext.Current.Request.RawUrl), false));
                            }
                            else
                            {
                                //取出需要调用的服务
                                iService Ser = (iService)Activator.CreateInstance(serDB.assemblyName, serDB.typeName).Unwrap();
                                if (Ser != null && !String.IsNullOrEmpty(serDB.Token))
                                {
                                    //执行服务
                                    Ser.Execute(this);

                                    if (!String.IsNullOrEmpty(Ser.ResponseString))
                                    {
                                        if (Ser.IsResponseWrite)
                                        {
                                            //输出字符串
                                            Response.Clear();
                                            Response.Write(Ser.ResponseString);
                                        }
                                        else
                                        {
                                            HttpContext.Current.Response.ContentType = "application/xml";
                                            using (StreamWriter sw = new StreamWriter(HttpContext.Current.Response.OutputStream, Encoding.UTF8))
                                            {
                                                sw.Write(Ser.ResponseString);
                                                sw.Close();
                                                sw.Dispose();
                                                //Response.Flush();
                                                //Response.End();
                                            }
                                        }
                                    }
                                    else
                                    {
                                        //错误,没有输出
                                    }
                                }
                                else
                                {
                                    //没有找到相应的服务
                                }
                            }
                        }
                        else
                        {
                            //没有找到相应的服务
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessPageLoadException(ex);
                Response.Write(String.Format("Exception:{0}", ex.Source));
            }
            finally
            {
                Response.End();
            }
        }