/// <summary> /// Gulu worker thread procedure. /// </summary> /// <param name="_param">The parameter of the type GuluWorkerParameter</param> public void WorkingThread(object _param) { Progress.Show(); GuluWorkerParameter parameter = (GuluWorkerParameter)_param; shouldStop__ = false; /* Sunny Chen Added 2008/07/01 --> */ BackupHelper backupHelper = new BackupHelper(parameter.ConfigurationReader.BackupDirectory); /* Sunny Chen Added 2008/07/01 <-- */ // Initialize the current value int i = 0; // Gets the maximum count of the files that needs to be processed int max = parameter.Items.Count; foreach (ListViewItem listViewItem in parameter.Items) { // Sets the progress value Progress.SetProgress(i, max); i++; // If stop is required, just get out of the loop if (shouldStop__) break; // Gets the full file name of for the current node. Full file name // is stored in the forth sub item of the list view item. string fileName = listViewItem.SubItems[3].Text; // If the file doesn't exist, prompt the error message and go on with // the next file if (!File.Exists(fileName)) { Output.Add(string.Format(Resources.TEXT_FILE_NOT_EXIST, fileName)); continue; } /* Sunny Chen Added 2008/07/01 --> */ // Backup the files if (parameter.ConfigurationReader.BackupEnabled && parameter.Gulu.BackupRequired) { bool result = backupHelper.Backup(fileName); if (!result) { Output.Add(string.Format(Resources.TEXT_BACKUP_FAILED, fileName)); continue; } } /* Sunny Chen Added 2008/07/01 <-- */ // Runs the gulu to process the current file. If the gulu failed processing, // a FALSE value will be returned and the error message will be added to // the system output if (!parameter.Gulu.Execute(fileName)) Output.Add(string.Format(Resources.TEXT_FILE_OPER_FAILED, fileName)); } /* Sunny Chen Added 2008/07/01 --> */ // Generates the backup mapping list. if (parameter.ConfigurationReader.BackupEnabled && parameter.Gulu.BackupRequired) backupHelper.GenerateMappingList(); /* Sunny Chen Added 2008/07/01 <-- */ // If shouldStop__ is true, that means it is the user who stops the running // of the gulu worker thread, so it is INTERRUPTED by the user. bool interrupted = shouldStop__ == true; // Calls the worker finished event handler OnGuluWorkerFinished(this, new GuluWorkerFinishedEventArgs(parameter.Gulu, interrupted)); }
/// <summary> /// Gulu worker thread procedure. /// </summary> /// <param name="_param">The parameter of the type GuluWorkerParameter</param> public void WorkingThread(object _param) { Progress.Show(); GuluWorkerParameter parameter = (GuluWorkerParameter)_param; shouldStop__ = false; /* Sunny Chen Added 2008/07/01 --> */ BackupHelper backupHelper = new BackupHelper(parameter.ConfigurationReader.BackupDirectory); /* Sunny Chen Added 2008/07/01 <-- */ // Initialize the current value int i = 0; // Gets the maximum count of the files that needs to be processed int max = parameter.Items.Count; foreach (ListViewItem listViewItem in parameter.Items) { // Sets the progress value Progress.SetProgress(i, max); i++; // If stop is required, just get out of the loop if (shouldStop__) { break; } // Gets the full file name of for the current node. Full file name // is stored in the forth sub item of the list view item. string fileName = listViewItem.SubItems[3].Text; // If the file doesn't exist, prompt the error message and go on with // the next file if (!File.Exists(fileName)) { Output.Add(string.Format(Resources.TEXT_FILE_NOT_EXIST, fileName)); continue; } /* Sunny Chen Added 2008/07/01 --> */ // Backup the files if (parameter.ConfigurationReader.BackupEnabled && parameter.Gulu.BackupRequired) { bool result = backupHelper.Backup(fileName); if (!result) { Output.Add(string.Format(Resources.TEXT_BACKUP_FAILED, fileName)); continue; } } /* Sunny Chen Added 2008/07/01 <-- */ // Runs the gulu to process the current file. If the gulu failed processing, // a FALSE value will be returned and the error message will be added to // the system output if (!parameter.Gulu.Execute(fileName)) { Output.Add(string.Format(Resources.TEXT_FILE_OPER_FAILED, fileName)); } } /* Sunny Chen Added 2008/07/01 --> */ // Generates the backup mapping list. if (parameter.ConfigurationReader.BackupEnabled && parameter.Gulu.BackupRequired) { backupHelper.GenerateMappingList(); } /* Sunny Chen Added 2008/07/01 <-- */ // If shouldStop__ is true, that means it is the user who stops the running // of the gulu worker thread, so it is INTERRUPTED by the user. bool interrupted = shouldStop__ == true; // Calls the worker finished event handler OnGuluWorkerFinished(this, new GuluWorkerFinishedEventArgs(parameter.Gulu, interrupted)); }