protected override void instancesComboBox_SelectionChangeCommitted(object sender, EventArgs e)
        {
            toolTip.SetToolTip(instancesComboBox, String.Empty);
            if (instancesComboBox.SelectedIndex >= 0)
            {
                var descriptor = (IDataDescriptor)instancesComboBox.SelectedItem;

                IContentView activeView = (IContentView)MainFormManager.MainForm.ActiveView;
                var          mainForm   = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;
                // lock active view and show progress bar
                mainForm.AddOperationProgressToContent(activeView.Content, "Loading problem instance.");

                Task.Factory.StartNew(() => {
                    CFGData data;
                    try {
                        data = Content.LoadDataLocal(descriptor, treeCheckBox.Checked, (int)numberOfTempVarUpDown.Value);
                    } catch (Exception ex) {
                        ErrorHandling.ShowErrorDialog(String.Format("Could not load the problem instance {0}", descriptor.Name), ex);
                        mainForm.RemoveOperationProgressFromContent(activeView.Content);
                        return;
                    }
                    try {
                        GenericConsumer.Load(data);
                    } catch (Exception ex) {
                        ErrorHandling.ShowErrorDialog(String.Format("This problem does not support loading the instance {0}", descriptor.Name), ex);
                    } finally {
                        mainForm.RemoveOperationProgressFromContent(activeView.Content);
                    }
                });
            }
        }
        public string IngresarUsuario(Usuario usuario)
        {
            //Invoco el servicio
            UsuarioResponse response = new UsuarioResponse();
            UsuarioRequest request = new UsuarioRequest();
            request.Username = usuario.Username;
            request.Password = usuario.Password;
            request.FechaNacimiento = usuario.FechaNacimiento;
            try
            {
                GenericConsumer<UsuarioRequest, UsuarioResponse> gc = new GenericConsumer<UsuarioRequest, UsuarioResponse>();
                gc.SetServiceParameters("Usuario", "IngresarUsuario", RestSharp.Method.POST);
                response = gc.GetService(request);

                if (response.ResponseStatus.StatusCode.Equals(HttpStatusCode.OK))
                {
                    return EXITO;
                }
                else
                {
                    return FALLIDO;
                }
            }
            catch (Exception e)
            {
                return FALLIDO;
            }

        }
Beispiel #3
0
        protected virtual void instancesComboBox_SelectionChangeCommitted(object sender, EventArgs e)
        {
            toolTip.SetToolTip(instancesComboBox, String.Empty);
            if (instancesComboBox.SelectedIndex >= 0)
            {
                var descriptor = (IDataDescriptor)instancesComboBox.SelectedItem;

                IContentView activeView = (IContentView)MainFormManager.MainForm.ActiveView;
                var          content    = activeView.Content;
                // lock active view and show progress bar
                Progress.Show(content, "Loading problem instance.", ProgressMode.Indeterminate);

                Task.Factory.StartNew(() => {
                    T data;
                    try {
                        data = Content.LoadData(descriptor);
                    } catch (Exception ex) {
                        ErrorHandling.ShowErrorDialog(String.Format("Could not load the problem instance {0}", descriptor.Name), ex);
                        Progress.Hide(content);
                        return;
                    }
                    try {
                        GenericConsumer.Load(data);
                    } catch (Exception ex) {
                        ErrorHandling.ShowErrorDialog(String.Format("This problem does not support loading the instance {0}", descriptor.Name), ex);
                    } finally {
                        Progress.Hide(content);
                    }
                });
            }
        }
        protected override void importButton_Click(object sender, EventArgs e)
        {
            var importTypeDialog = new CFGImportGenerateDialog();

            if (importTypeDialog.ShowDialog() == DialogResult.OK)
            {
                CFGData instance = null;
                try {
                    if (importTypeDialog.ImportButtonClick)
                    {
                        instance = Content.ImportData(importTypeDialog.Path);
                    }
                    else
                    {
                        instance = Content.GenerateGrammar(importTypeDialog.GenerateOptions);
                    }
                } catch (IOException ex) {
                    ErrorWhileParsing(ex);
                    return;
                }
                try {
                    GenericConsumer.Load(instance);
                    instancesComboBox.SelectedIndex = -1;
                } catch (IOException ex) {
                    ErrorWhileLoading(ex, importTypeDialog.Path);
                }
            }
        }
Beispiel #5
0
        protected override void importButton_Click(object sender, EventArgs e)
        {
            var importTypeDialog = new RegressionImportTypeDialog();

            if (importTypeDialog.ShowDialog() == DialogResult.OK)
            {
                IRegressionProblemData instance = null;

                Task.Factory.StartNew(() => {
                    var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;
                    // lock active view and show progress bar
                    IContentView activeView = (IContentView)MainFormManager.MainForm.ActiveView;

                    try {
                        var progress = mainForm.AddOperationProgressToContent(activeView.Content, "Loading problem instance.");

                        Content.ProgressChanged += (o, args) => { progress.ProgressValue = args.ProgressPercentage / 100.0; };

                        instance = Content.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat);
                    } catch (IOException ex) {
                        ErrorWhileParsing(ex);
                        mainForm.RemoveOperationProgressFromContent(activeView.Content);
                        return;
                    }
                    try {
                        GenericConsumer.Load(instance);
                    } catch (IOException ex) {
                        ErrorWhileLoading(ex, importTypeDialog.Path);
                    } finally {
                        Invoke((Action)(() => instancesComboBox.SelectedIndex = -1));
                        mainForm.RemoveOperationProgressFromContent(activeView.Content);
                    }
                });
            }
        }
Beispiel #6
0
        protected override void importButton_Click(object sender, EventArgs e)
        {
            var provider = Content as DataAnalysisInstanceProvider <T, DataAnalysisImportType>;

            if (provider != null)
            {
                var importTypeDialog = new DataAnalysisImportDialog();
                if (importTypeDialog.ShowDialog() == DialogResult.OK)
                {
                    T instance = default(T);
                    try {
                        instance = provider.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat);
                    } catch (IOException ex) {
                        ErrorWhileParsing(ex);
                        return;
                    }
                    try {
                        GenericConsumer.Load(instance);
                        instancesComboBox.SelectedIndex = -1;
                    } catch (IOException ex) {
                        ErrorWhileLoading(ex, importTypeDialog.Path);
                    }
                }
            }
            else
            {
                base.importButton_Click(sender, e);
            }
        }
Beispiel #7
0
        public void Should_send_to_specific_endpoint()
        {
            var consumer = new GenericConsumer<SendMessage>();
            Bus.AddInstanceSubscription(consumer);
            Bus.Send(Bus.LocalEndpoint, new SendMessage());

            Assert.IsTrue(consumer.WaitForDelivery());
        }
Beispiel #8
0
        public void Consume_message()
        {
            var consumer = new GenericConsumer<MyMessage>();
            Bus.AddInstanceSubscription(consumer);

            Bus.Consume(new MyMessage());

            Assert.IsNotNull(consumer.LastReceived);
        }
Beispiel #9
0
        public void Consume_message()
        {
            var consumer = new GenericConsumer<MyMessage>();
            Bus.AddInstanceSubscription(consumer);

            Bus.Consume(new MyMessage());

            Assert.IsNotNull(consumer.LastReceived);
        }
Beispiel #10
0
        public void Should_send_to_specific_endpoint()
        {
            var consumer = new GenericConsumer <SendMessage>();

            Bus.AddInstanceSubscription(consumer);
            Bus.Send(Bus.LocalEndpoint, new SendMessage());

            Assert.IsTrue(consumer.WaitForDelivery());
        }
Beispiel #11
0
        public void Test_subscription()
        {
            var consumer = new GenericConsumer<MyMessage>();

            Bus.AddInstanceSubscription(consumer);

            Bus.Publish(new MyMessage { Value = 1 });

            Assert.IsTrue(consumer.WaitForDelivery());
            Assert.AreEqual(1, consumer.LastReceived.Value);
        }
Beispiel #12
0
        public void Should_report_error_if_send_cannot_be_performed()
        {
            var consumer = new GenericConsumer<SendMessage>();
            Bus.AddInstanceSubscription(consumer);

            BasicReturn error = null;
            Bus.Send(new RogerEndpoint("inexistent"), new SendMessage(), reason => error = reason);

            Assert.IsFalse(consumer.WaitForDelivery());
            Assert.IsNotNull(error);
        }
Beispiel #13
0
        public void Should_reply_to_response_consumer()
        {
            var responder = new MyRequestResponder(Bus);
            var responseConsumer = new GenericConsumer<MyReply>();

            Bus.AddInstanceSubscription(responder);
            Bus.AddInstanceSubscription(responseConsumer);

            Bus.Request(new MyRequest());

            Assert.IsTrue(responseConsumer.WaitForDelivery(1500 /*roudtrip here*/));
            Assert.IsNotNull(responseConsumer.LastReceived);
        }
Beispiel #14
0
        public void Should_reply_to_response_consumer()
        {
            var responder        = new MyRequestResponder(Bus);
            var responseConsumer = new GenericConsumer <MyReply>();

            Bus.AddInstanceSubscription(responder);
            Bus.AddInstanceSubscription(responseConsumer);

            Bus.Request(new MyRequest());

            Assert.IsTrue(responseConsumer.WaitForDelivery(1500 /*roudtrip here*/));
            Assert.IsNotNull(responseConsumer.LastReceived);
        }
Beispiel #15
0
        public void Test_subscription()
        {
            var consumer = new GenericConsumer <MyMessage>();

            Bus.AddInstanceSubscription(consumer);

            Bus.Publish(new MyMessage {
                Value = 1
            });

            Assert.IsTrue(consumer.WaitForDelivery());
            Assert.AreEqual(1, consumer.LastReceived.Value);
        }
Beispiel #16
0
        public void Test_unsubscription()
        {
            var consumer = new GenericConsumer<MyMessage>();

            var token = Bus.AddInstanceSubscription(consumer);

            token.Dispose();

            Bus.Publish(new MyMessage { Value = 1 });

            Assert.IsFalse(consumer.WaitForDelivery());
            Assert.IsNull(consumer.LastReceived);
        }
Beispiel #17
0
        public void Should_report_error_if_send_cannot_be_performed()
        {
            var consumer = new GenericConsumer <SendMessage>();

            Bus.AddInstanceSubscription(consumer);

            BasicReturn error = null;

            Bus.Send(new RogerEndpoint("inexistent"), new SendMessage(), reason => error = reason);

            Assert.IsFalse(consumer.WaitForDelivery());
            Assert.IsNotNull(error);
        }
Beispiel #18
0
        public void Error_reports_should_be_raised_only_for_the_call_which_triggered_them()
        {
            var consumer = new GenericConsumer<SendMessage>();
            Bus.AddInstanceSubscription(consumer);

            var errors = new SynchronizedCollection<BasicReturn>();

            Bus.Send(new RogerEndpoint("inexistent1"), new SendMessage(), errors.Add);
            Bus.Send(new RogerEndpoint("inexistent2"), new SendMessage(), errors.Add);

            Assert.IsFalse(consumer.WaitForDelivery());
            Assert.AreEqual(2, errors.Count);
        }
Beispiel #19
0
        public void Error_reports_should_be_raised_only_for_the_call_which_triggered_them()
        {
            var consumer = new GenericConsumer <SendMessage>();

            Bus.AddInstanceSubscription(consumer);

            var errors = new SynchronizedCollection <BasicReturn>();

            Bus.Send(new RogerEndpoint("inexistent1"), new SendMessage(), errors.Add);
            Bus.Send(new RogerEndpoint("inexistent2"), new SendMessage(), errors.Add);

            Assert.IsFalse(consumer.WaitForDelivery());
            Assert.AreEqual(2, errors.Count);
        }
Beispiel #20
0
        public void Test_unsubscription()
        {
            var consumer = new GenericConsumer <MyMessage>();

            var token = Bus.AddInstanceSubscription(consumer);

            token.Dispose();

            Bus.Publish(new MyMessage {
                Value = 1
            });

            Assert.IsFalse(consumer.WaitForDelivery());
            Assert.IsNull(consumer.LastReceived);
        }
 protected override void importButton_Click(object sender, EventArgs e)
 {
     using (var dialog = new TSPLIBImportDialog()) {
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             var instance = Content.LoadData(dialog.TSPFileName, dialog.TourFileName, dialog.Quality);
             try {
                 GenericConsumer.Load(instance);
                 instancesComboBox.SelectedIndex = -1;
             } catch (Exception ex) {
                 MessageBox.Show(String.Format("This problem does not support loading the instance {0}: {1}", Path.GetFileName(openFileDialog.FileName), Environment.NewLine + ex.Message), "Cannot load instance");
             }
         }
     }
 }
 /// <summary>
 /// Creates a new instance of <see cref="TcpBridge"/>
 /// </summary>
 /// <param name="settings">Configuration</param>
 public TcpBridge(TcpBridgeSettings settings)
 {
     _settings = new TcpBridgeSettings(settings);
     _clients  = new List <IPEndPoint>();
     _consumer = new GenericConsumer <Message>();
     _consumer.ReceivedGeneric += ConsumerOnReceivedGeneric;
     _endPointLookup            = new Dictionary <ITcpSocket, IPEndPoint>();
     _socketLookup              = new Dictionary <IPEndPoint, ITcpSocket>();
     _queued    = new Dictionary <ITcpSocket, Queue <Message> >();
     _tcpServer = new AsyncEventServer(_settings.ListenEndPoint.Address, _settings.ListenEndPoint.Port, this,
                                       settings.ServerSettings);
     foreach (NetworkPoint networkPoint in _settings.ClientEndPoints)
     {
         _clients.Add(networkPoint.ToIpEndPoint());
     }
 }
Beispiel #23
0
        public void Should_work_when_message_deliverable()
        {
            var consumer = new GenericConsumer<MyMessage>();

            Bus.AddInstanceSubscription(consumer);

            consumer.WaitForDelivery();

            var handle = new ManualResetEvent(false);

            Bus.PublishMandatory(new MyMessage {Value = 1}, reason => handle.Set());

            if(handle.WaitOne(1000))
                Assert.Fail("Delivery failure callback wasn't expected to be called");

            Assert.IsNotNull(consumer.LastReceived);
        }
Beispiel #24
0
 protected virtual void importButton_Click(object sender, EventArgs e)
 {
     openFileDialog.FileName = Content.Name + " instance";
     if (openFileDialog.ShowDialog() == DialogResult.OK)
     {
         T instance = default(T);
         try {
             instance = Content.ImportData(openFileDialog.FileName);
         } catch (Exception ex) {
             MessageBox.Show(String.Format("There was an error parsing the file: {0}", Environment.NewLine + ex.Message), "Error while parsing", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         try {
             GenericConsumer.Load(instance);
             instancesComboBox.SelectedIndex = -1;
         } catch (Exception ex) {
             MessageBox.Show(String.Format("This problem does not support loading the instance {0}: {1}", Path.GetFileName(openFileDialog.FileName), Environment.NewLine + ex.Message), "Cannot load instance");
         }
     }
 }
Beispiel #25
0
        public void Should_work_when_message_deliverable()
        {
            var consumer = new GenericConsumer <MyMessage>();

            Bus.AddInstanceSubscription(consumer);

            consumer.WaitForDelivery();

            var handle = new ManualResetEvent(false);

            Bus.PublishMandatory(new MyMessage {
                Value = 1
            }, reason => handle.Set());

            if (handle.WaitOne(1000))
            {
                Assert.Fail("Delivery failure callback wasn't expected to be called");
            }

            Assert.IsNotNull(consumer.LastReceived);
        }
        protected override void importButton_Click(object sender, EventArgs e)
        {
            var importTypeDialog = new TimeSeriesPrognosisImportDialog();

            if (importTypeDialog.ShowDialog() == DialogResult.OK)
            {
                ITimeSeriesPrognosisProblemData instance = null;
                try {
                    instance = Content.ImportData(importTypeDialog.Path, importTypeDialog.ImportType, importTypeDialog.CSVFormat);
                } catch (IOException ex) {
                    ErrorWhileParsing(ex);
                    return;
                }
                try {
                    GenericConsumer.Load(instance);
                    instancesComboBox.SelectedIndex = -1;
                } catch (IOException ex) {
                    ErrorWhileLoading(ex, importTypeDialog.Path);
                }
            }
        }
Beispiel #27
0
 protected override void BeforeBusInitialization()
 {
     RegisterOnDefaultBus(simpleConsumer = new GenericConsumer <MyMessage>());
     RegisterOnDefaultBus(baseConsumer   = new GenericConsumer <MyBaseMessage>());
 }
Beispiel #28
0
 protected override void BeforeSecondaryBusInitialization()
 {
     RegisterOnSecondaryBus(consumer = new GenericConsumer <MyMessage>());
 }
Beispiel #29
0
        public String LoguearUsuario(Usuario usuario) 
        {
            UsuarioResponse response = new UsuarioResponse();
            UsuarioRequest request = new UsuarioRequest();
            request.Username = usuario.Username;
            request.Password = usuario.Password;
            try
            {
                GenericConsumer<UsuarioRequest, UsuarioResponse> gc = new GenericConsumer<UsuarioRequest, UsuarioResponse>();
                gc.SetServiceParameters("Usuario", "LoguearUsuario", RestSharp.Method.POST);
                response = gc.GetService(request);

                if (response.ResponseStatus.StatusCode.Equals(HttpStatusCode.OK))
                {
                    //Almaceno el usuario en sesion
                   Session["usuario"] = usuario.Username;
                   return EXITO;
                }
                else
                {
                    return FALLIDO;
                }
            }
            catch (Exception e)
            {
                return FALLIDO;
            }

        }
 protected override void BeforeBusInitialization()
 {
     RegisterOnDefaultBus(consumer = new GenericConsumer<MyMessage>());
 }
Beispiel #31
0
        public void Should_not_require_exchange_to_be_defined_on_reply_message_type()
        {
            var responseConsumer = new GenericConsumer <MyReply>();

            Bus.AddInstanceSubscription(responseConsumer);
        }
Beispiel #32
0
        public void Should_not_require_exchange_to_be_defined_on_reply_message_type()
        {
            var responseConsumer = new GenericConsumer<MyReply>();

            Bus.AddInstanceSubscription(responseConsumer);
        }