private static void CreateWorkbook(out IPersistenceLayer persistence, out IWorkbook workbook)
        {
            persistence = new WinPersistenceLayer(false);
            IWorkbook currentWorkbook = null;

            if (persistence.HasSave)
            {
                try
                {
                    currentWorkbook = persistence.Open() as Workbook;
                }
                catch (Exception ex)
                {
                    Debug.Fail(ex.ToString());
                }
            }

            if (currentWorkbook == null)
            {
                persistence.Initialize();
                persistence.Save();
                currentWorkbook = new Workbook(persistence.Context, WinSettings.Instance);
            }

            workbook = currentWorkbook;
            workbook.Initialize();
        }
Ejemplo n.º 2
0
        protected IWorkbook InitializeWorkbook(IPersistenceLayer persistence, IPlatformService platformService)
        {
            IWorkbook workbook = null;

            if (persistence.HasSave)
            {
                try
                {
                    workbook = persistence.Open();
                }
                catch (Exception ex)
                {
                    TrackingManagerHelper.Exception(ex, "Initialize workbook");
                    platformService.DeleteFileAsync(persistence.DatabaseFilename).Wait(1000);
                }
            }

            if (workbook == null)
            {
                persistence.Initialize();
                workbook = this.CreateDefaultWorkbook(persistence.Context, platformService);
                persistence.Save();
            }

            // important: read view from persistence and not from workbook as they are not loaded yet in the workbook !
            if (persistence.Context.Views.Count() != DefaultDataCreator.ViewCount)
            {
                CreateDefaultViews(workbook);
            }

            workbook.Initialize();
            Ioc.RegisterInstance <IWorkbook, Workbook>((Workbook)workbook);

            return(workbook);
        }