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

public partial class Calendar_Calendars : 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.SetMcCommonCss(Page.Header);
    }

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

    private void LoadCalendarList()
    {
        List<McCalendar> calList = new List<McCalendar>();

        UserMcCalendar userCalendar = new UserMcCalendar(WebUser.CurrentUser.DomainUserID);
        // 개인 일정표
        foreach (McCalendar calendar in userCalendar.MyCalendars)
        {
            calList.Add(calendar);
        }

        // 공유 일정표
        foreach (McCalendar calendar in userCalendar.ShareCalendars)
        {
            if (calendar.AccessFlag != McCalendar.RsAccessFlag.None)
            {
                calList.Add(calendar);
            }
        }

        CalendarRepeater.DataSource = calList;
        CalendarRepeater.DataBind();
    }
    

    protected string GetClickEventFunction(Guid id)
    {
        return string.Format("location.href='Monthly.aspx?cid={0}';", id);
    }
}