We are NOT using custom code to send invitations.
This is the code for adding members to checkbox:
IPrincipal myUserPrincipal;
IIdentity myUserIdentity;
for (int x = 0; x < itasSurveyMember.Count; x++)
{
heapSortCheckboxMemberList(checkboxRespondentsList , checkboxRespondentsList.Count - 1);
int respondentIDIdx = binaryCheckboxMemberListSearch(checkboxRespondents List, itasSurveyMember[x]._ITASSurveyUniqueIdentifier);
if (respondentIDIdx == -1)
{
try
{
myUserPrincipal = UserManager.GetUser(itasSurveyMember[x]._ITASSurveyUniqueIdentifier);
myUserIdentity = UserManager.GetUserIdentity(itasSurveyMember[x]._ITASSurveyUniqueIdentifier);
if (myUserPrincipal == null)
{
string status = string.Empty;
IIdentity myNewUserIdentiy = UserManager.CreateUser(itasSurveyMember[x]._ITASSurveyUniqueIdentifier, "PWD", out status);
myUserPrincipal = UserManager.GetUser(itasSurveyMember[x]._ITASSurveyUniqueIdentifier);
myUserIdentity = UserManager.GetUserIdentity(itasSurveyMember[x]._ITASSurveyUniqueIdentifier);
RoleManager.AddIdentityRole(myUserIdentity, 4);
UserManager.SetProfileProperty(myUserIdentity, "Email", itasSurveyMember[x]._STUINTEMAIL);
itasSurveyMember[x]._updateMember = true;
logFile.WriteLine("*** Member Added to Checkbox Member List - ITASSurveyUniqueIdentifier: " + itasSurveyMember[x]._ITASSurveyUniqueIdentifier);
logFile.Flush();
}
}
catch(Exception ex)
{
logFile.WriteLine("");
logFile.WriteLine("****** Begin CreateUser Error ****");
logFile.WriteLine("CreateUser - itasSurveyMember[x]._SSN: " + itasSurveyMember[x]._SSN + " itasSurveyMember[x]._ITASSurveyUniqueIdentifier: " + itasSurveyMember[x]._ITASSurveyUniqueIdentifier);
logFile.WriteLine("*** Error | Time : " + DateTime.Now.ToString() + "***");
logFile.WriteLine(ex.ToString());
logFile.WriteLine("****** End CreateUser Error ****");
logFile.WriteLine("");
logFile.Flush();
}
}
else
{
try
{
UserManager.SetProfileProperty(UserManager.GetUser Identity(itasSurveyMember[x]._ITASSurveyUniqueIdentifier), "Email", itasSurveyMember[x]._STUINTEMAIL);
}
catch(Exception ex)
{
logFile.WriteLine("");
logFile.WriteLine("****** Begin SetProfileProperty Error ****");
logFile.WriteLine("SetProfileProperty - itasSurveyMember[x]._ITASSurveyUniqueIdentifier: " + itasSurveyMember[x]._SSN + " checkboxRespondentsList[respondentIDIdx]: " + checkboxRespondentsList[respondentIDIdx]);
logFile.WriteLine("*** Error | Time : " + DateTime.Now.ToString() + "***");
logFile.WriteLine(ex.ToString());
logFile.WriteLine("****** End SetProfileProperty Error ****");
logFile.WriteLine("");
logFile.Flush();
}
}
}
This is the code for later adding the members to the groups
IPrincipal[] cbxGroupUsers;
string searchForAddToGroupName;
string searchForRemFromGroupName;
const string RESSTAT_R = "R";
const string INPSTAT_I = "I";
const string OUTSTAT_G = "G";
bool inMyGroup = false;
for(int x = 0; x < itasMembers.Count; x++)
{
for(int y = 0; y < itasMembers[x]._itasApplications.Count; y++)
{
searchForAddToGroupName = itasMembers[x]._itasApplications[y]._groupName + "EXRES";
searchForRemFromGroupName = itasMembers[x]._itasApplications[y]._groupName;
inMyGroup = false;
itasMembers[x]._itasApplications[y]._EXRES = "Y";
if(itasMembers[x]._itasApplications[y]._DOEXRES == "N")
{
itasMembers[x]._itasApplications[y]._EXRES = "N";
}
else if (itasMembers[x]._itasApplications[y]._RESSTAT == RESSTAT_R)
{
if (itasMembers[x]._itasApplications[y]._INPSTAT == INPSTAT_I || itasMembers[x]._itasApplications[y]._INPSTAT == "")
{
if (itasMembers[x]._itasApplications[y]._OUTSTAT == OUTSTAT_G || itasMembers[x]._itasApplications[y]._OUTSTAT == "")
{
itasMembers[x]._itasApplications[y]._EXRES = "N";
}
}
}
if (itasMembers[x]._itasApplications[y]._EXRES == "N")
{
heapSortCheckboxGroup(cbxGroups, cbxGroups.Count - 1);
int groupIDIdx = binaryCheckboxGroupSearch(cbxGroups, itasMembers[x]._itasApplications[y]._groupName);
if(groupIDIdx > 0)
{
cbxGroupUsers = cbxGroups[groupIDIdx].GetUsers();
for (int z = 0; z < cbxGroupUsers.Length; ++z)
{
if(itasMembers[x]._ITASSurveyUniqueIdentifier.Equals(cbxGroupUsers[z].Identity.Name))
{
inMyGroup = true;
}
}
if (!inMyGroup)
{
cbxGroups[groupIDIdx].AddUser(itasMembers[x]._ITASSurveyUniqueIdentifier);
Group.Commit(cbxGroups[groupIDIdx], pPrincipal);
}
}
}
else
{
heapSortCheckboxGroup(cbxGroups, cbxGroups.Count - 1);
int groupIDIdx = binaryCheckboxGroupSearch(cbxGroups, itasMembers[x]._itasApplications[y]._groupName);
if(groupIDIdx > 0)
{
cbxGroupUsers = cbxGroups[groupIDIdx].GetUsers();
for (int z = 0; z < cbxGroupUsers.Length; ++z)
{
if (itasMembers[x]._ITASSurveyUniqueIdentifier.Equals(cbxGroupUsers[z].Identity.Name))
{
inMyGroup = true;
}
}
if (inMyGroup)
{
cbxGroups[groupIDIdx].RemoveUser(itasMembers[x]._ITASSurveyUniqueIdentifier);
Group.Commit(cbxGroups[groupIDIdx], pPrincipal);
}
}
inMyGroup = false;
groupIDIdx = binaryCheckboxGroupSearch(cbxGroups, itasMembers[x]._itasApplications[y]._groupName + "~EXRES");
if(groupIDIdx == -1)
{
Group newGroup = Group.CreateGroup(itasMembers[x]._itasApplications[y]._groupName + "~EXRES", itasMembers[x]._itasApplications[y]._groupDesc + "~EXRES");
Group.Commit(newGroup, pPrincipal);
cbxGroups.Add(newGroup);
ITASSurveyGroup newITASSurveyGroup = new ITASSurveyGroup(newGroup.ID, newGroup.Name, newGroup.Description, itasMembers[x]._itasApplications[y]._QS, itasMembers[x]._itasApplications[y]._SITEID, itasMembers[x]._itasApplications[y]._FY, itasMembers[x]._itasApplications[y]._SCH, itasMembers[x]._itasApplications[y]._CRS, itasMembers[x]._itasApplications[y]._PHASE, itasMembers[x]._itasApplications[y]._CLS, "Y", itasMembers[x]._itasApplications[y]._TRACK, itasMembers[x]._itasApplications[y]._PROVIDER, true);
itasGroups.Add(newITASSurveyGroup);
logFile.WriteLine("*** Group Added to Checkbox Groups - groupID: " + newGroup.ID.ToString() + " | groupName: " + newGroup.Name);
logFile.Flush();
groupIDIdx = cbxGroups.Count - 1;
}
cbxGroupUsers = cbxGroups[groupIDIdx].GetUsers();
for (int z = 0; z < cbxGroupUsers.Length; ++z)
{
if (itasMembers[x]._ITASSurveyUniqueIdentifier.Equals(cbxGroupUsers[z].Identity.Name))
{
inMyGroup = true;
}
}
if (!inMyGroup)
{
cbxGroups[groupIDIdx].AddUser(itasMembers[x]._ITASSurveyUniqueIdentifier);
Group.Commit(cbxGroups[groupIDIdx], pPrincipal);
}
}
}
}
|