using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TABS.MailCarrier.WebSDK.Contact;

public partial class Contact_SelectOrgzEx : System.Web.UI.Page
{
    protected override void InitializeCulture()
    {
        string defLang = WebUser.CurrentUser.UiLanguage;
        Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(defLang);
        Thread.CurrentThread.CurrentUICulture = new CultureInfo(defLang);
        base.InitializeCulture();
    }

    protected void Page_Init(object sender, EventArgs e)
    {
        WebUtil.SetKendoUiLocalResource(Page.Header, WebUser.CurrentUser.UiLanguage);
        WebUtil.SetMcCommonCss(Page.Header);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Page.Title = AppSetting.GetTitleInfo(Request).Title;
            LoadOrgzBookList();
            
        }
    }

    private void LoadOrgzBookList()
    {
        List<ListItem> items = new List<ListItem>();

        // 조직도
        UserAddressBook userAddrBook = new UserAddressBook(WebUser.CurrentUser.DomainUserID);
        foreach (Organization orgz in userAddrBook.Organizations)
        {
            if (orgz.AccessFlag != Organization.RsAccessFlag.None)
            {
                ListItem item = new ListItem();
                item.Value = orgz.ID.ToString();
                item.Text = orgz.Name;
                items.Add(item);
            }
        }

        OrgzList.DataSource = items;
        OrgzList.DataTextField = "Text";
        OrgzList.DataValueField = "Value";
        OrgzList.DataBind();
    }
}