using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Net;
namespace JuSNS.AppClient
{
    /// <summary>
    /// 客户端应用程序类
    /// </summary>
    public class Application
    {
        /// <summary>
        /// 程序开始
        /// </summary>
        static public void Start()
        {
            int AppUserID;
            string uStr = HttpContext.Current.Request.QueryString["u"];
            if (!string.IsNullOrEmpty(uStr))
            {
                AppRequest aReq = new AppRequest("SecretUser", "DecryptUserID", uStr);
                int.TryParse(aReq.Result, out AppUserID);
                HttpContext.Current.Session["AppUserID"] = AppUserID.ToString();               
            }
        }
        /// <summary>
        /// 取得首页链接
        /// </summary>
        /// <returns></returns>
        static public string GetHomepage()
        {
            Uri uri = new Uri(Config.ServerUrl);
            return "http://" + uri.Host + "/home";
        }
        /// <summary>
        /// 取得某个应用的链接
        /// </summary>
        /// <param name="appname"></param>
        /// <returns></returns>
        static public string GetAppUrl(string appname)
        {
            Uri uri = new Uri(Config.ServerUrl);
            return "http://" + uri.Host + "/home/" + appname;
        }
        /// <summary>
        /// 取得空间链接
        /// </summary>
        /// <param name="userid">用户ID</param>
        /// <returns></returns>
        static public string GetSpaceUrl(int userid)
        {
            Uri uri = new Uri(Config.ServerUrl);
            return "http://" + uri.Host + "/home/space?" + userid;
        }
    }
}
