Exemple #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Client = new SalesforceClient(consumerKey, consumerSecret, callbackUrl);
            Client.AuthenticationComplete += (sender, e) => OnAuthenticationCompleted(e);

            var users = Client.LoadUsers();

            if (!users.Any())
            {
                var intent = Client.GetLoginInterface() as Intent;
                StartActivityForResult(intent, 42);
            }
            else
            {
                LoadAccounts();
            }

            ListView.ItemClick += (sender, e) => {
                var t = ((DataAdapter)ListAdapter)[e.Position];

                System.Diagnostics.Debug.WriteLine("Clicked on " + t.ToString());

                var intent = new Intent();
                intent.SetClass(this, typeof(DetailActivity));
                intent.PutExtra("JsonItem", "{\"attributes\": {\"type\": \"Account\", \"url\": \"/services/data/v28.0/sobjects/Account/\"}, " +
                                string.Format("\"Id\": \"{0}\", \"Name\": \"{1}\", \"AccountNumber\": \"{2}\", \"Phone\": \"{3}\", \"Website\": \"{4}\", \"Industry\": \"{5}\"", t.Id, t.Name, t.AccountNumber, t.Phone, t.Website, t.Industry) + "}");

                StartActivity(intent);
            };
        }
        protected override void OnStart()
        {
            Client = new SalesforceClient(ConsumerKey, ConsumerSecret, CallbackUrl);
            Client.AuthenticationComplete += OnComplete;

            Client.LoadUsers();                 // Load any user tokens that were saved to disk in a previous run

            if (Client.CurrentUser == null)
            {
                Platform.ShowUI(Client.GetLoginInterface());                 // no current user, show login UI
            }
            else
            {
                this.MainPage = new CampaignsPage();                 // user already logged in, show data page
            }
        }