static void UpdateFamilyAttributes(Rock.Client.Group family, Rock.Client.GroupLocation address, List <KeyValuePair <string, string> > attributes, HttpRequest.RequestResult resultHandler) { // are there attributes? int pendingCompleteCount = 0; if (attributes != null && attributes.Count > 0) { // update each attribute foreach (KeyValuePair <string, string> attribValue in attributes) { // just fire and forget these values. FamilyManagerApi.UpdateOrAddFamilyAttribute(family.Id, attribValue.Key, attribValue.Value, delegate { // once we complete updating them (whether successful or not) we're done. pendingCompleteCount++; if (pendingCompleteCount == attributes.Count) { resultHandler(HttpStatusCode.OK, ""); } }); } } // no, so we're done else { resultHandler(HttpStatusCode.OK, ""); } }
static void TryUpdatePerson(bool isNewPerson, Rock.Client.Person person, bool isNewPhoneNumber, Rock.Client.PhoneNumber phoneNumber, List <KeyValuePair <string, string> > attributes, MemoryStream personImage, HttpRequest.RequestResult resultHandler) { // if they're a new person, flag them as a pending visitor. if (isNewPerson == true) { person.RecordStatusValueId = Settings.Rock_RecordStatusValueId_Pending; person.ConnectionStatusValueId = Settings.Rock_ConnectionStatusValueId_Visitor; } ApplicationApi.UpdateOrAddPerson(person, isNewPerson, Config.Instance.CurrentPersonAliasId, delegate(System.Net.HttpStatusCode statusCode, string statusDescription) { if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true) { // was this a new person? if (isNewPerson == true) { // then we need to get their profile so we know the ID to use for updating the rest of their stuff. TryGetNewlyCreatedProfile(person, isNewPhoneNumber, phoneNumber, attributes, personImage, resultHandler); } else { // now update pending attributes. foreach (KeyValuePair <string, string> attribValue in attributes) { // just fire and forget these values. FamilyManagerApi.UpdateOrAddPersonAttribute(person.Id, attribValue.Key, attribValue.Value, null); } // are we deleting an existing number? if (string.IsNullOrWhiteSpace(phoneNumber.Number) == true && isNewPhoneNumber == false) { TryDeleteCellPhone(person, phoneNumber, personImage, resultHandler); } // are we updating or adding an existing? else if (string.IsNullOrWhiteSpace(phoneNumber.Number) == false) { TryUpdateCellPhone(person, isNewPhoneNumber, phoneNumber, personImage, resultHandler); } else { TryUpdateProfilePic(person, personImage, resultHandler); } } } else { // error resultHandler(statusCode, statusDescription); } }); }
public void PerformSearch( ) { // is there something to search? if (SearchField.GetCurrentValue( ).Length > Settings.General_MinSearchLength) { SearchField.ResignFirstResponder( ); // disable the button, reset the results, and show the blocker SearchButton.Enabled = false; ClearResults( ); SearchField.ResignFirstResponder( ); Parent.BlockerView.BringToFront( ); Parent.BlockerView.Show( delegate { // search for the family RockApi.Get_Groups_FamiliesByPersonNameSearch(SearchField.GetCurrentValue( ), delegate(System.Net.HttpStatusCode statusCode, string statusDescription, List <Rock.Client.Family> model) { // re-enable the search button SearchButton.Enabled = true; // if results came back, populate our list if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true && model != null && model.Count > 0) { foreach (Rock.Client.Family family in model) { FamilyManagerApi.SortFamilyMembers(family.FamilyMembers); FamilyResult result = new FamilyResult(this, family); Results.Add(result); // tell our parent to re-layout so we position the results ParentView.SetNeedsLayout( ); } } else { // just create a single entry that represents a 'no result' entry FamilyResult result = new FamilyResult(this, null); Results.Add(result); ParentView.SetNeedsLayout( ); } Parent.BlockerView.Hide( ); }); }); } }
static void TryGetNewlyCreatedProfile(Rock.Client.Person person, bool isNewPhoneNumber, Rock.Client.PhoneNumber phoneNumber, List <KeyValuePair <string, string> > attributes, MemoryStream personImage, HttpRequest.RequestResult resultHandler) { ApplicationApi.GetPersonByGuid(person.Guid, delegate(System.Net.HttpStatusCode statusCode, string statusDescription, Rock.Client.Person model) { if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true) { person = model; // see if we should set their first time visit status if (Config.Instance.RecordFirstVisit == true) { FamilyManagerApi.UpdateOrAddPersonAttribute(person.Id, Config.Instance.FirstTimeVisitAttrib.Key, DateTime.Now.ToString( ), null); } // now update pending attributes. foreach (KeyValuePair <string, string> attribValue in attributes) { // just fire and forget these values. FamilyManagerApi.UpdateOrAddPersonAttribute(person.Id, attribValue.Key, attribValue.Value, null); } // if there's a phone number to send, send it. if (string.IsNullOrWhiteSpace(phoneNumber.Number) == false) { TryUpdateCellPhone(person, isNewPhoneNumber, phoneNumber, personImage, resultHandler); } else { TryUpdateProfilePic(person, personImage, resultHandler); } } else { resultHandler(statusCode, statusDescription); } }); }
void UIThread_ProfileComplete(System.Net.HttpStatusCode code, string desc, Rock.Client.Person model) { switch (code) { case System.Net.HttpStatusCode.OK: { // make sure they have an alias ID. if they don't, it's a huge bug, and we can't // let them proceed. if (model.PrimaryAliasId.HasValue) { Config.Instance.CurrentPersonAliasId = model.PrimaryAliasId.Value; // now ensure they are authorized FamilyManagerApi.GetAppAuthorization(model.Id, AuthorizationComplete); } else { // if we couldn't get their profile, that should still count as a failed login. SetUIState(LoginState.Out); // failed to login for some reason FadeLoginResult(true); LoginResult.Text = Strings.General_Error_Message; LoginResult.SizeToFit( ); } break; } default: { // if we couldn't get their profile, that should still count as a failed login. SetUIState(LoginState.Out); // failed to login for some reason FadeLoginResult(true); LoginResult.Text = Strings.General_Error_Message; LoginResult.SizeToFit( ); break; } } }