public void DS_StartForms(UIApplication uiapp) { DS_Form newForm = new DS_Form { TopLevel = true }; SourcePath = newForm.DS_OpenInputFolderDialogForm("Set folder for checking '*.rvt' files").ToString(); if (SourcePath == "") { newForm.Close(); return; } DestinationPath = newForm.DS_OpenOutputFolderDialogForm("Set output folder for '*.nwc' files").ToString(); if (DestinationPath == "") { newForm.Close(); return; } DS_Filter filter = new DS_Filter(uiapp) { TopLevel = true, sourcePath = SourcePath, destinationPath = DestinationPath }; filter.Show(); }
public void DialogFormsInvoke() { //Directories set DS_Form newForm = new DS_Form(); string FolderPathNWC = newForm.DS_OpenFolderDialogForm("", "Set a directory with input folders with NWC files:").ToString(); if (FolderPathNWC == "") { Close(); return; } //Property set FolderPathNWCpr = FolderPathNWC; string FolderPathNWD = newForm.DS_OpenFolderDialogForm("", "Set a directory with output folders for NWD files:").ToString(); if (FolderPathNWD == "") { Close(); return; } //Property set FolderPathNWDpr = FolderPathNWD; }
public void AddParametersToProject() { FilesPathes.Clear(); SelectesParameters.Clear(); bool FileError = false; DS_Form newForm = new DS_Form { TopLevel = true }; FileWithProjectsPathes = newForm.DS_OpenFileDialogForm_txt("", "Select file with pathes to *.rvt projects.").ToString(); if (FileWithProjectsPathes == "") { newForm.Close(); return; } CreateFilesPathesList(ref FileError); if (FileError == true) { return; } SPFPath = newForm.DS_OpenFileDialogForm_txt("", "Select shared parameter file for loading.").ToString(); if (SPFPath == "") { newForm.Close(); return; } MyApplication.thisApp.ShowForm(App); }
public static void Main() { DS_Form newForm = new DS_Form(); string SourcePath = newForm.DS_OpenFolderDialogForm("", "Chose source folder:").ToString(); string BasedirName = new DirectoryInfo(SourcePath).Name; string TopFolderPath = SourcePath.Replace(BasedirName, ""); string TextFilePath = newForm.DS_OpenFileDialogForm("Chose the txt file with list of names:").ToString(); string[] lines = File.ReadAllLines(TextFilePath); //Copying and renaming directories try { foreach (string line in lines) { if (line != BasedirName) { string DestinationPath = TopFolderPath + line; DirCopy(SourcePath, DestinationPath); DirRename(DestinationPath, line, BasedirName); } } } catch (Exception ex) { Console.WriteLine("An error occured: " + ex.Message); } Console.WriteLine("Done!"); Console.ReadLine(); }
public void ExcelSave() { DS_Form newForm = new DS_Form { TopLevel = true }; newForm.Show(); string DestinationPath = newForm.DS_OpenFolderDialogForm("Chose folder for Excel report").ToString(); if (DestinationPath == "") { return; } string ExcelOutputFileName = "Bim-проекты_" + Unloading.ColNameUnload + "_изменения" + ".xlsx"; string ExcelOutputDir = DestinationPath + ((char)92).ToString() + ExcelOutputFileName; FileInfo fileInfo = new FileInfo(ExcelOutputDir); try { package.SaveAs(fileInfo); MessageBox.Show("Excel file has been saved to \n" + ExcelOutputDir); } catch (Exception excpt) { MessageBox.Show(excpt.Message); } }
public void DS_StartForms(UIApplication uiapp) { DS_Form newForm = new DS_Form { TopLevel = true }; SPFPath = newForm.DS_OpenFileDialogForm_txt("", "Select shared parameter file for loading.").ToString(); if (SPFPath == "") { newForm.Close(); return; } ParametersNamesPath = newForm.DS_OpenFileDialogForm_txt("", "Select file with parameters names.").ToString(); if (ParametersNamesPath == "") { newForm.Close(); return; } AddParametersToSFPOptions addParametersToSFPOptions = new AddParametersToSFPOptions(uiapp); addParametersToSFPOptions.Show(); }
static void Main(string[] args) { DS_Form newForm = new DS_Form { TopLevel = true }; string InputFolderPath = newForm.DS_OpenInputFolderDialogForm("Chose folder for checking").ToString(); if (InputFolderPath == "") { return; } string OutputFolderPath = newForm.DS_OpenOutputFolderDialogForm("Chose folder for result").ToString(); if (OutputFolderPath == "") { return; } DirectoryInfo Dir = new DirectoryInfo(InputFolderPath); //DirectoryInfo[] Files = d.Get("*.*"); //Getting files names string str = ""; string FileNameOut = "DS_Names.txt"; string writePath = ""; foreach (DirectoryInfo d in Dir.EnumerateDirectories()) { if (d.Name != FileNameOut) { str = str + d.Name + "\n"; Console.WriteLine(d.Name); writePath = OutputFolderPath + "\\" + FileNameOut; try { using (StreamWriter sw = new StreamWriter(writePath, false, System.Text.Encoding.UTF8)) { sw.WriteLine(str + "\n"); } } catch (Exception) { } } } if (str == "") { Console.WriteLine("No files in the folder."); } else { Console.WriteLine("\n Names of files are recorded to " + writePath); } Console.ReadLine(); }
public void Program(MongoClient client) { DS_Form newForm = new DS_Form { TopLevel = true }; newForm.Show(); SourseFolderPath = newForm.DS_OpenFolderDialogForm("Chose folder for checking").ToString(); if (SourseFolderPath == "") { return; } string DirName = Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\Desktop"); dS_Output.DS_WritePath = DirName + "\\" + "Log_ReportStatusExport" + "\\" + CurDateTime + "_" + "Log" + ".txt"; dS_Output.DS_PathNameCreate(CurDateTime, DirName + "\\" + "Log_ReportStatusExport"); Form_ReportDays form_ReportDays = new Form_ReportDays { TopLevel = true }; form_ReportDays.ShowDialog(); int.TryParse(form_ReportDays.textBox_DaysNum.Text, out int DaysNumber); if (DaysNumber == 0) { Environment.Exit(1); } Uploading mongoDB_Test = new Uploading(client); //Iterating through lines in txt file CheckFiles(SourseFolderPath, DaysNumber, mongoDB_Test); CheckDir(SourseFolderPath, DaysNumber, mongoDB_Test); mongoDB_Test.SortPeople(client); MessageBox.Show("Log file has been saved to: " + dS_Output.DS_WritePath); UnloadOpt unloadOpt = new UnloadOpt { TopLevel = true }; unloadOpt.ShowDialog(); MessageBox.Show("Process complete!"); Application.Exit(); }
public static void Main() { DS_Form newForm = new DS_Form { TopLevel = true }; newForm.Show(); string CheckPath = newForm.DS_OpenFolderDialogForm("", "Chose directory for check:").ToString(); string CheckPathName = new DirectoryInfo(CheckPath).Name; if (CheckPath == "") { return; } string ReportPath = newForm.DS_OpenFolderDialogForm("", "Chose directory for report file:").ToString(); if (ReportPath == "") { return; } //Name generation for output file string CurDate = DateTime.Now.ToString("yyMMdd"); ReportPath = ReportPath + ((char)92).ToString() + CurDate + "_" + CheckPathName + ".txt"; //Refresh existing file if (File.Exists(ReportPath)) { List <string> EmptyList = new List <string>(); File.WriteAllLines(ReportPath, EmptyList); } List <string> ForbiddenList = new List <string>() { "!", "£", "$", "%", "(", ")", "^", "&", "{", "}", "[", "]", "+", "-", "=", "@", "’", "~", "¬", "`", "‘", "/", "?", ":", "*", "<", ">", " ", ((char)34).ToString(), ((char)92).ToString(), ((char)124).ToString(), }; CheckPathSearch(CheckPathName, CheckPath, ForbiddenList, ReportPath); CheckSubPathSearch(CheckPath, ForbiddenList, ReportPath); //No issues has been found FileInfo ReportPathInf = new FileInfo(ReportPath); if (File.Exists(ReportPath) == false | (File.Exists(ReportPath) == true && ReportPathInf.Length == 0)) { StreamWriter(ReportPath, "Check complete!\nNo issues found in this folder!"); } Process.Start("notepad.exe", ReportPath); }
public void AssignFamilyPath() { DS_Form newForm = new DS_Form { TopLevel = true }; FamilyPath = newForm.DS_OpenInputFolderDialogForm().ToString(); if (FamilyPath == "") { newForm.Close(); return; } }
public static void Main1() { DS_Form newForm = new DS_Form(); string SourceFilePath = newForm.DS_OpenFileDialogForm("Chose the base file:").ToString(); string ext = new DirectoryInfo(SourceFilePath).Extension; string FolderPath = newForm.DS_OpenFolderDialogForm("", "Chose directory with folders:").ToString(); string SubFolderPath = newForm.DS_OpenFolderDialogForm(FolderPath, "Chose a type of folder for the base file:").ToString(); SubFolderPath = SubFolderPath.Replace(FolderPath, ""); string[] DirPathes = Directory.GetDirectories(FolderPath); string dirName; //Subfolder path Getting foreach (string dirPath in DirPathes) { dirName = new DirectoryInfo(dirPath).Name; SubFolderPath = SubFolderPath.Replace(dirName, ""); SubFolderPath = SubFolderPath.TrimStart((char)92); } //File copying foreach (string dirPath in DirPathes) { dirName = new DirectoryInfo(dirPath).Name; File.Copy(SourceFilePath, dirPath + @"\" + SubFolderPath + @"\" + dirName + ext, true); } Console.WriteLine("Done!" + "\n" + "File " + "\n" + "'" + SourceFilePath + "'" + "\n" + "has been copied to each folder: " + "\n" + "'" + SubFolderPath + "'" + "\n" + " in the directory: " + "\n" + "'" + FolderPath + "'"); Console.ReadLine(); }
static void Main(string[] args) { DS_Form newForm = new DS_Form { TopLevel = true }; string InputFilePath = newForm.DS_OpenFileDialogForm_txt().ToString(); if (InputFilePath == "") { return; } string InputFolderPath = newForm.DS_OpenInputFolderDialogForm("Chose folder for renaming").ToString(); if (InputFolderPath == "") { return; } //Name of input file //string textFile = "DS_Names.txt"; if (File.Exists(InputFilePath)) { DirectoryInfo Dir = new DirectoryInfo(InputFolderPath); DirectoryInfo[] DirArr = Dir.GetDirectories(); //DirectoryInfo d = new DirectoryInfo(@Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));//Assuming Test is your Folder //FileInfo[] Files = d.GetFiles("*.*"); //Getting files ArrayList list = new ArrayList(); int ai = 0; NewNamesList(DirArr, InputFilePath, list); int directoryCount = DirArr.Length; //Dirs renaming string[] lines = File.ReadAllLines(InputFilePath); try { for (int i = 0; i <= directoryCount - 1; i++) { if (DirArr[i].Name != InputFilePath) //Exceptions { Directory.Move(InputFolderPath + "/" + DirArr[i].Name, InputFolderPath + "/" + lines[i - ai]); } else { ai += 1; } } } catch (Exception ex) { Console.WriteLine("An error occured: " + ex.Message); } //Output for existing files Console.WriteLine("Existing folders:\n"); list = new ArrayList(); NewNamesList(DirArr, InputFilePath, list); foreach (string namelist in list) { Console.WriteLine(namelist); } Console.WriteLine("\n in the folder: '" + InputFolderPath + "'\n are renamed to: \n"); //Output for renames files Dir = new DirectoryInfo(InputFolderPath); DirArr = Dir.GetDirectories(); list = new ArrayList(); NewNamesList(DirArr, InputFilePath, list); foreach (string namelist in list) { Console.WriteLine(namelist); } } else { Console.WriteLine("File '" + InputFilePath + "' is absent."); } Console.ReadKey(); }
public void Program() { //New form creation DS_Form newForm = new DS_Form(); string FolderPathNWD = newForm.DS_OpenFolderDialogForm("", "Set directory for projects with NWF files:").ToString(); if (FolderPathNWD == "") { newForm.Close(); return; } SourseFolderPath = FolderPathNWD; string CurDateTime = DateTime.Now.ToString("yyMMdd_HHmmss"); DS_Output dS_Output = new DS_Output { DS_WritePath = SourseFolderPath + "\\" + "Log_ClashVPReport_" + CurDateTime + ".txt" }; SavedFiles.Clear(); SavedFiles.Add("Files has been saved: " + "\n"); FilesWithNoClashTests.Clear(); FilesWithNoClashTests.Add("No clash tests exist in files: " + "\n"); FilesWithNoClashRes.Clear(); FilesWithNoClashRes.Add("No clashes are in files: " + "\n"); FilesCheck(SourseFolderPath); DirIterate(SourseFolderPath); //Start log writing if (SavedFiles.Count > 1) { SavedFiles.Add("\n"); foreach (string s in SavedFiles) { dS_Output.DS_StreamWriter(s); } } else { dS_Output.DS_StreamWriter("No NWF files have been found in this folder."); MessageBox.Show("Errors occurred!" + "\n" + "Look at " + dS_Output.DS_WritePath + " for details."); return; } if (FilesWithNoClashTests.Count > 1) { FilesWithNoClashTests.Add("\n"); foreach (string s in FilesWithNoClashTests) { dS_Output.DS_StreamWriter(s); } } if (FilesWithNoClashRes.Count > 1) { FilesWithNoClashRes.Add("\n"); foreach (string s in FilesWithNoClashRes) { dS_Output.DS_StreamWriter(s); } } MessageBox.Show("Process complete! See report: " + "\n" + dS_Output.DS_WritePath); }