// Ponieważ algorytm generuje listę rozkrojową osobno dla każdego profilu, // Elementy również są aktualizowane profilami. public static void writeProfileToStoreFile(string storeFile, List <StoredElement> store) { using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open(storeFile, true)) { WorkbookPart workbookPart = spreadsheetDocument.WorkbookPart; for (int i = 0; i != store.Count();) { int count = 0; int curr_len = store[i].GetLength(); StoredElement e = store[i]; while (i != store.Count() && store[i].GetLength() == curr_len) { ++i; ++count; } // jeśli zostaje mniej niż 700mm długości, to element nie wraca do magazynu, // tylko idzie na złom if (e.GetDelivery() != "" && e.GetLength() >= 700) { writeElementToStoreFile(workbookPart, e, count); } } } }
private List <string> GetElementDescriptions(SortedDictionary <string, List <StoredElement> > elements) { List <string> ret = new List <string>(); StoredElement prev = new StoredElement(); foreach (KeyValuePair <string, List <StoredElement> > p in elements) { int lastLen = 0; int count = 0; foreach (StoredElement e in p.Value) { if (lastLen != e.GetInitialLength()) { if (count != 0) { ret.Add(prev.ToString() + " Sztuk: " + count); count = 0; } } prev = e; lastLen = e.GetInitialLength(); ++count; } if (elements.Any()) { ret.Add(prev.ToString() + " Sztuk: " + count); ret.Add(""); } } return(ret); }
private static void writeElementToStoreFile(WorkbookPart workbook, StoredElement e, int count) { InsertCell(workbook, "A", rowNumber, e.GetProfile()); InsertCell(workbook, "B", rowNumber, e.GetElementType()); InsertCell(workbook, "C", rowNumber, e.GetLength().ToString()); InsertCell(workbook, "D", rowNumber, count.ToString()); InsertCell(workbook, "E", rowNumber, e.GetDelivery()); ++rowNumber; }