コード例 #1
0
ファイル: Member.cs プロジェクト: foresightbrand/brandqq
        /// <summary>
        /// ����¼�Ƿ�ɹ�
        /// </summary>
        /// <param name="guid">Guid</param>
        /// <param name="member">����������Ϣ��Memberʵ��</param>
        /// <param name="email">�ʼ���ַ</param>
        /// <param name="pwd">����</param>
        /// <param name="expire">��������</param>
        /// <returns></returns>
        private static bool Login(string guid,Member member, string email, string pwd, int expire)
        {
            Member m;
            if (member == null)
            {
                if (!String.IsNullOrEmpty(guid))
                {
                    m = IsMember(guid);
                }
                else
                {
                    m = IsMember(email, pwd);
                }

                if (m == null)
                {
                    return false;
                }
            }
            else
            {
                m = member;
            }

            if (expire > 0)
            {
                Cookies.WriteCookie(__cookieName, expire, new string[] { "ID", "GUID", "EMAIL", "NAME" }, new string[] { m.Id.ToString(), m.RegGuid, email, HttpContext.Current.Server.UrlEncode(m.Name.ToString()) });
            }
            else
            {
                Cookies.WriteCookie(__cookieName, new string[] { "ID", "GUID", "EMAIL", "NAME" }, new string[] { m.Id.ToString(), m.RegGuid, email, HttpContext.Current.Server.UrlEncode(m.Name.ToString()) });
            }

            if (Member.TempInfo != null)
            {
                if (Member.TempInfo.ResultId > 0)
                {
                    //���ҵ�¼֮ǰ�����Ľ���ļ�
                    //ͬ���������ݿ��е�״̬��¼
                    string tempPath = GeneralConfig.Instance.PaperResultTempSavePath + Member.TempInfo.ResultId.ToString() + ".rst";
                    if (File.Exists(tempPath))
                    {
                        UpdateResultStatusGuid(Member.TempInfo.ResultId, Member.Instance.Guid);
                    }
                }

                //������ʱ��־��
                Cookies.WriteCookie("BRANDQQ_TEMP_INFO", GeneralConfig.Instance.UserTempInfoDuration, new string[] { "GUID" }, new string[] { m.RegGuid });
            }

            return true;
        }
コード例 #2
0
ファイル: Member.cs プロジェクト: foresightbrand/brandqq
 /// <summary>
 /// ����¼�Ƿ�ɹ�
 /// </summary>
 /// <param name="u">Member</param>
 /// <param name="expire">��������</param>
 /// <returns></returns>
 public static bool Login(Member u,int expire)
 {
     return Login(u.email, u.password, expire);
 }
コード例 #3
0
ファイル: Member.cs プロジェクト: foresightbrand/brandqq
 /// <summary>
 /// ����¼�Ƿ�ɹ�
 /// </summary>
 /// <param name="guid">Guid</param>
 /// <param name="m">����������Ϣ��Memberʵ��</param>
 /// <returns></returns>
 public static bool Login(string guid,Member m)
 {
     return Login(guid, m, "", "", 0);
 }
コード例 #4
0
ファイル: Member.cs プロジェクト: foresightbrand/brandqq
 /// <summary>
 /// ����¼�Ƿ�ɹ�
 /// </summary>
 /// <param name="u">Member</param>
 /// <returns></returns>
 public static bool Login(Member u)
 {
     return Login(u.email,u.password);
 }
コード例 #5
0
ファイル: Member.cs プロジェクト: foresightbrand/brandqq
        /// <summary>
        /// ��ȡ�û���¼
        /// </summary>
        /// <param name="email">�ʼ���ַ�ؼ���</param>
        /// <param name="name">�����ؼ���</param>
        /// <param name="Pager">��ҳ����</param>
        /// <returns></returns>
        public static ArrayList List(string mail, string name, Pager pager)
        {
            /* MemberList
             * @email varchar(50)='',
             * @name varchar(20)='',
             * @pageindex int=1,
             * @pagesize int=20,
             * @sort int=0
             */

            ArrayList list = new ArrayList();
            SqlParameter[] prams ={
                Database.MakeInParam("@email",SqlDbType.VarChar,50,mail),
                Database.MakeInParam("@name",SqlDbType.VarChar,20,name),
                Database.MakeInParam("@pageIndex",SqlDbType.Int,pager.PageIndex),
                Database.MakeInParam("@pageSize",SqlDbType.Int,pager.PageSize),
                Database.MakeInParam("@sort",SqlDbType.Int,pager.SortNum)
            };

            SqlDataReader reader = null;
            try
            {
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "MemberList", prams);

                if (reader.Read())
                {
                    pager.RecordCount = reader.GetInt32(0);

                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            /*[Id], Email, [Name], RegDate, LastLogin, LoginTimes, LastIp*/
                            Member m = new Member();
                            m.Id = reader.GetInt32(0);
                            m.Email = reader.GetString(1);
                            m.Name = reader.GetString(2);
                            m.RegDate = reader.GetDateTime(3);
                            m.LastLogin = reader.GetDateTime(4);
                            m.LoginTimes = reader.GetInt32(5);
                            m.LastIp = reader.GetString(6);

                            list.Add(m);
                        }
                    }
                }

                reader.Close();
            }
            catch(Exception e)
            {
                throw new Exception("Member.List: +"+e.ToString());
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return list;
        }
コード例 #6
0
ファイル: Member.cs プロジェクト: foresightbrand/brandqq
        /// <summary>
        /// ���һ��Guid����(Email/password)�Ƿ�Ϸ��û�
        /// </summary>
        /// <param name="guid"></param>
        /// <param name="mail"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public static Member IsMember(string guid,string mail, string pwd)
        {
            /* MemberCheck
             * @guid varchar(32)='',
             * @email varchar(50),
             * @pass varchar(32)='',
             * @ip varchar(50)=''
             */

            Member m = null;

            SqlParameter[] prams ={
                Database.MakeInParam("@guid",SqlDbType.VarChar,32,guid),
                Database.MakeInParam("@email",SqlDbType.VarChar,50,mail),
                Database.MakeInParam("@pass",SqlDbType.VarChar,32,Utility.MD5(pwd)),
                Database.MakeInParam("@ip",SqlDbType.VarChar,50,HttpContext.Current.Request.UserHostAddress)
            };

            SqlDataReader reader = null;

            try
            {
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "MemberCheck", prams);
                if (reader.HasRows)
                {
                    m = new Member();
                    if (reader.Read())
                    {
                        /*[Id],RegGuid, [Name], RegDate, LastLogin, LoginTimes, LastIp*/
                        m.Id = reader.GetInt32(0);
                        m.Email = mail;
                        m.RegGuid = reader.GetString(1);
                        m.Name = reader.GetString(2);
                        m.RegDate = reader.GetDateTime(3);
                        m.LastLogin = reader.GetDateTime(4);
                        m.LoginTimes = reader.GetInt32(5);
                        m.LastIp = reader.GetString(6);
                    }
                }
                reader.Close();
            }
            catch
            {
                //
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return m;
        }
コード例 #7
0
ファイル: Member.cs プロジェクト: foresightbrand/brandqq
        /// <summary>
        /// ��ȡ�û�����
        /// </summary>
        /// <param name="id">�û���¼��</param>
        /// <returns></returns>
        public static Member Get(int id)
        {
            /* MemberGet
             * @id int
             */

            Member m = new Member();

            SqlParameter[] prams ={
                Database.MakeInParam("@id",SqlDbType.Int,id)
            };

            SqlDataReader reader = null;

            try
            {
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "MemberGet", prams);
                if (reader.Read())
                {
                    /*RegGuid,Email, [Name],[Password], RegDate, LastLogin, LoginTimes, LastIp*/
                    m.Id = id;
                    m.RegGuid = reader.GetString(0);
                    m.Email = reader.GetString(1);
                    m.Name = reader.GetString(2);
                    m.Password = reader.GetString(3);
                    m.RegDate = reader.GetDateTime(4);
                    m.LastLogin = reader.GetDateTime(5);
                    m.LoginTimes = reader.GetInt32(6);
                    m.LastIp = reader.GetString(7);
                }
                reader.Close();
            }
            catch
            {
                //
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return m;
        }
コード例 #8
0
ファイル: AjaxPost.cs プロジェクト: foresightbrand/brandqq
        /// <summary>
        /// �û�ע��
        /// </summary>
        /// <returns></returns>
        private string Register()
        {
            string str = "FAILED";
            if (Request.Form["email"] != null && Request.Form["password"] != null && Request.Form["password2"] != null)
            {
                string email = Request.Form["email"].Trim();
                string pass = Request.Form["password"].Trim();
                string pass2 = Request.Form["password2"].Trim();

                if (Member.IsExistEmail(email))
                {
                    str="EXISTS_EMAIL";
                }

                if (pass != pass2)
                {
                    str="ERROR_PASS";
                }

                Member m = new Member();
                m.Email = email;
                m.Name = "";
                m.Password = pass;

                m.Save();
                Member.Login(email, pass);

                Email.SendMail(email, "��ӭ����BrandQQ.com", "��ӭ������BrandQQ,���ĵ�¼�ʺ�:" + email + ",��¼����:" + pass + " \n\n ��¼��BrandQQ.com http://www.brandqq.com \n\n \n\n����Ʒ�ƹ��� http://www.foresight.net.cn", false, GeneralConfig.MailSenderInstance);

                str = "OK";
            }
            return str;
        }