private void OnGatewayRemoveNode(Gateways.MySensors.Node node) { MySensorsNode oldNode = GetMySensorsNode(node.Id); if (oldNode != null) engine.RemoveNode(oldNode); }
//public override void OnOutputChange(Output output) //{ // if (output is MySensorsNodeOutput) // { // MySensorsNodeOutput mySensorsNodeOutput = (MySensorsNodeOutput) output; // LogInfo( // $"Hardware Node{nodeId} Sensor{mySensorsNodeOutput.sensorId} output: {output.Value}"); // } // else // { // LogInfo($"Hardware Node{nodeId} {output.Name} : {output.Value}"); // }; // base.OnOutputChange(output); //} private void CreateInputsOutputs(Gateways.MySensors.Node node) { foreach (var sensor in node.sensors) { AddInputAndOutput(sensor); } }
private void CreateOrUpdateNode(Gateways.MySensors.Node node) { MySensorsNode oldNode = GetMySensorsNode(node.Id); if (oldNode == null) { MySensorsNode newMySensorsNode = new MySensorsNode(node); engine.AddNode(newMySensorsNode); } else { oldNode.Settings["Name"].Value = node.GetSimpleName2(); engine.UpdateNodeInEditor(oldNode); engine.UpdateNodeInDb(oldNode); } }
#pragma warning restore CS8618 // Non-nullable field is uninitialized. public IWorkflowNodeEntity GetNode(Lite <IWorkflowNodeEntity> lite) { if (lite is Lite <WorkflowEventEntity> we) { return(Events.GetOrThrow(we)); } if (lite is Lite <WorkflowActivityEntity> wa) { return(Activities.GetOrThrow(wa)); } if (lite is Lite <WorkflowGatewayEntity> wg) { return(Gateways.GetOrThrow(wg)); } throw new InvalidOperationException("Unexpected " + lite.EntityType); }
/// <summary> /// Initializes client properties. /// </summary> private void Initialize() { Datasets = new Datasets(this); Imports = new Imports(this); Reports = new Reports(this); Dashboards = new Dashboards(this); Tiles = new Tiles(this); Apps = new Apps(this); Dataflows = new Dataflows(this); Gateways = new Gateways(this); Groups = new Groups(this); Capacities = new Capacities(this); AvailableFeatures = new AvailableFeatures(this); BaseUri = new System.Uri("https://api.powerbi.com"); SerializationSettings = new JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.Indented, DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; DeserializationSettings = new JsonSerializerSettings { DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), Converters = new List <JsonConverter> { new Iso8601TimeSpanConverter() } }; CustomInitialize(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddICanPay(a => { var gateways = new Gateways(); // 设置商户数据 var alipayMerchant = new Alipay.Merchant { AppId = "2016081600256163", NotifyUrl = "http://localhost:61337/Notify", ReturnUrl = "http://localhost:61337/Return", AlipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsW6+mN2E3Oji2DPjSKuYgRzK6MlH9q6W0iM0Yk3R0qbpp5wSesSXqudr2K25gIBOTCchiIbXO7GXt/zEdnhnC32eOaTnonDsnuBWIp+q7LoVx/gvKIX5LTHistCvGli8VW4EDGsu2jAyQXyMPgPrIz+/NzWis/gZsa4TaqVY4SpWRuSgMXxleh2ERB6k0ijK0IYM+Cv5fz1ZPDCgk7EbII2jk2fDxtlMLoN5UYEJCcD8OUyivm3Hti3u1kPolckCCf0xk+80g/4EdmzFAffsVgPeXZrkm5EIuiTTOIeRHXlTg3HtkkCw2Wl0CpYSKBr9Vzv7x0gNvb1wnXPmBJNRgQIDAQAB", Privatekey = "MIIEpAIBAAKCAQEAyC43UbsE5XZ2Pmqg1YgzeCqAMk4HOH8fYHslseeSgKxyDjybjqM0yjGIJry1FRmVvLnY7v8jURgwr7d/pDCSRdoHa6zaxuSzg0OlieNmujae34YZ54PmFxULZW0BHSdzmx3OIYK2GarRECkds531ZzpbLdRXqsxQf5G26JZLIFxmNuh/VjBjJ6Hic1WOFT+FCYyi8om+LkPn3jELeA7LPLXzFqzzxx0vo4yiAePrsX5WucWxf+Y8rZoDhRIy/cPtQECXi9SiAWOJe/82JqjVjfpowf3QN7UJHsA82RBloAS4lvvDGJA7a+8DDlqpqPer8cS41Dv5r39iqtJUybDqoQIDAQABAoIBAHi39kBhiihe8hvd7bQX+QIEj17G02/sqZ1jZm4M+rqCRB31ytGP9qvghvzlXEanMTeo0/v8/O1Qqzusa1s2t19MhqEWkrDTBraoOtIWwsKVYeXmVwTY9A8Db+XwgHV2by8iIEbxLqP38S/Pu8uv/GgONyJCJcQohnsIAsfsqs2OGggz+PplZaXJfUkPomWkRdHM9ZWWDLrCIlmRSHLmhHEtFJaXD083kqo437qra58Amw/n+2gH57utbAQ9V3YQFjD8zW511prC+mB6N/WUlaLstkxswGJ16obEJfQ0r8wYHx14ep6UKGyi3YXlMHcteI8gz+uFx4RuVV9EotdXagECgYEA7AEz9oPFYlW1H15OkDGy8yBnpJwIBu2CQLxINsxhrLIAZ2Bgxqcsv+D9CpnYCBDisbXoGoyMK6XaSypBMRKe2y8yRv4c+w00rcKHtGfRjzSJ5NQO0Tv+q8vKY+cd6BuJ6OUQw82ICLANIfHJZNxtvtTCmmqBwSJDpcQJQXmKXTECgYEA2SQCSBWZZONkvhdJ15K+4IHP2HRbYWi+C1OvKzUiK5bdJm77zia4yJEJo5Y/sY3mV3OK0Bgb7IAaxL3i0oH+WNTwbNoGpMlYHKuj4x1453ITyjOwPNj6g27FG1YSIDzhB6ZC4dBlkehi/7gIlIiQt1wkIZ+ltOqgI5IqIdXoSHECgYB3zCiHYt4oC1+UW7e/hCrVNUbHDRkaAygSGkEB5/9QvU5tK0QUsrmJcPihj/RUK9YW5UK7b0qbwWWsr/dFpLEUi8GWvdkSKuLprQxbrDN44O96Q5Z96Vld9WV4DtJkhs4bdWNsMQFzf4I7D9PuKeJfcvqRjaztz6nNFFSqcrqkkQKBgQCJKlUCohpG/9notp9fvQQ0n+viyQXcj6TVVOSnf6X5MRC8MYmBHTbHA8+59bSAfanO/l7muwQQro+6TlUVMyaviLvjlwpxV/sACXC6jCiO06IqreIbXdlJ41RBw2op0Ss5gM5pBRLUS58V+HP7GBWKrnrofofXtAq6zZ8txok4EQKBgQCXrTeGMs7ECfehLz64qZtPkiQbNwupg938Z40Qru/G1GR9u0kmN7ibTyYauI6NNVHGEZa373EBEkacfN+kkkLQMs1tj5Zrlw+iITm+ad/irpXQZS/NHCcrg6h82vu0LcgiKnHKlmW6K5ne0w4LqmsmRCm7JdJjt9WlapAs0ticiw==" }; var wechatpayMerchant = new Wechatpay.Merchant { AppId = "wx2428e34e0e7dc6ef", MchId = "1233410002", Key = "e10adc3849ba56abbe56e056f20f883e", AppSecret = "51c56b886b5be869567dd389b3e5d1d6", SslCertPath = "Certs/apiclient_cert.p12", SslCertPassword = "******", NotifyUrl = "http://localhost:61337/Notify" }; gateways.Add(new AlipayGateway(alipayMerchant) { GatewayUrl = "https://openapi.alipaydev.com/gateway.do?charset=UTF-8" }); gateways.Add(new WechatpayGataway(wechatpayMerchant)); return(gateways); }); }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddMvc(options => { options.Filters.Add <ApiKeyFilter>(); options.Filters.Add <ApiExceptionFilter>(); options.Filters.Add <LogFilter>(); }); services.Configure <ConnectionStrings>(Configuration.GetSection("ConnectionStrings")); services.Configure <ApplicationSettings>(Configuration.GetSection("ApplicationSettings")); services.AddOptions(); services.AddICanPay(a => { //var gateways = new List<GatewayBase>(); var gateways = new Gateways(); // 设置商户数据 var alipayMerchant = new ICanPay.Alipay.Merchant { AppId = "2017093009005992", NotifyUrl = "http://localhost:61337/Notify", ReturnUrl = "http://localhost:61337/Return", AlipayPublicKey = "Varorbc", Privatekey = "Varorbc" }; var wechatpayMerchant = new ICanPay.Wechatpay.Merchant { AppId = "wx2428e34e0e7dc6ef", MchId = "1233410002", Key = "e10adc3849ba56abbe56e056f20f883e", AppSecret = "51c56b886b5be869567dd389b3e5d1d6", SslCertPath = "Certs/apiclient_cert.p12", SslCertPassword = "******", NotifyUrl = "http://localhost:61337/Notify" }; gateways.Add(new AlipayGateway(alipayMerchant)); gateways.Add(new WechatpayGateway(wechatpayMerchant)); return(gateways); }); services.AddSingleton <IEventBus, EventBus>(); services.AddTransient <IEventAggregator, EventAggregator>(); services.AddSingleton <IServiceConfigurationProxy, ServiceConfigurationProxy>(); services.AddScoped <IDbUnitOfWork, DbUnitOfWork>(); services.AddScoped <IDbContextProvider, DbContextProvider>(); services.AddDbContext <DatabaseContext>(options => { options.UseMySql(Configuration.GetConnectionString("ServiceDb")); }); //services.AddTransient<IImageAppService, ImageAppService>(); //services.AddTransient<IImageRepository, ImageRepository>(); //services.AddTransient<IDomainEventHandler<VerificationCreatedEvent>, VerificationCreatedEventHandler>(); var container = services.ToServiceContainer(); container.Configure(config => { config.Interceptors.AddTyped <ExceptionInterceptor>(m => m.DeclaringType.Name.EndsWith("AppService")); }); return(IocProvider.Container = container.Build()); }
private void OnNodeBatteryUpdated(Gateways.MySensors.Node node) { MySensorsNode n = GetMySensorsNode(node.Id); n?.UpdateBattery(node.batteryLevel); }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddMvc(options => { options.Filters.Add <ApiKeyFilter>(); options.Filters.Add <ApiExceptionFilter>(); options.Filters.Add <LogFilter>(); }); services.Configure <ConnectionStrings>(Configuration.GetSection("ConnectionStrings")); services.Configure <ApplicationSettings>(Configuration.GetSection("ApplicationSettings")); services.AddOptions(); services.AddPaySharp(a => { var gateways = new Gateways(); var wechatpayMerchant = new PaySharp.Wechatpay.Merchant { AppId = "wx0a5983b08057acd0", AppSecret = "7a6e9a59bc4ea25379945979d5423b1e", SslCertPath = "Certs/apiclient_cert.p12", SslCertPassword = "******", MchId = "1504096781", Key = "sCafbvydmAoLaNjFDfd2nfVMG86bKBY8", //NotifyUrl = "https://partnergateway.gooios.com/api/wechat/v1/paymentnotify" NotifyUrl = "https://apigateway.gooios.com/paymentservice/wechatpayment/v1/paymentnotify" }; a.Add(new WechatpayGateway(wechatpayMerchant)); a.UseWechatpay(Configuration); }); services.AddSingleton <IEventBus, EventBus>(); services.AddTransient <IEventAggregator, EventAggregator>(); services.AddSingleton <IServiceConfigurationProxy, ServiceConfigurationProxy>(); services.AddSingleton <IWeChatAppConfigurationRepository, WeChatAppConfigurationRepository>(); services.AddScoped <IDbUnitOfWork, DbUnitOfWork>(); services.AddScoped <IDbContextProvider, DbContextProvider>(); services.AddDbContext <DatabaseContext>(options => { options.UseMySql(Configuration.GetConnectionString("ServiceDb")); }); services.AddTransient <IWeChatPaymentNotifyMessageRepository, WeChatPaymentNotifyMessageRepository>(); services.AddTransient <IWeChatPaymentNotifyMessageAppService, WeChatPaymentNotifyMessageAppService>(); services.AddTransient <IWeChatPaymentAppService, WeChatPaymentAppService>(); services.AddTransient <IOrderServiceProxy, OrderServiceProxy>(); services.AddTransient <IWeChatApiProxy, WeChatApiProxy>(); services.AddTransient <IAuthServiceProxy, AuthServiceProxy>(); //services.AddTransient<IImageAppService, ImageAppService>(); //services.AddTransient<IImageRepository, ImageRepository>(); //services.AddTransient<IDomainEventHandler<VerificationCreatedEvent>, VerificationCreatedEventHandler>(); var container = services.ToServiceContainer(); container.Configure(config => { config.Interceptors.AddTyped <ExceptionInterceptor>(m => m.DeclaringType.Name.EndsWith("AppService")); }); return(IocProvider.Container = container.Build()); }
/// <summary> /// Create instance of Gateway /// </summary> /// <param name="gatewayType">gateways type</param> /// <returns>IPaymentGateWay</returns> public IPaymentGateWay Create(Gateways gatewayType) { return(_factoryFactory(gatewayType)); }
public List <string> Validate(Action <WorkflowGatewayEntity, WorkflowGatewayDirection> changeDirection) { List <string> errors = new List <string>(); if (Events.Count(a => a.Value.Type.IsStart()) == 0) { errors.Add(WorkflowValidationMessage.SomeStartEventIsRequired.NiceToString()); } if (Workflow.MainEntityStrategy != WorkflowMainEntityStrategy.CreateNew) { if (Events.Count(a => a.Value.Type == WorkflowEventType.Start) == 0) { errors.Add(WorkflowValidationMessage.NormalStartEventIsRequiredWhenThe0Are1Or2.NiceToString( Workflow.MainEntityStrategy.GetType().NiceName(), WorkflowMainEntityStrategy.SelectByUser.NiceToString(), WorkflowMainEntityStrategy.Both.NiceToString())); } } if (Events.Count(a => a.Value.Type == WorkflowEventType.Start) > 1) { errors.Add(WorkflowValidationMessage.MultipleStartEventsAreNotAllowed.NiceToString()); } var finishEventCount = Events.Count(a => a.Value.Type.IsFinish()); if (finishEventCount == 0) { errors.Add(WorkflowValidationMessage.FinishEventIsRequired.NiceToString()); } Events.Values.ToList().ForEach(e => { var fanIn = PreviousGraph.RelatedTo(e).Count; var fanOut = NextGraph.RelatedTo(e).Count; if (e.Type.IsStart()) { if (fanIn > 0) { errors.Add(WorkflowValidationMessage._0HasInputs.NiceToString(e)); } if (fanOut == 0) { errors.Add(WorkflowValidationMessage._0HasNoOutputs.NiceToString(e)); } if (fanOut > 1) { errors.Add(WorkflowValidationMessage._0HasMultipleOutputs.NiceToString(e)); } if (fanOut == 1) { var nextConn = NextGraph.RelatedTo(e).Single().Value; if (e.Type == WorkflowEventType.Start && !(nextConn.To is WorkflowActivityEntity)) { errors.Add(WorkflowValidationMessage.StartEventNextNodeShouldBeAnActivity.NiceToString()); } } } if (e.Type.IsFinish()) { if (fanIn == 0) { errors.Add(WorkflowValidationMessage._0HasNoInputs.NiceToString(e)); } if (fanOut > 0) { errors.Add(WorkflowValidationMessage._0HasOutputs.NiceToString(e)); } } if (e.Type.IsTimerStart()) { var schedule = e.ScheduledTask(); if (schedule == null) { errors.Add(WorkflowValidationMessage._0IsTimerStartAndSchedulerIsMandatory.NiceToString(e)); } var wet = e.WorkflowEventTask(); if (wet == null) { errors.Add(WorkflowValidationMessage._0IsTimerStartAndTaskIsMandatory.NiceToString(e)); } else if (wet.TriggeredOn != TriggeredOn.Always) { if (wet.Condition?.Script == null || !wet.Condition.Script.Trim().HasText()) { errors.Add(WorkflowValidationMessage._0IsConditionalStartAndTaskConditionIsMandatory.NiceToString(e)); } } } }); Gateways.Values.ToList().ForEach(g => { var fanIn = PreviousGraph.RelatedTo(g).Count; var fanOut = NextGraph.RelatedTo(g).Count; if (fanIn == 0) { errors.Add(WorkflowValidationMessage._0HasNoInputs.NiceToString(g)); } if (fanOut == 0) { errors.Add(WorkflowValidationMessage._0HasNoOutputs.NiceToString(g)); } if (fanIn == 1 && fanOut == 1) { errors.Add(WorkflowValidationMessage._0HasJustOneInputAndOneOutput.NiceToString(g)); } var newDirection = fanOut == 1 ? WorkflowGatewayDirection.Join : WorkflowGatewayDirection.Split; if (g.Direction != newDirection) { changeDirection(g, newDirection); } if (g.Direction == WorkflowGatewayDirection.Split) { if (g.Type == WorkflowGatewayType.Exclusive || g.Type == WorkflowGatewayType.Inclusive) { if (NextGraph.RelatedTo(g).OrderByDescending(a => a.Value.Order).Any(c => c.Value.DecisonResult != null)) { List <WorkflowActivityEntity> previousActivities = new List <WorkflowActivityEntity>(); PreviousGraph.DepthExploreConnections(g, (prev, conn, next) => { if (next is WorkflowActivityEntity a) { previousActivities.Add(a); return(false); } return(true); }); foreach (var act in previousActivities.Where(a => a.Type != WorkflowActivityType.Decision)) { errors.Add(WorkflowValidationMessage.Activity0ShouldBeDecision.NiceToString(act)); } } } if (g.Type == WorkflowGatewayType.Exclusive && NextGraph.RelatedTo(g).OrderByDescending(a => a.Value.Order).Skip(1).Any(c => c.Value.DecisonResult == null && c.Value.Condition == null)) { errors.Add(WorkflowValidationMessage.Gateway0ShouldHasConditionOrDecisionOnEachOutputExceptTheLast.NiceToString(g)); } if (g.Type == WorkflowGatewayType.Inclusive && NextGraph.RelatedTo(g).Any(c => c.Value.DecisonResult == null && c.Value.Condition == null)) { errors.Add(WorkflowValidationMessage.Gateway0ShouldHasConditionOnEachOutput.NiceToString(g)); } } }); var starts = Events.Values.Where(a => a.Type.IsStart()).ToList(); TrackId = starts.ToDictionary(a => (IWorkflowNodeEntity)a, a => 0); TrackCreatedBy = new Dictionary <int, WorkflowGatewayEntity> { { 0, null } }; ParallelWorkflowPairs = new Dictionary <WorkflowGatewayEntity, WorkflowGatewayEntity>(); starts.ForEach(st => NextGraph.BreadthExploreConnections(st, (prev, conn, next) => { var prevTrackId = TrackId.GetOrThrow(prev); int newTrackId; if (IsParallelGateway(prev, WorkflowGatewayDirection.Split)) { if (IsParallelGateway(next, WorkflowGatewayDirection.Join)) { newTrackId = prevTrackId; } else { newTrackId = TrackCreatedBy.Count + 1; TrackCreatedBy.Add(newTrackId, (WorkflowGatewayEntity)prev); } } else { if (IsParallelGateway(next, WorkflowGatewayDirection.Join)) { var split = TrackCreatedBy.TryGetC(prevTrackId); if (split == null) { errors.Add(WorkflowValidationMessage._0CanNotBeConnectedToAParallelJoinBecauseHasNoPreviousParallelSplit.NiceToString(prev)); return(false); } ParallelWorkflowPairs[split] = (WorkflowGatewayEntity)next; newTrackId = TrackId.GetOrThrow(split); } else { newTrackId = prevTrackId; } } if (TrackId.ContainsKey(next)) { if (TrackId[next] != newTrackId) { errors.Add(WorkflowValidationMessage._0Track1CanNotBeConnectedTo2Track3InsteadOfTrack4.NiceToString(prev, prevTrackId, next, TrackId[next], newTrackId)); } return(false); } else { TrackId[next] = newTrackId; return(true); } }) ); Action <WorkflowActivityEntity, IWorkflowTransitionTo> ValidateTransition = (WorkflowActivityEntity wa, IWorkflowTransitionTo item) => { var activity0CanNotXTo1Because2 = (item is WorkflowJumpEmbedded || item is WorkflowScriptPartEmbedded) ? WorkflowValidationMessage.Activity0CanNotJumpTo1Because2 : WorkflowValidationMessage.Activity0CanNotTimeoutTo1Because2; var to = item.To is Lite <WorkflowActivityEntity>?(IWorkflowNodeEntity)Activities.TryGetC((Lite <WorkflowActivityEntity>)item.To) : item.To is Lite <WorkflowGatewayEntity>?(IWorkflowNodeEntity)Gateways.TryGetC((Lite <WorkflowGatewayEntity>)item.To) : item.To is Lite <WorkflowEventEntity>?(IWorkflowNodeEntity)Events.TryGetC((Lite <WorkflowEventEntity>)item.To) : null; if (to == null) { errors.Add(activity0CanNotXTo1Because2.NiceToString(wa, item.To, WorkflowValidationMessage.IsNotInWorkflow.NiceToString())); } if (to is WorkflowEventEntity && ((WorkflowEventEntity)to).Type.IsStart()) { errors.Add(activity0CanNotXTo1Because2.NiceToString(wa, item.To, WorkflowValidationMessage.IsStart.NiceToString())); } if (to is WorkflowActivityEntity && to == wa) { errors.Add(activity0CanNotXTo1Because2.NiceToString(wa, item.To, WorkflowValidationMessage.IsSelfJumping.NiceToString())); } if (TrackId.GetOrThrow(to) != TrackId.GetOrThrow(wa)) { errors.Add(activity0CanNotXTo1Because2.NiceToString(wa, item.To, WorkflowValidationMessage.IsInDifferentParallelTrack.NiceToString())); } }; foreach (var wa in Activities.Values) { var fanIn = PreviousGraph.RelatedTo(wa).Count; var fanOut = NextGraph.RelatedTo(wa).Count; if (fanIn == 0) { errors.Add(WorkflowValidationMessage._0HasNoInputs.NiceToString(wa)); } if (fanOut == 0) { errors.Add(WorkflowValidationMessage._0HasNoOutputs.NiceToString(wa)); } if (fanOut > 1) { errors.Add(WorkflowValidationMessage._0HasMultipleOutputs.NiceToString(wa)); } if (fanOut == 1 && wa.Type == WorkflowActivityType.Decision) { var nextConn = NextGraph.RelatedTo(wa).Single().Value; if (!(nextConn.To is WorkflowGatewayEntity) || ((WorkflowGatewayEntity)nextConn.To).Type == WorkflowGatewayType.Parallel) { errors.Add(WorkflowValidationMessage.Activity0WithDecisionTypeShouldGoToAnExclusiveOrInclusiveGateways.NiceToString(wa)); } } if (wa.Reject != null) { var prevs = PreviousGraph.IndirectlyRelatedTo(wa, kvp => !(kvp.Key is WorkflowActivityEntity)); if (prevs.Any(a => a is WorkflowEventEntity && ((WorkflowEventEntity)a).Type.IsStart())) { errors.Add(WorkflowValidationMessage.Activity0CanNotRejectToStart.NiceToString(wa)); } if (prevs.Any(a => IsParallelGateway(a))) { errors.Add(WorkflowValidationMessage.Activity0CanNotRejectToParallelGateway.NiceToString(wa)); } } if (wa.Timeout != null) { ValidateTransition(wa, wa.Timeout); } if (wa.Script != null) { ValidateTransition(wa, wa.Script); } foreach (var item in wa.Jumps) { ValidateTransition(wa, item); } } if (errors.HasItems()) { this.TrackCreatedBy = null; this.TrackId = null; this.ParallelWorkflowPairs = null; } return(errors); }
public MySensorsNode(Gateways.MySensors.Node node) : base("Hardware", "MySensors") { this.nodeId = node.Id; Settings.Add("Name", new NodeSetting(NodeSettingType.Text, "Name", node.GetSimpleName2())); CreateInputsOutputs(node); }
protected void OnData(ITransactionMessage <IPointModel> message) { var point = message.Next; var account = point.Account; var gateway = Gateways.First(); var instrumentX = point.Account.Instruments[_assetX]; var instrumentY = point.Account.Instruments[_assetY]; var seriesX = instrumentX.PointGroups; var seriesY = instrumentY.PointGroups; var indicatorX = _scaleIndicatorX.Calculate(seriesX).Bar.Close; var indicatorY = _scaleIndicatorY.Calculate(seriesY).Bar.Close; //var balanceIndicator = _balanceIndicator.Calculate(Gateways.Select(o => o.Account), point).Close; if (seriesX.Any() && seriesY.Any()) { if (account.ActiveOrders.Any() == false && account.ActivePositions.Any() == false && Math.Abs(indicatorX.Value - indicatorY.Value) >= 0.5) { if (indicatorX > indicatorY) { gateway.OrderSenderStream.OnNext(new TransactionMessage <ITransactionOrderModel> { Action = ActionEnum.Create, Next = new TransactionOrderModel { Size = 1, Side = OrderSideEnum.Sell, Type = OrderTypeEnum.Market, Instrument = instrumentX } }); gateway.OrderSenderStream.OnNext(new TransactionMessage <ITransactionOrderModel> { Action = ActionEnum.Create, Next = new TransactionOrderModel { Size = 1, Side = OrderSideEnum.Buy, Type = OrderTypeEnum.Market, Instrument = instrumentX } }); } if (indicatorX < indicatorY) { gateway.OrderSenderStream.OnNext(new TransactionMessage <ITransactionOrderModel> { Action = ActionEnum.Create, Next = new TransactionOrderModel { Size = 1, Side = OrderSideEnum.Buy, Type = OrderTypeEnum.Market, Instrument = instrumentX } }); gateway.OrderSenderStream.OnNext(new TransactionMessage <ITransactionOrderModel> { Action = ActionEnum.Create, Next = new TransactionOrderModel { Size = 1, Side = OrderSideEnum.Sell, Type = OrderTypeEnum.Market, Instrument = instrumentY } }); } } if (account.ActivePositions.Any() && Math.Abs(indicatorX.Value - indicatorY.Value) < 0.05) { } } }
private async Task LoadUser(string token) { var client = new HttpClient(); var httpRequestMessage = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri("https://kwikwink-lab.fr/api/auth/user"), Headers = { { HttpRequestHeader.Accept.ToString(), "application/json" }, { HttpRequestHeader.Authorization.ToString(), "Bearer " + token } } }; var response = client.SendAsync(httpRequestMessage).Result; Console.WriteLine(response.StatusCode); if (response.IsSuccessStatusCode) { string myloguser = await response.Content.ReadAsStringAsync(); user = JsonConvert.DeserializeObject <User>(myloguser); App.user_id = user.id; Title = user.first_name + " " + user.last_name; } //brubrubruh /*var httpNodesRequestMessage = new HttpRequestMessage * { * Method = HttpMethod.Get, * RequestUri = new Uri("https://kwikwink-lab.fr/api/users/me/gateways"), * Headers = { * { HttpRequestHeader.Accept.ToString(), "application/json" }, * { HttpRequestHeader.Authorization.ToString(), "Bearer " + access_token } * } * }; * var NodesResponse = client.SendAsync(httpNodesRequestMessage).Result; * * Console.WriteLine("body response " + await NodesResponse.Content.ReadAsStringAsync()); */ string NodesResponse = "{\"data\":[{\"id\":\"497f6eca-6276-4993-bfeb-53cbbbba6f08\",\"name\":\"bruh\",\"user\":\"76f62a58-5404-486d-9afc-07bded328704\",\"connected\":true,\"is_streaming\":true,\"address\":\"somewhere\",\"zipcode\":\"string\",\"city\":\"Dij city\",\"permissions\":[\"string\"],\"nodes\":[{\"id\":\"497f6eca-6276-4993-bfeb-53cbbbba6f08\",\"name\":\"Passerelle Test\",\"permissions\":[\"string\"],\"devices\":[{\"id\":\"497f6eca-6276-4993-bfeb-53cbbbba6f08\",\"type\":\"lock\",\"state\":\"unlock\",\"battery\":0},{\"id\":\"497f6eca-6276-4993-bfeb-53cbbbba6f09\",\"type\":\"door_sensor\",\"state\":\"open\",\"battery\":60}]},{\"id\":\"507f6eca-6276-4993-bfeb-53cbbbba6f08\",\"name\":\"George la passerelle\",\"permissions\":[\"string\"],\"devices\":[{\"id\":\"497f6eca-6276-4993-bfeb-53cbbbba6faa\",\"type\":\"lock\",\"state\":\"lock\",\"battery\":0},{\"id\":\"49'f6eca-6276-4993-bfeb-53ccbbba6f09\",\"type\":\"door_sensor\",\"state\":\"close\",\"battery\":60}]}],\"created_at\":\"2019-08-24T14:15:22Z\",\"updated_at\":\"2019-08-24T14:15:22Z\"},{\"id\":\"497f6eca-6276-4993-bfeb-53cbbbba6f08\",\"name\":\"Le Bureau\",\"user\":\"76f62a58-5404-486d-9afc-07bded328704\",\"connected\":true,\"is_streaming\":true,\"address\":\"somewhere\",\"zipcode\":\"string\",\"city\":\"Dij city\",\"permissions\":[\"string\"],\"nodes\":[{\"id\":\"497f6eca-6276-4993-bfeb-53cbbbba6f08\",\"name\":\"Passerelle Test\",\"permissions\":[\"string\"],\"devices\":[{\"id\":\"497f6eca-6276-4993-bfeb-53cbbbba6f08\",\"type\":\"lock\",\"state\":\"unlock\",\"battery\":0},{\"id\":\"497f6eca-6276-4993-bfeb-53cbbbba6f09\",\"type\":\"door_sensor\",\"state\":\"open\",\"battery\":60}]},{\"id\":\"507f6eca-6276-4993-bfeb-53cbbbba6f08\",\"name\":\"George la passerelle\",\"permissions\":[\"string\"],\"devices\":[{\"id\":\"497f6eca-6276-4993-bfeb-53cbbbba6faa\",\"type\":\"lock\",\"state\":\"lock\",\"battery\":0},{\"id\":\"49'f6eca-6276-4993-bfeb-53ccbbba6f09\",\"type\":\"door_sensor\",\"state\":\"close\",\"battery\":60}]}],\"created_at\":\"2019-08-24T14:15:22Z\",\"updated_at\":\"2019-08-24T14:15:22Z\"}]}"; gateways = JsonConvert.DeserializeObject <Gateways>(NodesResponse); foreach (Gateway gtw in gateways.data) { List <NodeEntityWrapper> tmp = new List <NodeEntityWrapper>(); Console.WriteLine($"gateway id => {gtw.name}"); foreach (Node nd in gtw.nodes) { Console.WriteLine($"node id => {nd.name}"); Nodes.Add(nd); tmp.Add(new NodeEntityWrapper(nd)); } NodeGroups.Add(new Grouping <Gateway, NodeEntityWrapper>(gtw, tmp)); } }
public static void RegisterPaySetting() { var builder = new ContainerBuilder(); var gateways = new Gateways(); var db = AppContext.Current.Resolve <IDBContext>(); // 注册所有配置 var allSettings = db.Table.FindAll <Setting>().ToList(); // 所有支付参数 builder.RegisterInstance(new SettingsCollection(allSettings)).As <Domain.ISettings>().SingleInstance(); // 注册支付配置 var settings = allSettings.Where(n => n.KeyName.StartsWith("pay.")).ToList(); var normalSettings = settings.ToDictionary(n => StoreKey(n.KeyName, n.StoreId)); // key+ 门店ID 唯一 //按门店设置商户号参数 var storeSettings = settings.GroupBy(n => n.StoreId); var domainUrl = allSettings.FirstOrDefault(n => n.KeyName == SettingKeys.System_Domain).Value; foreach (var storeSettingGroup in storeSettings) { /// 支付宝配置 var alipaySetting = storeSettingGroup.Where(n => n.KeyName.StartsWith("pay.alipay")).ToList().ToDictionary(n => StoreKey(n.KeyName, n.StoreId)); var storeid = storeSettingGroup.Key; var alipayMerchant = new PaySharp.Alipay.Merchant { AppId = alipaySetting.ContainsKey(StoreKey(SettingKeys.Pay_Alipay_Appid, storeid)) ? alipaySetting[StoreKey(SettingKeys.Pay_Alipay_Appid, storeid)].Value : "", NotifyUrl = domainUrl + (normalSettings.ContainsKey(StoreKey(SettingKeys.Pay_Notify_Url, storeid)) ? normalSettings[StoreKey(SettingKeys.Pay_Notify_Url, storeid)].Value : ""), ReturnUrl = domainUrl + (normalSettings.ContainsKey(StoreKey(SettingKeys.Pay_Return_Url, storeid)) ? normalSettings[StoreKey(SettingKeys.Pay_Return_Url, storeid)].Value : ""), AlipayPublicKey = alipaySetting.ContainsKey(StoreKey(SettingKeys.Pay_Alipay_Public_Key, storeid)) ? alipaySetting[StoreKey(SettingKeys.Pay_Alipay_Public_Key, storeid)].Value : "", Privatekey = alipaySetting.ContainsKey(StoreKey(SettingKeys.Pay_Alipay_Private_Key, storeid)) ? alipaySetting[StoreKey(SettingKeys.Pay_Alipay_Private_Key, storeid)].Value : "", StoreId = storeid }; gateways.Add(new AlipayGateway(alipayMerchant) { GatewayUrl = "https://openapi.alipaydev.com" }); //微信配置 var wechatSetting = storeSettingGroup.Where(n => n.KeyName.StartsWith("pay.wechat")).ToList().ToDictionary(n => StoreKey(n.KeyName, n.StoreId)); var wechatpayMerchant = new PaySharp.Wechatpay.Merchant { AppId = wechatSetting.ContainsKey(StoreKey(SettingKeys.Pay_Wechat_Appid, storeid)) ? wechatSetting[StoreKey(SettingKeys.Pay_Wechat_Appid, storeid)].Value : "", MchId = wechatSetting.ContainsKey(StoreKey(SettingKeys.Pay_Wechat_MchId, storeid)) ? wechatSetting[StoreKey(SettingKeys.Pay_Wechat_MchId, storeid)].Value : "", Key = wechatSetting.ContainsKey(StoreKey(SettingKeys.Pay_Wechat_MchKey, storeid)) ? wechatSetting[StoreKey(SettingKeys.Pay_Wechat_MchKey, storeid)].Value : "", AppSecret = wechatSetting.ContainsKey(StoreKey(SettingKeys.Pay_Wechat_AppSecret, storeid)) ? wechatSetting[StoreKey(SettingKeys.Pay_Wechat_AppSecret, storeid)].Value : "", //SslCertPath = AppDomain.CurrentDomain.BaseDirectory + "Certs/apiclient_cert.p12", //SslCertPassword = "******", NotifyUrl = domainUrl + (normalSettings.ContainsKey(StoreKey(SettingKeys.Pay_Notify_Url, storeid)) ? normalSettings[StoreKey(SettingKeys.Pay_Notify_Url, storeid)].Value : ""), StoreId = storeid }; gateways.Add(new WechatpayGateway(wechatpayMerchant)); } // builder.RegisterInstance(new DapperDBContext(Configer.MasterDB)).As<IDBContext>().InstancePerLifetimeScope(); builder.RegisterInstance(gateways).As <IGateways>().SingleInstance(); // 注册支付路由 PayServices.IPayRoute route = new PayServices.DefaultPayRoute(); route.InitRoute(); builder.RegisterInstance(route).As <PayServices.IPayRoute>().SingleInstance(); builder.Update(AppContext.Container); }
private async void OnOpenPlease(object obj) { Console.WriteLine("token --> " + Access_token); var httpRequestMessage = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri("https://kwikwink-lab.fr/api/auth/user"), Headers = { { HttpRequestHeader.Accept.ToString(), "application/json" }, { HttpRequestHeader.Authorization.ToString(), "Bearer " + Access_token } } }; response = client.SendAsync(httpRequestMessage).Result; Console.WriteLine(response.StatusCode); if (response.IsSuccessStatusCode) { myloguser = await response.Content.ReadAsStringAsync(); user = JsonConvert.DeserializeObject <User>(myloguser); var httpRequestMessageGateways = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri("https://kwikwink-lab.fr/api/users/" + user.id + "/gateways"), Headers = { { HttpRequestHeader.Accept.ToString(), "application/json" }, { HttpRequestHeader.Authorization.ToString(), "Bearer " + Access_token } } }; response = client.SendAsync(httpRequestMessageGateways).Result; if (response.IsSuccessStatusCode) { var myGateways = await response.Content.ReadAsStringAsync(); Console.WriteLine(myGateways); Gateways gateways = JsonConvert.DeserializeObject <Gateways>(myGateways); foreach (Gateway gateway in gateways.data) { Console.WriteLine(gateway.id); } var httpRequestMessageState = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri("https://kwikwink-lab.fr/api/gateways/" + gateways.data[0].id + "/devices"), Headers = { { HttpRequestHeader.Authorization.ToString(), "Bearer " + Access_token } } }; response = client.SendAsync(httpRequestMessageState).Result; Console.WriteLine(response.StatusCode); if (response.IsSuccessStatusCode) { var stateOfDoor = await response.Content.ReadAsStringAsync(); Console.WriteLine(stateOfDoor); Sensors sensors = JsonConvert.DeserializeObject <Sensors>(stateOfDoor); Console.WriteLine(sensors.ToString()); if (sensors.data.Door.state == "open") { //Display alert --> you can't change the state of your door if it's open } else if (sensors.data.Door.state == "close") { if (sensors.data.Lock.state == "open") { /*/ gateways /{ gateway_id}/lock/ close*/ var httpRequestMessageOpen = new HttpRequestMessage { Method = HttpMethod.Post, RequestUri = new Uri("https://kwikwink-lab.fr/api/gateways/" + gateways.data[0].id + "/lock/close"), Headers = { { HttpRequestHeader.Authorization.ToString(), "Bearer " + Access_token } } }; response = client.SendAsync(httpRequestMessageOpen).Result; Console.WriteLine(response.StatusCode); } else if (sensors.data.Lock.state == "close") { /*/ gateways /{ gateway_id}/lock/ open*/ var httpRequestMessageClose = new HttpRequestMessage { Method = HttpMethod.Post, RequestUri = new Uri("https://kwikwink-lab.fr/api/gateways/" + gateways.data[0].id + "/lock/open"), Headers = { { HttpRequestHeader.Authorization.ToString(), "Bearer " + Access_token } } }; response = client.SendAsync(httpRequestMessageClose).Result; Console.WriteLine(response.StatusCode); } } } Console.WriteLine(); } } else { Console.WriteLine("t'es mauvais frr"); //Try to refresh the token in first place and if expire : //--> Show popup that say that you need to log in again } }
/// <summary> /// Set the ip address properties of the <see cref="NetworkConnectionProperties"/> instance. /// </summary> /// <param name="properties">Element of the type <see cref="IPInterfaceProperties"/>.</param> private void SetIpProperties(IPInterfaceProperties properties) { var ipList = properties.UnicastAddresses; foreach (var ip in ipList) { if (ip.Address.AddressFamily == AddressFamily.InterNetwork) { IPv4 = ip.Address.ToString(); IPv4Mask = ip.IPv4Mask.ToString(); } else if (ip.Address.AddressFamily == AddressFamily.InterNetworkV6) { if (string.IsNullOrEmpty(IPv6Primary)) { IPv6Primary = ip.Address.ToString(); } if (ip.Address.IsIPv6LinkLocal) { IPv6LinkLocal = ip.Address.ToString(); } else if (ip.Address.IsIPv6SiteLocal) { IPv6SiteLocal = ip.Address.ToString(); } else if (ip.Address.IsIPv6UniqueLocal) { IPv6UniqueLocal = ip.Address.ToString(); } else if (ip.SuffixOrigin == SuffixOrigin.Random) { IPv6Temporary = ip.Address.ToString(); } else { IPv6Global = ip.Address.ToString(); } } } foreach (var ip in properties.GatewayAddresses) { Gateways.Add(ip.Address.ToString()); } foreach (var ip in properties.DhcpServerAddresses) { DhcpServers.Add(ip.ToString()); } foreach (var ip in properties.DnsAddresses) { DnsServers.Add(ip.ToString()); } foreach (var ip in properties.WinsServersAddresses) { WinsServers.Add(ip.ToString()); } }
internal void Load(TextReader input) { var xml = new XmlDocument(); var xmlReader = XmlReader.Create(input); xml.Load(xmlReader); var root = xml.DocumentElement; foreach (XmlNode node in root.ChildNodes) { var child = node as XmlElement; if (child != null) { switch (child.LocalName) { case "Gateway": Gateways.Add(ConfigUtilities.ParseIPEndPoint(child)); if (GatewayProvider == GatewayProviderType.None) { GatewayProvider = GatewayProviderType.Config; } break; case "Azure": // Throw exception with explicit deprecation error message throw new OrleansException( "The Azure element has been deprecated -- use SystemStore element instead."); case "SystemStore": if (child.HasAttribute("SystemStoreType")) { var sst = child.GetAttribute("SystemStoreType"); GatewayProvider = (GatewayProviderType)Enum.Parse(typeof(GatewayProviderType), sst); } if (child.HasAttribute("DeploymentId")) { DeploymentId = child.GetAttribute("DeploymentId"); } if (child.HasAttribute(Constants.DATA_CONNECTION_STRING_NAME)) { DataConnectionString = child.GetAttribute(Constants.DATA_CONNECTION_STRING_NAME); if (String.IsNullOrWhiteSpace(DataConnectionString)) { throw new FormatException("SystemStore.DataConnectionString cannot be blank"); } if (GatewayProvider == GatewayProviderType.None) { // Assume the connection string is for Azure storage if not explicitly specified GatewayProvider = GatewayProviderType.AzureTable; } } break; case "Tracing": ConfigUtilities.ParseTracing(this, child, ClientName); break; case "Statistics": ConfigUtilities.ParseStatistics(this, child, ClientName); break; case "Limits": ConfigUtilities.ParseLimitValues(this, child, ClientName); break; case "Debug": break; case "Messaging": base.Load(child); break; case "LocalAddress": if (child.HasAttribute("PreferredFamily")) { PreferredFamily = ConfigUtilities.ParseEnum <AddressFamily>(child.GetAttribute("PreferredFamily"), "Invalid address family for the PreferredFamily attribute on the LocalAddress element"); } else { throw new FormatException("Missing PreferredFamily attribute on the LocalAddress element"); } if (child.HasAttribute("Interface")) { NetInterface = child.GetAttribute("Interface"); } if (child.HasAttribute("Port")) { Port = ConfigUtilities.ParseInt(child.GetAttribute("Port"), "Invalid integer value for the Port attribute on the LocalAddress element"); } break; default: if (child.LocalName.EndsWith("Providers", StringComparison.Ordinal)) { var providerConfig = new ProviderCategoryConfiguration(); providerConfig.Load(child); ProviderConfigurations.Add(providerConfig.Name, providerConfig); } break; } } } }
/// <summary> /// Define what gateways will be used /// </summary> protected void CreateGateways(IGatewayModel gateway) { Gateways.Add(gateway); }
/// <summary> /// 负责调用autofac实现依赖注入,负责创建MVC控制器类的对象(调用控制器的有参构造函数),接管DefaultControllerFactory的工作 /// </summary> public static void Register() { // 第一步:注册控制器 var builder = new ContainerBuilder(); // 告诉autofac将来要创建的控制器类存放在哪个程序集 //builder.RegisterControllers(Assembly.GetExecutingAssembly()).PropertiesAutowired(PropertyWiringOptions.PreserveSetValues); // 把当前程序集中的 Controller 都注册 builder.RegisterControllers(typeof(MvcApplication).Assembly) // 自动给属性进行“注入” .PropertiesAutowired(PropertyWiringOptions.PreserveSetValues); builder.RegisterWebApiFilterProvider(GlobalConfiguration.Configuration); builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); builder.RegisterFilterProvider(); // 第二步:注册接口 // 获取所有相关类库的程序集 Assembly[] repository_assemblies = new Assembly[] { Assembly.Load(Assemblies.RepositoryAssembly) }; // 把当前程序集中的类都注册 builder.RegisterAssemblyTypes(repository_assemblies) // 注入类本身 .AsSelf() // 剔除抽象类; type1.IsAssignableFrom(type2):type2是否实现了type1的接口/或者是否集成自type1。这样就只注册实现了IBaseService接口的类,避免注册其它无关的类 .Where(type => !type.IsAbstract) // 为接口注入具体类 .AsImplementedInterfaces() // 自动给属性进行“注入” .PropertiesAutowired() // 同一个Lifetime生成的对象是同一个实例 .InstancePerLifetimeScope(); // 获取所有相关类库的程序集 Assembly[] service_assemblies = new Assembly[] { Assembly.Load(Assemblies.ServiceAssembly) }; // 把当前程序集中的类都注册 builder.RegisterAssemblyTypes(service_assemblies) // 剔除抽象类; type1.IsAssignableFrom(type2):type2是否实现了type1的接口/或者是否集成自type1。这样就只注册实现了IBaseService接口的类,避免注册其它无关的类 .Where(type => !type.IsAbstract) // 注入类本身 .AsSelf() // 为接口注入具体类 .AsImplementedInterfaces() // 自动给属性进行“注入” .PropertiesAutowired() // 同一个Lifetime生成的对象是同一个实例 .InstancePerLifetimeScope(); // 其他 builder.RegisterType <DefaultDbContext>().OnRelease(db => db.Dispose()).InstancePerLifetimeScope(); builder.RegisterType <RedisHelper>().OnRelease(db => db.Dispose()).InstancePerLifetimeScope(); //builder.RegisterType<BackgroundJobClient>().SingleInstance();//指定生命周期为单例 //builder.RegisterType<HangfireBackJob>().As<IHangfireBackJob>().PropertiesAutowired(PropertyWiringOptions.PreserveSetValues).InstancePerDependency(); // 支付平台 builder.Register(a => { var gateways = new Gateways(); #region gateways.RegisterAlipay(); //gateways.RegisterAlipay(); var alipayMerchant = new PaySharp.Alipay.Merchant { AppId = "2016081600256163", NotifyUrl = "http://localhost:50160/Notify", ReturnUrl = "http://localhost:50160/Notify", AlipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsW6+mN2E3Oji2DPjSKuYgRzK6MlH9q6W0iM0Yk3R0qbpp5wSesSXqudr2K25gIBOTCchiIbXO7GXt/zEdnhnC32eOaTnonDsnuBWIp+q7LoVx/gvKIX5LTHistCvGli8VW4EDGsu2jAyQXyMPgPrIz+/NzWis/gZsa4TaqVY4SpWRuSgMXxleh2ERB6k0ijK0IYM+Cv5fz1ZPDCgk7EbII2jk2fDxtlMLoN5UYEJCcD8OUyivm3Hti3u1kPolckCCf0xk+80g/4EdmzFAffsVgPeXZrkm5EIuiTTOIeRHXlTg3HtkkCw2Wl0CpYSKBr9Vzv7x0gNvb1wnXPmBJNRgQIDAQAB", Privatekey = "MIIEpAIBAAKCAQEAyC43UbsE5XZ2Pmqg1YgzeCqAMk4HOH8fYHslseeSgKxyDjybjqM0yjGIJry1FRmVvLnY7v8jURgwr7d/pDCSRdoHa6zaxuSzg0OlieNmujae34YZ54PmFxULZW0BHSdzmx3OIYK2GarRECkds531ZzpbLdRXqsxQf5G26JZLIFxmNuh/VjBjJ6Hic1WOFT+FCYyi8om+LkPn3jELeA7LPLXzFqzzxx0vo4yiAePrsX5WucWxf+Y8rZoDhRIy/cPtQECXi9SiAWOJe/82JqjVjfpowf3QN7UJHsA82RBloAS4lvvDGJA7a+8DDlqpqPer8cS41Dv5r39iqtJUybDqoQIDAQABAoIBAHi39kBhiihe8hvd7bQX+QIEj17G02/sqZ1jZm4M+rqCRB31ytGP9qvghvzlXEanMTeo0/v8/O1Qqzusa1s2t19MhqEWkrDTBraoOtIWwsKVYeXmVwTY9A8Db+XwgHV2by8iIEbxLqP38S/Pu8uv/GgONyJCJcQohnsIAsfsqs2OGggz+PplZaXJfUkPomWkRdHM9ZWWDLrCIlmRSHLmhHEtFJaXD083kqo437qra58Amw/n+2gH57utbAQ9V3YQFjD8zW511prC+mB6N/WUlaLstkxswGJ16obEJfQ0r8wYHx14ep6UKGyi3YXlMHcteI8gz+uFx4RuVV9EotdXagECgYEA7AEz9oPFYlW1H15OkDGy8yBnpJwIBu2CQLxINsxhrLIAZ2Bgxqcsv+D9CpnYCBDisbXoGoyMK6XaSypBMRKe2y8yRv4c+w00rcKHtGfRjzSJ5NQO0Tv+q8vKY+cd6BuJ6OUQw82ICLANIfHJZNxtvtTCmmqBwSJDpcQJQXmKXTECgYEA2SQCSBWZZONkvhdJ15K+4IHP2HRbYWi+C1OvKzUiK5bdJm77zia4yJEJo5Y/sY3mV3OK0Bgb7IAaxL3i0oH+WNTwbNoGpMlYHKuj4x1453ITyjOwPNj6g27FG1YSIDzhB6ZC4dBlkehi/7gIlIiQt1wkIZ+ltOqgI5IqIdXoSHECgYB3zCiHYt4oC1+UW7e/hCrVNUbHDRkaAygSGkEB5/9QvU5tK0QUsrmJcPihj/RUK9YW5UK7b0qbwWWsr/dFpLEUi8GWvdkSKuLprQxbrDN44O96Q5Z96Vld9WV4DtJkhs4bdWNsMQFzf4I7D9PuKeJfcvqRjaztz6nNFFSqcrqkkQKBgQCJKlUCohpG/9notp9fvQQ0n+viyQXcj6TVVOSnf6X5MRC8MYmBHTbHA8+59bSAfanO/l7muwQQro+6TlUVMyaviLvjlwpxV/sACXC6jCiO06IqreIbXdlJ41RBw2op0Ss5gM5pBRLUS58V+HP7GBWKrnrofofXtAq6zZ8txok4EQKBgQCXrTeGMs7ECfehLz64qZtPkiQbNwupg938Z40Qru/G1GR9u0kmN7ibTyYauI6NNVHGEZa373EBEkacfN+kkkLQMs1tj5Zrlw+iITm+ad/irpXQZS/NHCcrg6h82vu0LcgiKnHKlmW6K5ne0w4LqmsmRCm7JdJjt9WlapAs0ticiw==" }; gateways.Add(new AlipayGateway(alipayMerchant) { GatewayUrl = "https://openapi.alipaydev.com" }); #endregion #region gateways.RegisterWechatpay(); //gateways.RegisterWechatpay(); var wechatpayMerchant = new PaySharp.Wechatpay.Merchant { AppId = "wx2428e34e0e7dc6ef", MchId = "1233410002", Key = "e10adc3849ba56abbe56e056f20f883e", AppSecret = "51c56b886b5be869567dd389b3e5d1d6", SslCertPath = AppDomain.CurrentDomain.BaseDirectory + "Certs/apiclient_cert.p12", SslCertPassword = "******", NotifyUrl = "http://localhost:64852/Notify" }; gateways.Add(new WechatpayGateway(wechatpayMerchant)); #endregion #region gateways.RegisterUnionpay(); //gateways.RegisterUnionpay(); var unionpayMerchant = new PaySharp.Unionpay.Merchant { AppId = "777290058110048", CertPwd = "000000", CertPath = AppDomain.CurrentDomain.BaseDirectory + "Certs/acp_test_sign.pfx", NotifyUrl = "http://localhost:50160/Notify", ReturnUrl = "http://localhost:50160/Notify" }; gateways.Add(new UnionpayGateway(unionpayMerchant) { GatewayUrl = "https://gateway.test.95516.com" }); #endregion return(gateways); }).As <IGateways>().InstancePerRequest(); // 第三步:注册系统容器,所有对象都从这里获取。 Container = builder.Build(); //5.0 将当前容器交给MVC底层,保证容器不被销毁,控制器由autofac来创建 GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(Container); GlobalHost.DependencyResolver = new Autofac.Integration.SignalR.AutofacDependencyResolver(Container); //注册系统级别的 DependencyResolver,这样当 MVC 框架创建 Controller 等对象的时候都是管 Autofac 要对象。 DependencyResolver.SetResolver(new AutofacDependencyResolver(Container)); }
internal void LoadFromXml(XmlElement root) { foreach (XmlNode node in root.ChildNodes) { var child = node as XmlElement; if (child != null) { switch (child.LocalName) { case "Gateway": Gateways.Add(ConfigUtilities.ParseIPEndPoint(child).GetResult()); if (GatewayProvider == GatewayProviderType.None) { GatewayProvider = GatewayProviderType.Config; } break; case "Azure": // Throw exception with explicit deprecation error message throw new OrleansException( "The Azure element has been deprecated -- use SystemStore element instead."); case "SystemStore": if (child.HasAttribute("SystemStoreType")) { var sst = child.GetAttribute("SystemStoreType"); GatewayProvider = (GatewayProviderType)Enum.Parse(typeof(GatewayProviderType), sst); } if (child.HasAttribute("CustomGatewayProviderAssemblyName")) { CustomGatewayProviderAssemblyName = child.GetAttribute("CustomGatewayProviderAssemblyName"); if (CustomGatewayProviderAssemblyName.EndsWith(".dll")) { throw new FormatException("Use fully qualified assembly name for \"CustomGatewayProviderAssemblyName\""); } if (GatewayProvider != GatewayProviderType.Custom) { throw new FormatException("SystemStoreType should be \"Custom\" when CustomGatewayProviderAssemblyName is specified"); } } if (child.HasAttribute("DeploymentId")) { DeploymentId = child.GetAttribute("DeploymentId"); } if (child.HasAttribute(Constants.DATA_CONNECTION_STRING_NAME)) { DataConnectionString = child.GetAttribute(Constants.DATA_CONNECTION_STRING_NAME); if (String.IsNullOrWhiteSpace(DataConnectionString)) { throw new FormatException("SystemStore.DataConnectionString cannot be blank"); } if (GatewayProvider == GatewayProviderType.None) { // Assume the connection string is for Azure storage if not explicitly specified GatewayProvider = GatewayProviderType.AzureTable; } } if (child.HasAttribute(Constants.ADO_INVARIANT_NAME)) { AdoInvariant = child.GetAttribute(Constants.ADO_INVARIANT_NAME); if (String.IsNullOrWhiteSpace(AdoInvariant)) { throw new FormatException("SystemStore.AdoInvariant cannot be blank"); } } break; case "Tracing": ConfigUtilities.ParseTracing(this, child, ClientName); break; case "Statistics": ConfigUtilities.ParseStatistics(this, child, ClientName); break; case "Limits": ConfigUtilities.ParseLimitValues(LimitManager, child, ClientName); break; case "Debug": break; case "Messaging": base.Load(child); break; case "LocalAddress": if (child.HasAttribute("PreferredFamily")) { PreferredFamily = ConfigUtilities.ParseEnum <AddressFamily>(child.GetAttribute("PreferredFamily"), "Invalid address family for the PreferredFamily attribute on the LocalAddress element"); } else { throw new FormatException("Missing PreferredFamily attribute on the LocalAddress element"); } if (child.HasAttribute("Interface")) { NetInterface = child.GetAttribute("Interface"); } if (child.HasAttribute("Port")) { Port = ConfigUtilities.ParseInt(child.GetAttribute("Port"), "Invalid integer value for the Port attribute on the LocalAddress element"); } break; case "Telemetry": ConfigUtilities.ParseTelemetry(child); break; default: if (child.LocalName.EndsWith("Providers", StringComparison.Ordinal)) { var providerCategory = ProviderCategoryConfiguration.Load(child); if (ProviderConfigurations.ContainsKey(providerCategory.Name)) { var existingCategory = ProviderConfigurations[providerCategory.Name]; existingCategory.Merge(providerCategory); } else { ProviderConfigurations.Add(providerCategory.Name, providerCategory); } } break; } } } }
public void Rotate(TileOrientation Orientation, Util.ObjectRotateMode ObjectRotateMode) { var X = 0; var Y = 0; var Pos = new XYInt(0, 0); var RotatedPos = new XYInt(); var NewTerrainPosA = TileUtil.GetRotatedPos(Orientation, new XYInt(0, 0), Terrain.TileSize); var NewTerrainPosB = TileUtil.GetRotatedPos(Orientation, Terrain.TileSize, Terrain.TileSize); var VertexLimits = new XYInt(Math.Max(NewTerrainPosA.X, NewTerrainPosB.X), Math.Max(NewTerrainPosA.Y, NewTerrainPosB.Y)); var NewTerrain = new clsTerrain(VertexLimits); var NewTileLimits = new XYInt(NewTerrain.TileSize.X - 1, NewTerrain.TileSize.Y - 1); var NewSideHLimits = new XYInt(NewTerrain.TileSize.X - 1, NewTerrain.TileSize.Y); var NewSideVLimits = new XYInt(NewTerrain.TileSize.X, NewTerrain.TileSize.Y - 1); var OldTileLimits = new XYInt(Terrain.TileSize.X - 1, Terrain.TileSize.Y - 1); var OldPosLimits = new XYInt(Terrain.TileSize.X * Constants.TerrainGridSpacing, Terrain.TileSize.Y * Constants.TerrainGridSpacing); var ReverseOrientation = new TileOrientation(); var TriDirection = new TileDirection(); ReverseOrientation = Orientation; ReverseOrientation.Reverse(); for (Y = 0; Y <= NewTerrain.TileSize.Y; Y++) { Pos.Y = Y; for (X = 0; X <= NewTerrain.TileSize.X; X++) { Pos.X = X; RotatedPos = TileUtil.GetRotatedPos(ReverseOrientation, Pos, VertexLimits); NewTerrain.Vertices[X, Y].Height = Terrain.Vertices[RotatedPos.X, RotatedPos.Y].Height; NewTerrain.Vertices[X, Y].Terrain = Terrain.Vertices[RotatedPos.X, RotatedPos.Y].Terrain; } } for (Y = 0; Y <= NewTerrain.TileSize.Y - 1; Y++) { Pos.Y = Y; for (X = 0; X <= NewTerrain.TileSize.X - 1; X++) { Pos.X = X; RotatedPos = TileUtil.GetRotatedPos(ReverseOrientation, Pos, NewTileLimits); NewTerrain.Tiles[X, Y].Texture = Terrain.Tiles[RotatedPos.X, RotatedPos.Y].Texture; NewTerrain.Tiles[X, Y].Texture.Orientation = NewTerrain.Tiles[X, Y].Texture.Orientation.GetRotated(Orientation); NewTerrain.Tiles[X, Y].DownSide = Terrain.Tiles[RotatedPos.X, RotatedPos.Y].DownSide; NewTerrain.Tiles[X, Y].DownSide = NewTerrain.Tiles[X, Y].DownSide.GetRotated(Orientation); if (Terrain.Tiles[RotatedPos.X, RotatedPos.Y].Tri) { TriDirection = TileUtil.TopLeft; } else { TriDirection = TileUtil.TopRight; } TriDirection = TriDirection.GetRotated(Orientation); NewTerrain.Tiles[X, Y].Tri = Convert.ToBoolean(TileUtil.IdenticalTileDirections(TriDirection, TileUtil.TopLeft) || TileUtil.IdenticalTileDirections(TriDirection, TileUtil.BottomRight)); if (Terrain.Tiles[RotatedPos.X, RotatedPos.Y].Tri) { if (Terrain.Tiles[RotatedPos.X, RotatedPos.Y].TriTopLeftIsCliff) { TileUtil.RotateDirection(TileUtil.TopLeft, Orientation, ref TriDirection); NewTerrain.Tiles[X, Y].TriCliffAddDirection(TriDirection); } if (Terrain.Tiles[RotatedPos.X, RotatedPos.Y].TriBottomRightIsCliff) { TileUtil.RotateDirection(TileUtil.BottomRight, Orientation, ref TriDirection); NewTerrain.Tiles[X, Y].TriCliffAddDirection(TriDirection); } } else { if (Terrain.Tiles[RotatedPos.X, RotatedPos.Y].TriTopRightIsCliff) { TileUtil.RotateDirection(TileUtil.TopRight, Orientation, ref TriDirection); NewTerrain.Tiles[X, Y].TriCliffAddDirection(TriDirection); } if (Terrain.Tiles[RotatedPos.X, RotatedPos.Y].TriBottomLeftIsCliff) { TileUtil.RotateDirection(TileUtil.BottomLeft, Orientation, ref TriDirection); NewTerrain.Tiles[X, Y].TriCliffAddDirection(TriDirection); } } NewTerrain.Tiles[X, Y].Terrain_IsCliff = Terrain.Tiles[RotatedPos.X, RotatedPos.Y].Terrain_IsCliff; } } if (Orientation.SwitchedAxes) { for (Y = 0; Y <= NewTerrain.TileSize.Y; Y++) { Pos.Y = Y; for (X = 0; X <= NewTerrain.TileSize.X - 1; X++) { Pos.X = X; RotatedPos = TileUtil.GetRotatedPos(ReverseOrientation, Pos, NewSideHLimits); NewTerrain.SideH[X, Y].Road = Terrain.SideV[RotatedPos.X, RotatedPos.Y].Road; } } for (Y = 0; Y <= NewTerrain.TileSize.Y - 1; Y++) { Pos.Y = Y; for (X = 0; X <= NewTerrain.TileSize.X; X++) { Pos.X = X; RotatedPos = TileUtil.GetRotatedPos(ReverseOrientation, Pos, NewSideVLimits); NewTerrain.SideV[X, Y].Road = Terrain.SideH[RotatedPos.X, RotatedPos.Y].Road; } } } else { for (Y = 0; Y <= NewTerrain.TileSize.Y; Y++) { Pos.Y = Y; for (X = 0; X <= NewTerrain.TileSize.X - 1; X++) { Pos.X = X; RotatedPos = TileUtil.GetRotatedPos(ReverseOrientation, Pos, NewSideHLimits); NewTerrain.SideH[X, Y].Road = Terrain.SideH[RotatedPos.X, RotatedPos.Y].Road; } } for (Y = 0; Y <= NewTerrain.TileSize.Y - 1; Y++) { Pos.Y = Y; for (X = 0; X <= NewTerrain.TileSize.X; X++) { Pos.X = X; RotatedPos = TileUtil.GetRotatedPos(ReverseOrientation, Pos, NewSideVLimits); NewTerrain.SideV[X, Y].Road = Terrain.SideV[RotatedPos.X, RotatedPos.Y].Road; } } } var Unit = default(Unit); foreach (var tempLoopVar_Unit in Units) { Unit = tempLoopVar_Unit; Unit.Sectors.Clear(); if (ObjectRotateMode == Util.ObjectRotateMode.All) { Unit.Rotation = (MathUtil.AngleClamp(MathUtil.RadOf360Deg - TileUtil.GetRotatedAngle(Orientation, MathUtil.AngleClamp(MathUtil.RadOf360Deg - Unit.Rotation * MathUtil.RadOf1Deg))) / MathUtil.RadOf1Deg).ToInt(); if (Unit.Rotation < 0) { Unit.Rotation += 360; } } else if (ObjectRotateMode == ObjectRotateMode.Walls) { if (Unit.TypeBase.Type == UnitType.PlayerStructure) { if (((StructureTypeBase)Unit.TypeBase).StructureType == StructureType.Wall) { Unit.Rotation = (MathUtil.AngleClamp(MathUtil.RadOf360Deg - TileUtil.GetRotatedAngle(Orientation, MathUtil.AngleClamp(MathUtil.RadOf360Deg - Unit.Rotation * MathUtil.RadOf1Deg))) / MathUtil.RadOf1Deg) .ToInt(); if (Unit.Rotation < 0) { Unit.Rotation += 360; } //If Unit.Rotation = 180 Then // Unit.Rotation = 0 //ElseIf Unit.Rotation = 270 Then // Unit.Rotation = 90 //End If } } } Unit.Pos.Horizontal = TileUtil.GetRotatedPos(Orientation, Unit.Pos.Horizontal, OldPosLimits); } var ZeroPos = new XYInt(0, 0); var Position = 0; foreach (var tempLoopVar_Unit in Units.GetItemsAsSimpleList()) { Unit = tempLoopVar_Unit; if (!App.PosIsWithinTileArea(Unit.Pos.Horizontal, ZeroPos, NewTerrain.TileSize)) { Position = Unit.MapLink.ArrayPosition; UnitRemove(Position); } } Terrain = NewTerrain; var Gateway = default(Gateway); foreach (var tempLoopVar_Gateway in Gateways.GetItemsAsSimpleClassList()) { Gateway = tempLoopVar_Gateway; GatewayCreate(TileUtil.GetRotatedPos(Orientation, Gateway.PosA, OldTileLimits), TileUtil.GetRotatedPos(Orientation, Gateway.PosB, OldTileLimits)); Gateway.Deallocate(); } if (readyForUserInput) { CancelUserInput(); InitializeUserInput(); } }