private void GetWorkItemInfo(WorkItemActionRequest request) { long startTicks = Log.EVENT_HANDLER("Enter", Common.PROJECT_NAME); try { RequestHandlers.SpeedUpStart(); char[] splitChars = { ',' }; int workItemId = 0; Options_AZDO_TFS options = GetOptions(); foreach (string workItem in request.WorkItemID.Split(splitChars, StringSplitOptions.None)) { if (int.TryParse(workItem, out workItemId)) { CreateWS_WIS_WorkItemInfo(workItemId, request, options); Globals.ThisAddIn.Application.ActiveWorkbook.Save(); } AZDOHelper.ProcessLoopDelay(options); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { RequestHandlers.SpeedUpEnd(); } Log.EVENT_HANDLER("Exit", Common.PROJECT_NAME, startTicks); }
void AddPivotSummary(WorkItemActionRequest request) { long startTicks = Log.EVENT_HANDLER("Enter", Common.PROJECT_NAME); Workbook wb = Globals.ThisAddIn.Application.ActiveWorkbook; Worksheet ws = Globals.ThisAddIn.Application.ActiveSheet; Microsoft.Office.Interop.Excel.Range activeCell = Globals.ThisAddIn.Application.ActiveCell; Options_AZDO_TFS options = new Options_AZDO_TFS(); int workItemID = int.Parse(request.WorkItemID); XlHlp.XlLocation insertAt = CreateNewWorksheet(string.Format("P_WI_{0}", workItemID), GetOptions()); // TODO(crhodes) // Figure out how to get the table name from the active cell. var tableName = activeCell.ListObject.Name; PivotCache pc = wb.PivotCaches().Create( SourceType: XlPivotTableSourceType.xlDatabase, SourceData: tableName, Version: 6); string insertRange = $"{insertAt.workSheet.Name}!R{options.StartingRow}C{options.StartingColumn}"; PivotTable pt = pc.CreatePivotTable(TableDestination: insertRange); // this is from the macro recording. Not all may be needed or desired. pt.ColumnGrand = true; pt.HasAutoFormat = true; pt.DisplayErrorString = false; pt.DisplayNullString = true; pt.EnableDrilldown = true; pt.ErrorString = ""; pt.MergeLabels = false; pt.NullString = ""; pt.PageFieldOrder = 2; pt.PageFieldWrapCount = 0; pt.PreserveFormatting = true; pt.RowGrand = true; pt.SaveData = true; pt.PrintTitles = false; pt.RepeatItemsOnEachPrintedPage = true; pt.TotalsAnnotation = false; pt.CompactRowIndent = 1; pt.InGridDropZones = false; pt.DisplayFieldCaptions = true; pt.DisplayMemberPropertyTooltips = false; pt.DisplayContextTooltips = true; pt.ShowDrillIndicators = true; pt.PrintDrillIndicators = false; pt.AllowMultipleFilters = false; pt.SortUsingCustomLists = true; pt.FieldListSortAscending = false; pt.ShowValuesRow = false; pt.CalculatedMembersInFilters = false; pt.RowAxisLayout(XlLayoutRowType.xlCompactRow); pt.PivotCache().RefreshOnFileOpen = false; pt.PivotCache().MissingItemsLimit = XlPivotTableMissingItems.xlMissingItemsDefault; PivotField pf1 = pt.PivotFields("Source.Type"); PivotField pf2 = pt.PivotFields("Target.Type"); pf1.Orientation = XlPivotFieldOrientation.xlRowField; pf1.Position = 1; pf2.Orientation = XlPivotFieldOrientation.xlRowField; pf2.Position = 2; //pt.AddDataField(pf1, "Count", XlConsolidationFunction.xlCount); //pf2.Orientation = XlPivotFieldOrientation.xlRowField; //pf2.Position = 2; //With ActiveSheet.PivotTables("PivotTable1").PivotFields("Target.Type") // .Orientation = xlRowField // .Position = 1 //End With //ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables(_ // "PivotTable1").PivotFields("Target.Type"), "Count of Target.Type", xlCount //With ActiveSheet.PivotTables("PivotTable1").PivotFields("SourceId") // .Orientation = xlRowField // .Position = 2 //End With insertAt.workSheet.Select(); Log.EVENT_HANDLER("Exit", Common.PROJECT_NAME, startTicks); }