Ejemplo n.º 1
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            IChatService chatService = InterfaceProxy.Resolve <IChatService>();
            string       result      = chatService.Hi("李四", "世界和平");

            MessageBox.Show(result);
        }
Ejemplo n.º 2
0
        public string Post(string posturl, string postData)
        {
            string requestResult = InterfaceProxy.GetResult(this.HttpContext.Request, _host + posturl,
                                                            "application/json", "application/json", "post", postData);

            return(requestResult);
        }
Ejemplo n.º 3
0
        ///// <summary>
        ///// 初始化长连接
        ///// </summary>
        ///// <param name="config"></param>
        //public static void Connect(string config)
        //{
        //    MConfiguration.Bind<Config.MConfig>(config);
        //    Connect(Config.MConfig.Host, Config.MConfig.Port);
        //}
        ///// <summary>
        ///// 初始化长连接
        ///// </summary>
        ///// <param name="Host"></param>
        ///// <param name="Port"></param>
        //public static void Connect(string Host, int Port)
        //{
        //    NettyContainer.Client.Connect(Host, Port);

        //}

        /// <summary>
        /// 初始化客户端
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="Host"></param>
        /// <param name="Port"></param>
        /// <returns></returns>
        public static T Client <T>(string config) where T : class
        {
            MConfiguration.Bind <Config.MConfig>(config);
            T client = InterfaceProxy.Resolve <T>();

            return(client);
        }
Ejemplo n.º 4
0
        public T CreateYard()
        {
            var interceptor = new ServiceInterceptor <T>(ThePools, App, Version);
            var result      = InterfaceProxy.New <T>(interceptor);

            return(result);
        }
Ejemplo n.º 5
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            IChatService chatService = InterfaceProxy.Resolve <IChatService>();
            string       result      = chatService.Hello(1);
            string       result1     = chatService.Hello(1.2);

            MessageBox.Show(result);
            MessageBox.Show(result1);
        }
Ejemplo n.º 6
0
        public InterfaceProxyTest()
        {
            answerCallback = PostEmptyAnswerTo;
            publisher      = new Mock <IPublisher <Message> >();
            publisher.Setup(it => it.Publish(It.IsAny <Message>())).Callback <Message>(it => answerCallback?.Invoke(it));

            _callHandler = CallHandler.CreateHandlerFor <ITestClass>(commandsObservable, publisher.Object);
            instance     = InterfaceProxy <ITestClass> .Create(_callHandler);
        }
Ejemplo n.º 7
0
        public async void Startup(string subEndpoint, string rpcEndpoint)
        {
            await Task.Yield();

            IFormatter formatter = new JsonFormatter();

            _rpcClient        = new ZmqRemoteCallClient(rpcEndpoint, formatter, TimeSpan.FromSeconds(3));
            _subClient        = new ZmqSubClient <RadarMuxTrack>(subEndpoint, formatter, onRadarMuxTrack, "tracks");
            _radarMuxCommands = InterfaceProxy.CreateObject <IRadarMuxCommands>(_rpcClient, "Commands");
        }
Ejemplo n.º 8
0
        private void TryVersion(RDPClientVersion clientVersion, MethodInvoker doApplyVersion)
        {
            try
            {
                if (lastDetectedVersion == RDPClientVersion.Unknown || lastDetectedVersion == clientVersion)
                {
                    doApplyVersion();
                    parent.Controls.Add((Control)client);                     // can throw a COMException

                    // Finish initialization - com object proxies
                    TrySetSecuredSettings(client.SecuredSettings, typeof(IMsTscSecuredSettings));
                    TrySetSecuredSettings(client.SecuredSettings2, typeof(IMsRdpClientSecuredSettings));

                    TrySetAdvancedSettings(client.AdvancedSettings9, typeof(MSTSCLib.IMsRdpClientAdvancedSettings8));
                    TrySetAdvancedSettings(client.AdvancedSettings8, typeof(MSTSCLib.IMsRdpClientAdvancedSettings7));
                    TrySetAdvancedSettings(client.AdvancedSettings7, typeof(MSTSCLib.IMsRdpClientAdvancedSettings6));
                    TrySetAdvancedSettings(client.AdvancedSettings6, typeof(MSTSCLib.IMsRdpClientAdvancedSettings5));
                    TrySetAdvancedSettings(client.AdvancedSettings5, typeof(MSTSCLib.IMsRdpClientAdvancedSettings4));
                    TrySetAdvancedSettings(client.AdvancedSettings3, typeof(MSTSCLib.IMsRdpClientAdvancedSettings2));
                    TrySetAdvancedSettings(client.AdvancedSettings2, typeof(MSTSCLib.IMsRdpClientAdvancedSettings));
                    TrySetAdvancedSettings(client.AdvancedSettings, typeof(MSTSCLib.IMsTscAdvancedSettings));

                    if (AdvancedSettings == null)
                    {
                        throw new NotSupportedException();
                    }

                    transportSettingsProxy = new InterfaceProxy <ITransportSettings>();
                    transportSettingsProxy.TargetInstance = client.TransportSettings2;
                    transportSettingsProxy.TargetType     = typeof(IMsRdpClientTransportSettings2);
                    TransportSettings = transportSettingsProxy.GetStrongTypedProxy();

                    host        = (AxHost)client;
                    host.Width  = host.Parent.ClientRectangle.Width;
                    host.Height = host.Parent.ClientRectangle.Height;

                    host.Visible = false;

                    lastDetectedVersion = clientVersion;
                }
            }
            catch (COMException ex)
            {
                if (parent.Controls.Contains((Control)client))
                {
                    parent.Controls.Remove((Control)client);                     // yes, this is required!
                }
                host   = null;
                client = null;
                System.Diagnostics.Debug.WriteLine(clientVersion + " failed to initialize: " + ex.Message);
                lastDetectedVersion = RDPClientVersion.Unknown;
            }
        }
Ejemplo n.º 9
0
        void start(string rpcEndPoint)
        {
            IFormatter formatter = new JsonFormatter();

            _zmqClient    = new ZmqRemoteCallClient(rpcEndPoint, formatter, TimeSpan.FromSeconds(15));
            _configClient = InterfaceProxy.CreateObject <IConfigService>(_zmqClient, "RadarConfig");
            InterfaceProxy <IRadarChannelMaintainer> proxy = new InterfaceProxy <IRadarChannelMaintainer>(_zmqClient, "RadarChannels");

            _radarChannelsMaintainer = proxy.Object;
            _radarChannelsMaintainer = InterfaceProxy.CreateObject <IRadarChannelMaintainer>(_zmqClient, "RadarChannels");
            _regionClient            = InterfaceProxy.CreateObject <IRadarRegionMaintainer>(_zmqClient, "RadarRegions");
        }
Ejemplo n.º 10
0
        public Sandbox(IObservable <Message> messagesObservable, IPublisher <Message> messagePublisher)
        {
            _messagePublisher = messagePublisher;
            Guard.IsInterface <TInterface>();
            Guard.NotNull(messagePublisher);
            Guard.NotNull(messagesObservable);
            _callHandler = CallHandler.CreateHandlerFor <TInterface>(messagesObservable, messagePublisher);
            Instance     = InterfaceProxy <TInterface> .Create(_callHandler);

            _commandsSubscription = messagesObservable.Subscribe(ExecuteCommand, ex => _exceptionHandlerSubject.OnNext(ex), () => _onProcessEnded.OnNext(Unit.Default));
            _disposeHandlers.Add(_exceptionHandlerSubject.Subscribe(ex => _onProcessEnded.OnNext(Unit.Default)));
            messagePublisher.Publish(new CreateObjectOfTypeCommand {
                TypeFullName = typeof(TObject).FullName, AssemblyPath = typeof(TObject).Assembly.Location
            });
        }
Ejemplo n.º 11
0
        public ActionResult SendSMS(string User, string Pass, string Mobiles, string Content, string SendTime)
        {
            SendSMSResult ret = new SendSMSResult();

            // 判断参数合法性
            if (string.IsNullOrWhiteSpace(User))
            {
                ret.Result = _ERR_USERISEMPTY;
            }
            else if (string.IsNullOrWhiteSpace(Pass))
            {
                ret.Result = _ERR_PASSISEMPTY;
            }
            else if (string.IsNullOrWhiteSpace(Mobiles))
            {
                ret.Result = _ERR_DESTISEMPTY;
            }
            else
            {
                // 发送短信
                try
                {
                    var r = InterfaceProxy.GetSendService().SendSMS(User, Pass, Content, Mobiles.Split(',').ToList(), "http");
                    if (r.Success)
                    {
                        ret.Result = _ERR_SUCCESS;
                        ret.MsgID  = r.Value.Message.ID;
                        if (r.Value.Message.AuditType == SMS.Model.AuditType.Manual)
                        {
                            Util.SendToDoToSMSAuditor(r.Value.Message);
                        }
                    }
                    else
                    {
                        ret.Result = r.Message;
                    }
                }
                catch (Exception ex)
                {
                    ret.Result = _ERR_SERVICE;
                }
            }

            string data = JsonSerialize.Serialize <SendSMSResult>(ret);

            return(base.Content(data));
        }
Ejemplo n.º 12
0
        public ActionResult GetMO(string User, string Pass)
        {
            GetSMSResult ret = new GetSMSResult();

            if (string.IsNullOrWhiteSpace(User))
            {
                ret.Result = _ERR_USERISEMPTY;
            }

            if (string.IsNullOrWhiteSpace(Pass))
            {
                ret.Result = _ERR_PASSISEMPTY;
            }
            try
            {
                SMS.Model.RPCResult <List <SMS.Model.MOSMS> > mos = InterfaceProxy.GetSendService().GetSMS(User, Pass);

                if (mos.Success)
                {
                    ret.Result = _ERR_SUCCESS;
                    List <SMS.Model.MOSMS> msgs = mos.Value;

                    ret.MONum = msgs.Count.ToString();

                    ret.Msgs = (from mo in msgs
                                select new MO()
                    {
                        Mobile = mo.UserNumber,
                        Content = mo.Message,
                        MOTime = mo.ReceiveTime.ToString()
                    }).ToList();
                }
                else
                {
                    ret.Result = mos.Message;
                }
            }
            catch (Exception ex)
            {
                ret.Result = _ERR_SERVICE;
            }
            string data = JsonSerialize.Serialize <GetSMSResult>(ret);

            return(Content(data));
        }
Ejemplo n.º 13
0
 private void TrySetAdvancedSettings(object targetInstance, Type targetType)
 {
     try
     {
         if (AdvancedSettings == null && targetInstance != null)
         {
             advancedSettingsProxy = new InterfaceProxy <IAdvancedSettings>();
             advancedSettingsProxy.TargetInstance = targetInstance;
             advancedSettingsProxy.TargetType     = targetType;
             AdvancedSettings = advancedSettingsProxy.GetStrongTypedProxy();
             advancedSettingsProxy.SettingsChanged += advancedSettingsProxy_SettingsChanged;
         }
     }
     catch
     {
         AdvancedSettings = null;
     }
 }
Ejemplo n.º 14
0
        public ActionResult GetReport(string User, string Pass, string MsgID)
        {
            GetReportResult ret = new GetReportResult();

            if (string.IsNullOrWhiteSpace(User))
            {
                ret.Result = _ERR_USERISEMPTY;
            }

            if (string.IsNullOrWhiteSpace(Pass))
            {
                ret.Result = _ERR_PASSISEMPTY;
            }
            try
            {
                var r = InterfaceProxy.GetSendService().GetReport(User, Pass, MsgID);

                if (r.Success)
                {
                    ret.Result = _ERR_SUCCESS;
                    List <SMS.Model.StatusReport> rts = r.Value;

                    ret.Reports = (from sr in rts
                                   select new Report()
                    {
                        MsgID = sr.SMSID,
                        Mobile = sr.Number,
                        Status = sr.Succeed ? "true" : "false"
                    }).ToList();
                }
                else
                {
                    ret.Result = r.Message;
                }
            }
            catch (Exception ex)
            {
                ret.Result = _ERR_SERVICE;
            }

            string data = JsonSerialize.Serialize <GetReportResult>(ret);

            return(Content(data));
        }
Ejemplo n.º 15
0
        private void TrySetSecuredSettings(object targetInstance, Type targetType)
        {
            try
            {
                if (SecuredSettings == null && targetInstance != null)
                {
                    securedSettingsProxy = new InterfaceProxy <ISecuredSettings>();
                    securedSettingsProxy.TargetInstance = targetInstance;
                    securedSettingsProxy.TargetType     = targetType;
                    SecuredSettings = securedSettingsProxy.GetStrongTypedProxy();

                    string test = SecuredSettings.WorkDir;
                }
            }
            catch
            {
                SecuredSettings = null;
            }
        }
        private static object New(Type clazz)
        {
            object[] attrs = clazz.GetCustomAttributes(typeof(ServiceObjectAttribute), false);
            if (attrs.Length <= 0)
            {
                return(ServiceBaseContainer.Current.Get(clazz));
            }
            ServiceObjectAttribute attr = (ServiceObjectAttribute)attrs[0];

            if (attr.ServiceFilter == null)
            {
                throw new ArgumentException();
            }
            object filter = ServiceFilterContainer.Current.Get(attr.ServiceFilter);

            if (filter == null)
            {
                throw new ArgumentException();
            }
            return(InterfaceProxy.New(clazz, (InvocationHandler)filter));
        }
Ejemplo n.º 17
0
        public ActionResult GetBalance(string User, string Pass)
        {
            string _Result     = "";
            int    _SmsBalance = 0;

            if (string.IsNullOrWhiteSpace(User))
            {
                _Result = _ERR_USERISEMPTY;
            }

            else if (string.IsNullOrWhiteSpace(Pass))
            {
                _Result = _ERR_PASSISEMPTY;
            }
            // 查询余额
            try
            {
                SMS.Model.RPCResult <SMS.Model.UserBalance> r = InterfaceProxy.GetSendService().GetBalanceByPlainPass(User, Pass);
                if (r.Success)
                {
                    _Result     = _ERR_SUCCESS;
                    _SmsBalance = r.Value.SmsBalance;
                }
                else
                {
                    _Result = r.Message;
                }
            }
            catch (Exception ex)
            {
                _Result = _ERR_SERVICE;
            }
            GetBalanceResult ret = new GetBalanceResult();

            ret.Result     = _Result;
            ret.SmsBalance = _SmsBalance.ToString();
            string data = JsonSerialize.Serialize <GetBalanceResult>(ret);

            return(Content(data));
        }
Ejemplo n.º 18
0
 /// <summary>Create a instance, wrapping the specified proxy</summary>
 public InterfaceNHibernateImpl(Func <IFrozenContext> lazyCtx, InterfaceProxy proxy)
     : base(lazyCtx, proxy) // pass proxy to parent
 {
     this.Proxy = proxy;
 }
Ejemplo n.º 19
0
        object InvocationHandler.InvokeMember(object obj, int rid, string name, params object[] args)
        {
            MethodBase met = InterfaceProxy.GetMethod(obj, rid);

            return(this.InvokeMember(this.ServiceBase, met, args));
        }
Ejemplo n.º 20
0
 /// <summary>Create a instance, wrapping the specified proxy</summary>
 public InterfaceNHibernateImpl(Func<IFrozenContext> lazyCtx, InterfaceProxy proxy)
     : base(lazyCtx, proxy) // pass proxy to parent
 {
     this.Proxy = proxy;
 }