Пример #1
0
 public void TearUp()
 {
     _transConfiguration = new GenericConfiguration<TransactionPayment>();
     _transConfiguration.Setup();
     _transList = TransactionHelper.GetTransactionList();
     _transactionModel = TransactionHelper.GetTransactionModel();
 }
Пример #2
0
        public int Execute(TaskConsoleParameters args)
        {
            var context = BSharpCompiler.CompileDirectory(args.ScriptDirectory,
                                                          new BSharpConfig {
                Global = new Scope(args.Global), KeepLexInfo = true
            });
            var cls = context[args.ScriptClass];

            if (null == cls)
            {
                throw new Exception("cannot find class " + args.ScriptClass);
            }
            var container = ContainerFactory.CreateDefault();

            container.RegisterAssembly(typeof(TaskProcess).Assembly);

            var configProvider = new GenericConfiguration(cls.Compiled, context)
            {
                Custom = args
            };

            container.Set <IConfigProvider>(configProvider);
            Loggy.Manager = container.Get <ILoggyManager>();
            var defloggy = Loggy.Manager.Get();

            defloggy.Level = args.LogLevel;
            var consoleAppender = defloggy.Appenders.OfType <ConsoleAppender>().FirstOrDefault();

            if (null == consoleAppender)
            {
                defloggy.Appenders.Add(new ConsoleAppender {
                    Format  = args.LogFormat,
                    Level   = args.LogLevel,
                    Manager = Loggy.Manager
                });
            }
            else
            {
                consoleAppender.Format = args.LogFormat;
                consoleAppender.Level  = args.LogLevel;
            }
            var loggy          = Loggy.Manager.Get("bcinst");
            var installRequest = new TaskEnvironment {
                Config  = cls.Compiled,
                Context = context,
                Log     = loggy,
                Globals = new Scope(args.Global),
                Targets = args.Targets.ToArray()
            };
            var processor = container.Get <ITaskProcessor>();

            processor.Execute(installRequest);
            return(0);
        }
Пример #3
0
 public void TearUp()
 {
     _authTokenConfig = new GenericConfiguration<AuthToken>();
     _clientLogin = new GenericConfiguration<ClientLogin>();
     _authTokenConfig.Setup();
     //_clientLogin.Setup();
     _authTokenList = TokenHelper.GetTokenModelList();
     _clientLoginList = TokenHelper.GetClientLoginList();
     _tokenModel = TokenHelper.GetModel();
     _authToken = TokenHelper.GetAuthTokenModel();
 }
Пример #4
0
        public void LoadDevice(GenericConfiguration genericConfiguration)
        {
            if (genericConfiguration == null)
            {
                throw new ArgumentNullException(nameof(genericConfiguration));
            }

            lock (_lock)
            {
                InternalLoadDevice(genericConfiguration);
            }
        }
Пример #5
0
        public GenericConfiguration GetGenericConfiguration()
        {
            var ports = RaspyPinManager.Instance.GetDevicePorts();

            var result = new GenericConfiguration()
            {
                DeviceName   = DeviceName,
                ConnectionId = SignalRRaspyberryPiClient.Instance.ConnectionId,
                Ports        = ports
            };

            return(result);
        }
Пример #6
0
        public int Execute(TaskConsoleParameters args) {
            var context = BSharpCompiler.CompileDirectory(args.ScriptDirectory,
                new BSharpConfig {Global = new Scope(args.Global),KeepLexInfo = true});
            var cls = context[args.ScriptClass];
            if (null == cls) {
                throw new Exception("cannot find class " + args.ScriptClass);
            }
            var container = ContainerFactory.CreateDefault();
            container.RegisterAssembly(typeof (TaskProcess).Assembly);

            var configProvider = new GenericConfiguration(cls.Compiled, context) {Custom = args};
            container.Set<IConfigProvider>(configProvider);
            Loggy.Manager = container.Get<ILoggyManager>();
            var defloggy = Loggy.Manager.Get();
            defloggy.Level = args.LogLevel;
            var consoleAppender = defloggy.Appenders.OfType<ConsoleAppender>().FirstOrDefault();
            if (null == consoleAppender) {
                defloggy.Appenders.Add(new ConsoleAppender {
                    Format = args.LogFormat,
                    Level = args.LogLevel,
                    Manager = Loggy.Manager
                });
            }
            else {
                consoleAppender.Format = args.LogFormat;
                consoleAppender.Level = args.LogLevel;
            }
            var loggy = Loggy.Manager.Get("bcinst");
            var installRequest = new TaskEnvironment {
                Config = cls.Compiled,
                Context = context,
                Log = loggy,
                Globals = new Scope(args.Global),
                Targets = args.Targets.ToArray()
            };
            var processor = container.Get<ITaskProcessor>();
            processor.Execute(installRequest);
            return 0;
        }
Пример #7
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app = GenericConfiguration.AppBuilderConfiguration(app, env.IsDevelopment());

            app = SwaggerConfiguration.AppBuilderConfig(app);
        }
Пример #8
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services = GenericConfiguration.Config(services, Configuration);
 }
        protected override void ExecuteLogic()
        {
            orgId  = context.OrganizationId.ToString();
            config = GetGenericConfig(service, orgId).ToEntity <GenericConfiguration>();
            config.DefaultCalendar.Require(nameof(config.DefaultCalendar));

            CustomJob target = null;
            CustomJob image  = null;

            try
            {
                // get the triggering record
                var targetGeneric = (Entity)context.InputParameters["Target"];
                target = targetGeneric.ToEntity <CustomJob>();
                image  = context.PostEntityImages.FirstOrDefault().Value?.ToEntity <CustomJob>();

                // sync
                if (context.Mode == 0)
                {
                    PerformSyncActions(targetGeneric);
                    return;
                }

                PerformAsyncActions(targetGeneric);
            }
            catch (Exception ex)
            {
                try
                {
                    if (target?.Id != null)
                    {
                        try
                        {
                            log.Log("Logging failure ...", LogLevel.Debug);
                            service.Update(
                                new CustomJob
                            {
                                Id = target.Id,
                                LatestRunMessage   = "Job handler failed to execute.\r\n" + BuildExceptionMessage(ex),
                                PreviousTargetDate = DateTime.UtcNow,
                                TargetDate         = null
                            });
                            log.Log("Logged.");

                            // if a recurrent job throws an exception (parent), then check for retry
                            // normally those jobs create sub-jobs that handle their own retry, but this is in case
                            // the main job itself fails, which should be extremely rare
                            if (image?.RecurrentJob == true && image.RetrySchedule != null)
                            {
                                UpdateRetryTargetDate(service, target, log);

                                log.Log($"Updating status of job to 'Waiting' ...");
                                SetStatus(service, CustomJob.StatusReasonEnum.Waiting, target.Id, false);
                                log.Log($"Updated status of job 'Waiting'.");
                            }
                        }
                        catch
                        {
                            // ignored
                        }

                        if (image?.RetrySchedule == null)
                        {
                            log.Log($"Setting job to 'Failure' ...", LogLevel.Debug);
                            service.Update(
                                new CustomJob
                            {
                                Id           = target.Id,
                                Status       = CustomJob.StatusEnum.Inactive,
                                StatusReason = CustomJob.StatusReasonEnum.Failure
                            });
                            log.Log($"Set job to 'Failure'.");
                        }
                    }
                }
                catch
                {
                    log.Log("Failed to set job 'failed' status.", LogLevel.Debug);
                }

                throw;
            }
        }
Пример #10
0
 public void TearUp()
 {
     transactionConfig = new GenericConfiguration<TransactionPayment>();
     transactionConfig.Setup();
     transactions = TransactionHelper.GetTranactions(6);
 }
Пример #11
0
        private void MainForm_Load(object sender, EventArgs e) {
            // Set up default values
            NewName = "Common.Configuration Test";
            Description = "Somebody";
            Option = "Option 2";
            OptionLink = "Option 3";
            DoSomething = true;
            ReadOnlyText = "Not to be edited.";
            WithAButton = "something";
            Age = 10;
            OutDir = Environment.CurrentDirectory;
            FileDir = Application.ExecutablePath;
            MultilineText = @"Line 1
Line 2
Line 3";

            // Create a second instance of the GenericConfiguration class
            GenericConfiguration second = new GenericConfiguration();
            second.Add(new ConfigurationEntry() {
                Name = "Slider",
                Text = "Slider",
                GroupKey = "RR",
                SortKey = 1,
                ControlType = ConfigurationEntry.ControlTypes.Slider,
                Minimum = 1,
                Maximum = 30
            }, 5);
            second.Add(new ConfigurationEntry() {
                Name = "CheckBox",
                Text = "CheckBox",
                GroupKey = "RR",
                SortKey = 2,
                ControlType = ConfigurationEntry.ControlTypes.CheckBox
            });

            // Show the configuration
            //ConfigControl.Configuration = GenericConfiguration.CreateFor(this);
            ConfigControl.MultipleConfigs = (new GenericConfiguration[] {
                GenericConfiguration.CreateFor(this),
                second
            }).ToList();
        }
Пример #12
0
 public DevicePortState(DevicePort port, GenericConfiguration genericConfiguration)
 {
     _port = port;
     _genericConfiguration = genericConfiguration;
 }
Пример #13
0
        private void InternalLoadDevice(GenericConfiguration genericConfiguration)
        {
            _devices.RemoveAll(p => string.Equals(p.DeviceName, genericConfiguration.DeviceName, StringComparison.InvariantCultureIgnoreCase));

            _devices.Add(genericConfiguration);
        }
Пример #14
0
 public void TearUp()
 {
     _transTypeConfiguration = new GenericConfiguration<TransactionType>();
     _transTypeConfiguration.Setup();
     _transTypeList = TransactionHelper.GetTransactionTypeList();
 }