Example #1
0
        public Robot(CleaningProgram cleaningProgram, IOffice office)
        {
            _office = office;
            _programme = cleaningProgram;

            CleanCell(_programme.InitialPosition);
        }
 public OfficeController()
 {
     off       = new MOffice();
     proType   = new MProjectType();
     phaseType = new MPhaseType();
     speedType = new MSpeedConnectionType();
     offScop   = new MOfficeScope();
 }
 public OfficeViewModel(IOffice office)
 {
     this.Id          = office.Id;
     this.Country     = office.Country;
     this.City        = office.City;
     this.StreetName  = office.Street;
     this.CompanyName = office.Company.Name;
 }
Example #4
0
 public HomeController()
 {
     dc      = new MDataCenter();
     off     = new MOffice();
     lab     = new MLab();
     fac     = new MFactory();
     other   = new MOtherProject();
     phaType = new MPhaseType();
     proType = new MProjectType();
     speed   = new MSpeedConnectionType();
 }
Example #5
0
        public CustomersListViewModel(IMediator mediator, IOffice office, AddNewCustomerViewModel addNewCustomerViewModel,
                                      EditCustomerViewModel editCustomerViewModel)
        {
            this.mediator = mediator;
            this.office   = office;
            this.addNewCustomerViewModel = addNewCustomerViewModel;
            this.editCustomerViewModel   = editCustomerViewModel;

            Messenger.Default.Register <NotificationMessage>(this, NotificationMessageReceived);

            InitialCustomerFeatureViewModels();
        }
Example #6
0
        public void TestNpoiExcelExport()
        {
            ServiceCollection services = new ServiceCollection();

            services.AddNpoiOffice();
            IServiceProvider serviceProvider = services.BuildServiceProvider();
            IOffice          office          = serviceProvider.GetRequiredService <IOffice>();
            string           fileName        = Guid.NewGuid().ToString();

            office.ExportToExcel(GetDemoDatas(), $"{fileName}.xlsx", new ExportOption()
            {
                SheetName = "sheet3"
            });
            Assert.IsTrue(File.Exists($"{fileName}.xlsx"));
        }
Example #7
0
        public void TestNpoiExcelImport()
        {
            ServiceCollection services = new ServiceCollection();

            services.AddNpoiOffice();
            IServiceProvider serviceProvider = services.BuildServiceProvider();
            IOffice          office          = serviceProvider.GetRequiredService <IOffice>();
            string           fileName        = Guid.NewGuid().ToString();

            office.ExportToExcel(GetDemoDatas(), $"{fileName}.xlsx", new ExportOption()
            {
                SheetName = "sheet3"
            });
            var result = office.ImportFromExcel <DemoData>($"{fileName}.xlsx");

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
        }
Example #8
0
 /// <summary>
 /// Converts the file to a PDF file
 /// </summary>
 /// <param name="filepath">The file to be converted</param>
 private void Converts(string filepath)
 {
     if (!this.officeNotInstalled)
     {
         this.UpdateTextLabel(this.statut, this.ressourceManager.GetString(ResourceMessage.STATUS_CONVERT_BEGIN));
         this.UpdateTextLabel(this.document, Path.GetFileName(filepath));
         IOffice office = OfficeHelper.GetOffice();
         try
         {
             this.UpdateTextLabel(this.statut, this.ressourceManager.GetString(ResourceMessage.STATUS_CONVERT_LOADING));
             office.ConvertToPdf(filepath);
             this.UpdateTextLabel(this.statut, this.ressourceManager.GetString(ResourceMessage.STATUS_CONVERT_END));
             this.UpdateTextLabel(this.label1, ++this.progressFiles + "/" + this.numberFiles);
             this.progressBar1.PerformStep();
         }
         catch (NotInstalledOfficeException)
         {
             this.officeNotInstalled = true;
             this.UpdateTextLabel(this.statut, this.ressourceManager.GetString(ResourceMessage.STATUS_ERROR_OFFICE));
             MessageBox.Show(this.ressourceManager.GetString(ResourceMessage.STATUS_ERROR_OFFICE));
         }
     }
 }
Example #9
0
 public HomeController(IOffice office)
 {
     _office = office;
 }
 public Engine(IOffice office, IEmployeeFactory employeeFactory, IJobFactory jobFactory)
 {
     this.office          = office;
     this.employeeFactory = employeeFactory;
     this.jobFactory      = jobFactory;
 }
Example #11
0
 public ProjectsListViewModel(IMediator mediator, IOffice office)
 {
     this.mediator = mediator;
     this.office   = office;
 }
Example #12
0
 public Robot(IOffice office)
 {
     this.office = office;
 }
Example #13
0
        private static void Main()
        {
            try
            {
                Console.CancelKeyPress += (e, args) => Cts.Cancel();

                string environmentVariable = Environment.GetEnvironmentVariable("ENVIRONMENT");
                string environmentName     = string.IsNullOrEmpty(environmentVariable)
                    ? "local"
                    : environmentVariable;

                IConfigurationRoot configurationRoot = new ConfigurationBuilder()
                                                       .SetBasePath($"{Directory.GetCurrentDirectory()}/settings")
                                                       .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                                                       .AddJsonFile($"appsettings.{environmentName}.json", optional: true, reloadOnChange: true)
                                                       .Build();
                var rhapsoConfiguration = new LaNinaConfiguration(configurationRoot);

                // Because RoboCustos brain logs using serilog we need to configure that logging stuff here
                // we will use the information from the log appsettings.json to configure it

                // TODO: this is already in the "Robot" section which seems a little odd, maybe we should move it?

                CommonAzureSerilogConfiguration.ConfigureFromProvider(new NetCoreSettingsProvider(configurationRoot.GetSection("Robot")),
                                                                      machineRole: "Robot",
                                                                      config: new Configuration
                {
                    ExtraConfigurationEnrichmentProperties = new[] { "TargetEnvironment" }
                });

                ILoggerFactory loggerFactory = GetLoggerFactory(configurationRoot).Result;
                _logger = loggerFactory.CreateLogger(nameof(Robot));

                AssemblyLoadContext.Default.Unloading += context =>
                {
                    // Handle SIGTERM and trigger cancellation token
                    _logger.LogInformation("SIGTERM signal has been received...");
                    Log.Logger.Information("SIGTERM signal has been received... (Serilog)");
                    Cts.Cancel();
                };

                // Write interaction information to kusto

                var kustoLocker = new RoboCustos.Lockers.Kusto.KustoStorageLocker(_logger)
                {
                    IncludeHappinessCounts = rhapsoConfiguration.IncludeHappinessCounts
                };

                List <RoboStorageLocker> lockers = new List <RoboStorageLocker>();
                lockers.Add(kustoLocker);
                // When running debug (likely a dev machine) also stream things to the console
#if DEBUG
                lockers.Add(new ConsoleLocker());
#endif

                CombinedStorageLocker combined = new CombinedStorageLocker(lockers);

                IOffice office = CreateLaNinaOffice(rhapsoConfiguration, combined);
                // log to both logging apis to make sure they are both working
                _logger.LogInformation("Rhapso.Robot Starting...");
                Log.Logger.Information("Rhapso.Robot Starting... (Serilog)");

                // loop forever (not sure if this is actually the best plan, maybe we should let the process exit on errors and get re-started?)
                while (true)
                {
                    try
                    {
                        office.Work(Cts.Token).Wait();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine($"Exception encountered {e}");
                        if (e is TaskCanceledException || e is OperationCanceledException ||
                            (e is AggregateException && ((AggregateException)e).Flatten().InnerExceptions.Any(i => i is TaskCanceledException || i is OperationCanceledException)))
                        {
                            // we are being cancelled so exit
                            // right now the only way this gets called is through CTRL-C on dev machines but we may integrate
                            // with K8s pre-stop events later perhaps.
                            Log.Logger.Information("Robocustos execution cancelled.");
                            return;
                        }
                        else
                        {
                            // log the exception via both logging pipelines in case there is some issue with one of them
                            Log.Logger.Error(e, "Exception Encountered running office");
                            _logger.LogException(e, "Exception Encountered running office");
                        }
                    }
                }
            }
            finally
            {
                // make sure any serilog pipeline stuff gets flushed (not sure if we can do the same thing for the kusto pipeline)
                Log.CloseAndFlush();
            }
        }
Example #14
0
 public CiaAgent(IOffice off)
 {
     this.SupportOffice = off;
 }