static void Main(string[] args) { string x = ImportTemplate.GetExportTemplate(false, Guid.Empty, Guid.Empty); using (Stream fileStream = File.OpenRead(x)) { MemoryStream stream = new MemoryStream(); fileStream.CopyTo(stream); stream.Seek(0, SeekOrigin.Begin); using (ExcelEngine engine = new ExcelEngine()) { IWorkbook workbook = engine.Excel.Workbooks.Open(stream); IWorksheet sheet = workbook.Worksheets[0]; if (!ImportProduct.CheckFile(sheet)) { sheet.Range[1, 19].Text = @"Шаблон отличается"; } else { for (int j = 1; j < sheet.Rows.Length; j++) { ImportProduct.ParseProduct(sheet.Rows[j], sheet); } } sheet.Range[1, 19].AutofitRows(); workbook.SaveAs(@"C:\Users\Василий\Desktop\dasdasd2.xls"); workbook.Close(); engine.Dispose(); } } }
public static void CheckInBpm(Product product, IRange row, IWorksheet sheet) { Guid result = Guid.Empty; string sqlText = $@"SELECT TOP 1 [Id] FROM [Product] WHERE [Id] = '{product.Id}' "; if (product.CodeSap != null || product.CodeSap != String.Empty) { sqlText += $@" OR [TcmCodeSap] = N'{product.CodeSap}'"; } if (product.CodeOld != null || product.CodeOld != String.Empty) { sqlText += $@" OR [TcmCodeOld] = N'{product.CodeOld}' "; } DataTable dt = ImportProduct.GetDataTable(sqlText); if (dt.Rows.Count > 0) { sheet.Range[row.Row, 1, row.Row, 18].CellStyle.Color = System.Drawing.Color.Red; sheet.Range[row.Row, 19].Text = @"Продукт уже существует"; } else { //InsertProductInBPM(product, sheet); } }
public static Guid GetLookupValue(string name, string lookupName) { Guid result = Guid.Empty; string sqlText = $@"SELECT TOP 1 [RecordId] FROM [{lookupName}] WHERE [Name] = N'{name}'"; DataTable dt = ImportProduct.GetDataTable(sqlText); if (dt.Rows.Count > 0) { result = dt.Rows[0].Field <Guid>("RecordId"); } return(result); }