Ejemplo n.º 1
0
        public static void SetAll(string ProjectID, string RoadmapName, string[] proj_dep, string[] link_arr, string[] string_dep, string desc, string risk)
        {
            List<Project> tot_list = new List<Project>(); // Total List of projects
            List<string> P_list = new List<string>(); //
            List<Project> P_list2 = new List<Project>();
            List<Project> dep_list = new List<Project>();
            List<Link> Link_List = new List<Link>();
            List<string> Dep_Names = new List<string>();
            List<string> Dep_Names2 = new List<string>();

            int pointindex = ProjectID.IndexOf("Bus");
            int valindex = ProjectID.IndexOf("Proj");
            string point = ProjectID.Substring(0, pointindex);
            string val = ProjectID.Substring(0, valindex);
            RoadMap map = new RoadMap(RoadmapName);
            StrategyPoint newpoint = map.GetPoint(point);
            BusinessValue newval = newpoint.GetBusinessValue(val);
            Project newproj = newval.GetProject(ProjectID);

            //setting
            newproj.SetModalDescription(desc);
            newproj.SetProjectRisks(risk);

            P_list = newproj.GetDependencies();
            tot_list = map.GetAllProjects();
            Link_List = GetProjectLinks(ProjectID, RoadmapName);
            Dep_Names = newproj.GetDependantStrings();

            //DELETE ALL DEPENDENTS
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandText = "DELETE FROM [dbo].[Dependents] WHERE ProjectName=@Pname AND RoadmapName=@Rname";
                    cmd.Parameters.AddWithValue("@Pname", ProjectID);
                    cmd.Parameters.AddWithValue("@Rname", RoadmapName);
                    cmd.Connection = conn;

                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }
            }

            //Add in new dependents list
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ConnectionString))
            {
                foreach (string s in proj_dep)
                {
                    Project proj=null;
                    foreach (Project pro in tot_list)
                    {
                        if (pro.GetDescription() == s)
                        {
                            proj = pro;
                        }
                    }
                    if (proj == null) break;
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.CommandText = "INSERT INTO [dbo].[Dependents] (ProjectName, DependantName,Description, RoadmapName) VALUES (@Pname, @Dname,'this column is dumb', @Rname)";
                        cmd.Parameters.AddWithValue("@Pname", ProjectID);
                        cmd.Parameters.AddWithValue("@Dname", proj.GetName());
                        cmd.Parameters.AddWithValue("@Rname", RoadmapName);
                        cmd.Connection = conn;

                        conn.Open();
                        cmd.ExecuteNonQuery();
                        conn.Close();
                    }
                }
            }

            //SEPARATE THE LINK
            //Check if link exists, if not create it
            bool lflag = false;

            foreach (string str_link in link_arr)
            {
                lflag = false;
                foreach (Link l_list in Link_List)
                {
                    if (str_link == l_list.GetLink())
                    {
                        lflag = true;
                    }
                }
                if (lflag == false)
                {
                    newproj.CreateLink(new Link("", ProjectID, str_link, RoadmapName));
                }
            }

            //Delete Links
            foreach (Link l in Link_List)
            {
                bool flag = false;
                foreach (string l_list in link_arr)
                {
                    if (l.GetLink() == l_list)
                    {
                        flag = true;
                    }
                }
                if (flag == false)
                {
                    newproj.DeleteLink(l);
                }
            }

            //SEPARATE THER STRINGDEPENDENCY
            //Check if a string depenedency is already in the list
            foreach (string s in string_dep)
            {
                if (!Dep_Names.Contains(s))
                {
                    Dep_Names.Add(s);
                }
            }

            //remove any that are in the list but not in the send in array
            foreach (string s in Dep_Names)
            {
                if (!string_dep.Contains(s))
                {
                    Dep_Names2.Add(s);
                }
            }
            foreach (string s in Dep_Names2)
            {
                Dep_Names.Remove(s);
            }

            newproj.UpdateDependantStrings(Dep_Names);
        }
Ejemplo n.º 2
0
        public static List<string> GetAllRoadmapProjectDesc(string RoadmapName)
        {
            List<Project> All_proj = new List<Project>();
            List<string> return_string = new List<string>();
            RoadMap map = new RoadMap(RoadmapName);
            All_proj = map.GetAllProjects();

            foreach (Project p in All_proj)
            {
                return_string.Add(p.GetDescription());
            }

            //return all the porjects names
            return return_string;
        }
Ejemplo n.º 3
0
 public static List<Project> GetAllRoadmapProjects(string RoadmapName)
 {
     RoadMap map = new RoadMap(RoadmapName);
     return map.GetAllProjects();
 }
Ejemplo n.º 4
0
        public static string[][] GetAll(string ProjectID, string RoadmapName)
        {
            int pointindex = ProjectID.IndexOf("Bus");
            int valindex = ProjectID.IndexOf("Proj");
            string point = ProjectID.Substring(0, pointindex);
            string val = ProjectID.Substring(0, valindex);
            RoadMap map = new RoadMap(RoadmapName);
            StrategyPoint newpoint = map.GetPoint(point);
            BusinessValue newval = newpoint.GetBusinessValue(val);
            Project newproj = newval.GetProject(ProjectID);

            List<string> DepStr = new List<string>();
            List<string> DepProj = new List<string>();
            List<string> Link = new List<string>();
            List<string> AllProj = new List<string>();
            List<string> Proj = new List<string>();
            string Desc = newproj.GetModalDescription();
            string Risk = newproj.GetProjectRisks();
            string Name = newproj.GetDescription();

            DepStr = newproj.GetDependantStrings();
            DepProj = GetProjectDependency(ProjectID, RoadmapName);
            Link = GetProjectLinksString(ProjectID, RoadmapName);
            AllProj = GetAllRoadmapProjectDesc(RoadmapName);

            List<Project> all_projs = map.GetAllProjects();
            List<string> DepProjNames = new List<string>();
            foreach (string s in DepProj)
            {
                foreach (Project proj in all_projs)
                {
                    if(proj.GetName() == s)
                    {
                        DepProjNames.Add(proj.GetDescription());
                    }
                }
            }

            foreach(string rem in AllProj)
            {
                if (rem != Name) {
                    Proj.Add(rem);
                }
            }

            string[][] final_return = new string[7][];
            final_return[0] = new string[1];
            final_return[1] = new string[1];
            final_return[2] = new string[1];
            final_return[3] = new string[DepStr.Count];
            final_return[4] = new string[DepProj.Count];
            final_return[5] = new string[Link.Count];
            final_return[6] = new string[Proj.Count];

            final_return[0][0] = Desc;
            final_return[1][0] = Risk;
            final_return[2][0] = Name;
            int y = 0, x = 0, z = 0, a = 0;

            foreach (string ds in DepStr)
            {
                final_return[3][x] = ds;
                x++;
            }
            foreach (string dp in DepProjNames)
            {
                final_return[4][a] = dp;
                a++;
            }
            foreach (string l in Link)
            {
                final_return[5][z] = l;
                z++;
            }
            foreach (string ap in Proj)
            {
                final_return[6][y] = ap;
                y++;
            }

            return final_return;
        }