I need to change the property value of a boolean i got on the members, and set them to true / false based on data in a CSV file. Kinda like so:
if(PhoneNumberFromCsvFile == member.property("phoneNumber"){
//Do nothing as property is false by default
}else{
//Set property to TRUE
}
(I'm aware the syntax is not correct, and that you should not have a empty if block like so, but hey, it's just so get the gist of what im trying to accomplish here.)
I tried using Member.GetAllAsList(), and do a foreach; but it ended up taking like 5 seconds each time it iterated. (..and with nearly 100k members, pretty much no-go).
Well, this was just something i sketched, so it's not.. exactly optimized!
public void SetReceiveSmsFromCsv()
{
var numbers = System.IO.File.ReadAllLines(@"C:\Users\Documents\GitHub\receiveSMSList.csv");
var members = Member.GetAllAsList();
bool found = false;
foreach(var member in members)
{
found = false;
foreach (var number in numbers)
{
if (member.getProperty("phone").Value.ToString().Contains(number))
{
found = true;
break;
}
}
if (!found)
{
member.getProperty("recieveSms").Value = true;
member.Save();
}
}
}
Change a property value on all members
Hi!
I need to change the property value of a boolean i got on the members, and set them to true / false based on data in a CSV file. Kinda like so:
(I'm aware the syntax is not correct, and that you should not have a empty if block like so, but hey, it's just so get the gist of what im trying to accomplish here.)
I tried using Member.GetAllAsList(), and do a foreach; but it ended up taking like 5 seconds each time it iterated. (..and with nearly 100k members, pretty much no-go).
Someone know of a quicker way to do this?
All help is appreciated! :-)
Can you post your entire code.
Dave
Well, this was just something i sketched, so it's not.. exactly optimized!
Hi,
Code seems okay. What line of code is slow. Is it the updating of the property or getting all the members ?
Dave
is working on a reply...