private async void openToolStripMenuItem_Click(object sender, EventArgs e) { CommonOpenFileDialog openFolder = new CommonOpenFileDialog { AllowNonFileSystemItems = false, Multiselect = false, IsFolderPicker = true }; if (openFolder.ShowDialog() != CommonFileDialogResult.Ok) { return; } if (mediaFileListView.Items.Count > 0) { mediaFileListView.Items.Clear(); } fileLoadProgressBar.Visible = true; fileLoadStatusLabel.Visible = true; totalFileCount = await Task.Run(() => ProcessFiles.MediaFileCount(openFolder.FileName)); fileLoadProgressBar.Maximum = totalFileCount; fileLoadStatusLabel.Text = $"0.00%"; await Task.Run(() => { LoadFiles(openFolder.FileName); HideProgressWithTimeout(1000); }); }
private void LoadFiles(string folderPath) { if (folderPath is null) { throw new ArgumentNullException(nameof(folderPath)); } int currentFileIndex = 0; foreach (MediaFile mediaFile in ProcessFiles.Load(folderPath)) { ListViewItem listViewItem = new ListViewItem(mediaFile.FileName.Name); listViewItem.SubItems.Add(ByteSize.FromBytes(mediaFile.FileName.Length).ToString()); listViewItem.SubItems.Add(mediaFile.MediaQuality); listViewItem.SubItems.Add(mediaFile.VideoCodec); listViewItem.SubItems.Add(mediaFile.AudioCodec); listViewItem.SubItems.Add(mediaFile.VideoResolution.Dimensions); listViewItem.SubItems.Add(mediaFile.VideoResolution.AspectRatio); listViewItem.SubItems.Add(mediaFile.FileName.FullName); synchronizationContext.Post(new SendOrPostCallback(o => { //Add the ListViewItem to our ListView mediaFileListView.Items.Add(listViewItem); //Increment our current file index currentFileIndex++; //Update our progress bar and percentage label fileLoadProgressBar.PerformStepNoAnimation(currentFileIndex); fileLoadStatusLabel.Text = string.Format("{0:P2}", currentFileIndex / (double)totalFileCount); }), null); } }
public void GoNext() { var processor = new ProcessFiles(); var prog = new ProgressStep <ProcessFiles>(processor); prog.MethodInvoke = e => { e.Execute(_mergeData.Unfiltered, _mergeOp); }; prog.GoNextAction = () => _wizard.GoToStep(this); _wizard.GoToStep(prog); }
private static T watchFile <T>(string file, TranspilerParams tparams, ProcessFiles <T> fnProcessFiles) { var fileKey = getHashedString(file); var watcher = dictWatch.GetOrAdd(fileKey, key => new Watcher { File = file, Process = new ProcessContainerForWatching(generateInputParams(fileKey, file, tparams), files => fnProcessFiles(separateFiles(fileKey, files, tparams.ExportType))) }); watcher.Process.RenewIfNecessary(); var ret = watcher.Process.GetLastOutput(); return(fnProcessFiles(separateFiles(fileKey, ret, tparams.ExportType))); }
// private void Application_Exit ( object sender, ExitEventArgs e ) /// <summary> /// Exit /// </summary> /// <param name="e"></param> protected override void OnExit(ExitEventArgs e) { base.OnExit(e); try { // terminate any running Omicron related process. IStartProcessInterface spi = new ProcessFiles(); do { if (MyCommons.CancellationToken.IsCancellationRequested == true) { break; } } while (!(Task.Factory.StartNew(() => spi.KillOmicronProcesses())).Result); // Log the operations completed so far. if (MyCommons.LogProcess.Length > 0) { // String logFilePath = Path.Combine(MyCommons.FileOutputFolder, MyResources.Strings_LogFolder); // write log to the file. File.WriteAllText(MyCommons.LogFileNameWithPath, MyCommons.LogProcess.ToString()); // open saved log file for the user. Process.Start(MyCommons.LogFileNameWithPath); } } catch (NullReferenceException nre) { // save to the fileOutputFolder and print to Debug window // if the project build is in DEBUG. ErrorHandler.Log(nre); //Debug.Flush(); MyCommons.EditProfileTraceSource.Flush(); } finally { // save debug and trace info before terminating the program. //Debug.Flush(); MyCommons.EditProfileTraceSource.Flush(); if (MyCommons.CancellationToken.CanBeCanceled) { MyCommons.TokenSource.Dispose(); } } }
private void SetupObservables() { // Keep the maximum value of the progressbar up to date this.WhenAnyValue(x => x.XMLProcessors.Count) .Where(c => c > 0) .Subscribe(count => ProgressMaximum = count * XMLProcessor.ProgressSteps); ProcessFiles.IsExecuting.ToPropertyEx(this, x => x.IsProcessingFiles, deferSubscription: false); OpenChildWindow = ShowWindow. Merge( ProcessFiles .Where(_ => XMLProcessors.Sum(processor => processor.StatusMessages.Count) > 0) .Select(_ => WindowType.ProcessingMessages) ); }
private void btnGenerateReport_Click(object sender, EventArgs e) { dataGridView1.DataSource = null; if (CanGenerateReport()) { vemp = new ProcessFiles(); errorMsgs = new List <ErrorMessage>(); var empData = vemp.ProcessEmpFiles(cmbBillingCycle.SelectedItem.ToString(), cmbYear.SelectedItem.ToString(), Convert.ToInt32(cmbAccountName.SelectedValue), costPath, billingPath, ref errorMsgs); if (errorMsgs.Count() > 0) { var msgResult = MessageBox.Show("There are few discripencies in the file.\nDo you like to continue", "Discripency Alert", MessageBoxButtons.YesNo); if (msgResult == System.Windows.Forms.DialogResult.Yes) { AccountMonthRevenue aMonthData = new AccountMonthRevenue(); bool isSuccessful = aMonthData.CreateAccountMonthWiseData(cmbBillingCycle.Text, Convert.ToInt32(cmbYear.Text), ((EntitiesLib.Account)(cmbAccountName.SelectedItem)).AccountID.ToString(), empData); //FillReportData(empData); dataGridView1.Visible = true; dataGridView1.DefaultCellStyle.ForeColor = Color.Black; DisableControls(); MessageBox.Show("Date generated successfully"); } else { ClearData(); dataGridView1.DefaultCellStyle.ForeColor = Color.Red; dataGridView1.DataSource = errorMsgs; dataGridView1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; //DisableControls(); MessageBox.Show("Cannot proceed as discripencies found in data!"); } } else { AccountMonthRevenue aMonthData = new AccountMonthRevenue(); bool isSuccessful = aMonthData.CreateAccountMonthWiseData(cmbBillingCycle.Text, Convert.ToInt32(cmbYear.Text), ((EntitiesLib.Account)(cmbAccountName.SelectedItem)).AccountID.ToString(), empData); //FillReportData(empData); dataGridView1.Visible = true; dataGridView1.DefaultCellStyle.ForeColor = Color.Black; DisableControls(); MessageBox.Show("Date generated successfully"); } } }
private void btnCopy_Click(object sender, RoutedEventArgs e) { var isValidPath = IsValidPath(new List <string>() { txtSrcPath.Text, txtTargetPath.Text }); rtxtMessage.Document.Blocks.Clear(); if (cbFileType.SelectedIndex == 0) { EditRichTextBox("File Type required.", Brushes.Red); } else if (isValidPath) { var strMessage = string.Empty; switch (fileType) { case FileType.Photos: strMessage = ProcessFiles.ExecuteProcessFiles(txtSrcPath.Text, txtTargetPath.Text, fileType, chbAllDirectories.IsChecked); break; case FileType.Videos: strMessage = CopyMovies.Copy(txtSrcPath.Text, txtTargetPath.Text, txtFileMoviesList.Text); System.Console.Read(); break; case FileType.Music: strMessage = ProcessFiles.ExecuteProcessFiles(txtSrcPath.Text, txtTargetPath.Text, fileType, chbAllDirectories.IsChecked); break; case FileType.Any: strMessage = ProcessFiles.ExecuteProcessFiles(txtSrcPath.Text, txtTargetPath.Text, fileType, chbAllDirectories.IsChecked); break; default: break; } EditRichTextBox(strMessage, Brushes.Black); } else { EditRichTextBox("Something went wrong.", Brushes.Red); } }
private void ExecuteCommand() { try { switch (_commandName) { case "jsontotsv": // convert results in JSON format to Webliographer TSV format var gs = new ProcessGoogleResults(); gs.JsonToStandardTsv(GetArg(), GetArg()); break; case "processtsv": // merge two TSVs into a new TSV var pt = new ProcessTsv(); pt.MergeTsv(GetArg(), GetArg(), GetArg()); break; case "processdirectories": // merge all TSVs in a directory into a master.tsv var pf = new ProcessFiles(); pf.ProcessDirectories(GetArg(), GetArg()); break; case "expandtsv": // convert results in minimal TSV format into Webliographer TSV format var pgr = new ProcessGoogleResults(); pgr.MinimalTsvToStandardTsv(GetArg(), GetArg()); break; case "processmd": // extract links from a Markdown file and write to a file in minimal TSV format (Title, Link) var pm = new ProcessMarkdown(); ProcessMarkdown.MarkdownToMinimalTsv(GetArg(), GetArg()); break; default: Console.WriteLine($"Unknown command: {_commandName}"); break; } } catch (Exception e) { Console.WriteLine(e.Message); } }
public static void Main(string[] args) { /**********************************************************/ //CopyMovies.Copy(@"F:\Movies"); //System.Console.Read(); /**********************************************************/ /**********************************************************/ var srcPath = @"C:\Users\Leo\Downloads\iloveimg-converted"; var destPath = @"C:\Users\Leo\Downloads\StagePhotos\"; ProcessFiles.ExecuteProcessFiles(srcPath, destPath, FileType.Photos, true); ProcessFiles.WriteLinesToFiles(srcPath); /**********************************************************/ //Delete Empty Folders //ProcessFiles.RemoveEmptyDirectories(srcPath); //Renaming Files //srcPath = @"F:\Videos\TV Shows\Blue's Clues (Complete)"; //var collection = new List<KeyValuePair<string, string>>() //{ // new KeyValuePair<string,string>("Blue's Clues - ", "BluesClues"), // new KeyValuePair<string,string>( " - ", ""), // new KeyValuePair<string,string>("'", ""), // new KeyValuePair<string,string>(" ", ""), // new KeyValuePair<string,string>("_.", ".") //}; //foreach (var kv in collection) //{ // RenameFiles(srcPath, kv.Key, kv.Value); //} ProcessFiles.WriteLinesToFiles(srcPath); }
private void btnDisplayEmployeeModel_Click(object sender, EventArgs e) { if (txtEmpDetailsExcellName.Text == string.Empty || txtUploadBillingName.Text == string.Empty) { MessageBox.Show("Please upload the cost sheet and revenue sheet to view the details"); } else { vemp = new ProcessFiles(); List <ErrorMessage> errorMsgs = new List <ErrorMessage>(); var empData = vemp.ProcessEmpFiles(cmbBillingCycle.SelectedItem.ToString(), cmbYear.SelectedItem.ToString(), Convert.ToInt32(cmbAccountName.SelectedValue), costPath, billingPath, ref errorMsgs); if (errorMsgs.Count() == 0) { dataGridView1.DataSource = empData; } else { dataGridView1.DataSource = errorMsgs; } } }
public void RemoveBlocksByName() { var editor = Application.DocumentManager.MdiActiveDocument.Editor; editor.WriteMessage("\nSelect Files To Process : "); List <string> dwgFiles = GetFiles.GetAllCadFilesFromDialog(); if (dwgFiles == null || dwgFiles.Count == 0) { return; } string blockName = editor.GetString("\nEnter Block Name : ").StringResult; if (string.IsNullOrWhiteSpace(blockName)) { return; } ProcessFiles.GetDatabasesFromFiles(dwgFiles).ForEach(db => db.RemoveAllBlocks(blockName)); editor.WriteMessage($"\nFinish /{DateTime.Now.ToShortTimeString()}/ !"); }
public static T CompileFile <T>(string file, TranspilerParams tparams, ProcessFiles <T> fnProcessFiles) => watchFile(file, tparams, fnProcessFiles);
/// <summary> /// Start up /// </summary> /// <param name="e">arguments</param> protected override async void OnStartup(StartupEventArgs e) { #region Catch All Unhandled Exceptions // Following code found on stackoverflow.com // http://stackoverflow.com/questions/10202987/in-c-sharp-how-to-collect-stack-trace-of-program-crash AppDomain currentDomain = default; currentDomain = AppDomain.CurrentDomain; // Handler for unhandled exceptions. currentDomain.UnhandledException += GlobalUnhandledExceptionHandler; // Handler for exceptions in thread behind forms. Current.DispatcherUnhandledException += GlobalThreadExceptionHandler; #endregion #region Create LocalApplication Folders. if (!Directory.Exists(MyCommons.LogFileFolderPath)) { Directory.CreateDirectory(MyCommons.LogFileFolderPath); } if (!Directory.Exists(MyCommons.CrashFileFolderPath)) { Directory.CreateDirectory(MyCommons.CrashFileFolderPath); } #endregion #region Error Logging. //// Trace is empty. //MyCommons.isTraceEmpty = true; //// Add textwriter for console. //TextWriterTraceListener consoleOut = // new TextWriterTraceListener(System.Console.Out); //Debug.Listeners.Add(consoleOut); //TextWriterTraceListener fileOut = // new TextWriterTraceListener(MyCommons.CrashFileNameWithPath);//File.CreateText(MyCommons.CrashFileNameWithPath)); //Debug.Listeners.Add(fileOut); // Set the Trace to track errors. // moving all tracing to the ErrorHandler module. // ErrorHandler.Tracer(); #endregion #region Application Starts Here. base.OnStartup(e); //// Verify none of the Omicron modules running, //// without it unexpected behaviors would occur. DispatchService.Invoke(() => { IStartProcessInterface spi = new ProcessFiles(); spi.KillOmicronProcesses(); }); ViewFactory factory = new ViewFactory(); ViewInfrastructure infrastructure = factory.Create(); infrastructure.View.DataContext = infrastructure.ViewModel; #if DEBUG MyCommons.MyViewModel.ReplaceWithTextBoxText = MyResources.Strings_Debug_TextBoxReplace; MyCommons.MyViewModel.FindWhatTextBoxText = MyResources.Strings_Debug_TextBoxFind; #endif MyCommons.MyViewModel.FileSideCoverText = MyResources.Strings_FormStartTest; MyCommons.MyViewModel.ModuleSideCoverText = MyResources.Strings_FormStartModuleTest; MyCommons.MyViewModel.Editable = true; // check for the updates await Task.Run(async() => { // log application update message Debug.WriteLine("Checking for updates", "Informative"); // await for application update await CheckForUpdates(); }); infrastructure.View.Show(); #endregion }
private ImportModel ProcessImport(string fileName) { ProcessFiles _fileImport = new ProcessFiles(); var path = Path.Combine(Server.MapPath("~/ImportFiles/"), fileName); _fileImport.FilePath = path; string Extension = fileName.Split('.')[1]; string fn = fileName.Split('.')[0]; string fsc = null; string naics = null; string[] fparts = fn.Split(' '); FSCCodes fsccodes = null; NAICSCodes naicscodes = null; if (fparts[0] == "FSC") { fsc = fparts[1]; fsccodes = db.FSCCodes.Where(f => f.FDCCode == fsc).FirstOrDefault(); } else { naics = fparts[0]; naicscodes = db.NAICSCodes.Where(n => n.NAICSCode == naics).FirstOrDefault(); } System.Data.DataTable dtBulk = null; switch (Extension) { case "csv": _fileImport.ProcessCsvFile(); dtBulk = _fileImport.UploadedTable; break; case "xls": case "xlsx": case "ods": dtBulk = BLS_Inventory.Common.ExcelToTables(path); break; } if (dtBulk == null) return(null); bool first = true; int compadded = 0; int compdupl = 0; int contadded = 0; int contdupl = 0; int comperrors = 0; int conterrors = 0; foreach (System.Data.DataRow row in dtBulk.Rows) { if (first) { first = false; continue; } Companies company; Contacts contact; string compname = row.ItemArray[3].ToString(); if (compname.Trim() == "") { comperrors += 1; continue; } string contemail = row.ItemArray[1].ToString(); if (contemail.EndsWith(".gov")) { conterrors += 1; continue; } company = (from c in db.Companies where c.CompanyName == compname select c).FirstOrDefault(); if (company == null) { compadded += 1; company = new Companies(); if (fsc != null) company.FSCCodes.Add(fsccodes); if (naics != null) company.NAICSCodes.Add(naicscodes); db.Companies.Add(company); } else compdupl += 1; contact = (from c in company.Contacts where c.email == contemail select c).FirstOrDefault(); if (contact == null) { contadded += 1; contact = new Contacts(); company.Contacts.Add(contact); } else { contdupl += 1; } contact.Name = row.ItemArray[0].ToString(); Fix_Name(contact); contact.email = row.ItemArray[1].ToString(); company.Cage = row.ItemArray[2].ToString(); company.CompanyName = row.ItemArray[3].ToString(); contact.Phone = row.ItemArray[4].ToString(); contact.Fax = row.ItemArray[5].ToString(); company.Address1 = row.ItemArray[6].ToString(); company.City = row.ItemArray[7].ToString(); company.State = row.ItemArray[8].ToString(); company.Zip = row.ItemArray[9].ToString(); db.SaveChanges(); } ImportModel im = new ImportModel(); im.FileNamee = path + fileName; im.CompaniesImported = compadded; im.CompaniesDuplicated = compdupl; im.CompanyErrors = comperrors; im.ContactErrors = conterrors; im.ContactsDuplicated = contdupl; im.ContactsImported = contadded; return im; }
public void GoNext() { var processor = new ProcessFiles(); var prog = new ProgressStep<ProcessFiles>(processor); prog.MethodInvoke = e => { e.Execute(_mergeData.Unfiltered, _mergeOp); }; prog.GoNextAction = () => _wizard.GoToStep(this); _wizard.GoToStep(prog); }
/// <summary> /// Actual command that does the work. /// </summary> /// <param name="unused"></param> public void ExecuteFindReplace(object unused) { // TODO: Find a mechanism to decide if .csv file open or not new ProcessFiles().OpenCsvFile(); // initialize new file dialog OpenFileDialog dlg = new OpenFileDialog { // Set OpenFileDialog defaults. Title = MyResources.Strings_OpenFileDialog, Filter = MyResources.Strings_FileDialogFilter, DefaultExt = MyResources.Strings_FileDialogDefault, Multiselect = true, }; #if DEBUG dlg.InitialDirectory = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), MyResources.Strings_Debug_InitialDirectory); #else dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); #endif // if (dlg.ShowDialog()== CommonFileDialogResult.Ok) if (dlg.ShowDialog() == true) { // initialize stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); if (MyCommons.TokenSource == null) { // Initialize Common Properties. MyCommons.TokenSource = new CancellationTokenSource(); MyCommons.CancellationToken = MyCommons.TokenSource.Token; } // Start Processing the user specified files. IStartProcessInterface spi = new ProcessFiles(); Task.Factory.StartNew(() => { try { // Polling Cancellation Token Status. // If cancellation requested throw an error and exit loop. if (MyCommons.CancellationToken.IsCancellationRequested == true) { MyCommons.CancellationToken.ThrowIfCancellationRequested(); } // Prevents the user to modify texts of FindWhat, ReplaceWith and Password // while test running. Enable(false); // Start process. // spi.StartProcessing ( dlg.FileNames, MyCommons.MyViewModel.Password, MyCommons.MyViewModel ); spi.StartProcessing(dlg.FileNames, MyCommons.MyViewModel); } catch (AggregateException ae) { ErrorHandler.Log(ae); } } , MyCommons.CancellationToken) .ContinueWith(value => { // Reset and Activate controls. ResetControls(); }); } else { // Reverts back 'Start', since the user 'Canceled' to select file MyCommons.MyViewModel.IsChecked = false; MyCommons.MyViewModel.IsEnabled = false; // Prevents the user to modify texts of FindWhat, ReplaceWith and Password // while test running. Enable(true); // Reset all controls MyCommons.MyViewModel.EraseCommand.Execute(null); } }
internal static void UpdateFiles() { var tagDictionary = TagDictionaryBuilder.BuildLazy(Arguments.FixedPath); ProcessFiles.UpdateFiles(Arguments.DeployFrom, Arguments.TemplateFilters, tagDictionary); }