Пример #1
0
        internal static XlHlp.XlLocation ProcessAddSectionCommand_BuildServer(
            XlHlp.XlLocation insertAt,
            IBuildServer buildServer,
            TeamProject teamProject,
            string sectionTitle,
            RequestHandlers.ProcessAddHeaderCommand addHeaderCommand,
            ProcessAddBodyCommand_BS addBodyCommand,
            string tablePrefix)
        {
            long startTicks = XlHlp.DisplayInWatchWindow(insertAt);

            try
            {
                // Save the location of the title so we can update later after have traversed all items.

                Range rngTitle = insertAt.GetCurrentRange();

                if (insertAt.OrientVertical)
                {
                    XlHlp.AddSectionInfo(insertAt.AddRow(), sectionTitle, "");
                }
                else
                {
                    XlHlp.AddSectionInfo(insertAt.AddRow(), sectionTitle, "",
                                         orientation: XlOrientation.xlUpward);
                    insertAt.IncrementColumns();
                }

                insertAt.MarkStart(XlHlp.MarkType.GroupTable);

                addHeaderCommand(insertAt);

                addBodyCommand(insertAt, buildServer, teamProject);

                insertAt.MarkEnd(XlHlp.MarkType.GroupTable, string.Format("{0}_{1}", tablePrefix, teamProject.Name));

                insertAt.Group(insertAt.OrientVertical);

                insertAt.EndSectionAndSetNextLocation(insertAt.OrientVertical);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            XlHlp.DisplayInWatchWindow("End: " + DateTime.Now);
            XlHlp.DisplayInWatchWindow(insertAt, startTicks, "End");

            return(insertAt);
        }
Пример #2
0
        private static string CopyRowsToNewWorkSheet(Worksheet sourceWs, int startRow, int endRow, string sheetName)
        {
            sheetName = XlHlp.SafeSheetName(sheetName);
            Worksheet destinationWS = XlHlp.NewWorksheet(sheetName, afterSheetName: "LAST");

            XlHlp.XlLocation insertAt = new XlHlp.XlLocation(destinationWS, row: 5, column: 1);

            insertAt.MarkStart(XlHlp.MarkType.GroupTable);

            CreateLogWorkSheetHeader(insertAt);

            insertAt.AddRowX();

            // HACK(crhodes)
            //
            // There are 14 columns normally, grab five more just in case
            // We can do better than this by finding the last active column.
            // Extra columns can appear when an exception messes up the formatting of the log file.

            Range sourceRng;

            sourceRng = sourceWs.Range[sourceWs.Cells[startRow, 1], sourceWs.Cells[endRow, 19]];  //.Cells[startRow, 1];

            sourceRng.Copy();

            insertAt.GetCurrentRange().PasteSpecial();

            destinationWS.Activate();

            // Things come over messed up.  Unfreeze
            //Globals.ThisAddIn.Application.ActiveWindow.FreezePanes = false;

            Range rng;

            rng = destinationWS.Cells[5, 1];

            Int32 lastRow    = rng.SpecialCells(XlCellType.xlCellTypeLastCell).Row;
            Int32 lastColumn = rng.SpecialCells(XlCellType.xlCellTypeLastCell).Column;

            XlHlp.DisplayInWatchWindow(string.Format("{0}() row:({1}) col:({2})",
                                                     MethodBase.GetCurrentMethod().Name, lastRow, lastColumn));

            insertAt.SetRow(lastRow + 1);
            insertAt.SetColumn(lastColumn);

            insertAt.MarkEnd(VNC.AddinHelper.Excel.MarkType.GroupTable, string.Format("tbl_{0}", destinationWS.Name));

            //rng = destinationWS.Columns["E:K"];
            //rng.Columns.Group();
            destinationWS.Columns["E:K"].Columns.Group();

            //destinationWS.Cells[6, 14].Select();

            //destinationWS.Application.ActiveWindow.FreezePanes = true;

            // TODO(crhodes)
            // Figure out what to do to make outlining work.

            //sourceWs.Outline.SummaryColumn = XlSummaryColumn.xlSummaryOnLeft;
            //sourceWs.Outline.SummaryRow = XlSummaryRow.xlSummaryAbove;
            return(sheetName);
        }
Пример #3
0
        internal static XlHlp.XlLocation Add_Members(
            XlHlp.XlLocation insertAt,
            TeamProject teamProject)
        {
            long startTicks = XlHlp.DisplayInWatchWindow(insertAt);

            try
            {
                int currentRows = insertAt.RowsAdded;

                // Save the location of the count so we can update later after have traversed all items.

                Range rngTitle = insertAt.GetCurrentRange();

                if (insertAt.OrientVertical)
                {
                    XlHlp.AddSectionInfo(insertAt.AddRow(),
                                         "Members Group", "");
                }
                else
                {
                    XlHlp.AddSectionInfo(insertAt.AddRow(),
                                         "Members Group", "",
                                         orientation: XlOrientation.xlUpward);
                    insertAt.IncrementColumns();
                }

                TeamFoundationIdentity[] projectGroups = AzureDevOpsExplorer.Presentation.Views.Server.IdentityManagementService.ListApplicationGroups(
                    teamProject.ArtifactUri.AbsoluteUri, ReadIdentityOptions.None);

                Dictionary <IdentityDescriptor, object> descriptorSet = new Dictionary <IdentityDescriptor, object>(IdentityDescriptorComparer.Instance);

                foreach (TeamFoundationIdentity projectGroup in projectGroups)
                {
                    descriptorSet[projectGroup.Descriptor] = projectGroup.Descriptor;
                }

                // Expanded membership of project groups
                projectGroups = AzureDevOpsExplorer.Presentation.Views.Server.IdentityManagementService.ReadIdentities(descriptorSet.Keys.ToArray(), MembershipQuery.Expanded, ReadIdentityOptions.None);

                // Collect all descriptors
                foreach (TeamFoundationIdentity projectGroup in projectGroups)
                {
                    foreach (IdentityDescriptor mem in projectGroup.Members)
                    {
                        descriptorSet[mem] = mem;
                    }
                }

                // NOTE(crhodes)
                // Might need to ensure that _Global_Groups and _Global_Identities already populated.

                if (Section_TeamProjectCollection._Global_Identities.Count == 0)
                {
                    TeamFoundationIdentity everyoneExpanded = AzureDevOpsExplorer.Presentation.Views.Server.IdentityManagementService.ReadIdentity(
                        GroupWellKnownDescriptors.EveryoneGroup, MembershipQuery.Expanded, ReadIdentityOptions.None);
                    AZDOHelper.FetchIdentities(everyoneExpanded.Members, Section_TeamProjectCollection._Global_Groups, Section_TeamProjectCollection._Global_Identities);
                }


                _TeamProject_Groups.Clear();
                _TeamProject_Identities.Clear();

                AZDOHelper.FetchIdentities(descriptorSet.Keys.ToArray(), _TeamProject_Groups, _TeamProject_Identities);

                insertAt.MarkStart(XlHlp.MarkType.GroupTable);
                // Keep in same order as fields, infra.

                // Group

                XlHlp.AddColumnHeaderToSheet(insertAt.AddOffsetColumn(), 50, "Identifier");
                XlHlp.AddColumnHeaderToSheet(insertAt.AddOffsetColumn(), 50, "Identity");

                // Members

                XlHlp.AddColumnHeaderToSheet(insertAt.AddOffsetColumn(), 15, "IsContainer");
                XlHlp.AddColumnHeaderToSheet(insertAt.AddOffsetColumn(), 50, "DisplayName");
                XlHlp.AddColumnHeaderToSheet(insertAt.AddOffsetColumn(), 80, "UniqueName");
                XlHlp.AddColumnHeaderToSheet(insertAt.AddOffsetColumn(), 40, "IdentityType");
                XlHlp.AddColumnHeaderToSheet(insertAt.AddOffsetColumn(), 20, "UniqueUserId");
                XlHlp.AddColumnHeaderToSheet(insertAt.AddOffsetColumn(), 10, "IsActive");

                insertAt.IncrementRows();

                foreach (TeamFoundationIdentity identity in _TeamProject_Groups)
                {
                    foreach (IdentityDescriptor member in identity.Members)
                    {
                        insertAt.ClearOffsets();

                        try
                        {
                            // Group

                            XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), identity.Descriptor.Identifier);
                            XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), identity.DisplayName);

                            // Members

                            // NOTE(crhodes)
                            // This line is throwing exception.  Why?

                            XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), Section_TeamProjectCollection._Global_Identities[member].IsContainer.ToString());
                            XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), Section_TeamProjectCollection._Global_Identities[member].DisplayName);
                            XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), Section_TeamProjectCollection._Global_Identities[member].UniqueName);
                            XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), Section_TeamProjectCollection._Global_Identities[member].Descriptor.IdentityType);
                            XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), Section_TeamProjectCollection._Global_Identities[member].UniqueUserId.ToString());
                            XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), Section_TeamProjectCollection._Global_Identities[member].IsActive.ToString());
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }

                        insertAt.IncrementRows();
                    }
                }

                insertAt.MarkEnd(XlHlp.MarkType.GroupTable, string.Format("tblTPMembers_{0}", insertAt.workSheet.Name));

                insertAt.Group(insertAt.OrientVertical);

                // Update counts.  -2 covers Header and Table Column Header

                if (insertAt.OrientVertical)
                {
                    XlHlp.AddLabeledInfoX(rngTitle, "Members Group", (insertAt.RowsAdded - currentRows - 2).ToString());
                }
                else
                {
                    XlHlp.AddLabeledInfoX(rngTitle, "Members Group", (insertAt.RowsAdded - currentRows - 2).ToString(), orientation: XlOrientation.xlUpward);
                }

                insertAt.EndSectionAndSetNextLocation(insertAt.OrientVertical);

                //insertAt.AddRow();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            XlHlp.DisplayInWatchWindow(insertAt, startTicks, "End");

            return(insertAt);
        }