Пример #1
0
        private async void SendScreenshotButton_Click(object sender, RoutedEventArgs e)
        {
            bool receiverExists = await _connectionService.ReceiverExists(PartnerId.Text);

            if (!receiverExists)
            {
                System.Windows.MessageBox.Show("Partner was not found",
                                               "Error",
                                               MessageBoxButton.OK,
                                               MessageBoxImage.Error);
                return;
            }

            Thread.Sleep(200);
            WindowState = WindowState.Minimized;
            Thread.Sleep(200);

            string url = string.Empty;

            using (var memoryStreamScreenshot = new MemoryStream())
            {
                _connectionService.GetScreenShot(memoryStreamScreenshot);
                url = await _connectionService.UploadScreenshotToImageHosting(memoryStreamScreenshot);

                //ShowScreenshot(memoryStreamScreenshot);
            }

            await _connectionService.CreateConnection(url, YourId.Text, PartnerId.Text);

            _notifyIcon.ShowBalloonTip(2000, "Done", "Image was successfully sent", ToolTipIcon.Info);
        }
        static void Main(string[] args)
        {
            // Create a Connection and Channel for transporting message
            IConnection connection = ConnectionService.CreateConnection();
            IModel      channel    = connection.CreateModel();

            Console.WriteLine(string.Concat("Connection open: ", connection.IsOpen));

            // Declare an Exchange and Queue and bind them
            channel.ExchangeDeclare("my.first.exchange", ExchangeType.Direct, true, false, null);
            channel.QueueDeclare("my.first.queue", true, false, false, null);
            channel.QueueBind("my.first.queue", "my.first.exchange", "");

            // Basic message properties
            IBasicProperties properties = channel.CreateBasicProperties();

            properties.Persistent  = true; // Keep even after server restart
            properties.ContentType = "text/plain";

            // Publish a message
            PublicationAddress address = new PublicationAddress(ExchangeType.Direct, "my.first.exchange", "");

            channel.BasicPublish(address, properties, Encoding.UTF8.GetBytes("This is a message from the RabbitMq .NET driver"));
            Console.WriteLine("Message sent");

            // Close Connection & Channel
            channel.Close();
            connection.Close();

            // Finish
            Console.WriteLine(string.Concat("Channel is closed: ", channel.IsClosed));
            Console.ReadKey();
        }
Пример #3
0
        public async void SetConnection()
        {
            await _ConnectionService.CreateConnection();

            ResultText = "Connected";

            _ReactiveMessenger = new ReactiveMessenger(_ConnectionService);
            _ViewObserver      = _ReactiveMessenger.Subscribe(x => UpdateProducts());
        }
Пример #4
0
        public HttpStatusCode Get(int fromId, int toId, string url)
        {
            var connection = new ConnectionVM
            {
                FromId = fromId,
                ToId   = toId,
                URL    = url
            };

            return(_connectionService.CreateConnection(connection));
        }
Пример #5
0
    public static void ConnectPathFromPreviousNodeColors(World model, int width, int height)
    {
        for (int y = 1; y < height; y++)
        {
            for (int x = 0; x < width; x++)
            {
                Point fromPoint = PointService.GetPointInGrid(model, x, y - 1);

                for (int i = fromPoint.colors.Count - 1; i >= 0; i--)
                {
                    ColorType color = fromPoint.colors[i];
                    fromPoint.colors.Remove(color);

                    Point toPoint = PointService.GetPointInGrid(
                        model,
                        MathService.RandomRange(
                            MathService.Clamp(x - 1, 0, width),
                            MathService.Clamp(x + 2, 0, width)),
                        y
                        );

                    ConnectionService.CreateConnection(model, fromPoint.id, toPoint.id, color);

                    if (MathService.Random() < 0.75f)
                    {
                        PointService.AddColorToPointWithId(model, toPoint.id, color);
                    }
                    else
                    {
                        ColorService.ReleaseColor(model, color);
                        for (int j = 0; j < MathService.RandomRange(1, 1); j++)
                        {
                            PointService.AddColorToPointWithId(model, toPoint.id, ColorService.GetFreeColor(model));
                        }
                    }
                }
            }
        }
    }
Пример #6
0
        public ActionResult Create(ConnectionDTO connectionDTO)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    connectionService.CreateConnection(connectionDTO.Server,
                                                       connectionDTO.Database,
                                                       connectionDTO.User,
                                                       connectionDTO.Password);

                    ViewBag.Message = "The process has been executed successfully";
                    ViewBag.Type    = "info";
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
                ViewBag.Type    = "danger";
            }

            return(View(connectionDTO));
        }