Beispiel #1
0
        public async Task <User> ValidarSenha(string login, string senha)
        {
            UsuarioValidarResponse usuarioValidarResponse;
            User usuario = new User();

            using (var proxy = new GenericProxy <SegurancaSoap>(Binding, Endpoint))
            {
                try
                {
                    var usuariovalidar = new UsuarioValidarRequest
                    {
                        login = login,
                        senha = senha,
                        SegurancaSoapHeader = await MRVFrameworkHelper.ValidaAcessoAsync(Configuration["MRVFramework:ApiKey"], Configuration["MRVFramework:CodigoSistema"])
                    };

                    usuarioValidarResponse = await proxy.Execute(c => c.UsuarioValidarAsync(usuariovalidar));

                    usuario = new User()
                    {
                        Name  = usuarioValidarResponse.UsuarioValidarResult.Nome,
                        Login = usuarioValidarResponse.UsuarioValidarResult.Login,
                        Email = usuarioValidarResponse.UsuarioValidarResult.Email
                    };

                    foreach (var grupo in usuarioValidarResponse.UsuarioValidarResult.Grupos)
                    {
                        usuario.Profile     = grupo.Nome;
                        usuario.ProfileCode = grupo.Codigo;
                    }
                }
                catch (FaultException faultException)
                {
                    throw new Exception("Acesso Inválido");
                }
                catch (Exception ex)
                {
                    if (ex.Message.IndexOf("Logon failure: unknown user name or bad password", StringComparison.Ordinal) != -1)
                    {
                        throw new Exception("Acesso Inválido");
                    }

                    else if (ex.Message.IndexOf("#E20", StringComparison.Ordinal) != -1 || ex.Message.IndexOf("#E21", StringComparison.Ordinal) != -1)
                    {
                        throw new Exception("Acesso Inválido");
                    }

                    else
                    {
                        throw new Exception("Acesso Inválido");
                    }
                }

                return(usuario);
            }
        }
Beispiel #2
0
        public static async Task GatherInfo(GenericProxy proxy)
        {
            await Task.Yield();

            //File.WriteAllText("serviceMessages.json", await proxy.GetServiceMessages());


            //File.WriteAllText("methods.json", await proxy.ListMethods());
            //File.WriteAllText("interfaces.json", await proxy.ListBidcosInterfaces());
            //File.WriteAllText("devices.json", await proxy.ListDevices("HEQ0356495"));
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                return;
            }

            Console.WriteLine("writer starts");
            byte[] one = new byte[100000];
            GenericProxy <CacheStream.IIOHelper> p = null;

            p = new SimpleIPC.GenericProxy <CacheStream.IIOHelper>(new SimpleIPC.Windows.SIPCProxy("cachestreamreader"));
            if (args[0] == "1")
            {
                Console.WriteLine("******System Cache Read Write Demo*******");
                CacheStream.IOHelper ioh = new CacheStream.IOHelper(@"test1.dat");
                Console.WriteLine("created d:\\test1.dat on system cache");
                for (int i = 0; i < one.Length; ++i)
                {
                    one[i] = 1;
                }

                bool bret = ioh.Write(one, 0, one.Length);
                Console.WriteLine("Wrote 100000 bytes with 1");
                Console.WriteLine("Sending IPC call to the Reader");
                p.Proxy.WroteBytes(Process.GetCurrentProcess().Id, ioh.hImageFile, 0, one.Length);
                Console.WriteLine("Sleeping for 5 seconds");
                System.Threading.Thread.Sleep(5000);
                ioh.Read(one, 0, one.Length);
                Console.WriteLine("read {0} bytes with {1}", one.Length, one[0]);
            }
            else
            {
                Console.WriteLine("\n\n******ReadProcessMemory WriteProcessMeory Demo*******");
                for (int i = 0; i < one.Length; ++i)
                {
                    one[i] = 3;
                }
                GCHandle handle = GCHandle.Alloc(one, GCHandleType.Pinned);
                Console.WriteLine("Wrote 100000 bytes with 3");
                Console.WriteLine("Sending IPC call to the Reader");
                p.Proxy.WroteMemBytes(Process.GetCurrentProcess().Id, handle.AddrOfPinnedObject(), one.Length);
                Console.WriteLine("Sleeping for 5 seconds");
                System.Threading.Thread.Sleep(5000);
                Console.WriteLine("Remote Read 100000 bytes with {0}", one[0]);
                handle.Free();
                p.Dispose();
            }
            Console.WriteLine("press any key to stop");
            Console.ReadKey();
            Console.WriteLine("writer stops");
        }
        public void MethodInvocationWithGenericParameterTest(int iterations)
        {
            var proxy     = new GenericProxy(new Generic());
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            for (var i = 0; i < iterations; i++)
            {
                proxy.Invoke(i);
            }

            stopwatch.Stop();

            Report.Instance.Write("Regular", "n/a", Scenario.MethodInvocationWithGenericParameter, iterations, stopwatch.Elapsed);
        }
        public void MethodInvocationWithGenericParameterTest(int iterations)
        {
            var proxy = new GenericProxy(new Generic());
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            for (var i = 0; i < iterations; i++)
            {
                proxy.Invoke(i);
            }

            stopwatch.Stop();

            Report.Instance.Write("Regular", "n/a", Scenario.MethodInvocationWithGenericParameter, iterations, stopwatch.Elapsed);
        }
Beispiel #6
0
        public void publish(object o)
        {
            string cbservername = o as string;

            System.Threading.Thread.Sleep(1000);
            Console.WriteLine("publishing to client for ticket#  {0}, name:{1}", 100, current_name);
            GenericProxy <Example.ICallbackInterface> p = null;

            if (winmode)
            {
                p = new SimpleIPC.GenericProxy <Example.ICallbackInterface>(new SimpleIPC.Windows.SIPCProxy(cbservername));
            }
            else
            {
                p = new SimpleIPC.GenericProxy <Example.ICallbackInterface>(new SimpleIPC.NamedObject.SIPCProxy(cbservername));
            }

            p.Proxy.update(100, new Example.regdata {
                name = current_name, regid = Guid.NewGuid().ToString()
            });
            p.Dispose();
        }
Beispiel #7
0
        public static async Task GatherInfo(GenericProxy proxy)
        {
            await Task.Yield();
            //File.WriteAllText("serviceMessages.json", await proxy.GetServiceMessages());


            //File.WriteAllText("methods.json", await proxy.ListMethods());
            //File.WriteAllText("interfaces.json", await proxy.ListBidcosInterfaces());
            //File.WriteAllText("devices.json", await proxy.ListDevices("HEQ0356495"));
        }
Beispiel #8
0
 public Blind(string address, GenericProxy genericProxy)
 {
     _genericProxy = genericProxy;
     Address = address;
 }
Beispiel #9
0
 public Dimmer(string address, GenericProxy genericProxy)
 {
     _genericProxy = genericProxy;
     Address = address;
 }
Beispiel #10
0
 public PrincipalController()
 {
     _clientProxy  = new ClientProxy();
     _genericProxy = new GenericProxy();
 }
Beispiel #11
0
        public static async Task Test()
        {
            var endpoint = new IPEndPoint(IPAddress.Parse("192.168.63.3"), 2001);

            using (var client = new HmRpcClient(endpoint))
            {
                var stopwatch = new Stopwatch();

                stopwatch.Start();
                await client.ConnectAsync();

                Console.WriteLine("Connect: {0}ms.", stopwatch.Elapsed.TotalMilliseconds);

                var proxy = new GenericProxy(client);

                var req1 = new Request {
                    Method = "setValue", Parameters = { "HEQ0359881:1", "LEVEL", 1d, "FLOAT" }
                };
                var req2 = new Request {
                    Method = "setValue", Parameters = { "HEQ0359959:1", "LEVEL", 1d, "FLOAT" }
                };
                var req3 = new Request {
                    Method = "setValue", Parameters = { "IEQ0019224:1", "LEVEL", 0d, "FLOAT" }
                };
                var req4 = new Request {
                    Method = "setValue", Parameters = { "IEQ0020290:1", "LEVEL", 0d, "FLOAT" }
                };
                var req5 = new Request {
                    Method = "setValue", Parameters = { "IEQ0020353:1", "LEVEL", 0d, "FLOAT" }
                };

                //var response = await proxy.MultiCall(req1, req2/*, req3, req4, req5*/);

                var req1_ = new Request {
                    Method = "setValue", Parameters = { "HEQ0359881:1", "LEVEL", 0d, "FLOAT" }
                };
                var req2_ = new Request {
                    Method = "setValue", Parameters = { "HEQ0359959:1", "LEVEL", 0d, "FLOAT" }
                };
                var req3_ = new Request {
                    Method = "setValue", Parameters = { "IEQ0019224:1", "LEVEL", 1d, "FLOAT" }
                };
                var req4_ = new Request {
                    Method = "setValue", Parameters = { "IEQ0020290:1", "LEVEL", 1d, "FLOAT" }
                };
                var req5_ = new Request {
                    Method = "setValue", Parameters = { "IEQ0020353:1", "LEVEL", 1d, "FLOAT" }
                };

                //var response_ = await proxy.MultiCall(req1_, req2_, req3_, req4_, req5_);
                //return;

                var pong = await client.ExecuteRequest(new Request { Method = "init", Parameters = { "binary://192.168.63.192:6300", "TEST-" + DateTime.Now.ToString("hhmm", System.Globalization.CultureInfo.GetCultureInfo("nl-NL")), 0 } });

                Console.WriteLine(pong);

                Console.ReadLine();
                var deInit = await client.ExecuteRequest(new Request { Method = "init", Parameters = { "binary://192.168.63.192:6300", "" /* "TEST-" + DateTime.Now.ToString("hhmm")*/, 0 } });


                return;

                await GatherInfo(proxy);

                return;

                var defBlind = Devices["blind_door"];
                var blind    = (Blind)Activator.CreateInstance(defBlind.Item2, defBlind.Item1, proxy);
                stopwatch.Restart();
                await blind.SetLevel(0.5d);

                Console.WriteLine("Blind.SetLevel: {0}ms.", stopwatch.Elapsed.TotalMilliseconds);

                Console.ReadLine();
                Thread.Sleep(1000);
                await blind.SetLevel(1d);

                return;

                var defDimmer = Devices["dimmer_dining"];
                var dimmer    = (Dimmer)Activator.CreateInstance(defDimmer.Item2, defDimmer.Item1, proxy);


                var defSwitch = Devices["switch_hallway"];
                var @switch   = (Switch)Activator.CreateInstance(defSwitch.Item2, defSwitch.Item1, proxy);

                await @switch.SetState(true);

                Thread.Sleep(2000);

                await @switch.SetState(false);



                for (double i = 0; i <= 1; i += 0.1)
                {
                    await dimmer.SetLevel(i);

                    Thread.Sleep(500);
                }
                await dimmer.SetLevel(0d);


                //Console.WriteLine(response);
            }
        }
Beispiel #12
0
 public PaymentServiceStartUp(Logger logger)
 {
     this.logger       = logger;
     mMutex            = new Mutex();
     payServiceConnect = new GenericProxy <IPaymentService.IPayService>(new NetTcpBinding(), new EndpointAddress(Endpoint));
 }
Beispiel #13
0
 public Dimmer(string address, GenericProxy genericProxy)
 {
     _genericProxy = genericProxy;
     Address       = address;
 }
Beispiel #14
0
        public static async Task Test()
        {
            var endpoint = new IPEndPoint(IPAddress.Parse("192.168.63.3"), 2001);
            using (var client = new HmRpcClient(endpoint))
            {
                var stopwatch = new Stopwatch();

                stopwatch.Start();
                await client.ConnectAsync();
                Console.WriteLine("Connect: {0}ms.", stopwatch.Elapsed.TotalMilliseconds);

                var proxy = new GenericProxy(client);

                var req1 = new Request { Method = "setValue", Parameters = { "HEQ0359881:1", "LEVEL", 1d, "FLOAT" } };
                var req2 = new Request { Method = "setValue", Parameters = { "HEQ0359959:1", "LEVEL", 1d, "FLOAT" } };
                var req3 = new Request { Method = "setValue", Parameters = { "IEQ0019224:1", "LEVEL", 0d, "FLOAT" } };
                var req4 = new Request { Method = "setValue", Parameters = { "IEQ0020290:1", "LEVEL", 0d, "FLOAT" } };
                var req5 = new Request { Method = "setValue", Parameters = { "IEQ0020353:1", "LEVEL", 0d, "FLOAT" } };

                //var response = await proxy.MultiCall(req1, req2/*, req3, req4, req5*/);

                var req1_ = new Request { Method = "setValue", Parameters = { "HEQ0359881:1", "LEVEL", 0d, "FLOAT" } };
                var req2_ = new Request { Method = "setValue", Parameters = { "HEQ0359959:1", "LEVEL", 0d, "FLOAT" } };
                var req3_ = new Request { Method = "setValue", Parameters = { "IEQ0019224:1", "LEVEL", 1d, "FLOAT" } };
                var req4_ = new Request { Method = "setValue", Parameters = { "IEQ0020290:1", "LEVEL", 1d, "FLOAT" } };
                var req5_ = new Request { Method = "setValue", Parameters = { "IEQ0020353:1", "LEVEL", 1d, "FLOAT" } };

                //var response_ = await proxy.MultiCall(req1_, req2_, req3_, req4_, req5_);
                //return;

                var pong = await client.ExecuteRequest(new Request { Method = "init", Parameters = { "binary://192.168.63.192:6300", "TEST-" + DateTime.Now.ToString("hhmm", System.Globalization.CultureInfo.GetCultureInfo("nl-NL")), 0 } });
                Console.WriteLine(pong);

                Console.ReadLine();
                var deInit = await client.ExecuteRequest(new Request { Method = "init", Parameters = { "binary://192.168.63.192:6300", "" /* "TEST-" + DateTime.Now.ToString("hhmm")*/, 0 } });


                return;

                await GatherInfo(proxy);
                return;

                var defBlind = Devices["blind_door"];
                var blind = (Blind)Activator.CreateInstance(defBlind.Item2, defBlind.Item1, proxy);
                stopwatch.Restart();
                await blind.SetLevel(0.5d);
                Console.WriteLine("Blind.SetLevel: {0}ms.", stopwatch.Elapsed.TotalMilliseconds);

                Console.ReadLine();
                Thread.Sleep(1000);
                await blind.SetLevel(1d);
                return;

                var defDimmer = Devices["dimmer_dining"];
                var dimmer = (Dimmer)Activator.CreateInstance(defDimmer.Item2, defDimmer.Item1, proxy);


                var defSwitch = Devices["switch_hallway"];
                var @switch = (Switch)Activator.CreateInstance(defSwitch.Item2, defSwitch.Item1, proxy);

                await @switch.SetState(true);
                Thread.Sleep(2000);

                await @switch.SetState(false);



                for (double i = 0; i <= 1; i += 0.1)
                {
                    await dimmer.SetLevel(i);
                    Thread.Sleep(500);
                }
                await dimmer.SetLevel(0d);


                //Console.WriteLine(response);
            }

        }
Beispiel #15
0
 public Switch(string address, GenericProxy genericProxy)
 {
     _genericProxy = genericProxy;
     Address = address;
 }
Beispiel #16
0
 public Switch(string address, GenericProxy genericProxy)
 {
     _genericProxy = genericProxy;
     Address       = address;
 }
Beispiel #17
0
 public Blind(string address, GenericProxy genericProxy)
 {
     _genericProxy = genericProxy;
     Address       = address;
 }