Пример #1
0
        static bool ConectarZServer()
        {
            _newConn = null;
            TcpDuplexClientProtocolSetup protocol = new TcpDuplexClientProtocolSetup(true);

            try
            {
                _newConn = new ZyanConnection(_serverUrl, protocol, false);
            }
            catch (System.Net.Sockets.SocketException)
            {
                // Indica servidor apagado o imposible de conectar, ignorar y retornar false
                return(false);
            }


            if (_newConn == null)
            {
                // No se establecio conexion
                return(false);
            }
            else
            {
                _proxy = _newConn.CreateProxy <IMonitor>();

                // connections
                // conectando input y output
                // Las acciones de salida del form, a metodos del proxy, para su transmision remota al servidor.
                _theForm.Out_GetClientConfig = Asynchronizer <RemReqClientData> .WireUp(_proxy.In_RequestClientData);

                _theForm.Out_GetSystemConfig = Asynchronizer <RemReqSystemData> .WireUp(_proxy.In_RequestSystemData);

                _theForm.Out_GetQueueInfo = Asynchronizer <RemReqQueueData> .WireUp(_proxy.In_RequestQueueData);

                _theForm.Out_GetLogFile = Asynchronizer <RemReqLogFile> .WireUp(_proxy.In_RequestLogFile);

                _theForm.Out_GetConsoleText = Asynchronizer <RemReqConsoleText> .WireUp(_proxy.In_RequestConsoleText);

                // La salida del servidor remoto, a controladores de solicitud del formulario.
                _proxy.Out_SendClientConfig = SyncContextSwitcher <RemReplyClientData> .WireUp(_theForm.In_ClientDataList);

                _proxy.Out_SendSystemConfigData = SyncContextSwitcher <RemReplySystemData> .WireUp(_theForm.In_SystemConfigData);

                _proxy.Out_SendQueueData = SyncContextSwitcher <RemReplyQueueInfo> .WireUp(_theForm.In_QueueInfo);

                _proxy.Out_SendLogFile = SyncContextSwitcher <RemReplyLogFile> .WireUp(_theForm.In_LogFile);

                _proxy.Out_SendError = SyncContextSwitcher <RemReplyConsoleText> .WireUp(_theForm.In_Error);

                _proxy.Out_SendConsoleText = SyncContextSwitcher <RemReplyConsoleText> .WireUp(_theForm.In_ConsoleText);

                // estableciendo control sobre estado de la conexion
                _newConn.Disconnected += _newConn_Disconnected;

                _newConn.PollingInterval = TimeSpan.FromSeconds(1);
                _newConn.PollingEnabled  = true;

                return(true);
            }
        }
Пример #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ZyanConnection connection = LoginAndConnect();

            if (connection != null)
            {
                try
                {
                    CalcForm    form  = new CalcForm();
                    ICalculator proxy = connection.CreateProxy <ICalculator>();

                    form.Out_AddNumbers = Asynchronizer <AdditionRequest> .WireUp(proxy.In_AddNumbers);

                    proxy.Out_SendResult = SyncContextSwitcher <decimal> .WireUp(form.In_ReceiveResult);

                    Application.Run(form);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    connection.Dispose();
                }
            }
        }
Пример #3
0
 public IFuture GetUserBounds(LatentRegionHolder latentRegionHolder, FutureFeatures features)
 {
     D.Assert(UnwarpedMapTileSource.HasFeature(features, FutureFeatures.Async));
     return(new MemCacheFuture(cachePackage.asyncCache,
                               Asynchronizer.MakeFuture(cachePackage.computeAsyncScheduler,
                                                        new MemCacheFuture(cachePackage.boundsCache,
                                                                           new ApplyFuture(new ConstantVerb(new BoundsPresent(
                                                                                                                new RenderRegion(new MapRectangle(-85.0, -5000.0, 85.0, 5000.0), new DirtyEvent()))),
                                                                                           new IFuture[0])))));
 }
Пример #4
0
        public void Aspekte_sind_zu_trennen() {
            var asyncer = new Asynchronizer<string>();
            var sut = new LongRunning();
            var autoResetEvent = new AutoResetEvent(false);

            string result = null;
            asyncer.Result += x => {
                result = x;
                autoResetEvent.Set();
            };

            asyncer.Process(sut.GetResult);

            Assert.That(autoResetEvent.WaitOne(5000), Is.True);
            Assert.That(result, Is.EqualTo("Hello"));
        }
Пример #5
0
        public static void Main() {
            var mainWindow = new MainWindow();
            var logik = new Logik();
            var async = new Asynchronizer();
            var sync = new ebcpatterns.wpf.Synchronizer<string>();

            mainWindow.ButtonClick += async.Process;
            async.Result += logik.Process;
            logik.Result += sync.Process;
            sync.Result += mainWindow.SetText;


            var app = new Application {
                MainWindow = mainWindow
            };
            app.Run(mainWindow);
        }
Пример #6
0
        /*
         * internal static bool ConectarServidor()
         * {
         *  const string methodName = "ConectarServidor";
         *
         *  try
         *  {
         *      Log.WriteEntry(ClassName, methodName, TraceEventType.Information, "Conectando con servidor.");
         *
         *      var connection = new ZyanConnection(_connString);
         *      var service = connection.CreateProxy<IMessageHandler>();
         *
         *      _connection = connection;
         *      _proxy = service;
         *
         *      Log.WriteEntry(ClassName, methodName, TraceEventType.Information, "Conexion realizada con exito.");
         *      return true;
         *  }
         *  catch (Exception ex)
         *  {
         *      Log.WriteEntry(ClassName, methodName, TraceEventType.Error, string.Format("Error: {0}", ex.Message));
         *      return false;
         *  }
         * }
         */
        internal static bool ConectarServidor()
        {
            const string methodName = "ConectarServidor";

            try
            {
                Log.WriteEntry(ClassName, methodName, TraceEventType.Information, "Conectando con servidor.");

                var connection = new ZyanConnection(_connString);
                var service    = connection.CreateProxy <IMessageHandler>();

                _connection = connection;
                _proxy      = service;

                // Conectando input y output.
                // Las acciones de salida, a metodos del proxy, para su transmision remota al servidor.
                // Comandos
                Out_AsistenciaUpdateCommand = Asynchronizer <AsistenciaUpdateCommand> .WireUp(_proxy.In_AsistenciaUpdateCommand);

                // Consultas
                Out_AsistenciaQuery = Asynchronizer <AsistenciaQuery> .WireUp(_proxy.In_AsistenciaQuery);

                // La respuesta del servidor remoto, a acciones de entrada.
                // Comandos
                _proxy.Out_AsistenciaUpdateCommandResult = SyncContextSwitcher <CommandStatus> .WireUp(In_AsistenciaUpdateCommandResult);

                // Consultas
                _proxy.Out_AsistenciaQuery = SyncContextSwitcher <AsistenciaQueryResult> .WireUp(In_AsistenciaQueryResult);


                // Estableciendo controlador de sesion.
                _connection.Disconnected += _zyanConn_Disconnected;
                // Estableciendo monitoreo de la conexion.
                _connection.PollingInterval = TimeSpan.FromSeconds(3);
                _connection.PollingEnabled  = true;

                Log.WriteEntry(ClassName, methodName, TraceEventType.Information, "Conexion realizada con exito.");
                return(true);
            }
            catch (Exception ex)
            {
                Log.WriteEntry(ClassName, methodName, TraceEventType.Error, string.Format("Error: {0}", ex.Message));
                return(false);
            }
        }
Пример #7
0
        private bool Connect(string arg)
        {
            try
            {
                if (_zConnection != null)
                {
                    _zConnection.Dispose();
                }

                TcpDuplexClientProtocolSetup protocol = new TcpDuplexClientProtocolSetup(true);

                Hashtable credentials = new Hashtable();
                credentials.Add(AuthRequestMessage.CREDENTIAL_USERNAME, "zc");
                credentials.Add(AuthRequestMessage.CREDENTIAL_PASSWORD, "zc");

                _zConnection = new ZyanConnection(arg, protocol, credentials, false, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
                this.chkConect.Checked = false;
                return(false);
            }

            this.chkConect.Checked = true;

            IMonitor relMonitor = _zConnection.CreateProxy <IMonitor>();

            //this.Out_GetClient = Asynchronizer<int>.WireUp(relMonitor.In_RequestClientDataList);
            //this.Out_GetSystem = Asynchronizer<int>.WireUp(relMonitor.In_RequestSystemConfigData);
            this.Out_GetAllData = Asynchronizer <RequestDataEvent> .WireUp(relMonitor.In_RequestData);

            relMonitor.Out_SendClientDataList = SyncContextSwitcher <ClientDataList> .WireUp(this.In_GetClient);

            relMonitor.Out_SendSystemConfigData = SyncContextSwitcher <SystemConfigData> .WireUp(this.In_GetSys);


            return(true);
        }
Пример #8
0
        public static void Main() {
            var dateien_im_Pfad_ermitteln = new Dateien_im_Pfad_ermitteln();
            var filtern = new Filtern_der_20_größten_Dateien();
            var map = new Map();
            var viewModel = new ViewModel();
            var mainWindow = new MainWindow();
            var asynchronizer = new Asynchronizer<string>();
            var synchronizer = new ebcpatterns.wpf.Synchronizer<IEnumerable<messages.Datei>>();

            mainWindow.Suchen += asynchronizer.Process;
            mainWindow.Abbrechen += dateien_im_Pfad_ermitteln.Abbrechen;
            asynchronizer.Result += dateien_im_Pfad_ermitteln.Process;
            dateien_im_Pfad_ermitteln.Result += filtern.Process;
            filtern.Result += synchronizer.Process;
            synchronizer.Result += map.Process;

            map.Inject(viewModel);
            mainWindow.Inject(viewModel);

            var app = new Application {
                MainWindow = mainWindow
            };
            app.Run(app.MainWindow);
        }
Пример #9
0
 public void Setup() {
     sut = new Asynchronizer<int>();
     waitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
 }
Пример #10
0
 public IFuture GetAsynchronousFuture(CachePackage cachePackage)
 {
     return(new MemCacheFuture(cachePackage.asyncCache,
                               Asynchronizer.MakeFuture(cachePackage.computeAsyncScheduler, GetSynchronousFuture(cachePackage))));
 }
Пример #11
0
        static private bool ConectarZServer(string url)
        {
            Log.WriteEntry(ClassName, "ConectarZServer", TraceEventType.Verbose, "Conectando al servidor Zyan remoto: " + url);

            ZyanConnection _newConn = null;

            try
            {
                _newConn = new ZyanConnection(url);
            }
            catch (System.Net.Sockets.SocketException)
            {
                // Indica servidor apagado o imposible de conectar, ignorar y retornar false.
                return(false);
            }
            catch (Exception ex)
            {
                // Registrar otro tipo de excepcion para depurar
                Log.WriteEntry(ClassName, "ConectarZServer", TraceEventType.Error, "Exception: " + ex.Message);
                return(false);
            }

            if (_newConn == null)
            {
                // No se establecio conexion.
                return(false);
            }
            else
            {
                _proxy = _newConn.CreateProxy <IMonitor>();

                // Conectando input y output.
                // Las acciones de salida del form, a metodos del proxy, para su transmision remota al servidor.
                // Acciones que solicitan envio de datos.
                _theForm.Out_GetClientConfig = Asynchronizer <RemReqClientData> .WireUp(_proxy.In_RequestClientData);

                _theForm.Out_GetSystemConfig = Asynchronizer <RemReqSystemData> .WireUp(_proxy.In_RequestSystemData);

                _theForm.Out_GetQueueInfo = Asynchronizer <RemReqQueueData> .WireUp(_proxy.In_RequestQueueData);

                _theForm.Out_GetLogFile = Asynchronizer <RemReqLogFile> .WireUp(_proxy.In_RequestLogFile);

                _theForm.Out_GetConsoleText = Asynchronizer <RemReqConsoleText> .WireUp(_proxy.In_RequestConsoleText);

                // Acciones que solicitan modificar objetos.
                _theForm.Out_SendCreateClient = Asynchronizer <RemReqCreateClient> .WireUp(_proxy.In_RequestClientCreate);

                _theForm.Out_SendClientUpdate = Asynchronizer <RemReqUpdateClient> .WireUp(_proxy.In_RequestClientUpdate);

                _theForm.Out_SendClientDelete = Asynchronizer <RemReqDeleteClient> .WireUp(_proxy.In_RequestClientDelete);

                _theForm.Out_SendSystemUpdate = Asynchronizer <RemReqUpdateSystem> .WireUp(_proxy.In_RequestSystemUpdate);

                _theForm.Out_SendClientPause = Asynchronizer <RemReqPauseClient> .WireUp(_proxy.In_RequestClientPause);

                _theForm.Out_SendClientResume = Asynchronizer <RemReqResumeClient> .WireUp(_proxy.In_RequestClientResume);

                // La salida del servidor remoto, a controladores de solicitud del formulario.
                _proxy.Out_SendClientConfig = SyncContextSwitcher <RemReplyClientData> .WireUp(_theForm.In_ClientDataList);

                _proxy.Out_SendSystemConfigData = SyncContextSwitcher <RemReplySystemData> .WireUp(_theForm.In_SystemConfigData);

                _proxy.Out_SendQueueData = SyncContextSwitcher <RemReplyQueueInfo> .WireUp(_theForm.In_QueueInfo);

                _proxy.Out_SendLogFile = SyncContextSwitcher <RemReplyLogFile> .WireUp(_theForm.In_LogFile);

                _proxy.Out_SendError = SyncContextSwitcher <RemReplyConsoleText> .WireUp(_theForm.In_Error);

                _proxy.Out_SendConsoleText = SyncContextSwitcher <RemReplyConsoleText> .WireUp(_theForm.In_ConsoleText);

                // Guardando referencia a nueva conexion.
                _zyanConn = _newConn;

                // Estableciendo controlador de sesion
                _zyanConn.Disconnected += _zyanConn_Disconnected;
                // Estableciendo monitoreo de la conexion
                _zyanConn.PollingInterval = TimeSpan.FromSeconds(1.5);
                _zyanConn.PollingEnabled  = true;


                return(true);
            }
        }