Exemple #1
0
        static void Main(string[] args)
        {
            string connectionString = @"server type=Embedded;user id=sysdba;password=masterky;dialect=3;character set=UTF8;client library=fbembed.dll;database=D:\task.fdb";
            var taskMan = new TaskManager(connectionString);
            Console.Write("Input new task: ");
            var input = Console.ReadLine();
            Console.WriteLine("Insert entry...");
            taskMan.CreateQueueTask(input);
            Console.WriteLine("List tasks...");
            foreach (var t in taskMan.GetAllTasks())
            {
                Console.WriteLine("Taskid: {0} \t Created: {2} \t Taskname: {1}", t.Id, t.Name, t.CreationDate);
            }

            Console.WriteLine("Press any key...");
            Console.ReadKey();
            Console.WriteLine("Shutting down...");
        }
        /// <summary>
        /// Initializes a new instance of the ViewModelLocator class.
        /// </summary>
        public ViewModelLocator()
        {
            string databaseFileName;
            if (ViewModelBase.IsInDesignModeStatic)
            {
                databaseFileName = @"D:\TEMP\WORK3.FDB";
            }
            else
            {
                databaseFileName = GetDatabase();
                if (databaseFileName == "") Environment.Exit(-1);
            }
            var connectionString = String.Format(@"server type=Embedded;user id=sysdba;password=masterky;dialect=3;character set=UTF8;client library=fbembed.dll;database={0}", databaseFileName);
            var taskMan = new TaskManager(connectionString);

            var builder = new ContainerBuilder();
            builder.RegisterType<MainViewModel>();
            builder.RegisterType<TaskListViewModel>().WithParameters(new TypedParameter[]
                {
                    new TypedParameter(typeof(TaskManager), taskMan),
                    new TypedParameter(typeof(MainWindow), App.Current.MainWindow)
                });
            builder.RegisterType<TimeLogViewModel>().WithParameters(new TypedParameter[]
                {
                    new TypedParameter(typeof(TaskManager), taskMan)
                });
            builder.RegisterType<SettingsViewModel>();
            viewContainer = builder.Build();

            ////if (ViewModelBase.IsInDesignModeStatic)
            ////{
            ////    // Create design time view services and models
            ////    SimpleIoc.Default.Register<IDataService, DesignDataService>();
            ////}
            ////else
            ////{
            ////    // Create run time view services and models
            ////    SimpleIoc.Default.Register<IDataService, DataService>();
            ////}
        }
        private void btnOpenDb_Click(object sender, RoutedEventArgs e)
        {
            // The MySql Style
            //this.taskMan = new TaskManager();
            //AllTasksToListBox();

            // The Firebird way
            var openDialog = new Microsoft.Win32.OpenFileDialog();
            if (openDialog.ShowDialog().Value)
            {
                string connectionString = String.Format(@"server type=Embedded;user id=sysdba;password=masterky;dialect=3;character set=UTF8;client library=fbembed.dll;database={0}", openDialog.FileName);
                this.taskMan = new TaskManager(connectionString);
                btnOpenDb.IsEnabled = false;
                this.Title = this.Title + " - " + openDialog.FileName;

                AllTasksToListBox();

                if (this.taskMan.HasActiveTask)
                {
                    SetTaskBarIconActive();
                }
                else SetTaskBarIconPaused();
            }
        }