Ejemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            employeeDirectory = new EmployeeDirectoryClient(WorklightClient.CreateInstance(this));

            SearchView search   = FindViewById <SearchView> (Resource.Id.searchView1);
            TextView   lblName  = FindViewById <TextView> (Resource.Id.lblName);
            TextView   lblEmail = FindViewById <TextView> (Resource.Id.lblEmail);
            TextView   lblPhone = FindViewById <TextView> (Resource.Id.lblPhone);

            search.QueryTextSubmit += async(object sender, SearchView.QueryTextSubmitEventArgs e) => {
                Employee employeeRecord = await employeeDirectory.FindEmployee(search.Query);

                if (employeeRecord != null)
                {
                    lblName.Text  = employeeRecord.Name;
                    lblEmail.Text = employeeRecord.Email;
                    lblPhone.Text = employeeRecord.Phone;
                }
                else
                {
                    lblName.Text  = "No Record Found";
                    lblEmail.Text = "";
                    lblPhone.Text = "";
                }
            };
        }
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();

            App.GetWorklightClient = WorklightClient.CreateInstance();

            LoadApplication(new App());

            return(base.FinishedLaunching(app, options));
        }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            App.WorklightClient = new SampleClient(WorklightClient.CreateInstance(this));

            LoadApplication(new App());
        }
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            App.GetWorklightClient = WorklightClient.CreateInstance(this);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            LoadApplication(new App());
        }
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            var splashDelay = Task.Delay(2000);

            global::Xamarin.Forms.Forms.Init();

            App.WorklightClient = new SampleClient(WorklightClient.CreateInstance(), WorklightPush.Instance);

            LoadApplication(new App());

            splashDelay.Wait();

            return(base.FinishedLaunching(app, options));
        }
Ejemplo n.º 6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Perform any additional setup after loading the view, typically from a nib.
            lblName.Text  = "";
            lblEmail.Text = "";
            lblPhone.Text = "";


            //
            // Create instance of MFP client
            //
            employeeDirectory = new EmployeeDirectoryClient(WorklightClient.CreateInstance());

            tbxSearch.ShouldReturn += (textField) => {
                tbxSearch.ResignFirstResponder();
                return(true);
            };

            tbxSearch.Ended += async delegate(object sender, EventArgs e) {
                Employee employeeRecord = await employeeDirectory.FindEmployee(tbxSearch.Text);

                if (employeeRecord != null)
                {
                    lblName.Text  = employeeRecord.Name;
                    lblEmail.Text = employeeRecord.Email;
                    lblPhone.Text = employeeRecord.Phone;
                }
                else
                {
                    lblName.Text  = "No record found";
                    lblEmail.Text = "";
                    lblPhone.Text = "";
                }
            };
        }
Ejemplo n.º 7
0
        //mfp initialilzing environment
        public async void setOffers()
        {
            var isConnected = false;

            //mobileFirst client
            if (mfpClient == null)
            {
                mfpClient = WorklightClient.CreateInstance(this);
            }

            System.Console.WriteLine("MFP before connect");

            //getting connection
            WorklightResponse task1 = await mfpClient.Connect();

            if (task1.Success)
            {
                Console.WriteLine("connected to MFP");

                logger = mfpClient.Logger("Xamarin: MainActivity.cs");

                logger.Info("connection from Android Plenty app established");
                //write to the server the connection status
                mfpClient.Analytics.Log("Connect response : " + task1.Success);
                isConnected = true;
            }
            else
            {
                Console.WriteLine("connection failed");
            }

            //accessing protected feedAdapter
            if (isConnected)
            {
                //adding challengehandler
                string           appRealm = "PlentyAppRealm";
                ChallengeHandler customCH = new CustomChallengeHandler(appRealm);
                mfpClient.RegisterChallengeHandler(customCH);
                System.Console.WriteLine("MFP before adapter");

                WorklightProcedureInvocationData invocationData =
                    new WorklightProcedureInvocationData(
                        "FeedAdapter", "getFeed", new object[] { "" });

                WorklightResponse task3 = await mfpClient.InvokeProcedure(invocationData);

                if (task3.Success)
                {
                    isInitialCall = false;
                    Console.WriteLine("adapter connected");
                    Console.WriteLine(task3.ResponseText.ToString());

                    logger.Info("FeedAdapter Accessed from Android Plenty app");
                    //write to the server the connection status
                    mfpClient.Analytics.Log("FeedAdapter response : " + task3.Success);
                }
                else
                {
                    Console.WriteLine("adapter failed");
                    Console.WriteLine(task3.ResponseJSON.ToString());

                    logger.Error("FeedAdapter FAILED from Android Plenty app");
                    //write to the server the connection status
                    mfpClient.Analytics.Log("FeedAdapter response : " + task3.ResponseText);
                }
            }
            //end of protected feedAdapter


            task1 = await mfpClient.Connect();

            if (task1.Success)
            {
                Console.WriteLine("connected to MFP");
                isConnected = true;
            }
            else
            {
                Console.WriteLine("connection failed");
            }


            //ACCESSING STRONGLOOP for Offers
            if (isConnected)
            {
                System.Console.WriteLine("MFP before SL url");

                //calling protected adapter (strongloop)

                /*WorklightProcedureInvocationData invocationData =
                 *      new WorklightProcedureInvocationData (
                 *              "SLAdapter", "getOffers", new object[] { "" });
                 *
                 * WorklightResponse task2 = await mfpClient.InvokeProcedure (invocationData);
                 */

                //calling protected url (strongLoop)
                WorklightResourceRequest resourceRequest = mfpClient.ResourceRequest(
                    new Uri(URL_STRONGLOOP + "Offers"), "GET");
                WorklightResponse task2 = await resourceRequest.Send();


                if (task2.Success)
                {
                    Console.WriteLine("strongloop url connected");
                    Console.WriteLine(task2.ResponseText.ToString());

                    logger.Info("Strongloop Accessed/Offers from Android Plenty app");
                    //write to the server the connection status
                    mfpClient.Analytics.Log("Strongloop response : " + task2.Success);

                    Plenty.Offers.offers = new List <OffersModel> {
                    };
                    JsonArray jsonArray = new JsonArray(task2.ResponseText);

                    Console.WriteLine(jsonArray.Count);
                    var myObjectList =
                        (List <Offer>)
                        JsonConvert.DeserializeObject(task2.ResponseText, typeof(List <Offer>));
                    foreach (Offer offer in myObjectList)
                    {
                        /*
                         * Console.WriteLine (offer.offername);
                         * Console.WriteLine (offer.offerdescription);
                         * Console.WriteLine (offer.offerpicture);
                         */

                        Plenty.Offers.offers.Add(new OffersModel(
                                                     offer.offername,
                                                     offer.offerdescription,
                                                     offer.offerpicture));
                    }
                }
                else
                {
                    Console.WriteLine("strongloop url failed");
                    Console.WriteLine(task2.ResponseText.ToString());

                    logger.Error("Strongloop FAILED on Offers from Android Plenty app");
                    //write to the server the connection status
                    mfpClient.Analytics.Log("Strongloop response : " + task2.ResponseText);

                    //dummy offers
                    Plenty.Offers.offers = new List <OffersModel> {
                        new OffersModel("potatoes", "For offers refer", "Potatoes.jpg"),
                        new OffersModel(
                            "Buy one get one free on salted nuts for the big game!",
                            "This offer entitles you to a free can of salted nuts for every can you purchase.  Limit 4.",
                            "offers/asparagus.jpg"),
                    };
                }
            }
            else
            {
                Console.WriteLine("connection for SL failed");
                //dummy offers
                logger.Error("Strongloop FAILED even on Connection to MFP? while on Offers from Android Plenty app");
                //write to the server the connection status
                mfpClient.Analytics.Log("FeedAdapter response : " + task1.ResponseText);

                Plenty.Offers.offers = new List <OffersModel> {
                    new OffersModel(
                        "Buy one get one free on salted nuts for the big game!",
                        "This offer entitles you to a free can of salted nuts for every can you purchase.  Limit 4.",
                        "NUTS.jpg"),
                };
            }             //end Strongloops for Offers


            task1 = await mfpClient.Connect();

            if (task1.Success)
            {
                Console.WriteLine("connected to MFP");
                isConnected = true;
            }
            else
            {
                Console.WriteLine("connection failed");
            }


            //ACCESSING STRONGLOOP for Events
            if (isConnected)
            {
                System.Console.WriteLine("MFP before SL url");
                //calling protected url (strongLoop)
                WorklightResourceRequest resourceRequest = mfpClient.ResourceRequest(
                    new Uri(URL_STRONGLOOP + "Events"), "GET");
                WorklightResponse task4 = await resourceRequest.Send();


                if (task4.Success)
                {
                    Console.WriteLine("strongloop url connected");
                    Console.WriteLine(task4.ResponseText.ToString());
                    logger.Info("Strongloop Accessed/Events from Android Plenty app");
                    //write to the server the connection status
                    mfpClient.Analytics.Log("Strongloop response : " + task4.Success);

                    Plenty.SpecialEvents.events = new List <EventsModel> {
                    };

                    JsonArray jsonArray = new JsonArray(task4.ResponseText);

                    Console.WriteLine(jsonArray.Count);
                    var myObjectList =
                        (List <Event>)JsonConvert.DeserializeObject(task4.ResponseText, typeof(List <Event>));
                    foreach (Event myevent in myObjectList)
                    {
                        Plenty.SpecialEvents.events.Add(new EventsModel(
                                                            myevent.offername,
                                                            myevent.offerdescription,
                                                            myevent.offerpicture));
                    }
                }
                else
                {
                    Console.WriteLine("strongloop url failed");
                    Console.WriteLine(task4.ResponseText.ToString());
                    logger.Error("Strongloop FAILED on Events from Android Plenty app");
                    //write to the server the connection status
                    mfpClient.Analytics.Log("Strongloop response : " + task4.ResponseText);
                    //dummy events
                    Plenty.SpecialEvents.events = new List <EventsModel> {
                        new EventsModel(
                            "Growler Fill-Up",
                            "Fill up your growler from a selection of local craft beers!",
                            "events/fillyourgrowler.jpg"),
                    };
                }
            }
            else
            {
                Console.WriteLine("connection for SL failed");
                logger.Error("Strongloop FAILED even on Connection to MFP? while on Offers from Android Plenty app");
                //write to the server the connection status
                mfpClient.Analytics.Log("FeedAdapter response : " + task1.ResponseText);
                //dummy offers
                Plenty.Offers.offers = new List <OffersModel> {
                    new OffersModel(
                        "Buy one get one free on salted nuts for the big game!",
                        "This offer entitles you to a free can of salted nuts for every can you purchase.  Limit 4.",
                        "NUTS.jpg"),
                };
            }
        }