当在petshop中check out之后,会跳转到SignIn.aspx进行登录,之后执行Global.asax中的方法,将匿名用户转变为审核用户,并在Profile表和Cart表中将匿名用户的信息转变为登陆用户的信息。
通过执行Global.asax中的ProfileManager.DeleteProfile(e.AnonymousID); 然后跳转到PetShop.Profile.PetShopProfileProvider中的以下方法:
int deleteCount = 0;
foreach(string user in usernames)
if(DeleteProfile(user))
deleteCount++;
return deleteCount;
}
private static bool DeleteProfile(string username) {
CheckUserName(username);
return dal.DeleteProfile(username, applicationName);
}
执行PetShop.SQLProfileDAL.PetShopProfileProvider中的
int uniqueID = GetUniqueID(userName, false, true, appName);
string sqlDelete = "DELETE FROM Profiles WHERE UniqueID = @UniqueID;";
SqlParameter param = new SqlParameter("@UniqueId", SqlDbType.Int, 4);
param.Value = uniqueID;
int numDeleted = SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringProfile, CommandType.Text, sqlDelete, param);
if(numDeleted <= 0)
return false;
else
return true;
}
方法,删除匿名用户。