Exemplo n.º 1
0
        public override void Run()
        {
            TreeNode    taskNode = Workbench.Instance.ObjectExplorer.GetSelectedNode();
            TaskManager mgr      = ServiceManager.Instance.GetService <TaskManager>();
            //EtlProcess proc = mgr.GetTask(taskNode.Name);
            FdoSpecializedEtlProcess proc = mgr.GetTask(taskNode.Name) as FdoSpecializedEtlProcess;

            if (proc != null)
            {
                if (proc is FdoBulkCopy)
                {
                    FdoBulkCopy    copy = proc as FdoBulkCopy;
                    FdoBulkCopyCtl ctl  = new FdoBulkCopyCtl(taskNode.Name, copy);
                    Workbench.Instance.ShowContent(ctl, ViewRegion.Document);
                }
                else if (proc is FdoJoin)
                {
                    FdoJoin    join = proc as FdoJoin;
                    FdoJoinCtl ctl  = new FdoJoinCtl(taskNode.Name, join);
                    Workbench.Instance.ShowContent(ctl, ViewRegion.Document);
                }
                else if (proc is FdoSequentialProcess)
                {
                    FdoSequentialProcess    seq = proc as FdoSequentialProcess;
                    FdoSequentialProcessCtl ctl = new FdoSequentialProcessCtl(taskNode.Name, seq.ProcessDefinition);
                    Workbench.Instance.ShowContent(ctl, ViewRegion.Document);
                }
                else
                {
                    MessageService.ShowError(ResourceService.GetString("ERR_NO_EDITOR_FOR_TASK"));
                }
            }
        }
Exemplo n.º 2
0
        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 { }
                }
            }
        }
Exemplo n.º 3
0
        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);
                        }
                    }
                }
            }
        }
        /// <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);
        }
Exemplo n.º 5
0
        /// <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);
        }
Exemplo n.º 6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            using (new TempCursor(Cursors.WaitCursor))
            {
                if (string.IsNullOrEmpty(txtName.Text))
                {
                    MessageService.ShowError("Name required");
                    return;
                }

                TaskManager tmgr = ServiceManager.Instance.GetService<TaskManager>();
                LoggingService.Info("Updating loaded task. Please wait.");
                List<SequentialOperation> ops = new List<SequentialOperation>();
                foreach (var obj in lstProcesses.Items)
                {
                    ops.Add((SequentialOperation)obj);
                }
                if (_def == null) //is new
                {
                    _def = new SequentialProcessDefinition();
                    foreach(var op in ops)
                    {
                        _def.AddOperation(op);
                    }
                    var proc = new FdoSequentialProcess(_def);
                    tmgr.AddTask(txtName.Text, proc);
                }
                else
                {
                    _def.ClearOperations();
                    foreach (var op in ops)
                    {
                        _def.AddOperation(op);
                    }
                }
                this.Close();
            }
        }
Exemplo n.º 7
0
        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);
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        public override int Execute()
        {
            CommandStatus    retCode;
            DefinitionLoader loader = new DefinitionLoader();
            string           name   = null;

            if (TaskDefinitionHelper.IsBulkCopy(_file))
            {
                FdoBulkCopyTaskDefinition def = null;
                using (var sr = new StreamReader(_file))
                {
                    XmlSerializer ser = new XmlSerializer(typeof(FdoBulkCopyTaskDefinition));
                    def = (FdoBulkCopyTaskDefinition)ser.Deserialize(sr);
                }

                if (def == null)
                {
                    return((int)CommandStatus.E_FAIL_TASK_VALIDATION);
                }

                //If more than one task specified, load the default task and weed
                //out unneeded elements.
                if (_taskNames.Length > 0)
                {
                    base.WriteLine("Certain tasks have been specified, only part of the bulk copy definition will execute");
                    var keepConnections = new Dictionary <string, FdoConnectionEntryElement>();
                    var keepTasks       = new List <FdoCopyTaskElement>();

                    //Store needed tasks
                    foreach (var task in def.CopyTasks)
                    {
                        if (Array.IndexOf(_taskNames, task.name) >= 0)
                        {
                            keepTasks.Add(task);
                        }
                    }

                    //Store needed connections
                    foreach (var task in keepTasks)
                    {
                        foreach (var conn in def.Connections)
                        {
                            //Is referenced as source/target connection?
                            if (task.Source.connection == conn.name || task.Target.connection == conn.name)
                            {
                                if (!keepConnections.ContainsKey(conn.name))
                                {
                                    keepConnections.Add(conn.name, conn);
                                }
                            }
                        }
                    }

                    if (keepTasks.Count != _taskNames.Length)
                    {
                        List <string> names = new List <string>();
                        foreach (var n in _taskNames)
                        {
                            bool found = false;
                            foreach (var task in keepTasks)
                            {
                                if (task.name == n)
                                {
                                    found = true;
                                    break;
                                }
                            }

                            if (!found)
                            {
                                names.Add(n);
                            }
                        }

                        base.WriteError("Could not find specified tasks in bulk copy definition: " + string.Join(",", names.ToArray()));

                        return((int)CommandStatus.E_FAIL_MISSING_BULK_COPY_TASKS);
                    }

                    //Now replace
                    def.Connections = new List <FdoConnectionEntryElement>(keepConnections.Values).ToArray();
                    def.CopyTasks   = keepTasks.ToArray();
                }

                using (FdoBulkCopyOptions opts = loader.BulkCopyFromXml(def, ref name, true))
                {
                    FdoBulkCopy copy = new FdoBulkCopy(opts);
                    copy.ProcessMessage += delegate(object sender, MessageEventArgs e)
                    {
                        base.WriteLine(e.Message);
                    };
                    copy.ProcessAborted += delegate(object sender, EventArgs e)
                    {
                        base.WriteLine("Bulk Copy Aborted");
                    };
                    copy.ProcessCompleted += delegate(object sender, EventArgs e)
                    {
                        base.WriteLine("Bulk Copy Completed");
                    };
                    copy.Execute();
                    List <Exception> errors = new List <Exception>(copy.GetAllErrors());
                    if (errors.Count > 0)
                    {
                        string file = GenerateLogFileName("bcp-error-");
                        LogErrors(errors, file);
                        base.WriteError("Errors were encountered during bulk copy.");
                        retCode = CommandStatus.E_FAIL_BULK_COPY_WITH_ERRORS;
                    }
                    else
                    {
                        retCode = CommandStatus.E_OK;
                    }
                }
            }
            else if (TaskDefinitionHelper.IsJoin(_file))
            {
                if (_taskNames.Length > 0)
                {
                    base.WriteError("Parameter -bcptask is not applicable for join tasks");
                    return((int)CommandStatus.E_FAIL_INVALID_ARGUMENTS);
                }

                using (FdoJoinOptions opts = loader.JoinFromXml(_file, ref name, true))
                {
                    opts.Left.Connection.Open();
                    opts.Right.Connection.Open();
                    opts.Target.Connection.Open();
                    FdoJoin join = new FdoJoin(opts);
                    join.ProcessMessage += delegate(object sender, MessageEventArgs e)
                    {
                        base.WriteLine(e.Message);
                    };
                    join.Execute();
                    List <Exception> errors = new List <Exception>(join.GetAllErrors());
                    if (errors.Count > 0)
                    {
                        string file = GenerateLogFileName("join-error-");
                        LogErrors(errors, file);
                        base.WriteError("Errors were encountered during join operation");
                        retCode = CommandStatus.E_FAIL_JOIN_WITH_ERRORS;
                    }
                    else
                    {
                        retCode = CommandStatus.E_OK;
                    }
                }
            }
            else if (TaskDefinitionHelper.IsSequentialProcess(_file))
            {
                var def  = (SequentialProcessDefinition)SequentialProcessDefinition.Serializer.Deserialize(File.OpenRead(_file));
                var proc = new FdoSequentialProcess(def);
                proc.ProcessMessage += delegate(object sender, MessageEventArgs e)
                {
                    base.WriteLine(e.Message);
                };
                proc.Execute();
                List <Exception> errors = new List <Exception>(proc.GetAllErrors());
                if (errors.Count > 0)
                {
                    string file = GenerateLogFileName("seq-process-");
                    LogErrors(errors, file);
                    base.WriteError("Errors were encountered during sequential process");
                }
                //Why E_OK? the user should check the log for the underlying return codes
                //of individual FdoUtil.exe invocations!
                retCode = CommandStatus.E_OK;
            }
            else
            {
                retCode = CommandStatus.E_FAIL_UNRECOGNISED_TASK_FORMAT;
            }

            return((int)retCode);
        }
Exemplo n.º 9
0
        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 { }
                }
            }
        }
Exemplo n.º 10
0
        public override int Execute()
        {
            CommandStatus retCode;
            DefinitionLoader loader = new DefinitionLoader();
            string name = null;
            if (TaskDefinitionHelper.IsBulkCopy(_file))
            {
                FdoBulkCopyTaskDefinition def = null;
                using (var sr = new StreamReader(_file))
                {
                    XmlSerializer ser = new XmlSerializer(typeof(FdoBulkCopyTaskDefinition));
                    def = (FdoBulkCopyTaskDefinition)ser.Deserialize(sr);
                }

                if (def == null)
                {
                    return (int)CommandStatus.E_FAIL_TASK_VALIDATION;
                }

                //If more than one task specified, load the default task and weed
                //out unneeded elements.
                if (_taskNames.Length > 0)
                {
                    base.WriteLine("Certain tasks have been specified, only part of the bulk copy definition will execute");
                    var keepConnections = new Dictionary<string, FdoConnectionEntryElement>();
                    var keepTasks = new List<FdoCopyTaskElement>();

                    //Store needed tasks
                    foreach (var task in def.CopyTasks)
                    {
                        if (Array.IndexOf(_taskNames, task.name) >= 0)
                        {
                            keepTasks.Add(task);
                        }
                    }

                    //Store needed connections
                    foreach (var task in keepTasks)
                    {
                        foreach (var conn in def.Connections)
                        {
                            //Is referenced as source/target connection?
                            if (task.Source.connection == conn.name || task.Target.connection == conn.name)
                            {
                                if (!keepConnections.ContainsKey(conn.name))
                                    keepConnections.Add(conn.name, conn);
                            }
                        }
                    }

                    if (keepTasks.Count != _taskNames.Length)
                    {
                        List<string> names = new List<string>();
                        foreach (var n in _taskNames)
                        {
                            bool found = false;
                            foreach (var task in keepTasks)
                            {
                                if (task.name == n)
                                {
                                    found = true;
                                    break;
                                }
                            }

                            if (!found)
                                names.Add(n);
                        }

                        base.WriteError("Could not find specified tasks in bulk copy definition: " + string.Join(",", names.ToArray()));

                        return (int)CommandStatus.E_FAIL_MISSING_BULK_COPY_TASKS;
                    }

                    //Now replace
                    def.Connections = new List<FdoConnectionEntryElement>(keepConnections.Values).ToArray();
                    def.CopyTasks = keepTasks.ToArray();
                }

                using (FdoBulkCopyOptions opts = loader.BulkCopyFromXml(def, ref name, true))
                {
                    FdoBulkCopy copy = new FdoBulkCopy(opts);
                    copy.ProcessMessage += delegate(object sender, MessageEventArgs e)
                    {
                        base.WriteLine(e.Message);
                    };
                    copy.ProcessAborted += delegate(object sender, EventArgs e)
                    {
                        base.WriteLine("Bulk Copy Aborted");
                    };
                    copy.ProcessCompleted += delegate(object sender, EventArgs e)
                    {
                        base.WriteLine("Bulk Copy Completed");
                    };
                    copy.Execute();
                    List<Exception> errors = new List<Exception>(copy.GetAllErrors());
                    if (errors.Count > 0)
                    {
                        string file = GenerateLogFileName("bcp-error-");
                        LogErrors(errors, file);
                        base.WriteError("Errors were encountered during bulk copy.");
                        retCode = CommandStatus.E_FAIL_BULK_COPY_WITH_ERRORS;
                    }
                    else { retCode = CommandStatus.E_OK; }
                }
            }
            else if (TaskDefinitionHelper.IsJoin(_file))
            {
                if (_taskNames.Length > 0)
                {
                    base.WriteError("Parameter -bcptask is not applicable for join tasks");
                    return (int)CommandStatus.E_FAIL_INVALID_ARGUMENTS;
                }

                using (FdoJoinOptions opts = loader.JoinFromXml(_file, ref name, true))
                {
                    opts.Left.Connection.Open();
                    opts.Right.Connection.Open();
                    opts.Target.Connection.Open();
                    FdoJoin join = new FdoJoin(opts);
                    join.ProcessMessage += delegate(object sender, MessageEventArgs e)
                    {
                        base.WriteLine(e.Message);
                    };
                    join.Execute();
                    List<Exception> errors = new List<Exception>(join.GetAllErrors());
                    if (errors.Count > 0)
                    {
                        string file = GenerateLogFileName("join-error-");
                        LogErrors(errors, file);
                        base.WriteError("Errors were encountered during join operation");
                        retCode = CommandStatus.E_FAIL_JOIN_WITH_ERRORS;
                    }
                    else { retCode = CommandStatus.E_OK; }
                }
            }
            else if (TaskDefinitionHelper.IsSequentialProcess(_file))
            {
                var def = (SequentialProcessDefinition)SequentialProcessDefinition.Serializer.Deserialize(File.OpenRead(_file));
                var proc = new FdoSequentialProcess(def);
                proc.ProcessMessage += delegate(object sender, MessageEventArgs e)
                {
                    base.WriteLine(e.Message);
                };
                proc.Execute();
                List<Exception> errors = new List<Exception>(proc.GetAllErrors());
                if (errors.Count > 0)
                {
                    string file = GenerateLogFileName("seq-process-");
                    LogErrors(errors, file);
                    base.WriteError("Errors were encountered during sequential process");
                }
                //Why E_OK? the user should check the log for the underlying return codes
                //of individual FdoUtil.exe invocations!
                retCode = CommandStatus.E_OK;
            }
            else
            {
                retCode = CommandStatus.E_FAIL_UNRECOGNISED_TASK_FORMAT;
            }

            return (int)retCode;
        }