public static async Task Main()
        {
            // Initialize the DI
            var construction = Framework.Construct <DefaultFrameworkConstruction>()
                               .AddControlManager()
                               .AddDialogManager()
                               .AddDefaultApplicationEnvironment("CeidDiplomatiki", "EN")
                               .AddCeidDiplomatikiManager()
                               .AddDatabaseAnalyzers();

            // Build the framework using the injected services
            Framework.Construction.Build();

            // Set up
            await SetUpAsync();

            // We need to create a new thread to run our application because the STAThread attribute of the main
            // gets ignored when compiled.
            // Issue: https://github.com/dotnet/roslyn/issues/22112
            var thread = new Thread(() =>
            {
                var app = new App();
                app.InitializeComponent();
                app.Run();
            });

            // Set the thread department to STA
            thread.SetApartmentState(ApartmentState.STA);

            // Start the application
            thread.Start();
        }
Beispiel #2
0
 /// <summary>
 /// Sets up the DI and binds initial view models to that
 /// </summary>
 public static void InitialSetup()
 {
     Framework.Construct <DefaultFrameworkConstruction>()
     .AddFileLogger()
     .AddDbContext()
     .AddApplicationServices();
 }
Beispiel #3
0
        private void ApplicationSetupAsync()
        {
            // Setup the Dna Framework
            Framework.Construct <DefaultFrameworkConstruction>()
            .AddPosTicketViewModels()
            .Build();
            if (File.Exists("PosTicket.ark") == false)
            {
                try
                {
                    SQLiteConnection connection = (SQLiteConnection)DatabaseContext.GetConnection();
                    SQLiteConnection.CreateFile("PosTicket.ark");
                    connection.Open();
                    string        sql_table = "create table config (id INTEGER PRIMARY KEY AUTOINCREMENT, server_url varchar(100), pos_printer varchar(100), ticket_printer varchar(100), current_ip varchar(100), api_key varchar(100), session_data text)";
                    SQLiteCommand command   = new SQLiteCommand(sql_table, connection);
                    command.ExecuteNonQuery();
                    command.Dispose();
                    connection.Close();
                    writeConfig = new WriteConfig();
                    writeConfig.CreateInitData();
                }
                catch (Exception sqlException)
                {
                    MessageBox.Show("Terjadi kesalahan inisialisasi data: " + sqlException.Message, "SQL Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            Login loginWindow = new Login();

            loginWindow.Show();
            Thread thread = new Thread(() => PingPong());

            thread.IsBackground = true;
            thread.Priority     = ThreadPriority.Highest;
            thread.Start();
        }
Beispiel #4
0
        /// <summary>
        /// custom startup so we load the iocContainer imcyctely after startup
        /// </summary>
        protected override async void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            QuickConverterHelpers.Setup();
            Framework.Construct <DefaultFrameworkConstruction>()
            .AddWpfPlotDigitizerServices()
            .Build();

            appManager.LoadLanguage();
            Current.MainWindow             = mainWindow;
            mainWindow.splashFrame.Content = splashPage;
            Current.MainWindow.Show();

#if DEBUG
            //splashPageVM.CompleteCommand.Execute(null);
#endif

            await NativeMethod.WaitAsync(obj => (obj as SplashPageVM).IsComplete, splashPageVM);

            mainWindow.gridMain.Children.Remove(mainWindow.splashFrame);

            var pageControl = mainWindow.Resources["pageControl"] as PageControl;
            mainWindow.PageControl    = pageControl;
            pageControl.PageAnimated += mainWindow.PageControl_PageAnimated;
            mainWindow.gridMain.Children.Add(pageControl);

#if DEBUG
            //browsePageVM.PBInput = new Uri(CycResources.PackUri + @"images/data.png").ToPixelBitmap();
            //axLimPageVM.AxLim = new Rect(new Point(1e-4, 1e-4), new Point(1e6, 1e7));
            //axLimPageVM.AxLogBase = new Point(10, 10);
            //appManager.PageManager.TurnTo((int)ApplicationPages.Save);
#endif
        }
Beispiel #5
0
 public Iso8583InfoTests()
 {
     Framework.Construct <DefaultFrameworkConstruction>().Build();
     Framework.Container
     .Register <IIso8583Info>(
         f => new Iso8583Info(
             logger: loggerFactory.CreateLogger <Iso8583Info>(),
             assemblyName: "StandardLibs.ISO8583",
             cfgFileName: "StandardLibs.ISO8583.Config.iso8583Fn.xml",
             xPath: @"//Message[@name='Common' and @peer='Common']"
             ),
         "commonInfo",
         new PerContainerLifetime()
         )
     .Register <IIso8583Info>(
         f => new Iso8583Info(
             logger: loggerFactory.CreateLogger <Iso8583Info>(),
             assemblyName: "StandardLibs.ISO8583",
             cfgFileName: "StandardLibs.ISO8583.Config.iso8583Fn.xml",
             xPath: @"//Message[@name='DF61' and @peer='Common']"
             ),
         "df61Info",
         new PerContainerLifetime()
         );
     this.ctx        = Framework.Container;
     this.commonInfo = this.ctx.GetInstance <IIso8583Info>("commonInfo");
     this.df61Info   = this.ctx.GetInstance <IIso8583Info>("df61Info");
 }
Beispiel #6
0
        /// <summary>
        /// Configures our application ready for use
        /// </summary>
        private async Task ApplicationSetupAsync()
        {
            // Set the default working directory
            Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) ?? Directory.GetCurrentDirectory());

            // Setup the Dna Framework
            Framework.Construct<DefaultFrameworkConstruction>()
                .AddFileLogger()
                .AddClientDataStore()
                .AddClientServices()
                .AddApplicationViewModels()
                .Build();

            await DI.SettingsManager.Initiate();

            FileAssociations.EnsureAssociationsSet();

            // Load settings
            DI.UIManager.UpdateDarkMode(DI.SettingsManager.IsDarkMode());

            DI.UIManager.UpdateFontSize(DI.SettingsManager.GetFontSize());

            // Ensure the client data store 
            await ClientDataStore.EnsureDataStoreAsync();

        }
Beispiel #7
0
 private void ApplicationSetup()
 {
     Framework.Construct <DefaultFrameworkConstruction>()
     .AddFileLogger()
     .AddAppViewModels()
     .Build();
 }
        /// <summary>
        /// Adds the Dna Framework construct to the ASP.Net Core application
        /// </summary>
        /// <param name="builder">The web host builder</param>
        /// <param name="configure">Custom action to configure the Dna Framework</param>
        /// <returns></returns>
        public static IWebHostBuilder UseDnaFramework(this IWebHostBuilder builder, Action <FrameworkConstruction> configure = null)
        {
            builder.ConfigureServices((context, services) =>
            {
                // Construct a hosted Dna Framework
                Framework.Construct <HostedFrameworkConstruction>();

                // Setup this service collection to
                // be used by DnaFramework
                services.AddDnaFramework()
                // Add configuration
                .AddConfiguration(context.Configuration)
                // Add default services
                .AddDefaultServices();

                // Fire off construction configuration
                configure?.Invoke(Framework.Construction);

                // NOTE: Framework will do .Build() from the Startup.cs Configure call
                //       app.UseDnaFramework()
            });

            // Return builder for chaining
            return(builder);
        }
Beispiel #9
0
        public async static Task Main()
        {
            // Initialize the DI
            Framework.Construct <DefaultFrameworkConstruction>()
            .AddDialogManager()
            .AddDefaultCredentialsLocalDataStorage($"DataSource=UserCredentials.db")
            .AddiPetrosServices();

            // Build the framework using the injected services
            Framework.Construction.Build();

            // Set up
            await SetUpAsync();

            // We need to create a new thread to run our application because the STAThread attribute of the main
            // gets ignored when compiled.
            // Issue: https://github.com/dotnet/roslyn/issues/22112
            var thread = new Thread(() =>
            {
                var app = new App();
                app.InitializeComponent();
                app.Run();
            });

            // Set the thread department to STA
            thread.SetApartmentState(ApartmentState.STA);

            // Start the application
            thread.Start();
        }
Beispiel #10
0
 /// <summary>
 /// Configure the application
 /// </summary>
 private void ApplicationSetup()
 {
     // Setup the Dna Framework
     Framework.Construct <DefaultFrameworkConstruction>()
     .AddCryptoCalcViewModels()
     .AddCryptoCalcClientServices()
     .Build();
 }
 /// <summary>
 /// Configures our application ready for use
 /// </summary>
 private async Task ApplicationSetupAsync()
 {
     // Setup the Dna Framework
     Framework.Construct <DefaultFrameworkConstruction>()
     .AddFileLogger()
     .AddFornavnEfternavnWpfControlsGUIViewModels()
     .Build();
 }
Beispiel #12
0
        public App()
        {
            var config = ReadConfig();

            Framework.Construct <DefaultFrameworkConstruction>()
            .AddConfiguration(config)
            .AddModules()
            .Build();

            MainPage = new AppShell();
        }
Beispiel #13
0
        /// <summary>
        /// Custom startup so we load our IoC immediately before anything else
        /// </summary>
        /// <param name="e"></param>
        protected override async void OnStartup(StartupEventArgs e)
        {
            // Let the base application do what it needs
            base.OnStartup(e);

            // Setup the Dna Framework
            Framework.Construct <DefaultFrameworkConstruction>()
            .AddFileLogger()
            .AddTranslatorContext()
            .Build();
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            // Create a list of dependencies
            var services = new ServiceCollection();


            // Configurations are heavily used in the .Net core DI for
            // configuring services, so we can make use of that
            var configurationBuilder = new ConfigurationBuilder();

            // Add default configuration file
            configurationBuilder.AddJsonFile("appsettings.json", optional: true);

            // Build the configuraton
            var configuration = configurationBuilder.Build();

            // Inject the configuration into the DI system
            services.AddSingleton <IConfiguration>(configuration);

            // At this point, all dependencies can be added to the
            // DI system via the service collection

            // e.g. services.AddScoped()

            // Builder service provider
            var provider = services.BuildServiceProvider();

            // At this point, your DI system is ready to go
            // and you can get any services via the provider
            var myConfiguration = provider.GetService <IConfiguration>();



            // The way to do this in Dna.Framework.....

            // Use framework.Construct<FrameworkConstruction> for totally
            // blank service provider containing just the FrameworkEnvironment
            // but no configuration or other services
            // For this purpose using a class with blank constructor and inherit FramworkConstruction class
            // then pass this class name .Construct<className>()

            // Or you can use DefaultframeworkConstruction for one that
            // includes basic services such as logging and inclue a
            // configuration
            Framework.Construct <DefaultFrameworkConstruction>()
            // Add further services
            .AddFileLogger()
            // And once done, build
            .Build();
        }
Beispiel #15
0
        /// <summary>
        /// Configures our application ready for use
        /// </summary>
        private async Task ApplicationSetupAsync()
        {
            Framework.Construct <DefaultFrameworkConstruction>()
            .UseClientDataStore()
            .Build();

            IoC.Setup();
            IoC.Kernel.Bind <IUIManager>().ToConstant(new UIManager());
            IoC.Kernel.Bind <IAuthService>().ToConstant(new AuthService());
            IoC.Kernel.Bind <IMapper>().ToConstructor(c => new Mapper(AutoMapperConfig.CreateConfiguration())).InSingletonScope();


            await IoC.ClientDataStore.EnsureDataStoreAsync();
        }
Beispiel #16
0
        private async Task ApplicationSetupAsync()
        {
            Framework.Construct <DefaultFrameworkConstruction>()
            .AddFileLogger()
            .AddClientDataStore()
            .AddSynthesisViewModels()
            .AddSynthesisClientServices()
            .Build();

            await Di.ClientDataStore.EnsureDataStoreAsync();

            MonitorServerStatus();

            CoreDi.TaskManager.RunAndForget(Di.ViewModelSettings.LoadAsync);
        }
Beispiel #17
0
        /// <summary>
        /// Configures our application ready for use
        /// </summary>
        private Task ApplicationSetupAsync()
        {
            // Setup the Dna Framework
            Framework.Construct <DefaultFrameworkConstruction>()
            .AddFileLogger()
            .AddClientDataStore()
            .AddViewModels()
            .AddClientServices()
            .Build();

            // Load new settings
            TaskManager.RunAndForget(ViewModelSettings.LoadAsync);

            return(Task.CompletedTask);
        }
Beispiel #18
0
        /// <summary>
        /// Configures our application ready for use
        /// </summary>
        private async Task ApplicationSetupAsync()
        {
            // Setup configuration builder
            var builder = new ConfigurationBuilder();

            // Set the path to the "appsettings.json"
            builder.SetBasePath(AppDomain.CurrentDomain.BaseDirectory.Split(new String[] { @"bin\" }, StringSplitOptions.None)[0]);

            // Get configuration from appsettings.json
            builder.AddJsonFile("appsettings.json");

            // Build the configuration
            var config = builder.Build();

            Framework.Construct <DefaultFrameworkConstruction>()
            .AddFileLogger()
            .AddClientDataStore()
            .Build();

            // Use the configuration file
            Framework.Construction.UseConfiguration(config);

            // Setup IoC
            IoC.Setup();

            // Bind a Logger
            IoC.Kernel.Bind <ILogFactory>().ToConstant(new BaseLogFactory(new[]
            {
                // TODO: Add ApplicationSettings so we can set/edit a log location
                //       For now just log to the path where this application is running
                new Core.FileLogger("log.txt")
            }));

            IoC.Kernel.Bind <ITaskManager>().ToConstant(new TaskManager());

            // Bind a file manager
            IoC.Kernel.Bind <IFileManager>().ToConstant(new FileManager());

            // Bind a UI Manager
            IoC.Kernel.Bind <IUIManager>().ToConstant(new UIManager());

            // Ensure the client data store
            await IoC.ClientDataStore.EnsureDataStoreAsync();

            // Load new settings
            //await IoC.Settings.LoadAsync();
            IoC.Task.RunAndForget(IoC.Settings.LoadAsync);
        }
Beispiel #19
0
        private async Task ApplicationSetupAsync()
        {
            // Setup the Quan Framework
            Framework.Construct <DefaultFrameworkConstruction>()
            .AddFileLogger("QuanLog.txt")
            .AddClientDataStore()
            .AddQuanWordViewModels()
            .AddQuanWordClientServices()
            .Build();

            // Ensure the client data store
            await ClientDataStore.EnsureDataStoreAsync();

            // Load new settings
            await SettingsVM.LoadAsync();
        }
Beispiel #20
0
        /// <summary>
        /// Configures our application ready for use
        /// </summary>
        private async Task ApplicationSetupAsync()
        {
            // Setup the Dna Framework
            Framework.Construct <DefaultFrameworkConstruction>()
            .AddFileLogger()
            .AddClientDataStore()
            .AddFasettoWordViewModels()
            .AddFasettoWordClientServices()
            .Build();

            // Ensure the client data store
            await ClientDataStore.EnsureDataStoreAsync();

            // Load new settings
            TaskManager.RunAndForget(ViewModelSettings.LoadAsync);
        }
Beispiel #21
0
        /// <summary>
        /// Custom startup so we load our IoC immediately before anything else
        /// </summary>
        /// <param name="e"></param>
        protected override void OnStartup(StartupEventArgs e)
        {
            // Let the base application do what it needs
            base.OnStartup(e);

            // Setup the Dna Fraimwork
            Framework.Construct <DefaultFrameworkConstruction>()
            .AddFileLogger()
            .AddChatHostViewModels()
            .AddChatClientHostServices()
            .Build();

            // Log it
            Logger.LogDebugSource("Application starting...");

            ViewModelApplication.GoToPage(ApplicationPage.Login);
        }
Beispiel #22
0
        /// <summary>
        /// Sets up the IoC and injects all required elements
        /// </summary>
        /// <param name="addinPath">The full path to the add-in dll file</param>
        /// <param name="configureServices">Provides a callback to inject any services into the Dna.Framework DI system</param>
        public static void Setup(string addinPath, Action <FrameworkConstruction> configureServices = null)
        {
            // Create default construction
            Framework.Construct(new DefaultFrameworkConstruction(configure =>
            {
                // Add configuration file for the name of this file
                // For example if it is MyAddin.dll then the configuration file
                // will be in the same folder called MyAddin.appsettings.json"
                configure.AddJsonFile(Path.ChangeExtension(addinPath, "appsettings.json"), optional: true);
            }));

            // Invoke the callback for adding custom services
            configureServices?.Invoke(Framework.Construction);

            // Build DI
            Framework.Construction.Build();
        }
Beispiel #23
0
        protected override void OnStartup(StartupEventArgs e)
        {
            Framework.Construct(builder =>
            {
                builder.RegisterInstance(ApplicationViewModel.Instance).ExternallyOwned().SingleInstance();
                builder.RegisterType <MainPageViewModel>().AsSelf();
                builder.RegisterType <FileDialogService>().As <IFileDialogService>();
                builder.RegisterType <UIManager>().As <IUIManager>();

                DataIOServiceInstaller.Install(builder);
                AlgorithmServiceInstaller.Install(builder);
                CoreServicesInstaller.Install(builder);
            });
            ExcelPackage.LicenseContext = LicenseContext.NonCommercial;

            base.OnStartup(e);
        }
Beispiel #24
0
        /// <summary>
        /// Configures our application ready for use
        /// </summary>
        private async Task ApplicationSetupAsync()
        {
            Framework.Construct <DefaultFrameworkConstruction>()
            .UseClientDataStore()
            .Build();

            // Setup the IoC
            IoC.Setup();

            // Bind the UI Manager
            IoC.Kernel.Bind <IUIManager>().ToConstant(new UIManager());

            var a = Framework.Service <IClientDataStore>();

            // Ensure Data Store
            await IoC.ClientDataStore.EnsureDataStoreAsync();
        }
Beispiel #25
0
        /// <summary>
        /// Configures our application ready for use
        /// </summary>
        private async Task ApplicationSetupAsync()
        {
            // Setup the Dna Framework
            Framework.Construct <DefaultFrameworkConstruction>()
            .AddFileLogger()
            .AddClientDataStore()
            .AddClientServices()
            .AddViewModels()
            .Build();

            // Ensure the client data store
            await ClientDataStore.EnsureDataStoreAsync();


            ViewModelApplication.GoToPage(ApplicationPage.Server);

            // Show the main window
            Current.MainWindow = new MainWindow();
            Current.MainWindow.Show();
        }
Beispiel #26
0
        /// <summary>
        /// Configures our application ready for use
        /// </summary>
        private async Task ApplicationSetupAsync()
        {
            // Setup the Dna Framework
            Framework.Construct <DefaultFrameworkConstruction>()
            .AddFileLogger()
            .AddClientDataStore()
            .AddAppsViewModels()
            .AddAppsClientServices()
            .Build();

            // Ensure the client data store
            await ClientDataStore.EnsureDataStoreAsync();

            // Ensure the BaseList data store
            await BaseListItem.EnsureDataStoreAsync();

            // Monitor for server connection status
            MonitorServerStatus();

            // Load new settings
            TaskManager.RunAndForget(ViewModelSettings.LoadAsync);
        }
Beispiel #27
0
        /// <summary>
        /// Configures our application ready for use
        /// </summary>
        private async Task ApplicationSetupAsync()
        {
            // Set database file name
            string fileName = "Dailylight.db";

            // Set database path
            string dbPath = Path.Combine(System
                                         .Environment
                                         .GetFolderPath(System.Environment.SpecialFolder.Personal), fileName);

            // Setup the Dna Framework
            Framework.Construct <DefaultFrameworkConstruction>()
            .AddClientDataStore(dbPath)
            .Build();

            // Ensure the client data store
            await ClientDataStore.EnsureDataStoreAsync();

            // Set the first page
            SetContentView(Resource.Layout.user_setup);

            // TODO: Monitor for server connection status
        }
Beispiel #28
0
        /// <summary>
        /// Configures our application ready for use
        /// </summary>
        private async Task ApplicationSetupAsync()
        {
            // Setup the Dna Framework
            Framework.Construct<DefaultFrameworkConstruction>()
                .AddFileLogger()
                .AddClientDataStore()
                .AddLoremIpsumViewModels()
                .AddLoremIpsumClientServices()
                .AddFluentValidators()
                .Build();

            // Ensure the client data store 
            await ClientDataStore.EnsureDataStoreAsync();

            // Monitor for server connection status
            MonitorServerStatus();

            //Load new settings
            TaskManager.RunAndForget(ViewModelSettings.LoadAsync);

            //Load the localization
            TaskManager.RunAndForget(() => ViewModelLocalization.LoadAsync(LanguageType.English));
        }
Beispiel #29
0
 /// <summary>
 /// Sets up the DI and binds initial view models to that
 /// </summary>
 public static void InitialSetup() => Framework.Construct <DefaultFrameworkConstruction>()
 .AddFileLogger()
 .AddPogodeoViewModels()
 .Build();
Beispiel #30
0
 public ISO8583TestsFixture()
 {
     Framework.Construct <DefaultFrameworkConstruction>().Build();
     Framework.Container
     .Register <IHexConverter>(
         f => new HexConverter(),
         "hexConverter",
         new PerContainerLifetime()
         )
     .Register <IBitConverter>(
         f => new BitConverter(f.GetInstance <IHexConverter>("hexConverter")),
         "bitConverter",
         new PerContainerLifetime()
         )
     .Register <IBitMapWorker>(
         f => new BitMapWorker(
             hexConverter: f.GetInstance <IHexConverter>("hexConverter"),
             bitConverter: f.GetInstance <IBitConverter>("bitConverter")
             ),
         "bitMapWorker",
         new PerContainerLifetime()
         )
     .Register <BitWorker>(
         f => new BitWorker(logger: loggerFactory.CreateLogger <BitWorker>(), iso8583Info: f.GetInstance <IIso8583Info>("commonInfo")),
         "commonBitWorker",
         new PerContainerLifetime()
         ).Register <BitWorker>(
         f => new BitWorker(logger: loggerFactory.CreateLogger <BitWorker>(), iso8583Info: f.GetInstance <IIso8583Info>("df61Info")),
         "df61BitWorker",
         new PerContainerLifetime()
         )
     .Register <IIso8583Info>(
         f => new Iso8583Info(
             logger: loggerFactory.CreateLogger <Iso8583Info>(),
             assemblyName: "StandardLibs.ISO8583",
             cfgFileName: "StandardLibs.ISO8583.Config.iso8583Fn.xml",
             xPath: @"//Message[@name='Common' and @peer='Common']"
             ),
         "commonInfo",
         new PerContainerLifetime()
         )
     .Register <IIso8583Info>(
         f => new Iso8583Info(
             logger: loggerFactory.CreateLogger <Iso8583Info>(),
             assemblyName: "StandardLibs.ISO8583",
             cfgFileName: "StandardLibs.ISO8583.Config.iso8583Fn.xml",
             xPath: @"//Message[@name='DF61' and @peer='Common']"
             ),
         "df61Info",
         new PerContainerLifetime()
         )
     .Register <IMessageWorker>(
         f => new MainMessageWorker(
             logger: loggerFactory.CreateLogger <MainMessageWorker>(),
             bitMapWorker: f.GetInstance <IBitMapWorker>("bitMapWorker"),
             bitWorker: f.GetInstance <BitWorker>("commonBitWorker")
             ),
         "mainMsgWorker",
         new PerContainerLifetime()
         )
     .Register <IMessageWorker>(
         f => new Df61MessageWorker(
             logger: loggerFactory.CreateLogger <Df61MessageWorker>(),
             bitMapWorker: f.GetInstance <IBitMapWorker>("bitMapWorker"),
             bitWorker: f.GetInstance <BitWorker>("df61BitWorker")
             ),
         "df61MsgWorker",
         new PerContainerLifetime()
         );
 }