|
|
Rank: Aficionado
Joined: 7/23/2006 Posts: 172
|
I'm about to import members from an external datasource into Umbraco. And when new members are added into the external datasource it has to update the umbraco Members aswell
I have allready made this funktionality but when I add a new member to the external I want to make sure that it doesn't exist in Umbraco. to make these check I can only find these methods
if (umbraco.cms.businesslogic.member.Member.IsMember("login") == true) { ... } and there are the getmemberfrom... also but I want to compare to a property instead - is this possible somehow.
Søren Linaa Level 1 & 2 Certified Professional
|
|
 Rank: Umbracoholic
Joined: 7/20/2006 Posts: 1,076 Location: Charleston, West Virginia, United States
|
Søren, Email me at Casey[shift-2]neehouse.com, and I will help you with this if you are still in need of assistance. Thanks Case
• 2007/2008 MVP • 2008/2009 MVP • Certified • Licensing • Support • Development • Hosting •
|
|
Rank: Fanatic
Joined: 3/15/2007 Posts: 378 Location: Cary, NC USA
|
I'd be curious about this as well... I'm going to be looking into writing some type of application to handle member and group membership imports in the near future...
|
|
 Rank: Umbracoholic
Joined: 7/20/2006 Posts: 1,076 Location: Charleston, West Virginia, United States
|
here is some code I used for a CSV file. So, the fields array was result of a split call. Code: umbraco.cms.businesslogic.member.Member m = umbraco.cms.businesslogic.member.Member.MakeNew( fields[2].ToString().Trim(), //NAME fields[14].ToString().Trim().ToLower(), //EMAIL umbraco.cms.businesslogic.member.MemberType.GetByAlias("Contact"), //Member Type umbraco.BasePages.UmbracoEnsuredPage.CurrentUser); //USER ID to create against... can be 0.
m.getProperty("Contact").Value = fields[3].ToString().Trim(); m.getProperty("Address1").Value = fields[4].ToString().Trim(); m.getProperty("Address2").Value = fields[5].ToString().Trim(); m.getProperty("Address3").Value = fields[6].ToString().Trim(); m.getProperty("City").Value = fields[7].ToString().Trim(); m.getProperty("State").Value = fields[8].ToString().Trim(); m.getProperty("PostalCode").Value = fields[9].ToString().Trim();
//Group ID m.AddGroup(5368);
//Not sure if this is required or not. m.XmlGenerate(new System.Xml.XmlDocument());
• 2007/2008 MVP • 2008/2009 MVP • Certified • Licensing • Support • Development • Hosting •
|
|
Rank: Aficionado
Joined: 7/23/2006 Posts: 172
|
Hey Cassey I don't have any problems making a new member but to test if the member exist before making it again. There's some build in methods for this like Code: if (umbraco.cms.businesslogic.member.Member.IsMember("login" == true) { ... }
Code: if (umbraco.cms.businesslogic.member.Member.GetMemberFromLoginName(username.Text.Trim()) != null) { ... }
Code: if (umbraco.cms.businesslogic.member.Member.GetMemberFromEmail(email.Text) != null) { ... }
But is it possible to test it on a property -
Søren Linaa Level 1 & 2 Certified Professional
|
|
Rank: Devotee
Joined: 7/20/2006 Posts: 50 Location: Copenhagen, Denmark
|
Hi, I'm having som trouble adding members from c# When I execute the folowing code... Code:using System; using System.IO; using System.Web.UI; using umbraco.cms.businesslogic.member;
namespace WebApplication1 { public partial class _Default : System.Web.UI.Page { private void import() { Member m = Member.MakeNew("Martin", MemberType.GetByAlias("test"), new umbraco.BusinessLogic.User(0)); m.Save(); }
protected void Page_Load(object sender, EventArgs e) { import(); } } } ...I got an exception "The given key was not present in the dictionary". When I do it from Umbraco (using the same parameters), everything works fine. I'm using the latest source-code from Codeplex. My little webapplication use the same dll's as the umbraco, so I'm sure that it is the same code being executed both times. Any explanation to this ? Regards Martin Udblog.dk
|
|
|
Guest |