public void Load() { TaskLoader ldr = new TaskLoader(); string path = Preferences.SessionDirectory; if (System.IO.Directory.Exists(path)) { string[] files = System.IO.Directory.GetFiles(path, "*" + TaskDefinitionHelper.BULKCOPYDEFINITION); foreach (string f in files) { try { string name = string.Empty; FdoBulkCopyOptions opt = ldr.BulkCopyFromXml(f, ref name, false); FdoBulkCopy cpy = new FdoBulkCopy(opt); AddTask(name, cpy); } catch { } } files = System.IO.Directory.GetFiles(path, "*" + TaskDefinitionHelper.JOINDEFINITION); foreach (string f in files) { try { string name = string.Empty; FdoJoinOptions opt = ldr.JoinFromXml(f, ref name, false); FdoJoin join = new FdoJoin(opt); AddTask(name, join); } catch { } } files = System.IO.Directory.GetFiles(path, "*" + TaskDefinitionHelper.SEQUENTIALPROCESS); foreach (string f in files) { try { string prefix = Path.GetFileNameWithoutExtension(f); string name = prefix; int counter = 0; while (this.NameExists(name)) { counter++; name = prefix + counter; } SequentialProcessDefinition spd = (SequentialProcessDefinition)SequentialProcessDefinition.Serializer.Deserialize(File.OpenRead(f)); FdoSequentialProcess proc = new FdoSequentialProcess(spd); AddTask(name, proc); } catch { } } } }
/// <summary> /// Handles the file drop /// </summary> /// <param name="file">The file being dropped</param> public void HandleDrop(string file) { TaskManager mgr = ServiceManager.Instance.GetService<TaskManager>(); TaskLoader ldr = new TaskLoader(); string prefix = string.Empty; FdoBulkCopyOptions opt = ldr.BulkCopyFromXml(file, ref prefix, false); FdoBulkCopy cpy = new FdoBulkCopy(opt); string name = prefix; int counter = 0; while (mgr.NameExists(name)) { counter++; name = prefix + counter; } mgr.AddTask(name, cpy); }
/// <summary> /// Handles the file drop /// </summary> /// <param name="file">The file being dropped</param> public void HandleDrop(string file) { TaskManager mgr = ServiceManager.Instance.GetService<TaskManager>(); TaskLoader ldr = new TaskLoader(); SequentialProcessDefinition spd = (SequentialProcessDefinition)SequentialProcessDefinition.Serializer.Deserialize(File.OpenRead(file)); FdoSequentialProcess proc = new FdoSequentialProcess(spd); string prefix = Path.GetFileNameWithoutExtension(file); string name = prefix; int counter = 0; while (mgr.NameExists(name)) { counter++; name = prefix + counter; } mgr.AddTask(name, proc); }
private void btnSave_Click(object sender, EventArgs e) { if (mTreeView.Nodes[0].Nodes.Count == 0) { MessageService.ShowMessage("Please define at least one copy task"); return; } if (string.IsNullOrEmpty(txtName.Text)) { MessageService.ShowMessage("Please specify a name for this task"); return; } TaskManager tmgr = ServiceManager.Instance.GetService<TaskManager>(); if (IsNew && tmgr.GetTask(txtName.Text) != null) { MessageService.ShowMessage("A task named " + txtName.Text + " already exists. Please specify a name for this task"); return; } //This could take a while... using (new TempCursor(Cursors.WaitCursor)) { LoggingService.Info("Updating loaded task. Please wait."); TaskLoader loader = new TaskLoader(); if (IsNew) { string name = string.Empty; FdoBulkCopyOptions opts = loader.BulkCopyFromXml(Save(), ref name, false); FdoBulkCopy bcp = new FdoBulkCopy(opts); tmgr.AddTask(name, bcp); this.Close(); } else { FdoBulkCopy bcp = tmgr.GetTask(txtName.Text) as FdoBulkCopy; if (bcp == null) { MessageService.ShowMessage("This named task is not a bulk copy task or could not find the named task to update"); return; } string name = string.Empty; FdoBulkCopyOptions opts = loader.BulkCopyFromXml(Save(), ref name, false); Debug.Assert(name == txtName.Text); //unchanged //Update options bcp.Options = opts; MessageService.ShowMessage("Task updated. To save to disk, right-click the task object and choose: " + ResourceService.GetString("CMD_SaveTask")); this.Close(); } } }
public override void Run() { TaskManager mgr = ServiceManager.Instance.GetService<TaskManager>(); TaskLoader ldr = new TaskLoader(); string file = FileService.OpenFile(ResourceService.GetString("TITLE_LOAD_TASK"), ResourceService.GetString("FILTER_TASK_DEFINITION")); if (FileService.FileExists(file)) { using (new TempCursor(Cursors.WaitCursor)) { LoggingService.Info(ResourceService.GetString("LOADING_TASK_DEFINITION_WAIT")); if (TaskDefinitionHelper.IsBulkCopy(file)) { string name = string.Empty; FdoBulkCopyOptions opt = ldr.BulkCopyFromXml(file, ref name, false); FdoBulkCopy cpy = new FdoBulkCopy(opt); mgr.AddTask(name, cpy); } else if (TaskDefinitionHelper.IsJoin(file)) { string name = string.Empty; FdoJoinOptions opt = ldr.JoinFromXml(file, ref name, false); FdoJoin join = new FdoJoin(opt); mgr.AddTask(name, join); } else if (TaskDefinitionHelper.IsSequentialProcess(file)) { using (var fs = File.OpenRead(file)) { int counter = 0; var prefix = Path.GetFileNameWithoutExtension(file); var name = prefix; while (mgr.NameExists(name)) { counter++; name = prefix + counter; } var def = (SequentialProcessDefinition)SequentialProcessDefinition.Serializer.Deserialize(fs); var proc = new FdoSequentialProcess(def); mgr.AddTask(name, proc); } } } } }