Example #1
0
        public IActionResult Deicing2(string dataLine)
        {
            RMParser rm  = new RMParser();
            string   res = rm.Parse(FileTipe.De_icing, dataLine, Program.AppConfig["mscns"]);

            return(Content(res));
        }
Example #2
0
        static void Main(string[] args)
        {
            RMParser parser = new RMParser();

            if (!parser.Parse(args))
            {
                return;
            }

            GlobalState.Name = parser["n"].ToLower();
            string port_num = parser["p"];

            System.Console.WriteLine(string.Format("Starting resource manager for {0} on port {1}", GlobalState.Name, port_num));

            System.Collections.Specialized.ListDictionary channelProperties = new System.Collections.Specialized.ListDictionary();
            channelProperties.Add("port", port_num);
            channelProperties.Add("name", GlobalState.Name);

            HttpChannel channel = new HttpChannel(channelProperties, new SoapClientFormatterSinkProvider(), new SoapServerFormatterSinkProvider());

            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false);
            System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType
                (Type.GetType("MyRM.MyRM")                                      // Assembly name
                , "RM.soap"                                                     // URI
                , System.Runtime.Remoting.WellKnownObjectMode.Singleton         // Instancing mode
                );

            // activate the object
            string[] urls = channel.GetUrlsForUri("RM.soap");
            if (1 != urls.Length)
            {
                throw new InvalidOperationException();
            }

            MyRM resourceManager = (MyRM)System.Activator.GetObject(typeof(TP.RM), urls[0]);

            if (null == resourceManager)
            {
                throw new InvalidProgramException();
            }

            // initialize and start RM
            Console.WriteLine("{0}: Initializing", GlobalState.Name);
            resourceManager.Init(parser["n"], urls[0], parser["tm"]);

            Console.WriteLine("{0}: Running", GlobalState.Name);
            resourceManager.Run();

            Console.WriteLine("{0}: Exitting", GlobalState.Name);
        }
Example #3
0
 public IActionResult Deicing(List <IFormFile> files)
 {
     if (files.Count == 0)
     {
         return(Content("Не загружен файл de-icing.xml"));
     }
     else
     {
         IFormFile img = files[0];
         int       n   = (int)img.Length;
         byte[]    buf = new byte[n];
         Stream    ms  = img.OpenReadStream();
         ms.Read(buf, 0, n);
         string   dataLine = Encoding.UTF8.GetString(buf);
         RMParser rm       = new RMParser();
         string   res      = rm.Parse(FileTipe.De_icing, dataLine, Program.AppConfig["mscns"]);
         return(Content(res));
     }
 }
Example #4
0
        static void Main(string[] args)
        {
            isReady = false; // set isReady false because we want to make sure the actual code is not executed before the rm is going into the stable loop waiting.
            RMParser parser = new RMParser();

            if (!parser.Parse(args))
            {
                return;
            }

            GlobalState.Name = parser["n"].ToLower();
            string port_num = parser["p"];

            System.Collections.Specialized.ListDictionary channelProperties = new System.Collections.Specialized.ListDictionary();

            channelProperties.Add("port", port_num);
            channelProperties.Add("name", GlobalState.Name);

            HttpChannel channel = new HttpChannel(channelProperties, new SoapClientFormatterSinkProvider(), new SoapServerFormatterSinkProvider());

            System.Console.WriteLine(string.Format("Starting resource manager for {0} on port {1}", GlobalState.Name, port_num));
            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false);

            System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType
                (Type.GetType("MyRM.MyRM")                                      // Assembly name
                , "RM.soap"                                                     // URI
                , System.Runtime.Remoting.WellKnownObjectMode.Singleton         // Instancing mode
                );


            if (String.Compare(parser["tm"], "none", true) != 0)
            {
                while (_transactionManager == null)
                {
                    tmUrl = parser["tm"];
                    try
                    {
                        _transactionManager = (TP.TM)System.Activator.GetObject(typeof(TP.TM), tmUrl);

                        _transactionManager.Ping();
                        urls = channel.GetUrlsForUri("RM.soap");
                        foreach (string url in urls)
                        {
                            _transactionManager.Register(url + "$" + GlobalState.Name);
                        }
                    }
                    catch (ArgumentException)
                    {
                        _transactionManager = null;
                        Console.WriteLine("Waiting 1 second for Transaction Manager \"{0}\"", parser["tm"]);
                        System.Threading.Thread.Sleep(1000);
                    }
                }
            }

            Console.WriteLine("{0} RM: Transaction Manager retrieved at {1}", GlobalState.Name, parser["tm"]);

            while (GlobalState.Mode == GlobalState.RunMode.Loop)
            {
                try
                {
                    _transactionManager.Ping();
                }
                catch (WebException)
                {
                    _transactionManager = null;
                    ReconnectToTM();
                }
                isReady = true;
                System.Threading.Thread.Sleep(2000);
            }

            int loopCount = 0;

            while (GlobalState.Mode == GlobalState.RunMode.Wait && loopCount < 15)
            {
                System.Threading.Thread.Sleep(1000);
                loopCount++;
                Console.WriteLine("{0}: Waiting for transaction complete ({1} second(s))", GlobalState.Name, loopCount);
            }

            Console.WriteLine("{0}: Exitting", GlobalState.Name);
        }
Example #5
0
        static void Main(string[] args)
        {
            RMParser parser = new RMParser();
            if (!parser.Parse(args))
            {
                return;
            }

            GlobalState.Name = parser["n"].ToLower();
            string port_num = parser["p"];

            System.Console.WriteLine(string.Format("Starting resource manager for {0} on port {1}", GlobalState.Name, port_num));

            System.Collections.Specialized.ListDictionary channelProperties = new System.Collections.Specialized.ListDictionary();
            channelProperties.Add("port", port_num);
            channelProperties.Add("name", GlobalState.Name);

            HttpChannel channel = new HttpChannel(channelProperties, new SoapClientFormatterSinkProvider(), new SoapServerFormatterSinkProvider());
            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false);
            System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType
            (Type.GetType("MyRM.MyRM")									    // Assembly name
                  , "RM.soap"												// URI
                  , System.Runtime.Remoting.WellKnownObjectMode.Singleton	// Instancing mode
            );

            // activate the object
            string[] urls = channel.GetUrlsForUri("RM.soap");
            if (1 != urls.Length)
            {
                throw new InvalidOperationException();
            }

            MyRM resourceManager = (MyRM)System.Activator.GetObject(typeof(TP.RM), urls[0]);
            if (null == resourceManager)
            {
                throw new InvalidProgramException();
            }

            // initialize and start RM
            Console.WriteLine("{0}: Initializing", GlobalState.Name);
            resourceManager.Init(parser["n"], urls[0], parser["tm"]);

            Console.WriteLine("{0}: Running", GlobalState.Name);
            resourceManager.Run();

            Console.WriteLine("{0}: Exitting", GlobalState.Name);
        }
Example #6
0
        static void Main(string[] args)
        {
            isReady = false; // set isReady false because we want to make sure the actual code is not executed before the rm is going into the stable loop waiting.
            RMParser parser = new RMParser();
            if (!parser.Parse(args))
            {
                return;
            }

            GlobalState.Name = parser["n"].ToLower();
            string port_num = parser["p"];

            System.Collections.Specialized.ListDictionary channelProperties = new System.Collections.Specialized.ListDictionary();

            channelProperties.Add("port", port_num);
            channelProperties.Add("name", GlobalState.Name);

            HttpChannel channel = new HttpChannel(channelProperties, new SoapClientFormatterSinkProvider(), new SoapServerFormatterSinkProvider());

            System.Console.WriteLine(string.Format("Starting resource manager for {0} on port {1}", GlobalState.Name, port_num));
            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false);

            System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType
            (Type.GetType("MyRM.MyRM")									// Assembly name
                  , "RM.soap"												// URI
                  , System.Runtime.Remoting.WellKnownObjectMode.Singleton	// Instancing mode
            );

            if (String.Compare(parser["tm"], "none", true) != 0)
            {
                while (_transactionManager == null)
                {
                    tmUrl = parser["tm"];
                    try
                    {
                        _transactionManager = (TP.TM)System.Activator.GetObject(typeof(TP.TM), tmUrl);

                        _transactionManager.Ping();
                        urls = channel.GetUrlsForUri("RM.soap");
                        foreach (string url in urls)
                        {
                            _transactionManager.Register(url + "$" + GlobalState.Name);

                        }
                    }
                    catch (ArgumentException)
                    {
                        _transactionManager = null;
                        Console.WriteLine("Waiting 1 second for Transaction Manager \"{0}\"", parser["tm"]);
                        System.Threading.Thread.Sleep(1000);
                    }
                }
            }

            Console.WriteLine("{0} RM: Transaction Manager retrieved at {1}", GlobalState.Name, parser["tm"]);

            while (GlobalState.Mode == GlobalState.RunMode.Loop)
            {
                try
                {
                    _transactionManager.Ping();
                }
                catch(WebException)
                {
                    _transactionManager = null;
                    ReconnectToTM();
                }
                isReady = true;
                System.Threading.Thread.Sleep(2000);

            }

            int loopCount = 0;

            while (GlobalState.Mode == GlobalState.RunMode.Wait && loopCount < 15)
            {
                System.Threading.Thread.Sleep(1000);
                loopCount++;
                Console.WriteLine("{0}: Waiting for transaction complete ({1} second(s))", GlobalState.Name, loopCount);
            }

            Console.WriteLine("{0}: Exitting", GlobalState.Name);
        }