Beispiel #1
0
        public void ConvertToDto(TaskDto dto, TaskHolder task, IEnumerable <GroupDto> groups, bool updateGroups)
        {
            ConvertToDto(dto, task);
            if (task.Groups == null)
            {
                return;
            }

            foreach (var group in task.Groups)
            {
                var groupDto = groups.Where(x => x.Id == group.Id).SingleOrDefault();
                if (groupDto == null)
                {
                    continue;
                }
                if (!dto.Groups.Contains(groupDto))
                {
                    dto.Groups.Add(groupDto);
                }

                if (updateGroups)
                {
                    if (groupDto.Tasks == null)
                    {
                        groupDto.Tasks = new List <TaskDto>();
                    }

                    if (!groupDto.Tasks.Contains(dto))
                    {
                        groupDto.Tasks.Add(dto);
                    }
                }
            }
        }
Beispiel #2
0
        public void UpdateConfigHolders(ICollection <GroupHolder> groups, ICollection <TaskHolder> tasks, ConfigDto config)
        {
            foreach (var group in config.Groups)
            {
                var groupHolderToUpdate = groups.Where(x => x.Id == group.Id).SingleOrDefault();
                if (groupHolderToUpdate == null)
                {
                    groupHolderToUpdate = new GroupHolder();
                    groups.Add(groupHolderToUpdate);
                }
                groupHolderToUpdate.Tasks = new ObservableCollection <TaskHolder>();
                _holdersConversionService.ConvertFromDto(groupHolderToUpdate, group);
            }

            foreach (var task in config.Tasks)
            {
                var taskHolderToUpdate = tasks.Where(x => x.Id == task.Id).SingleOrDefault();
                if (taskHolderToUpdate == null)
                {
                    taskHolderToUpdate = new TaskHolder();
                    tasks.Add(taskHolderToUpdate);
                }
                taskHolderToUpdate.Groups = new ObservableCollection <GroupHolder>();
                _holdersConversionService.ConvertFromDto(taskHolderToUpdate, task, groups, true);
            }
        }
Beispiel #3
0
        public void ConvertFromDto(TaskHolder task, TaskDto dto, IEnumerable <GroupHolder> groups, bool updateGroups)
        {
            ConvertFromDto(task, dto);
            if (dto.Groups == null)
            {
                return;
            }

            foreach (var group in dto.Groups)
            {
                var groupHolder = groups.Where(x => x.Id == group.Id).SingleOrDefault();
                if (groupHolder == null)
                {
                    continue;
                }
                if (!task.Groups.Contains(groupHolder))
                {
                    task.Groups.Add(groupHolder);
                }

                if (updateGroups)
                {
                    if (groupHolder.Tasks == null)
                    {
                        groupHolder.Tasks = new ObservableCollection <TaskHolder>();
                    }

                    if (!groupHolder.Tasks.Contains(task))
                    {
                        groupHolder.Tasks.Add(task);
                    }
                }
            }
        }
Beispiel #4
0
        private void SetCompletionVarGraph(TaskHolder taskHolder, int[] weeksTaskFinishCount)
        {
            int i = 0;

            for (int weekCount = 0; weekCount < 5; weekCount++)
            {
                for (int k = 0; k < 7; k++, i++)
                {
                    if (this.WeekCompletionView[i].Weight > 1)
                    {
                        weeksTaskFinishCount[weekCount]++;
                    }
                }
            }
            double taskPerWeek = 0;

            for (int shiftN = 0; shiftN < 7; shiftN++)
            {
                if ((taskHolder.WeeklyRepeatPattern & ((int)0b00000001 << (shiftN))) > 0)
                {
                    taskPerWeek++;
                }
            }

            this.WeekTaskCompletionVarGraph[0].Values[0] = (weeksTaskFinishCount[4] == 0) ? 0 : ((double)(int)((weeksTaskFinishCount[4] / taskPerWeek) * 100));
            this.WeekTaskCompletionVarGraph[0].Values[1] = (weeksTaskFinishCount[3] == 0) ? 0 : ((double)(int)((weeksTaskFinishCount[3] / taskPerWeek) * 100));
            this.WeekTaskCompletionVarGraph[0].Values[2] = (weeksTaskFinishCount[2] == 0) ? 0 : ((double)(int)((weeksTaskFinishCount[2] / taskPerWeek) * 100));
            this.WeekTaskCompletionVarGraph[0].Values[3] = (weeksTaskFinishCount[1] == 0) ? 0 : ((double)(int)((weeksTaskFinishCount[1] / taskPerWeek) * 100));
            this.WeekTaskCompletionVarGraph[0].Values[4] = (weeksTaskFinishCount[0] == 0) ? 0 : ((double)(int)((weeksTaskFinishCount[0] / taskPerWeek) * 100));
        }
Beispiel #5
0
        public GroupHolder InitializeGroupDetails(List <TaskHolder> availableTasksToAdd, GroupHolder chooosenGroup, List <TaskHolder> tasks)
        {
            GroupHolder shownGroup = new GroupHolder()
            {
                Id          = chooosenGroup.Id,
                Name        = chooosenGroup.Name,
                Description = chooosenGroup.Description,
                Archivized  = chooosenGroup.Archivized,
                Tasks       = new ObservableCollection <TaskHolder>(),
            };

            foreach (var task in tasks)
            {
                var newTask = new TaskHolder
                {
                    Id          = task.Id,
                    Name        = task.Name,
                    Description = task.Description,
                    Archivized  = task.Archivized,
                    Groups      = new ObservableCollection <GroupHolder>(),
                };

                if (task.Groups.Contains(chooosenGroup))
                {
                    newTask.Groups.Add(shownGroup);
                    shownGroup.Tasks.Add(newTask);
                }
                else
                {
                    availableTasksToAdd.Add(newTask);
                }
            }
            return(shownGroup);
        }
Beispiel #6
0
        public void ApplyChanges(ICollection <TaskHolder> currnetTasks, IEnumerable <GroupHolder> currentGroups, TaskHolder updatedTask)
        {
            var taskToUpdate = currnetTasks.SingleOrDefault(x => x.Id == updatedTask.Id);

            if (taskToUpdate == null)
            {
                taskToUpdate = new TaskHolder();
                currnetTasks.Add(taskToUpdate);
            }
            taskToUpdate.Name        = updatedTask.Name;
            taskToUpdate.Description = updatedTask.Description;
            taskToUpdate.StartDate   = updatedTask.StartDate;
            taskToUpdate.Frequency   = updatedTask.Frequency;
            if (taskToUpdate.Groups == null)
            {
                taskToUpdate.Groups = new ObservableCollection <GroupHolder>();
            }

            foreach (var group in currentGroups)
            {
                var taskInDetails = updatedTask.Groups.Where(x => x.Id == group.Id).SingleOrDefault();

                if (!taskToUpdate.Groups.Contains(group) && taskInDetails != null)
                {
                    group.Tasks.Add(taskToUpdate);
                    taskToUpdate.Groups.Add(group);
                }

                if (taskToUpdate.Groups.Contains(group) && taskInDetails == null)
                {
                    group.Tasks.Remove(taskToUpdate);
                    taskToUpdate.Groups.Remove(group);
                }
            }
        }
Beispiel #7
0
        public IntPtr MarshallTask(Task task)
        {
            var holder = new TaskHolder(task, this);

            _taskRegistry.Add(holder.CallbackPtr, holder);
            return(holder.CallbackPtr);
        }
    /// <summary>
    /// Generate task prefab to UI Holder
    /// </summary>
    /// <param name="p_taskHolder"></param>
    private void GeneratePickableTask(TaskHolder p_taskHolder)
    {
        if (p_taskHolder != null && TaskPickScrollContent != null &&
            taskItemPrefab != null && p_taskHolder.stpObjectHolder.Count > 0)
        {
            TaskPickScrollContent.anchoredPosition = Vector2.zero;

            UtilityMethod.ClearChildObject(TaskPickScrollContent.transform);
            int taskObjectLength = p_taskHolder.stpObjectHolder.Count;

            VerticalLayoutGroup verticalLayout   = TaskPickScrollContent.GetComponent <VerticalLayoutGroup>();
            RectTransform       taskSlotRect     = taskItemPrefab.GetComponent <RectTransform>();
            Vector2             taskSlotRectSize = taskSlotRect.sizeDelta;

            for (int i = 0; i < taskObjectLength; i++)
            {
                GameObject   generateObject = UtilityMethod.CreateObjectToParent(TaskPickScrollContent.transform, taskItemPrefab);
                TaskDataSlot taskSlotObject = generateObject.GetComponent <TaskDataSlot>();

                taskSlotObject.SetUp(p_taskHolder.stpObjectHolder[i]);
            }

            TaskPickScrollContent.sizeDelta = new Vector2(TaskPickScrollContent.sizeDelta.x, ((taskObjectLength * taskSlotRectSize.y) + (verticalLayout.spacing * taskObjectLength)));
        }
    }
Beispiel #9
0
    static private void CreateTaskStats(TaskHolder statsHolder)
    {
        //TextAsset csvText = (TextAsset)AssetDatabase.LoadAssetAtPath(CSV_FOLDER + "/database - task.csv", typeof(TextAsset));
        string csvText = System.IO.File.ReadAllText(Application.streamingAssetsPath + "/ExternalDatabase/CSV/" + ParameterFlag.CSVFileName.Task);

        CSVFile csvFile = new CSVFile(csvText);

        AssetDatabase.CreateFolder(ASSETS_FOLDER + "/Asset", "Task");

        int csvCount = csvFile.length;

        for (int i = 0; i < csvCount; i++)
        {
            string id = csvFile.Get <string>(i, "ID");

            if (string.IsNullOrEmpty(id))
            {
                continue;
            }

            TaskStats c_prefab = ScriptableObjectUtility.CreateAsset <TaskStats>(ASSETS_FOLDER + "/Asset/Task/", "[TaskStats] " + id);
            EditorUtility.SetDirty(c_prefab);

            c_prefab.id    = id;
            c_prefab.tag   = csvFile.Get <string>(i, "Tag");
            c_prefab.label = csvFile.Get <string>(i, "Name");

            c_prefab.cost   = csvFile.Get <string>(i, "Cost");
            c_prefab.effect = csvFile.Get <string>(i, "Effect");
            c_prefab.desc   = csvFile.Get <string>(i, "Description");

            statsHolder.stpObjectHolder.Add(c_prefab);
        }
    }
Beispiel #10
0
        /// <summary>
        /// Set the TaskHolde based on Properties
        /// </summary>
        private void SetTaskHolderValues()
        {
            if (taskHolder == null)
            {
                this.timeTakeToMakeTaskEnd = DateTime.Now;
                this.taskHolder            = new NormalTaskHolder();

                this.taskHolder.TimeTakeToMakeTask = (int)((TimeTakeToMakeTaskEnd - TimeTakeToMakeTaskStart).TotalSeconds);
            }
            else
            {
                this.taskHolder.TimeTakeToMakeTask += (int)((TimeTakeToMakeTaskEnd - TimeTakeToMakeTaskStart).TotalSeconds);
            }

            this.taskHolder.DisplayTitle = this.displayTitle;

            this.taskHolder.Description = this.description;
            this.taskHolder.IsRepeat    = this.isRepeat;
            if (taskHolder is NormalTaskHolder normalTaskHolder)
            {
                if (isRepeat)
                {
                    normalTaskHolder.TaskDuration = this.TaskDuration;
                }
                else
                {
                    normalTaskHolder.TaskDuration = (this.dueDate - DateTime.Now).Days;
                }
            }
            this.taskHolder.WeeklyRepeatPattern = GetWeeklyRepeatPattern();
        }
Beispiel #11
0
        public IntPtr MarshallTask(Task task, out ReleaseDotNetValue releaseCallback)
        {
            var holder = new TaskHolder(task, this);

            _taskRegistry.Add(holder.CallbackPtr, holder);
            releaseCallback = ReleaseTaskCallback;
            return(holder.CallbackPtr);
        }
Beispiel #12
0
        public FTDIInterface(int readTimeout, int writeTimeout, SemaphoreSlim locker)
        {
            Locker       = locker;
            _ftdi        = new FTDI();
            _portUpdater = new TaskHolder();
            _portUpdater.RegisterAsync(c => updateAwailablePortsLoop(c)).GetAwaiter().GetResult();

            Pipe = new FTDIPipe(_ftdi, readTimeout, writeTimeout);
            openStateCheckingAsyncLoop();
        }
Beispiel #13
0
 protected MediatorClientTestHandlerBase(TaskHolder holder, string message)
 {
     task = new Task(() =>
     {
         Thread.Sleep(10);
         holder.Messages.Add(message);
     });
     this.holder = holder;
     holder.Tasks.Add(task);
 }
Beispiel #14
0
 public void ConvertFromDto(TaskHolder task, TaskDto dto)
 {
     ConvertFromNamedModelDto(task, dto);
     task.Frequency = dto.Frequency;
     task.StartDate = dto.StartDate;
     if (task.Groups == null)
     {
         task.Groups = new ObservableCollection <GroupHolder>();
     }
 }
Beispiel #15
0
 public void ConvertToDto(TaskDto dto, TaskHolder task)
 {
     ConvertToNamedModelDto(dto, task);
     dto.Frequency = task.Frequency;
     dto.StartDate = task.StartDate;
     if (dto.Groups == null)
     {
         dto.Groups = new List <GroupDto>();
     }
 }
Beispiel #16
0
        public TaskHolder CreateNewTask(IEnumerable <TaskHolder> tasks)
        {
            var newTask = new TaskHolder()
            {
                Id        = GenerateTemporaryId(tasks),
                Name      = GetNameWithIndexIfNeeded("New task", tasks),
                Groups    = new ObservableCollection <GroupHolder>(),
                StartDate = DateTime.Now,
                Frequency = 1,
            };

            return(newTask);
        }
        public void Initialize(TaskHolder choosenTask, List <GroupHolder> groups)
        {
            if (choosenTask == null)
            {
                TaskDetailsPanel.Visibility = Visibility.Hidden;
                return;
            }

            TaskDetailsPanel.Visibility = Visibility.Visible;
            _availableGroupsToAdd       = new List <GroupHolder>();

            ShownTask = _holdersService.InitializeTaskDetails(_availableGroupsToAdd, choosenTask, groups);
        }
Beispiel #18
0
 public TaskHolderSettingsControl(TaskHolder taskHolderRequiredSetting)
 {
     InitializeComponent();
     this.taskHolder              = taskHolderRequiredSetting;
     this.DisplayTitle            = taskHolderRequiredSetting.DisplayTitle;
     this.Description             = taskHolderRequiredSetting.Description;
     this.IsRepeat                = taskHolderRequiredSetting.IsRepeat;
     this.WeeklyRepeatPattern     = taskHolderRequiredSetting.WeeklyRepeatPattern;
     this.TaskDuration            = taskHolderRequiredSetting.TaskDuration;
     this.timeTakeToMakeTaskStart = DateTime.Now;
     this.ByteToDayOfWeekBool(this.weeklyRepeatPattern);
     FutureDatePicker.BlackoutDates.Add(new CalendarDateRange(new DateTime(0001, 1, 1), DateTime.Now.AddDays(-1)));
 }
Beispiel #19
0
        public async Task InitialSetUpAsync(TaskHolder taskHolder)
        {
            this.ResetHeatGraph();

            await SetBoolHeatMapGraphAsync(taskHolder);

            int[] weeksTaskFinishCount = new int[5];

            this.SetCompletionVarGraph(taskHolder, weeksTaskFinishCount);
            this.SetPersentageOfCompleteGraph(weeksTaskFinishCount);

            this.OnPropertyChanged("PersentageOfComplete");
            this.OnPropertyChanged("WeekCompletionView");
            this.OnPropertyChanged("WeekTaskCompletionVarGraph");
        }
        private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            TaskHolder.CancelTasks();
            e.Handled = true;

            int[] intArray = new int[theElements.Count];
            for (int i = 0; i < theElements.Count; i++)
            {
                intArray[i] = theElements[i].Value;
            }
            double[] progressReport = new double[1];
            TaskHolder.cts  = new CancellationTokenSource();
            TaskHolder.task = Task.Run(() => Functions.Algorithms.SimpleArgument114115(intArray, targetValue, TaskHolder.cts.Token, ref progressReport[0]));
            ResultPage page = new ResultPage(TaskHolder.task, progressReport);

            NavigationService.Navigate(page);
        }
 protected override TaskPersisterSession.TaskHolder LoadTaskRecord(string instanceId, bool forUpdate)
 {
     var th = new TaskHolder { State = RecordState.Unmodified };
     using (var cmd = _ses.Connection.CreateCommand())
     {
         cmd.CommandText = string.Format("select instance_id, task_data, task_type, version from TaskInstance {1} where instance_id='{0}'", instanceId, forUpdate ? "with(updlock,rowlock)" : "with(rowlock)");
         using (var dr = cmd.ExecuteReader())
         {
             if (!dr.Read()) return null;
             th.TaskData = Convert.ToString(dr["task_data"]);
             th.TaskTypeId = Convert.ToString(dr["task_type"]);
             th.DbVersion = Convert.ToString(dr["version"]);
             th.Deserialized = _ser.Deserialize(th.TaskData, th.TaskTypeId);
         }
     }
     return th;
 }
        public async Task AssignNewTaskHolderFromControlAsync(TaskHolder taskHolder)
        {
            try
            {
                taskHolder.Title = taskHolder.DisplayTitle.Replace(" ", "_");
                //check duplication and assign title for DB access to create table
                taskHolder.Title = this.GetTitleNameForDB(taskHolder.Title);

                if (taskHolder is NormalTaskHolder normalTaskHolder)
                {
                    await AssignNewTaskHolder(normalTaskHolder);
                }
                await ResetAllTaskListAsync();
            }
            finally
            {
                this.SettingContent = null;
            }
        }
        public virtual void SaveNew(TaskInstance ti)
        {
            if (string.IsNullOrEmpty(ti.InstanceId))
            {
                throw new Exception("Missing instance ID");
            }
            if (_cache.ContainsKey(ti.InstanceId))
            {
                throw new Exception("Task already exists");
            }
            string typeId;
            var    th = new TaskHolder
            {
                State        = RecordState.New,
                Deserialized = ti,
                TaskData     = _ser.Serialize(ti, out typeId)
            };

            th.TaskTypeId         = typeId;
            _cache[ti.InstanceId] = th;
        }
Beispiel #24
0
        /// <summary>
        /// Set HeatMapGrap Async
        /// </summary>
        /// <param name="taskHolder"></param>
        /// <returns></returns>
        private async Task SetBoolHeatMapGraphAsync(TaskHolder taskHolder)
        {
            if (taskHolder is NormalTaskHolder nTaskHolder)
            {
                var tasks     = new List <Task>();
                var dayOfWeek = (int)DateTime.Now.DayOfWeek;
                foreach (BoolTypeUserTask userTask in nTaskHolder.CurrentTaskList)
                {
                    tasks.Add(Task.Run(() =>
                    {
                        var timeDifference = DateTime.Now.Date - userTask.DateData.Date;
                        int week;

                        if (timeDifference.Days <= dayOfWeek)
                        {
                            week = 0;
                        }
                        else
                        {
                            week = ((timeDifference.Days - (dayOfWeek + 1)) / 7) + 1;
                        }
                        // since timeDifference value have current week

                        // diving time of completion by 5
                        if (userTask.IsTaskDone)
                        {
                            //var hourQuaterContraint = (boolTask.TimeOfCompletionLocalData.Hour / 6) + 2;
                            WeekCompletionView[(int)userTask.TimeOfCompletionLocalData.DayOfWeek + (week * 7)].Weight = 3;
                        }
                        else
                        {
                            WeekCompletionView[(int)userTask.TimeOfCompletionLocalData.DayOfWeek + (week * 7)].Weight = 1;
                        }
                    }));
                }
                await Task.WhenAll(tasks);
            }
        }
Beispiel #25
0
        protected override TaskPersisterSession.TaskHolder LoadTaskRecord(string instanceId, bool forUpdate)
        {
            var th = new TaskHolder {
                State = RecordState.Unmodified
            };

            using (var cmd = _ses.Connection.CreateCommand())
            {
                cmd.CommandText = string.Format("select instance_id, task_data, task_type, version from TaskInstance {1} where instance_id='{0}'", instanceId, forUpdate ? "with(updlock,rowlock)" : "with(rowlock)");
                using (var dr = cmd.ExecuteReader())
                {
                    if (!dr.Read())
                    {
                        return(null);
                    }
                    th.TaskData     = Convert.ToString(dr["task_data"]);
                    th.TaskTypeId   = Convert.ToString(dr["task_type"]);
                    th.DbVersion    = Convert.ToString(dr["version"]);
                    th.Deserialized = _ser.Deserialize(th.TaskData, th.TaskTypeId);
                }
            }
            return(th);
        }
Beispiel #26
0
    static private void UpdateStatsAsset()
    {
        TaskHolder statsHolder = (TaskHolder)AssetDatabase.LoadAssetAtPath(ASSETS_FOLDER + "/[Task]Holder.asset", typeof(TaskHolder));

        if (statsHolder != null)
        {
            FileUtil.DeleteFileOrDirectory(ASSETS_FOLDER + "/Asset");
            AssetDatabase.CreateFolder(ASSETS_FOLDER, "Asset");

            statsHolder.stpObjectHolder.Clear();
            CreateTaskStats(statsHolder);

            CreateCharacterStats();
        }
        else
        {
            Debug.LogError("[Stats]Holder.asset has not been created yet!");
        }

        EditorUtility.SetDirty(statsHolder);
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
    }
Beispiel #27
0
        public TaskHolder InitializeTaskDetails(List <GroupHolder> availableGroupsToAdd, TaskHolder choosenTask, List <GroupHolder> groups)
        {
            TaskHolder shownTask = new TaskHolder()
            {
                Id          = choosenTask.Id,
                Name        = choosenTask.Name,
                Description = choosenTask.Description,
                StartDate   = choosenTask.StartDate,
                Frequency   = choosenTask.Frequency,
                Archivized  = choosenTask.Archivized,
                Groups      = new ObservableCollection <GroupHolder>(),
            };

            foreach (var group in groups)
            {
                var newGroup = new GroupHolder
                {
                    Id          = group.Id,
                    Name        = group.Name,
                    Description = group.Description,
                    Archivized  = group.Archivized,
                    Tasks       = new ObservableCollection <TaskHolder>(),
                };

                if (group.Tasks.Contains(choosenTask))
                {
                    newGroup.Tasks.Add(shownTask);
                    shownTask.Groups.Add(newGroup);
                }
                else
                {
                    availableGroupsToAdd.Add(newGroup);
                }
            }
            return(shownTask);
        }
Beispiel #28
0
 public void PerformMessage(IFileStorageService service)
 {
     OperationHolder = new TaskHolder(service.MoveFileAsync(Path, DestinationPath, Rewrite));
 }
 public void PerformMessage(INavigationService service)
 {
     OperationHolder = new TaskHolder(service.NavigateToAsync(PageName, Parameter));
 }
 public void PerformMessage(IGeolocationService service)
 {
     OperationHolder = new TaskHolder <ILocation>(service.GetLocationAsync(this, CancellationSource.Token));
 }
 public void PerformMessage(IDialogService service)
 {
     OperationHolder = new TaskHolder(service.ShowDialogAsync(DialogName));
 }
 private void UpdateHolder(double progress, string message, object token)
 {
     lock (_syncRoot)
     {
         var existing = _holders.FirstOrDefault(x => x.Token == token);
         if (existing == null)
         {
             existing = new TaskHolder
             {
                 Token = token,
                 Message = message,
                 Progress = progress
             };
         }
         else
         {
             existing.Message = message;
             existing.Progress = progress;
             _holders.Remove(existing);
         }
         _holders.Add(existing);
         Update();
     }
 }
 public virtual void SaveNew(TaskInstance ti)
 {
     if (string.IsNullOrEmpty(ti.InstanceId)) throw new Exception("Missing instance ID");
     if (_cache.ContainsKey(ti.InstanceId)) throw new Exception("Task already exists");
     string typeId;
     var th = new TaskHolder
     {
         State = RecordState.New,
         Deserialized = ti,
         TaskData = _ser.Serialize(ti, out typeId)
     };
     th.TaskTypeId = typeId;
     _cache[ti.InstanceId] = th;
 }