public MainViewModel( CommandClient jason, ODataClient odata )
		{
			this.jason = jason;
			this.odata = odata;

			this.People = new ObservableCollection<PersonView>();
		}
Example #2
0
        internal static void Clone(string branchLocation, string localPath, MonoDevelop.Core.IProgressMonitor monitor)
        {
            try {
                CommandClient.Clone(source: branchLocation, destination: localPath, mercurialPath: DefaultMercurialPath);
            } catch (CommandException ce) {
                monitor.ReportError(ce.Message, ce);
            }

            monitor.ReportSuccess(string.Empty);
        }
        public MainPage()
        {
            InitializeComponent();

            this.client = new CommandClient();
            this.client.GetPageCompleted += Client_GetPageCompleted;
            this.client.GetDataCompleted += Client_GetDataCompleted;
            this.client.SaveCompleted    += Client_SaveCompleted;
            this.client.GetPageAsync(1);
        }
Example #4
0
File: Form1.cs Project: minskowl/MY
 public void StartClient()
 {
     address = IPAddress.Parse("127.0.0.1");
     client  = new CommandClient(address, 8000, "Hi");
     client.ConnectToServer();
     client.CommandSent     += new CommandSentEventHandler(client_CommandSent);
     client.CommandReceived += new CommandReceivedEventHandler(client_CommandReceived);
     // client.SendCommand(new Command(CommandType.FreeCommand, IPAddress.Broadcast, client.IP + ":" + client.NetworkName));
     //client.SendCommand(new Command(CommandType.SendClientList, client.ServerIP));
 }
Example #5
0
        private void fillTheDataGrid()
        {
            var commandServer = new CommandServer();

            try
            {
                radGridView1.Invoke(new MethodInvoker(delegate()
                {
                    radGridView1.EnablePaging = true;

                    if (dateS == null)
                    {
                        _bindingSource = new BindingSource {
                            DataSource = commandServer.DataGridSet(@"select * from ListSurvey() order by [Дата] desc").Tables[0]
                        }
                    }
                    ;
                    else
                    {
                        _bindingSource = new BindingSource {
                            DataSource = commandServer.DataGridSet(@"select * from ListSurvey()
                    where [Дата] between '" + dateS.Value + "' and '" + dateE.Value + "'order by [Дата] desc").Tables[0]
                        }
                    };

                    radGridView1.DataSource = _bindingSource;

                    if (radGridView1.Columns.Count > 0)
                    {
                        radGridView1.Columns[0].IsVisible    = false;
                        radGridView1.Columns[6].FormatString = "{0:dd/MM/yyyy}";
                        radGridView1.AutoSizeColumnsMode     = GridViewAutoSizeColumnsMode.Fill;
                        radGridView1.Columns[1].BestFit();
                        radGridView1.Columns[6].BestFit();

                        radGridView1.EnableFiltering = true;
                        radGridView1.MasterTemplate.ShowHeaderCellButtons = true;
                        radGridView1.MasterTemplate.ShowFilteringRow      = false;
                        radGridView1.Columns["Адрес"].AllowFiltering      = false;
                        radGridView1.Columns["ФИО"].AllowFiltering        = false;
                        radGridView1.Columns[6].AllowFiltering            = false;
                        radGridView1.Columns["Результат"].AllowFiltering  = false;
                    }

                    radLabelElement1.Text = @"Записей: " + radGridView1.MasterTemplate.DataView.ItemCount;
                }));
            }
            catch (Exception ex)
            {
                CommandClient commandClient = new CommandClient();
                radLabelElement1.Text = @"Произошла ошибка при загрузке данных. Сообщите разработчику.";
                commandClient.WriteFileError(ex, "select * from ListSurvey() order by [Дата] desc");
            }
        }
        /// <summary>
        /// oxd-web Checks Access for UMA RS resource
        /// </summary>
        /// <param name="oxdweburl">Oxd Web url</param>
        /// <param name="umaRsCheckAccessParams">Input params for UMA RS Check Access command</param>
        /// <returns></returns>
        public UmaRsCheckAccessResponse CheckAccess(string oxdweburl, UmaRsCheckAccessParams umaRsCheckAccessParams)
        {
            Logger.Info("Verifying input parameters.");


            if (umaRsCheckAccessParams == null)
            {
                throw new ArgumentNullException("The UMA RS Check Access command params should not be NULL.");
            }

            if (string.IsNullOrEmpty(umaRsCheckAccessParams.OxdId))
            {
                throw new MissingFieldException("Oxd ID is required for checking access of UMA resources.");
            }

            if (string.IsNullOrEmpty(umaRsCheckAccessParams.Path))
            {
                throw new MissingFieldException("Valid Path is required for checking access of UMA resource in RS.");
            }

            if (string.IsNullOrEmpty(umaRsCheckAccessParams.HttpMethod))
            {
                throw new MissingFieldException("Valid HTTP method is required for checking access of UMA resource in RS.");
            }

            try
            {
                Logger.Info("Preparing and sending command.");
                var cmdUmaRsCheckAccess = new Command {
                    CommandType = CommandType.uma_rs_check_access, CommandParams = umaRsCheckAccessParams
                };
                var    commandClient   = new CommandClient(oxdweburl);
                string commandResponse = commandClient.send(cmdUmaRsCheckAccess);

                var response = JsonConvert.DeserializeObject <UmaRsCheckAccessResponse>(commandResponse);

                if (response.Status.ToLower().Equals("error"))
                {
                    Logger.Info(string.Format("Got response status as {0}. The error is {1} with description {2}",
                                              response.Status, response.Data.Error, response.Data.ErrorDescription));
                }
                else
                {
                    Logger.Info(string.Format("Got response status as {0} and the access is {1}", response.Status, response.Data.Access));
                }

                return(response);
            }
            catch (Exception ex)
            {
                Logger.Log(NLog.LogLevel.Error, ex, "Exception when checking access of UMA resource.");
                return(null);
            }
        }
Example #7
0
        public void TestRoot()
        {
            string path = GetTemporaryPath();

            CommandClient.Initialize(path, MercurialPath);
            Assert.That(Directory.Exists(Path.Combine(path, ".hg")), string.Format("Repository was not created at {0}", path));

            using (var client = new CommandClient(path, null, null, MercurialPath)) {
                Assert.AreEqual(path, client.Root, "Unexpected repository root");
            }
        }
Example #8
0
 private void OnConnectClick()
 {
     new Thread(() =>
     {
         //init communication
         InfoServer server = InfoServer.Instance;
         server.Start();
         CommandClient commandClient = CommandClient.Instance;
         commandClient.Start();
     }).Start();
 }
        private GetRPTResponse GetRPTResponse(UmaRpGetRptParams getRptParams, CommandClient oxdcommand)
        {
            var cmdGetRPT = new Command {
                CommandType = CommandType.uma_rp_get_rpt, CommandParams = getRptParams
            };
            string commandResponse = oxdcommand.send(cmdGetRPT);
            var    response        = JsonConvert.DeserializeObject <GetRPTResponse>(commandResponse);

            Logger.Info(string.Format("Got response status as {0} and RPT is {1}", response.Status, response.Data.Rpt));
            return(response);
        }
        /// <summary>
        /// oxd-local Get Claims Gathering Url
        /// </summary>
        /// <param name="host">Oxd Host</param>
        /// <param name="port">Oxd Port</param>
        /// <param name="umaRpGetClaimsGatheringUrlParams">Input params for UMA Claims Gathering URL command</param>
        /// <returns></returns>
        public UmaRpGetClaimsGatheringUrlResponse GetClaimsGatheringUrl(string host, int port, UmaRpGetClaimsGatheringUrlParams umaRpGetClaimsGatheringUrlParams)
        {
            Logger.Info("Verifying input parameters.");
            if (string.IsNullOrEmpty(host))
            {
                throw new ArgumentNullException("Oxd Host should not be NULL.");
            }

            if (port <= 0)
            {
                throw new ArgumentNullException("Oxd Port should be a valid port number.");
            }

            if (umaRpGetClaimsGatheringUrlParams == null)
            {
                throw new ArgumentNullException("The UMA RS Check Access command params should not be NULL.");
            }

            if (string.IsNullOrEmpty(umaRpGetClaimsGatheringUrlParams.OxdId))
            {
                throw new MissingFieldException("Oxd ID is required for checking access of UMA resources.");
            }


            try
            {
                Logger.Info("Preparing and sending command.");
                var cmdUmaRpGetClaimsGatheringUrl = new Command {
                    CommandType = CommandType.uma_rp_get_claims_gathering_url, CommandParams = umaRpGetClaimsGatheringUrlParams
                };
                var    commandClient   = new CommandClient(host, port);
                string commandResponse = commandClient.send(cmdUmaRpGetClaimsGatheringUrl);

                var response = JsonConvert.DeserializeObject <UmaRpGetClaimsGatheringUrlResponse>(commandResponse);

                if (response.Status.ToLower().Equals("error"))
                {
                    Logger.Info(string.Format("Got response status as {0}. The error is {1} with description {2}",
                                              response.Status, response.Data.Error, response.Data.ErrorDescription));
                }
                else
                {
                    Logger.Info(string.Format("Got response status as {0} ", response.Status));
                }

                return(response);
            }
            catch (Exception ex)
            {
                Logger.Log(NLog.LogLevel.Error, ex, "Exception when Getting UMA Claims Gathering URL.");
                return(null);
            }
        }
Example #11
0
        /// <summary>
        /// Gets different type of tokens by Code using Oxd Server
        /// </summary>
        /// <param name="host">Oxd Host</param>
        /// <param name="port">Oxd Port</param>
        /// <param name="getTokensByCodeParams">Input params for Get Tokens by Code command</param>
        /// <returns></returns>
        public GetTokensByCodeResponse GetTokensByCode(string host, int port, GetTokensByCodeParams getTokensByCodeParams)
        {
            Logger.Info("Verifying input parameters.");
            if (string.IsNullOrEmpty(host))
            {
                throw new ArgumentNullException("Oxd Host should not be NULL.");
            }

            if (port <= 0)
            {
                throw new ArgumentNullException("Oxd Port should be a valid port number.");
            }

            if (getTokensByCodeParams == null)
            {
                throw new ArgumentNullException("The get tokens by code command params should not be NULL.");
            }

            if (string.IsNullOrEmpty(getTokensByCodeParams.OxdId))
            {
                throw new MissingFieldException("Oxd ID is required for getting tokens.");
            }

            if (string.IsNullOrEmpty(getTokensByCodeParams.Code))
            {
                throw new MissingFieldException("Auth Code is required for getting tokens.");
            }

            if (string.IsNullOrEmpty(getTokensByCodeParams.State))
            {
                throw new MissingFieldException("Auth State is required for getting tokens.");
            }

            try
            {
                Logger.Info("Preparing and sending command.");
                var cmdGetTokensByCode = new Command {
                    CommandType = CommandType.get_tokens_by_code, CommandParams = getTokensByCodeParams
                };
                var    commandClient   = new CommandClient(host, port);
                string commandResponse = commandClient.send(cmdGetTokensByCode);

                var response = JsonConvert.DeserializeObject <GetTokensByCodeResponse>(commandResponse);
                Logger.Info(string.Format("Got response status as {0} and access token is {1}", response.Status, response.Data.AccessToken));

                return(response);
            }
            catch (Exception ex)
            {
                Logger.Log(NLog.LogLevel.Error, ex, "Exception when getting tokens of site.");
                return(null);
            }
        }
Example #12
0
        static void Main(string[] args)
        {
            CommandClient client = new CommandClient();

            Stopwatch sw = Stopwatch.StartNew();
            client.SaveCommand("Loading");
            Console.WriteLine("Time = {0}", sw.ElapsedMilliseconds);

            Stopwatch sw2 = Stopwatch.StartNew();
            client.SaveCommandOneWay("Loading");
            Console.WriteLine("Time One Way = {0}", sw2.ElapsedMilliseconds);
        }
Example #13
0
        private void StartDataGrid()
        {
            var commandServer = new CommandServer();

            try
            {
                radGridView1.Invoke(new MethodInvoker(delegate()
                {
                    radGridView1.EnablePaging = true;
                    _bindingSource            = new BindingSource {
                        DataSource = commandServer.DataGridSet(@"select (family.family + ' ' + family.name + ' ' + family.surname) as [ФИО], count(*) as [кол.]
                        from dublicate inner join alone on dublicate.fk_alone = alone.key_alone
	                        inner join family on family.fk_alone = alone.key_alone
                        group by family.family, family.name, family.surname").Tables[0]
                    };

                    _bindingSourcePol = new BindingSource {
                        DataSource = commandServer.DataGridSet(@"--вычисление женщин
                        select alone.key_alone, family + ' ' + name + ' ' + surname as [ФИО], 
	                        case pol when 1 then 'муж' when 0 then 'жен' end as [пол]
                        from alone inner join family on alone.key_alone = family.fk_alone
                        where alone.pol = 0 and (family.surname not like '%на' and family.surname not like '%зы' and family.surname not like '%ва')
                        union all
                        select alone.key_alone, family + ' ' + name + ' ' + surname as [ФИО],
	                        case pol when 1 then 'муж' when 0 then 'жен' end as [пол]
                        from alone inner join family on alone.key_alone = family.fk_alone
                        where alone.pol = 1 and (family.surname not like '%ич' and family.surname not like '%лы')").Tables[0]
                    };


                    radGridView1.DataSource = _bindingSource;
                    radGridView4.DataSource = _bindingSourcePol;

                    if (radGridView1.Columns.Count > 0)
                    {
                        radGridView1.Columns[0].BestFit();
                        radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
                    }

                    if (radGridView4.Columns.Count > 0)
                    {
                        radGridView4.Columns[0].IsVisible = false;
                        radGridView4.AutoSizeColumnsMode  = GridViewAutoSizeColumnsMode.Fill;
                    }
                }));
            }
            catch (Exception ex)
            {
                CommandClient commandClient = new CommandClient();
                commandClient.WriteFileError(ex, null);
            }
        }
Example #14
0
        public void TestResolve()
        {
            string firstPath  = GetTemporaryPath();
            string secondPath = GetTemporaryPath();
            string file       = Path.Combine(firstPath, "foo");

            CommandClient.Initialize(firstPath, MercurialPath);
            CommandClient firstClient  = null,
                          secondClient = null;

            try {
                // Create repo with one commit
                firstClient = new CommandClient(firstPath, null, null, MercurialPath);
                File.WriteAllText(file, "1\n");
                firstClient.Add(file);
                firstClient.Commit("1");

                // Clone repo
                CommandClient.Clone(source: firstPath, destination: secondPath, mercurialPath: MercurialPath);
                secondClient = new CommandClient(secondPath, null, null, MercurialPath);
                Assert.AreEqual(1, secondClient.Log(null).Count, "Unexpected number of log entries");

                // Add changeset to original repo
                File.WriteAllText(file, "2\n");
                firstClient.Commit("2");

                // Add non-conflicting changeset to child repo
                File.WriteAllText(Path.Combine(secondPath, "foo"), "1\na\n");
                secondClient.Commit("a");

                // Pull from clone
                Assert.IsTrue(secondClient.Pull(null), "Pull unexpectedly resulted in unresolved files");
                Assert.AreEqual(3, secondClient.Log(null).Count, "Unexpected number of log entries");

                Assert.AreEqual(2, secondClient.Heads().Count(), "Unexpected number of heads");

                Assert.IsTrue(secondClient.Merge(null), "Merge unexpectedly resulted in unresolved files");

                IDictionary <string, bool> statuses = secondClient.Resolve(null, true, true, false, false, null, null, null);
                Assert.That(statuses.ContainsKey("foo"), "No merge status for foo");
                Assert.AreEqual(true, statuses ["foo"], "Incorrect merge status for foo");
            } finally {
                if (null != firstClient)
                {
                    firstClient.Dispose();
                }
                if (null != secondClient)
                {
                    secondClient.Dispose();
                }
            }
        }
Example #15
0
 private void radGridView1_DoubleClick(object sender, EventArgs e)
 {
     Hide();
     try
     {
         new Alone(false, Convert.ToInt32(radGridView1.CurrentRow.Cells[0].Value), null, null).ShowDialog();
     }catch (Exception ex)
     {
         var commandClient = new CommandClient();
         commandClient.WriteFileError(ex, null);
     }
     Show();
 }
Example #16
0
        public void TestVersion()
        {
            string path = GetTemporaryPath();

            CommandClient.Initialize(path, MercurialPath);
            Regex versionRegex = new Regex(@"^\d\.\d\.\d.*$");

            using (var client = new CommandClient(path, null, null, MercurialPath)) {
                Match match = versionRegex.Match(client.Version);
                Assert.IsNotNull(match, "Invalid version string");
                Assert.That(match.Success, "Invalid version string");
            }
        }
Example #17
0
        public void TestConfiguration()
        {
            string path = GetTemporaryPath();

            CommandClient.Initialize(path, MercurialPath);

            using (CommandClient client = new CommandClient(path, null, null, MercurialPath)) {
                IDictionary <string, string> config = client.Configuration;
                Assert.IsNotNull(config);
                Assert.Greater(config.Count, 0, "Expecting nonempty configuration");
                // Console.WriteLine (config.Aggregate (new StringBuilder (), (s,pair) => s.AppendFormat ("{0} = {1}\n", pair.Key, pair.Value), s => s.ToString ()));
            }
        }
Example #18
0
        public void TestAnnotate()
        {
            string path = GetTemporaryPath();
            string file = Path.Combine(path, "foo");

            CommandClient.Initialize(path, MercurialPath);

            using (var client = new CommandClient(path, null, null, MercurialPath)) {
                File.WriteAllText(file, "1");
                client.Add(file);
                client.Commit("1", null, false, false, null, null, null, null, "user");
                Assert.AreEqual("user 0: 1\n", client.Annotate(null, file));
            }
        }
Example #19
0
 private void radButton1_Click(object sender, EventArgs e)
 {
     Hide();
     try
     {
         new Alone(false, Convert.ToInt32(textBox1.Text), null, null).ShowDialog();
     }
     catch (Exception ex)
     {
         var commandClient = new CommandClient();
         commandClient.WriteFileError(ex, null);
     }
     Show();
 }
Example #20
0
        static void Main(string[] args)
        {
            CommandClient client = new CommandClient();

            Stopwatch sw = Stopwatch.StartNew();

            client.SaveCommand("Loading");
            Console.WriteLine("Time = {0}", sw.ElapsedMilliseconds);

            Stopwatch sw2 = Stopwatch.StartNew();

            client.SaveCommandOneWay("Loading");
            Console.WriteLine("Time One Way = {0}", sw2.ElapsedMilliseconds);
        }
Example #21
0
        public static async Task Main(string[] args)
        {
            Console.WriteLine("Hello, press [Enter] to proceed...");
            Console.ReadLine();

            var commandClient = new CommandClient("http://localhost:7071/api/command/");

            commandClient.Post(new FooCommand {
                Value = "sv-SE"
            });
            await commandClient.PostAsync(new FooCommand { Value = "en-GB" });

            // Command with result
            commandClient.Post(new BazCommand {
                Value = "sv-SE"
            }).Log();
            (await commandClient.PostAsync(new BazCommand {
                Value = "en-GB"
            })).Log();

            var queryClient = new QueryClient("http://localhost:7071/api/query/", client =>
            {
                client.Timeout = TimeSpan.FromSeconds(10);
            });

            queryClient.Post(new BarQuery {
                Id = 1
            }).Log();
            queryClient.Get(new BarQuery {
                Id = 1
            }).Log();
            (await queryClient.PostAsync(new BarQuery {
                Id = 1
            })).Log();
            (await queryClient.GetAsync(new BarQuery {
                Id = 1
            })).Log();

            // Query with enumerable property
            queryClient.Get(new QuxQuery {
                Ids = new[] { Guid.NewGuid(), Guid.NewGuid() }
            }).Log();
            (await queryClient.GetAsync(new QuxQuery {
                Ids = new[] { Guid.NewGuid(), Guid.NewGuid() }
            })).Log();

            Console.WriteLine("Press [Enter] to exit");
            Console.ReadLine();
        }
Example #22
0
        /// <summary>
        /// Gets User Info by access token using Oxd Server
        /// </summary>
        /// <param name="host">Oxd Host</param>
        /// <param name="port">Oxd Port</param>
        /// <param name="getUserInfoParams">Input params for Get User Info command.</param>
        /// <returns></returns>
        public GetUserInfoResponse GetUserInfo(string host, int port, GetUserInfoParams getUserInfoParams)
        {
            Logger.Info("Verifying input parameters.");
            if (string.IsNullOrEmpty(host))
            {
                throw new ArgumentNullException("Oxd Host should not be NULL.");
            }

            if (port <= 0)
            {
                throw new ArgumentNullException("Oxd Port should be a valid port number.");
            }

            if (getUserInfoParams == null)
            {
                throw new ArgumentNullException("The get user info command params should not be NULL.");
            }

            if (string.IsNullOrEmpty(getUserInfoParams.OxdId))
            {
                throw new MissingFieldException("Oxd ID is required for getting user info.");
            }

            if (string.IsNullOrEmpty(getUserInfoParams.AccessToken))
            {
                throw new MissingFieldException("Access Token is required for getting user info.");
            }

            try
            {
                Logger.Info("Preparing and sending command.");
                var cmdGetUserInfo = new Command {
                    CommandType = CommandType.get_user_info, CommandParams = getUserInfoParams
                };
                var    commandClient   = new CommandClient(host, port);
                string commandResponse = commandClient.send(cmdGetUserInfo);

                var response = JsonConvert.DeserializeObject <GetUserInfoResponse>(commandResponse);
                Logger.Info(string.Format("Got response status as {0} and name is {1}", response.Status, response.Data.UserClaims["name"].FirstOrDefault()));

                return(response);
            }
            catch (Exception ex)
            {
                Logger.Log(NLog.LogLevel.Error, ex, "Exception when getting user info of site.");
                return(null);
            }
        }
        /// <summary>
        /// oxd-local Protects set of UMA resources in Resource Server
        /// </summary>
        /// <param name="host">Oxd Host</param>
        /// <param name="port">Oxd Port</param>
        /// <param name="umaRsProtectParams">Input params for UMA RS Protect command</param>
        /// <returns></returns>
        public UmaRsProtectResponse ProtectResources(string host, int port, UmaRsProtectParams umaRsProtectParams)
        {
            Logger.Info("Verifying input parameters.");
            if (string.IsNullOrEmpty(host))
            {
                throw new ArgumentNullException("Oxd Host should not be NULL.");
            }

            if (port <= 0)
            {
                throw new ArgumentNullException("Oxd Port should be a valid port number.");
            }

            if (umaRsProtectParams == null)
            {
                throw new ArgumentNullException("The UMA RS Protect command params should not be NULL.");
            }

            if (string.IsNullOrEmpty(umaRsProtectParams.OxdId))
            {
                throw new MissingFieldException("Oxd ID is required for protecting UMA resources.");
            }

            if (umaRsProtectParams.ProtectResources == null || umaRsProtectParams.ProtectResources.Count == 0)
            {
                throw new MissingFieldException("Valid resources are required for protecting UMA resource in RS.");
            }

            try
            {
                Logger.Info("Preparing and sending command.");
                var cmdUmaRsProtect = new Command {
                    CommandType = CommandType.uma_rs_protect, CommandParams = umaRsProtectParams
                };
                var    commandClient   = new CommandClient(host, port);
                string commandResponse = commandClient.send(cmdUmaRsProtect);

                var response = JsonConvert.DeserializeObject <UmaRsProtectResponse>(commandResponse);
                Logger.Info(string.Format("Got response status as {0}", response.Status));

                return(response);
            }
            catch (Exception ex)
            {
                Logger.Log(NLog.LogLevel.Error, ex, "Exception when protecting UMA resource.");
                return(null);
            }
        }
Example #24
0
        public void TestParents()
        {
            string path = GetTemporaryPath();
            string file = Path.Combine(path, "foo");

            CommandClient.Initialize(path, MercurialPath);
            using (var client = new CommandClient(path, null, null, MercurialPath)) {
                File.WriteAllText(file, string.Empty);
                client.Add(file);
                client.Commit("Commit all");
                Assert.That(!client.Status().ContainsKey(file), "Default commit failed for foo");

                IEnumerable <Revision> parents = client.Parents(file, null);
                Assert.AreEqual(1, parents.Count(), "Unexpected number of parents");
            }
        }
Example #25
0
        public void TestLog()
        {
            string path = GetTemporaryPath();
            string file = Path.Combine(path, "foo");

            CommandClient.Initialize(path, MercurialPath);

            using (var client = new CommandClient(path, null, null, MercurialPath)) {
                File.WriteAllText(file, "1");
                client.Add(file);
                client.Commit("1");
                File.WriteAllText(file, "2");
                client.Commit("2");
                Assert.AreEqual(2, client.Log(null).Count, "Unexpected revision count");
            }
        }
Example #26
0
        static void Main(string[] args)
        {
            // Assumptions:

            // 1) Rovers are not allowed to travel outside of the map boundaries.

            // 2) Rovers are not allowed to drive through each other.

            // 3) The number of rovers is not specified. I will assume that the program
            //    will run until an option is selected indicating that no more are to be added.

            // 4) Commands (i.e. L, R, M) and directions (N, S, E, W) are case in-sensitive.

            // 5) It seems as if the instructions suggest that upon entering an input for each
            //    rover that they are "spawned" at that location, so I have placed new rovers at
            //    the input position. Alternatively, you could pre-populate the map with rovers and
            //    only allow successful connections if a rover existed at the input location.

            var mapInput = UI.GetMapCoordinates();
            var map      = new Map(mapInput.X, mapInput.Y);

            // Handles connections for all controller objects.
            using (var client = new CommandClient())
            {
                var running = true;
                while (running)
                {
                    var conn = UI.GetConnectionInput(validation: map.IsOnMap);
                    var ctrl = client.Connect(conn, map);

                    UI.Info($"Satellite uplink enabled. Communication established with rover {ctrl.Id}");

                    var commands = UI.GetMovementPlan(ctrl.Id);

                    ctrl.Execute(commands);

                    UI.Info("Movement plan complete.");
                    UI.Info($"Rover {ctrl.Id} destination: {ctrl.Position}");
                    UI.Break();

                    running = UI.KeepGoing();
                }
            }

            UI.Break();
            UI.Info("Done");
        }
Example #27
0
        public void TestArchive()
        {
            string path        = GetTemporaryPath();
            string archivePath = GetTemporaryPath();
            string file        = Path.Combine(path, "foo");

            CommandClient.Initialize(path, MercurialPath);
            using (var client = new CommandClient(path, null, null, MercurialPath)) {
                File.WriteAllText(file, string.Empty);
                client.Add(file);
                client.Commit(file);
                client.Archive(archivePath);
                Assert.That(Directory.Exists(archivePath));
                Assert.That(!Directory.Exists(Path.Combine(archivePath, ".hg")));
                Assert.That(File.Exists(Path.Combine(archivePath, "foo")));
            }
        }
Example #28
0
        public void TestSummary()
        {
            string path    = GetTemporaryPath();
            string file    = Path.Combine(path, "foo");
            string summary = string.Empty;

            CommandClient.Initialize(path, MercurialPath);

            using (var client = new CommandClient(path, null, null, MercurialPath)) {
                File.WriteAllText(file, "1");
                client.Add(file);
                client.Commit("1", null, false, false, null, null, null, null, "user");
                summary = client.Summary(false);
            }

            Assert.IsTrue(summary.Contains("branch: default"));
        }
        protected virtual void InitRestClients()
        {
            RestClient = new RestClient(RootUrl + "api/v1/");
            RestClient.AddDefaultHeader("Authentication", ApiKey);
            RestClient.AddDefaultHeader("X-Api-Key", ApiKey);
            RestClient.UseSystemTextJson();

            Commands      = new CommandClient(RestClient, ApiKey);
            Tasks         = new ClientBase <TaskResource>(RestClient, ApiKey, "system/task");
            History       = new ClientBase <HistoryResource>(RestClient, ApiKey);
            HostConfig    = new ClientBase <HostConfigResource>(RestClient, ApiKey, "config/host");
            Indexers      = new IndexerClient(RestClient, ApiKey);
            Logs          = new LogsClient(RestClient, ApiKey);
            Notifications = new NotificationClient(RestClient, ApiKey);

            //Releases = new ReleaseClient(RestClient, ApiKey);
            Tags = new ClientBase <TagResource>(RestClient, ApiKey);
        }
Example #30
0
        public void TestRollback()
        {
            string path = GetTemporaryPath();
            string file = Path.Combine(path, "foo");

            CommandClient.Initialize(path, MercurialPath);
            using (var client = new CommandClient(path, null, null, MercurialPath)) {
                File.WriteAllText(file, string.Empty);
                client.Add(file);
                client.Commit(file);
                File.WriteAllText(file, file);
                client.Commit(file);
                Assert.AreEqual(2, client.Log(null).Count, "Unexpected history length");
                Assert.That(client.Rollback());
                Assert.AreEqual(1, client.Log(null).Count, "Unexpected history length after rollback");
                Assert.AreEqual(Mercurial.Status.Modified, client.Status(file) ["foo"], "Unexpected file status after rollback");
            }
        }
Example #31
0
        public void TestCat()
        {
            string path = GetTemporaryPath();
            string file = Path.Combine(path, "foo");

            CommandClient.Initialize(path, MercurialPath);
            using (var client = new CommandClient(path, null, null, MercurialPath)) {
                File.WriteAllText(file, "foo\n");
                client.Add(Path.Combine(path, "foo"));
                client.Commit("Commit all");
                Assert.That(!client.Status().ContainsKey("foo"), "Default commit failed for foo");

                var contents = client.Cat(null, file);
                Assert.AreEqual(1, contents.Count, "Unexpected size of file set");
                Assert.That(contents.ContainsKey(file), "foo not in file set");
                Assert.AreEqual("foo\n", contents [file]);
            }
        }
Example #32
0
        public void TestRevert()
        {
            string path = GetTemporaryPath();
            string file = Path.Combine(path, "foo");

            CommandClient.Initialize(path, MercurialPath);
            using (var client = new CommandClient(path, null, null, MercurialPath)) {
                File.WriteAllText(file, string.Empty);
                client.Add(file);
                client.Commit("Commit all");
                Assert.That(!client.Status().ContainsKey("foo"), "Default commit failed for foo");

                File.WriteAllText(file, "Modified!");
                Assert.That(client.Status().ContainsKey("foo"), "Failed to modify file");
                client.Revert(null, file);
                Assert.That(!client.Status().ContainsKey("foo"), "Revert failed for foo");
            }
        }
		public void Install( IWindsorContainer container, IConfigurationStore store )
		{
			container.Register(
				Component.For<CommandClient>()
					.UsingFactoryMethod( () => 
					{
						string baseAddress = ConfigurationManager.AppSettings[ "jason/baseAddress" ];
						var client = new CommandClient( baseAddress );

						return client;
					} )
				);

			container.Register(
				Component.For<ODataClient>()
					.UsingFactoryMethod( () =>
					{
						string baseAddress = ConfigurationManager.AppSettings[ "odata/baseAddress" ];
						var client = new ODataClient( baseAddress );

						return client;
					} )
				);
		}
        protected virtual void InitRestClients()
        {
            RestClient = new RestClient(RootUrl + "api/");
            RestClient.AddDefaultHeader("Authentication", ApiKey);
            RestClient.AddDefaultHeader("X-Api-Key", ApiKey);

            Blacklist = new ClientBase<BlacklistResource>(RestClient, ApiKey);
            Commands = new CommandClient(RestClient, ApiKey);
            DownloadClients = new DownloadClientClient(RestClient, ApiKey);
            Episodes = new EpisodeClient(RestClient, ApiKey);
            History = new ClientBase<HistoryResource>(RestClient, ApiKey);
            HostConfig = new ClientBase<HostConfigResource>(RestClient, ApiKey, "config/host");
            Indexers = new IndexerClient(RestClient, ApiKey);
            NamingConfig = new ClientBase<NamingConfigResource>(RestClient, ApiKey, "config/naming");
            Notifications = new NotificationClient(RestClient, ApiKey);
            Profiles = new ClientBase<ProfileResource>(RestClient, ApiKey);
            Releases = new ReleaseClient(RestClient, ApiKey);
            RootFolders = new ClientBase<RootFolderResource>(RestClient, ApiKey);
            Series = new SeriesClient(RestClient, ApiKey);
            Tags = new ClientBase<TagResource>(RestClient, ApiKey);
            WantedMissing = new ClientBase<EpisodeResource>(RestClient, ApiKey, "wanted/missing");
            WantedCutoffUnmet = new ClientBase<EpisodeResource>(RestClient, ApiKey, "wanted/cutoff");
        }
Example #35
0
        private void OnImageDone(object o, Gst.GLib.SignalArgs args)
        {
            Emgu.CV.Image <Bgr, byte> sourceImage =
            new Emgu.CV.Image<Bgr, byte> ("snapshot.png");

            // Image conversion
            ImageProcessor processor = new ImageProcessor (sourceImage);

            // Face detection
            var detector = new FaceDetector ("/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt2.xml",
            processor.NormalizedImage);

            Image<Gray, byte> drawedFace = processor.GrayscaleImage;

            System.Drawing.Rectangle rect = new System.Drawing.Rectangle();
            if (detector.processImage (drawedFace, out rect)) {
                Title = "Лицо найдено. Данные отправляются на сервер";
                var binding = new BasicHttpBinding ();
                var address = new EndpointAddress ("http://" + entryHost.Text + ":" + entryPort.Text);
                client = new CommandClient (binding, address);
                Console.WriteLine (client.authenticate (UserInfoManager.SerializeImage (processor.NormalizedImage.GetSubRect(rect).Clone())));
            //	Console.WriteLine (client.executeCommand ("dmesg", ""));

            } else {
                Title = "В видоискателе нет лица";
                authButton.Sensitive = true;
            }
            /*
            using (Image<Bgr, byte> img = new Image<Bgr, byte>(400, 200, new Bgr(255, 0, 0))) {
            MCvFont f = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_COMPLEX, 1.0, 1.0);
            Emgu.CV.CvInvoke.cvNamedWindow("w1");
            CvInvoke.cvShowImage("w1", img.Ptr);
            CvInvoke.cvWaitKey (0);
            //Destory the window
            CvInvoke.cvDestroyWindow("w1");
            } */
        }