Esempio n. 1
0
        // 我的帳號
        public IActionResult Index()
        {
            var services    = HttpContext.RequestServices.GetServices <IB2dAccountRepository>();
            var accountRepo = services.First(o => o.GetType() == typeof(B2dAccountRepository));

            var account      = User.Identities.SelectMany(i => i.Claims.Where(c => c.Type == "Account").Select(c => c.Value)).FirstOrDefault();
            var countryRepos = HttpContext.RequestServices.GetService <CommonRepository>();
            var locale       = User.Identities.SelectMany(i => i.Claims.Where(c => c.Type == "Locale").Select(c => c.Value)).FirstOrDefault();

            B2dUserProfile _profile = accountRepo.GetProfile(account);

            _profile.USER_TYPE_DESC = _profile.USER_TYPE == "01" ? "管理者" : "使用者";

            ViewData["CountryAreas"]   = countryRepos.GetCountryAreas(locale);
            ViewData["CountryLocales"] = countryRepos.GetCountryLocales();

            //寄送mail
            //var aesUserData = User.Identities.SelectMany(i => i.Claims.Where(c => c.Type == ClaimTypes.UserData).Select(c => c.Value)).FirstOrDefault();
            //var UserData = JsonConvert.DeserializeObject<B2dAccount>(AesCryptHelper.aesDecryptBase64(aesUserData, Website.Instance.AesCryptKey));

            //var md5 = System.Security.Cryptography.MD5.Create();
            //var token = Sha256Helper.Gethash(UserData.EMAIL + UserData.TEL + "#BID%&*KK@auth");
            //var url = "https://*****:*****@kkday.com";
            //string from_name = "dora";
            //Dictionary<string, string> user = new Dictionary<string, string>();
            //user.Add("doraemon", "*****@*****.**");
            //string subject = "註冊已完成";
            //string body = "請點選連結:" + url + "以完成帳號啟用";

            return(View(_profile));
        }
Esempio n. 2
0
        // 取得分銷商「我的帳號」資訊
        public static B2dUserProfile GetProfile(string email)
        {
            try
            {
                string sqlStmt = @"SELECT a.xid, a.user_uuid, a.email, a.account_type,
 a.name_first, a.name_last, a.name_last || a.name_first AS name, a.department, a.gender_title, 
 a.job_title, a.tel, a.enable, b.xid AS comp_xid, b.comp_name, b.comp_tel_country_code, b.comp_invoice,
 b.comp_url, b.comp_address
FROM b2b.b2d_account a
JOIN b2b.b2d_company b ON a.company_xid=b.xid
WHERE a.email=:email";

                NpgsqlParameter[] sqlParams = new NpgsqlParameter[] {
                    new NpgsqlParameter("email", email)
                };

                DataSet ds = NpgsqlHelper.ExecuteDataset(Website.Instance.SqlConnectionString, CommandType.Text, sqlStmt, sqlParams);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = ds.Tables[0].Rows[0];

                    B2dUserProfile b2dAccount = new B2dUserProfile()
                    {
                        XID          = dr.ToInt64("xid"),
                        UUID         = dr.ToStringEx("user_uuid"),
                        EMAIL        = dr.ToStringEx("email"),
                        USER_TYPE    = dr.ToStringEx("account_type"),
                        NAME_FIRST   = dr.ToStringEx("name_first"),
                        NAME_LAST    = dr.ToStringEx("name_last"),
                        NAME         = dr.ToStringEx("name"),
                        DEPARTMENT   = dr.ToStringEx("department"),
                        GENDER_TITLE = dr.ToStringEx("gender_title"),
                        JOB_TITLE    = dr.ToStringEx("job_title"),
                        TEL          = dr.ToStringEx("tel"),
                        ENABLE       = dr.ToBoolean("enable"),
                        COMPANY_XID  = dr.ToInt64("comp_xid"),
                        COMPANY_NAME = dr.ToStringEx("comp_name"),
                        TEL_AREA     = dr.ToStringEx("comp_tel_country_code"),
                        INVOICE_NO   = dr.ToStringEx("comp_invoice"),
                        URL          = dr.ToStringEx("comp_url"),
                        ADDRESS      = dr.ToStringEx("comp_address")
                    };

                    return(b2dAccount);
                }
            }
            catch (Exception ex)
            {
                Website.Instance.logger.FatalFormat("{0}.{1}", ex.Message, ex.StackTrace);
                throw ex;
            }

            return(null);
        }
Esempio n. 3
0
        // 取拿Token用帳密
        public static B2dUserProfile GetApiAccount(Int64 xid)
        {
            B2dUserProfile account = ApiAccountDAL.GetAccount_Api(xid);

            return(account);
        }