예제 #1
0
        public static CenRfgwController GetNewErGatewayController(string key, string name, string id, string gatewayType)
        {
            uint           uid;
            eExGatewayType type;

            try
            {
                uid  = Convert.ToUInt32(id, 16);
                type = (eExGatewayType)Enum.Parse(typeof(eExGatewayType), gatewayType, true);
                var cs = Global.ControlSystem;

                GatewayBase gw = null;
                switch (type)
                {
                case eExGatewayType.Ethernet:
                    gw = new CenErfgwPoe(uid, cs);
                    break;

                case eExGatewayType.EthernetShared:
                    gw = new CenErfgwPoeEthernetSharable(uid, cs);
                    break;

                case eExGatewayType.Cresnet:
                    gw = new CenErfgwPoeCresnet(uid, cs);
                    break;
                }
                return(new CenRfgwController(key, name, gw));
            }
            catch (Exception)
            {
                Debug.Console(0, "ERROR: Cannot create EX Gateway, id {0}, type {1}", id, gatewayType);
                return(null);
            }
        }
예제 #2
0
        /// <summary>
        /// 初始化支付事件数据的基类
        /// </summary>
        /// <param name="gateway">支付网关</param>
        public PaymentEventArgs(GatewayBase gateway)
        {
            this.gateway = gateway;
#if NETSTANDARD2_0
            notifyServerHostAddress = HttpUtil.Current.Request.Host.Host;
#elif NET46
            notifyServerHostAddress = HttpUtil.Current.Request.UserHostAddress;
#endif
        }
예제 #3
0
 //-------------------------------------------------------------------------
 // App startup
 static void AppStartup(string database, Dictionary <string, string> settings)
 {
     //can use App.Config instead
     //var appsettings = ConfigurationManager.AppSettings;
     //var settings = appsettings.AllKeys
     //  .ToDictionary(k => _settingsdict[k], k => appsettings[k]);
     _gateway = Andl.Gateway.GatewayFactory.Create(database, settings);
     _gateway.JsonReturnFlag = true; // FIX: s/b default
 }
예제 #4
0
 internal void Repl()
 {
     _api = GatewayFactory.Create(DatabaseName, _settingsdict);
     for (; ;)
     {
         Console.Write(">>>");
         var line = Console.ReadLine();
         Run(line);
     }
 }
예제 #5
0
        public static GatewayBase Find(string id)
        {
            GatewayBase gw = Gateways.FirstOrDefault(m => m.Id == id);

            if (gw == null)
            {
                gw = RecurringGateways.FirstOrDefault(m => m.Id == id);
            }

            return(gw);
        }
예제 #6
0
 /// <summary>Register service method implementations with a service binder. Useful when customizing the service binding logic.
 /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
 /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static void BindService(grpc::ServiceBinderBase serviceBinder, GatewayBase serviceImpl)
 {
     serviceBinder.AddMethod(__Method_Topology, serviceImpl.Topology);
     serviceBinder.AddMethod(__Method_DeployWorkflow, serviceImpl.DeployWorkflow);
     serviceBinder.AddMethod(__Method_PublishMessage, serviceImpl.PublishMessage);
     serviceBinder.AddMethod(__Method_UpdateJobRetries, serviceImpl.UpdateJobRetries);
     serviceBinder.AddMethod(__Method_FailJob, serviceImpl.FailJob);
     serviceBinder.AddMethod(__Method_CompleteJob, serviceImpl.CompleteJob);
     serviceBinder.AddMethod(__Method_CreateWorkflowInstance, serviceImpl.CreateWorkflowInstance);
     serviceBinder.AddMethod(__Method_CancelWorkflowInstance, serviceImpl.CancelWorkflowInstance);
     serviceBinder.AddMethod(__Method_UpdateWorkflowInstancePayload, serviceImpl.UpdateWorkflowInstancePayload);
     serviceBinder.AddMethod(__Method_ActivateJobs, serviceImpl.ActivateJobs);
     serviceBinder.AddMethod(__Method_ListWorkflows, serviceImpl.ListWorkflows);
     serviceBinder.AddMethod(__Method_GetWorkflow, serviceImpl.GetWorkflow);
     serviceBinder.AddMethod(__Method_ResolveIncident, serviceImpl.ResolveIncident);
 }
예제 #7
0
 /// <summary>Creates service definition that can be registered with a server</summary>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static grpc::ServerServiceDefinition BindService(GatewayBase serviceImpl)
 {
     return(grpc::ServerServiceDefinition.CreateBuilder()
            .AddMethod(__Method_Topology, serviceImpl.Topology)
            .AddMethod(__Method_DeployWorkflow, serviceImpl.DeployWorkflow)
            .AddMethod(__Method_PublishMessage, serviceImpl.PublishMessage)
            .AddMethod(__Method_UpdateJobRetries, serviceImpl.UpdateJobRetries)
            .AddMethod(__Method_FailJob, serviceImpl.FailJob)
            .AddMethod(__Method_CompleteJob, serviceImpl.CompleteJob)
            .AddMethod(__Method_CreateWorkflowInstance, serviceImpl.CreateWorkflowInstance)
            .AddMethod(__Method_CancelWorkflowInstance, serviceImpl.CancelWorkflowInstance)
            .AddMethod(__Method_UpdateWorkflowInstancePayload, serviceImpl.UpdateWorkflowInstancePayload)
            .AddMethod(__Method_ActivateJobs, serviceImpl.ActivateJobs)
            .AddMethod(__Method_ListWorkflows, serviceImpl.ListWorkflows)
            .AddMethod(__Method_GetWorkflow, serviceImpl.GetWorkflow)
            .AddMethod(__Method_ResolveIncident, serviceImpl.ResolveIncident).Build());
 }
예제 #8
0
        // main entry creates and launches the server
        static void Main(string[] args)
        {
            Console.WriteLine("Andl Thrift Server");
            Logger.Open(0); // no default logging
            var options = OptionParser.Create(_options, Help);

            if (!options.Parse(args))
            {
                return;
            }
            GatewayBase gateway = null;

            try {
                gateway = AppStartup(options.GetPath(0), _settings);
                Processor        processor       = new Processor(gateway);
                TServerTransport serverTransport = new TServerSocket(ServerPort);

                // There are several different servers available. They should all work.

                Server = new TThreadPoolServer(processor, serverTransport);
                //TServer server = new TThreadPoolServer(processor, serverTransport);
                //TServer server = new TThreadPoolServer(processor, serverTransport, new TTransportFactory(), new TCompactProtocol.Factory());
                //TServer server = new TThreadedServer(processor, serverTransport);
                //TServer server = new TSimpleServer(processor, serverTransport);

                Server.setEventHandler(new ServerEventHandler());
                gateway.OpenSession();
                Console.WriteLine($"Starting server...database '{gateway.DatabaseName}' {gateway.DatabaseKind}");
                Server.Serve();
                gateway.CloseSession(true);
            } catch (ProgramException ex) {
                Console.WriteLine(ex.ToString());
                if (gateway != null)
                {
                    gateway.CloseSession(false);
                }
            } catch (Exception ex) {
                Console.WriteLine(ex.ToString());
                if (gateway != null)
                {
                    gateway.CloseSession(false);
                }
            }
            Console.WriteLine("done.");
        }
예제 #9
0
        /// <summary>
        /// 接收并验证网关的支付通知
        /// </summary>
        public void Received(PaymentNotifyMethod paymentNotifyMethod)
        {
            GatewayBase gateway = NotifyProcess.GetGateway();

            gateway.PaymentNotifyMethod = paymentNotifyMethod;
            if (gateway.GatewayType != GatewayType.None)
            {
                gateway.Merchant = GetMerchant(gateway.GatewayType);
                if (gateway.ValidateNotify())
                {
                    OnPaymentSucceed(new PaymentSucceedEventArgs(gateway));
                    gateway.WriteSucceedFlag();
                }
                else
                {
                    OnPaymentFailed(new PaymentFailedEventArgs(gateway));
                }
            }
            else
            {
                gateway.PaymentNotifyMethod = PaymentNotifyMethod.None;
                OnUnknownGateway(new UnknownGatewayEventArgs(gateway));
            }
        }
예제 #10
0
 /// <summary>
 /// 初始化支付失败网关事件数据
 /// </summary>
 /// <param name="gateway">支付网关</param>
 public PaymentFailedEventArgs(GatewayBase gateway)
     : base(gateway)
 {
 }
예제 #11
0
 public ModelBase(GatewayBase gateway)
 {
     this.Gateway = gateway;
 }
예제 #12
0
 /// <summary>
 /// 初始化支付失败网关事件数据
 /// </summary>
 /// <param name="gateway">支付网关</param>
 public PaymentFailedEventArgs(GatewayBase gateway)
     : base(gateway)
 {
 }
예제 #13
0
 /// <summary>
 /// 初始化未知网关事件数据
 /// </summary>
 /// <param name="gateway">支付网关</param>
 public UnknownGatewayEventArgs(GatewayBase gateway)
     : base(gateway)
 {
 }
예제 #14
0
 /// <summary>
 /// 初始化支付成功网关事件数据
 /// </summary>
 /// <param name="gateway">支付网关</param>
 public PaymentSucceedEventArgs(GatewayBase gateway)
     : base(gateway)
 {
 }
예제 #15
0
 /// <summary>
 /// 初始化未知网关事件数据
 /// </summary>
 /// <param name="gateway">支付网关</param>
 public UnknownGatewayEventArgs(GatewayBase gateway)
     : base(gateway)
 {
 }
예제 #16
0
 internal void Exec()
 {
     _api = GatewayFactory.Create(DatabaseName, _settingsdict);
     Run("fact:0(n:0) => if(n<=1,1,n*fact(n-1))");
     Run("fact(6)");
 }
예제 #17
0
 /// <summary>
 /// Constructor for the on-board gateway
 /// </summary>
 /// <param name="key"></param>
 /// <param name="name"></param>
 public CenRfgwController(string key, string name, GatewayBase gateway) :
     base(key, name, gateway)
 {
 }
예제 #18
0
 /// <summary>
 /// 初始化支付事件数据的基类
 /// </summary>
 /// <param name="gateway">支付网关</param>
 public PaymentEventArgs(GatewayBase gateway)
 {
     this.gateway            = gateway;
     notifyServerHostAddress = System.Web.HttpContext.Current.Request.UserHostAddress;
 }
예제 #19
0
 /// <summary>
 /// 初始化支付成功网关事件数据
 /// </summary>
 /// <param name="gateway">支付网关</param>
 public PaymentSucceedEventArgs(GatewayBase gateway)
     : base(gateway)
 {
 }
예제 #20
0
 public Processor(GatewayBase gateway)
 {
     _gateway = gateway;
 }