using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using JuSNS.Model.ApiInterface;
using JuSNS.Common;

namespace JuSNS.Web.app.frame
{
    public partial class index : JuSNS.UI.Page.UserPage
    {
        protected string url = string.Empty;
        protected int AppID = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            int.TryParse(Request.QueryString["id"], out AppID);
            if (AppID == 0)
            {
                Response.Redirect("?errmsg="+HttpUtility.UrlEncode("链接不正确！"));
                Response.End();
            }
            ApiInterface.ApiUser aUser = new JuSNS.ApiInterface.ApiUser(this.UserID);
            if (!aUser.IsAppAdded(AppID))
            {
                Response.Redirect("../appinstall.aspx?id=" + AppID);
            }
            AppInfo info = ApiInterface.App.GetAppInfo(AppID);
            if (info.IsSys == 1)
            {
                Response.Redirect(Public.rootDir + "/home/" + info.Url);
                Response.End();
            }
            url = info.Url + "?u=" + ApiInterface.SecretUser.EncryptUserID(this.UserID.ToString());
        }
    }
}
