Example #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

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

            Button            btnLock   = FindViewById <Button>(Resource.Id.buttonLock);
            Button            btnUnlock = FindViewById <Button>(Resource.Id.buttonUnlock);
            RestClientService client    = new RestClientService();

            GetLocationPermissionAsync();

            btnLock.Click += (sender, e) =>
            {
                string response = client.SendLockRequest();
                if (!string.IsNullOrEmpty(response))
                {
                    Toast.MakeText(this, response, ToastLength.Short).Show();
                }
            };

            btnUnlock.Click += (sender, e) =>
            {
                string response = client.SendUnlockRequest();
                if (!string.IsNullOrEmpty(response))
                {
                    Toast.MakeText(this, response, ToastLength.Short).Show();
                }
            };
        }
Example #2
0
        public RocketChat(string serverUrl)
        {
            IRestClient            restClient            = new RestClient(serverUrl);
            IJsonSerializer        jsonSerializer        = new JsonSerializer();
            IAuthHelper            authHelper            = new AuthHelper();
            IRestClientService     restClientService     = new RestClientService(authHelper, restClient, jsonSerializer);
            IFileRestClientService fileRestClientService = new FileRestClientService(authHelper, restClient, jsonSerializer);
            IAuthenticationService authService           = new AuthenticationService(authHelper, restClientService);
            IChannelsService       channelsService       = new ChannelsService(restClientService);
            IGroupsService         groupsService         = new GroupsService(restClientService);
            IUsersService          usersService          = new UsersService(restClientService);
            IChatService           chatService           = new ChatService(restClientService);
            IRoomService           roomService           = new RoomService(restClientService);
            IAssetsService         assetsService         = new AssetsService(restClientService);
            IAutoTranslateService  autoTranslateService  = new AutoTranslateService(restClientService);
            ICommandsService       commandsService       = new CommandsService(restClientService);
            IEmojisService         emojisService         = new EmojisService(restClientService, fileRestClientService);

            Api = new RocketChatApi(
                chatService,
                usersService,
                groupsService,
                channelsService,
                authService,
                roomService,
                assetsService,
                autoTranslateService,
                commandsService,
                emojisService);
        }
Example #3
0
        public MembersViewModel()
        {
            ListMembers = RestClientService.GetListMembers();
            _proto      = new ProtobufContext(new piwcldbEntities());
            _proto.Executor <member>();

            ListMembers = _proto.Context <member>();
        }
Example #4
0
        /// <summary>
        /// Bind to TestProject config data and set the current config
        /// </summary>
        public void TestProjecReset()
        {
            RestClientService.ResetHttpClient();
            TestData          data   = new TestData();
            IHasRestApiConfig config = data.Clone();

            RestClientService.SetConfig(config);
        }
Example #5
0
        public OrderPage()
        {
            InitializeComponent();

            restClient = new RestClientService <ItemCategories>();

            InitializeListView();
            lstItemCategories.ItemSelected += ItemsCategory_ItemSelected;
        }
Example #6
0
        /// <summary>
        /// Called when the action is executing.
        /// </summary>
        /// <param name="filterContext">The filter context of the action executing.</param>
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var restClientService = new RestClientService(Constants.Risi)
            {
                Accept      = Constants.ApplicationXml,
                Credentials = new AmiCredentials(this.User, HttpContext.Request)
            };

            this.RisiClient = new RisiServiceClient(restClientService);

            base.OnActionExecuting(filterContext);
        }
        public async Task ExecuteGetDeviceInfo()
        {
            RestClientService restClientService = new RestClientService();

            BoardInfo = new Board();

            try
            {
                //TODO: clean up after working test
                BoardInfo = await restClientService.GetBoardInfo(DeviceIpAddress.Trim());

                if (BoardInfo == null)
                {
                    IsBoardConnected           = "Error";
                    ConnectedBoardType         = "Unable to detect";
                    ConnectedBoardChannelCount = 0;
                    //ConnectedBoardGains;
                }

                if (!BoardInfo.board_connected)
                {
                    LastConnectivityDisplay = "Error connecting to Board. Check Pins and EXTPWRSwitch and Try Again";
                    IsBoardConnected        = "No";
                }
                else
                {
                    LastConnectivityDisplay    = "Connected to WiFi Shield & Board";
                    IsBoardConnected           = "Yes";
                    ConnectedBoardType         = BoardInfo.board_type;
                    ConnectedBoardChannelCount = BoardInfo.num_channels;

                    StringBuilder builder = new StringBuilder();
                    foreach (int gain in BoardInfo.gains)     // Loop through all strings
                    {
                        builder.Append(gain).Append(", ");    // Append string to StringBuilder
                    }
                    ConnectedBoardGains = builder.ToString(); // Get string from StringBuilder

                    //ConnectedBoardGains = BoardInfo.gains.ToString();
                }
            }
            catch (Exception ex)
            {
                //this.PageLoadStatus = PageLoadStatus.Exception;

                ex.Data["method"] = "ExecuteGetDeviceInfo";
            }
        }
Example #8
0
        /// <summary>
        /// Gets the device service client.
        /// </summary>
        /// <returns>Returns an AMI service client instance or null.</returns>
        protected AmiServiceClient GetDeviceServiceClient()
        {
            var deviceIdentity = ApplicationSignInManager.LoginAsDevice();

            if (deviceIdentity == null)
            {
                return(null);
            }

            this.Request.Cookies.Set(new HttpCookie("access_token", deviceIdentity.AccessToken));

            var restClientService = new RestClientService(Constants.Ami)
            {
                Credentials = new AmiCredentials(new GenericPrincipal(deviceIdentity, null), this.Request)
            };

            return(new AmiServiceClient(restClientService));
        }
Example #9
0
 public Form1()
 {
     InitializeComponent();
     restService = new RestClientService();
 }
 public MembersViewModel()
 {
     ListMembers = RestClientService.GetListMembers();
 }
Example #11
0
 public RestClientServiceTests()
 {
     _restRequestFactoryMock = new Mock <IRestRequestFactory>();
     _restClientFactoryMock  = new Mock <IRestClientFactory>();
     _service = new RestClientService(_restClientFactoryMock.Object, _restRequestFactoryMock.Object);
 }
 public RemoteTodoItemRepository(RestClientService restClient)
 {
     _RestClient = restClient;
 }
Example #13
0
        static async Task Main(string[] args)
        {
            Console.WriteLine(Environment.CurrentDirectory);
            if (IsApiTest)
            {
                var apiRequest = SetTestData();

                try
                {
                    var publicIpAddress = await NetworkHelper.GetPublicIpAddress();

                    Console.WriteLine($"Public IP request {publicIpAddress}");
                    await RestClientService.SendRequest(apiRequest);

                    Console.WriteLine("API request success");
                }
                catch (HttpRequestException ex)
                {
                    Console.WriteLine($"Could not connect to service on { RestClientService.ServiceUrl }");
                    Console.WriteLine("Original exception:\n\n" + ex);
                }
                catch (ApiException ex)
                {
                    Console.WriteLine("API request failed");
                    if (!new System.Net.HttpStatusCode[] { System.Net.HttpStatusCode.NotFound, System.Net.HttpStatusCode.Unauthorized }.Contains(ex.StatusCode))
                    {
                        // Extract the details of the error
                        var errors = await ex.GetContentAsAsync <Dictionary <string, string> >();

                        // Combine the errors into a string
                        var message = string.Join("; ", errors.Values);
                        // Throw a normal exception
                        //throw new Exception(message);
                        Console.WriteLine("Message:\n" + message);
                    }
                    Console.WriteLine("Original exception:\n" + ex);
                }
            }
            else
            {
                var lines       = FileHelper.GetLinesFromFile(FileName);
                var segmentList = FileProcessor.BuildFileSegments(lines);
                var MIRSegments = SegmentProcessor.GenerateAllSegments(segmentList);
                var clipboard   = new StringBuilder();

                if (SegmentTypeTest.HasValue)
                {
                    MIRSegments = MIRSegments
                                  .Where(_ => _ != null && _.Type == SegmentTypeTest)
                                  .ToList();
                }

                foreach (var segment in MIRSegments)
                {
                    clipboard.AppendLine(segment.ToString());
                    Console.Write(segment.ToString());
                }
                ClipboardService.SetText(clipboard.ToString());
            }
            Console.ReadLine();
        }