public XpsEditor(List<Annotation> annotations) { if (annotations == null) { throw new ArgumentNullException(nameof(annotations)); } var byPages = annotations.GroupBy(a => a.PageNumber) .Select(g => new { Number = g.Key ?? -1, Annotations = g.ToArray() }) .OrderBy(g => g.Number) .ToList(); _commonAnnotations = _emptyAnnotations; var commonAnnotations = byPages.FirstOrDefault(p => p.Number == -1); if (commonAnnotations != null) { byPages.Remove(commonAnnotations); _commonAnnotations = commonAnnotations.Annotations.Select(a => new AnnotationData(a)).ToArray(); } _pageAnnotations = byPages.ToDictionary(p => p.Number, p => p.Annotations .Select(a => new AnnotationData(a)) .ToArray()); }
public OrgSelectEntity(List<ExtOrgObj> selectedValue) { this.SelectedValue = selectedValue; if (selectedValue != null && selectedValue.Count > 0) { IsMultipleType = selectedValue.GroupBy(item => item.ObjectType).Count() > 1; } }
public LaunchWindow() { string gameConfigurationFolder = "GameConfiguration"; string gameConfigurationsPath = Path.Combine(gameConfigurationFolder, "gameConfigs.json"); InitializeComponent(); if (!Directory.Exists(gameConfigurationFolder)) Directory.CreateDirectory(gameConfigurationFolder); //Loading the last used configurations for hammer RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"Software\Valve\Hammer\General"); var configs = new List<GameConfiguration>(); //try loading json if (File.Exists(gameConfigurationsPath)) { string jsonLoadText = File.ReadAllText(gameConfigurationsPath); configs.AddRange(JsonConvert.DeserializeObject<List<GameConfiguration>>(jsonLoadText)); } //try loading from registry if (rk != null) { string BinFolder = (string)rk.GetValue("Directory"); string gameData = Path.Combine(BinFolder, "GameConfig.txt"); configs.AddRange(GameConfigurationParser.Parse(gameData)); } //finalise config loading if (configs.Any()) { //remove duplicates configs = configs.GroupBy(g => g.Name).Select(grp => grp.First()).ToList(); //save string jsonSaveText = JsonConvert.SerializeObject(configs, Formatting.Indented); File.WriteAllText(gameConfigurationsPath, jsonSaveText); if (configs.Count == 1) Launch(configs.First()); GameGrid.ItemsSource = configs; } else//oh noes { LaunchButton.IsEnabled = false; WarningLabel.Content = "No Hammer configurations found. Cannot launch."; } }
protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); List<KeyValuePair<string, string>> images=new List<KeyValuePair<string, string>>(); /* Get image file with allowed extensions and group them with their directory */ images=ProjectTools.RetrieveFiles(ChooseImageDialog.Extension); IEnumerable<IGrouping<string, string>> grouping = images.GroupBy(image => image.Key, image => image.Value); /* Set values for _data and bind to the ListBox */ foreach(IGrouping<string, string> group in grouping){ List<string> temp=new List<string>(); foreach(var name in group){ temp.Add(name); } _data.Add(new ImageData(group.Key + Path.DirectorySeparatorChar,temp)); } Display.ItemsSource=_data; Display.SelectionChanged+=delegate { Display.SelectedItem=null; }; }
public NewForm() { InitializeComponent(); //Displays a SaveFileDialog so the user can save the xml template // assigned to Save Button. OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Xml file|*.xml"; if (!string.IsNullOrEmpty(Utility.lastDir)) openFileDialog1.InitialDirectory = Utility.lastDir; // Display OpenFileDialog by calling ShowDialog method Nullable<bool> result = openFileDialog1.ShowDialog(); // Get the selected file name and PARSE IT if (result == true) { Utility.lastDir = openFileDialog1.File.FullName; var list = new List<Element>(); var xElem = (XElement.Load(openFileDialog1.File.OpenRead())).Elements(); var serializer = new XmlSerializer(typeof(Element)); foreach (var item in xElem) { try { var test = (Element)serializer.Deserialize(item.CreateReader()); list.Add(test); } catch { throw; } } List<List<Element>> groupings = list.GroupBy(x => x.Type) .Select(x => x.ToList()).ToList(); foreach (var group in groupings) { string type = null; StackPanel stackVerticalMain = new StackPanel(); stackVerticalMain.Orientation = Orientation.Vertical; stackVerticalMain.Margin = new Thickness(10); WrapPanel wpFirst = new WrapPanel(); wpFirst.Orientation = Orientation.Horizontal; WrapPanel wpSecond = new WrapPanel(); wpSecond.Orientation = Orientation.Horizontal; WrapPanel wpThird = new WrapPanel(); wpThird.Orientation = Orientation.Horizontal; foreach (var element in group) { type = element.Type; if (element.Combo.Count == 0) { if (element.IsMultiple == true) { Border brd = new Border(); brd.BorderThickness = new Thickness(1); brd.Margin = new Thickness(5, 0, 0, 0); brd.BorderBrush = new SolidColorBrush(Colors.Transparent); brd.Background = new SolidColorBrush(Color.FromArgb(255, 34, 35, 37)); brd.Height = 150; ScrollViewer sv = new ScrollViewer(); sv.BorderBrush = new SolidColorBrush(Colors.Transparent); sv.Style = (Style)Helpers.FindResourceHelper.FindResource("ScrollViewerStyle1"); sv.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden; sv.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; StackPanel stackVertical = new StackPanel(); stackVertical.Orientation = Orientation.Vertical; stackVertical.Margin = new Thickness(10); StackPanel stackHorizontal = new StackPanel(); stackHorizontal.Orientation = Orientation.Horizontal; TextBlock textBlock = new TextBlock(); textBlock.Margin = new Thickness(5); textBlock.Text = element.Display; textBlock.Foreground = new SolidColorBrush(Color.FromArgb(255, 220, 220, 220)); stackHorizontal.Children.Add(textBlock); Button btnAdd = new Button(); btnAdd.Content = "ADD"; btnAdd.Style = (Style)Helpers.FindResourceHelper.FindResource("InformButton"); btnAdd.Margin = new Thickness(80, 5, 5, 5); btnAdd.Click -= new RoutedEventHandler(btnAdd_Click); btnAdd.Click += new RoutedEventHandler(btnAdd_Click); stackHorizontal.Children.Add(btnAdd); stackVertical.Children.Add(stackHorizontal); StackPanel hStack = new StackPanel(); hStack.Orientation = Orientation.Horizontal; TextBox textbox = new TextBox(); textbox.Margin = new Thickness(5, 5, 5, 5); textbox.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; textbox.Background = new SolidColorBrush(Color.FromArgb(255, 204, 204, 204)); textbox.Width = 200; textbox.Height = 25; hStack.Children.Add(textbox); stackVertical.Children.Add(hStack); sv.Content = stackVertical; brd.Child = sv; wpSecond.Children.Add(brd); } else { StackPanel stackPanel = new StackPanel(); stackPanel.Orientation = Orientation.Vertical; stackPanel.Margin = new Thickness(10); stackPanel.Background = new SolidColorBrush(Color.FromArgb(255, 34, 35, 37)); TextBlock textBlock = new TextBlock(); textBlock.Margin = new Thickness(5); textBlock.Text = element.Display; textBlock.Foreground = new SolidColorBrush(Color.FromArgb(255, 220, 220, 220)); stackPanel.Children.Add(textBlock); TextBox textbox = new TextBox(); textbox.Margin = new Thickness(10, 5, 10, 10); textbox.Background = new SolidColorBrush(Color.FromArgb(255, 204, 204, 204)); textbox.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; textbox.Width = 200; textbox.Height = 25; stackPanel.Children.Add(textbox); wpFirst.Children.Add(stackPanel); } } else { StackPanel stackPanel = new StackPanel(); stackPanel.Orientation = Orientation.Vertical; stackPanel.Margin = new Thickness(10); stackPanel.Background = new SolidColorBrush(Color.FromArgb(255, 34, 35, 37)); TextBlock textBlock = new TextBlock(); textBlock.Margin = new Thickness(5); textBlock.Text = element.Display; textBlock.Foreground = new SolidColorBrush(Color.FromArgb(255, 220, 220, 220)); stackPanel.Children.Add(textBlock); ComboBox cb = new ComboBox(); cb.Margin = new Thickness(10, 5, 10, 10); cb.Background = Background = new SolidColorBrush(Color.FromArgb(255, 204, 204, 204)); cb.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; cb.Width = 200; //TJS 05-18-2012 Modified to set Content and Tag of dropdown from the XML, so in ChangeEvent the tag can be placed into the destination field on the form string displayTitle = null; string destination = null; var q = from c in xElem.Descendants("Item") select (string)c.Element("DisplayTitle") + ";" + (string)c.Element("Destination"); foreach (string name in q) { string[] strings = name.Split(new[] { ";" }, System.StringSplitOptions.RemoveEmptyEntries); displayTitle = strings[0]; destination = strings[1]; ComboBoxItem cbItem = new ComboBoxItem(); cbItem.Content = displayTitle; cbItem.Tag = destination; cb.Items.Add(cbItem); } if (cb.Items.Count <= 0) { cb.ItemsSource = element.Combo; } cb.SelectionChanged += new SelectionChangedEventHandler(cb_SelectionChanged); // cb.ItemsSource = element.Combo; // End of TJS Modification block stackPanel.Children.Add(cb); wpThird.Children.Add(stackPanel); } } TextBox tbType = new TextBox(); tbType.Text = type; tbType.FontSize = 14; tbType.IsReadOnly = true; tbType.IsHitTestVisible = false; tbType.Foreground = new SolidColorBrush(Color.FromArgb(255, 220, 220, 220)); LinearGradientBrush myVerticalGradient = new LinearGradientBrush(); myVerticalGradient.StartPoint = new Point(0.0, 0.0); myVerticalGradient.EndPoint = new Point(0, 1); GradientStop g1 = new GradientStop(); g1.Color = Color.FromArgb(255, 76, 75, 80); g1.Offset = 0.28; myVerticalGradient.GradientStops.Add(g1); GradientStop g2 = new GradientStop(); g2.Color = Color.FromArgb(255, 76, 75, 80); g2.Offset = 0.0; myVerticalGradient.GradientStops.Add(g2); GradientStop g3 = new GradientStop(); g3.Color = Colors.LightGray; g3.Offset = 0.0; myVerticalGradient.GradientStops.Add(g3); tbType.Background = myVerticalGradient; stackVerticalMain.Children.Add(tbType); stackVerticalMain.Children.Add(wpFirst); stackVerticalMain.Children.Add(wpSecond); stackVerticalMain.Children.Add(wpThird); stackContent.Children.Add(stackVerticalMain); } } }
private void UPWR(string[] pids) { string dt = DateTime.Now.Day.ToString("00") + DateTime.Now.Month.ToString("00") + DateTime.Now.Year.ToString().Substring(2, 2); Microsoft.Win32.OpenFileDialog ofg = new Microsoft.Win32.OpenFileDialog(); ofg.DefaultExt = ".xlsx"; ofg.Filter = "WR Spreadsheet (.xlsx)|*.xlsx"; Nullable<bool> result = ofg.ShowDialog(); List<DevT> DevTrackList = new List<DevT>(); bool worked = false; string[] debug = new string[4]; if (result == true) { Dispatcher.Invoke((System.Action)delegate() { status.Content = "Analyzing spreadsheet..."; pBar.Visibility = Visibility.Visible; pBar.Value = 0; }); string textSave = ofg.FileName.Substring(0, ofg.FileName.Length - 4) + "txt"; string dtPicked = "";//2015-01-27 DateTime selectedDT = new DateTime(); bool doAll = false; Dispatcher.Invoke((System.Action)delegate() { doAll = doAllcb.IsChecked.Value; if (!doAll) { selectedDT = dtPick.SelectedDate.Value; string dtDay = dtPick.SelectedDate.Value.Day.ToString("00"); string dtMonth = dtPick.SelectedDate.Value.Month.ToString("00"); string dtYear = dtPick.SelectedDate.Value.Year.ToString("0000"); dtPicked = dtYear + "-" + dtMonth + "-" + dtDay; } }); using (StreamWriter sw = File.CreateText(textSave)) { if (doAll) { sw.WriteLine("All Dates"); } else { sw.WriteLine(dtPicked); } foreach (string pid in pids) { sw.WriteLine(pid); } } #region analyzeExcel Excel.Application xlApp = null; Excel.Workbook OldBook = null; Excel.Worksheet OldSheet = null; Excel.Sheets sheets = null; Excel.Range xlR = null; Excel.Worksheet dpSheet = null; try { xlApp = new Excel.Application(); ; xlApp.DisplayAlerts = false; OldBook = xlApp.Workbooks.Open(ofg.FileName, false, false, Type.Missing, Type.Missing, Type.Missing, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); OldSheet = OldBook.Sheets[1]; sheets = OldBook.Sheets; string oldversion = OldSheet.get_Range("G1").Value; if (oldversion != "Request" + Environment.NewLine + "Status") { xlR = OldSheet.get_Range("G1", "I1").EntireColumn; xlR.Insert(Excel.XlInsertShiftDirection.xlShiftToRight); OldSheet.Cells[1, 7] = "Request" + Environment.NewLine + "Status"; OldSheet.Cells[1, 8] = "Requested" + Environment.NewLine + "Date"; OldSheet.Cells[1, 9] = "Planned" + Environment.NewLine + "Release Date"; } int OldMR = OldSheet.UsedRange.Rows.Count; object[,] OldData = OldSheet.get_Range("A2:R" + OldMR).Value; List<string> OldWRs = getColumn(OldData, 5); List<string> OldPID = getColumn(OldData, 3); string ignoreItem = "qwertyuiop12345"; Dispatcher.Invoke((System.Action)delegate() { status.Content = "Retrieving data from DevTrack..."; pBar.Visibility = Visibility.Visible; pBar.Value = 0; ignoreItem = ignoreBox.Text; }); string[] ignoreItems = System.Text.RegularExpressions.Regex.Split(ignoreItem, ", "); List<DevT> OpenDevItems = OpenDevT(pids, ignoreItems); List<DevT> LatestOpenDevItems = new List<DevT>(); List<WR> JIRAitems = new List<WR>(); bool isError = false; foreach (DevT DTitem in OpenDevItems) { if (DTitem == null) isError = true; } if (isError) {//devtrack connection issues? skipped a beat Dispatcher.Invoke((System.Action)delegate() { pBar.Visibility = System.Windows.Visibility.Hidden; status.Content = "DevTrack possibly busy/unavailable, trying to reconnect." + Environment.NewLine + "Please wait, retries occur ~3seconds.."; }); while (isError) { Thread.Sleep(3000);//wait for devtrack to cooldown, possible connection/timeout issues. OpenDevItems = OpenDevT(pids, ignoreItems); for (int i = 0; i < OpenDevItems.Count; i++) { if (OpenDevItems[i] == null) { isError = true; break; } else { isError = false; } } } } if (!doAll) { Parallel.ForEach(OpenDevItems, DTitem => { if (DTitem.createdDate >= selectedDT) { LatestOpenDevItems.Add(DTitem); } }); } else { LatestOpenDevItems = OpenDevItems; } List<string> nowClosed = getNowClosed(LatestOpenDevItems, OldWRs); List<string> urls = makeUrl(LatestOpenDevItems); List<string> closedURLs = mkoldURLs(nowClosed); if (nowClosed.Count > 0) { urls.AddRange(closedURLs); } double j = 100.0; double k = j / urls.Count(); Dispatcher.Invoke((System.Action)delegate() { status.Content = "Querying a lot of JIRA..."; pBar.Visibility = Visibility.Visible; pBar.Value = 0; }); //int speed = 987;//get wait //foreach (string qry in urls) { // JIRAitems.Add(pJSON(qry)); // Dispatcher.Invoke((System.Action)delegate() { // pBar.Value += k; // }); // Thread.Sleep(speed); //} Parallel.ForEach(urls, qry => { JIRAitems.Add(pJSON(qry)); Dispatcher.Invoke((System.Action)delegate() { pBar.Value += k; }); }); Dispatcher.Invoke((System.Action)delegate() { status.Content = "Parsing JIRA data..."; }); List<WRQuery> JItemsC = new List<WRQuery>(); foreach (WR dd in JIRAitems) { foreach (Jissues info in dd.issues) { JItemsC.Add(new WRQuery(info, pids)); } } Dispatcher.Invoke((System.Action)delegate() { status.Content = "Finding JIRA errors..."; }); List<string> notInJIRA = new List<string>(); foreach (DevT lodi in LatestOpenDevItems) { if (DevWRExists(JItemsC, lodi.WR) < 0) { notInJIRA.Add(lodi.WR); } } Dispatcher.Invoke((System.Action)delegate() { status.Content = "Wrestling Excel..."; pBar.Value = 0; }); if (JIRAitems.Count != 0) { List<string> cautions = new List<string>(); string dtNow = DateTime.Now.Month.ToString("00") + "-" + DateTime.Now.Day.ToString("00") + "-" + DateTime.Now.Year.ToString().Substring(2, 2); if (!doAll) { OldSheet.Name = dtPicked + " and newer"; } else { OldSheet.Name = "All"; } int nXLcount = LatestOpenDevItems.Count(); double iB = 100.0; double iJ = iB / nXLcount; int rowCount = 2; //start at row 2 int insOffset = 0; int maxR = OldData.GetLength(0); foreach (DevT DT in LatestOpenDevItems) { //foreach found valid devtrack item debug[0] = DT.WR; debug[1] = DT.Project; int xWR = DevWRExists(JItemsC, DT.WR); //find it in the JIRA data string wSuite = "WR NOT IN JIRA!"; string wSummary = "WR NOT IN JIRA!"; string wCurRel = "WR NOT IN JIRA!"; string wIT = "WR NOT IN JIRA!"; string wProd = "WR NOT IN JIRA!"; string wStatus = "WR NOT IN JIRA!"; string rStatus = "WR NOT IN JIRA!"; string rDate = "WR NOT IN JIRA!"; string dDate = "WR NOT IN JIRA!"; string wDesc = "WR NOT IN JIRA! Contact Development for assistance with this WR."; if (xWR >= 0) { //if it exists in the JIRA data, update the default strings wSuite = JItemsC[xWR].Suite; wSummary = JItemsC[xWR].Summary; rStatus = JItemsC[xWR].RequestedStatus; rDate = JItemsC[xWR].RequestedDate; dDate = JItemsC[xWR].DueDate; wCurRel = JItemsC[xWR].CurrentRelease; wIT = JItemsC[xWR].IssueType; wStatus = JItemsC[xWR].Resolution + Environment.NewLine + JItemsC[xWR].Status; wProd = JItemsC[xWR].Product; wDesc = JItemsC[xWR].Description; } int jets = getSIndex(OldWRs, OldPID, DT.WR, DT.Project); debug[3] = jets.ToString(); if (jets < 0) { //new item string cdate = DT.createdDate.Month + "-" + DT.createdDate.Day + "-" + DT.createdDate.Year; string[] newLine = { dtNow, "No", DT.Project, wSuite, DT.WR, wStatus, rStatus, rDate, dDate, cdate, wSummary, "'" + wDesc, wProd, wCurRel, DT.IV, DT.IVseverity, DT.NeedByEvent, DT.NeedByDate }; object[,] xlNewLine = new object[1, newLine.Length]; for (int i = 0; i < newLine.Length; i++) { xlNewLine[0, i] = newLine[i]; } //insert row at end xlR = OldSheet.get_Range("A" + (maxR + 2), "A" + (maxR + 2)).EntireRow; xlR.Insert(Excel.XlInsertShiftDirection.xlShiftDown); xlR = OldSheet.Range["A" + (maxR + 2), getAlpha(newLine.Length) + (maxR + 2)]; xlR.Interior.ColorIndex = 0; xlR.Value2 = xlNewLine; maxR++; } else { //existing item //check if updates occured //-update item, highlight yellow // string[] oldRow = getRow(OldData, jets + 1).ToArray(); bool updated = false; int[] colData = new int[] { 4, 6, 7, 8, 9, 11, 13, 14, 16, 17, 18 }; string[] colDx = new string[] { wSuite, wStatus, rStatus, rDate, dDate, wSummary, wProd, wCurRel, DT.IVseverity, DT.NeedByEvent, DT.NeedByDate }; for (int i = 0; i < colData.Length; i++) { string undated = undate(oldRow[colData[i] - 1]); if (undate(colDx[i]) != undated) { if (undated != "") { string ttemp = "Was: " + undated + Environment.NewLine + Environment.NewLine + "Now: " + colDx[i]; OldSheet.Range[getAlpha(colData[i]) + (insOffset + jets + 2), Type.Missing].Interior.ColorIndex = 6; OldSheet.Cells[insOffset + jets + 2, colData[i]] = ttemp; updated = true; } else { string ttemp = colDx[i]; OldSheet.Cells[insOffset + jets + 2, colData[i]] = ttemp; } } } if (updated) { OldSheet.Cells[insOffset + jets + 2, 2] = "Yes"; } } //progress bar rowCount++; Dispatcher.Invoke((System.Action)delegate() { pBar.Value += iJ; }); } foreach (string closedWR in nowClosed) { int xWR = DevWRExists(JItemsC, closedWR); string rStatus = "WR NOT IN JIRA!"; string rDate = "WR NOT IN JIRA!"; string dDate = "WR NOT IN JIRA!"; string wSuite = "WR NOT IN JIRA!"; string wSummary = "WR NOT IN JIRA!"; string wCurRel = "WR NOT IN JIRA!"; string wIT = "WR NOT IN JIRA!"; string wProd = "WR NOT IN JIRA!"; string wStatus = "WR NOT IN JIRA!"; string wDesc = "WR NOT IN JIRA! Contact Development for assistance with this WR."; if (xWR >= 0) { //if it exists in the JIRA data, update the default strings wSuite = JItemsC[xWR].Suite; wSummary = JItemsC[xWR].Summary; wCurRel = JItemsC[xWR].CurrentRelease; rStatus = JItemsC[xWR].RequestedStatus; rDate = JItemsC[xWR].RequestedDate; dDate = JItemsC[xWR].DueDate; wIT = JItemsC[xWR].IssueType; wStatus = JItemsC[xWR].Resolution + Environment.NewLine + JItemsC[xWR].Status; wProd = JItemsC[xWR].Product; wDesc = JItemsC[xWR].Description; } int jets = getIndex(OldWRs, closedWR); debug[3] = jets.ToString(); string[] oldRow = getRow(OldData, jets + 1).ToArray(); int[] colData = new int[] { 4, 6, 7, 8, 9, 11, 13, 14 }; string[] colDx = new string[] { wSuite, wStatus, rStatus, rDate, dDate, wSummary, wProd, wCurRel }; for (int i = 0; i < colData.Length; i++) { string undated = undate(oldRow[colData[i] - 1]); if (undate(colDx[i]) != undated) { if (undated != "") { string ttemp = "Was: " + undated + Environment.NewLine + Environment.NewLine + "Now: " + colDx[i]; OldSheet.Range[getAlpha(colData[i]) + (insOffset + jets + 2), Type.Missing].Interior.ColorIndex = 6; OldSheet.Cells[insOffset + jets + 2, colData[i]] = ttemp; } else { string ttemp = colDx[i]; OldSheet.Cells[insOffset + jets + 2, colData[i]] = ttemp; } } } string xtemp = oldRow[9].Split(' ')[0]; OldSheet.Cells[insOffset + jets + 2, 10] = "Was: " + xtemp + Environment.NewLine + Environment.NewLine + "But it was not found" + Environment.NewLine + "Check dates, closure," + Environment.NewLine + "or linked status."; OldSheet.Range["J" + (insOffset + jets + 2), Type.Missing].Interior.ColorIndex = 6; OldSheet.Cells[insOffset + jets + 2, 2] = "Yes"; } } #endregion int maxRf = OldSheet.UsedRange.Rows.Count; object[,] arr = OldSheet.get_Range("C2:E" + maxRf).Value; List<string> ProjectRow = new List<string>(); List<string> ProjectWR = new List<string>(); for (int i = 1; i < maxRf; i++) { ProjectRow.Add(arr[i, 1].ToString()); ProjectWR.Add(arr[i, 3].ToString()); } List<string> duplicatedWRs = ProjectWR.GroupBy(x => x) .Where(group => group.Count() > 1) .Select(group => group.Key).ToList(); if (duplicatedWRs.Count > 0) { if (sheets.Count > 1) { xlApp.DisplayAlerts = false; OldBook.Sheets[2].Delete(); } dpSheet = (Worksheet)sheets.Add(Type.Missing, sheets[1], Type.Missing, Type.Missing); dpSheet.Name = "Updated Duplicate WRs"; int rowToPrint = 2; dpSheet.Cells[1, 1] = "Duplicated" + Environment.NewLine + "WRs Found"; dpSheet.Cells[1, 2] = "Projects found linked"; dpSheet.Cells[1, 3] = "These WRs did NOT get updated correctly, and will require a manual review!"; foreach (string dWRx in duplicatedWRs) { debug[3] = rowToPrint.ToString(); string ProjectsFound = ""; for (int i = 0; i < ProjectWR.Count; i++) { if (dWRx == ProjectWR[i]) { if (ProjectsFound == "") { ProjectsFound += ProjectRow[i]; } else { ProjectsFound += Environment.NewLine + ProjectRow[i]; } } } //print this WR dpSheet.Cells[rowToPrint, 1] = dWRx; dpSheet.Cells[rowToPrint, 2] = ProjectsFound; rowToPrint++; } dpSheet.get_Range("A:A", Type.Missing).EntireColumn.ColumnWidth = 16; dpSheet.get_Range("B:B", Type.Missing).EntireColumn.ColumnWidth = 32; dpSheet.get_Range("A:B", Type.Missing).EntireColumn.VerticalAlignment = XlVAlign.xlVAlignCenter; dpSheet.get_Range("A:B", Type.Missing).EntireColumn.HorizontalAlignment = XlHAlign.xlHAlignCenter; dpSheet.get_Range("A1", "B1").Cells.Font.Bold = true; dpSheet.Select(); // } else { if (sheets.Count > 1) { xlApp.DisplayAlerts = false; OldBook.Sheets[2].Delete(); } } //Data Validation string validS = "Urgent,High,Med,Low,SCT";//MATCH WRPR above string validW = "Urgent,High,Med,Low"; //string validC = "High,Med,Low,Not required"; string validU = "Yes,No"; OldSheet.get_Range("B2", "Z" + (maxRf - 1)).Validation.Delete(); //gotta clear it before we can set it. OldSheet.get_Range("B2", "B" + (maxRf - 1)).Validation.Add(XlDVType.xlValidateList, XlDVAlertStyle.xlValidAlertStop, XlFormatConditionOperator.xlBetween, validU, Type.Missing); OldSheet.get_Range("S2", "S" + (maxRf - 1)).Validation.Add(XlDVType.xlValidateList, XlDVAlertStyle.xlValidAlertStop, XlFormatConditionOperator.xlBetween, validS, Type.Missing); OldSheet.get_Range("W2", "W" + (maxRf - 1)).Validation.Add(XlDVType.xlValidateList, XlDVAlertStyle.xlValidAlertStop, XlFormatConditionOperator.xlBetween, validW, Type.Missing); OldSheet.get_Range("U2", "U" + (maxRf - 1)).Validation.Add(XlDVType.xlValidateList, XlDVAlertStyle.xlValidAlertStop, XlFormatConditionOperator.xlBetween, validW, Type.Missing); worked = true; OldBook.SaveAs(ofg.FileName, XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, false, false, XlSaveAsAccessMode.xlNoChange, XlSaveConflictResolution.xlLocalSessionChanges, Type.Missing, Type.Missing, Type.Missing); OldBook.Close(true, Type.Missing, Type.Missing); xlApp.Quit(); } catch (Exception e) { OldBook.Close(false, Type.Missing, Type.Missing); xlApp.Quit(); if(e.Message=="Object reference not set to an instance of an object."){ MessageBoxResult dialogResult = new MessageBoxResult(); dialogResult = MessageBox.Show("Formatting issue " + debug[1] + " " + debug[0] + Environment.NewLine + debug[3] + " ERROR:" + e.Message + Environment.NewLine + "Likely blank rows at bottom of table." +Environment.NewLine + "Try deleting several entire rows below the table.", "TRY AGAIN - Fatal error with Excel", MessageBoxButton.OK); Dispatcher.Invoke((System.Action)delegate() { status.Content = "Failed! Excel is garbage :("; }); } else { MessageBoxResult dialogResult = new MessageBoxResult(); dialogResult = MessageBox.Show("Investigate/remove " + debug[1] + " " + debug[0] + Environment.NewLine + debug[3] + " ERROR:" + e.Message + Environment.NewLine + "Possible JIRA interference!", "TRY AGAIN - Fatal error with Excel", MessageBoxButton.OK); Dispatcher.Invoke((System.Action)delegate() { status.Content = "Failed! Excel is garbage :("; }); } result = false; } finally { releaseObject(xlR); releaseObject(dpSheet); releaseObject(sheets); releaseObject(OldSheet); releaseObject(OldBook); releaseObject(xlApp); } } Dispatcher.Invoke((System.Action)delegate() { pBar.Visibility = Visibility.Hidden; pBar.Value = 0; if (worked) { status.Content = "Completed! Please close the application."; } }); }
private void WRPR(string[] pids) { string dt = DateTime.Now.Day.ToString("00") + DateTime.Now.Month.ToString("00") + DateTime.Now.Year.ToString().Substring(2, 2); Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = "_" + dt + "_WRReports"; dlg.DefaultExt = ".xlsx"; dlg.Filter = "Excel Workbook (.xlsx)|*.xlsx"; string[] debug = new string[4]; Nullable<bool> result = dlg.ShowDialog(); List<DevT> DevTrackList = new List<DevT>(); if (result == true) { string textSave = dlg.FileName.Substring(0, dlg.FileName.Length - 4) + "txt"; string dtPicked = "";//2015-01-27 DateTime selectedDT = new DateTime(); bool doAll = false; Dispatcher.Invoke((System.Action)delegate() { selectedDT = dtPick.SelectedDate.Value; string dtDay = dtPick.SelectedDate.Value.Day.ToString("00"); string dtMonth = dtPick.SelectedDate.Value.Month.ToString("00"); string dtYear = dtPick.SelectedDate.Value.Year.ToString("0000"); dtPicked = dtYear + "-" + dtMonth + "-" + dtDay; doAll = doAllcb.IsChecked.Value; }); using (StreamWriter sw = File.CreateText(textSave)) { if (doAll) { sw.WriteLine("All Dates"); } else { sw.WriteLine(dtPicked); } foreach (string pid in pids) { sw.WriteLine(pid); } } string ignoreItem = "qwertyuiop12345"; Dispatcher.Invoke((System.Action)delegate() { status.Content = "Retrieving data from DevTrack..."; pBar.Visibility = Visibility.Visible; pBar.Value = 0; ignoreItem = ignoreBox.Text; }); //ignorebox string[] ignoreItems = System.Text.RegularExpressions.Regex.Split(ignoreItem, ", "); List<DevT> OpenDevItems = OpenDevT(pids, ignoreItems); List<DevT> LatestOpenDevItems = new List<DevT>(); List<WR> JIRAitems = new List<WR>(); bool isError = false; foreach (DevT DTitem in OpenDevItems) { if (DTitem == null) isError = true; } if (isError) { Dispatcher.Invoke((System.Action)delegate() { pBar.Visibility = System.Windows.Visibility.Hidden; status.Content = "DevTrack possibly busy/unavailable, trying to reconnect." + Environment.NewLine + "Please wait, retries occur ~3seconds.."; pBar.Value = 0; }); while (isError) { Thread.Sleep(3000); OpenDevItems = OpenDevT(pids, ignoreItems); for (int i = 0; i < OpenDevItems.Count; i++) { if (OpenDevItems[i] == null) { isError = true; break; } else { isError = false; } } } } foreach (DevT DTitem in OpenDevItems) { if (DTitem == null) isError = true; } if (!isError) { #region meatNpotatoes if (!doAll) { foreach (DevT DTitem in OpenDevItems) { if (DTitem.createdDate >= selectedDT) { LatestOpenDevItems.Add(DTitem); } } } else { LatestOpenDevItems = OpenDevItems; } List<string> urls = makeUrl(LatestOpenDevItems); double j = 100.0; double k = j / urls.Count(); Dispatcher.Invoke((System.Action)delegate() { status.Content = "Querying a lot of JIRA..."; pBar.Visibility = Visibility.Visible; pBar.Value = 0; }); //int speed = 987;//get wait //foreach (string qry in urls) {//parallel could be a LOT faster, but might ddos jira if its lagging. // JIRAitems.Add(pJSON(qry)); // Dispatcher.Invoke((System.Action)delegate() { // pBar.Value += k; // }); // Thread.Sleep(speed); //} Parallel.ForEach(urls, qry => { JIRAitems.Add(pJSON(qry)); Dispatcher.Invoke((System.Action)delegate() { pBar.Value += k; }); }); Dispatcher.Invoke((System.Action)delegate() { status.Content = "Parsing JIRA data..."; }); List<WRQuery> JItemsC = new List<WRQuery>(); foreach (WR dd in JIRAitems) { foreach (Jissues info in dd.issues) { JItemsC.Add(new WRQuery(info, pids)); } } Dispatcher.Invoke((System.Action)delegate() { status.Content = "Finding JIRA errors..."; }); List<string> notInJIRA = new List<string>(); foreach (DevT lodi in LatestOpenDevItems) { if (DevWRExists(JItemsC, lodi.WR) < 0) { notInJIRA.Add(lodi.WR); } } Dispatcher.Invoke((System.Action)delegate() { status.Content = "No WRs were found in criteria!"; pBar.Value = 0; }); bool worked = false; if (JIRAitems.Count != 0) { Dispatcher.Invoke((System.Action)delegate() { status.Content = "Wrestling Excel..."; pBar.Value = 0; }); //EXCEL should be on its own to better manage the crashes //can't pass excel objects for some reason, investigate to clean up code redundancy List<string> cautions = new List<string>(); Excel.Application excelApp = null; Excel.Workbook workbook = null; Excel.Sheets sheets = null; Excel.Worksheet dataSheet = null; Excel.Range xlR = null; try { excelApp = new Excel.Application(); workbook = excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet); sheets = workbook.Sheets; dataSheet = sheets[1]; string dtNow = DateTime.Now.Month.ToString("00") + "-" + DateTime.Now.Day.ToString("00") + "-" + DateTime.Now.Year.ToString().Substring(2, 2); if (!doAll) { dataSheet.Name = dtPicked + " and newer"; } else { dataSheet.Name = "All"; } #region Header format //string[] headers = { "PD Priority Submission Date", "Updated?" + Environment.NewLine + "(Yes/No)", "Project", "DevTeam", "WR#", "WR Status (JIRA -" + Environment.NewLine + "Resolution/Status)", "WR Created" + Environment.NewLine + "Date", "WR Summary", "WR Description", "WR Product", "Product" + Environment.NewLine + "Version", "Project's Variance", "Variance Severity", "Variance's Need by" + Environment.NewLine + "Event (Var Priority)", "Variance's Need by" + Environment.NewLine + "Date", "PE/PSE Mgmt Priority" + Environment.NewLine + "(High/Med/Low)", "PE/PSE Mgmt Justification", "Certification Priority" + Environment.NewLine + "(High/Med/Low)", "Certification Justification", "Project Delivery Priority" + Environment.NewLine + "(High/Med/Low)", "Project Delivery Need by Date","WR Count"+Environment.NewLine+"(Duplicates)" }; string[] headers = { "PD Priority" + Environment.NewLine + "Submission Date", "Updated?" + Environment.NewLine + "(Yes/No)", "Project", "DevTeam", "WR#", "WR Resolution/" + Environment.NewLine + "Status", "Request" + Environment.NewLine + "Status", "Requested" + Environment.NewLine + "Date", "Planned" + Environment.NewLine + "Release Date", "WR Created" + Environment.NewLine + "Date", "WR Summary", "WR Description", "WR Product", "Product" + Environment.NewLine + "Version", "Project's Variance", "Variance Severity", "Variance's Need by" + Environment.NewLine + "Event (Var Priority)", "Variance's Need by" + Environment.NewLine + "Date", "PE/PSE Mgmt Priority" + Environment.NewLine + "(Urgent/High/Med/Low)", "PE/PSE Mgmt Justification", "Certification Priority" + Environment.NewLine + "(Urgent/High/Med/Low)", "Certification Justification", "Project Delivery Priority" + Environment.NewLine + "(Urgent/High/Med/Low)", "Project Delivery Need by Date", "WR Count" + Environment.NewLine + "(Duplicates)", "QC" + Environment.NewLine + "(PE/PSE Justification)", "QC" + Environment.NewLine + "(Var. Date)" }; object[,] xlHeader = new object[1, headers.Length]; string columnMax = getAlpha(headers.Length); for (int i = 0; i < headers.Length; i++) { xlHeader[0, i] = headers[i]; } xlR = dataSheet.Range["A1", columnMax + "1"];//Header xlR.Value2 = xlHeader; #endregion dataSheet.get_Range("G:G", Type.Missing).EntireColumn.ColumnWidth = 50; int nXLcount = LatestOpenDevItems.Count(); double iB = 100.0; double iJ = iB / nXLcount; int rowCount = 2; //start at row 2 foreach (DevT DT in LatestOpenDevItems) { debug[0] = DT.WR; debug[1] = DT.Project; debug[3] = rowCount.ToString(); int xWR = DevWRExists(JItemsC, DT.WR); string wSuite = "WR NOT IN JIRA!"; string wSummary = "WR NOT IN JIRA!"; string wCurRel = "WR NOT IN JIRA!"; string wIT = "WR NOT IN JIRA!"; string wProd = "WR NOT IN JIRA!"; string wStatus = "WR NOT IN JIRA!"; string rStatus = "WR NOT IN JIRA!"; string rDate = "WR NOT IN JIRA!"; string dDate = "WR NOT IN JIRA!"; string wDesc = "WR NOT IN JIRA! Contact Development for assistance with this WR."; if (xWR >= 0) { wSuite = JItemsC[xWR].Suite; rStatus = JItemsC[xWR].RequestedStatus; rDate = JItemsC[xWR].RequestedDate; dDate = JItemsC[xWR].DueDate; wSummary = JItemsC[xWR].Summary; wCurRel = JItemsC[xWR].CurrentRelease; wIT = JItemsC[xWR].IssueType; wStatus = JItemsC[xWR].Resolution + Environment.NewLine + JItemsC[xWR].Status; wProd = JItemsC[xWR].Product; wDesc = JItemsC[xWR].Description; } string cdate = DT.createdDate.Month + "-" + DT.createdDate.Day + "-" + DT.createdDate.Year; string[] newLine = { dtNow, "No", DT.Project, wSuite, DT.WR, wStatus, rStatus, rDate, dDate, cdate, wSummary, "'" + wDesc, wProd, wCurRel, DT.IV, DT.IVseverity, DT.NeedByEvent, DT.NeedByDate }; //string[] newLine = { dtNow, "No", DT.Project, wSuite, DT.WR, wStatus, rStatus, rDate, dDate, cdate, wSummary, wDesc, wProd, wCurRel, DT.IV, DT.IVseverity, DT.NeedByEvent, DT.NeedByDate };//DEBUG ONLY object[,] xlNewLine = new object[1, newLine.Length]; for (int i = 0; i < newLine.Length; i++) { xlNewLine[0, i] = newLine[i]; } xlR = dataSheet.Range["A" + rowCount, getAlpha(newLine.Length) + rowCount]; xlR.Value2 = xlNewLine; rowCount++; Dispatcher.Invoke((System.Action)delegate() { pBar.Value += iJ; }); }//end of magic #region findDuplicates int maxRf = dataSheet.UsedRange.Rows.Count; object[,] arr = dataSheet.get_Range("C2:E" + maxRf).Value; List<string> ProjectRow = new List<string>(); List<string> ProjectWR = new List<string>(); for (int i = 1; i < maxRf; i++) { ProjectRow.Add(arr[i, 1].ToString()); ProjectWR.Add(arr[i, 3].ToString()); } List<string> duplicatedWRs = ProjectWR.GroupBy(x => x) .Where(group => group.Count() > 1) .Select(group => group.Key).ToList(); if (duplicatedWRs.Count > 0) { Excel.Worksheet dpSheet = (Worksheet)sheets.Add(Type.Missing, sheets[1], Type.Missing, Type.Missing); dpSheet.Name = "Duplicated WRs"; int rowToPrint = 2; dpSheet.Cells[1, 1] = "Duplicated" + Environment.NewLine + "WRs Found"; dpSheet.Cells[1, 2] = "Projects found linked"; foreach (string dWRx in duplicatedWRs) { debug[3] = rowToPrint.ToString(); string ProjectsFound = ""; for (int i = 0; i < ProjectWR.Count; i++) { if (dWRx == ProjectWR[i]) { if (ProjectsFound == "") { ProjectsFound += ProjectRow[i]; } else { ProjectsFound += Environment.NewLine + ProjectRow[i]; } } } //print this WR dpSheet.Cells[rowToPrint, 1] = dWRx; dpSheet.Cells[rowToPrint, 2] = ProjectsFound; rowToPrint++; } dpSheet.get_Range("A:A", Type.Missing).EntireColumn.ColumnWidth = 16; dpSheet.get_Range("B:B", Type.Missing).EntireColumn.ColumnWidth = 32; dpSheet.get_Range("A:B", Type.Missing).EntireColumn.VerticalAlignment = XlVAlign.xlVAlignCenter; dpSheet.get_Range("A:B", Type.Missing).EntireColumn.HorizontalAlignment = XlHAlign.xlHAlignCenter; dpSheet.get_Range("A1", "B1").Cells.Font.Bold = true; dpSheet.Select(); releaseObject(dpSheet); } #endregion dataSheet.get_Range("A:" + columnMax, Type.Missing).EntireColumn.VerticalAlignment = XlVAlign.xlVAlignCenter; dataSheet.get_Range("A:F", Type.Missing).EntireColumn.HorizontalAlignment = XlHAlign.xlHAlignCenter; dataSheet.get_Range("A:" + columnMax, Type.Missing).EntireColumn.WrapText = true; dataSheet.get_Range("A:" + columnMax, Type.Missing).EntireColumn.ColumnWidth = 17.8; dataSheet.get_Range("B:B", Type.Missing).EntireColumn.ColumnWidth = 12; dataSheet.get_Range("E:E", Type.Missing).EntireColumn.ColumnWidth = 8; dataSheet.get_Range("G:G", Type.Missing).EntireColumn.ColumnWidth = 14; dataSheet.get_Range("H:J", Type.Missing).EntireColumn.ColumnWidth = 12; dataSheet.get_Range("K:K", Type.Missing).EntireColumn.ColumnWidth = 32; dataSheet.get_Range("L:L", Type.Missing).EntireColumn.ColumnWidth = 50; dataSheet.get_Range("Q:R", Type.Missing).EntireColumn.ColumnWidth = 20; dataSheet.get_Range("S:X", Type.Missing).EntireColumn.ColumnWidth = 28; dataSheet.get_Range("A:" + columnMax, Type.Missing).EntireRow.HorizontalAlignment = XlHAlign.xlHAlignLeft; //Column data validation string validS = "Urgent,High,Med,Low,SCT"; string validW = "Urgent,High,Med,Low"; //string validC = "High,Med,Low,Not required"; string validU = "Yes,No"; dataSheet.get_Range("B2", "B" + (rowCount - 1)).Validation.Add(XlDVType.xlValidateList, XlDVAlertStyle.xlValidAlertStop, XlFormatConditionOperator.xlBetween, validU, Type.Missing); dataSheet.get_Range("S2", "S" + (rowCount - 1)).Validation.Add(XlDVType.xlValidateList, XlDVAlertStyle.xlValidAlertStop, XlFormatConditionOperator.xlBetween, validS, Type.Missing); dataSheet.get_Range("W2", "W" + (rowCount - 1)).Validation.Add(XlDVType.xlValidateList, XlDVAlertStyle.xlValidAlertStop, XlFormatConditionOperator.xlBetween, validW, Type.Missing); dataSheet.get_Range("U2", "U" + (rowCount - 1)).Validation.Add(XlDVType.xlValidateList, XlDVAlertStyle.xlValidAlertStop, XlFormatConditionOperator.xlBetween, validW, Type.Missing); xlR = dataSheet.get_Range("A1:" + columnMax + (rowCount - 1)); dataSheet.ListObjects.AddEx(XlListObjectSourceType.xlSrcRange, xlR, Type.Missing, Excel.XlYesNoGuess.xlYes, Type.Missing).Name = "MyTableStyle"; dataSheet.ListObjects.get_Item("MyTableStyle").TableStyle = "TableStyleLight8"; dataSheet.get_Range("A1", columnMax + "1").EntireRow.RowHeight = 31; dataSheet.get_Range("A1", "B1").Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Goldenrod); dataSheet.get_Range("R1", "R1").Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Brown); dataSheet.get_Range("S1", "X1").Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Goldenrod); dataSheet.get_Range("Y1", "AA1").Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.DeepSkyBlue); dataSheet.get_Range("Y:" + columnMax, Type.Missing).EntireColumn.Hidden = true; //dataSheet.get_Range("G:I", Type.Missing).EntireColumn.Hidden = true; dataSheet.Range["Y2"].Formula = "=COUNTIF(E:E,[@[WR'#]])";//duplicate formula dataSheet.Range["X2"].Formula = "=[@[Variance''s Need by" + Environment.NewLine + "Date]]"; dataSheet.Columns[24].NumberFormat = "m/d/yyyy"; dataSheet.Range["W2"].Value = "=IF([@[PE/PSE Mgmt Priority" + Environment.NewLine + //gotta use .Value because of length I guess? "(Urgent/High/Med/Low)]]<>\"SCT\",[@[PE/PSE Mgmt Priority" + Environment.NewLine + "(Urgent/High/Med/Low)]],[@[Certification Priority" + Environment.NewLine + "(Urgent/High/Med/Low)]])"; dataSheet.Range["Z2"].Value = "=IF(AND(OR([@[PE/PSE Mgmt Priority" + Environment.NewLine + "(Urgent/High/Med/Low)]]=\"Urgent\",[@[PE/PSE Mgmt Priority" + Environment.NewLine + "(Urgent/High/Med/Low)]]=\"High\",[@[PE/PSE Mgmt Priority" + Environment.NewLine + "(Urgent/High/Med/Low)]]=\"Med\"),[@[PE/PSE Mgmt Justification]]=\"\"),\"Not Justified!\",\"Justified\")"; dataSheet.Range["AA2"].Value = "=IF(AND(OR([@[PE/PSE Mgmt Priority" + Environment.NewLine + "(Urgent/High/Med/Low)]]=\"Urgent\",[@[PE/PSE Mgmt Priority" + Environment.NewLine + "(Urgent/High/Med/Low)]]=\"High\",[@[PE/PSE Mgmt Priority" + Environment.NewLine + "(Urgent/High/Med/Low)]]=\"Med\"),[@[Variance''s Need by" + Environment.NewLine + "Date]]=\"Date Not Set\"),\"Req'd Date Not Set!\",IF(AND(OR([@[PE/PSE Mgmt Priority" + Environment.NewLine + "(Urgent/High/Med/Low)]]=\"Urgent\",[@[PE/PSE Mgmt Priority" + Environment.NewLine + "(Urgent/High/Med/Low)]]=\"High\",[@[PE/PSE Mgmt Priority" + Environment.NewLine + "(Urgent/High/Med/Low)]]=\"Med\"),[@[Variance''s Need by" + Environment.NewLine + "Date]]<=TODAY()),\"Old Date Set!\",\"Adequate Date\"))"; ((Excel._Worksheet)dataSheet).Activate(); dataSheet.Application.ActiveWindow.SplitRow = 1; dataSheet.Application.ActiveWindow.FreezePanes = true; bool readOnly = false; excelApp.DisplayAlerts = false; workbook.SaveAs(dlg.FileName, XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, readOnly, false, XlSaveAsAccessMode.xlNoChange, XlSaveConflictResolution.xlLocalSessionChanges, Type.Missing, Type.Missing, Type.Missing); workbook.Close(true, Type.Missing, Type.Missing); excelApp.Quit(); releaseObject(xlR); releaseObject(dataSheet); releaseObject(sheets); releaseObject(workbook); releaseObject(excelApp); worked = true; } catch (Exception e) { //a terrible attempt to debug the issue, possible COM Interop investigation workbook.Close(false, Type.Missing, Type.Missing); excelApp.Quit(); string m = e.Message; MessageBoxResult dialogResult = new MessageBoxResult(); dialogResult = MessageBox.Show("Investigate/remove " + debug[1] + " " + debug[0] + Environment.NewLine + debug[3] + " ERROR:" + e.Message + Environment.NewLine + "Possible JIRA item polled while it was being changed.", "TRY AGAIN - Fatal error with Excel", MessageBoxButton.OK); Dispatcher.Invoke((System.Action)delegate() { status.Content = "Failed! Excel got corrupted :("; }); result = false; } finally { releaseObject(xlR); releaseObject(dataSheet); releaseObject(sheets); releaseObject(workbook); releaseObject(excelApp); } } disableButtons(false); Dispatcher.Invoke((System.Action)delegate() { pBar.Visibility = Visibility.Hidden; pBar.Value = 0; if (worked) { status.Content = "Completed!"; } }); #endregion } else { disableButtons(false); Dispatcher.Invoke((System.Action)delegate() { status.Content = "Network failure?! just try again shortly..." + Environment.NewLine + "If this continues, try someplace else."; pBar.Value = 0; pBar.Visibility = System.Windows.Visibility.Hidden; }); } }//if file name chosen }
private void Menu_RedownloadItemAssets(object sender, RoutedEventArgs e) { string sMessageBoxText = L10n.Message("The existing Skill Item assets will be deleted and new assets will be downloaded.") + "\n\n" + L10n.Message("Do you want to continue?"); var rsltMessageBox = Popup.Ask(sMessageBoxText, MessageBoxImage.Warning); string appDataPath = AppData.GetFolder(true); switch (rsltMessageBox) { case MessageBoxResult.Yes: if (Directory.Exists(Path.Combine(appDataPath, "Data"))) { try { if (Directory.Exists(Path.Combine(appDataPath, "DataBackup"))) Directory.Delete("DataBackup", true); Directory.Move(Path.Combine(appDataPath, "Data"), Path.Combine(appDataPath, "DataBackup")); var bases = new List<ItemBase>(); var images = new List<Tuple<string, string>>(); StartLoadingWindow(); UpdateLoadingWindow(0, 3); ItemAssetDownloader.ExtractJewelry(bases, images); UpdateLoadingWindow(1, 3); ItemAssetDownloader.ExtractArmors(bases, images); UpdateLoadingWindow(2, 3); ItemAssetDownloader.ExtractWeapons(bases, images); UpdateLoadingWindow(3, 3); new System.Xml.Linq.XElement("ItemBaseList", bases.Select(b => b.Serialize())).Save(Path.Combine(AppData.GetFolder(@"Data\Equipment"), "Itemlist.xml")); var imgroups = images.GroupBy(t => t.Item2).ToArray(); UpdateLoadingWindow(0, imgroups.Length); var dir = AppData.GetFolder(@"Data\Equipment\Assets"); using (var client = new WebClient()) { for (int i = 0; i < imgroups.Length; i++) { using (var ms = new MemoryStream(client.DownloadData(imgroups[i].Key))) { PngBitmapDecoder dec = new PngBitmapDecoder(ms, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); var image = dec.Frames[0]; var cropped = new CroppedBitmap(image, new Int32Rect(4, 4, image.PixelWidth - 8, image.PixelHeight - 8)); PngBitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(cropped)); using (var m = new MemoryStream()) { encoder.Save(m); foreach (var item in imgroups[i]) { using (var f = File.Create(Path.Combine(dir, item.Item1 + ".png"))) { m.Seek(0, SeekOrigin.Begin); m.CopyTo(f); } } } UpdateLoadingWindow(i + 1, imgroups.Length); } } } foreach (var file in new DirectoryInfo(Path.Combine(appDataPath, @"DataBackup")).GetFiles()) file.CopyTo(Path.Combine(Path.Combine(appDataPath, @"Data"), file.Name)); File.Copy(Path.Combine(AppData.GetFolder(@"DataBackup\Equipment"), "Affixlist.xml"), Path.Combine(AppData.GetFolder(@"Data\Equipment"), "Affixlist.xml")); Directory.Move(Path.Combine(appDataPath, @"DataBackup\Assets"), Path.Combine(appDataPath, @"Data\Assets")); if (Directory.Exists(Path.Combine(appDataPath, "DataBackup"))) Directory.Delete(Path.Combine(appDataPath, "DataBackup"), true); CloseLoadingWindow(); } catch (Exception ex) { if (Directory.Exists(Path.Combine(appDataPath, "Data"))) Directory.Delete(Path.Combine(appDataPath, "Data"), true); try { CloseLoadingWindow(); } catch (Exception) { //Nothing } Directory.Move(Path.Combine(appDataPath, "DataBackup"), Path.Combine(appDataPath, "Data")); Popup.Error(L10n.Message("Error while downloading assets.")); } } break; case MessageBoxResult.No: //Do nothing break; } }
private void BindData() { List<EmployeeContributions> employees = new List<EmployeeContributions>(); // get list item values into a strongly typed class foreach (ListItem li in _employees) { employees.Add(new EmployeeContributions { Name = li["Title"].ToString(), TeamName = li["Team"].ToString(), Contributions = Convert.ToDecimal(li["Contribution_x0020__x0028_in_x00"]) }); } // use linq to group employees on team name and then total team contributions List<TeamContributions> teams = employees .GroupBy(e => e.TeamName) .Select(t => new TeamContributions { Name = t.Key, Contributions = t.Sum(e => e.Contributions) }).ToList(); chart.DataContext = teams; // must be on UI thread }
/// <summary> /// This returns all the unique edge triangles of the cells passed in (each face of the cell cube has two triangles), and which /// cells share each of those triangles /// </summary> private static Tuple<ITriangle, int[]>[] GetBlockedCellsSprtEdgeMap(Rectangle3DIndexedMapped[] cells) { if (cells.Length == 0) { return new Tuple<ITriangle, int[]>[0]; } // Get the triangles for each cell List<Tuple<int, Tuple<int, int, int>>> trianglesPerCell = new List<Tuple<int, Tuple<int, int, int>>>(); for (int cntr = 0; cntr < cells.Length; cntr++) { Tuple<int, int, int>[] trianglesOrdered = cells[cntr].GetEdgeTriangles().Select(o => { int[] indices = o.IndexArray.OrderBy(p => p).ToArray(); // sorting them so they can be easily compared to other cell's triangles return Tuple.Create(indices[0], indices[1], indices[2]); }). ToArray(); trianglesPerCell.AddRange(trianglesOrdered.Select(o => Tuple.Create(cntr, o))); } Point3D[] points = cells[0].AllPoints; // Now group by triangle var retVal = trianglesPerCell.GroupBy(o => o.Item2). Select(o => { ITriangle triangle = new TriangleIndexed(o.Key.Item1, o.Key.Item2, o.Key.Item3, points); int[] correspondingCells = o.Select(p => p.Item1).Distinct().ToArray(); return Tuple.Create(triangle, correspondingCells); }). ToArray(); // Exit Function return retVal; }
private void btnSalesReport_Click(object sender, RoutedEventArgs e) { const int PAD = 10; string summary = ""; summary += string.Format(SALES_REPORT_FORM_HEADER, mReceipts[0].Date.ToShortDateString()); List<SalesItem> allItems = new List<SalesItem>(); mReceipts.ForEach(r => { allItems.AddRange(r.SalesItems); }); var x = allItems .GroupBy(i => i.Item) .Select(i => i.First()); var sortedItems = (from i in x orderby i.Department, i.Category, i.Item select i); //StreamWriter csvFile = new StreamWriter(mCurrentReceiptLogFile + @".csv"); //csvFile.WriteLine("Dept,Category,Code,Name,Price,Sold,Total"); //foreach (var i in sortedItems) //{ // double total = (from si in allItems // where si.Item.Equals(i.Item) // select si.Price).Sum(); // csvFile.WriteLine("{0},{1},{2},{3},{4},{5},{6}", // i.Department, // i.Category, // i.Item, // i.ItemDetail, // i.Price, // allItems.Count(si => si.Item.Equals(i.Item)), // total); //} //csvFile.Flush(); //csvFile.Close(); double grandTotal = (from i in allItems select i.Price).Sum(); double totalBeer = (from i in allItems where (i.Category.Equals(Categories.BEERS)) select i.Price).Sum(); int beerCount = allItems.Count(i => i.Category.Equals(Categories.BEERS)); double totalDraft = (from i in allItems where (i.Category.Equals(Categories.DRAFT)) select i.Price).Sum(); int draftCount = allItems.Count(i => i.Category.Equals(Categories.DRAFT)); double totalSodas = (from i in allItems where (i.Category.Equals(Categories.SODAS) || i.Category.Equals(Categories.W_WHAT)) select i.Price).Sum(); int sodasCount = allItems.Count(i => (i.Category.Equals(Categories.SODAS) || i.Category.Equals(Categories.W_WHAT))); double totalWine = (from i in allItems where (i.Category.Equals(Categories.WINE)) select i.Price).Sum(); int wineCount = allItems.Count(i => i.Category.Equals(Categories.WINE)); double totalCigs = (from i in allItems where (i.Category.Equals(Categories.CIG)) select i.Price).Sum(); int cigCount = allItems.Count(i => i.Category.Equals(Categories.CIG)); double totalSnackFoodDress = (from i in allItems where (i.Category.Equals(Categories.SNACKS) || i.Category.Equals(Categories.FOOD) || i.Category.Equals(Categories.DRESS)) select i.Price).Sum(); int sfdCount = allItems.Count(i => i.Category.Equals(Categories.SNACKS) || i.Category.Equals(Categories.FOOD) || i.Category.Equals(Categories.DRESS)); double totalLiquor = (from i in allItems where (i.Category.Equals(Categories.LIQUOR) || i.Category.Equals(Categories.CORDIA) || i.Category.Equals(Categories.HOUSE) || i.Category.Equals(Categories.C_SHOT) || i.Category.Equals(Categories.SHOTS) || i.Category.Equals(Categories.DRINKS) || i.Category.Equals(Categories.TINI) || (i.Category.Equals(Categories.MISC) && i.Department.Equals(Departments.DELI))) select i.Price).Sum(); int liquorCount = allItems.Count(i => i.Category.Equals(Categories.LIQUOR) || i.Category.Equals(Categories.CORDIA) || i.Category.Equals(Categories.HOUSE) || i.Category.Equals(Categories.C_SHOT) || i.Category.Equals(Categories.SHOTS) || i.Category.Equals(Categories.DRINKS) || i.Category.Equals(Categories.TINI) || (i.Category.Equals(Categories.MISC) && i.Department.Equals(Departments.DELI))); double totalTShirts = (from i in allItems where (i.Category.Equals(Categories.TSHIRT)) select i.Price).Sum(); int tshirtCount = allItems.Count(i => i.Category.Equals(Categories.TSHIRT)); double totalPolo = (from i in allItems where (i.Category.Equals(Categories.POLO)) select i.Price).Sum(); int poloCount = allItems.Count(i => i.Category.Equals(Categories.POLO)); double totalPoolRental = (from i in allItems where (i.Department.Equals(Departments.RENTAL_POOL) && i.Category.Equals(Categories.PLAYER)) select i.Price).Sum(); int poolRentalCount = allItems.Count(i => (i.Department.Equals(Departments.RENTAL_POOL) && i.Category.Equals(Categories.PLAYER))); double totalPoolWB = (from i in allItems where (i.Department.Equals(Departments.POOL) && i.Category.Equals(Categories.MISC)) select i.Price).Sum(); int poolWBCount = allItems.Count(i => (i.Department.Equals(Departments.POOL) && i.Category.Equals(Categories.MISC))); summary += "\n" + " Category Sales Quan.\n" + "____________________________\n" + String.Format("LIQUOR {0} {1}", String.Format("{0:c}", totalLiquor).PadLeft(PAD), liquorCount) + "\n" + String.Format("DRAFT {0} {1}", String.Format("{0:c}", totalDraft).PadLeft(PAD), draftCount) + "\n" + String.Format("BEERS {0} {1}", String.Format("{0:c}", totalBeer).PadLeft(PAD), beerCount) + "\n" + String.Format("SODAS {0} {1}", String.Format("{0:c}", totalSodas).PadLeft(PAD), sodasCount) + "\n" + String.Format("FOOD {0} {1}", String.Format("{0:c}", totalSnackFoodDress).PadLeft(PAD), sfdCount) + "\n" + String.Format("POOL RENT {0} {1}", String.Format("{0:c}", totalPoolRental).PadLeft(PAD), poolRentalCount) + "\n" + String.Format("POOL WBANDS {0} {1}", String.Format("{0:c}", totalPoolWB).PadLeft(PAD), poolWBCount) + "\n" + String.Format("CIG {0} {1}", String.Format("{0:c}", totalCigs).PadLeft(PAD), cigCount) + "\n" + String.Format("TSHIRT {0} {1}", String.Format("{0:c}", totalTShirts).PadLeft(PAD), tshirtCount) + "\n" + String.Format("POLOS {0} {1}", String.Format("{0:c}", totalPolo).PadLeft(PAD), poloCount) + "\n" + String.Format("WINE {0} {1}", String.Format("{0:c}", totalWine).PadLeft(PAD), wineCount) + "\n"; double totalSales = totalDraft + totalBeer + totalSodas + totalSnackFoodDress + totalWine + totalLiquor + totalCigs + totalPoolRental + totalPoolWB + totalTShirts + totalPolo; summary += "\n" + "----------------------------\n" + String.Format("Total: {0}\n\n", String.Format("{0:c}", totalSales).PadLeft(PAD)); //summary += "\nItemized Counts\n" + // "____________________________\n"; //foreach (var i in sortedItems) //{ // double total = (from si in allItems // where si.Item.Equals(i.Item) // select si.Price).Sum(); // summary += String.Format("{0} {1}\t{2}\n", // String.Format("{0}", i.ItemDetail).PadRight(15), // String.Format("{0:c}", total).PadLeft(PAD), // String.Format("{0}", allItems.Count(si => si.Item.Equals(i.Item))).PadLeft(2)); //} float totalCC = 0; float caCC = 0; float tipsCC = 0; totalCC = (from r in mReceipts where r.Type.Equals(Constants.CREDIT_TOKEN) select r.Total).Sum(); caCC = (from r in mReceipts where r.Type.Equals(Constants.CREDIT_TOKEN) select r.CashAdvances).Sum(); tipsCC = (from r in mReceipts where r.Type.Equals(Constants.CREDIT_TOKEN) select r.Tip).Sum(); float totalCASH = (from r in mReceipts where r.Type.Equals(Constants.CASH_TOKEN) select r.Total).Sum(); totalCASH -= (caCC + tipsCC); float totalDiscounts = (from r in mReceipts select r.Discounts).Sum(); float totalCharges = (from r in mReceipts select r.Charges).Sum(); summary += "\n" + "----------------------------\n" + String.Format("CC Total {0}\n", String.Format("{0:c}", totalCC).PadLeft(PAD)); summary += "\n" + String.Format("Cash Total {0}\n", String.Format("{0:c}", totalCASH).PadLeft(PAD)); summary += "\n" + String.Format("Discounts {0}\n", String.Format("{0:c}", totalDiscounts).PadLeft(PAD)); summary += "\n" + String.Format("Charges {0}\n", String.Format("{0:c}", totalCharges).PadLeft(PAD)); summary += "\n" + String.Format("Tips/CA {0}\n", String.Format("{0:c}", -(caCC + tipsCC)).PadLeft(PAD)); summary += "\n" + "OVER/UNDER __________ \n\n\n"; SalesReport sr = new SalesReport(summary); sr.ShowDialog(); }
private void btnGenera_Click(object sender, RoutedEventArgs e) { int anno = 0; try { anno = int.Parse(txtboxAnno.Text); } catch (FormatException ex) { MessageBox.Show("L'anno dev'essere un numero intero", "Formato anno errato", MessageBoxButton.OK, MessageBoxImage.Error); return; } int mese = mesi[cbxMese.Text]; DateTime arrivoDa = new DateTime(anno, mese, 1); DateTime arrivoA = arrivoDa.AddMonths(1).AddDays(-1); //prendi tutti i pagamenti emessi in questo mese allPagamenti = dag.cercaPagamentiByData(arrivoDa, arrivoA); if (allPagamenti.Count == 0) { MessageBox.Show("Non ci sono pagamenti registrati nel mese selezionato", "Nessun pagamento", MessageBoxButton.OK, MessageBoxImage.Information); return; } btnPrint.IsEnabled = true; var pageqcom = new PagamentiComparer(); //cerca pagamenti duplicati var pagdups = allPagamenti.GroupBy(i => i, pageqcom) .Where(g => g.Count() > 1) .Select(g => g.Key).ToList<Pagamento>(); if (pagdups.Count > 0) { var plist = new List<Pagamento>(); foreach (var p in allPagamenti) { if (pagdups.Contains(p, pageqcom)) plist.Add(p); } pagamentiDup = new ObservableCollection<Pagamento>(plist); //allPagamenti.Intersect<Pagamento>(pagdups, pageqcom).ToList<Pagamento>()); dataGridPagamentiDup.DataContext = pagamentiDup; } //cerca pagamenti a importo nullo var pagnull = (from p in allPagamenti where p.Totale == 0 select p).ToList<Pagamento>(); if (pagnull.Count > 0) { pagamentiNull = new ObservableCollection<Pagamento>(pagnull); dataGridPagamentiNulli.DataContext = pagamentiNull; } //verifica progressivi mancanti checkProgressiviMancanti(allPagamenti); }
public void ViewRelation(int max, RelationIndexType type, out List<ItemRelationViewData> list) { if (comunityDic == null) { CreateComunityDic(); } foreach (var item in comunityDic.Values.Where(n => n.Selected == false)) { item.NewBrush(Colors.Transparent, 1); } var selectedList = AllComunity.Where(n => n.Selected == true); List<ItemRelation> relationList = new List<ItemRelation>(); foreach (var item in selectedList) { relationList.AddRange(item.Relations.Where(n => selectedList.Where(m => m.Id == n.ItemId).Any() == false)); } var d = relationList.GroupBy(n => n.ItemId).Select(n => new { n.Key, a = n.Aggregate(1.0, (m, l) => l.GetIndex(type) * m) }); int half = max / 2; int count = 0; foreach (var item in d.OrderByDescending(n => n.a).Where(n => comunityDic.ContainsKey(n.Key) == true).Take(max)) { if (count > half) { comunityDic[item.Key].NewBrush(Colors.Orange, 0.2); } else { comunityDic[item.Key].NewBrush(Colors.Orange, 0.6); } count++; } int i = 1; list = new List<ItemRelationViewData>(); foreach (var item in d.OrderByDescending(n => n.a)) { if (comunityDic.ContainsKey(item.Key)) { var c = comunityDic[item.Key]; if (type == RelationIndexType.確信度) { list.Add(new ItemRelationViewData() { Rank = i, Name = c.Name, 確信度 = item.a.ToString("F3"), }); } else { list.Add(new ItemRelationViewData() { Rank = i, Name = c.Name, 補正確信度 = item.a.ToString("F3") }); } i++; } } //foreach (var item in comunity.Relations.OrderByDescending(n => n.GetIndex(type)).Take(max)) //{ // if (comunityDic.ContainsKey(item.ItemId)) // { // if (count > half) // { // comunityDic[item.ItemId].NewBrush(Colors.Orange, 0.2); // } // else // { // comunityDic[item.ItemId].NewBrush(Colors.Orange, 0.6); // } // count++; // } //} }
internal void SetMandatoryMappingColumns(List<ColumnMetaInfo> _mandatoryColumns) { bmRequiredFields = _mandatoryColumns.GroupBy(f => f.columnName).Select(g=>g.First()).ToList(); }
//used with displayAllSessionsOnViewer() private void printListsScreen(List<string> list, ListBox listToPrint, TextBox listTotal) { var q1 = list.GroupBy(x => x) .Select(g => new { Value = g.Key, Count = g.Count() }) .OrderByDescending(x => x.Count); foreach (var x in q1) { listToPrint.Items.Add(x.Value + ": " + x.Count); } listTotal.Text = list.Count().ToString(); }
private void CreateGroupedTestData(IList<ProcessedFileChangeInfo> sourceData) { var data = new List<AggregateTestData>(); var identities = this.IdentityService.GetUserIdentities(); foreach (var testDataItem in sourceData) { var memberIdentity = identities.Where(id => id.IdentityKey == testDataItem.Member).FirstOrDefault(); if (memberIdentity == null) { var aggregateData = new AggregateTestData() { Comitter = "UnknownMembers", TestCountDelta = testDataItem.AttributeChanges.TestCountChange }; data.Add(aggregateData); } else { if (memberIdentity.Groups.Count == 0) { var aggregateData = new AggregateTestData() { Comitter = "UnknownGroups", TestCountDelta = testDataItem.AttributeChanges.TestCountChange }; data.Add(aggregateData); } else { foreach (var memberGroupItem in memberIdentity.Groups) { var aggregateData = new AggregateTestData() { Comitter = memberGroupItem.DisplayName, TestCountDelta = testDataItem.AttributeChanges.TestCountChange }; data.Add(aggregateData); System.Diagnostics.Debug.WriteLine(memberGroupItem.IdentityKey + "\t" + testDataItem.Member + "\t" + testDataItem.AttributeChanges.TestCountChange.ToString() + "\t" + testDataItem.ChangesetId); } } } } this.groupedData = data .GroupBy(i => i.Comitter) .Select(g => new AggregateTestData() { Comitter = g.Key, TestCountDelta = g.Sum(h => h.TestCountDelta) }) .OrderBy(v => v.TestCountDelta) .ToList(); this.layoutRoot.DataContext = null; this.layoutRoot.DataContext = this.groupedData; }
private bool HasDuplicateKeys() { List<Key> keyList = new List<Key>(); keyList.Add( PitchUpKey ); keyList.Add( PitchDownKey ); keyList.Add( RollLeftKey ); keyList.Add( RollRightKey ); keyList.Add( YawLeftKey ); keyList.Add( YawRightKey ); keyList.Add( GazUpKey ); keyList.Add( GazDownKey ); keyList.Add( TakeoffKey ); keyList.Add( LandKey ); keyList.Add( HoverKey ); keyList.Add( CameraSwapKey ); keyList.Add( EmergencyKey ); keyList.Add( FlatTrimKey ); keyList.Add( SpecialActionKey ); return keyList.GroupBy( x => x ).Any(c => c.Count() > 1); }
public string CreateHTML(List<ClasterData> list) { StringBuilder sb = new StringBuilder(); sb.Append("<html><body>"); var r = datalist.Where(n => n.Question != null).Select(n => n.Question); List<string> qqList = new List<string>(); foreach (var item2 in r) { foreach (var item3 in item2) { qqList.Add(item3.Item1 + "</th><th>" + item3.Item2); } } sb.Append("<h2>全体</h2><table>"); foreach (var item in qqList.GroupBy(n=>n).Select(n=>new { Key = n.Key,Count= n.Count()}).OrderByDescending(n=>n.Count)) { sb.Append("<tr><th>" + item.Key + "</th><td>" + item.Count + "</td></tr>"); } sb.Append("</table>"); int i = 1; foreach (var item in list) { sb.Append("<hr><h2>クラスター" + i.ToString() + "(" + item.AnswerData.Count().ToString() + ")</h2>"); sb.Append("<table>"); for (int k = 0; k < item.Data.Length; k++) { sb.Append("<tr><th>" + categoryList[k].ItemCategoryName + "</th><td>" + (item.Data[k] * 100).ToString("F2") + "%</td></tr>"); } sb.Append("</table>"); sb.Append("<ul>"); List<string> qList = new List<string>(); foreach (var item2 in item.AnswerData) { if (item2.Question != null) { foreach (var item3 in item2.Question) { qList.Add(item3.Item1 + "</th><th>" + item3.Item2); } } } sb.Append("<table>"); foreach (var item2 in qList.GroupBy(n => n).Select(n => new { Key = n.Key, Count = n.Count() }).OrderByDescending(n => n.Count)) { sb.Append("<tr><th>" + item2.Key + "</th><td>" + item2.Count + "</td></tr>"); } sb.Append("</table>"); foreach (var item2 in item.AnswerData) { if (item2.FreeAnswer != null) { sb.Append("<li>" + item2.FreeAnswer.FirstOrDefault().Item2); sb.Append("<small>"); foreach (var item3 in item2.Question) { sb.Append("[" + item3.Item2 + "]"); } sb.Append("</small>"); sb.Append("</li>"); } } sb.Append("</ul>"); i++; } return sb.ToString(); }