コード例 #1
0
        /// <summary>
        /// Mounts an image and returns it's path and format
        /// </summary>
        /// <param name="path"></param>
        /// <param name="mountedPath"></param>
        /// <returns></returns>
        private static VideoFormat MountImage(string path, out string mountedPath)
        {
            VideoFormat videoFormat = VideoFormat.UNKNOWN;

            MountingTool mounter = new MountingTool();

            if (mounter.Mount(path, out mountedPath))
            {
                mountedPath += ":\\";

                // now that we've mounted it let's see what it is
                videoFormat = (FileScanner.IsDVD(mountedPath))
                                   ? VideoFormat.DVD
                                   : (FileScanner.IsBluRay(mountedPath))
                                        ? VideoFormat.BLURAY
                                        : (FileScanner.IsHDDVD(mountedPath))
                                            ? VideoFormat.HDDVD
                                            : VideoFormat.UNKNOWN;
            }
            else
            {
                mountedPath = null;
            }

            return(videoFormat);
        }
コード例 #2
0
        public VideoFormat GetFormatFromPath(string path)
        {
            // Validate the new path
            if (File.Exists(path))
            {
                return((VideoFormat)Enum.Parse(typeof(VideoFormat),
                                               System.IO.Path.GetExtension(Path).Replace(".", "").Replace("-", ""), true));
            }
            else if (Directory.Exists(path))
            {
                if (FileScanner.IsDVD(path))
                {
                    return(VideoFormat.DVD);
                }

                if (FileScanner.IsBluRay(path))
                {
                    return(VideoFormat.BLURAY);
                }

                if (FileScanner.IsHDDVD(path))
                {
                    return(VideoFormat.HDDVD);
                }
            }

            return(VideoFormat.UNKNOWN);
        }
コード例 #3
0
ファイル: VariablesStore.cs プロジェクト: ToanDao2612/middler
        private IEntry FindVariableEntry(string parentFolder, string name, string extension = null)
        {
            parentFolder = parentFolder ?? String.Empty;
            name         = name ?? String.Empty;
            extension    = extension?.Trim('.');

            Regex regex;

            if (string.IsNullOrWhiteSpace(extension))
            {
                regex = new Regex($"{name}\\.[A-Za-z1-9]+", RegexOptions.IgnoreCase);
            }
            else
            {
                regex = new Regex($"{name}\\.{extension}", RegexOptions.IgnoreCase);
            }



            var scanner = new FileScanner(FileSystem)
                          .AddRegex(parentFolder, regex)
                          .SetReturnFiles(true)
                          .SetReturnDirectories(false)
                          .SetDirectoryEvaluator((entry) => false);

            return(scanner.FirstOrDefault());
        }
コード例 #4
0
        public void Restart()
        {
            Aborting = true;

            ThreadPool.QueueUserWorkItem(delegate
            {
                while (
                    !FileScanner.Stopped ||
                    !FileUploader.Stopped ||
                    !PlaylistProcessor.Stopped ||
                    !IdleProcessor.Stopped ||
                    !QueueChecker.Stopped)
                {
                    ThreadHelper.SafeSleep(250);
                }

                FileScanner       = new FileScanner(this);
                FileUploader      = new FileUploader(this);
                IdleProcessor     = new IdleProcessor(this);
                QueueChecker      = new QueueChecker(this);
                PlaylistProcessor = new PlaylistProcessor(this);

                FileScanner.Reset();
                Aborting = false;

                ManagingYTMusicStatus = ManagingYTMusicStatusEnum.CloseChangesComplete;
                StartMainProcess(true);
            });
        }
コード例 #5
0
        private void btnScanFiles_Click(object sender, EventArgs e)
        {
            DateTime      startTime = System.DateTime.Now;
            DirectoryInfo diTop     = new DirectoryInfo(@"C:\");
            string        extension = "xlsx";
            DataTable     dt        = null;

            dt = FileScanner.scanFilesByExtension(diTop, extension);

            DateTime endTime = System.DateTime.Now;
            TimeSpan ts      = endTime - startTime;

            Console.WriteLine("Total : {0}", string.Format("{0:D2}h:{1:D2}m:{2:D2}s:{3:D3}ms",
                                                           ts.Hours,
                                                           ts.Minutes,
                                                           ts.Seconds,
                                                           ts.Milliseconds));

            string filePathAndName = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + Path.DirectorySeparatorChar + "test2.txt";
            bool   result          = Utility.writeDataTableToFile(filePathAndName, dt, true);

            if (result == true)
            {
                MessageBox.Show("done");
            }
            else
            {
                MessageBox.Show("error");
            }
        }
コード例 #6
0
        public bool PlayMovie()
        {
            if (FileScanner.IsBluRay(_mediaPath))
            {
                string play_string = FileScanner.GetPlayStringForPath(_mediaPath);
//                play_string = "BLURAY://" + play_string;
//                play_string.Replace('\\', '/');
                if (AddInHost.Current.MediaCenterEnvironment.PlayMedia(MediaType.Video, play_string, false))
                {
                    if (AddInHost.Current.MediaCenterEnvironment.MediaExperience != null)
                    {
                        Utilities.DebugLine("BluRayPlayer.PlayMovie: movie {0} Playing", _source);
                        OMLApplication.Current.NowPlayingMovieName = _source.Name;
                        OMLApplication.Current.NowPlayingStatus    = PlayState.Playing;
                        AddInHost.Current.MediaCenterEnvironment.MediaExperience.Transport.PropertyChanged -= MoviePlayerFactory.Transport_PropertyChanged;
                        AddInHost.Current.MediaCenterEnvironment.MediaExperience.Transport.PropertyChanged += MoviePlayerFactory.Transport_PropertyChanged;
                        AddInHost.Current.MediaCenterEnvironment.MediaExperience.GoToFullScreen();
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: wheeliemow/tinyopds
        private static void ScanFolder()
        {
            // Init log file settings
            Log.SaveToFile = TinyOPDS.Properties.Settings.Default.SaveLogToDisk;

            _scanner                = new FileScanner();
            _scanner.OnBookFound   += scanner_OnBookFound;
            _scanner.OnInvalidBook += (_, __) => { _invalidFiles++; };
            _scanner.OnFileSkipped += (object _sender, FileSkippedEventArgs _e) =>
            {
                _skippedFiles = _e.Count;
                UpdateInfo();
            };
            _scanner.OnScanCompleted += (_, __) =>
            {
                UpdateInfo(true);
                Log.WriteLine("Directory scanner completed");
            };
            _fb2Count      = _epubCount = _skippedFiles = _invalidFiles = _duplicates = 0;
            _scanStartTime = DateTime.Now;
            _scanner.Start(Library.LibraryPath);
            Console.WriteLine("Scanning directory {0}", Library.LibraryPath);
            Log.WriteLine("Directory scanner started");
            UpdateInfo();
            while (_scanner != null && _scanner.Status == FileScannerStatus.SCANNING)
            {
                Thread.Sleep(500);
            }
            // Save library in the main thread
            Library.Save();
        }
コード例 #8
0
        protected List <DataFileInfo> GetExcelFiles()
        {
            var excelFileList = new List <DataFileInfo>();


            FileScanner.ScanAllExcelFiles(new DirectoryInfo(clientConfig.ExcelOrderFolder));
            if (FileScanner.ScannedFiles.Any())
            {
                FileScanner.ScannedFiles.ForEach(file =>
                {
                    var dateStr  = file.Name.Split('.').First().Split('_').Last().Substring(0, 8);
                    var fileDate = DateTime.ParseExact(dateStr, "yyyyMMdd", CultureInfo.InvariantCulture);

                    excelFileList.Add(new DataFileInfo(fileDate, file.Name, file.FullName));
                });
                var dt = string.IsNullOrEmpty(clientConfig.LastSyncDate) == true ? DateTime.Now : DateTime.Parse(clientConfig.LastSyncDate);
                if (!string.IsNullOrEmpty(clientConfig.LastSyncDate))
                {
                    excelFileList = excelFileList.Where(e => e.FileDate > dt).ToList();
                }
            }

            excelFileList = excelFileList.OrderBy(f => f.FileDate).ToList();

            return(excelFileList);
        }
コード例 #9
0
        protected List <DataFileInfo> GetExcelFiles()
        {
            var excelFileList = new List <DataFileInfo>();


            FileScanner.ScanAllExcelFiles(new DirectoryInfo(clientConfig.ExcelOrderFolder));
            if (FileScanner.ScannedFiles.Any())
            {
                FileScanner.ScannedFiles.ForEach(file =>
                {
                    var dateStr = file.Name.Split('.').First();
                    if (dateStr.Contains("供货商发货"))
                    {
                        dateStr = dateStr.Substring(5, 8);
                    }
                    else
                    {
                        dateStr = dateStr.Substring(6, 8);
                    }

                    var fileDate = DateTime.ParseExact(dateStr, "yyyyMMdd", CultureInfo.InvariantCulture);

                    excelFileList.Add(new DataFileInfo(fileDate, file.Name, file.FullName));
                });
            }

            excelFileList = excelFileList.OrderBy(f => f.FileDate).ToList();

            return(excelFileList);
        }
コード例 #10
0
        public void ScanFolderForFilesShouldReturnRootFolder()
        {
            // Arrange
            var directoryProvider = new Mock <IDirectoryProvider>();
            var fileProvider      = new Mock <IIsoFileProvider>();

            directoryProvider.Setup(m => m.GetDirectories(It.IsAny <string>())).Returns(new string[0]);
            var            fileScanner = new FileScanner(directoryProvider.Object, fileProvider.Object);
            IsoFolder      rootFolder;
            string         driveLetter    = "D";
            FileScanResult fileScanResult = new FileScanResult();

            // Act
            rootFolder = fileScanner.ScanFolderForFiles(driveLetter, fileScanResult, null);

            // Assert
            Assert.IsNotNull(rootFolder);
            Assert.AreEqual("/", rootFolder.Name);
            Assert.AreEqual(driveLetter + ":\\", rootFolder.Path);
            Assert.IsNull(rootFolder.Parent);
            Assert.AreEqual(0, rootFolder.ChildFiles.Count);
            Assert.AreEqual(0, rootFolder.ChildFolders.Count);
            Assert.AreEqual(0, fileScanResult.FilesWithErrorCount);
            Assert.AreEqual(0, fileScanResult.FoldersWithErrorCount);
            Assert.AreEqual(0, fileScanResult.ProcessedFileCount);
            Assert.AreEqual(1, fileScanResult.ProcessedFolderCount);
        }
コード例 #11
0
        public void ScanFolderForFilesShouldAddFiles()
        {
            // Arrange
            var directoryProvider = new Mock <IDirectoryProvider>();
            var fileProvider      = new Mock <IIsoFileProvider>();

            fileProvider.Setup(m => m.GetIsoFile(@"D:\file01.txt")).Returns(new IsoFile {
                Name = "file01.txt"
            });
            fileProvider.Setup(m => m.GetIsoFile(@"D:\file02.txt")).Returns(new IsoFile {
                Name = "file02.txt"
            });
            fileProvider.Setup(m => m.GetIsoFile(@"D:\file03.txt")).Returns(new IsoFile {
                Name = "file03.txt"
            });
            directoryProvider.Setup(m => m.GetDirectories(It.IsAny <string>())).Returns(new string[0]);
            directoryProvider.Setup(m => m.GetFiles(@"D:\", It.IsAny <string>())).Returns(new string[] { @"D:\file01.txt", @"D:\file02.txt", @"D:\file03.txt" });
            var            fileScanner = new FileScanner(directoryProvider.Object, fileProvider.Object);
            IsoFolder      rootFolder;
            string         driveLetter    = "D";
            FileScanResult fileScanResult = new FileScanResult();

            // Act
            rootFolder = fileScanner.ScanFolderForFiles(driveLetter, fileScanResult, null);

            // Assert
            Assert.AreEqual(3, rootFolder.ChildFiles.Count);
            Assert.AreEqual(0, rootFolder.ChildFolders.Count);
            Assert.AreEqual("file01.txt", rootFolder.ChildFiles.ToList()[0].Name);
            Assert.AreEqual(0, fileScanResult.FilesWithErrorCount);
            Assert.AreEqual(0, fileScanResult.FoldersWithErrorCount);
            Assert.AreEqual(3, fileScanResult.ProcessedFileCount);
            Assert.AreEqual(1, fileScanResult.ProcessedFolderCount);
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: SeanDunford/nzbliteclient
 private static void ModeBackup()
 {
     try
     {
         if (Db.Load(null, true) == false)
         {
             Logger.Error(LOGNAME, "An error occurred while loading database", null);
             return;
         }
         if (FileScanner.Start() == false)
         {
             Logger.Error(LOGNAME, "An error occurred while starting filescanner", null);
             return;
         }
         if (FileUploader.Start() == false)
         {
             Logger.Error(LOGNAME, "An error occurred while starting fileuploader", null);
             return;
         }
     }
     catch (Exception ex)
     {
         Logger.Error(LOGNAME, ex.Message, ex);
     }
 }
コード例 #13
0
        /// <summary>
        /// Run in a thread.
        /// </summary>
        /// <param name="dir">Directory to start scanning at.</param>
        private void ScanDirectory(object dir)
        {
            string sdir    = dir.ToString();
            bool   success = false;

            try {
                FileScanner scanner = new FileScanner();

                scanner.ScanFiles(this, Thread.CurrentThread, sdir);

                LogAction("Scan complete");

                using (Database db = new Database()) {
                    db.SaveScanDir(sdir);
                }

                success = true;
            }
            catch (ThreadAbortException taex) {
                LogAction("Scan aborted: " + taex.Message);
            }
            catch (Exception ex) {
                LogAction("Scan interrupted: " + ex.Message + " (" + ex.ToString() + ")");
            }
            finally {
                BeginInvoke(onScanComplete, new object[] { this, new ScanCompleteEventArgs {
                                                               ScanDir = sdir, Success = success
                                                           } });
            }
        }
コード例 #14
0
 public void ScanTest()
 {
     FileScanner scaner = new FileScanner("*.sln");
     var result = scaner.Scan(@"D:\CodeFolder\DotNet\Visual Studio 2013\Projects\ProcjetManager", @"D:\CodeFolder\DotNet\Visual Studio 2013\Projects\ProcjetManager\TestFiles\新建文件夹 (2)");
     Assert.IsNotNull(result);
     Assert.AreEqual(2, result.Count());
 }
コード例 #15
0
        private async Task StartScanning(CancellationToken ct)
        {
            if (string.IsNullOrEmpty(folderBrowserDialog1.SelectedPath))
            {
                return;
            }

            try
            {
                var stopwatch = Stopwatch.StartNew();

                _fileList = await Task.Run(() => FileScanner.ScanForMusicFiles(folderBrowserDialog1.SelectedPath, ScanningProgress, ct), ct);

                stopwatch.Stop();
                _duration = stopwatch.Elapsed;

                _hasFilesToIndex = _fileList.Any();
                ScanningFinished();
            }
            catch (Exception e)
            {
                _scanningStarted = false;
                MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK);
            }
            finally
            {
                _cts.Dispose();
                _cts = null;
            }
        }
コード例 #16
0
        public bool PlayMovie()
        {
            if (FileScanner.IsDVD(_mediaPath))
            {
                bool   isUNC = false;
                string path  = FileScanner.GetPlayStringForPath(_mediaPath);

                // the unc path requires that it start with // so remove \\ if it exists
                //http://discuss.mediacentersandbox.com/forums/thread/9307.aspx
                if (path.StartsWith("\\\\"))
                {
                    path  = path.Substring(2);
                    isUNC = true;
                }

                path = path.Replace("\\", "/");

                if (OMLApplication.IsWindows7 && isUNC)
                {
                    path = string.Format("//{0}", path);
                }
                else
                {
                    path = string.Format("DVD://{0}", path);
                }

                OMLApplication.DebugLine("[MoviePlayerDVD] Actual play string being passed to PlayMovie: {0}", path);
                return(PlayMovie(path));
            }
            return(false);
        }
コード例 #17
0
        public void Test_ProcessFolder()
        {
            string    path  = @"x:\bak";
            Stopwatch timer = new Stopwatch();

            timer.Reset();
            FileScanner   scanner = new FileScanner();
            DirectoryInfo dir     = new DirectoryInfo(path);

            timer.Start();
            scanner.GetDirectorySize(dir);
            timer.Stop();
            Debug.WriteLine($"File Scanner Seconds: {timer.Elapsed.TotalSeconds:0.000}");

            timer.Reset();
            FileLogger logger = new FileLogger();

            timer.Start();
            logger.ProcessFolder(path, 1000);
            timer.Stop();
            Debug.WriteLine($"File Logger Seconds - Queue 1000: {timer.Elapsed.TotalSeconds:0.000}");

            timer.Reset();
            timer.Start();
            logger.ProcessFolder(path, 100);
            timer.Stop();
            Debug.WriteLine($"File Logger Seconds - Queue 100: {timer.Elapsed.TotalSeconds:0.000}");

            timer.Reset();
            timer.Start();
            FileLogger.ProcessTest(path);
            timer.Stop();
            Debug.WriteLine($"Process Test Seconds: {timer.Elapsed.TotalSeconds:0.000}");
        }
コード例 #18
0
        public TreeWalker()
        {
            Mq = BlockingMq.GetMq();

            FileTaskScheduler = SnaffCon.GetFileTaskScheduler();
            TreeTaskScheduler = SnaffCon.GetTreeTaskScheduler();
            FileScanner       = SnaffCon.GetFileScanner();
        }
コード例 #19
0
        public static List <String> GetFileList(String path, Func <String, Boolean> filter, bool recursive = true)
        {
            var ret = new List <String>();
            var fs  = new FileScanner(ret, filter, recursive);

            WalkTree(path, fs);
            return(ret);
        }
コード例 #20
0
ファイル: Program.cs プロジェクト: Ajoni/netcdu
 static async Task GoUp(Window window, FileScanner fs, Toplevel top, TreeView tree)
 {
     if (!fs.GoUp())
     {
         return;
     }
     tree.Root = null;
     await ScanFiles(window, fs, top, tree);
 }
コード例 #21
0
        public void FileScannerConstructorWithNullFileProviderShouldThrowException()
        {
            //Arrange
            FileScanner fileScanner;
            var         directoryProvider = new Mock <IDirectoryProvider>();

            //Act
            fileScanner = new FileScanner(directoryProvider.Object, null);
        }
コード例 #22
0
 public void Restart()
 {
     QueueChecker.Queue = false;
     Aborting           = false;
     Requests.UploadCheckCache.CleanUp = true;
     FileUploader.Stopped = true;
     FileScanner.Reset();
     StartMainProcess();
 }
コード例 #23
0
        public void FindsDoesNotFindNonTestProcedure()
        {
            var scanner = new FileScanner(new TSql130Parser(false));


            var result =
                scanner.ScanCode("--select 100\r\nGO\r\ncreate    procedure [blah hello there] as select 1;", new ScanResults(), "path");

            Assert.AreEqual(0, result.FoundPotentialTests.Count);
        }
コード例 #24
0
        public void Should_question_redirect_when_found_a_pdf()
        {
            var fileMover = Substitute.For<IFileMover>();
            var uiInteraction = Substitute.For<IUiInteraction>();
            var fileScanner = new FileScanner(uiInteraction, fileMover, "");

            fileScanner.Sort(@"MyDirectory\MyFile.pdf");

            uiInteraction.Received(1).Question("Choose category for file MyFile.pdf\no : Open file MyFile.pdf\n:");
        }
コード例 #25
0
        public void Finds_Classes_Registered_With_NewTestClass()
        {
            var script = @"tSQLt.NewTestClass @ClassName = 'class name'";

            var scanner = new FileScanner(_parser);
            var results = scanner.ScanCode(script, new ScanResults(), "path");

            Assert.True(results.FoundClasses.Any(p => p.Name == "class name"));
            Assert.True(results.FoundProperties.Any(p => p.SchemaName == "class name"));
        }
コード例 #26
0
        public static List <String> GetFileList(String path, Func <String, Boolean> filter, bool recursive = true)
        {
            var ret = new List <String>();

            if (!String.IsNullOrEmpty(path))
            {
                var fs = new FileScanner(ret, filter, recursive, null);
                WalkTree(path, fs);
            }
            return(ret);
        }
コード例 #27
0
        public void FindsSchema()
        {
            var scanner = new FileScanner(new TSql130Parser(false));


            var result =
                scanner.ScanCode("--select 100\r\nGO\r\ncreate      /*AAAAAAAA*/ schema [my_schema];", new ScanResults(), "path");

            Assert.AreEqual(1, result.FoundClasses.Count);
            Assert.AreEqual("my_schema", result.FoundClasses.First().Name);
        }
コード例 #28
0
        public void FindsTestProcedure()
        {
            var scanner = new FileScanner(new TSql130Parser(false));


            var result =
                scanner.ScanCode("--select 100\r\nGO\r\ncreate    procedure [test hello there] as select 1;", new ScanResults(), "path");

            Assert.AreEqual(1, result.FoundPotentialTests.Count);
            Assert.AreEqual("test hello there", result.FoundPotentialTests.First().Name.Object);
        }
コード例 #29
0
        public void Finds_Extended_Event_Procedure_With_Exec()
        {
            var script = @"EXEC sp_addextendedproperty
                            @name = N'tSQLt.TestClass'
                            , @value = 1
                            , @level0type = N'SCHEMA'
                            , @level0name = N'MyUnitSchema';";

            var scanner = new FileScanner(_parser);

            scanner.ScanCode(script, new ScanResults(), "path");
        }
コード例 #30
0
 protected List <FileInfo> GetExcelFiles()
 {
     FileScanner.ScanAllExcelFiles(new DirectoryInfo(clientConfig.ExcelOrderFolder));
     if (FileScanner.ScannedFiles.Any())
     {
         return(FileScanner.ScannedFiles);
     }
     else
     {
         return(new List <FileInfo>());
     }
 }
コード例 #31
0
        private void btnScan_Click(object sender, EventArgs e)
        {
            if (IsServiceRunning)
            {
                MessageBox.Show("已有后台服务在运行,请先停止服务!");
                return;
            }
            List <string> directorys = new List <string>();
            DialogResult  select     = MessageBox.Show("要执行全盘扫描吗?", "扫描确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (select == DialogResult.Yes)
            {
                List <DriveInfo> drives = Directory.GetLogicalDrives().Select(q => new DriveInfo(q)).ToList();
                foreach (var driveInfo in drives)
                {
                    if (driveInfo.IsReady && driveInfo.DriveType == DriveType.Fixed)
                    {
                        directorys.Add(driveInfo.Name);
                    }
                }
                if (directorys.Count == 0)
                {
                    Notice("无有效磁盘驱动器");
                    return;
                }
            }
            else if (select == DialogResult.No)
            {
                FolderBrowserDialog dialog = new FolderBrowserDialog();
                dialog.Description = "请选择目录";
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    string foldPath = dialog.SelectedPath;
                    directorys.Add(foldPath);
                    Notice("待扫描目录:" + foldPath);
                }
            }

            ThreadPool.QueueUserWorkItem((w) =>
            {
                UpdateUI(() =>
                {
                    Notice("等待初始化队列...");
                });
                _fileScanner = new ResumeFileScanner(directorys, ckAsync.Checked, Convert.ToInt32(numTheadCount.Value), FileEnqueueCallBack, FileHandleCallBack, ScanOverCallBack, HandleOverCallBack);
                UpdateUI(() =>
                {
                    Notice("队列创建就绪");
                    btnStart.Enabled = true;
                });
            });
        }
コード例 #32
0
        public void Should_open_file_when_answer_o_for_the_category()
        {
            var fileMover = Substitute.For<IFileMover>();
            var uiInteraction = Substitute.For<IUiInteraction>();

            uiInteraction.Question(Arg.Any<string>()).Returns("o", "");

            var fileScanner = new FileScanner(uiInteraction, fileMover, "directoryDestination");

            fileScanner.Sort(@"MyDirectory\MyFile.pdf");

            fileMover.Received(1).OpenPdf(@"MyDirectory\MyFile.pdf");
        }
コード例 #33
0
 public void TearDown()
 {
     _mockRepository            = null;
     _containerDataScanner      = null;
     _codecDataScanner          = null;
     _codecStreamDataScanner    = null;
     _dataReaderPool            = null;
     _progressReporter          = null;
     _createDataBlockBuilder    = null;
     _createSubProgressReporter = null;
     _inputFile   = null;
     _fileScanner = null;
 }
コード例 #34
0
        public void Should_move_to_directory_redirect_when_answer_the_category()
        {
            var fileMover = Substitute.For<IFileMover>();
            var uiInteraction = Substitute.For<IUiInteraction>();

            uiInteraction.Question(Arg.Any<string>()).Returns("MyCategory");

            var fileScanner = new FileScanner(uiInteraction, fileMover, "directoryDestination");

            fileScanner.Sort(@"MyDirectory\MyFile.pdf");

            fileMover.Received(1).Move(@"MyDirectory\MyFile.pdf", @"directoryDestination\MyCategory\MyFile.pdf");
        }
コード例 #35
0
        public void Should_did_not_move_file_when_answer_o_and_empty_for_the_category()
        {
            var fileMover = Substitute.For<IFileMover>();
            var uiInteraction = Substitute.For<IUiInteraction>();

            uiInteraction.Question(Arg.Any<string>()).Returns("o", "");

            var fileScanner = new FileScanner(uiInteraction, fileMover, "directoryDestination");

            fileScanner.Sort(@"MyDirectory\MyFile.pdf");

            fileMover.DidNotReceive().Move(Arg.Any<string>(), Arg.Any<string>());
        }
コード例 #36
0
ファイル: Form1.cs プロジェクト: CucumbersEye/diplom
        private void button1_Click(object sender, EventArgs e)
        {
            FcaMatrix matrix = new FcaMatrix();
            FileScanner fscan = new FileScanner();
            String[] processingFiles = Directory.GetFiles(txtSourceDir.Text);

            matrix = fscan.processFiles(processingFiles);

            FcaTree tree = new FcaTree();
            tree.closureOneByOne(matrix,tree);
            FcaObjectSet lattice = new FcaObjectSet();
            lattice.buildLattice(tree, matrix);
            fscan.RefactorHierarchy(lattice);
        }
コード例 #37
0
ファイル: Unpacker.cs プロジェクト: paveltimofeev/UPU
        public static async Task Unpack(UnpackerConfig config)
        {
            using (var initialUnpack = new InitialUnpack(config.InputUnityFile, config.WorkingDir, config.Logger))
            {
                await initialUnpack.StartAsync();
                var fileScanner = new FileScanner(config.WorkingDir, config.OutputDir, config.Logger);
                var scannedFiles = await fileScanner.StartAsync();

                using (var fileExtractor = new FileExtractor(config.WorkingDir, scannedFiles, config.Logger))
                {
                    await fileExtractor.StartAsync();
                }
            }
        }
コード例 #38
0
ファイル: PriceAnalysis.cs プロジェクト: carriercomm/ED-IBE
 /// <summary>
 /// event-worker for ExternalDataEvent-event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void LogfileScanner_LocationChanged(object sender, FileScanner.EDLogfileScanner.LocationChangedEventArgs e)
 {
     try
     {
         if((e.Changed & FileScanner.EDLogfileScanner.enLogEvents.System) > 0)
         {
             GUI.setFilterHasChanged(true);
             //GUI.RefreshData();
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Error while processing the LocationChanged-event", ex);
     }
 }
コード例 #39
0
ファイル: EDDNCommunicator.cs プロジェクト: Duke-Jones/ED-IBE
        /// <summary>
        /// event-worker for JournalEventRecieved-event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void JournalEventRecieved(object sender, FileScanner.EDJournalScanner.JournalEventArgs e)
        {
            try
            {
                switch (e.EventType)
                {
                    case FileScanner.EDJournalScanner.JournalEvent.FSDJump:
                    case FileScanner.EDJournalScanner.JournalEvent.Docked:
                    case FileScanner.EDJournalScanner.JournalEvent.Scan:
                        SendJournalData((JObject)e.Data);
                        break;
                }

            }
            catch (Exception ex)
            {
                CErr.processError(ex, "Error while processing the JournalEventRecieved-event");
            }
        }
コード例 #40
0
        /// <summary>
        /// event-worker for JournalEventRecieved-event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void JournalEventRecieved(object sender, FileScanner.EDJournalScanner.JournalEventArgs e)
        {
            try
            {
                if(e.EventType == FileScanner.EDJournalScanner.JournalEvent.FSDJump) 
                    TransmitVisit(e.Data.Value<String>("StarSystem"), (Double)e.Data["StarPos"][0], (Double)e.Data["StarPos"][1], (Double)e.Data["StarPos"][2], e.Data.Value<DateTime>("timestamp"));

            }
            catch (Exception ex)
            {
                CErr.processError(ex, "Error while processing the JournalEventRecieved-event");
            }
        }
コード例 #41
0
ファイル: Form1.cs プロジェクト: carriercomm/ED-IBE
        void LogfileScanner_LocationChanged(object sender, FileScanner.EDLogfileScanner.LocationChangedEventArgs e)
        {
            try
            {

                if((e.Changed & FileScanner.EDLogfileScanner.enLogEvents.Jump) > 0)
                {
                    setText(txtExtInfo,             "jump recognized...");
                    setText(txtRecievedSystem,      "");
                    setText(txtRecievedStation,     "");
                    setText(txtLocalDataCollected,  "");

                    setButton(cmdConfirm, false);
                    setButton(cmdGetMarketData, false);

                    Program.actualCondition.Location = e.Location;
                    setText(tbCurrentStationinfoFromLogs, Program.actualCondition.Location);
                }

                if((e.Changed & FileScanner.EDLogfileScanner.enLogEvents.System) >  0)
                {
                    // the location has changed -> the reference for all distances has changed
                    Program.PriceAnalysis.GUI.RefreshData();

                    Program.actualCondition.System   = e.System;
                    setText(tbCurrentSystemFromLogs,      Program.actualCondition.System);
                }

                if((e.Changed & FileScanner.EDLogfileScanner.enLogEvents.Location) > 0)
                {
                    Program.actualCondition.Location   = e.Location;
                    setText(tbCurrentStationinfoFromLogs,  Program.actualCondition.Location);
                }

            }
            catch (Exception ex)
            {
                throw new Exception("Error in m_LogfileScanner_LocationChanged", ex);
            }
        }
コード例 #42
0
        /// <summary>
        /// register the LogfileScanner in the CommandersLog for the DataEvent
        /// </summary>
        /// <param name="JournalScanner"></param>
        public void registerJournalScanner(FileScanner.EDJournalScanner JournalScanner)
        {
            try
            {
                if(m_JournalScanner == null)
                { 
                    m_JournalScanner = JournalScanner;
                    m_JournalScanner.JournalEventRecieved += JournalEventRecieved;
                }
                else 
                    throw new Exception("LogfileScanner already registered");

            }
            catch (Exception ex)
            {
                throw new Exception("Error while registering the LogfileScanner", ex);
            }
        }
コード例 #43
0
ファイル: PriceAnalysis.cs プロジェクト: Duke-Jones/ED-IBE
 /// <summary>
 /// event-worker for JournalEventRecieved-event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void JournalEventRecieved(object sender, FileScanner.EDJournalScanner.JournalEventArgs e)
 {
     try
     {
         switch (e.EventType)
         {
             case FileScanner.EDJournalScanner.JournalEvent.FSDJump:
                 GUI.RefreshColors();
                 GUI.setFilterHasChanged(true);
                 
                 break;
         }
     }
     catch (Exception ex)
     {
         CErr.processError(ex, "Error while processing the JournalEventRecieved-event");
     }
 }
コード例 #44
0
ファイル: CommandersLog.cs プロジェクト: carriercomm/ED-IBE
 /// <summary>
 /// event-worker for ExternalDataEvent-event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void LogfileScanner_LocationChanged(object sender, FileScanner.EDLogfileScanner.LocationChangedEventArgs e)
 {
     try
     {
         if((e.Changed & FileScanner.EDLogfileScanner.enLogEvents.System) > 0)
         {
             double? Distance = Program.Data.getDistanceBetween(e.System, e.OldSystem);
             SaveEvent(DateTime.UtcNow, e.System, "", "", "", 0, 0, 0, "Jumped To", "", Distance);
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Error while processing the LocationChanged-event", ex);
     }
 }
コード例 #45
0
ファイル: Form1.cs プロジェクト: Duke-Jones/ED-IBE
        void JournalEventRecieved(object sender, FileScanner.EDJournalScanner.JournalEventArgs e)
        {
            try
            {
                switch (e.EventType)
                {
                    case FileScanner.EDJournalScanner.JournalEvent.Location:
                        
                        if(Program.actualCondition.System.EqualsNullOrEmpty(e.Data.Value<String>("StarSystem")) && 
                           Program.actualCondition.Station.EqualsNullOrEmpty(e.Data.Value<String>("StationName")))
                            AddComboboxLine(txtEventInfo,             "Current location confirmed");
                        else
                            AddComboboxLine(txtEventInfo,             "Got new location");


                        Program.actualCondition.System          = e.Data.Value<String>("StarSystem");
                        Program.actualCondition.Coordinates     = new Point3Dbl((Double)e.Data["StarPos"][0], (Double)e.Data["StarPos"][1], (Double)e.Data["StarPos"][2]);


                        if(e.Data.Value<Boolean>("Docked"))
                        {
                            Program.actualCondition.Station    = e.Data.Value<String>("StationName");

                            // from now it is allowed to send data to eddn immediately again
                            Program.EDDNComm.SendingReset();
                        }
                        else
                        {
                            Program.actualCondition.Station    = "";
                        }

                        Program.actualCondition.Body        = String.IsNullOrWhiteSpace(e.Data.Value<String>("Body")) ? "" : e.Data.Value<String>("Body");
                        Program.actualCondition.BodyType    = String.IsNullOrWhiteSpace(e.Data.Value<String>("BodyType")) ? "" : e.Data.Value<String>("BodyType");

                        ShowLocationData();
                        ShowStatus();
                        
                        break;

                    case FileScanner.EDJournalScanner.JournalEvent.FSDJump:
                        AddComboboxLine(txtEventInfo,             "FSD jump recognized");

                        Program.actualCondition.Station = "";

                        // from now it is allowed to send data to eddn immediately again
                        Program.EDDNComm.SendingReset();

                        Program.actualCondition.System      = e.Data.Value<String>("StarSystem");
                        Program.actualCondition.Coordinates = new Point3Dbl((Double)e.Data["StarPos"][0], (Double)e.Data["StarPos"][1], (Double)e.Data["StarPos"][2]);

                        Program.actualCondition.Body        = String.IsNullOrWhiteSpace(e.Data.Value<String>("Body")) ? "" : e.Data.Value<String>("Body");
                        Program.actualCondition.BodyType    = String.IsNullOrWhiteSpace(e.Data.Value<String>("BodyType")) ? "" : e.Data.Value<String>("BodyType");

                        ShowLocationData();
                        ShowStatus();
                        
                        break;

                    case FileScanner.EDJournalScanner.JournalEvent.Docked:
                        if((!Program.actualCondition.System.EqualsNullOrEmpty(e.Data.Value<String>("StarSystem"))) || 
                           (!Program.actualCondition.Station.EqualsNullOrEmpty(e.Data.Value<String>("StationName"))))
                        {
                            AddComboboxLine(txtEventInfo,       "Docked");

                            Program.actualCondition.System      = e.Data.Value<String>("StarSystem");
                            Program.actualCondition.Station    = e.Data.Value<String>("StationName");

                            ShowLocationData();
                            ShowStatus();
                        }

                        break;

                    case FileScanner.EDJournalScanner.JournalEvent.Undocked:

                        AddComboboxLine(txtEventInfo,       "Undocked");

                        Program.actualCondition.Station    = "";

                        ShowLocationData();
                        ShowStatus();
                        
                        break;

                    case FileScanner.EDJournalScanner.JournalEvent.SupercruiseEntry:

                        AddComboboxLine(txtEventInfo,       "Supercruise");

                        Program.actualCondition.Body        = String.IsNullOrWhiteSpace(e.Data.Value<String>("Body")) ? "" : e.Data.Value<String>("Body");
                        Program.actualCondition.BodyType    = String.IsNullOrWhiteSpace(e.Data.Value<String>("BodyType")) ? "" : e.Data.Value<String>("BodyType");

                        ShowLocationData();
                        ShowStatus();
                        
                        break;

                    case FileScanner.EDJournalScanner.JournalEvent.SupercruiseExit:

                        AddComboboxLine(txtEventInfo,       "Normal flight");

                        Program.actualCondition.Body        = String.IsNullOrWhiteSpace(e.Data.Value<String>("Body")) ? "" : e.Data.Value<String>("Body");
                        Program.actualCondition.BodyType    = String.IsNullOrWhiteSpace(e.Data.Value<String>("BodyType")) ? "" : e.Data.Value<String>("BodyType");

                        ShowLocationData();
                        ShowStatus();
                        
                        break;
                }



            }
            catch (Exception ex)
            {
                CErr.processError(ex, "Error in m_LogfileScanner_LocationChanged");
            }
        }
コード例 #46
0
ファイル: Condition.cs プロジェクト: Duke-Jones/ED-IBE
        /// <summary>
        /// event-worker for BasedataEventRecieved-event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void BasedataEventRecieved(object sender, FileScanner.EDJournalScanner.BasedataEventArgs e)
        {
            try
            {
                switch (e.EventType)
                {
                    case FileScanner.EDJournalScanner.JournalEvent.Basedata:
                        Program.Data.checkPotentiallyNewSystemOrStation(e.System, e.Station, e.Coordinates);
                        break;
                }

            }
            catch (Exception ex)
            {
                CErr.processError(ex, "Error while processing the JournalEventRecieved-event");
            }
        }
コード例 #47
0
ファイル: CommandersLog.cs プロジェクト: Duke-Jones/ED-IBE
        /// <summary>
        /// event-worker for JournalEventRecieved-event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void JournalEventRecieved(object sender, FileScanner.EDJournalScanner.JournalEventArgs e)
        {
            try
            {
                switch (e.EventType)
                {
                    case FileScanner.EDJournalScanner.JournalEvent.Docked:

                        if((!Program.actualCondition.System.EqualsNullOrEmpty(e.Data.Value<String>("StarSystem"))) || 
                           (!Program.actualCondition.Station.EqualsNullOrEmpty(e.Data.Value<String>("StationName"))))
                        {
                            if(Program.DBCon.getIniValue<Boolean>(IBESettingsView.DB_GROUPNAME, "AutoAdd_Visited", true.ToString(), false))
                                SaveEvent(DateTime.UtcNow, e.Data.Value<String>("StarSystem"), e.Data.Value<String>("StationName"), "", "", 0, 0, Program.CompanionIO.SGetCreditsTotal(), "Visited", "");
                        }
                        else if(e.History.Find(x => ((x.EventType == FileScanner.EDJournalScanner.JournalEvent.Resurrect) && (e.History.IndexOf(x) < 2))) != null)
                        {
                            var resurrectEvent = e.History.Find(x => ((x.EventType == FileScanner.EDJournalScanner.JournalEvent.Resurrect) && (e.History.IndexOf(x) < 2)));

                            SaveEvent(e.Data.Value<DateTime>("timestamp"), 
                                      e.Data.Value<String>("StarSystem"), 
                                      e.Data.Value<String>("StationName"), 
                                      "", 
                                      "", 
                                      0, 
                                      0, 
                                      Program.CompanionIO.SGetCreditsTotal(), 
                                      "Resurrect", 
                                      String.Format("option: {0}\ncost: {1} cr.\nbankrupt = {2}", 
                                                    resurrectEvent.Data.Value<String>("Option"), 
                                                    resurrectEvent.Data.Value<Int32>("Cost"), 
                                                    resurrectEvent.Data.Value<Boolean>("Bankrupt") ? "yes" : "no"));

                        }
                        
                        break;
                    case FileScanner.EDJournalScanner.JournalEvent.FSDJump:
                        if(Program.DBCon.getIniValue<Boolean>(IBESettingsView.DB_GROUPNAME, "AutoAdd_JumpedTo", true.ToString(), false))
                        {
                            SaveEvent(e.Data.Value<DateTime>("timestamp"), 
                                      e.Data.Value<String>("StarSystem"),
                                      "", 
                                      "", 
                                      "", 
                                      0, 
                                      0, 
                                      Program.CompanionIO.SGetCreditsTotal(), 
                                      "Jumped To", 
                                      "", 
                                      e.Data.Value<Double>("JumpDist"));
                        }
                        break;

                    case FileScanner.EDJournalScanner.JournalEvent.Died:

                        String killInfo= "";
                        IBECompanion.CompanionConverter cmpConverter = new IBECompanion.CompanionConverter();  

                        if(e.Data.Value<String>("KillerName") != null)
                        {
                            
                            killInfo =  String.Format("killed by \t: {0}\n" +
                                                      "ship \t: {1}\n" +
                                                      "rank \t: {2}", 
                                                      (e.Data.Value<String>("KillerName_Localised") != null) ? e.Data.Value<String>("KillerName_Localised") : e.Data.Value<String>("KillerName"), 
                                                      cmpConverter.GetShipNameFromSymbol(Program.Data.BaseData.tbshipyardbase, e.Data.Value<String>("KillerShip")), 
                                                      e.Data.Value<String>("KillerRank")); 


                        }
                        else if(e.Data.Value<Object>("Killers") != null)
                        {
                            killInfo = "killed by wing:\n";
                            Int32 counter = 1;
                            foreach (JToken killerData in e.Data.SelectTokens("Killers.[*]"))
                            {

                                killInfo +=  String.Format("{4}{3}. \t{0}, \t{1}, \t{2}", 
                                                           killerData.Value<String>("Name"), 
                                                           cmpConverter.GetShipNameFromSymbol(Program.Data.BaseData.tbshipyardbase, killerData.Value<String>("Ship")), 
                                                           killerData.Value<String>("Rank"), 
                                                           counter, 
                                                           counter > 1 ? "\n":""); 
                                counter++;
                            }
                        }

                        SaveEvent(e.Data.Value<DateTime>("timestamp"), 
                                  Program.actualCondition.System, 
                                  "", 
                                  "", 
                                  "", 
                                  0, 
                                  0, 
                                  Program.CompanionIO.SGetCreditsTotal(), 
                                  "Died", 
                                  killInfo);
                        break;

                    case FileScanner.EDJournalScanner.JournalEvent.Resurrect:
                        break;

                    case FileScanner.EDJournalScanner.JournalEvent.Touchdown:
                        if(Program.DBCon.getIniValue<Boolean>(IBESettingsView.DB_GROUPNAME, "AutoAdd_TouchDown", true.ToString(), false))
                        {
                            SaveEvent(e.Data.Value<DateTime>("timestamp"), 
                                      Program.actualCondition.System,
                                      "", 
                                      "", 
                                      "", 
                                      0, 
                                      0, 
                                      Program.CompanionIO.SGetCreditsTotal(), 
                                      "Touchdown", 
                                      String.Format("landed on {0}{1}\n" +
                                                    "long: {3}\n" +
                                                    "lat : {2}",
                                                    Program.actualCondition.Body, 
                                                    String.IsNullOrWhiteSpace(Program.actualCondition.BodyType) ? "" : " (" + Program.actualCondition.BodyType + ")",
                                                    e.Data.Value<Double>("Latitude"), 
                                                    e.Data.Value<Double>("Longitude")));
                        }
                        break;

                    case FileScanner.EDJournalScanner.JournalEvent.Liftoff:
                        if(Program.DBCon.getIniValue<Boolean>(IBESettingsView.DB_GROUPNAME, "AutoAdd_Liftoff", true.ToString(), false))
                        {
                            SaveEvent(e.Data.Value<DateTime>("timestamp"), 
                                      Program.actualCondition.System,
                                      "", 
                                      "", 
                                      "", 
                                      0, 
                                      0, 
                                      Program.CompanionIO.SGetCreditsTotal(), 
                                      "Liftoff", 
                                      String.Format("liftoff from {0}{1}\n" +
                                                    "long: {3}\n" +
                                                    "lat : {2}",
                                                    Program.actualCondition.Body, 
                                                    String.IsNullOrWhiteSpace(Program.actualCondition.BodyType) ? "" : " (" + Program.actualCondition.BodyType + ")",
                                                    e.Data.Value<Double>("Latitude"), 
                                                    e.Data.Value<Double>("Longitude")));
                        }
                        break;

                    case FileScanner.EDJournalScanner.JournalEvent.Scan:
                        if(Program.DBCon.getIniValue<Boolean>(IBESettingsView.DB_GROUPNAME, "AutoAdd_Scan", true.ToString(), false))
                        {
                            TextHelper txtHelp = new TextHelper();

                            Font usedFont = m_GUI.dgvCommandersLog.Columns["notes"].DefaultCellStyle.Font != null ? m_GUI.dgvCommandersLog.Columns["notes"].DefaultCellStyle.Font : m_GUI.dgvCommandersLog.DefaultCellStyle.Font ; 
                            System.Text.StringBuilder data  = new System.Text.StringBuilder();
                            System.Text.StringBuilder rings = new System.Text.StringBuilder();
                         
                            Int32 fullLength = 170;

                            if(e.Data.Value<Object>("StarType") != null)
                            {
                                data.AppendLine(String.Format("{0} :   {1}   (Star)", txtHelp.FixedLength("Name", usedFont, fullLength),  e.Data.Value<String>("BodyName")));
                                data.AppendLine(String.Format("{0} :   {1}", txtHelp.FixedLength("Type", usedFont, fullLength),  e.Data.Value<String>("StarType")));
                                data.AppendLine(String.Format("{0} :   {1:N1} ls", txtHelp.FixedLength("Distance", usedFont, fullLength),  e.Data.Value<Double>("DistanceFromArrivalLS")));

                                if(!String.IsNullOrWhiteSpace(e.Data.Value<String>("Radius")))
                                    data.AppendLine(String.Format("{0} :   {1:N1} km", txtHelp.FixedLength("Radius", usedFont, fullLength),  e.Data.Value<Double>("Radius")));
                                if(!String.IsNullOrWhiteSpace(e.Data.Value<String>("StellarMass")))
                                    data.AppendLine(String.Format("{0} :   {1:N1} stellar masses", txtHelp.FixedLength("Mass", usedFont, fullLength),  e.Data.Value<Double>("StellarMass")));
                                if(!String.IsNullOrWhiteSpace(e.Data.Value<String>("Age_MY")))
                                    data.AppendLine(String.Format("{0} :   {1:N1} my", txtHelp.FixedLength("Age", usedFont, fullLength),  e.Data.Value<Double>("Age_MY")));
                                if(!String.IsNullOrWhiteSpace(e.Data.Value<String>("SurfaceTemperature")))
                                    data.AppendLine(String.Format("{0} :   {1:N1}°K  ( {2:N1}°C )", txtHelp.FixedLength("Temp.", usedFont, fullLength),  e.Data.Value<Double>("SurfaceTemperature"), e.Data.Value<Double>("SurfaceTemperature") - 273.15));
                            }
                            else
                            {
                                System.Text.StringBuilder materials = new System.Text.StringBuilder();

                                data.AppendLine(String.Format("{0} :   {1}   (Planet/Moon)", txtHelp.FixedLength("Name", usedFont, fullLength),  e.Data.Value<String>("BodyName")));
                                data.AppendLine(String.Format("{0} :   {1:N1} ls", txtHelp.FixedLength("Distance", usedFont, fullLength),  e.Data.Value<Double>("DistanceFromArrivalLS")));

                                if(!String.IsNullOrWhiteSpace(e.Data.Value<String>("TerraformState")))
                                    data.AppendLine(String.Format("{0} :   {1}", txtHelp.FixedLength("Terraform", usedFont, fullLength),  e.Data.Value<String>("TerraformState")));
                                if(!String.IsNullOrWhiteSpace(e.Data.Value<String>("PlanetClass")))
                                    data.AppendLine(String.Format("{0} :   {1}", txtHelp.FixedLength("Class", usedFont, fullLength),  e.Data.Value<String>("PlanetClass")));
                                if(!String.IsNullOrWhiteSpace(e.Data.Value<String>("Atmosphere")))
                                    data.AppendLine(String.Format("{0} :   {1}", txtHelp.FixedLength("Atmosphere", usedFont, fullLength),  e.Data.Value<String>("Atmosphere")));
                                if(!String.IsNullOrWhiteSpace(e.Data.Value<String>("Volcanism")))
                                    data.AppendLine(String.Format("{0} :   {1}", txtHelp.FixedLength("Volcanism", usedFont, fullLength),  e.Data.Value<String>("Volcanism")));
                                if(!String.IsNullOrWhiteSpace(e.Data.Value<String>("SurfaceGravity")))
                                    data.AppendLine(String.Format("{0} :   {1:N2} g", txtHelp.FixedLength("Gravity", usedFont, fullLength),  e.Data.Value<Double>("SurfaceGravity")/10.0));
                                if(!String.IsNullOrWhiteSpace(e.Data.Value<String>("SurfaceTemperature")))
                                    data.AppendLine(String.Format("{0} :   {1:N1}°K  ( {2:N1}°C )", txtHelp.FixedLength("Temp.", usedFont, fullLength),  e.Data.Value<Double>("SurfaceTemperature"), e.Data.Value<Double>("SurfaceTemperature") - 273.15));
                                if(!String.IsNullOrWhiteSpace(e.Data.Value<String>("SurfacePressure")))
                                    data.AppendLine(String.Format("{0} :   {1:N1} atm", txtHelp.FixedLength("Pressure", usedFont, fullLength),  e.Data.Value<Double>("SurfacePressure") / 100000.0));
                                if((!String.IsNullOrWhiteSpace(e.Data.Value<String>("Landable"))) && e.Data.Value<Boolean>("Landable"))
                                    data.AppendLine(String.Format("{0} :   {1}", txtHelp.FixedLength("Landable", usedFont, fullLength),  e.Data.Value<Boolean>("Landable") ? "yes" : "no"));

                                if (e.Data.Value<Object>("Materials") != null)
                                {
                                    TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;

                                    foreach (JProperty  material in e.Data.SelectToken("Materials"))
                                    {
                                        if(materials.Length == 0)
                                            materials.AppendFormat(String.Format("\n{0} :   ", txtHelp.FixedLength("Materials", usedFont, fullLength)));
                                        else
                                            materials.AppendFormat(", ");
                                        materials.AppendFormat("{0} : {1:N1}%", textInfo.ToTitleCase(material.Name), (Double)material.Value);
                                    }
                                    data.AppendLine(materials.ToString());
                                }
                            }

                            if(e.Data.Value<Object>("Rings") != null)
                            {
                                foreach (JObject ring in e.Data.SelectTokens("Rings.[*]"))
                                {
                                    String classname = ring.Value<String>("RingClass").Replace("eRingClass_","")
                                                                                      .Replace("Rich"," Rich")
                                                                                      .Replace("Metal","Metall");

                                    if(rings.Length == 0)
                                        rings.AppendLine(String.Format("\n{0} • {1} (Type: {2})", txtHelp.FixedLength("Belts", usedFont, 100), ring.Value<String>("Name"), classname));
                                    else
                                        rings.AppendLine(String.Format("{0} • {1} (Type: {2})", txtHelp.FixedLength("", usedFont, 100), ring.Value<String>("Name"), classname));
                                }

                                data.Append(rings);
                            }

                            SaveEvent(e.Data.Value<DateTime>("timestamp"), 
                                      Program.actualCondition.System,
                                      "", 
                                      "", 
                                      "", 
                                      0, 
                                      0, 
                                      Program.CompanionIO.SGetCreditsTotal(), 
                                      "Scan", 
                                      data.ToString());
                        }
                        break;


                }

            }
            catch (Exception ex)
            {
                CErr.processError(ex, "Error while processing the JournalEventRecieved-event");
            }
        }
コード例 #48
0
ファイル: CommandersLog.cs プロジェクト: carriercomm/ED-IBE
        //private void setLocationInfo(string Systemname, string Locationname, Boolean ForceChangedLocation)
        //{
        //    //bool Jumped_To      = false;
        //    bool systemFirstTimeVisited      = false;
        //    bool newLocation    = false;
        //    bool InitialRun     = false;
        //    if(!String.IsNullOrEmpty(Systemname))
        //    {
        //        // system info found
        //        if(!Program.actualCondition.System.Equals(Systemname, StringComparison.InvariantCultureIgnoreCase))
        //        {
        //            // it's a new system
        //            Debug.Print("tbCurrentSystemFromLogs=" + tbCurrentSystemFromLogs);
        //            Program.actualCondition.System = Systemname;
        //            systemFirstTimeVisited = true;
        //        }
        //        // system info found
        //        if(!_LoggedSystem.Equals(Systemname, StringComparison.InvariantCultureIgnoreCase))
        //        {
        //            // system is not logged yet
        //            // update Cmdr's Log ?
        //            if(_LoggedSystem != ID_NOT_SET)
        //            {
        //                // it's not the first run, create a event if wanted
        //                if (Program.DBCon.getIniValue<Boolean>(MTSettings.tabSettings.DB_GROUPNAME, "AutoAdd_JumpedTo", true.ToString(), false, true))
        //                {
        //                    // create event is enabled
        //                    CommandersLog_CreateJumpedToEvent(Systemname);
        //                }
        //            }
        //            else
        //            {
        //                InitialRun = true;
        //            }
        //            //Jumped_To = true;
        //            _LoggedSystem = Systemname;
        //        }
        //    }
        //    if(!String.IsNullOrEmpty(Locationname))
        //    {
        //        // system info found
        //        if(!Program.actualCondition.Location.Equals(Locationname, StringComparison.InvariantCultureIgnoreCase))
        //        {
        //            // it's a new location
        //            Program.actualCondition.Location = Locationname;
        //            newLocation = true;
        //            throw new NotImplementedException();
        //            List<EDStation> SystemStations = null; // _Milkyway.getStations(Systemname);
        //            if((SystemStations != null) && (SystemStations.Find(x => x.Name.Equals(Locationname, StringComparison.InvariantCultureIgnoreCase)) != null))
        //                if (Program.DBCon.getIniValue<Boolean>(MTSettings.tabSettings.DB_GROUPNAME, "AutoAdd_Visited", true.ToString(), false, true))
        //                {
        //                    // create event is enabled
        //                    CommandersLog_StationVisitedEvent(Systemname, Locationname);
        //                }
        //            _LoggedLocation = Locationname;
        //            _LoggedMarketData = "";
        //            _LoggedVisited = "";
        //        }
        //    }else if(systemFirstTimeVisited || ForceChangedLocation)
        //        Program.actualCondition.Location = Condition.STR_Scanning;
        //    if((systemFirstTimeVisited || newLocation) && (!InitialRun))
        //    {
        //        loadSystemData(_LoggedSystem);
        //        loadStationData(_LoggedSystem, _LoggedLocation);
        //        if(Program.DBCon.getIniValue<Boolean>(MTSettings.tabSettings.DB_GROUPNAME, "AutoActivateSystemTab", true.ToString(), false, true))
        //            tabCtrlMain.SelectedTab = tabCtrlMain.TabPages["tabSystemData"];
        //    }
        //    tbCurrentSystemFromLogs.Text        = Program.actualCondition.System;
        //    tbCurrentStationinfoFromLogs.Text   = Program.actualCondition.Location;
        //}
        //private void CommandersLog_StationVisitedEvent(string Systemname, string StationName)
        //{
        //    if (InvokeRequired)
        //    {
        //        Invoke(new del_EventLocationInfo(CommandersLog_StationVisitedEvent), Systemname, StationName);
        //    }
        //    else
        //    {
        //        if (!_LoggedVisited.Equals(Systemname + "|" + StationName, StringComparison.InvariantCultureIgnoreCase))
        //        {
        //            bool noLogging = _LoggedVisited.Equals(ID_NOT_SET);
        //            _LoggedVisited = Systemname + "|" + StationName;
        //            if (Program.DBCon.getIniValue<Boolean>(MTSettings.tabSettings.DB_GROUPNAME, "AutoAdd_Visited", true.ToString(), false, true) && !noLogging)
        //            {
        //                Program.CommandersLog.SaveEvent(DateTime.UtcNow, Systemname, StationName, "", "", 0, 0, 0, "Visited", "");
        //            }
        //        }
        //    }
        //}
        //private void CommandersLog_MarketDataCollectedEvent(string Systemname, string StationName)
        //{
        //    if (InvokeRequired)
        //    {
        //        Invoke(new del_EventLocationInfo(CommandersLog_MarketDataCollectedEvent), Systemname, StationName);
        //    }
        //    else
        //    {
        //        try
        //        {
        //            if (!_LoggedMarketData.Equals(Systemname + "|" + StationName, StringComparison.InvariantCultureIgnoreCase))
        //            {
        //                _LoggedMarketData = Systemname + "|" + StationName;
        //                if (Program.DBCon.getIniValue<Boolean>(MTSettings.tabSettings.DB_GROUPNAME, "AutoAdd_Marketdata", true.ToString(), false, true))
        //                {
        //                    if (Program.DBCon.getIniValue<Boolean>(MTSettings.tabSettings.DB_GROUPNAME, "AutoAdd_ReplaceVisited", true.ToString(), false, true))
        //                    {
        //                        //object logEvent = Program.CommandersLog.LogEvents.SingleOrDefault(x => x.EventID == _CmdrsLog_LastAutoEventID);
        //                        //if (logEvent != null &&
        //                        //   logEvent.System.Equals(Systemname, StringComparison.InvariantCultureIgnoreCase) &&
        //                        //   logEvent.Location.Equals(StationName, StringComparison.InvariantCultureIgnoreCase) &&
        //                        //   logEvent.EventType.Equals("Visited", StringComparison.InvariantCultureIgnoreCase))
        //                        //{
        //                        //    logEvent.EventType = "Market m_BaseData Collected";
        //                        //    Program.CommandersLog.UpdateCommandersLogListView();
        //                        //}
        //                        //else
        //                        //{
        //                        //    _CmdrsLog_LastAutoEventID = Program.CommandersLog.SaveEvent("Market m_BaseData Collected", StationName, Systemname, "", "", 0, "", DateTime.UtcNow);
        //                        //    setActiveItem(_CmdrsLog_LastAutoEventID);
        //                        //}
        //                    }
        //                    else
        //                    {
        //                        Program.CommandersLog.SaveEvent(DateTime.Now, Systemname, StationName, "", "", 0, 0, 0, "Market Data Collected", "");
        //                    }
        //                }
        //            }
        //        }
        //        catch (Exception ex)
        //        {
        //            throw ex;
        //        }
        //    }
        //}
        /// <summary>
        /// register the LogfileScanner in the CommandersLog for the DataEvent
        /// </summary>
        /// <param name="LogfileScanner"></param>
        public void registerLogFileScanner(FileScanner.EDLogfileScanner LogfileScanner)
        {
            try
            {
                if(m_LogfileScanner == null)
                {
                    m_LogfileScanner = LogfileScanner;
                    m_LogfileScanner.LocationChanged += LogfileScanner_LocationChanged;
                }
                else
                    throw new Exception("LogfileScanner already registered");

            }
            catch (Exception ex)
            {
                throw new Exception("Error while registering the LogfileScanner", ex);
            }
        }
コード例 #49
0
ファイル: Condition.cs プロジェクト: Duke-Jones/ED-IBE
        /// <summary>
        /// event-worker for JournalEventRecieved-event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void JournalEventRecieved(object sender, FileScanner.EDJournalScanner.JournalEventArgs e)
        {
            try
            {
                switch (e.EventType)
                {
                    case FileScanner.EDJournalScanner.JournalEvent.Fileheader:
                        JournalHeaderObject = (JObject)e.Data;
                        break;
                }

            }
            catch (Exception ex)
            {
                CErr.processError(ex, "Error while processing the JournalEventRecieved-event");
            }
        }