Checkbox Forums

Help
+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    ihill Guest

    Default Problems adding groups to invitation

    We created a API that runs nightly to create groups and add members. When we use the Invitations function to add these groups to a survey invitation, sometimes the result is that no group was added, sometimes the result is that the wrong group is added. Any one see this behavior? Suggestions?

  2. #2
    ncushing is offline Administrator
    Join Date
    Mar 2007
    Location
    Prezza Technologies
    Posts
    227

    Default

    Can you post the code you are using the create and send the invitation? That would help debug the issue.

  3. #3
    ihill Guest

    Default

    Code for adding groups.

    heapSortCheckboxGroup(checkboxGroupList, checkboxGroupList.Count - 1);
    for (int x = 0; x < itasSurveyGroupList.Count; x++)
    {
    int groupIDIdx = binaryCheckboxGroupSearch(checkboxGroupList, itasSurveyGroupList[x]._groupName);
    if (groupIDIdx == -1)
    {
    Group newGroup = Group.CreateGroup(itasSurveyGroupList[x]._groupName, itasSurveyGroupList[x]._groupDesc);
    Group.Commit(newGroup, surveyPrincipal);
    checkboxGroupList.Add(newGroup);
    itasSurveyGroupList[x]._groupID = newGroup.ID;
    itasSurveyGroupList[x]._updateGroup = true;
    logFile.WriteLine("*** Group Added to Checkbox Groups - groupID: " + itasSurveyGroupList[x]._groupID.ToString() + " | groupName: " + itasSurveyGroupList[x]._groupName);
    logFile.Flush();
    heapSortCheckboxGroup(checkboxGroupList, checkboxGroupList.Count - 1);
    }
    else if (itasSurveyGroupList[x]._groupID != checkboxGroupList[groupIDIdx].ID)
    {
    itasSurveyGroupList[x]._groupID = checkboxGroupList[groupIDIdx].ID;
    itasSurveyGroupList[x]._updateGroup = true;
    }
    }

    We are using checkbox V4.4.1.14 to send the invitations

  4. #4
    pwiesner is offline Administrator
    Join Date
    Mar 2007
    Posts
    385

    Default

    This appears to be only a subsection of the code. Would it be possible to obtain the portions which are responsible for creating users and invitations? If this is sensitive information please open a support ticket so that we can continue this conversation in private.

  5. #5
    ihill Guest

    Default

    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);
    }
    }

    }
    }

  6. #6
    pwiesner is offline Administrator
    Join Date
    Mar 2007
    Posts
    385

    Default

    Thank you for the additional code. Just so I am completely clear you are using the Checkbox web application and not the API to add groups to invitations, correct?

    Do the groups look accurate if you examine them in the Checkbox web application?

    Can you confirm that all users have email addresses? Users that do not have email addresses are not added to invitations.

  7. #7
    ihill Guest

    Post

    I've done more research into this issue. It seems to happen during two different scenarios:

    1. If I add a group from a page other than the first one.

    Example: I'll add a group from page 2 on row 4 and it will instead add the group from page 1 row 4.

    2. If I search for a group and add a group from the result set.

    Example: I'll seach for group A and if the result set is 2 rows with group A in row 2, add group A from the result set and the group added is whatever group is in the row 2 postion on the unfiltered search (original group list prior to search).

    Also everyone in the groups have valid email addresses

    Any suggestions on how to handle?
    Last edited by ihill; 10-06-2008 at 03:36 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO 3.5.0