Exemplo n.º 1
0
        internal void VerifyAndSaveiOSReceiptInternal(string totalCost, int totalQuantity, bool useSandbox, string appleItemID,
                                                      string receiptData, string customTransactionID, string appData, Action <BuddyCallResult <bool> > callback)
        {
            if (string.IsNullOrEmpty(totalCost))
            {
                throw new ArgumentNullException("totalCost");
            }

            this.Client.Service.Commerce_Receipt_VerifyAndSaveiOSReceipt(this.Client.AppName, this.Client.AppPassword, this.AuthUser.Token,
                                                                         appleItemID, receiptData, customTransactionID, appData, totalCost, totalQuantity.ToString(), useSandbox ? "1" : "0", (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create(default(bool), bcr.Error));
                    return;
                }
                {
                    callback(BuddyResultCreator.Create(result == "1", bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 2
0
        internal void GetInternal(string albumName, Action <BuddyCallResult <PhotoAlbum> > callback)
        {
            if (String.IsNullOrEmpty(albumName))
            {
                throw new ArgumentNullException("albumName");
            }

            this.Client.Service.Pictures_PhotoAlbum_GetFromAlbumName(this.Client.AppName, this.Client.AppPassword, this.AuthUser.Token,
                                                                     this.AuthUser.ID.ToString(), albumName.ToString(), (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create <PhotoAlbum> (null, bcr.Error));
                    return;
                }
                if (result.Length == 0)
                {
                    callback(BuddyResultCreator.Create <PhotoAlbum> (null, bcr.Error));
                    return;
                }
                ;

                GetInternal(Int32.Parse(result [0].AlbumID), callback);
            });
            return;
        }
Exemplo n.º 3
0
        internal void CheckIfExistsInternal(string name, Action <BuddyCallResult <bool> > callback)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }

            this.Client.Service.GroupMessages_Manage_CheckForGroup(this.Client.AppName, this.Client.AppPassword, AuthUser.Token,
                                                                   name, (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create(default(bool), bcr.Error));
                    return;
                }
                if (result == "1")
                {
                    callback(BuddyResultCreator.Create(true, bcr.Error));
                    return;
                }
                else
                {
                    callback(BuddyResultCreator.Create(false, bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 4
0
        internal void GetInternal(string gameStateKey, Action <BuddyCallResult <GameState> > callback)
        {
            if (String.IsNullOrEmpty(gameStateKey))
            {
                throw new ArgumentException("gameStateKey", "Can't be null or empty.");
            }


            this.Client.Service.Game_State_Get(
                this.Client.AppName,
                this.Client.AppPassword,
                User.TokenOrId, gameStateKey, (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create <GameState> (null, bcr.Error));
                    return;
                }
                if (result.Length == 0)
                {
                    callback(BuddyResultCreator.Create <GameState> (null, bcr.Error));
                    return;
                }
                ;

                {
                    callback(BuddyResultCreator.Create(new GameState(result [0]), bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 5
0
        internal void AddInternal(string gameStateKey, string gameStateValue, string appTag, Action <BuddyCallResult <bool> > callback)
        {
            if (String.IsNullOrEmpty(gameStateKey))
            {
                throw new ArgumentException("gameStateKey", "Key can not be null or empty.");
            }
            if (gameStateValue == null)
            {
                throw new ArgumentNullException("gameStateValue", "Value can not be null.");
            }



            this.Client.Service.Game_State_Add(this.Client.AppName, this.Client.AppPassword, User.TokenOrId, gameStateKey, gameStateValue, appTag ?? "", (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None && bcr.Error != BuddyError.ServiceErrorNegativeOne)
                {
                    callback(BuddyResultCreator.Create(false, bcr.Error));
                    return;
                }
                callback(BuddyResultCreator.Create(result == "1", BuddyError.None));
                return;
            });
            return;
        }
Exemplo n.º 6
0
        internal void SendToastMessageInternal(string xmlPayload, int senderUserId, DateTime deliverAfter, string groupName, Action <BuddyCallResult <bool> > callback)
        {
            if (xmlPayload == null)
            {
                throw new ArgumentNullException("xmlPayload");
            }

            this.Client.Service.PushNotifications_Win8_SendToast(this.Client.AppName, this.Client.AppPassword, senderUserId.ToString(), xmlPayload,
                                                                 deliverAfter == DateTime.MinValue ? "" : deliverAfter.ToString(CultureInfo.InvariantCulture), groupName, (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create(default(bool), bcr.Error));
                    return;
                }
                if (result == "1")
                {
                    callback(BuddyResultCreator.Create(true, bcr.Error));
                    return;
                }
                else
                {
                    callback(BuddyResultCreator.Create(false, bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 7
0
        internal void AddPictureBatchInternal(List <PicturePublic> pictures, Action <BuddyCallResult <bool> > callback)
        {
            if (pictures == null || pictures.Count == 0)
            {
                throw new ArgumentException("Can't be null or empty.", "pictures");
            }

            string batch = "";

            foreach (var p in pictures)
            {
                batch += p.PhotoID + ";";
            }
            batch = batch.Substring(0, batch.Length - 1);

            this.Client.Service.Pictures_VirtualAlbum_AddPhotoBatch(this.Client.AppName, this.Client.AppPassword, this.AuthUser.Token, this.ID.ToString(),
                                                                    batch, (bcr) =>
            {
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create(default(bool), bcr.Error));
                    return;
                }
                {
                    callback(BuddyResultCreator.Create(true, bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 8
0
        internal void AddInternal(User user, string appTag, Action <BuddyCallResult <bool> > callback)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            this.Client.Service.Friends_FriendRequest_Add(this.Client.AppName, this.Client.AppPassword, this.AuthUser.Token, user.ID.ToString(), appTag, (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create(default(bool), bcr.Error));
                    return;
                }
                if (result == "1")
                {
                    callback(BuddyResultCreator.Create(true, bcr.Error));
                    return;
                }
                else
                {
                    callback(BuddyResultCreator.Create(false, bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 9
0
        internal void SendToastMessageInternal(string toastTitle, string toastSubtitle, int senderUserId, string toastParameter, DateTime deliverAfter, string groupName, Action <BuddyCallResult <bool> > callback)
        {
            if (toastTitle == null)
            {
                throw new ArgumentNullException("toastTitle");
            }
            if (toastSubtitle == null)
            {
                throw new ArgumentNullException("toastSubtitle");
            }
            if (toastParameter == null)
            {
                throw new ArgumentNullException("toastParameter");
            }

            this.Client.Service.PushNotifications_WP_SendToastMessage(this.Client.AppName, this.Client.AppPassword, senderUserId.ToString(), toastTitle, toastSubtitle, toastParameter,
                                                                      deliverAfter == DateTime.MinValue ? "" : deliverAfter.ToString(CultureInfo.InvariantCulture), groupName, (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None && bcr.Error != BuddyError.ServiceErrorNegativeOne)
                {
                    callback(BuddyResultCreator.Create(false, bcr.Error));
                    return;
                }
                callback(BuddyResultCreator.Create(result == "1", BuddyError.None));
                return;
            });
            return;
        }
Exemplo n.º 10
0
        internal void FindInternal(int searchDistanceInMeters, double latitude, double longitude, int recordLimit,
                                   string boardName, int onlyForLastNumberOfDays, int minimumScore, string rank, string appTag, Action <BuddyCallResult <List <GamePlayer> > > callback)
        {
            if (latitude > 90.0 || latitude < -90.0)
            {
                throw new ArgumentException("Can't be bigger than 90.0 or smaller than -90.0.", "atLatitude");
            }
            if (longitude > 180.0 || longitude < -180.0)
            {
                throw new ArgumentException("Can't be bigger than 180.0 or smaller than -180.0.", "atLongitude");
            }

            this.Client.Service.Game_Player_SearchPlayers(this.Client.AppName, this.Client.AppPassword, this.AuthUser.Token, recordLimit.ToString(),
                                                          onlyForLastNumberOfDays.ToString(), appTag == null ? "" : appTag, rank == null ? "" : rank, boardName == null ? "" : boardName, searchDistanceInMeters.ToString(),
                                                          latitude.ToString(CultureInfo.InvariantCulture), longitude.ToString(CultureInfo.InvariantCulture), (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create <List <GamePlayer> > (null, bcr.Error));
                    return;
                }
                List <GamePlayer> players = new List <GamePlayer> ();
                foreach (var d in result)
                {
                    players.Add(new GamePlayer(this.Client, this.AuthUser, d));
                }
                {
                    callback(BuddyResultCreator.Create(players, bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 11
0
        internal void AddInternal(string name, string board, string rank, double latitude, double longitude, string appTag, Action <BuddyCallResult <bool> > callback)
        {
            if (latitude > 90.0 || latitude < -90.0)
            {
                throw new ArgumentException("Can't be bigger than 90.0 or smaller than -90.0.", "atLatitude");
            }
            if (longitude > 180.0 || longitude < -180.0)
            {
                throw new ArgumentException("Can't be bigger than 180.0 or smaller than -180.0.", "atLongitude");
            }

            this.Client.Service.Game_Player_Add(this.Client.AppName, this.Client.AppPassword, this.AuthUser.Token, name, latitude.ToString(CultureInfo.InvariantCulture), longitude.ToString(CultureInfo.InvariantCulture), rank == null ? "" : rank,
                                                board == null ? "" : board, appTag == null ? "" : appTag, (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create(default(bool), bcr.Error));
                    return;
                }
                if (result == "1")
                {
                    callback(BuddyResultCreator.Create(true, bcr.Error));
                    return;
                }
                else
                {
                    callback(BuddyResultCreator.Create(false, bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 12
0
        internal void GetAllInternal(int recordLimit, Action <BuddyCallResult <List <GameScore> > > callback)
        {
            if (recordLimit <= 0)
            {
                throw new ArgumentException("Can't be smaller or equal to zero.", "recordLimit");
            }

            this.Client.Service.Game_Score_GetScoresForUser(this.Client.AppName, this.Client.AppPassword,
                                                            AuthUser != null ? AuthUser.Token : User.ID.ToString(), recordLimit.ToString(), (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create <List <GameScore> > (null, bcr.Error));
                    return;
                }
                List <GameScore> scores = new List <GameScore> ();
                foreach (var d in result)
                {
                    scores.Add(new GameScore(this.Client, d));
                }
                {
                    callback(BuddyResultCreator.Create(scores, bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 13
0
 internal void DeleteAllInternal(Action <BuddyCallResult <bool> > callback)
 {
     this.Client.Service.Game_Score_DeleteAllScoresForUser(this.Client.AppName, this.Client.AppPassword,
                                                           AuthUser != null ? AuthUser.Token : User.ID.ToString(), (bcr) =>
     {
         var result = bcr.Result;
         if (bcr.Error != BuddyError.None)
         {
             callback(BuddyResultCreator.Create(default(bool), bcr.Error));
             return;
         }
         if (result == "1")
         {
             callback(BuddyResultCreator.Create(true, bcr.Error));
             return;
         }
         else
         {
             callback(BuddyResultCreator.Create(false, bcr.Error));
             return;
         }
         ;
     });
     return;
 }
Exemplo n.º 14
0
        internal void CheckForValuesInternal(string values, Action <BuddyCallResult <List <IdentityItemSearchResult> > > callback)
        {
            if (String.IsNullOrEmpty(values))
            {
                throw new ArgumentException("Can't be null or empty.", "value");
            }

            this.Client.Service.UserAccount_Identity_CheckForValues(this.Client.AppName, this.Client.AppPassword, this.Token, values, (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create <List <IdentityItemSearchResult> > (null, bcr.Error));
                    return;
                }
                List <IdentityItemSearchResult> lst = new List <IdentityItemSearchResult> ();
                foreach (var d in result)
                {
                    lst.Add(new IdentityItemSearchResult(d.ValueFound, DateTime.MinValue, d.ValueFound == "1" ? true : false,
                                                         d.ValueFound == "1" ? Int32.Parse(d.UserProfileID) : -1));
                }
                {
                    callback(BuddyResultCreator.Create(lst, bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 15
0
        internal void BatchSumInternal(string forKeys, string withinDistance, double latitude, double longitude,
                                       int updatedMinutesAgo, string withAppTag, Action <BuddyCallResult <List <MetadataSum> > > callback)
        {
            if (withinDistance == "-1")
            {
                for (int i = 0; i < forKeys.Split(';').Length - 1; i++)
                {
                    withinDistance += ";-1";
                }
            }

            this.Client.Service.MetaData_ApplicationMetaDataValue_BatchSum(this.Client.AppName, this.Client.AppPassword,
                                                                           forKeys, withinDistance, latitude.ToString(CultureInfo.InvariantCulture), longitude.ToString(CultureInfo.InvariantCulture), updatedMinutesAgo.ToString(), withAppTag, (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create <List <MetadataSum> > (null, bcr.Error));
                    return;
                }
                List <MetadataSum> lst = new List <MetadataSum> ();
                foreach (var d in result)
                {
                    lst.Add(new MetadataSum(this.Client.TryParseDouble(d.TotalValue), Int32.Parse(d.KeyCount), d.MetaKey));
                }
                {
                    callback(BuddyResultCreator.Create(lst, bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 16
0
        internal void BatchSetInternal(string keys, string values, double latitude, double longitude, string appTag, Action <BuddyCallResult <bool> > callback)
        {
            if (string.IsNullOrEmpty(keys))
            {
                throw new ArgumentException("Can't be null.", "keys");
            }
            if (string.IsNullOrEmpty(values))
            {
                throw new ArgumentException("Can't be null.", "values");
            }

            this.Client.Service.MetaData_UserMetaDataValue_BatchSet(this.Client.AppName, this.Client.AppPassword, this.Token, keys, values, latitude.ToString(CultureInfo.InvariantCulture),
                                                                    longitude.ToString(CultureInfo.InvariantCulture), appTag, (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None && bcr.Error != BuddyError.ServiceErrorNegativeOne)
                {
                    callback(BuddyResultCreator.Create(false, bcr.Error));
                    return;
                }
                callback(BuddyResultCreator.Create(result == "1", BuddyError.None));
                return;
            });
            return;
        }
Exemplo n.º 17
0
        internal void GetInternal(string key, Action <BuddyCallResult <MetadataItem> > callback)
        {
            if (String.IsNullOrEmpty(key))
            {
                throw new ArgumentException("Can't be null or empty.", "key");
            }

            this.Client.Service.MetaData_ApplicationMetaDataValue_Get(this.Client.AppName, this.Client.AppPassword, key, (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create <MetadataItem> (null, bcr.Error));
                    return;
                }
                if (result.Length == 0)
                {
                    callback(BuddyResultCreator.Create <MetadataItem> (null, bcr.Error));
                    return;
                }
                ;

                InternalModels.DataContract_ApplicationMetaData d = result[0];
                {
                    callback(BuddyResultCreator.Create(new MetadataItem(this.Client, null, this, null, d.MetaKey, d.MetaValue,
                                                                        this.Client.TryParseDouble(d.MetaLatitude), this.Client.TryParseDouble(d.MetaLongitude), d.LastUpdateDate, null), bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 18
0
        internal void FindScoresInternal(User user, int distanceInMeters, double latitude,
                                         double longitude, int recordLimit, string boardName, int daysOld, double minimumScore, string appTag, Action <BuddyCallResult <List <GameScore> > > callback)
        {
            if (latitude > 90.0 || latitude < -90.0)
            {
                throw new ArgumentException("Can't be bigger than 90.0 or smaller than -90.0.", "atLatitude");
            }
            if (longitude > 180.0 || longitude < -180.0)
            {
                throw new ArgumentException("Can't be bigger than 180.0 or smaller than -180.0.", "atLongitude");
            }

            this.Client.Service.Game_Score_SearchScores(this.Client.AppName, this.Client.AppPassword, user == null ? "-1" : user.ID.ToString(),
                                                        distanceInMeters.ToString(), latitude.ToString(CultureInfo.InvariantCulture), longitude.ToString(CultureInfo.InvariantCulture), recordLimit.ToString(), boardName, daysOld.ToString(),
                                                        minimumScore.ToString(CultureInfo.InvariantCulture), appTag, (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create <List <GameScore> > (null, bcr.Error));
                    return;
                }
                List <GameScore> scores = new List <GameScore> ();
                foreach (var d in result)
                {
                    scores.Add(new GameScore(this.Client, d));
                }
                {
                    callback(BuddyResultCreator.Create(scores, bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 19
0
        internal void RegisterDeviceInternal(string appleDeviceToken, string groupName, Action <BuddyCallResult <bool> > callback)
        {
            if (String.IsNullOrEmpty(appleDeviceToken))
            {
                throw new ArgumentException("Can't be null or empty.", "appleDeviceToken");
            }

            this.Client.Service.PushNotifications_Apple_RegisterDevice(this.Client.AppName, this.Client.AppPassword, AuthUser.Token, groupName,
                                                                       appleDeviceToken, (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create(default(bool), bcr.Error));
                    return;
                }
                if (result == "1")
                {
                    callback(BuddyResultCreator.Create(true, bcr.Error));
                    return;
                }
                else
                {
                    callback(BuddyResultCreator.Create(false, bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 20
0
        internal void GetLowScoresInternal(string boardName, int recordLimit, Action <BuddyCallResult <List <GameScore> > > callback)
        {
            if (boardName == null)
            {
                throw new ArgumentNullException("boardName");
            }
            if (recordLimit <= 0)
            {
                throw new ArgumentException("Can't be smaller or equal to zero.", "recordLimit");
            }

            this.Client.Service.Game_Score_GetBoardLowScores(this.Client.AppName, this.Client.AppPassword,
                                                             boardName, recordLimit.ToString(), (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create <List <GameScore> >(null, bcr.Error));
                    return;
                }
                List <GameScore> scores = new List <GameScore>();
                foreach (var d in result)
                {
                    scores.Add(new GameScore(this.Client, d));
                }
                {
                    callback(BuddyResultCreator.Create(scores, bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 21
0
        internal void GetRegisteredDevicesInternal(string forGroup, int pageSize, int currentPage, Action <BuddyCallResult <List <RegisteredDeviceAndroid> > > callback)
        {
            if (pageSize <= 0)
            {
                throw new ArgumentException("Can't be smaller or equal to zero.", "pageSize");
            }
            if (currentPage <= 0)
            {
                throw new ArgumentException("Can't be smaller or equal to zero.", "currentPage");
            }

            this.Client.Service.PushNotifications_Android_GetRegisteredDevices(this.Client.AppName, this.Client.AppPassword,
                                                                               String.IsNullOrEmpty(forGroup) ? "" : forGroup, pageSize.ToString(), currentPage.ToString(), (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create <List <RegisteredDeviceAndroid> > (null, bcr.Error));
                    return;
                }
                List <RegisteredDeviceAndroid> lst = new List <RegisteredDeviceAndroid> ();
                foreach (var d in result)
                {
                    lst.Add(new RegisteredDeviceAndroid(d, this.AuthUser));
                }
                {
                    callback(BuddyResultCreator.Create(lst, bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 22
0
        internal void AddInternal(string friendlyName, string mimeType, string appTag, double latitude, double longitude, Stream blobData, Action <BuddyCallResult <long> > callback)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("BuddyApplicationName", this.Client.AppName);
            parameters.Add("BuddyApplicationPassword", this.Client.AppPassword);
            parameters.Add("UserToken", this.AuthUser.Token);
            parameters.Add("FriendlyName", friendlyName);
            parameters.Add("AppTag", appTag);
            parameters.Add("Latitude", latitude);
            parameters.Add("Longitude", longitude);
            parameters.Add("BlobData", new BuddyFile {
                Data        = blobData,
                ContentType = mimeType,
                Name        = "BlobData"
            });

            this.Client.Service.CallMethodAsync <string>("Blobs_Blob_AddBlob", parameters, (bcr) =>
            {
                long result = -1;
                if (bcr.Result != null)
                {
                    result = long.Parse(bcr.Result);
                }
                callback(BuddyResultCreator.Create(result, bcr.Error));
            });
        }
Exemplo n.º 23
0
        internal void GetAllInternal(Action <BuddyCallResult <Dictionary <string, GameState> > > callback)
        {
            this.Client.Service.Game_State_GetAll(this.Client.AppName, this.Client.AppPassword, User.TokenOrId,
                                                  (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create <Dictionary <string, GameState> > (null, bcr.Error));
                    return;
                }
                Dictionary <string, GameState> dict = new Dictionary <string, GameState> ();

                foreach (var d in result)
                {
                    dict [d.StateKey] = new GameState(d);
                }
                ;

                {
                    callback(BuddyResultCreator.Create(dict, bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 24
0
        internal void SetInternal(string key, string value, double latitude, double longitude, string appTag, Action <BuddyCallResult <bool> > callback)
        {
            if (String.IsNullOrEmpty(key))
            {
                throw new ArgumentException("Can't be null or empty.", "key");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            if (appTag == null)
            {
                appTag = "";
            }

            this.Client.Service.MetaData_ApplicationMetaDataValue_Set(this.Client.AppName, this.Client.AppPassword, key, value, latitude.ToString(CultureInfo.InvariantCulture),
                                                                      longitude.ToString(CultureInfo.InvariantCulture), appTag, (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None && bcr.Error != BuddyError.ServiceErrorNegativeOne)
                {
                    callback(BuddyResultCreator.Create(false, bcr.Error));
                    return;
                }
                callback(BuddyResultCreator.Create(result == "1", BuddyError.None));
                return;
            });
            return;
        }
Exemplo n.º 25
0
        internal void AddPictureWithWatermarkInternal(Stream photoStream, string comment, double latitude, double longitude, string appTag, string watermarkmessage, Action <BuddyCallResult <Picture> > callback)
        {
            if (photoStream == null || photoStream.Length == 0)
            {
                throw new ArgumentException("Can't be null or empty.", "blob");
            }

            this.Client.Service.Pictures_Photo_AddWithWatermark(this.Client.AppName, this.Client.AppPassword, this.AuthUser.Token, photoStream, this.AlbumId.ToString(), comment, latitude.ToString(CultureInfo.InvariantCulture), longitude.ToString(CultureInfo.InvariantCulture), appTag, watermarkmessage, (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create <Picture> (null, bcr.Error));
                    return;
                }
                this.AuthUser.GetPictureInternal(Int32.Parse(result), callback);

                {
                    callback(BuddyResultCreator.Create <Picture> (null, bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 26
0
 internal void FindInternal(int searchDistanceMeters, double latitude, double longitude, int numberOfResults,
                            string withKey, string withValue, int updatedMinutesAgo, double valueMin, double valueMax, bool searchAsFloat, bool sortAscending, bool disableCache, Action <BuddyCallResult <Dictionary <string, MetadataItem> > > callback)
 {
     this.Client.Service.MetaData_ApplicationMetaDataValue_SearchData(this.Client.AppName, this.Client.AppPassword, searchDistanceMeters.ToString(),
                                                                      latitude.ToString(CultureInfo.InvariantCulture), longitude.ToString(CultureInfo.InvariantCulture), numberOfResults.ToString(), withKey, withValue, updatedMinutesAgo.ToString(),
                                                                      valueMin.ToString(CultureInfo.InvariantCulture), valueMax.ToString(CultureInfo.InvariantCulture), searchAsFloat ? "1" : "", sortAscending ? "asc" : "desc", disableCache ? "true" : "", (bcr) =>
     {
         var result = bcr.Result;
         if (bcr.Error != BuddyError.None)
         {
             callback(BuddyResultCreator.Create <Dictionary <string, MetadataItem> > (null, bcr.Error));
             return;
         }
         Dictionary <string, MetadataItem> dict = new Dictionary <string, MetadataItem> ();
         foreach (var d in result)
         {
             dict.Add(d.MetaKey, new MetadataItem(this.Client, null, this, null, d, latitude, longitude));
         }
         {
             callback(BuddyResultCreator.Create(dict, bcr.Error));
             return;
         }
         ;
     });
     return;
 }
Exemplo n.º 27
0
        internal void GetAllInternal(DateTime afterDate, Action <BuddyCallResult <List <PhotoAlbum> > > callback)
        {
            this.Client.Service.Pictures_PhotoAlbum_GetAllPictures(this.Client.AppName, this.Client.AppPassword, this.AuthUser.Token,
                                                                   this.AuthUser.ID.ToString(), afterDate == DateTime.MinValue ? "1/1/1950" : afterDate.ToString(CultureInfo.InvariantCulture), (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create <List <PhotoAlbum> > (null, bcr.Error));
                    return;
                }
                Dictionary <string, PhotoAlbum> dict = new Dictionary <string, PhotoAlbum> ();
                foreach (var d in result)
                {
                    if (!dict.ContainsKey(d.AlbumID))
                    {
                        dict.Add(d.AlbumID, new PhotoAlbum(this.Client, this.AuthUser, Int32.Parse(d.AlbumID)));
                    }
                    dict [d.AlbumID].pictures.Add(new Picture(this.Client, d.FullPhotoURL, d.ThumbnailPhotoURL,
                                                              this.Client.TryParseDouble(d.Latitude), this.Client.TryParseDouble(d.Longitude), d.PhotoComment,
                                                              d.ApplicationTag, d.AddedDateTime, Int32.Parse(d.PhotoID), this.AuthUser));
                }
                ;

                {
                    callback(BuddyResultCreator.Create(dict.Values.ToList(), bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 28
0
        internal void SumInternal(string forKeys, int withinDistance, double latitude, double longitude,
                                  int updatedMinutesAgo, string withAppTag, Action <BuddyCallResult <MetadataSum> > callback)
        {
            this.Client.Service.MetaData_ApplicationMetaDataValue_Sum(this.Client.AppName, this.Client.AppPassword,
                                                                      forKeys, withinDistance.ToString(), latitude.ToString(CultureInfo.InvariantCulture), longitude.ToString(CultureInfo.InvariantCulture), updatedMinutesAgo.ToString(), withAppTag, (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create <MetadataSum> (null, bcr.Error));
                    return;
                }
                if (result.Length == 0)
                {
                    callback(BuddyResultCreator.Create <MetadataSum> (null, bcr.Error));
                    return;
                }
                ;

                {
                    callback(BuddyResultCreator.Create(new MetadataSum(String.IsNullOrEmpty(result [0].TotalValue) ? 0 : this.Client.TryParseDouble(result [0].TotalValue),
                                                                       Int32.Parse(result [0].KeyCount), forKeys), bcr.Error));
                    return;
                }
                ;
            });
            return;
        }
Exemplo n.º 29
0
        internal void GetInternal(int placeId, double latitude, double longitude, Action <BuddyCallResult <Place> > callback)
        {
            if (latitude > 90.0 || latitude < -90.0)
            {
                throw new ArgumentException("Can't be bigger than 90.0 or smaller than -90.0.", "atLatitude");
            }
            if (longitude > 180.0 || longitude < -180.0)
            {
                throw new ArgumentException("Can't be bigger than 180.0 or smaller than -180.0.", "atLongitude");
            }

            this.Client.Service.GeoLocation_Location_GetFromID(this.Client.AppName, this.Client.AppPassword, AuthUser.Token,
                                                               placeId.ToString(CultureInfo.InvariantCulture), latitude.ToString(CultureInfo.InvariantCulture), longitude.ToString(CultureInfo.InvariantCulture), (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None)
                {
                    callback(BuddyResultCreator.Create <Place> (null, bcr.Error));
                    return;
                }
                if (result.Length == 0)
                {
                    callback(BuddyResultCreator.Create <Place> (null, bcr.Error));
                    return;
                }
                else
                {
                    callback(BuddyResultCreator.Create(new Place(this.Client, this.AuthUser, result [0]), bcr.Error));
                    return;
                }
            });

            return;
        }
Exemplo n.º 30
0
        internal void SaveReceiptInternal(string totalCost, int totalQuantity, int storeItemID, string storeName,
                                          string receiptData, string customTransactionID, string appData, Action <BuddyCallResult <bool> > callback)
        {
            if (string.IsNullOrEmpty(totalCost))
            {
                throw new ArgumentNullException("totalCost");
            }
            if (string.IsNullOrEmpty(storeName))
            {
                throw new ArgumentNullException("storeName");
            }

            this.Client.Service.Commerce_Receipt_Save(this.Client.AppName, this.Client.AppPassword, this.AuthUser.Token,
                                                      receiptData, customTransactionID, appData, totalCost, totalQuantity.ToString(), storeItemID.ToString(), storeName, (bcr) =>
            {
                var result = bcr.Result;
                if (bcr.Error != BuddyError.None && bcr.Error != BuddyError.ServiceErrorNegativeOne)
                {
                    callback(BuddyResultCreator.Create(default(bool), bcr.Error));
                    return;
                }
                {
                    callback(BuddyResultCreator.Create(result == "1", bcr.Error));
                    return;
                }
                ;
            });
            return;
        }