Пример #1
0
        public static void GetGroupSummary(int groupId, OnGroupSummaryResult onResultHandler)
        {
            System.IO.MemoryStream familyPhoto = null;

            // first, get the group info
            RockApi.Get_CustomEndPoint <GroupInfo>(RockApi.BaseUrl + EndPoint_GroupInfo + groupId, delegate(HttpStatusCode statusCode, string statusDescription, GroupInfo model)
            {
                if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true)
                {
                    // get an image size appropriate for the device.
                    uint imageRes = (uint)Rock.Mobile.Graphics.Util.UnitToPx(512);
                    RockApi.Get_GetImage(model.FamilyPhotoGuid, imageRes, null, delegate(HttpStatusCode imageCode, string imageDescription, System.IO.MemoryStream imageStream)
                    {
                        // if the image didn't return successfully, just null it out.
                        if (Rock.Mobile.Network.Util.StatusInSuccessRange(imageCode) == false)
                        {
                            imageStream = null;
                        }
                        else
                        {
                            // otherwise, copy it. We must copy it because the imageStream
                            // will be going out of scope when we make the next Get_GetImage async call.
                            familyPhoto = new System.IO.MemoryStream( );

                            imageStream.CopyTo(familyPhoto);
                            familyPhoto.Position = 0;
                        }

                        // now try for the group photo
                        RockApi.Get_GetImage(model.GroupPhotoGuid, imageRes, null, delegate(HttpStatusCode groupImageCode, string groupImageDesc, System.IO.MemoryStream groupImageStream)
                        {
                            // if the image didn't return successfully, just null it out.
                            if (Rock.Mobile.Network.Util.StatusInSuccessRange(groupImageCode) == false)
                            {
                                groupImageStream = null;
                            }

                            // JHM Note: Enable this to debug the image size issue that's on certain devices.
                            //groupImageStream.CopyTo( leaderPhoto );
                            //groupImageStream.Position = 0;
                            //leaderPhoto.Position = 0;

                            // return ok whether they have a images or not (since they're not required)
                            onResultHandler(model, familyPhoto, groupImageStream);
                        });
                    });
                }
                // GROUP INFO fail
                else
                {
                    // return ok whether they have an image or not (since it's not required)
                    onResultHandler(null, null, null);
                }
            });
        }
Пример #2
0
        public static void GetPECampaign(int?personId, HttpRequest.RequestResult <JArray> resultHandler)
        {
            // if they're logged in, add their personId
            string endPoint = EndPoint_Campaign;

            if (personId.HasValue)
            {
                endPoint += "personId=" + personId.Value + "&";
            }

            RockApi.Get_CustomEndPoint <JArray>(RockApi.BaseUrl + endPoint + "campaignTypeList=" + PrivateGeneralConfig.PersonalizationEngine_MobileAppNewsFeed_Key, resultHandler);
        }
Пример #3
0
 public static void GetPersonData(string userID, OnPersonDataResult onResultHandler)
 {
     RockApi.Get_CustomEndPoint <PersonData>(RockApi.BaseUrl + EndPoint_PersonData + System.Net.WebUtility.UrlEncode(userID), delegate(HttpStatusCode statusCode, string statusDescription, PersonData model)
     {
         if (Util.StatusInSuccessRange(statusCode) == true)
         {
             onResultHandler(model, statusCode);
         }
         else
         {
             onResultHandler(null, statusCode);
         }
     });
 }
Пример #4
0
        public static void GetPublicGroupsByLocation(int groupTypeId, int locationId, int skip, int top, OnGroupsByLocationResult resultHandler)
        {
            string queryParams = string.Format("?locationId={0}&groupTypeId={1}&skip={2}&top={3}&publicOnly=true", locationId, groupTypeId, skip, top);

            RockApi.Get_CustomEndPoint <JArray>(RockApi.BaseUrl + EndPoint_GroupsByLocation + queryParams, delegate(HttpStatusCode statusCode, string statusDescription, JArray model)
            {
                if (Util.StatusInSuccessRange(statusCode) == true)
                {
                    resultHandler(model.ToObject <List <GroupSearchResult> >( ));
                }
                else
                {
                    resultHandler(null);
                }
            });
        }
Пример #5
0
        public static void IsRockAtURL(string url, HttpRequest.RequestResult onComplete)
        {
            // get the default person in Rock
            string fullUrl = url + "/api/People/1";

            RockApi.Get_CustomEndPoint <Rock.Client.Person>(fullUrl,
                                                            delegate(HttpStatusCode statusCode, string statusDescription, Rock.Client.Person person)
            {
                // if it returns, this is safely a Rock server.
                // we'll also consider it valid if it returns Unauthorized. I think its pretty safe to assume
                // that there won't be other servers out there (especially when people are TRYING to connect to Rock)
                // that just so happen to have an /api/people/{0} that returns Unauthorized.
                if ((Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) && person != null) || statusCode == HttpStatusCode.Unauthorized)
                {
                    onComplete(HttpStatusCode.OK, "");
                }
                // otherwise, Rock isn't here.
                else
                {
                    onComplete(HttpStatusCode.BadRequest, "");
                }
            });
        }
Пример #6
0
 public static void Get_LaunchData(HttpRequest.RequestResult <LaunchData> resultHandler)
 {
     // pull down launch data for the mobile app
     RockApi.Get_CustomEndPoint <LaunchData>(RockApi.BaseUrl + EndPoint_LaunchData, resultHandler);
 }