private void frmReporter_Load(object sender, EventArgs e) { Application.DoEvents(); var hlpr = new DHMisc(); // i think getting syncs is unneeded since devprojects has the syncid in it // and handling syncs and projects is over complicating this issue // SyncList = hlpr.GetProjectSyncs(); //TODO: look for ssms projects which are not .master ProjList = hlpr.GetProjectsForReporting(); lvProjects.Items.Clear(); string syncID = string.Empty; foreach (var item in ProjList.Projects) { string sync = item.SyncID; if (sync == syncID) { continue; } syncID = sync; var lvi = new ListViewItem(item.DevProjectName); lvi.SubItems.Add(item.DevProjectCount.ToString()); var displayName = ProjList.Names.Find(x => x.UserName == item.UserName); lvi.SubItems.Add(displayName != null ? displayName.DisplayName : item.UserName); lvProjects.Items.Add(lvi); } lbDevelopers.Items.Clear(); lbDevelopers.Items.Add("All"); List <DeveloperNames> developers = hlpr.GetDeveloperNames(); if (AppWrapper.AppWrapper.UserPermissionLevel == PermissionLevel.Developer) { var devObj = developers.Find(o => o.UserName.ToLower() == Environment.UserName.ToLower()); if (devObj != null) { lbDevelopers.Items.Add(devObj.UserName + " - " + devObj.UserDisplayName); lbDevelopers.SelectedIndex = 1; lbDevelopers.Enabled = false; } } else { foreach (var developer in developers) { lbDevelopers.Items.Add(developer.UserName + " - " + developer.UserDisplayName); } } AppList = hlpr.GetNotableApplications(); lbApplications.Items.Clear(); lbApplications.Items.Add("All Applications"); lbApplications.Items.Add("All Listed Applications"); foreach (var item in AppList) { lbApplications.Items.Add(item.AppFriendlyName); } }
/// <summary> /// NOTE: there could be multiple collaborative projects with the same name /// this code must handle that situation /// </summary> public ProjAndSyncReport GetProjectsForReporting() { using (var cmd = new SqlCommand("DevTrkr..GetProjectsForReporting")) { var ds = GetDataSet(cmd); ProjAndSyncReport rptData = new ProjAndSyncReport(); List <ReportProjects> list = new List <ReportProjects>(); // these variables work to handle multiple collaborative projs same name string projName = string.Empty; string syncID = string.Empty; foreach (DataRow dr in ds.Tables[0].Rows) { string devProjName = dr["DevProjectName"].ToString(); string sync = Convert.ToString(dr["SyncID"]); if (projName == devProjName && sync == syncID) { continue; } projName = devProjName; syncID = sync; list.Add(new ReportProjects { DevProjectName = (string)dr["DevProjectName"], DevProjectCount = (int)dr["DevProjectCount"], SyncID = Convert.ToString(dr["SyncID"]), UserName = (string)dr["UserName"], DevSLNPath = dr["DevSLNPath"] != DBNull.Value ? (string)dr["DevSLNPath"] : string.Empty, GitURL = dr["GitURL"] != DBNull.Value ? (string)dr["GitURL"] : string.Empty, DatabaseProject = dr["DatabaseProject"] == DBNull.Value ? false : (bool)dr["DatabaseProject"] }); } rptData.Projects = list; rptData.Names = (from DataRow dr in ds.Tables[1].Rows select new ReportUserNames { UserName = (string)dr["UserName"], DisplayName = (string)dr["UserDisplayName"] }).ToList(); return(rptData); } }