Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var cfg = Properties.Settings.Default;

            // Carga la configuracion...
            CfgSacta.CfgSactaUdp.PuertoOrigen           = int.Parse(cfg.Listen.Split(':')[1]);      // Listen
            CfgSacta.CfgSactaUdp.PuertoDestino          = int.Parse(cfg.SendingLan1.Split(':')[1]); // Send
            CfgSacta.CfgMulticast.Interfaz              = cfg.Listen.Split(':')[0];
            CfgSacta.CfgMulticast.RedA                  = cfg.SendingLan1.Split(':')[0];
            CfgSacta.CfgMulticast.RedB                  = cfg.SendingLan2.Split(':')[0];
            CfgSacta.CfgIpAddress.IpRedA                = cfg.FromLan1; // From LAN1
            CfgSacta.CfgIpAddress.IpRedB                = cfg.FromLan2; // From LAN2
            CfgSacta.CfgSactaUsuarioSectores.IdSectores = cfg.Sectores;
            CfgSacta.CfgSactaUsuarioSectores.IdUcs      = cfg.Posiciones;

            PrintMenu();
            ConsoleKeyInfo result;

            do
            {
                result = Console.ReadKey(true);
                switch (result.Key)
                {
                case ConsoleKey.A:
                    if (SactaMod == null)
                    {
                        SactaMod = new SactaModule("sim");
                        SactaMod.Start();
                    }
                    break;

                case ConsoleKey.P:
                    if (SactaMod != null)
                    {
                        SactaMod.Stop();
                        SactaMod = null;
                    }
                    break;

                case ConsoleKey.C:
                    Console.Clear();
                    break;
                }
            } while (result.Key != ConsoleKey.Escape);

            if (SactaMod != null)
            {
                SactaMod.Stop();
                SactaMod = null;
            }
        }
    public void EndSacta()
    {
        if (sModule == null)
        {
            //System.Diagnostics.Debug.Assert(false);
            System.Configuration.Configuration config           = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
            System.Configuration.KeyValueConfigurationElement s = config.AppSettings.Settings["Sistema"];
            IdSistema = s.Value;
            sModule   = new Sacta.SactaModule(IdSistema, MySqlConnectionToCd40);
            sModule.Stop();
        }
        else
        {
            sModule.Stop();
        }

        EstadoSacta = (byte)0;

        sModule = null;
    }