Beispiel #1
0
        public async Task <FilesResult> LoadSelectedFile()
        {
            FilesResult           result = new FilesResult();
            ExternalStorageDevice sdCard = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();

            if (sdCard != null)
            {
                IEnumerable <ExternalStorageFile> files = await sdCard.RootFolder.GetFilesAsync();

                if (SelectedFile.Name.EndsWith(".txt"))
                {
                    System.IO.Stream fileStream = await SelectedFile.OpenForReadAsync();

                    //Read the entire file into the FileText property
                    using (StreamReader streamReader = new StreamReader(fileStream))
                    {
                        FileText = streamReader.ReadToEnd();
                    }

                    fileStream.Close();
                    result.Success = true;
                }
                else
                {
                    result.Success = false;
                    result.Message = "Invalid file type. Can only open text files with a '.txt' extension";
                }
            }

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// Gets all external storage files
        /// </summary>
        /// <param name="sdCard"></param>
        /// <returns></returns>
        public async Task <ObservableCollection <ExternalStorageFile> > GetExternal_GPXFiles(string folder, string fileExtension)
        {
            ObservableCollection <ExternalStorageFile> storageFIle = new ObservableCollection <ExternalStorageFile>();

            try
            {
                ExternalStorageDevice sdCard = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();
                if (sdCard != null)
                {
                    ExternalStorageFolder routesFolder = await sdCard.GetFolderAsync(folder);

                    IEnumerable <ExternalStorageFile> routeFiles = await routesFolder.GetFilesAsync();

                    foreach (ExternalStorageFile extStoreFile in routeFiles)
                    {
                        if (extStoreFile.Path.EndsWith(fileExtension))
                        {
                            storageFIle.Add(extStoreFile);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("SD card not found, Please make sure the SD card is inserted properly.");
                }
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show("The file folder " + folder + " not found.");
                return(null);
            }
            return(storageFIle);
        }
Beispiel #3
0
        async Task GetExtStorage()
        {
            ExternalStorageDevice sdCard = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();

            if (!appSettings.Contains("extstorage") || (int)appSettings["extstorage"] == -1)
            {
                if (sdCard != null)
                {
                    if (MessageBox.Show(UVEngine.Resources.UVEngine.sdinserted, UVEngine.Resources.UVEngine.tip, MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                    {
                        appSettings.Add("extstorage", 1);
                    }
                    else
                    {
                        appSettings.Add("extstorage", 0);
                    }
                }
                else
                {
                    //No SDCard Inserted
                    appSettings.Add("extstorage", -1);
                }
                appSettings.Save();
            }
            else if (sdCard == null)
            {
                appSettings["extstorage"] = -1;
            }
        }
Beispiel #4
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            // Connect to the current SD card.
            sdCard = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();

            // If the SD card is present, add GPX files to the Routes collection.
            if (sdCard != null)
            {
                this.skydriveStack[0].Add(new SDCardListItem()
                {
                    Name       = "Root",
                    isFolder   = true,
                    ThisFolder = sdCard.RootFolder,
                    ParentPath = null
                });


                this.OpenFolder(sdCard.RootFolder);
            }
            else
            {
                // No SD card is present.
                MessageBox.Show(AppResources.SDCardMissingText);
            }

            base.OnNavigatedTo(e);
        }
Beispiel #5
0
        private async void LoadFileAsync(string fileId, AsyncContext context)
        {
            try
            {
                var sdCardStorage = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();
                if (sdCardStorage == null)
                {
                    context.Error = new Exception("There are no external storage devices found.");
                    context.WaitHandle.Set();
                    return;
                }

                var file = await sdCardStorage.GetFileAsync(fileId);

                var stream = await file.OpenForReadAsync();

                context.Stream = CopyStream(stream);
            }
            catch (Exception exception)
            {
                context.Error = exception;
            }
            finally
            {
                context.WaitHandle.Set();
            }
        }
Beispiel #6
0
        private ExternalStorage UIToExternalStorageModel()
        {
            ExternalStorage externalStorage = new ExternalStorage();

            externalStorage.connectionString = AzureStorageConnectionString.Text;
            externalStorage.container        = AzureStorageContainerName.Text;
            return(externalStorage);
        }
Beispiel #7
0
        /// <summary>
        /// Checks if there is an external storage and is ready for use.
        /// </summary>
        /// <returns>True, if there is an external device ready for use</returns>
        internal static async Task <ExternalStorageDevice> GetExternalStorageAsync()
        {
            if (sdCard == null)
            {
                IEnumerable <ExternalStorageDevice> devices =
                    await ExternalStorage.GetExternalStorageDevicesAsync();

                sdCard = devices.FirstOrDefault();
            }

            return(sdCard);
        }
Beispiel #8
0
        public static async void ExportDb()
        {
            try
            {
                StorageFile file = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("weibodb.sqlite");

                ExternalStorageDevice device = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();
                ExternalStorageFolder folder = await device.GetFolderAsync("WeiBo");

                //await file.CopyAsync(folder);
            }
            catch
            {
            }
        }
        // Create
        public bool CreateExternal(ExternalCreate model)
        {
            ExternalStorage entity = new ExternalStorage
            {
                Name         = model.Name,
                Manufacturer = model.Manufacturer,
                Interface    = model.Interface,
                Capacity     = model.Capacity,
                Type         = model.Type,
                Color        = model.Color,
                IsPortiable  = model.IsPortiable,
                IsAvailable  = model.IsAvailable
            };

            _db.ExternalStorages.Add(entity);
            return(_db.SaveChanges() == 1);
        }
Beispiel #10
0
        async void Initialize()
        {
            _folderTree  = new Stack <ExternalStorageFolder>();
            CurrentItems = new ObservableCollection <FileExplorerItem>();

            var storageAssets = await ExternalStorage.GetExternalStorageDevicesAsync();

            _currentStorageDevice = storageAssets.FirstOrDefault();

            LayoutRoot.Width  = Application.Current.Host.Content.ActualWidth;
            LayoutRoot.Height = Application.Current.Host.Content.ActualHeight;

            if (_currentStorageDevice != null)
            {
                GetTreeForFolder(_currentStorageDevice.RootFolder);
            }
        }
Beispiel #11
0
        public async Task <IEnumerable <ExternalStorageFile> > GetFilesAsync(params string[] extensions)
        {
            if (_sdCardStorage == null)
            {
                _sdCardStorage = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();
            }

            //suppose SD-card is null
            if (_sdCardStorage == null)
            {
                throw new SdCardNotSupportedException();
            }

            //read all files recursively
            var files = new List <ExternalStorageFile>();

            await GetFilesAsync(_sdCardStorage.RootFolder, files);

            return(files);
        }
        public SimCorpMobile()
        {
            _vCpu = new Cpu("Intel", new List <Core> {
                new Core(64, 2.1), new Core(64, 2.1)
            });
            _vExternalStorage    = new ExternalStorage(128);
            _vFrontalBasicCamera = new FrontalBasicCamera(1.5, 5);

            _vGraphCpu = new GraphCpu("AMD", new List <Core>
            {
                new Core(64, 2.1), new Core(64, 2.1), new Core(64, 2.1), new Core(64, 2.1)
            });

            _vInternalStorage = new InternalStorage(64);
            _vKeyboard        = new DigitalKeyboard(new List <char>(), new List <char>());
            _vLiIonBattery    = new LiIonBattery(5, 2200, true);
            _vMicrophone      = new Microphone("Internal", 3.5, 2);

            _vMultiMainBasicCamera = new MultiMainBasicCamera(2.5, 12,
                                                              new List <MainBasicCamera>
            {
                new MainBasicCamera(2.5, 12),
                new MainBasicCamera(2.5, 12),
                new MainBasicCamera(2.5, 12)
            });

            _vMultiSimCardHolder = new MultiSimCardHolder("DoubleSim",
                                                          new List <SimCardHolder>
            {
                new SimCardHolder("microSim"),
                new SimCardHolder("microSim")
            });

            _vMultiTouchScreen = new MultiTouchScreen("Multi", 10);

            _vOLedBasicScreen = new OLedBasicScreen(1080, 1920, 7, 233);
            _vRam             = new Ram(4);
            _vSpeaker         = new Speaker(15, 15000, 4.5, 3, Output);
            SmsProvider       = new SmsProvider();
            SmsProvider.Count = 0;
        }
Beispiel #13
0
        public async Task <FilesResult> GetFiles()
        {
            FilesResult result = new FilesResult();

            ExternalStorageDevice sdCard = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();

            if (sdCard != null)
            {
                IEnumerable <ExternalStorageFile> files = await sdCard.RootFolder.GetFilesAsync();

                ExternalStorageFile file = files.FirstOrDefault();
                Files          = new ObservableCollection <ExternalStorageFile>(files.Where(f => f.Name.EndsWith(".txt")).ToList());
                result.Success = true;
            }
            else
            {
                result.Success = false;
                result.Message = "An SD card was not detected.";
            }
            return(result);
        }
Beispiel #14
0
        private async void RefreshList()
        {
            // Clear the collection bound to the page.
            Files.Clear();

            // Connect to the current SD card.
            ExternalStorageDevice _sdCard = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();

            // If the SD card is present, add KDBX files to the Files collection.
            if (_sdCard != null)
            {
                try
                {
                    // Look for a folder on the SD card named Files.
                    ExternalStorageFolder dbFolder = await _sdCard.GetFolderAsync("CodeSafe");

                    // Get all files from the CodeSafe folder.
                    IEnumerable <ExternalStorageFile> routeFiles = await dbFolder.GetFilesAsync();

                    // Add each KDBX file to the Files collection.
                    foreach (ExternalStorageFile esf in routeFiles)
                    {
                        if (esf.Path.EndsWith(".kdbx"))
                        {
                            Files.Add(esf);
                        }
                    }
                }
                catch (FileNotFoundException)
                {
                    // No CodeSafe folder is present.
                    MessageBox.Show("The CodeSafe folder is missing on your SD card. Add a CodeSafe folder containing at least one .kdbx file and try again.");
                }
            }
            else
            {
                // No SD card is present.
                MessageBox.Show("The SD card is mssing. Insert an SD card that has a CodeSafe folder containing at least one .kdbx file and try again.");
            }
        }
Beispiel #15
0
        /// <summary>
        /// Checks to see if a folder exists on the sd card.
        /// </summary>
        /// <param name="folderName"></param>
        /// <returns></returns>
        public async Task <bool> SDCard_CheckFolder(string folderName)
        {
            try
            {
                if (folderName != string.Empty)
                {
                    ExternalStorageDevice sdcard = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();
                    if (sdcard != null)
                    {
                        ExternalStorageFolder folder = await sdcard.GetFolderAsync(folderName);

                        return(true);
                    }
                    return(false);
                }
                return(false);
            }
            catch (FileNotFoundException)
            {
                return(false);
            }
        }
Beispiel #16
0
        private async System.Threading.Tasks.Task ShowList()
        {
            ExternalStorageDevice device = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();
            ExternalStorageFolder folder = await device.RootFolder.GetFolderAsync("ADV");

            ExternalStorageFolder[] gamefolders = (await folder.GetFoldersAsync()).ToArray <ExternalStorageFolder>();
            foreach (ExternalStorageFolder f in gamefolders)
            {
                ExternalStorageFile[] files = (await f.GetFilesAsync()).ToArray <ExternalStorageFile>();
                int count = 0;
                foreach (ExternalStorageFile ef in files)
                {
                    if (ef.Name == "nscript.dat" || ef.Name == "nscript.___" || ef.Name == "nscr.dat")
                    {
                        count++;
                    }
                }
                if (count >= 1)
                {
                    List.Text += f.Name + '\n';
                }
            }
        }
        async void InitializeStorageContainers()
        {
            if (StorageTarget == Interop.StorageTarget.ExternalStorage)
            {
                _externalFolderTree = new Stack <ExternalStorageFolder>();

                try
                {
                    var storageAssets = await ExternalStorage.GetExternalStorageDevicesAsync();

                    _currentStorageDevice = storageAssets.FirstOrDefault();

                    if (_currentStorageDevice != null)
                    {
                        GetTreeForExternalFolder(_currentStorageDevice.RootFolder);
                    }
                }
                catch
                {
                    Debug.WriteLine("EXT_STORAGE_ERROR: There was a problem accessing external storage.");
                }
            }
            else
            {
                _internalFolderTree = new Stack <StorageFolder>();

                try
                {
                    GetTreeForInternalFolder(ApplicationData.Current.LocalFolder);
                }
                catch
                {
                    Debug.WriteLine("INT_STORAGE_ERROR: There was a problem accessing internal storage.");
                }
            }
        }
Beispiel #18
0
        /// <summary>
        /// Gets a file from SD Card
        /// </summary>
        /// <param name="sdfilePath"></param>
        /// <returns>File Stream</returns>
        public async Task <Stream> SDCard_ReadFile(string sdfilePath)
        {
            try
            {
                ExternalStorageDevice sdcard = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();

                if (sdcard != null)
                {
                    ExternalStorageFile file = await sdcard.GetFileAsync(sdfilePath);

                    return(await file.OpenForReadAsync());
                }
                else
                {
                    MessageBox.Show("Please check SD Card");
                    return(null);
                }
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show("File not found.");
                return(null);
            }
        }
        async public void readfile(string filepath)
        {
            // enables progress indicator
            //ProgressIndicator indicator = SystemTray.ProgressIndicator;
            //if (indicator != null)
            //{
            //    //indicator.Text = "载入文件中 ...";
            //    //indicator.IsVisible = true;
            //}

            // Connect to the current SD card.
            ExternalStorageDevice _sdCard = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();

            // If the SD card is present, add GPX files to the Routes collection.
            if (_sdCard != null)
            {
                try
                {
                    // get file of the specific path
                    ExternalStorageFile esf = await _sdCard.GetFileAsync(filepath);

                    if (esf != null)
                    {
                        Debug.WriteLine("found file " + esf.Name);
                        if (esf.Path.EndsWith(".txtx"))
                        {
                            // print its content
                            Stream x = await esf.OpenForReadAsync();

                            byte[] buffer = new byte[x.Length];
                            x.Read(buffer, 0, (int)x.Length);
                            x.Close();

                            string result = System.Text.Encoding.UTF8.GetString(buffer, 0, buffer.Length);
                            //Debug.WriteLine(result);
                            //this.title.Text = "阅读器";
                            //Debug.WriteLine("title changed");
                            //this.content.Text = result.Substring(0, 10000);
                            //Debug.WriteLine("content changed");
                            this.contentString = result;

                            // cut content into pages
                            this.cutContentIntoPages();

                            // display first page
                            this.currentPage = 0;
                            this.displayCurrentPage();
                        }
                    }
                    Debug.WriteLine("done");
                }
                catch (FileNotFoundException)
                {
                    // No Routes folder is present.
                    this.content.Text = "Error loading file, reason: file not found";
                    Debug.WriteLine("file not found.");
                }
            }
            else
            {
                // No SD card is present.
                Debug.WriteLine("The SD card is mssing.");
            }
        }
Beispiel #20
0
        public static async void Update(DatabaseInfo info,
                                        Func <DatabaseInfo, bool> queryUpdate,
                                        ReportUpdateResult report)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }
            if (queryUpdate == null)
            {
                throw new ArgumentNullException("queryUpdate");
            }
            if (report == null)
            {
                throw new ArgumentNullException("report");
            }

            // Connect to the current SD card.
            ExternalStorageDevice _sdCard = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();

            // If the SD card is present, add KDBX files to the Files collection.
            if (_sdCard != null)
            {
                try
                {
                    // Look for a folder on the SD card named Files.
                    ExternalStorageFolder dbFolder = await _sdCard.GetFolderAsync("CodeSafe");

                    // Get all files from the CodeSafe folder.
                    IEnumerable <ExternalStorageFile> routeFiles = await dbFolder.GetFilesAsync();

                    bool found = false;
                    foreach (ExternalStorageFile esf in routeFiles)
                    {
                        if (esf.Name.RemoveKdbx() == info.Details.Name)
                        {
                            found = true;
                            Stream stream = await esf.OpenForReadAsync();

                            var check = DatabaseVerifier
                                        .VerifyUnattened(stream);

                            if (check.Result == VerifyResultTypes.Error)
                            {
                                report(info, SyncResults.Failed,
                                       check.Message);
                                return;
                            }

                            info.SetDatabase(stream, info.Details);
                            report(info, SyncResults.Downloaded, null);

                            break;
                        }
                    }

                    if (!found)
                    {
                        MessageBox.Show("The original database file is not found in CodeSafe folder on your SD card anymore. Did you delete it?");
                    }
                }
                catch (FileNotFoundException)
                {
                    // No CodeSafe folder is present.
                    MessageBox.Show("The CodeSafe folder is missing on your SD card. Add a CodeSafe folder containing at least one .kdbx file and try again.");
                }
            }
            else
            {
                // No SD card is present.
                MessageBox.Show("The SD card is mssing. Insert an SD card that has a CodeSafe folder containing at least one .kdbx file and try again.");
            }
        }
Beispiel #21
0
 public async Task <bool> GetIsAvailableAsync()
 {
     _sdCardStorage = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();
     return(_sdCardStorage != null);
 }
Beispiel #22
0
        //no overhead here since all services need these objects created anyway
        private void CreateSingletons()
        {
            System.Configuration.Configuration configuration = null;
            ConnectionStringSettings           cs            = null;
            ConnectionStringSettings           csMessageBus  = null;

            try
            {
                configuration = GetGlobalPacsConfig();
                if (null == configuration)
                {
                    cs = GetConnectionDefaults();
                }
                if (null == configuration && null == cs)
                {
                    throw new ServiceSetupException("Missing GlobalPacs.Config path information (and/or) missing the Connection strings configurations.");
                }

                csMessageBus = GetMessageBusConnection();

                if (null == csMessageBus)
                {
                    _messageBus = new Lazy <IMessagesBus>(() => new InMemoryMessagesBus());
                }
                else
                {
                    _messageBus = new Lazy <IMessagesBus>(() => new RebusSqlMessagesBus(csMessageBus.ConnectionString));
                }

                _storageAgent = new Lazy <IStorageDataAccessAgent3>(() =>
                {
                    if (DataAccessServices.IsDataAccessServiceRegistered <IStorageDataAccessAgent3>())
                    {
                        return(DataAccessServices.GetDataAccessService <IStorageDataAccessAgent3>());
                    }
                    else
                    {
                        if (null != configuration)
                        {
                            return(DataAccessFactory.GetInstance(new StorageDataAccessConfigurationView(configuration, ProductNameStorageServer, null)).CreateDataAccessAgent <IStorageDataAccessAgent3>());
                        }
                        else
                        {
                            return(createDataAccess <StorageDataAccessConfigurationView, IStorageDataAccessAgent3>(cs));
                        }
                    }
                });

                _loggingAgent = new Lazy <ILoggingDataAccessAgent>(() =>
                {
                    if (DataAccessServices.IsDataAccessServiceRegistered <ILoggingDataAccessAgent>())
                    {
                        return(DataAccessServices.GetDataAccessService <ILoggingDataAccessAgent>());
                    }
                    else
                    {
                        if (null != configuration)
                        {
                            return(DataAccessFactory.GetInstance(new LoggingDataAccessConfigurationView(configuration, ProductNameStorageServer, null)).CreateDataAccessAgent <ILoggingDataAccessAgent>());
                        }
                        else
                        {
                            return(createDataAccess <LoggingDataAccessConfigurationView, ILoggingDataAccessAgent>(cs));
                        }
                    }
                });

                //initialize external storage (slow)
                // (07.26.2019) Update for 85943: Call ExternalStorage.Startup() here for ExternalStorage (i.e. Cloud storage)
                ExternalStorage.Startup();

                _externalStoreAgent = new Lazy <IExternalStoreDataAccessAgent>(() =>
                {
                    if (DataAccessServices.IsDataAccessServiceRegistered <IExternalStoreDataAccessAgent>())
                    {
                        return(DataAccessServices.GetDataAccessService <IExternalStoreDataAccessAgent>());
                    }
                    else
                    {
                        IExternalStoreDataAccessAgent externalStoreAgent;
                        if (null != configuration)
                        {
                            externalStoreAgent = DataAccessFactory.GetInstance(new ExternalStoreDataAccessConfigurationView(configuration, ProductNameStorageServer, null)).CreateDataAccessAgent <IExternalStoreDataAccessAgent>();
                        }
                        else
                        {
                            externalStoreAgent = createDataAccess <ExternalStoreDataAccessConfigurationView, IExternalStoreDataAccessAgent>(cs);
                        }
                        DataAccessServices.RegisterDataAccessService <IExternalStoreDataAccessAgent>(externalStoreAgent);
                        return(externalStoreAgent);
                    }
                });

                _userManagementDataAccessAgent = new Lazy <IUserManagementDataAccessAgent4>(() =>
                {
                    if (null != configuration)
                    {
                        return(DataAccessFactory.GetInstance(new UserManagementDataAccessConfigurationView2(configuration, ProductNameStorageServer, null)).CreateDataAccessAgent <IUserManagementDataAccessAgent4>());
                    }
                    else
                    {
                        return(createDataAccess <UserManagementDataAccessConfigurationView2, IUserManagementDataAccessAgent4>(cs));
                    }
                });
                _permissionManagementDataAccessAgent = new Lazy <IPermissionManagementDataAccessAgent2>(() =>
                {
                    if (null != configuration)
                    {
                        return(DataAccessFactory.GetInstance(new PermissionManagementDataAccessConfigurationView(configuration, ProductNameStorageServer, null)).CreateDataAccessAgent <IPermissionManagementDataAccessAgent2>());
                    }
                    else
                    {
                        return(createDataAccess <PermissionManagementDataAccessConfigurationView, IPermissionManagementDataAccessAgent2>(cs));
                    }
                });
                _optionsDataAccessAgent = new Lazy <IOptionsDataAccessAgent>(() =>
                {
                    if (null != configuration)
                    {
                        return(DataAccessFactory.GetInstance(new OptionsDataAccessConfigurationView(configuration, ProductNameMedicalViewer, null)).CreateDataAccessAgent <IOptionsDataAccessAgent>());
                    }
                    else
                    {
                        return(createDataAccess <OptionsDataAccessConfigurationView, IOptionsDataAccessAgent>(cs));
                    }
                });
                _patientRightsDataAccess = new Lazy <IPatientRightsDataAccessAgent>(() =>
                {
                    if (null != configuration)
                    {
                        return(DataAccessFactory.GetInstance(new PatientRightsDataAccessConfigurationView(configuration, ProductNameMedicalViewer, null)).CreateDataAccessAgent <IPatientRightsDataAccessAgent>());
                    }
                    else
                    {
                        return(createDataAccess <PatientRightsDataAccessConfigurationView, IPatientRightsDataAccessAgent>(cs));
                    }
                });
                _downloadJobsDataAccessAgent = new Lazy <IDownloadJobsDataAccessAgent>(() =>
                {
                    if (null != configuration)
                    {
                        return(DataAccessFactory.GetInstance(new DownloadJobsDataAccessConfigurationView(configuration, ProductNameMedicalViewer, null)).CreateDataAccessAgent <IDownloadJobsDataAccessAgent>());
                    }
                    else
                    {
                        return(createDataAccess <DownloadJobsDataAccessConfigurationView, IDownloadJobsDataAccessAgent>(cs));
                    }
                });
                _monitorCalibrationDataAccessAgent = new Lazy <IMonitorCalibrationDataAccessAgent>(() =>
                {
                    if (null != configuration)
                    {
                        return(DataAccessFactory.GetInstance(new MonitorCalibrationDataAccessConfigurationView(configuration, ProductNameMedicalViewer, null)).CreateDataAccessAgent <IMonitorCalibrationDataAccessAgent>());
                    }
                    else
                    {
                        return(createDataAccess <MonitorCalibrationDataAccessConfigurationView, IMonitorCalibrationDataAccessAgent>(cs));
                    }
                });
                _templateDataAccessAgent = new Lazy <ITemplateDataAccessAgent>(() =>
                {
                    if (null != configuration)
                    {
                        return(DataAccessFactory.GetInstance(new TemplateDataAccessConfigurationView(configuration, ProductNameMedicalViewer, null)).CreateDataAccessAgent <ITemplateDataAccessAgent>());
                    }
                    else
                    {
                        return(createDataAccess <TemplateDataAccessConfigurationView, ITemplateDataAccessAgent>(cs));
                    }
                });

                _authorizedStorageDataAccessAgent = new Lazy <IAuthorizedStorageDataAccessAgent2>(() => new AuthorizedStorageDataAccessAgent(_storageAgent.Value, _patientRightsDataAccess.Value, _permissionManagementDataAccessAgent.Value));
                _dataCache          = new Lazy <Leadtools.Dicom.Imaging.IDataCacheProvider>(() => LTCachingCtrl.CreateCache(LTCachingCtrl.CacheSettings));
                _connectionSettings = new Lazy <ConnectionSettings>();
            }
            catch
            {
                throw new ServiceSetupException("Service component not registered");
            }
        }
Beispiel #23
0
 private void LoadToExtHardMemory(ILoadToStorage loadToHardMemory)
 {
     ExternalStorage.LoadToHardMemory(loadToHardMemory);
 }
Beispiel #24
0
 private void LoadFromExtHardMemory(ILoadFromStorage loadFromHardMemory)
 {
     ExternalStorage.LoadFromHardMemory(loadFromHardMemory);
 }
        private async void buildFileList()
        {
            // enables progress indicator
            //ProgressIndicator indicator = SystemTray.ProgressIndicator;
            //if (indicator != null)
            //{
            //    //indicator.Text = "载入文件中 ...";
            //    //indicator.IsVisible = true;
            //}

            this.files = new List <Book>();

            Book sampleBook = new Book();

            sampleBook.Name     = "《三国演义》节选";
            sampleBook.Path     = "试阅文本";
            sampleBook.IsSample = true;
            this.files.Add(sampleBook);

            // sandbox
            try
            {
                // sandbox root folder
                IStorageFolder routesFolder = ApplicationData.Current.LocalFolder;

                // Get all files from the Routes folder.
                IEnumerable <StorageFile> files = await routesFolder.GetFilesAsync();

                Debug.WriteLine("found folder");
                // Add each GPX file to the Routes collection.
                foreach (StorageFile esf in files)
                {
                    Debug.WriteLine("found file " + esf.Name);
                    if (esf.Path.EndsWith(".txtx"))
                    {
                        int    loc      = esf.Name.LastIndexOf(".txtx");
                        string bookname = esf.Name.Substring(0, loc);

                        // remove first part of book names
                        loc = bookname.LastIndexOf("-");
                        if (loc + 1 < bookname.Length)
                        {
                            bookname = bookname.Substring(loc + 1).Trim();
                        }

                        // add to file list
                        Book newBook = new Book();
                        newBook.Name = bookname;
                        newBook.Path = "\\" + esf.Path.Split(new String[] { "\\" }, StringSplitOptions.RemoveEmptyEntries).Last();
                        this.files.Add(newBook);
                    }
                }
                Debug.WriteLine("done");
            }
            catch (FileNotFoundException)
            {
                // No Routes folder is present.
                Debug.WriteLine("Folder not found.");
            }

            // Connect to the current SD card.
            ExternalStorageDevice _sdCard = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault();

            // If the SD card is present, add GPX files to the Routes collection.
            if (_sdCard != null)
            {
                // root folder
                try
                {
                    // Look for a folder on the SD card
                    ExternalStorageFolder folder = _sdCard.RootFolder;

                    // Get all files from the Routes folder.
                    IEnumerable <ExternalStorageFile> files = await folder.GetFilesAsync();

                    Debug.WriteLine("found folder");
                    // Add each GPX file to the Routes collection.
                    foreach (ExternalStorageFile esf in files)
                    {
                        Debug.WriteLine("found file " + esf.Name);
                        if (esf.Path.EndsWith(".txtx"))
                        {
                            int    loc      = esf.Name.LastIndexOf(".txtx");
                            string bookname = esf.Name.Substring(0, loc);

                            // remove first part of book names
                            loc = bookname.LastIndexOf("-");
                            if (loc + 1 < bookname.Length)
                            {
                                bookname = bookname.Substring(loc + 1).Trim();
                            }

                            // add to file list
                            Book newBook = new Book();
                            newBook.Name = bookname;
                            newBook.Path = esf.Path;
                            this.files.Add(newBook);
                        }
                    }
                    Debug.WriteLine("done");
                }
                catch (FileNotFoundException)
                {
                    // No Routes folder is present.
                    Debug.WriteLine("Folder not found.");
                }

                // Book
                try
                {
                    // Look for a folder on the SD card named Routes.
                    ExternalStorageFolder folder = await _sdCard.GetFolderAsync("Book");

                    // Get all files from the Routes folder.
                    IEnumerable <ExternalStorageFile> files = await folder.GetFilesAsync();

                    Debug.WriteLine("found folder");
                    // Add each GPX file to the Routes collection.
                    foreach (ExternalStorageFile esf in files)
                    {
                        Debug.WriteLine("found file " + esf.Name);
                        if (esf.Path.EndsWith(".txtx"))
                        {
                            int    loc      = esf.Name.LastIndexOf(".txtx");
                            string bookname = esf.Name.Substring(0, loc);

                            // remove first part of book names
                            loc = bookname.LastIndexOf("-");
                            if (loc + 1 < bookname.Length)
                            {
                                bookname = bookname.Substring(loc + 1).Trim();
                            }

                            // add to file list
                            Book newBook = new Book();
                            newBook.Name = bookname;
                            newBook.Path = esf.Path;
                            this.files.Add(newBook);
                        }
                    }
                    Debug.WriteLine("done");
                }
                catch (FileNotFoundException)
                {
                    // No Routes folder is present.
                    Debug.WriteLine("Folder not found.");
                }

                // Books
                try
                {
                    // Look for a folder on the SD card named Routes.
                    ExternalStorageFolder folder = await _sdCard.GetFolderAsync("Books");

                    // Get all files from the Routes folder.
                    IEnumerable <ExternalStorageFile> files = await folder.GetFilesAsync();

                    Debug.WriteLine("found folder");
                    // Add each GPX file to the Routes collection.
                    foreach (ExternalStorageFile esf in files)
                    {
                        Debug.WriteLine("found file " + esf.Name);
                        if (esf.Path.EndsWith(".txtx"))
                        {
                            int    loc      = esf.Name.LastIndexOf(".txtx");
                            string bookname = esf.Name.Substring(0, loc);

                            // remove first part of book names
                            loc = bookname.LastIndexOf("-");
                            if (loc + 1 < bookname.Length)
                            {
                                bookname = bookname.Substring(loc + 1).Trim();
                            }

                            // add to file list
                            Book newBook = new Book();
                            newBook.Name = bookname;
                            newBook.Path = esf.Path;
                            this.files.Add(newBook);
                        }
                    }
                    Debug.WriteLine("done");
                }
                catch (FileNotFoundException)
                {
                    // No Routes folder is present.
                    Debug.WriteLine("Folder not found.");
                }
            }
            else
            {
                // No SD card is present.
                Debug.WriteLine("The SD card is mssing.");
            }

            this.fileList.ItemsSource = this.files;
        }
Beispiel #26
0
        /// <summary>
        /// Resolves the SD card information. Note that the result false if the
        /// card is not installed even if the device supports one.
        /// </summary>
        private async void ResolveSDCardInfo()
        {
            var devices = await ExternalStorage.GetExternalStorageDevicesAsync();

            HasSDCardPresent = (devices != null && devices.Count() > 0);
        }