예제 #1
0
 /// <summary>
 /// 用於返回事物所用到的sql語句
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public string Save(UserQuery model)
 {
     model.Replace4MySQL();
     StringBuilder sb = new StringBuilder();
     sb.AppendFormat(" insert into user_history (user_id,user_name,file_name,content,creat_time,ip ) ");
     sb.AppendFormat(" values({0},'{1}','{2}','{3}',{4},'{5}');", model.kuser_id, model.kuser_name, model.file_name, model.content, CommonFunction.GetPHPTime(model.created.ToString()), model.ip);
     return sb.ToString();
 }
예제 #2
0
        public string Save(UserQuery uquery)
        {

            uquery.Replace4MySQL();


            StringBuilder sql = new StringBuilder();
            sql.Append("insert into users (user_id,user_email,user_new_email,user_password,user_newpasswd,user_name,user_mobile,user_zip,user_address,user_type, user_birthday_year,user_birthday_month,user_birthday_day,send_sms_ad,adm_note,user_status,user_source,user_login_attempts,user_actkey,user_reg_date,user_updatedate,user_mobile_bak)");
            sql.AppendFormat(" values({0},'{1}','{2}','{3}','{4}','{5}','{6}',{7},'{8}',{9},{10},{11},", uquery.user_id, uquery.user_email, uquery.user_new_email, uquery.user_password, uquery.user_newpasswd, uquery.user_name, uquery.user_mobile, uquery.user_zip, uquery.user_address, uquery.user_type,
                uquery.user_birthday_year, uquery.user_birthday_month);
            sql.AppendFormat("'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}');", uquery.user_birthday_day, uquery.send_sms_ad == false ? 0 : 1, uquery.adm_note, uquery.user_status, uquery.user_source, uquery.user_login_attempts, uquery.user_actkey, uquery.user_reg_date, uquery.user_updatedate,uquery.user_mobile);
            return sql.ToString();
        }
예제 #3
0
        public List<UserQuery> GetBonusList(UserQuery query, ref int totalCount)
        {

            try
            {
                return _usersDao.GetBonusList(query, out totalCount);
            }
            catch (Exception ex)
            {
                throw new Exception("UsersMgr-->GetBonusList-->" + ex.Message, ex);
            }
        }
예제 #4
0
        public HttpResponseBase SavePhone()
        {
            string jsonStr = string.Empty;
            UserQuery user = new UserQuery();
            HashEncrypt hmd5 = new HashEncrypt();
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["name"]))
                {
                    user.user_name = Request.Params["name"].ToString();
                }
                else
                {
                    user.user_name = "";
                }
                if (!string.IsNullOrEmpty(Request.Params["tel"]))
                {
                    if (!CommonFunction.isMobile(Request.Params["tel"].ToString()))
                    {
                        jsonStr = "{success:false,msg:0}";
                        this.Response.Clear();
                        this.Response.Write(jsonStr.ToString());
                        this.Response.End();
                        return this.Response;
                    }
                    else
                    {
                        //user.user_mobile = EncryptComputer.EncryptDecryptTextByApi(Request.Params["tel"].ToString());
                        user.user_mobile = Request.Params["tel"].ToString();
                    }
                    //if (user.user_mobile.Length < 10 || user.user_mobile.Substring(0, 2).ToString() != "09")
                    //{
                    //    for (int i = user.user_mobile.Length; i < 10; i++)
                    //    {
                    //        user.user_mobile = "0" + user.user_mobile;
                    //    }
                    //}
                }
                else
                {
                    user.user_mobile = "";
                }

                user.user_email = Request.Params["tel"] + "@user.gigade.com.tw";
                #region 獲取生日的年月日
                try
                {
                    DateTime birth = Convert.ToDateTime(Request.Params["birth"].ToString());
                    user.user_birthday_year = Convert.ToUInt32(birth.Year);
                    user.user_birthday_month = Convert.ToUInt32(birth.Month);
                    user.user_birthday_day = Convert.ToUInt32(birth.Day);
                }
                catch (Exception)
                {
                    user.user_birthday_year = 1970;
                    user.user_birthday_month = 0;
                    user.user_birthday_day = 0;
                }
                #endregion
                #region 密碼
                user.user_password = "******" + user.user_birthday_year;
                if (user.user_birthday_month.ToString().Length == 1)
                {
                    user.user_password += "0" + user.user_birthday_month;
                }
                else
                {
                    user.user_password += user.user_birthday_month;
                }
                if (user.user_birthday_day.ToString().Length == 1)
                {
                    user.user_password += "0" + user.user_birthday_day;
                }
                else
                {
                    user.user_password += user.user_birthday_day;
                }
                user.user_password = hmd5.SHA256Encrypt(user.user_password);
                #endregion
                if (!string.IsNullOrEmpty(Request.Params["zip"]))
                {
                    user.user_zip = Convert.ToUInt32(Request.Params["zip"].ToString());
                }
                else
                {
                    user.user_zip = 0;
                }
                if (!string.IsNullOrEmpty(Request.Params["address"]))
                {
                    user.user_address = Request.Params["address"].ToString();
                }
                else
                {
                    user.user_address = "";
                }
                if (!string.IsNullOrEmpty(Request.Params["IsAcceptAd"]))
                {
                    if (Request.Params["IsAcceptAd"].ToString() == "on")
                    {
                        user.send_sms_ad = true;
                    }
                }
                else
                {
                    user.send_sms_ad = false;
                }
                if (!string.IsNullOrEmpty(Request.Params["Remark"]))
                {
                    user.adm_note = Request.Params["Remark"].ToString();
                }
                else
                {
                    user.adm_note = "";
                }

                user.ip = Request.UserHostAddress;
                user.file_name = "UserPhone.chtml";

                user.created = DateTime.Now;
                user.kuser_id = Convert.ToUInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                mgr = new CallerMgr(mySqlConnectionString);
                Caller caller = new Caller();
                caller = mgr.GetUserById(Convert.ToInt32(user.kuser_id));
                user.kuser_name = caller.user_username;

                user.content = "user_email:" + user.user_email + ",user_mobile:" + user.user_mobile + ",user_birthday_year" + user.user_birthday_year + ",user_birthday_month" + user.user_birthday_month + ",user_birthday_day" + user.user_birthday_day + ",user_zip" + user.user_zip + ",user_address" + user.user_address + ",send_sms_ad" + user.send_sms_ad + ",adm_note" + user.adm_note;

                user.user_status = 1;
                user.user_source = "電話會員";
                user.user_login_attempts = 0;
                user.user_reg_date = Convert.ToUInt32(CommonFunction.GetPHPTime(DateTime.Now.ToString()));
                user.user_updatedate = Convert.ToUInt32(CommonFunction.GetPHPTime(DateTime.Now.ToString()));
                user.user_type = 2;

                _usmpgr = new UsersMgr(mySqlConnectionString);//實現方法
                if (_usmpgr.QueryByUserMobile(user.user_mobile).Rows.Count == 0)
                {
                    _usmpgr = new UsersMgr(mySqlConnectionString);
                    if (_usmpgr.SaveUserPhone(user) > 0)
                    {
                        jsonStr = "{success:true,msg:1}";
                    }
                    else
                    {
                        jsonStr = "{success:false,msg:2 }";
                    }
                }
                else
                {
                    jsonStr = "{success:false,msg:3 }";
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                jsonStr = "{success:false,msg:0}";
            }
            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }
예제 #5
0
        /// <summary>
        /// 通過郵箱獲取該用戶的信息
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase GetUserName()
        {
            UserQuery user = new UserQuery();
            List<UserQuery> userList = new List<UserQuery>();
            string user_email = "";
            uint group_id = 0;
            if (!string.IsNullOrEmpty(Request.Params["Email"]))
            {
                user_email = Request.Params["Email"];
            }
            if (!string.IsNullOrEmpty(Request.Params["group_id"]))
            {
                group_id = uint.Parse(Request.Params["group_id"]);
            }


            _usmpgr = new UsersMgr(mySqlConnectionString);
            string jsonStr = string.Empty;
            try
            {

                userList = _usmpgr.GetUserByEmail(user_email, group_id);
                if (userList.Count() > 0)//查詢到會員
                {
                    jsonStr = "{success:true,msg:\"" + 99 + "\"}";//該用戶已在此群組中
                }
                else
                {
                    userList = _usmpgr.GetUserByEmail(user_email, 0);
                    if (userList.Count() > 0)
                    {
                        jsonStr = "{success:true,msg:\"" + 100 + "\",user_id:'" + userList[0].user_id + "',user_name:'" + userList[0].user_name + "'}";//返回json數據
                    }
                    else
                    {
                        jsonStr = "{success:true,msg:\"" + 98 + "\"}";//此用戶不存在
                    }
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                jsonStr = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(jsonStr);
            this.Response.End();
            return this.Response;
        }
예제 #6
0
        public List<UserQuery> GetBonusList(UserQuery query, out int totalCount)
        {
            StringBuilder sql = new StringBuilder();
            StringBuilder sqlCondi = new StringBuilder();
            query.Replace4MySQL();
            try
            {
                sql.Append("select su.s_id, u.user_id,u.user_email,u.user_name,u.user_mobile,u.user_status");
                sql.Append(" ,u.user_reg_date,u.user_gender,user_company_id");
                sqlCondi.Append(" from users u");
                sqlCondi.Append(" left join sales_user su on u.user_id=su.user_id where 1=1");
                if (!string.IsNullOrEmpty(query.user_email))
                {
                    sqlCondi.AppendFormat(" and u.user_email like '%{0}%'", query.user_email);
                }
                if (!string.IsNullOrEmpty(query.user_name))
                {
                    sqlCondi.AppendFormat(" and u.user_name like '%{0}%'", query.user_name);
                }
                if (!string.IsNullOrEmpty(query.user_mobile))
                {
                    sqlCondi.AppendFormat(" and u.user_mobile like '%{0}%'", query.user_mobile);
                }
                if (query.is_select_status == 1)
                {
                    sqlCondi.AppendFormat(" and u.user_status={0}", query.user_status);
                }
                if (query.date_start != 0)
                {
                    sqlCondi.AppendFormat(" and u.user_reg_date>={0}", query.date_start);
                }
                if (query.date_end != 0)
                {
                    sqlCondi.AppendFormat(" and u.user_reg_date<={0}", query.date_end);
                }
                sqlCondi.Append(" order by u.user_id desc");
                totalCount = 0;
                if (query.IsPage)
                {
                    DataTable _dt = _accessMySql.getDataTable("select count(u.user_id) as totalCount " + sqlCondi.ToString());
                    if (_dt.Rows.Count > 0)
                    {
                        totalCount = int.Parse(_dt.Rows[0]["totalCount"].ToString());
                    }
                    sqlCondi.AppendFormat(" limit {0},{1}", query.Start, query.Limit);
                }

                sql.Append(sqlCondi.ToString());
                return _accessMySql.getDataTableForObj<UserQuery>(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("UsersDao.GetBonusList-->" + ex.Message + sql.ToString(), ex);
            }
        }