using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
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.Config;
using JuSNS.Common;

namespace JuSNS.Web.user.friend
{
    public partial class invitefine : JuSNS.UI.Page.UserPage
    {
        protected string rest = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            {
                string emails = Request.Form["TxtEmails"];
                if (emails == null || emails.Trim() == string.Empty)
                {
                    rest = "<div class=\"content bold reshow\">Email不能为空</div>";
                    DataBind();
                    return;
                }
                string note = Request.Form["TxtExtraNote"];

                #region 过滤关键字
                string res = JuSNS.Common.Public.CheckKey(note, true);
                if (!string.IsNullOrEmpty(res))
                {
                    note = note.Replace(res, "***");
                }
                #endregion
                JuSNS.Home.Friend frd = new JuSNS.Home.Friend();
                bool isRe = false;
                if (Request.Form["ReVite"] == "1")
                    isRe = true;
                Dictionary<string, int> dct = frd.InviteFriends(UserID, UserName, emails, note, isRe);
                string rStr = string.Empty;
                foreach (KeyValuePair<string, int> kv in dct)
                {
                    switch (kv.Value)
                    {
                        case 0:
                            rStr = "<span class=\"green pstr\">成功发送邀请！</span>";
                            break;
                        case 1:
                            rStr = "<span class=\"reshow pstr\">已在本站注册！</span> ";
                            break;
                        case 2:
                            rStr = "<span class=\"reshow pstr\">已被邀请！</span> ";
                            break;
                        case 3:
                            rStr = "<span class=\"reshow pstr\">发送邀请失败！</span>";
                            break;
                        case 4:
                            rStr = "<span class=\"reshow pstr\">发送邀请失败：邮件发送失败！</span>";
                            break;
                    }
                    //rest += "<a href=\"invite-rec.aspx?a=pending\">查看邀请记录 &raquo;</a></div>\r\n";
                    rest += "<ul><li>";
                    rest += kv.Key + " (" + rStr + ")</li>\r\n";
                    rest += "</ul>\r\n";

                }
                DataBind();
            }
        }
    }
}
