/// <summary>
        /// Internals the find and queue.
        /// </summary>
        /// <param name="taskDescription">The task description.</param>
        /// <param name="descriptions">The descriptions.</param>
        /// <param name="queue">The queue.</param>
        /// <returns></returns>
        private static bool InternalFindAndQueue(
            TaskDescription taskDescription,
            Collection <TaskDescription> descriptions,
            Queue <TaskDescription> queue)
        {
            bool result = false;

            foreach (TaskDescription child in descriptions)
            {
                if (child.Equals(taskDescription))
                {
                    //queue.Enqueue(child);
                    return(true);
                }
                else
                {
                    result = InternalFindAndQueue(taskDescription, child.Children, queue);
                    if (result == true)
                    {
                        queue.Enqueue(child);
                        return(result);
                    }
                }
            }
            return(result);
        }
        /// <summary>
        /// Finds the and stack.
        /// </summary>
        /// <param name="taskDescription">The task description.</param>
        /// <param name="descriptions">The descriptions.</param>
        /// <param name="stack">The stack.</param>
        /// <returns></returns>
        private static bool FindAndStack(TaskDescription taskDescription,
                                         Collection <TaskDescription> descriptions,
                                         Stack <TaskDescription> stack)
        {
            bool result = false;

            foreach (TaskDescription child in descriptions)
            {
                if (child.Equals(taskDescription))
                {
                    stack.Push(child);
                    return(true);
                }
                else
                {
                    result = FindAndStack(taskDescription, child.Children, stack);
                    if (result == true)
                    {
                        stack.Push(child);
                        return(result);
                    }
                }
            }
            return(result);
        }
        /// <summary>
        /// Ancestorses the specified task description.
        /// </summary>
        /// <param name="taskDescription">The task description.</param>
        /// <returns></returns>
        public Queue <TaskDescription> Ancestors(TaskDescription taskDescription)
        {
            Queue <TaskDescription> ancestors = new Queue <TaskDescription>();

            InternalFindAndQueue(taskDescription, TaskDescriptions, ancestors);
            return(ancestors);
        }
        public void CellsTaskPostRunTaskTest()
        {
            // TODO uncomment below to test the method and replace null with proper value
            string name      = BOOK1;
            string sheetName = SHEET6;
            string folder    = TEMPFOLDER;

            UpdateDataFile(folder, name);

            TaskData taskData = new TaskData();

            taskData.Tasks = new List <TaskDescription>();
            TaskDescription task1 = new TaskDescription();

            task1.TaskType = "SplitWorkbook";

            SplitWorkbookTaskParameter param1 = new SplitWorkbookTaskParameter();

            param1.DestinationFileFormat                  = "xlsx";
            param1.DestinationFilePosition                = new FileSource();
            param1.DestinationFilePosition.FilePath       = TEMPFOLDER;
            param1.DestinationFilePosition.FileSourceType = "CloudFileSystem";
            param1.SplitNameRule           = "sheetname";
            param1.Workbook                = new FileSource();
            param1.Workbook.FileSourceType = "CloudFileSystem";
            param1.Workbook.FilePath       = TEMPFOLDER + "\\" + BOOK1;
            task1.TaskParameter            = param1;
            taskData.Tasks.Add(task1);
            var response = instance.CellsTaskPostRunTask(taskData);

            Assert.IsInstanceOf <System.IO.Stream>(response, "response is System.IO.Stream");
        }
 /// <summary>
 /// Handles the AfterSelect event of the _treeViewTaskDescriptions control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.Windows.Forms.TreeViewEventArgs"/> instance containing the event data.</param>
 private void _treeViewTaskDescriptions_AfterSelect(object sender, TreeViewEventArgs e)
 {
     //  ...it's worth noting here that the "Tag" property could also be an IList<>
     //  object, therefore setting the CrossTab value to null. This is the desired
     //  behaviour as only child nodes should be selected
     this._crossTab = e.Node.Tag as TaskDescription;
 }
Esempio n. 6
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     TaskName.Clear();
     TaskDescription.Clear();
     TaskDue.DisplayDate = DateTime.Now;
     taskPopUp.IsOpen    = true;
 }
        private void BuildTree(TaskDescription parent, TreeNode rootNode)
        {
            foreach (TaskDescription child in parent.Children)
            {
                if (child != null)
                {
                    TreeNode node = new TreeNode(child.Name)
                    {
                        Tag         = child,
                        ToolTipText = child.Description
                    };
                    rootNode.Nodes.Add(node);
                    if (child.Children != null)
                    {
                        if (child.Children.Count > 0)
                        {
                            BuildTree(child, node);
                        }
                    }

                    if ((_currentTaskDescription != null) && (_currentTaskDescription.Id == child.Id))
                    {
                        _currentNode = node;
                    }
                }
            }
        }
        /// <summary>
        /// Appends the task descriptions to node.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="descriptions">The descriptions.</param>
        private void AppendTaskDescriptionsToNode(TreeNode parent, IEnumerable descriptions)
        {
            TaskActivity    currentActivity    = AppContext.Current.CurrentActivity;
            TaskDescription currentDescription =
                (currentActivity != null) ? currentActivity.TaskDescription : null;

            parent.Nodes.Clear();
            foreach (TaskDescription description in descriptions)
            {
                TreeNode node = new TreeNode(description.Name);
                parent.Nodes.Add(node);

                node.Tag         = description;
                node.ToolTipText = description.Description;
                if (description.IsEvent)
                {
                    node.NodeFont = new Font(this.Font, FontStyle.Italic);
                }
                if (description.Name == currentDescription.Name)
                {
                    node.NodeFont  = new Font(this.Font, FontStyle.Strikeout);
                    node.ForeColor = SystemColors.InactiveCaptionText;
                }
            }
        }
Esempio n. 9
0
        public async Task <IActionResult> AddTaskAsync([FromBody] TaskDescription task)
        {
            try
            {
                var addResult = await _taskService.AddTaskAsync(task.Description);

                switch (addResult.Status)
                {
                case StatusEnum.Ok:
                    return(Created("task", addResult.Task));

                case StatusEnum.Duplicated:
                    return(StatusCode(409, addResult.Error.ErrorMessage));

                case StatusEnum.InvalidParamater:
                    return(BadRequest(addResult.Error.ErrorMessage));

                default:
                    return(StatusCode(500));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message, ex.InnerException, $"Class={ nameof(TaskController) }", $"Method={ nameof(AddTaskAsync) }");
                throw;
            }
        }
 private void InsertItemInList(TaskDescription taskDescription)
 {
     if (!_exportList.Contains(taskDescription))
     {
         _exportList.Add(taskDescription);
     }
 }
Esempio n. 11
0
        /// <summary>
        /// </summary>
        protected sealed override void OnStarted()
        {
            _taskDescriptionClear = AppCore.Get <TaskSchedulingManager>().RegisterTask(new TaskRequest()
            {
                Name      = "Менеджер сообщений: очистка старых записей",
                IsEnabled = true,
                UniqueKey = typeof(MessagingManager).FullName + "_ClearLastNDays",
                Schedules = new List <TaskSchedule>()
                {
                    new TaskCronSchedule(Cron.Hourly())
                    {
                        IsEnabled = true
                    }
                },
                ExecutionLambda = () => ClearLastNDays(),
                TaskOptions     = TaskOptions.AllowDisabling | TaskOptions.AllowManualSchedule | TaskOptions.PreventParallelExecution
            });

            // Попытка инициализировать все сервисы обработки сообщений, наследующиеся от IMessagingService.
            var types = AppCore.GetQueryTypes().Where(x => x.GetInterfaces().Contains(typeof(IMessagingServiceInternal))).ToList();

            foreach (var type in types)
            {
                try
                {
                    var instance = AppCore.Get <IMessagingServiceInternal>(type);
                    if (instance != null && !_services.Contains(instance))
                    {
                        _services.Add(instance);
                    }
                }
                catch { }
            }
        }
        public void CellsTaskPostRunTaskTest()
        {
            string name      = "Book1.xlsx";
            string sheetName = "SHEET6";
            string folder    = null;

            new Config().UpdateDataFile(folder, name);

            TaskData taskData = new TaskData();

            taskData.Tasks = new List <TaskDescription>();
            TaskDescription task1 = new TaskDescription();

            task1.TaskType = "SplitWorkbook";

            SplitWorkbookTaskParameter param1 = new SplitWorkbookTaskParameter();

            param1.DestinationFileFormat                  = "xlsx";
            param1.DestinationFilePosition                = new FileSource();
            param1.DestinationFilePosition.FilePath       = null;
            param1.DestinationFilePosition.FileSourceType = "CloudFileSystem";
            param1.SplitNameRule           = "sheetname";
            param1.Workbook                = new FileSource();
            param1.Workbook.FileSourceType = "CloudFileSystem";
            param1.Workbook.FilePath       = "Book1.xlsx";
            task1.TaskParameter            = param1;
            taskData.Tasks.Add(task1);
            var response = instance.CellsTaskPostRunTask(taskData);

            Console.WriteLine(response);
        }
Esempio n. 13
0
 /// <summary>
 /// Inserts the item in list.
 /// </summary>
 /// <param name="taskDescription">The task description.</param>
 private void InsertItemInList(TaskDescription taskDescription)
 {
     if (!_taskDescriptions.Contains(taskDescription))
     {
         _taskDescriptions.Add(taskDescription);
     }
 }
Esempio n. 14
0
        void LoadUsingTasks(ProjectInstance projectInstance, ProjectRootElement project)
        {
            Func <string, bool> cond = s => projectInstance != null?projectInstance.EvaluateCondition(s) : Convert.ToBoolean(s);

            foreach (var ut in project.UsingTasks)
            {
                var ta = assemblies.FirstOrDefault(a => a.AssemblyFile.Equals(ut.AssemblyFile, StringComparison.OrdinalIgnoreCase) || a.AssemblyName.Equals(ut.AssemblyName, StringComparison.OrdinalIgnoreCase));
                if (ta == null)
                {
                    ta = new TaskAssembly()
                    {
                        AssemblyName = ut.AssemblyName, AssemblyFile = ut.AssemblyFile
                    };
                    ta.LoadedAssembly = ta.AssemblyName != null?Assembly.Load(ta.AssemblyName) : Assembly.LoadFile(ta.AssemblyFile);

                    assemblies.Add(ta);
                }
                var pg = ut.ParameterGroup == null ? null : ut.ParameterGroup.Parameters.Select(p => new TaskPropertyInfo(p.Name, Type.GetType(p.ParameterType), cond(p.Output), cond(p.Required)))
                         .ToDictionary(p => p.Name);
                var task = new TaskDescription()
                {
                    TaskAssembly          = ta,
                    Name                  = ut.TaskName,
                    TaskFactoryType       = string.IsNullOrEmpty(ut.TaskFactory) ? null : LoadTypeFrom(ta.LoadedAssembly, ut.TaskName, ut.TaskFactory),
                    TaskType              = string.IsNullOrEmpty(ut.TaskFactory) ? LoadTypeFrom(ta.LoadedAssembly, ut.TaskName, ut.TaskName) : null,
                    TaskFactoryParameters = pg,
                    TaskBody              = ut.TaskBody != null && cond(ut.TaskBody.Condition) ? ut.TaskBody.Evaluate : null,
                };
                task_descs.Add(task);
            }
        }
Esempio n. 15
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            DBConnect.Conecta_Banco(this);
            Bitmap          bm    = BitmapFactory.DecodeResource(Resources, Resource.Drawable.Icon);
            TaskDescription tDesc = new TaskDescription("Class Pad", bm, Color.Rgb(141, 195, 239));

            SetTaskDescription(tDesc);
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Main);

            var toolbar = FindViewById <Toolbar>(Resource.Id.sstoolbar);

            SetActionBar(toolbar);

            ActionBar.SetIcon(Resource.Drawable.portinari);
            toolbar.SetTitleTextColor(Color.Rgb(140, 118, 123));
            toolbar.InflateMenu(Resource.Menu.home);


            bottomNavigation = FindViewById <BottomNavigationView>(Resource.Id.bottom_navigation);
            BottomNavigationViewHelper.SetShiftMode(bottomNavigation, false, false);

            bottomNavigation.NavigationItemSelected += BottomNavigation_NavigationItemSelected;
            LoadFragment(Resource.Id.action_add);
        }
Esempio n. 16
0
        void ReleaseDesignerOutlets()
        {
            if (ChildTease != null)
            {
                ChildTease.Dispose();
                ChildTease = null;
            }

            if (StartButton != null)
            {
                StartButton.Dispose();
                StartButton = null;
            }

            if (TaskDescription != null)
            {
                TaskDescription.Dispose();
                TaskDescription = null;
            }

            if (TaskType != null)
            {
                TaskType.Dispose();
                TaskType = null;
            }

            if (TaskTypeIcon != null)
            {
                TaskTypeIcon.Dispose();
                TaskTypeIcon = null;
            }
        }
Esempio n. 17
0
        public async Task <IActionResult> Edit(int id, [Bind("TaskDescriptionID,Task_name")] TaskDescription taskDescription)
        {
            if (id != taskDescription.TaskDescriptionID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(taskDescription);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TaskDescriptionExists(taskDescription.TaskDescriptionID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(taskDescription));
        }
Esempio n. 18
0
        /// <summary>
        ///   Reads an unknown task from xml and tries to capsule it into a ReferenceTask object. If no task description for the task type was found, null is returned.
        /// </summary>
        /// <param name="reader"> Xml reader. </param>
        /// <param name="availableTaskDescriptions"> Available task descriptions. </param>
        /// <returns> Reference task which capsules the unknown task; null if no task description for the type of the unknown task was found. </returns>
        public static ReferenceTask ReadUnknownTask(XmlReader reader, TaskDescriptionSet availableTaskDescriptions)
        {
            string typeString = reader.GetAttribute("type");

            TaskDescription taskDescription =
                availableTaskDescriptions.Descriptions.Find(description => description.TypeName == typeString);

            if (taskDescription == null)
            {
                reader.Skip();
                return(null);
            }

            ReferenceTask referenceTask = new ReferenceTask {
                TaskDescription = taskDescription
            };

            if (reader.IsEmptyElement)
            {
                reader.Skip();
                return(referenceTask);
            }

            reader.ReadStartElement();
            referenceTask.ReadXml(reader);
            reader.ReadEndElement();

            return(referenceTask);
        }
        public ActionResult Upload(HttpPostedFileBase attachment)
        {
            if (!ModelState.IsValid)
            {
                return(JsonValidationError());
            }

            if (attachment == null)
            {
                return(JsonError("Cannot find the product specified."));
            }

            var fullname = Server.MapPath("~/App_Data/Temp/") + attachment.FileName;

            attachment.SaveAs(fullname);

            var task = new TaskDescription("Products importing from", attachment.FileName);

            TaskManager.AddTask(task);

            Task.Factory.StartNew(() =>
            {
                ProductsImportService.ImportProductsFromExcelFile(fullname, new ApplicationDbContext(), task);
            });

            return(RedirectToAction <ProductController>(c => c.Table()).WithSuccess("Products file uploaded!"));
        }
Esempio n. 20
0
        void ReleaseDesignerOutlets()
        {
            if (EditButton != null)
            {
                EditButton.Dispose();
                EditButton = null;
            }

            if (TaskDescription != null)
            {
                TaskDescription.Dispose();
                TaskDescription = null;
            }

            if (TaskType != null)
            {
                TaskType.Dispose();
                TaskType = null;
            }

            if (TaskTypeIcon != null)
            {
                TaskTypeIcon.Dispose();
                TaskTypeIcon = null;
            }

            if (ManageChildrenButton != null)
            {
                ManageChildrenButton.Dispose();
                ManageChildrenButton = null;
            }
        }
Esempio n. 21
0
        /// <summary>
        /// See http://taskscheduler.codeplex.com/ for help on using the TaskService wrapper library.
        /// </summary>
        /// <param name="context"></param>
        protected override void Execute(CodeActivityContext context)
        {
            try
            {
                using (TaskService ts = new TaskService())
                {
                    TaskDefinition td = ts.NewTask();
                    td.RegistrationInfo.Description = TaskDescription.Get(context);
                    var triggers = Triggers.Get(context);
                    if (triggers != null)
                    {
                        triggers.ToList().ForEach(t => td.Triggers.Add(t));
                    }
                    td.Actions.Add(new ExecAction(FileName.Get(context), Arguments.Get(context), WorkingDirectory.Get(context)));

                    string username = Username.Get(context);
                    string password = Password.Get(context);
                    if (string.IsNullOrEmpty(username))
                    {
                        username = WindowsIdentity.GetCurrent().Name;
                    }

                    ts.RootFolder.RegisterTaskDefinition(
                        TaskName.Get(context),
                        td,
                        TaskCreation.CreateOrUpdate,
                        username,
                        password);
                }
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// Internals the find top most frequently used.
        /// </summary>
        /// <param name="maximum">The maximum.</param>
        /// <returns></returns>
        internal TaskDescription[] InternalFindTopMostFrequentlyUsed(int maximum)
        {
            TaskDescriptionsProvider provider  = this.Engine.TaskDescriptionsProvider;
            List <TaskDescription>   localList = new List <TaskDescription>(maximum);

            //  ...sort by usage
            MostRecentlyUsedItem[] items = this._items.ToArray();
            Array.Sort(items, MostRecentlyUsedItem.UsageComparer);

            foreach (MostRecentlyUsedItem mruItem in items)
            {
                TaskDescription description = provider.FindDescription(mruItem.Id);
                if (description != null)
                {
                    localList.Add(description);
                }

                if (localList.Count == maximum)
                {
                    break;
                }
            }

            return(localList.ToArray());
        }
Esempio n. 23
0
 /// <summary>
 /// Removes the item from list.
 /// </summary>
 /// <param name="taskDescription">The task description.</param>
 private void RemoveItemFromList(TaskDescription taskDescription)
 {
     if (_taskDescriptions.Contains(taskDescription))
     {
         _taskDescriptions.Remove(taskDescription);
     }
 }
        void ReleaseDesignerOutlets()
        {
            if (TaskTypeIcon != null)
            {
                TaskTypeIcon.Dispose();
                TaskTypeIcon = null;
            }

            if (TaskTypeName != null)
            {
                TaskTypeName.Dispose();
                TaskTypeName = null;
            }

            if (TaskDescription != null)
            {
                TaskDescription.Dispose();
                TaskDescription = null;
            }

            if (FinishButton != null)
            {
                FinishButton.Dispose();
                FinishButton = null;
            }
        }
 private void RemoveItemFromList(TaskDescription taskDescription)
 {
     if (_exportList.Contains(taskDescription))
     {
         _exportList.Remove(taskDescription);
     }
 }
 /// <summary>
 /// When overridden in a provider, adds a description.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="description">The description.</param>
 protected override void ProviderAddDescription(TaskDescription parent, TaskDescription description)
 {
     Collection<TaskDescription> descriptions = ProviderLoadDescriptions();
     TaskDescription foundParent = FindChildInHierarchy(descriptions, parent);
     foundParent.Children.Add(description);
     ProviderSaveDescriptions(descriptions);
 }
        /// <summary>
        /// Uses the description handler.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void UseDescriptionHandler(object sender, EventArgs e)
        {
            if (listViewTaskDescriptions.SelectedItems.Count > 0)
            {
                ListViewItem    item        = listViewTaskDescriptions.SelectedItems[0];
                TaskDescription description = (TaskDescription)item.Tag;

                if (this._isAdvancedMode)
                {
                    AdvancedSelectDialog dialog = new AdvancedSelectDialog(description);
                    if (dialog.ShowDialog(this) == DialogResult.OK)
                    {
                        AppContext.Current.HandleNewTaskActivity(
                            dialog.Current,
                            dialog.CrossTab,
                            dialog.StartTime);

                        Close();
                    }
                }
                else
                {
                    AppContext.Current.HandleNewTaskActivity(description, DateTime.Now);
                    Close();
                }
            }
        }
 private void InsertItemInList(TaskDescription taskDescription)
 {
     if (!_exportList.Contains(taskDescription))
     {
         _exportList.Add(taskDescription);
     }
 }
Esempio n. 29
0
    public void SubmitTask(TaskDescription taskDescription)
    {
        // Simulate some work with a delay.
        Thread.Sleep(TimeSpan.FromSeconds(15));

        // Reverse the letters in string.
        char[] data = taskDescription.DataToProcess.ToCharArray();
        Array.Reverse(data);

        // Prepare the response.
        TaskResult result = new TaskResult();

        result.ProcessedData = new string(data);

        // Send the response to the client.
        try
        {
            IAsyncTaskClient client = OperationContext.Current.GetCallbackChannel <IAsyncTaskClient>();
            client.ReturnResult(result);
        }
        catch
        {
            // The client could not be contacted.
            // Clean up any resources here before the thread ends.
        }
        // Incidentally, you can call the client.ReturnResult() method mulitple times to
        // return different pieces of data at different times.
        // The connection remains available until the reference is released (when the method
        // ends and the variable goes out of scope).
    }
        private void TaskDescriptionsExplorer_Load(object sender, EventArgs e)
        {
            treeView.Font     = (Font)AppContext.Current.SettingsProvider.Get("GeneralFont", Font);
            propertyGrid.Font = (Font)AppContext.Current.SettingsProvider.Get("GeneralFont", Font);

            //clear the context variable
            AppContext.Current.SettingsProvider.Set(
                "SelectedTaskDescription",
                TaskDescription.Empty,
                PersistHint.AcrossSessions);

            TaskActivity currentTaskactivity =
                (TaskActivity)AppContext.Current.SettingsProvider.Get("CurrentActivity", TaskActivity.Empty);

            if (currentTaskactivity.IsNotEmpty())
            {
                _currentTaskDescription = currentTaskactivity.TaskDescription;
            }

            // Set Owner Draw Mode to Text
            if ((null == Site) || (!Site.DesignMode))
            {
                if ((bool)AppContext.Current.SettingsProvider.Get("Advanced Draw on Descriptions Tree", true))
                {
                    treeView.DrawMode = TreeViewDrawMode.OwnerDrawText;
                }
            }
            ReBuildTree(AppContext.Current.TaskDescriptionsProvider.TaskDescriptions);

            buttonUse.Visible = !(bool)AppContext.Current.SettingsProvider.Get("HideUseButton", false);

            Activate();
        }
Esempio n. 31
0
 /// <summary>
 /// Builds the tree.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <param name="rootNode">The root node.</param>
 private void BuildTree(TaskDescription parent, TreeNode rootNode)
 {
     foreach (TaskDescription child in parent.Children)
     {
         TreeNode node = new TreeNode(child.Name)
         {
             Tag         = child,
             ToolTipText = child.Description
         };
         if (comboboxScheme.SelectedIndex == 0)
         {
             node.Checked = !child.IsPrivate;
         }
         if (comboboxScheme.SelectedIndex == 2)
         {
             node.Checked = true;
         }
         if (node.Checked)
         {
             _taskDescriptions.Add(child);
         }
         rootNode.Nodes.Add(node);
         if (child.Children.Count > 0)
         {
             BuildTree(child, node);
         }
     }
 }
 /// <summary>
 /// When overridden in a provider, adds a description.
 /// </summary>
 /// <param name="taskDescription">The task description.</param>
 /// <param name="parent">The parent.</param>
 protected override void ProviderAddDescription(TaskDescription taskDescription, TaskDescription parent)
 {
     using (SqlConnection connection = new SqlConnection(_connectionString))
     {
         connection.Open();
         SaveToDb(connection, taskDescription, parent);
     }
 }
Esempio n. 33
0
 public void AddTaskDescription(TaskDescription td)
 {
     using (DatabaseContext ctx = new DatabaseContext())
     {
         ctx.TaskDescDB.Add(td);
         ctx.SaveChanges();
     }
 }
Esempio n. 34
0
 public ToDoOptions(ToDoOptions fromOptions)
 {
     if (fromOptions != null)
     {
         _reminderStrings = fromOptions.ReminderStrings;
         _groupStrings = fromOptions.GroupStrings;
         _defaultTaskDescription = fromOptions.DefaultTaskDescription;
     }
 }
Esempio n. 35
0
 /// <summary>
 /// This method get handed the start and end date selected by the exporter user
 /// and a copy of all the TaskActivities that fit into the users export selection
 /// and a copy of all the TaskDescriptions the export user selected
 /// </summary>
 /// <param name="startDate"></param>
 /// <param name="endDate"></param>
 /// <param name="taskActivities"></param>
 /// <param name="taskDescriptions"></param>
 public void AcceptData(DateTime startDate,
                        DateTime endDate, TaskActivity[] taskActivities,
                        TaskDescription[] taskDescriptions)
 {
     _startDate = startDate;
     _endDate = endDate;
     _taskActivities = taskActivities;
     _taskDescriptions = taskDescriptions;
 }
Esempio n. 36
0
 public ToDoOptions()
 {
     if (string.IsNullOrEmpty(_reminderStrings))
     {
         _reminderStrings = "Start by;End by;Should Start by;Should End by;Milestone;None";
     }
     if (string.IsNullOrEmpty(_groupStrings))
     {
         _groupStrings = "Over Due;Due Today;Due in the future, No due date";
     }
     _defaultTaskDescription = TaskDescription.Empty;
 }
 private void BuildTree(TaskDescription parent, TreeNode rootNode)
 {
     foreach (TaskDescription child in parent.Children)
     {
         TreeNode node = new TreeNode(child.Name);
         node.Tag = child;
         node.ToolTipText = child.Description;
         node.Checked = !child.IsPrivate;
         if (node.Checked)
         {
             _exportList.Add(child);
         }
         rootNode.Nodes.Add(node);
         if (child.Children.Count > 0)
         {
             BuildTree(child, node);
         }
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NewTaskDescriptionDialog"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 public NewTaskDescriptionDialog(TaskDescription parent)
 {
     InitializeComponent();
     _taskDescription = new TaskDescription();
     _taskDescription.Color = Color.Black;
     _taskDescription.Name = string.Empty;
     _taskDescription.NoNagMinutes = 0;
     if (parent != null)
     {
         this.buttonColorPicker.BackColor = Color.FromArgb(parent.Color.A - 2, parent.Color);
         this.textBoxColour.Text = TaskDescription.SerializeColor(this.buttonColorPicker.BackColor);
         this.maskedTextBoxNoNagMins.Text = parent.NoNagMinutes.ToString();
     }
     else
     {
         this.buttonColorPicker.BackColor = Color.FromArgb(Color.Black.A - 2, Color.Black);
         this.textBoxColour.Text = TaskDescription.SerializeColor(this.buttonColorPicker.BackColor);
         this.maskedTextBoxNoNagMins.Text = "0";
     }
 }
        private void AddNewTaskDescription(object sender, EventArgs e)
        {
            if (treeView.SelectedNode != null)
            {
                NewTaskDescriptionDialog ntdd
                    = new NewTaskDescriptionDialog(treeView.SelectedNode.Tag as TaskDescription);
                if (ntdd.ShowDialog(this) == DialogResult.OK)
                {
                    TaskDescription taskDescription = new TaskDescription();
                    taskDescription.Id = Guid.NewGuid();
                    taskDescription.Name = ntdd.TaskDescription.Name;
                    taskDescription.Color = ntdd.TaskDescription.Color;
                    taskDescription.NoNagMinutes = ntdd.TaskDescription.NoNagMinutes;
                    taskDescription.IsEvent = false;

                    TreeNode treeNode = new TreeNode(taskDescription.Name);
                    treeNode.Tag = taskDescription;
                    if ((treeView.SelectedNode.Tag != null) &&
                        (treeView.SelectedNode.Tag.GetType() == typeof(TaskDescription)))
                    {
                        TaskDescription td = treeView.SelectedNode.Tag as TaskDescription;
                        if (td != null)
                        {
                            td.Children.Add(taskDescription);
                            treeView.SelectedNode.Nodes.Add(treeNode);
                            treeView.SelectedNode = treeNode;
                        }
                    }
                    else
                    {
                        treeView.Nodes[0].Nodes.Add(treeNode);
                        treeView.SelectedNode = treeNode;
                        ((Collection<TaskDescription>)treeView.Nodes[0].Tag).Add(taskDescription);
                    }
                    AppContext.Current.TaskDescriptionsProvider.SaveDescriptions();
                }
            }
        }
 /// <summary>
 /// Finds the specified name.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <returns></returns>
 public TaskDescription FindDescription(string name)
 {
     TaskDescription test = new TaskDescription();
     test.Name = name;
     test = InternalFindByName(test, TaskDescriptions);
     if (test == null)
     {
         test = TaskDescription.UnknownTaskDescription;
     }
     return test;
 }
 /// <summary>
 /// Removes the item.
 /// </summary>
 /// <param name="description">The description.</param>
 public void RemoveDescription(TaskDescription description)
 {
     TaskDescription parent = null;
     foreach(TaskDescription child in TaskDescriptions)
     {
         parent = FindParentInHierarchy(child, description);
         if (parent != null)
         {
             break;
         }
     }
     if (parent != null)
     {
         TaskDescriptionEventArgs tdea = new TaskDescriptionEventArgs(description, parent);
         OnRemovingItemEvent(tdea);
         if (tdea.Cancel == false)
         {
             parent.Children.Remove(description);
             ProviderRemoveDescription(description);
         }
         OnTaskDescriptionsChangedEvent(EventArgs.Empty);
     }
 }
        private void BuildTree(TaskDescription parent, TreeNode rootNode)
        {
            foreach (TaskDescription child in parent.Children)
            {
                if (child != null)
                {
                    TreeNode node = new TreeNode(child.Name);
                    node.Tag = child;
                    node.ToolTipText = child.Description;
                    rootNode.Nodes.Add(node);
                    if (child.Children != null)
                    {
                        if (child.Children.Count > 0)
                        {
                            BuildTree(child, node);
                        }
                    }

                    if ((_currentTaskDescription != null) && (_currentTaskDescription.Id == child.Id))
                    {
                        _currentNode = node;
                    }
                }
            }
        }
 /// <summary>
 /// Handles the AfterSelect event of the _treeViewTaskDescriptions control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.Windows.Forms.TreeViewEventArgs"/> instance containing the event data.</param>
 private void _treeViewTaskDescriptions_AfterSelect(object sender, TreeViewEventArgs e)
 {
     //  ...it's worth noting here that the "Tag" property could also be an IList<>
     //  object, therefore setting the CrossTab value to null. This is the desired
     //  behaviour as only child nodes should be selected
     this._crossTab = e.Node.Tag as TaskDescription;
 }
Esempio n. 44
0
 private void InsertItemInList(TaskDescription taskDescription)
 {
     if (!_taskDescriptions.Contains(taskDescription))
     {
         _taskDescriptions.Add(taskDescription);
     }
     labelTaskDescriptionsCount.Text = string.Format("{0} TaskDescriptions selected.", _taskDescriptions.Count);
 }
Esempio n. 45
0
 private void RemoveItemFromList(TaskDescription taskDescription)
 {
     if (_taskDescriptions.Contains(taskDescription))
     {
         _taskDescriptions.Remove(taskDescription);
     }
     labelTaskDescriptionsCount.Text = string.Format("{0} TaskDescriptions selected.", _taskDescriptions.Count);
 }
 /// <summary>
 /// Internals the find and queue.
 /// </summary>
 /// <param name="taskDescription">The task description.</param>
 /// <param name="descriptions">The descriptions.</param>
 /// <param name="queue">The queue.</param>
 /// <returns></returns>
 private static bool InternalFindAndQueue(
     TaskDescription taskDescription,
     Collection<TaskDescription> descriptions,
     Queue<TaskDescription> queue)
 {
     bool result = false;
     foreach (TaskDescription child in descriptions)
     {
         if (child.Equals(taskDescription))
         {
             //queue.Enqueue(child);
             return true;
         }
         else
         {
             result = InternalFindAndQueue(taskDescription, child.Children, queue);
             if (result == true)
             {
                 queue.Enqueue(child);
                 return result;
             }
         }
     }
     return result;
 }
Esempio n. 47
0
 private void BuildTree(TaskDescription parent, TreeNode rootNode)
 {
     foreach (TaskDescription child in parent.Children)
     {
         TreeNode node = new TreeNode(child.Name);
         node.Tag = child;
         node.ToolTipText = child.Description;
         if (comboboxScheme.SelectedIndex == 0)
         {
             node.Checked = !child.IsPrivate;
         }
         if (comboboxScheme.SelectedIndex == 2)
         {
             node.Checked = true;
         }
         if (node.Checked)
         {
             _taskDescriptions.Add(child);
         }
         rootNode.Nodes.Add(node);
         if (child.Children.Count > 0)
         {
             BuildTree(child, node);
         }
     }
 }
 /// <summary>
 /// Saves the description hierarchy.
 /// </summary>
 /// <param name="connection">The connection.</param>
 /// <param name="child">The child.</param>
 /// <param name="parent">The parent.</param>
 private void SaveDescriptionHierarchy(SqlConnection connection, TaskDescription child, TaskDescription parent)
 {
     SaveToDb(connection, child, parent);
     if (child.Children.Count > 0)
     {
         foreach (TaskDescription td in child.Children)
         {
             SaveDescriptionHierarchy(connection, td, child);
         }
     }
 }
 /// <summary>
 /// Saves to db.
 /// </summary>
 /// <param name="connection">The connection.</param>
 /// <param name="description">The description.</param>
 /// <param name="parent">The parent.</param>
 private void SaveToDb(SqlConnection connection, TaskDescription description, TaskDescription parent)
 {
     SqlCommand command = new SqlCommand(saveDescriptionStatement, connection);
     command.CommandType = System.Data.CommandType.StoredProcedure;
     command.Parameters.AddWithValue("@UserId", Engine.IdentityProvider.Principal.Identity.Name);
     command.Parameters.AddWithValue("@Id", description.Id);
     if (parent != null)
     {
         command.Parameters.AddWithValue("@ParentId", parent.Id);
     }
     command.Parameters.AddWithValue("@Name", description.Name);
     if (description.Description != null)
     {
         command.Parameters.AddWithValue("@Description", description.Description);
     }
     command.Parameters.AddWithValue("@NoNagMinutes", description.NoNagMinutes);
     command.Parameters.AddWithValue("@Colour", description.Colour);
     command.Parameters.AddWithValue("@Sequence", description.Sequence);
     command.Parameters.AddWithValue("@CustomFlags", description.CustomFlags);
     command.Parameters.AddWithValue("@IsPrivate", description.IsPrivate);
     command.Parameters.AddWithValue("@IsCategory", description.IsCategory);
     command.Parameters.AddWithValue("@IsEvent", description.IsEvent);
     if (description.GroupName != null)
     {
         command.Parameters.AddWithValue("@GroupName", description.GroupName);
     }
     command.Parameters.AddWithValue("@MenuColumn", description.MenuColumn);
     command.Parameters.AddWithValue("@Url", description.Url);
     if (description.Server != null)
     {
         command.Parameters.AddWithValue("@Server", description.Server);
     }
     if (description.ValidFromDate != DateTime.MinValue)
     {
         command.Parameters.AddWithValue("@ValidFromDate", description.ValidFromDate);
     }
     if (description.ValidToDate != DateTime.MinValue)
     {
         command.Parameters.AddWithValue("@ValidToDate", description.ValidToDate);
     }
     command.Parameters.AddWithValue("@Enabled", description.Enabled);
     command.ExecuteScalar();
 }
 /// <summary>
 /// Froms the db reader.
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <returns></returns>
 private void FromDbReader(SqlDataReader reader, Collection<TaskDescription> descriptions)
 {
     TaskDescription td = new TaskDescription();
     td.Id = reader.GetGuid(0);
     td.Name = reader.GetString(2);
     if (!reader.IsDBNull(3))
     {
         td.Description = reader.GetString(3);
     }
     td.NoNagMinutes = reader.GetInt32(4);
     td.Colour = reader.GetString(5);
     td.Sequence = reader.GetInt32(6);
     td.CustomFlags = reader.GetInt32(7);
     td.IsPrivate = reader.GetBoolean(8);
     td.IsCategory = reader.GetBoolean(9);
     td.IsEvent = reader.GetBoolean(10);
     if (!reader.IsDBNull(11))
     {
         td.GroupName = reader.GetString(11);
     }
     td.MenuColumn = reader.GetInt32(12);
     if (!reader.IsDBNull(13))
     {
         td.Url = reader.GetString(13);
     }
     if (!reader.IsDBNull(14))
     {
         td.Server = reader.GetString(14);
     }
     if (!reader.IsDBNull(15))
     {
         td.ValidFromDate = reader.GetDateTime(15);
     }
     if (!reader.IsDBNull(16))
     {
         td.ValidToDate = reader.GetDateTime(16);
     }
     td.Enabled = reader.GetBoolean(17);
     if (!reader.IsDBNull(1))
     {
         Guid parentId = reader.GetGuid(1);
         TaskDescription parent = TaskDescriptionsProvider.FindChildInHierarchy(descriptions, parentId);
         if (parent != null)
         {
             parent.Children.Add(td);
         }
     }
     else
     {
         descriptions.Add(td);
     }
 }
        /// <summary>
        /// When overridden in a provider, removes a description.
        /// </summary>
        /// <param name="taskDescription">The task description.</param>
        protected override void ProviderRemoveDescription(TaskDescription taskDescription)
        {
            if (taskDescription == null)
            {
                throw new ArgumentNullException("taskDescription");
            }

            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();
                SqlCommand command = new SqlCommand(removeDescriptionStatement, connection);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@UserId", Engine.IdentityProvider.Principal.Identity.Name);
                command.Parameters.AddWithValue("@Id", taskDescription.Id);
                command.ExecuteScalar();
            }
        }
 /// <summary>
 /// Internals the find by id.
 /// </summary>
 /// <param name="test">The test.</param>
 /// <param name="taskDescriptions">The task descriptions.</param>
 /// <returns></returns>
 private static TaskDescription InternalFindById(
     TaskDescription test, Collection<TaskDescription> taskDescriptions)
 {
     TaskDescription result = null;
     foreach (TaskDescription child in taskDescriptions)
     {
         if (result != null)
         {
             return result;
         }
         else
         {
             if (child.Id == test.Id)
             {
                 return child;
             }
             result = InternalFindById(test, child.Children);
         }
     }
     return result;
 }
 /// <summary>
 /// Finds a TaskDescription in the hierarchy using the Id.
 /// </summary>
 /// <param name="descriptions">The descriptions.</param>
 /// <param name="id">The id.</param>
 /// <returns></returns>
 public static TaskDescription FindChildInHierarchy(Collection<TaskDescription> descriptions, Guid id)
 {
     TaskDescription toFind = new TaskDescription();
     toFind.Id = id;
     return FindChildInHierarchy(descriptions, toFind);
 }
 /// <summary>
 /// When overridden in a provider, removes a description.
 /// </summary>
 /// <param name="description">The description.</param>
 protected override void ProviderRemoveDescription(TaskDescription description)
 {
     Collection<TaskDescription> descriptions = ProviderLoadDescriptions();
     TaskDescription foundParent = null;
     foreach (TaskDescription child in descriptions)
     {
         foundParent = FindParentInHierarchy(child, description);
         if (foundParent != null)
         {
             break;
         }
     }
     if (foundParent != null)
     {
         foundParent.Children.Remove(description);
         ProviderSaveDescriptions(descriptions);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AdvancedSelectDialog"/> class.
 /// </summary>
 /// <param name="current">The current.</param>
 public AdvancedSelectDialog(TaskDescription current)
     : this()
 {
     this.Current = current;
 }
 /// <summary>
 /// When overridden in a provider, adds a description.
 /// </summary>
 /// <param name="taskDescription">The task description.</param>
 /// <param name="parent">The parent.</param>
 protected abstract void ProviderAddDescription(TaskDescription taskDescription, TaskDescription parent);
        private void TaskDescriptionsExplorer_Load(object sender, EventArgs e)
        {
            treeView.Font = (Font) AppContext.Current.SettingsProvider.Get("GeneralFont", Font);
            propertyGrid.Font = (Font) AppContext.Current.SettingsProvider.Get("GeneralFont", Font);

            //clear the context variable
            AppContext.Current.SettingsProvider.Set(
                "SelectedTaskDescription",
                TaskDescription.Empty,
                PersistHint.AcrossSessions);

            TaskActivity currentTaskactivity =
                (TaskActivity) AppContext.Current.SettingsProvider.Get("CurrentActivity", TaskActivity.Empty);
            if (currentTaskactivity.IsNotEmpty())
            {
                _currentTaskDescription = currentTaskactivity.TaskDescription;
            }

            // Set Owner Draw Mode to Text
            if ((null == Site) || (!Site.DesignMode))
            {
                if ((bool) AppContext.Current.SettingsProvider.Get("Advanced Draw on Descriptions Tree", true))
                {
                    treeView.DrawMode = TreeViewDrawMode.OwnerDrawText;
                }
            }
            ReBuildTree(AppContext.Current.TaskDescriptionsProvider.TaskDescriptions);

            buttonUse.Visible = !(bool) AppContext.Current.SettingsProvider.Get("HideUseButton", false);

            Activate();
        }
 /// <summary>
 /// When overridden in a provider, removes a description.
 /// </summary>
 /// <param name="taskDescription">The task description.</param>
 protected abstract void ProviderRemoveDescription(TaskDescription taskDescription);
Esempio n. 59
0
		// FIXME: my guess is the tasks does not have to be loaded entirely but only requested tasks must be loaded at invocation time.
		void LoadUsingTasks (ProjectInstance projectInstance, IEnumerable<ProjectUsingTaskElement> usingTasks)
		{
			Func<string,bool> cond = s => projectInstance != null ? projectInstance.EvaluateCondition (s) : Convert.ToBoolean (s);
			foreach (var ut in usingTasks) {
				var ta = assemblies.FirstOrDefault (a => a.AssemblyFile.Equals (ut.AssemblyFile, StringComparison.OrdinalIgnoreCase) || a.AssemblyName.Equals (ut.AssemblyName, StringComparison.OrdinalIgnoreCase));
				if (ta == null) {
					var path = Path.GetDirectoryName (string.IsNullOrEmpty (ut.Location.File) ? projectInstance.FullPath : ut.Location.File);
					ta = new TaskAssembly () { AssemblyName = ut.AssemblyName, AssemblyFile = ut.AssemblyFile };
					try {
						ta.LoadedAssembly = !string.IsNullOrEmpty (ta.AssemblyName) ? Assembly.Load (ta.AssemblyName) : Assembly.LoadFile (Path.Combine (path, ta.AssemblyFile));
					} catch {
						var errorNotLoaded = string.Format ("For task '{0}' Specified assembly '{1}' was not found", ut.TaskName, string.IsNullOrEmpty (ta.AssemblyName) ? ta.AssemblyFile : ta.AssemblyName);
						engine.LogWarningEvent (new BuildWarningEventArgs (null, null, projectInstance.FullPath, ut.Location.Line, ut.Location.Column, 0, 0, errorNotLoaded, null, null));
						continue;
					}
					assemblies.Add (ta);
				}
				var pg = ut.ParameterGroup == null ? null : ut.ParameterGroup.Parameters.Select (p => new TaskPropertyInfo (p.Name, Type.GetType (p.ParameterType), cond (p.Output), cond (p.Required)))
					.ToDictionary (p => p.Name);
				

				Type type = null;
				string error = null;
				TaskDescription task = new TaskDescription () {
					TaskAssembly = ta,
					Name = ut.TaskName,
					TaskFactoryParameters = pg,
					TaskBody = ut.TaskBody != null && cond (ut.TaskBody.Condition) ? ut.TaskBody.Evaluate : null,
					};
				if (string.IsNullOrEmpty (ut.TaskFactory)) {
					type = LoadTypeFrom (ta.LoadedAssembly, ut.TaskName, ut.TaskName);
					if (type == null)
						error = string.Format ("For task '{0}' Specified type '{1}' was not found in assembly '{2}'", ut.TaskName, ut.TaskName, ta.LoadedAssembly.FullName);
					else
						task.TaskType = type;
				} else {
					type = LoadTypeFrom (ta.LoadedAssembly, ut.TaskName, ut.TaskFactory);
					if (type == null)
						error = string.Format ("For task '{0}' Specified factory type '{1}' was not found in assembly '{2}'", ut.TaskName, ut.TaskFactory, ta.LoadedAssembly.FullName);
					else
						task.TaskFactoryType = type;
				}
				if (error != null)
					engine.LogWarningEvent (new BuildWarningEventArgs (null, null, projectInstance.FullPath, ut.Location.Line, ut.Location.Column, 0, 0, error, null, null));
				else
					task_descs.Add (task);
			}
		}
 /// <summary>
 /// Finds the and stack.
 /// </summary>
 /// <param name="taskDescription">The task description.</param>
 /// <param name="descriptions">The descriptions.</param>
 /// <param name="stack">The stack.</param>
 /// <returns></returns>
 private static bool FindAndStack(TaskDescription taskDescription,
                           Collection<TaskDescription> descriptions,
                           Stack<TaskDescription> stack)
 {
     bool result = false;
     foreach (TaskDescription child in descriptions)
     {
         if (child.Equals(taskDescription))
         {
             stack.Push(child);
             return true;
         }
         else
         {
             result = FindAndStack(taskDescription, child.Children, stack);
             if (result == true)
             {
                 stack.Push(child);
                 return result;
             }
         }
     }
     return result;
 }