using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using SysCore.Control;

public partial class UI_Flow_Flow : System.Web.UI.Page
{
    public string app_list = "";
    public string report_list = "";
    string category;
    protected void Page_Load(object sender, EventArgs e)
    {
        category = Request.QueryString["category"];
        Draw_Flow();
        Draw_Report();
    }
    /// <summary>
    /// 图标
    /// </summary>
    void Draw_Flow()
    {
        string where = "and category='" + category + "' and (isnull(url,'')<>'' or isnull(flow_url,'')<>'')";
        DataTable dt = new SysCore.DAL.ModuleDAL().GetList(where);
        AuthUI adal = new AuthUI();
        string js = "", auth_code = "", module_name = "", node_img = "", flow_url = "", url = "", icon_url = "", href = "";
        foreach (DataRow dr in dt.Rows)
        {
            auth_code = dr["auth_code"].ToString();
            if (!adal.AuthCheck(auth_code))
                continue;
            module_name = dr["module_name"].ToString();
            node_img = dr["node_img"].ToString();
            flow_url = dr["flow_url"].ToString();
            url = dr["url"].ToString();
            icon_url = url;
            
            if (icon_url.Equals(""))
            {
                icon_url = flow_url;
                //href = "window.location='" + icon_url + "';";
                href = "open_tab('" + auth_code + "','" + auth_code + "', '" + module_name + "', '" + icon_url + "')";
            }
            else
            {
                href = "open_tab('" + auth_code + "','" + auth_code + "', '" + module_name + "', '" + icon_url + "')";
            }
            js = "onclick=\"" + href + "\"";
            app_list += "<li " + js + "><div><img class='app_icon' src='../../System/SystemFrame/images/apps/" + node_img + "'/></div>"
                        + "<div>" + module_name + "</div></li>\n";
        }
    }
    /// <summary>
    /// 报表
    /// </summary>
    void Draw_Report()
    {
        string where = "and category='" + category + "_Report' and isnull(url,'')<>''";
        DataTable dt = new SysCore.DAL.ModuleDAL().GetList(where);
        AuthUI adal = new AuthUI();
        foreach (DataRow dr in dt.Rows)
        {
            string auth_code = dr["auth_code"].ToString();
            if (!adal.AuthCheck(auth_code))
                continue;
            string module_name = dr["module_name"].ToString();
            string node_img = dr["node_img"].ToString();
            string url = dr["url"].ToString();
            string js = "onclick=\"open_tab('" + auth_code + "','" + auth_code + "', '" + module_name + "', '" + url + "')\"";
            report_list += "<li " + js + ">" + module_name + "</li>\n";
        }
    }
}