protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            client = new JsonServiceClient("http://vmredisserver.cloudapp.net/api");

            PopulateSelectUsers();

            Spinner usersSpinner = FindViewById<Spinner>(Resource.Id.usersSpinner);
            usersSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => {
                TextView goalTextView = FindViewById<TextView>(Resource.Id.usersGoalTextView);
                TextView totalTextView = FindViewById<TextView>(Resource.Id.usersTotalTextView);

                var selectedUser = users[e.Position];
                goalTextView.Text = selectedUser.Goal.ToString();
                totalTextView.Text = selectedUser.Total.ToString();
            };

            //Adicionando novo usuario com a sua destinada meta de proteinas ao banco de dados.
            var addUserButton = FindViewById<Button>(Resource.Id.addNewUerButton);
            addUserButton.Click += (object sender, EventArgs e) =>
            {
                TextView nameTextView = FindViewById<TextView>(Resource.Id.nameTextView2);
                TextView goalTextView = FindViewById<TextView>(Resource.Id.goalTextView2);

                var goal = int.Parse(goalTextView.Text);

                var response = client.Send(new AddUser { Goal = goal, Name = nameTextView.Text });
                PopulateSelectUsers();                         

                nameTextView.Text = string.Empty;
                goalTextView.Text = string.Empty;

                Toast.MakeText(this, "Add New User", ToastLength.Short).Show();

            };


            //Addicionando proteinas (amount) ao usuario selecionado no Spinner
            var addProteinButton = FindViewById<Button>(Resource.Id.addProteinButton);
            addProteinButton.Click += (object sender, EventArgs e) =>
            {
                TextView amountTextView = FindViewById<TextView>(Resource.Id.amountTextView);
                var amount = int.Parse(amountTextView.Text);
                var selectedUser = users[usersSpinner.SelectedItemPosition];

                var response = client.Send(new AddProtein { Amount = amount, UserId = selectedUser.Id });
                selectedUser.Total = response.NewTotal;

                TextView totalTextView = FindViewById<TextView>(Resource.Id.usersTotalTextView);
                totalTextView.Text = selectedUser.Total.ToString();
                amountTextView.Text = string.Empty;

            };

        }
Example #2
0
 public static void Main(string[] args)
 {
     Console.Write("What is your name? ");
     var name = Console.ReadLine();
     var client = new JsonServiceClient("http://127.0.0.1:8080/servicestack");
     var response = client.Send<HelloResponse>(new Hello { Name = name });
     Console.WriteLine(response.Result);
 }
Example #3
0
        public static MessageResponse DoSendMessage(MessageOptions data)
        {
            JsonServiceClient client = new JsonServiceClient(ServiceUrl);
            //var client = new RestClient(ServiceUrl);

            var toSend = JsonSerializer.SerializeToString(data);
            MessageResponse response = client.Send<MessageResponse>("POST","createMessage",data);
            return response;
        }
Example #4
0
        public void Can_Authenticate_with_Metadata()
        {
            var client = new JsonServiceClient(BaseUri);

            var response = client.Send(new Authenticate
            {
                UserName = "******",
                Password = "******",
                Meta = new Dictionary<string, string> { { "custom", "metadata" } }
            });
        }
Example #5
0
        /// <summary>Login.</summary>
        ///
        /// <param name="userName">Name of the user.</param>
        /// <param name="password">The password.</param>
        ///
        /// <returns>A JsonServiceClient.</returns>
		public JsonServiceClient Login(string userName, string password)
		{
			var client = new JsonServiceClient(BaseUri);
			client.Send(new Auth {
				UserName = userName,
				Password = password,
				RememberMe = true,
			});

			return client;
		}
 public void T00_Test_authenticate_with_user1_json()
 {
     var restClient = new JsonServiceClient("http://localhost:25000/json/asynconeway/AuthenticateRequest");
     var response = restClient.Send<AuthenticateResponse>(
         new AuthenticateRequest()
         {
             Username = "******",
             Password = "******"
         }
     );
 }
Example #7
0
 private void Button_OnClicked(object sender, EventArgs e)
 {
     Button button = (Button)sender;
     var client = new JsonServiceClient("http://10.136.46.60:8088");
     var authResponse = client.Send<AuthenticateResponse>(new Authenticate
     {
         UserName = "******",
         Password = "******"
     });
     lblMessage.Text = "Logged in";
 }
 public void OnTestSetup()
 {
     _host = new ServiceTestAppHost();
     _host.Init();
     _host.Start(ServiceTestAppHost.BaseUrl);
     _client = new JsonServiceClient(ServiceTestAppHost.BaseUrl);
     IocBox.Kernel = new StandardKernel(new RealDomainModule(), new RealInfrastructureModule());
     string pass;
     _testUser = DbDataGenerator.AddUserToDatabase(out pass);
     _testBlueprint = DbDataGenerator.AddBlueprintToDatabase(_testUser.Id);
     _client.Send(new Auth {UserName = _testUser.Email, Password = pass});
 }
        public JsonServiceClient AuthenticateWithAdminUser()
        {
            var registration = CreateAdminUser();
            var adminServiceClient = new JsonServiceClient(BaseUri);
            adminServiceClient.Send<AuthResponse>(new Auth {
                UserName = registration.UserName,
                Password = registration.Password,
                RememberMe = true,
            });

            return adminServiceClient;
        }
Example #10
0
        public static void Main(string[] args)
        {
            string url = "http://localhost/autenticacion";

            using (JsonServiceClient client = new JsonServiceClient(url))
            {
                //var request = new LoginData { UserName="******", Password="******" };
                var request = new LoginData { UserName="******", Password="******" };
                var response = client.Send<LoginResponse>(request);
                Console.WriteLine(response.Success);

            }
        }
        static void Main(string[] args)
        {
            int amount = -1;
            JsonServiceClient client = null;
            client = new JsonServiceClient("http://localhost:4057") { UserName = "******", Password = "******" };
            var assignRResp = client.Send<AssignRolesResponse>(new AssignRoles
            {
                UserName = "******",
                Roles = new ArrayOfString("StatusUser"),
                Permissions = new ArrayOfString("GetStatus")
            });

            try
            {
                var repsspp = client.Send<StatusResponse>(new StatusQuery() { Date = DateTime.Now });
            }
            catch (WebServiceException ex)
            {
                if (ex.Message != null) { }
            }

            client.PostAsync<MagicResponse>(new MagicRequest { Id = 1 },
                resp => Console.WriteLine(resp.OutId), (resp, err) => { Console.WriteLine(err.Message); });

            while (amount != 0)
            {
                Console.WriteLine("Enter a protein amount (press 0 to exit)");
                if (int.TryParse(Console.ReadLine(), out amount))
                {
                    var response = client.Send<EntryResponse>(new Entry { Amount = amount, Time = DateTime.Now });
                    Console.WriteLine("Response, ID: " + response.Id);
                }
            }

            var reps2 = client.Post<StatusResponse>("status", new StatusQuery { Date = DateTime.Now });
            Console.WriteLine("{0} / {1}", reps2.Total, reps2.Goal);
            Console.WriteLine(reps2.Message);
            Console.ReadLine();
        }
        public void Can_register_a_new_user()
        {
            var client = new JsonServiceClient(ListeningOn);

            var response = client.Send(new Registration
            {
                UserName = "******",
                Password = "******",
                DisplayName = "New User",
                Email = "*****@*****.**",
                FirstName = "New",
                LastName = "User"
            });

            response.Should().NotBeNull();
            response.UserId.Should().NotBeNullOrEmpty();
        }
        public void SimpleTSPRoutingTest()
        {
            // creates the array of the routing hook.
            var hooks = new RoutingHook[4];

            // create the array of geocoordinates.
            var coordinates = new GeoCoordinate[]
                                  {
                                      new GeoCoordinate(51.09030, 3.44391),
                                      new GeoCoordinate(51.09002, 3.44380),
                                      new GeoCoordinate(51.089900970459, 3.44386267662048),
                                      new GeoCoordinate(51.0862655639648, 3.44465517997742)
                                  };

            // instantiate the routinghooK
            for (int idx = 0; idx < 4; idx++)
            {
                hooks[idx] = new RoutingHook()
                                 {
                                     Id = idx,
                                     Latitude = (float) coordinates[idx].Latitude,
                                     Longitude = (float) coordinates[idx].Longitude,
                                     Tags = new RoutingHookTag[0]
                                 };
            }

            // create Json client.
            var client = new JsonServiceClient("http://localhost:666/");
            client.Timeout = new TimeSpan(0, 5, 0);

            // set the request.
            var routingResponse = client.Send<RoutingResponse>(
                        new RoutingOperation()
                        {
                            Vehicle = VehicleEnum.Car,
                            Hooks = hooks,
                            Type = RoutingOperationType.TSP
                        });
        }
Example #14
0
        private bool PerformLogin(LoginEventArgs args)
        {
            using (var jsonClient = new JsonServiceClient(BaseUrl))
            {
                //jsonClient.SetCredentials("morten", "pass");
                jsonClient.HttpMethod = "POST";

                var login = new LoginUser
                                {
                                    Username = args.Username,
                                    Password = args.Password,
                                };
                var loginResponse = jsonClient.Send<LoginUserResponse>(login);
                if (loginResponse.Successful)
                {
                    _loginScreen.Enabled = false;
                    _loginScreen.Visible = false;
                }
                //jsonClient.AlwaysSendBasicAuthHeader = true;
                //jsonClient.SendOneWay(move);
            }
            return true;
        }
Example #15
0
        static void Main(string[] args)
        {
            int      iter               = 1;
            string   unitNumber         = "";
            int      meterReading       = -1;
            DateTime dt                 = DateTime.Now;
            double   fuelPurchaseAmount = -1;

            Console.WriteLine("Enter unit number:");
            unitNumber = Console.ReadLine();

            var client = new JsonServiceClient("http://localhost:57526/");

            while (iter > 0)
            {
                Console.WriteLine("Enter meter reading:");
                meterReading = int.Parse(Console.ReadLine());

                Console.WriteLine("Enter Fuel Purchase amount:");
                fuelPurchaseAmount = double.Parse(Console.ReadLine());

                var response = client.Send(
                    new Meter
                {
                    UnitNumber         = unitNumber,
                    Time               = dt,
                    MeterReading       = meterReading,
                    FuelPurchaseAmount = fuelPurchaseAmount
                });
                Console.WriteLine("Response : " + response.Id);

                Console.WriteLine("Enter 0 to stop enter meter reading");
                iter = int.Parse(Console.ReadLine());

                /* Async version
                 * client.SendAsync(
                 *  new Meter
                 *  {
                 *      UnitNumber = unitNumber,
                 *      Time = dt,
                 *      MeterReading = meterReading,
                 *      FuelPurchaseAmount = fuelPurchaseAmount
                 *  },
                 *  meterResponse => {
                 *      Console.WriteLine("Enter 0 to stop enter meter reading");
                 *      iter = int.Parse(Console.ReadLine());
                 *  },
                 *  (meterResponse, excpetion) => Console.WriteLine("Error: " + excpetion.Message)
                 * );
                 */
            }

            MeterQueryResponse meterQueryResponse = null;

            try
            {
                meterQueryResponse = client.Post(
                    new MeterQuery
                {
                    UnitNumber = unitNumber
                });
                Console.WriteLine("CurrentMeterReading : " + meterQueryResponse.CurrentMeterReading);
                Console.WriteLine("TotalFuelPurchaseAmount : " + meterQueryResponse.TotalFuelPurchaseAmount);
            }
            catch (WebServiceException ex)
            {
                Console.WriteLine(ex.ErrorMessage);
            }

            Console.WriteLine("Enter 0 to exit the program");
            iter = int.Parse(Console.ReadLine());
        }
Example #16
0
 public static void DeleteTabels()
 {
     var client   = new JsonServiceClient(ClientConect);
     var Response = client.Send(new DeleteAllTable {
     });
 }
Example #17
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            client = new JsonServiceClient("http://vmredisserver.cloudapp.net/api");

            PopulateSelectUsers();

            Spinner usersSpinner = FindViewById <Spinner>(Resource.Id.usersSpinner);

            usersSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => {
                TextView goalTextView  = FindViewById <TextView>(Resource.Id.usersGoalTextView);
                TextView totalTextView = FindViewById <TextView>(Resource.Id.usersTotalTextView);

                var selectedUser = users[e.Position];
                goalTextView.Text  = selectedUser.Goal.ToString();
                totalTextView.Text = selectedUser.Total.ToString();
            };

            //Adicionando novo usuario com a sua destinada meta de proteinas ao banco de dados.
            var addUserButton = FindViewById <Button>(Resource.Id.addNewUerButton);

            addUserButton.Click += (object sender, EventArgs e) =>
            {
                TextView nameTextView = FindViewById <TextView>(Resource.Id.nameTextView2);
                TextView goalTextView = FindViewById <TextView>(Resource.Id.goalTextView2);

                var goal = int.Parse(goalTextView.Text);

                var response = client.Send(new AddUser {
                    Goal = goal, Name = nameTextView.Text
                });
                PopulateSelectUsers();

                nameTextView.Text = string.Empty;
                goalTextView.Text = string.Empty;

                Toast.MakeText(this, "Add New User", ToastLength.Short).Show();
            };


            //Addicionando proteinas (amount) ao usuario selecionado no Spinner
            var addProteinButton = FindViewById <Button>(Resource.Id.addProteinButton);

            addProteinButton.Click += (object sender, EventArgs e) =>
            {
                TextView amountTextView = FindViewById <TextView>(Resource.Id.amountTextView);
                var      amount         = int.Parse(amountTextView.Text);
                var      selectedUser   = users[usersSpinner.SelectedItemPosition];

                var response = client.Send(new AddProtein {
                    Amount = amount, UserId = selectedUser.Id
                });
                selectedUser.Total = response.NewTotal;

                TextView totalTextView = FindViewById <TextView>(Resource.Id.usersTotalTextView);
                totalTextView.Text  = selectedUser.Total.ToString();
                amountTextView.Text = string.Empty;
            };
        }
Example #18
0
 public string GetData(Hello request)
 {
     JsonServiceClient client=new JsonServiceClient(BaseUri);
     var response = client.Send<HelloResponse>(request);
     return response.Result;
 }
Example #19
0
        public void ProcessRequest(HttpContext context)
        {
            string http = System.Web.Configuration.WebConfigurationManager.AppSettings["APIHttp"];

            IServiceClient client = new JsonServiceClient(http + "/SNSApi/");
            // IServiceClient client = new JsonServiceClient("http://education.istudy.sh.cn/SNSApi/");
            Guid   id      = Guid.Empty;
            string content = string.Empty;

            if (!string.IsNullOrEmpty(context.Request.QueryString["ID"]))
            {
                id = new Guid(context.Request.QueryString["ID"]);
            }
            if (!string.IsNullOrEmpty(context.Request.QueryString["Content"]))
            {
                content = HttpUtility.UrlDecode(context.Request.QueryString["Content"]);
            }


            UCHome_PersonNew pn = new UCHome_PersonNew();

            pn.AddUser    = id;
            pn.DeployTime = DateTime.Now;
            pn.Content    = content;
            pn.Hits       = 0;
            pn.PKID       = Guid.NewGuid();
            pn.Title      = content;
            pn.UCType     = "New";
            pn.IsShare    = "9";
            pn.IsAudit    = 0;
            pn.isTop      = 0;
            pn.IsShow     = 1;
            pn.flowers    = 0;
            UCHomeEntities uc = new UCHomeEntities();
            string         Newjson;

            try
            {
                uc.UCHome_PersonNew.AddObject(pn);
                uc.SaveChanges();
                UCHome_PersonNew pn2 = new UCHome_PersonNew();
                pn2.PKID       = Guid.NewGuid();
                pn2.AddUser    = pn.AddUser;
                pn2.UCType     = "static";
                pn2.Title      = "说说更新";
                pn2.Abstract   = string.Format("发表了新说说【{0}】({1})", pn.Title, pn.DeployTime);
                pn2.Content    = pn.Content;
                pn2.DeployTime = pn.DeployTime;
                pn2.IsShare    = pn.IsShare;
                pn2.IsShow     = 1;
                pn2.IsAudit    = 0;
                pn2.WriteFrom  = pn.UCType;
                pn2.flowers    = 0;
                uc.UCHome_PersonNew.AddObject(pn2);
                uc.SaveChanges();
                Newjson = "true";
                AddSNSFeedEntry feed = new AddSNSFeedEntry
                {
                    ObjectType = "说说",
                    ObjectID   = pn2.PKID.ToString(),
                    UID        = pn.AddUser.ToString(),
                    UName      = DisPlayName,
                    School     = XXMC,
                    Title      = "说说更新",
                    Summary    = pn.Content,
                    Date       = DateTime.Now,
                    //URL = "http://www.baidu.com",
                    Like     = 0,
                    Favorite = 0
                };
                client.Send <AddSNSFeedEntry>(feed);
            }
            catch (Exception ex)
            {
                Newjson = "false";
            }


            Newjson = string.Format("[{{ result:{0}}}]", Newjson);
            context.Response.ContentType = "text/plain";
            context.Response.Write(Newjson);
        }
        public void Does_use_request_binder_for_Send()
        {
            var response = client.Send <CustomRequestBinderResponse>(new CustomRequestBinder());

            Assert.That(response.FromBinder);
        }
Example #21
0
 public static MessageResponse DoSendMessage(MessageOptions data)
 {
     JsonServiceClient client = new JsonServiceClient(ServiceUrl);
     MessageResponse response = client.Send<MessageResponse>(JsonSerializer.SerializeToString(data));
     return response;
 }
Example #22
0
        protected virtual void ProcessRecordViaRest()
        {
            var client = new JsonServiceClient(ServiceUrl);

            if (Credential != null)
            {
                client.SetCredentials(Credential.UserName, Credential.Password.ToUnsecureString());
            }
            PowershellReponse response = null;

            try {
                // try connecting where the URL is the base URL
                response = client.Send <PowershellReponse>((this as T));

                if (response != null)
                {
                    if (!response.Warnings.IsNullOrEmpty())
                    {
                        foreach (var warning in response.Warnings)
                        {
                            WriteWarning(warning);
                        }
                    }

                    if (!response.Error.IsNullOrEmpty())
                    {
                        foreach (var error in response.Error.TakeAllBut(1))
                        {
                            WriteError(new ErrorRecord(new Exception("{0} - {1}".format(error.ExceptionType, error.ExceptionMessage)), error.Message, error.Category, null));
                        }
                    }

                    if (!response.Output.IsNullOrEmpty())
                    {
                        foreach (var ob in response.Output)
                        {
                            WriteObject(ob);
                        }
                    }

                    if (response.LastIsTerminatingError)
                    {
                        var error = response.Error.Last();
                        ThrowTerminatingError(new ErrorRecord(new Exception("{0} - {1}".format(error.ExceptionType, error.ExceptionMessage)), error.Message, error.Category, null));
                    }
                }
            } catch (WebServiceException wse) {
                switch (wse.StatusCode)
                {
                case 401:
                    if (Credential == null)
                    {
                        ThrowTerminatingError(new ErrorRecord(new Exception("Not Authenticated: you must supply credentials to access the remote service", wse), "", ErrorCategory.PermissionDenied, null));
                        return;
                    }
                    else
                    {
                        ThrowTerminatingError(new ErrorRecord(new Exception("Invalid Authentication: the given credentials are not valid with the remote service", wse), "", ErrorCategory.PermissionDenied, null));
                        return;
                    }

                case 403:
                    ThrowTerminatingError(new ErrorRecord(new Exception("Not Authorized: You are not authorized to access that remote service", wse), "", ErrorCategory.PermissionDenied, null));
                    return;

                case 404:
                    ThrowTerminatingError(new ErrorRecord(new Exception("Unknown Service: no remote service for {0} found at {1}".format(GetType().Name, ServiceStack.Text.StringExtensions.WithTrailingSlash(client.SyncReplyBaseUri) + GetType().Name), wse), "", ErrorCategory.ResourceUnavailable, null));
                    return;
                }

                ThrowTerminatingError(new ErrorRecord(new Exception("Unable to call remote cmdlet -- error: {0}".format(wse.Message), wse), "", ErrorCategory.NotSpecified, null));
            }
        }
Example #23
0
        public static void Main(string[] args)
        {
            string tipo;

            DateTime desde;
            DateTime hasta;
            DateTime hoy = DateTime.Today;

            if (args.Length > 0)
            {
                tipo = args[0].ToUpper();
            }
            else
            {
                tipo = "SEMANAL";
            }


            if (tipo == "SEMANAL")
            {
                desde = hoy.AddDays(-8);
                hasta = hoy.AddDays(-2);
            }

            else if (tipo == "MENSUAL")
            {
                int mes  = hoy.Month > 1 ? hoy.Month - 1: 12;
                int anio = hoy.Month > 1?  hoy.Year: hoy.Year - 1;

                desde = new DateTime(anio, mes, 1);
                hasta = new DateTime(anio, mes, DateTime.DaysInMonth(anio, mes));
            }
            else
            {
                Console.WriteLine("uso mono EstadoResultados.exe SEMANAL\nuso mono EstadoResultados.exe MENSUAL");
                return;
            }


            string url         = "http://localhost/autenticacion";
            string urlServicio = "http://localhost/servicio";

            using (JsonServiceClient client = new JsonServiceClient(url))
            {
                //var request = new LoginData { UserName="******", Password="******" };
                var request = new LoginData {
                    UserName = "******", Password = "******"
                };
                var response = client.Send <LoginResponse>(request);

                if (!response.Success)
                {
                    Console.WriteLine(response.ResponseStatus.Message);
                    return;
                }

                using (JsonServiceClient cl = new JsonServiceClient(urlServicio))
                {
                    CajaConsolidadoGet er = new CajaConsolidadoGet()
                    {
                        Desde     = desde,
                        Hasta     = hasta,
                        SessionId = response.Id,
                        SendMail  = true,
                    };

                    CajaConsolidadoGetResponse r = cl.Send <CajaConsolidadoGetResponse>(er);
                    if (!r.Success)
                    {
                        Console.WriteLine(r.ResponseStatus.Message);
                    }

                    LogoutData lo = new LogoutData()
                    {
                        SessionId = response.Id
                    };

                    client.Send <LogoutResponse>(lo);
                }
            }
            Console.WriteLine("This is The End my friend");
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

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

            client = new JsonServiceClient ("http://10.1.1.109/api");

            PopulateSelectUsers ();

            Spinner usersSpinner = FindViewById<Spinner> (Resource.Id.usersSpinner);
            usersSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) =>
            {
                var selectedUser = users[usersSpinner.SelectedItemPosition];
                TextView goalTextView = FindViewById<TextView> (Resource.Id.GoalTotal);
                TextView totalTextView = FindViewById<TextView> (Resource.Id.Total);

                goalTextView.Text = selectedUser.Goal.ToString();
                totalTextView.Text = selectedUser.Total.ToString();

            };

            // event for add user
            var addUserButton = FindViewById<Button> (Resource.Id.AddUser);
            addUserButton.Click += (object sender, EventArgs e) => {
                TextView goalTextView = FindViewById<TextView> (Resource.Id.Goal);
                TextView nameTextView = FindViewById<TextView> (Resource.Id.Name);
                var goal = int.Parse (goalTextView.Text);
                var response = client.Send (new AddUser { Goal = goal, Name = nameTextView.Text });

                PopulateSelectUsers ();
                goalTextView.Text = string.Empty;
                nameTextView.Text = string.Empty;

                Toast.MakeText (this, "Added new user", ToastLength.Short).Show();

            };

            // event for add Protein
            var addProteinButton = FindViewById<Button> (Resource.Id.AddProtein);
            addProteinButton.Click += (object sender, EventArgs e) => {
                TextView amountTextView = FindViewById<TextView> (Resource.Id.Amount);
                var amount = int.Parse(amountTextView.Text);
                var selectedUser = users[usersSpinner.SelectedItemPosition];

                var response = client.Send (new AddProtein { Amount = amount, UserID = selectedUser.Id });
                selectedUser.Total = response.NewTotal;
                TextView totalTextView = FindViewById<TextView> (Resource.Id.Total);
                totalTextView.Text = selectedUser.Total.ToString();
                amountTextView.Text = string.Empty;

                //string usermessage =  "Added Protein to :" & selectedUser.Name;

                Toast.MakeText (this, "Added Protein to :" + selectedUser.Name, ToastLength.Short).Show();

            };

            client.GetAsync<UserResponse>("users",(w2) => {
                Console.WriteLine(w2);
                foreach(var c in w2.Users) {
                    Console.WriteLine(c);
                    Console.WriteLine(c.Name);

                }
            },
            (w2, ex) => {
                Console.WriteLine(ex.Message);
            });
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            client = new JsonServiceClient("http://10.1.1.109/api");


            PopulateSelectUsers();

            Spinner usersSpinner = FindViewById <Spinner> (Resource.Id.usersSpinner);

            usersSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) =>
            {
                var      selectedUser  = users[usersSpinner.SelectedItemPosition];
                TextView goalTextView  = FindViewById <TextView> (Resource.Id.GoalTotal);
                TextView totalTextView = FindViewById <TextView> (Resource.Id.Total);

                goalTextView.Text  = selectedUser.Goal.ToString();
                totalTextView.Text = selectedUser.Total.ToString();
            };

            // event for add user
            var addUserButton = FindViewById <Button> (Resource.Id.AddUser);

            addUserButton.Click += (object sender, EventArgs e) => {
                TextView goalTextView = FindViewById <TextView> (Resource.Id.Goal);
                TextView nameTextView = FindViewById <TextView> (Resource.Id.Name);
                var      goal         = int.Parse(goalTextView.Text);
                var      response     = client.Send(new AddUser {
                    Goal = goal, Name = nameTextView.Text
                });

                PopulateSelectUsers();
                goalTextView.Text = string.Empty;
                nameTextView.Text = string.Empty;

                Toast.MakeText(this, "Added new user", ToastLength.Short).Show();
            };

            // event for add Protein
            var addProteinButton = FindViewById <Button> (Resource.Id.AddProtein);

            addProteinButton.Click += (object sender, EventArgs e) => {
                TextView amountTextView = FindViewById <TextView> (Resource.Id.Amount);
                var      amount         = int.Parse(amountTextView.Text);
                var      selectedUser   = users[usersSpinner.SelectedItemPosition];

                var response = client.Send(new AddProtein {
                    Amount = amount, UserID = selectedUser.Id
                });
                selectedUser.Total = response.NewTotal;
                TextView totalTextView = FindViewById <TextView> (Resource.Id.Total);
                totalTextView.Text  = selectedUser.Total.ToString();
                amountTextView.Text = string.Empty;

                //string usermessage =  "Added Protein to :" & selectedUser.Name;

                Toast.MakeText(this, "Added Protein to :" + selectedUser.Name, ToastLength.Short).Show();
            };



            client.GetAsync <UserResponse>("users", (w2) => {
                Console.WriteLine(w2);
                foreach (var c in w2.Users)
                {
                    Console.WriteLine(c);
                    Console.WriteLine(c.Name);
                }
            },
                                           (w2, ex) => {
                Console.WriteLine(ex.Message);
            });
        }
		public static AuthResponse Logout(JsonServiceClient client)
		{
			Auth request = new Auth { provider = "logout" };

			return client.Send<AuthResponse>(request);
		}
        public void Can_call_MoviesZip_WebService()
        {
            var client = new JsonServiceClient(ListeningOn);
            var request = new MoviesZip();
            var response = client.Send<MoviesZipResponse>(request);

            Assert.That(response.Movies.Count, Is.GreaterThan(0));
        }
Example #28
0
        public static void Main(string[] args)
        {
            string tipo;

            DateTime desde;
            DateTime hasta;
            DateTime hoy = DateTime.Today;

            if(args.Length>0)
                tipo= args[0].ToUpper();
            else
                tipo= "SEMANAL";

            if(tipo=="SEMANAL"){
                desde= hoy.AddDays(-8);
                hasta= hoy.AddDays(-2);
            }

            else if( tipo=="MENSUAL" ){
                int mes = hoy.Month >1 ? hoy.Month-1: 12 ;
                int anio =  hoy.Month >1?  hoy.Year: hoy.Year-1;

                desde= new DateTime(anio, mes, 1);
                hasta= new DateTime(anio, mes, DateTime.DaysInMonth(anio, mes) );
            }
            else{
                Console.WriteLine("uso mono EstadoResultados.exe SEMANAL\nuso mono EstadoResultados.exe MENSUAL");
                return;
            }

            string url = "http://localhost/autenticacion";
            string urlServicio = "http://localhost/servicio";

            using (JsonServiceClient client = new JsonServiceClient(url))
            {
                //var request = new LoginData { UserName="******", Password="******" };
                var request = new LoginData { UserName="******", Password="******" };
                var response = client.Send<LoginResponse>(request);

                if(!response.Success){
                    Console.WriteLine(response.ResponseStatus.Message);
                    return ;
                }

                using (JsonServiceClient cl = new JsonServiceClient(urlServicio))
                {
                    CajaConsolidadoGet er = new CajaConsolidadoGet()
                    {
                        Desde= desde,
                        Hasta= hasta,
                        SessionId= response.Id,
                        SendMail=true,
                    };

                    CajaConsolidadoGetResponse r = cl.Send<CajaConsolidadoGetResponse>(er);
                    if( ! r.Success ){
                        Console.WriteLine(r.ResponseStatus.Message);
                    }

                    LogoutData lo = new LogoutData(){
                        SessionId= response.Id
                    };

                    client.Send<LogoutResponse>(lo);
                }

            }
            Console.WriteLine("This is The End my friend");
        }
Example #29
0
        static void Main(string[] args)
        {
            int iter = 1;
            string unitNumber = "";
            int meterReading = -1;
            DateTime dt = DateTime.Now;
            double fuelPurchaseAmount = -1;

            Console.WriteLine("Enter unit number:");
            unitNumber = Console.ReadLine();

            var client = new JsonServiceClient("http://localhost:57526/");

            while (iter > 0)
            {

                Console.WriteLine("Enter meter reading:");
                meterReading = int.Parse(Console.ReadLine());

                Console.WriteLine("Enter Fuel Purchase amount:");
                fuelPurchaseAmount = double.Parse(Console.ReadLine());

                var response = client.Send(
                    new Meter
                    {
                        UnitNumber = unitNumber,
                        Time = dt,
                        MeterReading = meterReading,
                        FuelPurchaseAmount = fuelPurchaseAmount
                    });
                Console.WriteLine("Response : " + response.Id);

                Console.WriteLine("Enter 0 to stop enter meter reading");
                iter = int.Parse(Console.ReadLine());

                /* Async version
                client.SendAsync(
                    new Meter
                    {
                        UnitNumber = unitNumber,
                        Time = dt,
                        MeterReading = meterReading,
                        FuelPurchaseAmount = fuelPurchaseAmount
                    },
                    meterResponse => {
                        Console.WriteLine("Enter 0 to stop enter meter reading");
                        iter = int.Parse(Console.ReadLine());
                    },
                    (meterResponse, excpetion) => Console.WriteLine("Error: " + excpetion.Message)
                );
                */

            }

            MeterQueryResponse meterQueryResponse = null;
            try
            {
                meterQueryResponse = client.Post(
                    new MeterQuery
                    {
                        UnitNumber = unitNumber
                    });
                Console.WriteLine("CurrentMeterReading : " + meterQueryResponse.CurrentMeterReading);
                Console.WriteLine("TotalFuelPurchaseAmount : " + meterQueryResponse.TotalFuelPurchaseAmount);
            }
            catch (WebServiceException ex)
            {
                Console.WriteLine(ex.ErrorMessage);
            }

            Console.WriteLine("Enter 0 to exit the program");
            iter = int.Parse(Console.ReadLine());
        }
        public void GetBicyclesWithSeedData()
        {
            List<Bicycle> bicycles = null;
            "Given the seed data is created"
                .Given(() => { });

            "When a GET bicycles request is made using admin credentials"
                .When(() =>
                {
                    var restClient = new JsonServiceClient(BaseUrl);

                    restClient.Send(new Auth
                    {
                        provider = CredentialsAuthProvider.Name,
                        UserName = "******",
                        Password = "******",
                        RememberMe = true,
                    });

                    bicycles = restClient.Get(new GetBicycles());
                });

            "Then the response is not null."
                .Then(() =>
                {
                    Assert.NotNull(bicycles);
                });

            "And 4 bicycles are returned."
                .Then(() =>
                {
                    Assert.Equal(4, bicycles.Count);
                });
        }
Example #31
-1
        public HyperCommand(JsonServiceClient client ,Grandsys.Wfm.Services.Outsource.ServiceModel.Link link)
        {
            Content = link.Name;
            Command = new ReactiveAsyncCommand();
            Method = link.Method;
            Request = link.Request;
            Response = Command.RegisterAsyncFunction(_ => {

                Model.EvaluationItem response;
                if (string.IsNullOrEmpty(Method))
                    return null;

                switch (Method)
                {
                    default:
                        response = client.Send<Model.EvaluationItem>(Method, Request.ToUrl(Method), _ ?? Request);
                        break;
                    case "GET":
                        response = client.Get<Model.EvaluationItem>(Request.ToUrl(Method));
                        break;
                }
                return response;
            });
            Command.ThrownExceptions.Subscribe(ex => Console.WriteLine(ex.Message));
        }
        public static void Main(string[] args)
        {
            using (var client = new JsonServiceClient(address))
            {

                var response = client.Send<LayerListResponse>(new LayerList()
                    {
                        LayerName = "123"
                    });
                var response2 = client.Get(new LayerList()
                    {
                        LayerName = "Abc"
                    });
                var response3 = client.Get(new LayerListAll());

            }
        }