Task <int> ProcessAsync(Workbook WB, IProgress <int> ChangeProgressBar) { return(Task.Run(() => { Worksheet T1 = WB.Sheets["А407-088Т1"]; int NumberOfFirstRow = 8; int maxRow = NumberOfFirstRow; while (T1.Cells[maxRow, ColumnNumbers.WireSm2].Value != null) { maxRow++; } ChangeProgressBar.Report(maxRow - NumberOfFirstRow); int CurrentRow = NumberOfFirstRow; while (T1.Cells[CurrentRow, ColumnNumbers.WireSm2].Value != null) { Wire wr = new Wire(T1.Cells[CurrentRow, ColumnNumbers.WireSm2].Value, T1.Cells[CurrentRow, ColumnNumbers.WireColorNew].Value.ToString(), T1.Cells[CurrentRow, ColumnNumbers.WireKey].Value.ToString().Replace(',', '.')); //T1.Cells[8,7] //Color = WireColor.GetEngColor(T1.Cells[CurrentRow, ColumnNumbers.WireColor].Value.ToString()), //wr.WireKey = wr.ElectricalSizeMM2.ToString().Replace(',', '.') + "_" + WireColor.toText(wr.Color) + "__PVA_" + T1.Cells[CurrentRow, ColumnNumbers.WireMarka].Value + "_U_660"; //string ArticleKey = wr.ElectricalSizeMM2.ToString().Replace(',', '.') + WireColor.toText(wr.Color); string ArticleKey = T1.Cells[CurrentRow, ColumnNumbers.ArticleKey].Value.ToString().Replace(',', '.'); //string name = "\"" + (T1.Cells[CurrentRow, ColumnNumbers.NomerPoChertegu1].Value ?? "").ToString() + " " + (T1.Cells[CurrentRow, ColumnNumbers.NomerPoChertegu2].Value ?? "").ToString() + "\""; string name = "\"" + T1.Cells[CurrentRow, ColumnNumbers.NameOfNewLeadSet].Value + "\""; double wireLength = T1.Cells[CurrentRow, ColumnNumbers.WireLength].Value; double?[] strippingLength = new double?[2] { GetDoubleValue(T1.Cells[CurrentRow, ColumnNumbers.StrippingLength1].Value), GetDoubleValue(T1.Cells[CurrentRow, ColumnNumbers.StrippingLength2].Value) }; double?[] pullOffLength = new double?[2] { GetDoubleValue(T1.Cells[CurrentRow, ColumnNumbers.PullOffLength1].Value), GetDoubleValue(T1.Cells[CurrentRow, ColumnNumbers.PullOffLength2].Value) }; int pieces = (int)T1.Cells[CurrentRow, ColumnNumbers.Pieces].Value; string fontKey = T1.Cells[CurrentRow, ColumnNumbers.FontKey].Value; MarkingText MTBegin1 = new MarkingText( MarkingText.MarkingTextTypes.MarkingTextBegin , GetDoubleValue(T1.Cells[CurrentRow, ColumnNumbers.MarkingTextBegin1_distance].Value) , T1.Cells[CurrentRow, ColumnNumbers.MarkingTextBegin1_MarkingText].Value , GetIntValue(T1.Cells[CurrentRow, ColumnNumbers.MarkingTextBegin1_turnText].Value) ); MarkingText MTBegin2 = new MarkingText( MarkingText.MarkingTextTypes.MarkingTextBegin , GetDoubleValue(T1.Cells[CurrentRow, ColumnNumbers.MarkingTextBegin2_distance].Value) , T1.Cells[CurrentRow, ColumnNumbers.MarkingTextBegin2_MarkingText].Value , GetIntValue(T1.Cells[CurrentRow, ColumnNumbers.MarkingTextBegin2_turnText].Value) ); MarkingText MTBegin3 = new MarkingText( MarkingText.MarkingTextTypes.MarkingTextBegin , GetDoubleValue(T1.Cells[CurrentRow, ColumnNumbers.MarkingTextBegin3_distance].Value) , T1.Cells[CurrentRow, ColumnNumbers.MarkingTextBegin3_MarkingText].Value , GetIntValue(T1.Cells[CurrentRow, ColumnNumbers.MarkingTextBegin3_turnText].Value) ); MarkingText MTEndless = new MarkingText( MarkingText.MarkingTextTypes.MarkingTextEndless , GetDoubleValue(T1.Cells[CurrentRow, ColumnNumbers.MarkingTextEndless_distance].Value) , T1.Cells[CurrentRow, ColumnNumbers.MarkingTextEndless_MarkingText].Value , GetIntValue(T1.Cells[CurrentRow, ColumnNumbers.MarkingTextEndless_turnText].Value) ); MarkingText MTEnd1 = new MarkingText( MarkingText.MarkingTextTypes.MarkingTextEnd , GetDoubleValue(T1.Cells[CurrentRow, ColumnNumbers.MarkingTextEnd1_distance].Value) , T1.Cells[CurrentRow, ColumnNumbers.MarkingTextEnd1_MarkingText].Value , GetIntValue(T1.Cells[CurrentRow, ColumnNumbers.MarkingTextEnd1_turnText].Value) ); MarkingText MTEnd2 = new MarkingText( MarkingText.MarkingTextTypes.MarkingTextEnd , GetDoubleValue(T1.Cells[CurrentRow, ColumnNumbers.MarkingTextEnd2_distance].Value) , T1.Cells[CurrentRow, ColumnNumbers.MarkingTextEnd2_MarkingText].Value , GetIntValue(T1.Cells[CurrentRow, ColumnNumbers.MarkingTextEnd2_turnText].Value) ); MarkingText MTEnd3 = new MarkingText( MarkingText.MarkingTextTypes.MarkingTextEnd , GetDoubleValue(T1.Cells[CurrentRow, ColumnNumbers.MarkingTextEnd3_distance].Value) , T1.Cells[CurrentRow, ColumnNumbers.MarkingTextEnd3_MarkingText].Value , GetIntValue(T1.Cells[CurrentRow, ColumnNumbers.MarkingTextEnd3_turnText].Value) ); NewMarkingTextWire nmtw = new NewMarkingTextWire(new List <MarkingText> { MTBegin1, MTBegin2, MTBegin3, MTEndless, MTEnd1, MTEnd2, MTEnd3 }); NewLeadSet nls = new NewLeadSet(name, new string[] { wr.WireKey }, new double[] { wireLength }, strippingLength, pullOffLength, pieces, fontKey, nmtw); if (NewArticles.ContainsKey(ArticleKey)) { ((NewArticle)NewArticles[ArticleKey]).AddNewLeadSet(nls); } else { NewArticles.Add(ArticleKey, new NewArticle(wr, ArticleKey, new List <NewLeadSet> { nls })); } ChangeProgressBar.Report(CurrentRow - NumberOfFirstRow + 1); CurrentRow++; } return CurrentRow - NumberOfFirstRow; })); } // Process!!!!!!!!
public void AddNewLeadSet(NewLeadSet leadSet) { items.Add(leadSet); }