public void GetFileInfoTest() { // Arrange Pathes.Clear(); Pathes.Enqueue(_path1); Pathes.Enqueue(_path2); _ = Mock.Get(_readInfo) .Setup(x => x.GetFileInfo(It.IsAny <Queue <string> >(), It.IsAny <Queue <InfoFile> >())) .Callback(() => { Pathes.Dequeue(); InfoFiles.Enqueue(_infoFile1); InfoFiles.Enqueue(_infoFile2); }); // Act _readInfo.GetFileInfo(Pathes, InfoFiles); // Assert Assert.IsTrue(Pathes.Count == 1); Assert.IsTrue(Pathes.Contains(_path2)); Assert.IsTrue(InfoFiles.Count() == 2); Assert.IsTrue(InfoFiles.Contains(_infoFile2)); }
public void UpdateTree(ref Twinsanity.Paths PATHs, uint Index) { Pathes.BeginUpdate(); for (int i = 0; i <= PATHs._Item.Length - 1; i++) { Pathes.Nodes.Add("ID: " + PATHs._Item[i].ID.ToString()); } Pathes.EndUpdate(); IISIndex = (int)Index; }
private void GetPathandExtension(DirectoryInfo dir) { FileInfo[] files = dir.GetFiles(); foreach (FileInfo item in files) { Pathes.Add(item.FullName); Extensions.Add(item.Extension); CreationTime.Add(item.CreationTime); } }
static void Main(string[] args) { object mutex = new object(); Console.OutputEncoding = Encoding.UTF8; System.Windows.Forms.MessageBox.Show("Укажите путь к папке!"); // Путь к папке CurentFolderPath = GetCurentFolder(); if (!CheckPath(CurentFolderPath)) { return; } Console.WriteLine("Идёт обработка данных... шас всё будет..."); Pathes.Enqueue(CurentFolderPath); new Thread(() => GetPathes(Pathes)).Start(); while (!InfoFiles.Any()) { new Thread(() => GetFileInfo(Pathes)).Start(); while (InfoFiles.Any()) { WriteFileInfo(InfoFiles.Dequeue()); } bool acquiredLock = false; try { Monitor.Enter(locker, ref acquiredLock); if (!Pathes.Any()) { break; } } finally { if (acquiredLock) { Monitor.Exit(locker); } } } Console.ReadKey(); }
private void ChooseData() { FolderBrowserDialog folderDialog = new FolderBrowserDialog(); folderDialog.Description = "Виберіть каталог метеорологічних даних регіону"; folderDialog.SelectedPath = @"киев+\"; if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string path = folderDialog.SelectedPath; List <string> files = Directory.GetFiles(path, "*.xlsx").ToList(); for (int i = 0; i < files.Count; i++) { files[i] = files[i].Replace(Directory.GetCurrentDirectory(), ".").Replace(".xlsx", ""); } _sunFile = files.Last(x => x.Contains("soldata")); files.Remove(_sunFile); files.Sort(); _weatherFiles = files; ConvertProgressBarWindow progressBarWindow = new ConvertProgressBarWindow(_weatherFiles, _sunFile); progressBarWindow.Show(); Pathes pathes = new Pathes { SunFile = _sunFile, WeatherFiles = _weatherFiles }; BinaryController.WriteDataToBinary(_fileSource, new List <Pathes> { pathes }); MeteorogicalAnalysisView.TimePeriodChanged -= Calculate; //InitData(); // Task 1 _weatherController = new WeatherController(_weatherFiles); //_weatherController.CorrectWeather(); _sunConditionController = new SunConditionController(System.IO.Path.GetFullPath(_sunFile)); //_sunConditionController.CorrectData(_weatherController.Year); MeteorogicalAnalysisView.Init(_weatherController, _sunConditionController); Calculate(); MeteorogicalAnalysisView.TimePeriodChanged += Calculate; } else { Close(); } }
public void GetPathesTest() { // Arrange Pathes.Clear(); _ = Mock.Get(_readInfo) .Setup(x => x.GetPathes(It.IsAny <string>(), It.IsAny <Queue <string> >())) .Callback(() => { Pathes.Enqueue(_path1); Pathes.Enqueue(_path2); }); // Act _readInfo.GetPathes(_path, Pathes); // Assert Assert.IsTrue(Pathes.Count == 2); Assert.IsTrue(Pathes.Contains(_path1)); Assert.IsTrue(Pathes.ElementAt(1).Equals(_path2)); }
private void StartActions() { MainTabControl.IsEnabled = false; var sources = BinaryController.ReadDataFromBinary <Pathes>(_fileSource); if (sources.Count >= 1) { Pathes pathes = sources[0]; _weatherFiles = pathes.WeatherFiles; _sunFile = pathes.SunFile; } if (_weatherFiles == null) { ChooseData(); } else { InitData(); } MainTabControl.IsEnabled = true; }
void ScanButtAction() { // Change TextBoxStatus TextBoxStatus = "Scanning Started"; //use FolderBrowserDialog instead of FileDialog and get the path from the OK result. FolderBrowserDialog browser = new FolderBrowserDialog(); string[] longFilesNames; string sizeOfFiles; if (browser.ShowDialog() == DialogResult.OK) { StaticProp.ScanningFolderPath = browser.SelectedPath; // prints path TextBoxScanFolder = StaticProp.ScanningFolderPath; } if (StaticProp.ScanningFolderPath != "empty") { Pathes pathing = new Pathes(StaticProp.ScanningFolderPath); String searchFolder = pathing.InitialFolderPath; var filters = new String[] { "jpg", "jpeg", "png", "gif", "tiff", "bmp", "svg", "avi", "mpg", "mpeg", "m2v", "mpg", "mp2", "mpeg", "mpe", "mpv", "mp4", "m4p", "m4v", "amv", "rmvb", "rm", "yuv", "wmv", "mov", "qt", "mng", "gifv", "gif", "ogv", "ogg", "vob", "flv", "mkv" }; MethodsFromStartButton methods = new MethodsFromStartButton(); filesNames = methods.GetShortFilesFrom(searchFolder, filters, false); longFilesNames = methods.GetLongFilesFrom(searchFolder, filters, false); sizeOfFiles = methods.GetSizeOftheFiles(longFilesNames); TextBoxFotoCounter = TextBoxFotoCounterMethod <string>(filesNames); //ProgressBarStatusMax = TextBoxFotoCounterMethod<int>(filesNames); TextGenShowMethod(string.Join("\r\n", filesNames)); BottomTextBl_Text = "Total Number of Files : " + TextBoxFotoCounter + " Total memory weight : " + sizeOfFiles + " Mb."; } TextBoxStatus = "Scanning Finished"; }
private SettingsPathes GetSettingsPathesByName(string versionName) { //BMTools.BmDebug.Debug.InfoAsync("versionName=" + versionName); return(Pathes.First(p => p.Name == versionName)); }
void StartButtonMethod() { // disable button exit during run of the process IsEnabledExitButton = false; VisibilityStopButton = Visibility.Visible; // create dictionary to put all pairs what to Move where to Move and serialize it. var MovePicDictionary = new Dictionary <string, string>(); lock (block) { // if delete files after copy is true if (StaticProp.PropCheckBoxDelete) { #region Check Box Delete = true if (StaticProp.ScanningFolderPath != "empty" && StaticProp.CreateFolderPath != "empty") { // Change TextBoxStatus TextBoxStatus = "Process Started"; // Progress bar visible ProgressBarStatusVisible = Visibility.Visible; Pathes pathing = new Pathes(StaticProp.ScanningFolderPath); String searchFolder = pathing.InitialFolderPath; var filters = new String[] { "jpg", "jpeg", "png", "gif", "tiff", "bmp", "svg" }; MethodsFromStartButton methods = new MethodsFromStartButton(); filesNames = methods.GetLongFilesFrom(searchFolder, filters, false); var filtersVideo = new String[] { "mp4", "avi", "mpg", "mpeg", "m2v", "mp2", "mpe", "mpv", "m4p", "m4v", "amv", "rmvb", "rm", "yuv", "wmv", "mov", "qt", "mng", "gifv", "ogv", "ogg", "vob", "flv", "mkv" }; filesNamesVideo = methods.GetLongFilesFrom(searchFolder, filtersVideo, false); // ProgressBarStatusMax will be only pictures ProgressBarStatusMax = filesNames.Length; // i work with video files separately // make filter for video files if (StaticProp.CheckBoxVideoSeparateFolder) { // ProgressBarStatusMax will be pictures + Video ProgressBarStatusMax = filesNames.Length + filesNamesVideo.Length; MethodCopyVideoFiles(filesNamesVideo); } foreach (string item in filesNames) { ProgressBarStatusValue++; try { using (ExifReader reader = new ExifReader(item)) { // if exif data exist (!=null) if (reader != null) { // Extract the tag data using the ExifTags enumeration DateTime datePictureTaken; if (reader.GetTagValue <DateTime>(ExifTags.DateTimeDigitized, out datePictureTaken)) { // Do whatever is required with the extracted information string messageToWriteSuccess = "The picture was taken on " + datePictureTaken.ToString(); LoggingTxtIva ll4 = new LoggingTxtIva(messageToWriteSuccess); int intmonthOfPic = (Int32)datePictureTaken.Month; string monthOfPic = "NOMonth"; StaticProp.Monthes.TryGetValue(intmonthOfPic, out monthOfPic); string yearOfPic = datePictureTaken.Year.ToString(); // making extended Pathes string extendedYearPath = StaticProp.CreateFolderPath + string.Format("\\{0}", yearOfPic); string extendedMonthPath = extendedYearPath + string.Format("\\{0}", monthOfPic); //--------------------- // check if such a year exist in the new folder if (Directory.Exists(extendedYearPath)) { //check if such a month exist in the new folder if (Directory.Exists(extendedMonthPath)) { // Copy the file string fileToCopy = item; string destinationDirectory = extendedMonthPath + "\\"; MovePicDictionary.Add(fileToCopy, destinationDirectory); //CopyMethods instanceCopy = new CopyMethods(); //instanceCopy.Move_FileNameExistsMethod(fileToCopy, destinationDirectory); } else { // if month not exist Directory.CreateDirectory(extendedMonthPath); string fileToCopy = item; string destinationDirectory = extendedMonthPath + "\\"; MovePicDictionary.Add(fileToCopy, destinationDirectory); //CopyMethods instanceCopy = new CopyMethods(); //instanceCopy.Move_FileNameExistsMethod(fileToCopy, destinationDirectory); } } else { // if year not exist Directory.CreateDirectory(extendedYearPath); Directory.CreateDirectory(extendedMonthPath); string fileToCopy = item; string destinationDirectory = extendedMonthPath + "\\"; MovePicDictionary.Add(fileToCopy, destinationDirectory); //CopyMethods instanceCopy = new CopyMethods(); //instanceCopy.Move_FileNameExistsMethod(fileToCopy, destinationDirectory); } Thread.Sleep(2); } } else { // nothing } } } catch (Exception e) // this comes in case No Exif data found { string messageToWriteFailed = "Exception happen" + e.ToString(); LoggingTxtIva ll2 = new LoggingTxtIva(messageToWriteFailed); // here i need to create directory in case Exif Data not exist messageToWriteFailed = "No Exif data in the file"; LoggingTxtIva ll5 = new LoggingTxtIva(messageToWriteFailed); string extendedNoExif = StaticProp.CreateFolderPath + "\\No_Date"; Directory.CreateDirectory(extendedNoExif); // Copy the file string fileToCopy = item; string destinationDirectory = extendedNoExif + "\\"; MovePicDictionary.Add(fileToCopy, destinationDirectory); //CopyMethods instanceCopy = new CopyMethods(); //instanceCopy.Move_FileNameExistsMethod(fileToCopy, destinationDirectory); } } // Change TextBoxStatus TextBoxStatus = "Move process Started"; } else { //if (StaticProp.ScanningFolderPath != "empty" && StaticProp.CreateFolderPath != "empty") //MessageBox.Show("You have to choose SCAN folder and NEW folder", "Help", MessageBoxButtons.OK); TextBoxStatus = "Folders not determined"; } // Serialisation Process SerialisationProcess_Binary makeSerialisation = new SerialisationProcess_Binary(); // Make Serialisation: makeSerialisation.DoSerialisationB(MovePicDictionary); Thread.Sleep(1000); // Move Process through another thread - In case it hase influence to the access of the picture source files //object toPassDict = makeDeSerialisation.DoDeserialisation(); Thread t_potok = new Thread(() => MethodDeSerialisation()); t_potok.Start(); t_potok.Join(); #endregion } else { #region In case of CheckBox Delete files after copying is False // todo change belo line back if (StaticProp.ScanningFolderPath != "empty" && StaticProp.CreateFolderPath != "empty") //if (StaticProp.ScanningFolderPath != "empty") { // Change TextBoxStatus TextBoxStatus = "Process Started"; // Progress bar visible ProgressBarStatusVisible = Visibility.Visible; Pathes pathing = new Pathes(StaticProp.ScanningFolderPath); String searchFolder = pathing.InitialFolderPath; var filters = new String[] { "jpg", "jpeg", "png", "gif", "tiff", "bmp", "svg" }; MethodsFromStartButton methods = new MethodsFromStartButton(); filesNames = methods.GetLongFilesFrom(searchFolder, filters, false); var filtersVideo = new String[] { "mp4", "avi", "mpg", "mpeg", "m2v", "mp2", "mpe", "mpv", "m4p", "m4v", "amv", "rmvb", "rm", "yuv", "wmv", "mov", "qt", "mng", "gifv", "ogv", "ogg", "vob", "flv", "mkv" }; filesNamesVideo = methods.GetLongFilesFrom(searchFolder, filtersVideo, false); // ProgressBarStatusMax will be only pictures if video not needed to copy ProgressBarStatusMax = filesNames.Length; // i work with video files separately // make filter for video files if (StaticProp.CheckBoxVideoSeparateFolder) { // ProgressBarStatusMax will be pictures + Video ProgressBarStatusMax = filesNames.Length + filesNamesVideo.Length; MethodCopyVideoFiles(filesNamesVideo); } foreach (string item in filesNames) { ProgressBarStatusValue++; try { using (ExifReader reader = new ExifReader(item)) { // if exif data exist (!=null) if (reader != null) { // Extract the tag data using the ExifTags enumeration DateTime datePictureTaken; if (reader.GetTagValue <DateTime>(ExifTags.DateTimeDigitized, out datePictureTaken)) { // Do whatever is required with the extracted information string messageToWriteSuccess = "The picture was taken on " + datePictureTaken.ToString(); LoggingTxtIva ll4 = new LoggingTxtIva(messageToWriteSuccess); int intmonthOfPic = (Int32)datePictureTaken.Month; string monthOfPic = "NOMonth"; StaticProp.Monthes.TryGetValue(intmonthOfPic, out monthOfPic); string yearOfPic = datePictureTaken.Year.ToString(); // making extended Pathes string extendedYearPath = StaticProp.CreateFolderPath + string.Format("\\{0}", yearOfPic); string extendedMonthPath = extendedYearPath + string.Format("\\{0}", monthOfPic); //--------------------- // check if such a year exist in the new folder if (Directory.Exists(extendedYearPath)) { //check if such a month exist in the new folder if (Directory.Exists(extendedMonthPath)) { // Copy the file string fileToCopy = item; string destinationDirectory = extendedMonthPath + "\\"; CopyMethods instanceCopy = new CopyMethods(); instanceCopy.Copy_FileNameExistsMethod(fileToCopy, destinationDirectory); //File.Copy(fileToCopy, destinationDirectory + Path.GetFileName(fileToCopy)); } else { Directory.CreateDirectory(extendedMonthPath); string fileToCopy = item; string destinationDirectory = extendedMonthPath + "\\"; CopyMethods instanceCopy = new CopyMethods(); instanceCopy.Copy_FileNameExistsMethod(fileToCopy, destinationDirectory); //File.Copy(fileToCopy, destinationDirectory + Path.GetFileName(fileToCopy)); } } else { Directory.CreateDirectory(extendedYearPath); Directory.CreateDirectory(extendedMonthPath); string fileToCopy = item; string destinationDirectory = extendedMonthPath + "\\"; CopyMethods instanceCopy = new CopyMethods(); instanceCopy.Copy_FileNameExistsMethod(fileToCopy, destinationDirectory); //File.Copy(fileToCopy, destinationDirectory + Path.GetFileName(fileToCopy)); } Thread.Sleep(2); } } else { // nothing } } } catch (Exception e) // this comes if exif has no INFO { string messageToWriteFailed = "Exception happen" + e.ToString(); LoggingTxtIva ll2 = new LoggingTxtIva(messageToWriteFailed); // here i need to create directory in case Exif Data not exist messageToWriteFailed = "No Exif data in the file"; LoggingTxtIva ll5 = new LoggingTxtIva(messageToWriteFailed); string extendedNoExif = StaticProp.CreateFolderPath + "\\No_Date"; Directory.CreateDirectory(extendedNoExif); // Copy the file string fileToCopy = item; string destinationDirectory = extendedNoExif + "\\"; CopyMethods instanceCopy = new CopyMethods(); instanceCopy.Copy_FileNameExistsMethod(fileToCopy, destinationDirectory); //File.Copy(fileToCopy, destinationDirectory + Path.GetFileName("\\" + fileToCopy)); } } // Change TextBoxStatus TextBoxStatus = "Process Finished!"; } else { //MessageBox.Show("You have to choose SCAN folder and NEW folder", "Help", MessageBoxButtons.OK); // Change TextBoxStatus TextBoxStatus = "Folders not determined"; } #endregion } } // Stop button make hidden again VisibilityStopButton = Visibility.Hidden; // enable exit button when process is finished IsEnabledExitButton = true; }
/// <summary> /// 区别是否相等 /// </summary> /// <returns></returns> public override int GetHashCode() { return(Pathes.GetHashCode()); }
/// <summary> /// 区别是否相等 /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { var o = obj as MultiSiteObsStreamer; return(Pathes.Equals(o.Pathes)); }