Exemplo n.º 1
0
 internal void AddFile(BioFileInfo bioFileInfo)
 {
     Dispatcher.BeginInvoke(new Action(() =>
     {
         //log.InfoFormat("Adding file {0} with number {1}", bioFileInfo.Filename, bioFileInfo.FileNumber);
         TreeModel.Add(bioFileInfo);
         TreeModel.Update();
         //OnPropertyChanged("TreeModel");
     }));
 }
Exemplo n.º 2
0
        private void fillFileList(FillFileArgs args)
        {
            UInt32 index = 0;

            var archiveSize = _libClient.getArchiveEntriesCount();

            //log.Info("archive size = " + archiveSize);

            try
            {
                Nullable <BiosecLibClient.ArchivePathInfo> newPath = args.LibClient.getArchivePathsAt(index);
                while (newPath != null && !_stopFillingList)
                {
                    var biofile = new BioFileInfo()
                    {
                        Filename   = newPath.Value.pathName,
                        FileSize   = newPath.Value.size,
                        FileNumber = newPath.Value.index,
                        Timestamp  = newPath.Value.mTime
                    };

                    if (newPath.Value.type == BiosecLibClient.EntityAtPathType.Folder)
                    {
                        biofile.Type = IdentaZone.BioSecure.BioFileInfo.PathType.Folder;
                    }
                    else
                    {
                        biofile.Type = IdentaZone.BioSecure.BioFileInfo.PathType.File;
                    }
                    args.FileChooser.AddFile(biofile);
                    ++index;

                    newPath = args.LibClient.getArchivePathsAt(index);

                    //Thread.Sleep(1);
                }
            }
            catch (Exception ex)
            {
                Auxiliary.Logger._log.Error("Error retrieving archive paths: " + ex.Message);
            }

            if (!_stopFillingList)
            {
                args.FileChooser.IsDecryptAllEnabled = true;
            }
        }
Exemplo n.º 3
0
 internal void Add(BioFileInfo bioFileInfo)
 {
     //var timePoint0 = DateTime.Now;
     ++_itemCount;
     String[] split = System.IO.Path.GetDirectoryName(bioFileInfo.Filename).Split(System.IO.Path.DirectorySeparatorChar);
     //var timePoint1 = DateTime.Now;
     //var diff01 = timePoint1.Millisecond - timePoint0.Millisecond;
     //log.Info("timespan 1: " + diff01.ToString() + " ms");
     if (!String.IsNullOrEmpty(split[0]))
     {
         CheckAndCreateRoute(_items[0], split.ToList <String>(), bioFileInfo);
     }
     else
     {
         _items[0].Files.Add(new FileViewModel(this, bioFileInfo.Filename)
         {
             BioFileInfo = bioFileInfo
         });
         _hashSet.Add(bioFileInfo.Filename);
     }
     //var timePoint2 = DateTime.Now;
     //var diff12 = timePoint2.Millisecond - timePoint1.Millisecond;
     // log.Info("timespan 2: " + diff12.ToString() + " ms");
 }
Exemplo n.º 4
0
        private void CheckAndCreateRoute(FileViewModel fileViewModel, List <String> split, BioFileInfo bioFileInfo)
        {
            if (split.Count > 0)
            {
                var dirName = split[0];

                /*
                 * if (!fileViewModel.Files.Any(item => item.Name == dirName))
                 * {
                 *  fileViewModel.Files.Add(new FileViewModel(this, dirName));
                 * }
                 *
                 * HashSet<string> hash=new HashSet<string>();*/



                if (!_hashSet.Contains(dirName))
                {
                    fileViewModel.Files.Add(new FileViewModel(this, dirName));
                    _hashSet.Add(dirName);
                }

                split.RemoveAt(0);
                CheckAndCreateRoute(fileViewModel.Files.First(item => item.Name == dirName), split, bioFileInfo);
            }
            else
            {
                var fileName = System.IO.Path.GetFileName(bioFileInfo.Filename);
                if (bioFileInfo.Type == BioFileInfo.PathType.File)
                {
                    // if (!fileViewModel.Files.Any(item => item.Name == fileName))
                    if (!_hashSet.Contains(bioFileInfo.Filename))
                    {
                        fileViewModel.Files.Add(new FileViewModel(this, fileName)
                        {
                            BioFileInfo = bioFileInfo
                        });
                        _hashSet.Add(bioFileInfo.Filename);
                    }
                }
                else
                {
                    var existingNode = fileViewModel.Files.FirstOrDefault((obj) => obj.Name == fileName);
                    if (existingNode != null)
                    {
                        existingNode.BioFileInfo = bioFileInfo;
                    }
                    else
                    {
                        fileViewModel.Files.Add(new FileViewModel(this, fileName)
                        {
                            BioFileInfo = bioFileInfo
                        });
                        _hashSet.Add(fileName);
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void DestroyTimerEvent(object sender,EventArgs e)
        {
            _destroyer.Stop();
            switch (_result)
            {
            case ResultState.SHOW_PB_ENC:
                this.Hide();
                _progressBar.Show();
                _libClient.startEncryptionProcess(
                    _updateProgress,_fileOperationFinished,_fileOperationError);

                break;

            case ResultState.SHOW_FILECHOOSER:
                _fileChooser.IdentifiedAsString = "Identified as " + Truncate(_username,20);
                var archiveEntriesCount = _libClient.getArchiveEntriesCount();
                if (archiveEntriesCount > maxEntriesToShowFileChooserInstantly)
                {
                    var fileChooserProgressBar = new ProgressBar();
                    fileChooserProgressBar.SetBarsCount(1);
                    fileChooserProgressBar.SetText(0,"Please wait while BioSecure read protected file");
                    this.Hide();
                    fileChooserProgressBar.Show();

                    uint index = 0;

                    List <BioFileInfo> filesList = new List <BioFileInfo>();
                    Nullable <BiosecLibClient.ArchivePathInfo> newPath = _libClient.getArchivePathsAt(index);
                    while (newPath != null)
                    {
                        var biofile = new BioFileInfo()
                        {
                            Filename   = newPath.Value.pathName,
                            FileSize   = newPath.Value.size,
                            FileNumber = newPath.Value.index,
                            Timestamp  = newPath.Value.mTime
                        };

                        if (newPath.Value.type == BiosecLibClient.EntityAtPathType.Folder)
                        {
                            biofile.Type = IdentaZone.BioSecure.BioFileInfo.PathType.Folder;
                        }
                        else
                        {
                            biofile.Type = IdentaZone.BioSecure.BioFileInfo.PathType.File;
                        }
                        ++index;

                        filesList.Add(biofile);
                        newPath = _libClient.getArchivePathsAt(index);
                        this.Dispatcher.Invoke(new Action(() =>
                        {
                            var doneInPercent = (int)(((index + 1) * 100) / archiveEntriesCount);
                            fileChooserProgressBar.SetProgress(0,doneInPercent);
                        }));
                        //Thread.Sleep(1);
                    }


                    fileChooserProgressBar.Destroy();
                    _fileChooser.ShowFromList(filesList);
                }
                else
                {
                    _fileChooser.Show();
                    _fileListFiller = new Thread(() => fillFileList(new FillFileArgs()
                    {
                        FileChooser = _fileChooser,LibClient = _libClient
                    }));
                    _fileListFiller.Priority = ThreadPriority.BelowNormal;
                    _fileListFiller.Start();
                }


                break;

            case ResultState.SHOW_PB_DEC_SOME:
                _libClient.setSelectionPaths(_fileChooser.GetSelectedNodes().ToArray());
                _fileChooser.Close();
                this.Hide();
                _progressBar.Show();
                _libClient.startDecryptionProcess(_updateProgress,_fileOperationFinished,_fileOperationError);
                break;

            case ResultState.SHOW_PB_DEC_ALL:
                _libClient.setSelectionPaths(_fileChooser.GetAllNodes().ToArray());
                _fileChooser.Close();
                this.Hide();
                _progressBar.Show();
                _libClient.startDecryptionProcess(_updateProgress,_fileOperationFinished,_fileOperationError);
                break;
            }
        }