示例#1
0
 static void TryUpdateProfilePic(Rock.Client.Person person, MemoryStream personImage, HttpRequest.RequestResult resultHandler)
 {
     // is there a picture needing to be uploaded?
     if (personImage != null)
     {
         // upload
         ApplicationApi.UploadSavedProfilePicture(person, personImage, Config.Instance.CurrentPersonAliasId,
                                                  delegate(System.Net.HttpStatusCode statusCode, string statusDescription)
         {
             resultHandler(statusCode, statusDescription);
         });
     }
     else
     {
         resultHandler(HttpStatusCode.OK, "");
     }
 }
示例#2
0
                public void UploadSavedProfilePicture(HttpRequest.RequestResult result)
                {
                    // first open the image.
                    MemoryStream imageStream = (MemoryStream)FileCache.Instance.LoadFile(PrivateSpringboardConfig.ProfilePic);

                    // verify it's valid and not corrupt, or otherwise unable to load. If it is, we'll stop here.
                    if (imageStream != null)
                    {
                        // if upload is called, the profile image implicitely becomes dirty.
                        // that way if it fails, we can know to sync it on next run.
                        ProfileImageDirty = true;

                        ApplicationApi.UploadSavedProfilePicture(Person, imageStream, 0,
                                                                 delegate(System.Net.HttpStatusCode statusCode, string statusDescription)
                        {
                            // now we know that the profile image group was updated correctly, and that's the last step
                            if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true)
                            {
                                // so now we can finally flag everything as good
                                ProfileImageDirty = false;

                                SaveToDevice( );
                            }

                            if (result != null)
                            {
                                result(statusCode, statusDescription);
                            }
                        });
                    }
                    else
                    {
                        // the picture failed to save, so all we can do is say it was fine and
                        // that it is no longer dirty. Both things are true.
                        ProfileImageDirty = false;
                        result(System.Net.HttpStatusCode.OK, "");
                    }
                }