Пример #1
0
        public ActionResult AddHomework(IFormCollection collection)
        {
            string Text          = "";
            string NameDeveloper = Singleton.Instance.RolUser.ElementAt(0).NameUser;
            //VARIABLES
            var NewHomework = new Models.Homework
            {
                Title        = collection["Title"],
                Description  = "\"" + collection["Description"] + "\"",
                Project      = collection["Project"],
                Priority     = Convert.ToInt16(collection["Priority"]),
                DeliveryDate = Convert.ToDateTime(collection["DeliveryDate"]),
                Developer    = Singleton.Instance.RolUser.ElementAt(0).NameUser
            };

            if (Singleton.Instance.HashTableHomework.ValueRepeat(NewHomework) == false)
            {
                //AGREGAR TABLA HASH
                Singleton.Instance.HashTableHomework.AddHashTable(NewHomework);

                //AGREGAR AL ARCHIVO
                if (Singleton.Instance.HelpFile.Count() != 0)
                {
                    Text = "\n" + collection["Title"] + "," + "\"" + collection["Description"] + "\"" + "," + collection["Project"] + "," + Convert.ToInt16(collection["Priority"]) + "," + collection["DeliveryDate"] + "," + NameDeveloper;
                }
                else
                {
                    Text = collection["Title"] + "," + "\"" + collection["Description"] + "\"" + "," + collection["Project"] + "," + Convert.ToInt16(collection["Priority"]) + "," + collection["DeliveryDate"] + "," + NameDeveloper;
                    Singleton.Instance.HelpFile.InsertAtStart(1);
                }

                //OBJETO DE PRIORIDAD
                var NewPriority = new Models.PriorityHomework
                {
                    Title       = collection["Title"],
                    DeliverDate = Convert.ToDateTime(collection["DeliveryDate"]),
                    priority    = Convert.ToInt32(collection["Priority"])
                };

                //AGREGAR A LA COLA DE PRIORIODAD
                Singleton.Instance.PriorityHomeworkDate.HeapInsert(NewPriority, NewPriority);

                //ESCRIBIR EN UN TEXTO
                StreamWriter writer = new StreamWriter("ProjectManager.txt", true);
                writer.Write(Text);
                writer.Close();

                //MOSTRAR LA VISTA
                return(RedirectToAction(nameof(IndexDeveloper)));
            }
            else
            {
                //MOSTRAR LA VISTA
                return(RedirectToAction(nameof(Exists)));
            }
        }
Пример #2
0
        //PONER EN LA LISTA TODAS LAS TAREAS
        public void AllTask()
        {
            if (Singleton.Instance.PriorityHomeworkDate.isEmpty() == false)
            {
                //VARIABLES RECUPERAR TÍTULO
                string   TitleNH;
                int      PriorityNH;
                string   DesNH;
                string   ProjectNH;
                DateTime Date;
                string   NameDeveloper;

                int counting = Singleton.Instance.PriorityHomeworkDate.CountObj();
                //HEAPSORT
                for (int i = 0; i < counting; i++)
                {
                    HeapNode <PriorityHomework> TitlePriority = Singleton.Instance.PriorityHomeworkDate.HeapDelete();

                    var SearchInformation = new Models.Homework
                    {
                        Title = TitlePriority.value.Title
                    };

                    //RECUPERAR DATO DE LA TABLA HASH
                    TitleNH       = Singleton.Instance.HashTableHomework.ReturnHash(SearchInformation).value.Title;
                    PriorityNH    = Singleton.Instance.HashTableHomework.ReturnHash(SearchInformation).value.Priority;
                    DesNH         = Singleton.Instance.HashTableHomework.ReturnHash(SearchInformation).value.Description;
                    ProjectNH     = Singleton.Instance.HashTableHomework.ReturnHash(SearchInformation).value.Project;
                    Date          = Singleton.Instance.HashTableHomework.ReturnHash(SearchInformation).value.DeliveryDate;
                    NameDeveloper = Singleton.Instance.HashTableHomework.ReturnHash(SearchInformation).value.Developer;

                    var Task = new Models.Homework
                    {
                        Title        = TitleNH,
                        Priority     = PriorityNH,
                        Description  = DesNH,
                        Project      = ProjectNH,
                        DeliveryDate = Date,
                        Developer    = NameDeveloper
                    };


                    //AGREGAR A LA LISTA -> TODAS LAS TAREAS
                    if (Singleton.Instance.AllTask.GetCount == 0)
                    {
                        Singleton.Instance.AllTask.InsertAtStart(Task);
                    }
                    else
                    {
                        Singleton.Instance.AllTask.InsertAtEnd(Task);
                    }
                }

                //AGREGAR DE NUEVO
                for (int i = 0; i < Singleton.Instance.AllTask.Count(); i++)
                {
                    var ReturnHeap = new Models.PriorityHomework
                    {
                        Title       = Singleton.Instance.AllTask.ElementAt(i).Title,
                        DeliverDate = Singleton.Instance.AllTask.ElementAt(i).DeliveryDate,
                        priority    = Singleton.Instance.AllTask.ElementAt(i).Priority
                    };

                    //AGREGAR A LA COLA DE PRIORIODAD
                    Singleton.Instance.PriorityHomeworkDate.HeapInsert(ReturnHeap, ReturnHeap);
                }
            }
        }
Пример #3
0
        //RECOPILAR LA INFORMACIÓN DEL ARCHIVO
        public void ReadFileC(string UserDeveloper, bool PM)
        {
            //ELIMINAR INFORMACIÓN DE LA COLA DE PRIORIDAD
            int counting = Singleton.Instance.PriorityHomeworkDate.CountObj();

            for (int i = 0; i < counting; i++)
            {
                HeapNode <PriorityHomework> TitlePriority = Singleton.Instance.PriorityHomeworkDate.HeapDelete();
            }

            //RECOPILAR INFORMACIÓN ANTERIOR
            string       filePath     = bingPathToAppDir();
            StreamReader streamReader = new StreamReader(filePath);
            string       CurrentLine;
            string       Concatenando = "";
            bool         First        = true;
            bool         Repeat       = true;

            while (!streamReader.EndOfStream)
            {
                CurrentLine = streamReader.ReadLine();
                string[] FileInformationList = CurrentLine.Split(',');
                int      pos = 0;

                //VARIABLES
                string FileTitle       = "";
                string FileDescription = "";
                string FileProject     = "";
                string FilePriority    = "";
                string FileDate        = "";
                string FileDeveloper   = "";

                if (Singleton.Instance.HelpFile.Count() == 0)
                {
                    Singleton.Instance.HelpFile.InsertAtStart(1);
                }

                //TITULO
                //Titulo con " "
                if (FileInformationList[pos].Substring(0, 1) == "\"")
                {
                    while (Repeat == true)
                    {
                        if (First == true)
                        {
                            Concatenando += FileInformationList[pos];
                            First         = false;
                        }
                        else
                        {
                            Concatenando += "," + FileInformationList[pos];
                        }

                        string FileLength = FileInformationList[pos];
                        if (FileInformationList[pos].Substring(FileLength.Length - 1, 1) == "\"")
                        {
                            Repeat = false;
                        }
                        pos++;
                    }
                }
                else
                {
                    //Titulo sin " "
                    Concatenando = FileInformationList[pos];
                    pos++;
                }
                //GUARDAR TÍTULO
                FileTitle = Concatenando;

                //DESCRIPCIÓN
                Repeat       = true;
                First        = true;
                Concatenando = "";
                //Descripción con " "
                if (FileInformationList[pos].Substring(0, 1) == "\"")
                {
                    while (Repeat == true)
                    {
                        if (First == true)
                        {
                            Concatenando += FileInformationList[pos];
                            First         = false;
                        }
                        else
                        {
                            Concatenando += "," + FileInformationList[pos];
                        }

                        string FileLength = FileInformationList[pos];
                        if (FileInformationList[pos].Substring(FileLength.Length - 1, 1) == "\"")
                        {
                            Repeat = false;
                        }
                        pos++;
                    }
                }
                else
                {
                    //Descripción sin " "
                    Concatenando = FileInformationList[pos];
                    pos++;
                }
                FileDescription = Concatenando;

                //PROYECTO
                FileProject = FileInformationList[pos];
                pos++;

                //PRIORIDAD
                FilePriority = FileInformationList[pos];
                pos++;

                //FECHA
                FileDate = FileInformationList[pos];
                pos++;

                //NOMBRE DEL DEVELOPER
                FileDeveloper = FileInformationList[pos];

                //AGREGAR
                var CollectHomework = new Models.Homework
                {
                    Title        = FileTitle,
                    Description  = FileDescription,
                    Project      = FileProject,
                    Priority     = Convert.ToInt32(FilePriority),
                    DeliveryDate = Convert.ToDateTime(FileDate),
                    Developer    = FileDeveloper
                };

                if (Singleton.Instance.HashTableHomework.ValueRepeat(CollectHomework) == false)
                {
                    //AGREGAR A LA TABLA DE HASH
                    Singleton.Instance.HashTableHomework.AddHashTable(CollectHomework);
                }

                if (PM == false)
                {
                    //AGREGAR A LA COLA DE PRIORIDAD SI ES DEL DEVELOPER QUE INICIO SESIÓN
                    if (FileDeveloper == UserDeveloper)
                    {
                        //OBJETO DE PRIORIDAD
                        var NewPriority = new Models.PriorityHomework
                        {
                            Title       = FileTitle,
                            DeliverDate = Convert.ToDateTime(FileDate),
                            priority    = Convert.ToInt32(FilePriority)
                        };

                        //AGREGAR A LA COLA DE PRIORIODAD
                        Singleton.Instance.PriorityHomeworkDate.HeapInsert(NewPriority, NewPriority);
                    }
                }
            }
            //CERRAR LA LECTURA DEL ARCHIVO
            streamReader.Close();
        }