Example #1
0
        public ActionResult Dequeue()
        {
            HashCell taskContainer = new HashCell();
            Task     taskToDelete  = Storage.Instance.currentUser.scheduledTasks.Peek();
            int      i             = 0;
            bool     found         = false;
            int      index         = 0;

            while (!found)
            {
                index = taskContainer.HashF(taskToDelete.taskTitle, i);

                if (Storage.Instance.hashTable[index].key.Equals(taskToDelete.taskTitle))
                {
                    found = true;
                    Storage.Instance.hashTable[index].key         = null;
                    Storage.Instance.hashTable[index].taskDetails = null;
                    Storage.Instance.hashTable[index].state       = HashCell.cellState.vacio;
                }
                else
                {
                    found = false;
                }
            }

            Storage.Instance.currentUser.scheduledTasks.Dequeue();

            return(View("Index"));
        }
Example #2
0
 private int[] GetSortedHashPtr(ref HashCell[] hashTabA)
 {
     int nbRow = hashTabA.Length;
     var sortedIndex = new int[hashTabA.Length];
     for (int i = 0; i < nbRow; i++)
         sortedIndex[i] = i;
     GetSortedPtr_Recursive(hashTabA, sortedIndex, 0, nbRow - 1);
     return sortedIndex;
 }
Example #3
0
 private static void GetSortedPtr_Recursive(HashCell[] array, int[] ptr, int left, int rigth)
 {
     int l = left, r = rigth;
     int m = (left + rigth) / 2;
     int midPtr = ptr[m];
     uint midValue = array[midPtr].Hash;
     while (l <= r) {
         while (array[ptr[l]].Hash < midValue || (array[ptr[l]].Hash == midValue && ptr[l] < midPtr))
             l++;
         while (midValue < array[ptr[r]].Hash || (array[ptr[r]].Hash == midValue && midPtr < ptr[r]))
             r--;
         if (l <= r) {
             int buffer = ptr[l];
             ptr[l] = ptr[r];
             ptr[r] = buffer;
             l++; r--;
         }
     }
     if (left < r) GetSortedPtr_Recursive(array, ptr, left, r);
     if (l < rigth) GetSortedPtr_Recursive(array, ptr, l, rigth);
 }
Example #4
0
 HashCell[] GetCellsKey(object[,] data)
 {
     int nbRow = data.GetLength(0);
     int nbCol = data.GetLength(1);
     int nbCells = nbRow * nbCol;
     var hashCell = new HashCell[nbCells];
     for (int ri = 1, cell = 0; ri <= nbRow; ri++) {
         string text = String.Empty;
         for (int ci = 1; ci <= nbCol; ci++) {
             hashCell[cell].Row = ri;
             hashCell[cell].Column = ci;
             hashCell[cell].Key = GetObjectText(data[ri, ci]);
             hashCell[cell].Hash = ComputeHash(hashCell[cell].Key);
             cell++;
         }
     }
     return hashCell;
 }
Example #5
0
        public ActionResult Index(FormCollection collection)
        {
            Random randomNumber = new Random();

            try
            {
                string taskTitle               = collection["TaskTitle"];
                string proyectName             = collection["ProyectName"];
                string taskDescripction        = collection["TaskDescription"];
                string priority                = collection["Priority"];
                string dateString              = collection["Date"];
                int    randomNumberForPriority = 0;

                switch (priority)
                {
                case "Level1_13":
                {
                    randomNumberForPriority = randomNumber.Next(1, 13);
                }
                break;

                case "Level13_27":
                {
                    randomNumberForPriority = randomNumber.Next(13, 27);
                }
                break;

                case "Level28_41":
                {
                    randomNumberForPriority = randomNumber.Next(28, 41);
                }
                break;

                case "Level41_51":
                {
                    randomNumberForPriority = randomNumber.Next(41, 51);
                }
                break;

                default:
                    randomNumberForPriority = randomNumber.Next(1, 51);
                    break;
                }

                Task taskRegistered = new Task()
                {
                    taskTitle        = taskTitle.Replace(',', ' '),
                    proyectName      = proyectName.Replace(',', ' '),
                    taskDescripction = taskDescripction.Replace(',', ' '),
                    priority         = randomNumberForPriority,
                    date             = dateString,
                };


                HashCell taskContainer = new HashCell();

                int numberOfTasks = Storage.Instance.currentUser.scheduledTasks.tasksScheduled();

                if (numberOfTasks <= 10)
                {
                    Session.Remove(Storage.Instance.currentUser.name + "Tasks");

                    if (taskContainer.insert(taskTitle, taskRegistered))
                    {
                        Session.Remove("InsertTask");
                        string fileName = string.Empty;
                        string path     = string.Empty;
                        string folder   = string.Empty;


                        fileName = Path.GetFileName(Storage.Instance.currentUser.name);

                        if (Storage.Instance.currentUser.role == "Developer")
                        {
                            folder = "Developers";
                        }
                        else
                        {
                            folder = "ProductManagers";
                        }

                        path = Path.Combine(Server.MapPath("~/App_Data/" + folder), fileName + ".csv");
                        I_O_Manager file = new I_O_Manager(fileName, path);

                        file.writeInFile(taskRegistered);
                        Storage.Instance.currentUser.scheduledTasks.Enqueue(taskRegistered);

                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        Session["InsertTask"] = "Task already exists";
                        return(RedirectToAction("Index"));
                    }
                }
                else
                {
                    Session[Storage.Instance.currentUser.name + "Tasks"] = "The list of unfinished tasks is complety full";
                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
                return(View());
            }
        }