Exemplo n.º 1
0
        public override void OnEnter()
        {
            if (!PlayMakerParseProxy.IsPropertyKeyValid(propertyKey.Value))
            {
                LogError("Property Key name invalid");
                Fsm.Event(errorEvent);
                Finish();
            }

            ParseQuery <ParseObject> _query = PlayMakerParseProxy.GetParseObjectQuery(queryId.Value);

            if (_query == null)
            {
                LogError("retrieving query failed");
                Fsm.Event(errorEvent);
                Finish();
            }

            if (where == ParseExistsClauses.Exists)
            {
                _query = _query.WhereExists(propertyKey.Value);
            }
            else if (where == ParseExistsClauses.DoesNotExist)
            {
                _query = _query.WhereDoesNotExist(propertyKey.Value);
            }

            PlayMakerParseProxy.CacheParseObjectQuery(queryId.Value, _query);

            Fsm.Event(successEvent);
            Finish();
        }
Exemplo n.º 2
0
        public override void OnEnter()
        {
            ParseObject _object;

            if (objectId.IsNone)
            {
                _object = ParseUser.CurrentUser;
            }
            else
            {
                _object = PlayMakerParseProxy.GetParseObject(objectId.Value);
            }

            if (_object == null)
            {
                Fsm.Event(errorEvent);
            }
            else
            {
                bool _isDataAvailable = _object.IsDataAvailable;
                isDataAvailable.Value = _isDataAvailable;

                if (_isDataAvailable)
                {
                    Fsm.Event(dataIsAvailableEvent);
                }
                else
                {
                    Fsm.Event(dataIsNotAvailableEvent);
                }
                Fsm.Event(successEvent);
            }

            Finish();
        }
Exemplo n.º 3
0
        public override void OnEnter()
        {
            ParseObject _object;

            if (objectId.IsNone)
            {
                _object = ParseUser.CurrentUser;
            }
            else
            {
                _object = PlayMakerParseProxy.GetParseObject(objectId.Value);
            }

            bool ok = PlayMakerParseProxy.SetParsePropertyFromFsmVar(_object, propertyKey.Value, this.Fsm, value);

            if (!ok)
            {
                Fsm.Event(errorEvent);
            }
            else
            {
                Fsm.Event(successEvent);
            }

            Finish();
        }
Exemplo n.º 4
0
        public override void OnEnter()
        {
            ParseObject _object;

            if (objectId.IsNone)
            {
                _object = ParseUser.CurrentUser;
            }
            else
            {
                _object = PlayMakerParseProxy.GetParseObject(objectId.Value);
            }

            if (_object == null)
            {
                Fsm.Event(errorEvent);
            }
            else
            {
                bool _isDirty = _object.IsDirty;
                isDirty.Value = _isDirty;

                if (_isDirty)
                {
                    Fsm.Event(isDirtyEvent);
                }
                else
                {
                    Fsm.Event(isNotDirtyEvent);
                }
                Fsm.Event(successEvent);
            }

            Finish();
        }
Exemplo n.º 5
0
        public override void OnEnter()
        {
            ParseObject _object;

            if (objectId.IsNone)
            {
                _object = ParseUser.CurrentUser;
            }
            else
            {
                _object = PlayMakerParseProxy.GetParseObject(objectId.Value);
            }

            if (_object == null)
            {
                Fsm.Event(errorEvent);
                Finish();
            }
            else
            {
                if (fetchOnlyIfNeeded.Value)
                {
                    _task = _object.FetchIfNeededAsync();
                }
                else
                {
                    _task = _object.FetchAsync();
                }
            }
        }
Exemplo n.º 6
0
        public override void OnUpdate()
        {
            if (_task.IsFaulted || _task.IsCanceled)
            {
                ParseException _e = PlayMakerParseProxy.GetParseException(_task.Exception);
                if (_e != null)
                {
                    if (_e.Code == ParseException.ErrorCode.ObjectNotFound)
                    {
                        Fsm.Event(noResultEvent);
                    }
                    else
                    {
                        LogWarning(_e.Code + " " + _e.Message);

                        Fsm.EventData.IntData    = (int)_e.Code;
                        Fsm.EventData.StringData = _e.Message;
                        Fsm.Event(errorEvent);
                    }
                }
                else
                {
                    Fsm.Event(errorEvent);
                }
                Finish();
            }
            else if (_task.IsCompleted)
            {
                resultObjectId.Value = PlayMakerParseProxy.CacheParseObject(_task.Result);

                Fsm.Event(successEvent);
                Finish();
            }
        }
Exemplo n.º 7
0
        public override void OnUpdate()
        {
            if (_task.IsFaulted || _task.IsCanceled)
            {
                isLoggedIn.Value = false;

                ParseException _e = PlayMakerParseProxy.GetParseException(_task.Exception);
                if (_e != null)
                {
                    Fsm.EventData.IntData    = (int)_e.Code;
                    Fsm.EventData.StringData = _e.Message;
                    Fsm.Event(errorEvent);
                }
                else
                {
                    Fsm.Event(errorEvent);
                }

                Finish();
            }
            else if (_task.IsCompleted)
            {
                isLoggedIn.Value = true;
                Fsm.Event(successEvent);
                Finish();
            }
        }
Exemplo n.º 8
0
        public override void OnEnter()
        {
            ParseObject _object;

            if (objectId.IsNone)
            {
                _object = ParseUser.CurrentUser;
            }
            else
            {
                _object = PlayMakerParseProxy.GetParseObject(objectId.Value);
            }

            if (_object == null)
            {
                Fsm.Event(errorEvent);
            }
            else
            {
                _object.Revert();
                Fsm.Event(successEvent);
            }

            Finish();
        }
Exemplo n.º 9
0
        public override void OnUpdate()
        {
            if (_task.IsFaulted || _task.IsCanceled)
            {
                ParseException _e        = PlayMakerParseProxy.GetParseException(_task.Exception);
                string         _eMessage = "";
                if (_e != null)
                {
                    _eMessage                = "ErrorCode:" + _e.Code + " ErrorMessage:" + _e.Message;
                    Fsm.EventData.IntData    = (int)_e.Code;
                    Fsm.EventData.StringData = _e.Message;
                    Fsm.Event(errorEvent);
                }
                else
                {
                    Fsm.Event(errorEvent);
                }


                LogError("Parse SaveAsync failed :" + _eMessage);

                Finish();
            }

            if (_task.IsCompleted)
            {
                objectId.Value = _object.ObjectId;
                PlayMakerParseProxy.CacheParseObject(_object);
                Fsm.Event(successEvent);
                Finish();
            }
        }
Exemplo n.º 10
0
 public override string ErrorCheck()
 {
     if (!PlayMakerParseProxy.IsPropertyKeyValid(propertyKey.Value))
     {
         return("Parse Property must only contain alphanumeric or underscore characters, and must begin with a letter");
     }
     return("");
 }
Exemplo n.º 11
0
        public override void OnEnter()
        {
            if (!PlayMakerParseProxy.IsPropertyKeyValid(className.Value))
            {
                LogWarning("Parse Class must only contain alphanumeric or underscore characters, and must begin with a letter");
                Fsm.Event(errorEvent);
                Finish();
                return;
            }

            _task = ParseObject.GetQuery(className.Value).GetAsync(objectId.Value);
        }
Exemplo n.º 12
0
        public override void OnEnter()
        {
            if (!PlayMakerParseProxy.IsPropertyKeyValid(orderBy.Value))
            {
                LogError("orderBy Class name invalid");
                Fsm.Event(errorEvent);
                Finish();
            }

            if (!thenBy.IsNone && !PlayMakerParseProxy.IsPropertyKeyValid(thenBy.Value))
            {
                LogError("thenBy Class name invalid");
                Fsm.Event(errorEvent);
                Finish();
            }


            ParseQuery <ParseObject> _query = PlayMakerParseProxy.GetParseObjectQuery(queryId.Value);

            if (_query == null)
            {
                LogError("retrieving query failed");
                Fsm.Event(errorEvent);
                Finish();
            }

            if (descending.Value)
            {
                _query = _query.OrderBy(orderBy.Value);
            }
            else
            {
                _query = _query.OrderByDescending(orderBy.Value);
            }

            if (!thenBy.IsNone)
            {
                if (thenByDescending.Value)
                {
                    _query = _query.ThenBy(thenBy.Value);
                }
                else
                {
                    _query = _query.ThenByDescending(thenBy.Value);
                }
            }

            PlayMakerParseProxy.CacheParseObjectQuery(queryId.Value, _query);

            Fsm.Event(successEvent);
            Finish();
        }
Exemplo n.º 13
0
        public override string ErrorCheck()
        {
            if (!PlayMakerParseProxy.IsPropertyKeyValid(orderBy.Value))
            {
                return("Parse order by name must only contain alphanumeric or underscore characters, and must begin with a letter");
            }

            if (!thenBy.IsNone && !PlayMakerParseProxy.IsPropertyKeyValid(thenBy.Value))
            {
                return("Parse order by name must only contain alphanumeric or underscore characters, and must begin with a letter");
            }
            return("");
        }
Exemplo n.º 14
0
        public override void OnEnter()
        {
            ParseObject _object;

            if (objectId.IsNone)
            {
                _object = ParseUser.CurrentUser;
            }
            else
            {
                _object = PlayMakerParseProxy.GetParseObject(objectId.Value);
            }

            bool ok = true;

            if (_object.ContainsKey(propertyKey.Value))
            {
                ParseObject _relationObject = _object.Get <ParseObject>(propertyKey.Value);

                if (_relationObject != null)
                {
                    relationObjectId.Value = PlayMakerParseProxy.CacheParseObject(_relationObject);
                }
                else
                {
                    ok = false;
                }

                if (fetchIfNeeded.Value)
                {
                    _task = _relationObject.FetchIfNeededAsync();
                    return;                     // we are asynch
                }
            }
            else
            {
                ok = false;
            }


            if (!ok)
            {
                Fsm.Event(errorEvent);
            }
            else
            {
                Fsm.Event(successEvent);
            }

            Finish();
        }
Exemplo n.º 15
0
        public override void OnEnter()
        {
            if (!PlayMakerParseProxy.IsPropertyKeyValid(className.Value))
            {
                LogError("Class name invalid");
                Fsm.Event(errorEvent);
                Finish();
            }

            _object = new ParseObject(className.Value);

            if (useAcl)
            {
                ParseUser _aclOwner;

                if (AclOwnerObjectId.IsNone)
                {
                    _aclOwner = ParseUser.CurrentUser;
                }
                else
                {
                    _aclOwner = (ParseUser)PlayMakerParseProxy.GetParseObject(AclOwnerObjectId.Value);
                }

                if (_aclOwner != null)
                {
                    _object.ACL = new ParseACL(_aclOwner)
                    {
                        PublicReadAccess  = AclReadAccess.Value,
                        PublicWriteAccess = AclWriteAccess.Value
                    };
                }
                else
                {
                    LogError("ACL Owner is null.If you target the current user, make sure a user is logged in");
                    Fsm.Event(errorEvent);
                    Finish();
                }
            }

            bool ok = PlayMakerParseProxy.SetParsePropertyFromFsmVar(_object, property.Value, this.Fsm, value);

            if (!ok)
            {
                LogError("Set parse property failed");
                Fsm.Event(errorEvent);
                Finish();
            }

            _task = _object.SaveAsync();
        }
Exemplo n.º 16
0
        public override void OnEnter()
        {
            if (!PlayMakerParseProxy.IsPropertyKeyValid(propertyKey.Value))
            {
                LogError("Property Key name invalid");
                Fsm.Event(errorEvent);
                Finish();
            }

            ParseQuery <ParseObject> _query = PlayMakerParseProxy.GetParseObjectQuery(queryId.Value);

            if (_query == null)
            {
                LogError("retrieving query failed");
                Fsm.Event(errorEvent);
                Finish();
            }

            if (where == ParseComparisonClauses.EqualTo)
            {
                _query = _query.WhereEqualTo(propertyKey.Value, PlayMakerParseProxy.GetParseValueFromFsmVar(this.Fsm, propertyValue));
            }
            else if (where == ParseComparisonClauses.NotEqualTo)
            {
                _query = _query.WhereNotEqualTo(propertyKey.Value, PlayMakerParseProxy.GetParseValueFromFsmVar(this.Fsm, propertyValue));
            }
            else if (where == ParseComparisonClauses.LessThan)
            {
                _query = _query.WhereLessThan(propertyKey.Value, PlayMakerParseProxy.GetParseValueFromFsmVar(this.Fsm, propertyValue));
            }
            else if (where == ParseComparisonClauses.LessThanOrEqualTo)
            {
                _query = _query.WhereLessThanOrEqualTo(propertyKey.Value, PlayMakerParseProxy.GetParseValueFromFsmVar(this.Fsm, propertyValue));
            }
            else if (where == ParseComparisonClauses.GreaterThan)
            {
                _query = _query.WhereGreaterThan(propertyKey.Value, PlayMakerParseProxy.GetParseValueFromFsmVar(this.Fsm, propertyValue));
            }
            else if (where == ParseComparisonClauses.GreaterThanOrEqualTo)
            {
                _query = _query.WhereGreaterThanOrEqualTo(propertyKey.Value, PlayMakerParseProxy.GetParseValueFromFsmVar(this.Fsm, propertyValue));
            }

            PlayMakerParseProxy.CacheParseObjectQuery(queryId.Value, _query);

            Fsm.Event(successEvent);
            Finish();
        }
Exemplo n.º 17
0
        public override void OnUpdate()
        {
            if (_task.IsFaulted || _task.IsCanceled)
            {
                Fsm.Event(errorEvent);
                Finish();
            }

            if (_task.IsCompleted)
            {
                PlayMakerParseProxy.CacheParseObject(_task.Result);

                Fsm.Event(successEvent);
                Finish();
            }
        }
Exemplo n.º 18
0
        public override void OnEnter()
        {
            if (!PlayMakerParseProxy.IsPropertyKeyValid(className.Value))
            {
                LogError("Class name invalid");
                Fsm.Event(errorEvent);
                Finish();
            }


            ParseQuery <ParseObject> _query = ParseObject.GetQuery(className.Value);

            if (_query == null)
            {
                LogError("Set parse property failed");
                Fsm.Event(errorEvent);
                Finish();
            }

            if (!limit.IsNone)
            {
                _query = _query.Limit(limit.Value);
            }

            if (!string.IsNullOrEmpty(include.Value))
            {
                _query = _query.Include(include.Value);
            }


            bool ok = PlayMakerParseProxy.CacheParseObjectQuery(queryId.Value, _query);

            if (!ok)
            {
                LogError("Parse Query could not be cached");
                Fsm.Event(errorEvent);
                Finish();
            }

            Fsm.Event(successEvent);
            Finish();
        }
Exemplo n.º 19
0
        public override void OnEnter()
        {
            ParseQuery <ParseObject> _query = PlayMakerParseProxy.GetParseObjectQuery(queryId.Value);

            if (_query == null)
            {
                Fsm.Event(errorEvent);
                Finish();
            }
            else
            {
                if (firstOrDefault.Value)
                {
                    _task = _query.FirstOrDefaultAsync();
                }
                else
                {
                    _task = _query.FirstAsync();
                }
            }
        }
Exemplo n.º 20
0
        public override void OnEnter()
        {
            if (!PlayMakerParseProxy.IsPropertyKeyValid(propertyKey.Value))
            {
                LogError("Property Key name invalid");
                Fsm.Event(errorEvent);
                Finish();
            }

            ParseQuery <ParseObject> _query = PlayMakerParseProxy.GetParseObjectQuery(queryId.Value);

            if (_query == null)
            {
                LogError("retrieving query failed");
                Fsm.Event(errorEvent);
                Finish();
            }

            if (where == ParseStringMatchClauses.Contains)
            {
                _query = _query.WhereContains(propertyKey.Value, propertyValue.Value);
            }
            else if (where == ParseStringMatchClauses.StartsWith)
            {
                _query = _query.WhereStartsWith(propertyKey.Value, propertyValue.Value);
            }
            else if (where == ParseStringMatchClauses.EndsWith)
            {
                _query = _query.WhereEndsWith(propertyKey.Value, propertyValue.Value);
            }
            else if (where == ParseStringMatchClauses.Matches)
            {
                _query = _query.WhereMatches(propertyKey.Value, propertyValue.Value, null);
            }

            PlayMakerParseProxy.CacheParseObjectQuery(queryId.Value, _query);

            Fsm.Event(successEvent);
            Finish();
        }
Exemplo n.º 21
0
        public override void OnUpdate()
        {
            if (_task.IsFaulted || _task.IsCanceled)
            {
                ParseException _e = PlayMakerParseProxy.GetParseException(_task.Exception);
                if (_e != null)
                {
                    Fsm.EventData.IntData    = (int)_e.Code;
                    Fsm.EventData.StringData = _e.Message;
                }

                Fsm.Event(errorEvent);
                Finish();
            }
            else if (_task.IsCompleted)
            {
                PlayMakerParseProxy.CacheParseObject(_task.Result);

                Fsm.Event(successEvent);
                Finish();
            }
        }
Exemplo n.º 22
0
        public override void OnEnter()
        {
            ParseObject _object;

            if (objectId.IsNone)
            {
                _object = ParseUser.CurrentUser;
            }
            else
            {
                _object = PlayMakerParseProxy.GetParseObject(objectId.Value);
            }

            if (_object == null)
            {
                Fsm.Event(errorEvent);
            }
            else
            {
                System.DateTime _createdAt = (System.DateTime)_object.CreatedAt;

                if (!createdAt.IsNone)
                {
                    createdAt.Value = _createdAt.ToString(dateTimeFormat.Value);
                }

                if (!createdAtUnixStamp.IsNone)
                {
                    var date          = new System.DateTime(1970, 1, 1, 0, 0, 0, _createdAt.Kind);
                    var unixTimestamp = System.Convert.ToInt64((_createdAt - date).TotalSeconds);

                    createdAtUnixStamp.Value = (float)unixTimestamp;
                }

                Fsm.Event(successEvent);
            }

            Finish();
        }
Exemplo n.º 23
0
 public void Start()
 {
     _instance = this;
 }
Exemplo n.º 24
0
 public override void OnEnter()
 {
     PlayMakerParseProxy.ClearCache();
 }
Exemplo n.º 25
0
 public void Start()
 {
     _instance = this;
 }