complete
This commit is contained in:
@@ -13,6 +13,7 @@ namespace SushiBarBusinessLogic.OfficePackage
|
|||||||
public void CreateReport(ExcelInfo info)
|
public void CreateReport(ExcelInfo info)
|
||||||
{
|
{
|
||||||
CreateExcel(info);
|
CreateExcel(info);
|
||||||
|
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
{
|
{
|
||||||
ColumnName = "A",
|
ColumnName = "A",
|
||||||
@@ -20,40 +21,46 @@ namespace SushiBarBusinessLogic.OfficePackage
|
|||||||
Text = info.Title,
|
Text = info.Title,
|
||||||
StyleInfo = ExcelStyleInfoType.Title
|
StyleInfo = ExcelStyleInfoType.Title
|
||||||
});
|
});
|
||||||
|
|
||||||
MergeCells(new ExcelMergeParameters
|
MergeCells(new ExcelMergeParameters
|
||||||
{
|
{
|
||||||
CellFromName = "A1",
|
CellFromName = "A1",
|
||||||
CellToName = "C1"
|
CellToName = "C1"
|
||||||
});
|
});
|
||||||
|
|
||||||
uint rowIndex = 2;
|
uint rowIndex = 2;
|
||||||
foreach (var sc in info.SushiComponents)
|
foreach (var pc in info.SushiComponents)
|
||||||
{
|
{
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
{
|
{
|
||||||
ColumnName = "A",
|
ColumnName = "A",
|
||||||
RowIndex = rowIndex,
|
RowIndex = rowIndex,
|
||||||
Text = sc.SushiName,
|
Text = pc.SushiName,
|
||||||
StyleInfo = ExcelStyleInfoType.Text
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
});
|
});
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
foreach (var component in sc.Components)
|
|
||||||
|
foreach (var (Component, Count) in pc.Components)
|
||||||
{
|
{
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
{
|
{
|
||||||
ColumnName = "B",
|
ColumnName = "B",
|
||||||
RowIndex = rowIndex,
|
RowIndex = rowIndex,
|
||||||
Text = component.Item1,
|
Text = Component,
|
||||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||||
});
|
});
|
||||||
|
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
{
|
{
|
||||||
ColumnName = "C",
|
ColumnName = "C",
|
||||||
RowIndex = rowIndex,
|
RowIndex = rowIndex,
|
||||||
Text = component.Item2.ToString(),
|
Text = Count.ToString(),
|
||||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||||
});
|
});
|
||||||
|
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
{
|
{
|
||||||
ColumnName = "A",
|
ColumnName = "A",
|
||||||
@@ -65,11 +72,12 @@ namespace SushiBarBusinessLogic.OfficePackage
|
|||||||
{
|
{
|
||||||
ColumnName = "C",
|
ColumnName = "C",
|
||||||
RowIndex = rowIndex,
|
RowIndex = rowIndex,
|
||||||
Text = sc.TotalCount.ToString(),
|
Text = pc.TotalCount.ToString(),
|
||||||
StyleInfo = ExcelStyleInfoType.Text
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
});
|
});
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveExcel(info);
|
SaveExcel(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,26 +152,10 @@ namespace SushiBarBusinessLogic.OfficePackage
|
|||||||
|
|
||||||
SaveExcel(info);
|
SaveExcel(info);
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Создание excel-файла
|
protected abstract void CreateExcel(IDocument info);
|
||||||
/// </summary>
|
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
||||||
/// <param name="info"></param>
|
|
||||||
protected abstract void CreateExcel(ExcelInfo info);
|
|
||||||
/// <summary>
|
|
||||||
/// Добавляем новую ячейку в лист
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="cellParameters"></param>
|
|
||||||
protected abstract void InsertCellInWorksheet(ExcelCellParameters
|
|
||||||
excelParams);
|
|
||||||
/// <summary>
|
|
||||||
/// Объединение ячеек
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="mergeParameters"></param>
|
|
||||||
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
||||||
/// <summary>
|
protected abstract void SaveExcel(IDocument info);
|
||||||
/// Сохранение файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="info"></param>
|
|
||||||
protected abstract void SaveExcel(ExcelInfo info);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,39 +13,29 @@ namespace SushiBarBusinessLogic.OfficePackage
|
|||||||
public void CreateDoc(PdfInfo info)
|
public void CreateDoc(PdfInfo info)
|
||||||
{
|
{
|
||||||
CreatePdf(info);
|
CreatePdf(info);
|
||||||
CreateParagraph(new PdfParagraph
|
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||||
{
|
CreateParagraph(new PdfParagraph { Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||||
Text = info.Title,
|
|
||||||
Style = "NormalTitle",
|
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
|
||||||
});
|
|
||||||
CreateParagraph(new PdfParagraph
|
|
||||||
{
|
|
||||||
Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal",
|
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
|
||||||
});
|
|
||||||
CreateTable(new List<string> { "1cm", "3cm", "4cm", "6cm", "3cm" });
|
|
||||||
CreateRow(new PdfRowParameters
|
CreateRow(new PdfRowParameters
|
||||||
{
|
{
|
||||||
Texts = new List<string> { "Номер", "Дата заказа", "Статус", "Изделие", "Сумма" },
|
Texts = new List<string> { "Номер", "Дата заказа", "Пицца", "Статус", "Сумма" },
|
||||||
Style = "NormalTitle",
|
Style = "NormalTitle",
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (var order in info.Orders)
|
foreach (var order in info.Orders)
|
||||||
{
|
{
|
||||||
CreateRow(new PdfRowParameters
|
CreateRow(new PdfRowParameters
|
||||||
{
|
{
|
||||||
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.Status.ToString(), order.SushiName, order.Sum.ToString() },
|
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.SushiName, order.Status.ToString(), order.Sum.ToString() },
|
||||||
Style = "Normal",
|
Style = "Normal",
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
CreateParagraph(new PdfParagraph
|
CreateParagraph(new PdfParagraph { Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Rigth });
|
||||||
{
|
|
||||||
Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t",
|
|
||||||
Style = "Normal",
|
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Rigth
|
|
||||||
});
|
|
||||||
SavePdf(info);
|
SavePdf(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,33 +62,16 @@ namespace SushiBarBusinessLogic.OfficePackage
|
|||||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CreateParagraph(new PdfParagraph { Text = $"Итого: {info.GroupedOrders.Sum(x => x.OrdersSum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||||
|
|
||||||
|
SavePdf(info);
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Создание doc-файла
|
protected abstract void CreatePdf(IDocument info);
|
||||||
/// </summary>
|
|
||||||
/// <param name="info"></param>
|
|
||||||
protected abstract void CreatePdf(PdfInfo info);
|
|
||||||
/// <summary>
|
|
||||||
/// Создание параграфа с текстом
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="title"></param>
|
|
||||||
/// <param name="style"></param>
|
|
||||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||||
/// <summary>
|
|
||||||
/// Создание таблицы
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="title"></param>
|
|
||||||
/// <param name="style"></param>
|
|
||||||
protected abstract void CreateTable(List<string> columns);
|
protected abstract void CreateTable(List<string> columns);
|
||||||
/// <summary>
|
|
||||||
/// Создание и заполнение строки
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="rowParameters"></param>
|
|
||||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||||
/// <summary>
|
protected abstract void SavePdf(IDocument info);
|
||||||
/// Сохранение файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="info"></param>
|
|
||||||
protected abstract void SavePdf(PdfInfo info);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,22 +80,9 @@ namespace SushiBarBusinessLogic.OfficePackage
|
|||||||
SaveWord(info);
|
SaveWord(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
protected abstract void CreateWord(IDocument info);
|
||||||
/// Создание doc-файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="info"></param>
|
|
||||||
protected abstract void CreateWord(WordInfo info);
|
|
||||||
/// <summary>
|
|
||||||
/// Создание абзаца с текстом
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="paragraph"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
protected abstract void CreateParagraph(WordParagraph paragraph);
|
protected abstract void CreateParagraph(WordParagraph paragraph);
|
||||||
/// <summary>
|
protected abstract void SaveWord(IDocument info);
|
||||||
/// Сохранение файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="info"></param>
|
|
||||||
protected abstract void SaveWord(WordInfo info);
|
|
||||||
protected abstract void CreateTable(List<string> colums);
|
protected abstract void CreateTable(List<string> colums);
|
||||||
protected abstract void CreateRow(WordRowParameters rowParameters);
|
protected abstract void CreateRow(WordRowParameters rowParameters);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace SushiBarBusinessLogic.OfficePackage.HelperModels
|
namespace SushiBarBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class ExcelInfo
|
public class ExcelInfo : IDocument
|
||||||
{
|
{
|
||||||
public string FileName { get; set; } = string.Empty;
|
public string FileName { get; set; } = string.Empty;
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace SushiBarBusinessLogic.OfficePackage.HelperModels
|
namespace SushiBarBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class PdfInfo
|
public class PdfInfo : IDocument
|
||||||
{
|
{
|
||||||
public string FileName { get; set; } = string.Empty;
|
public string FileName { get; set; } = string.Empty;
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace SushiBarBusinessLogic.OfficePackage.HelperModels
|
namespace SushiBarBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class WordInfo
|
public class WordInfo : IDocument
|
||||||
{
|
{
|
||||||
public string FileName { get; set; } = string.Empty;
|
public string FileName { get; set; } = string.Empty;
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace SushiBarBusinessLogic.OfficePackage
|
namespace SushiBarBusinessLogic.OfficePackage
|
||||||
{
|
{
|
||||||
public interface IDocument
|
public interface IDocument
|
||||||
{
|
{
|
||||||
public string FileName { get; set; }
|
public string FileName { get; set; }
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
|
|||||||
@@ -14,167 +14,110 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
private SpreadsheetDocument? _spreadsheetDocument;
|
private SpreadsheetDocument? _spreadsheetDocument;
|
||||||
private SharedStringTablePart? _shareStringPart;
|
private SharedStringTablePart? _shareStringPart;
|
||||||
private Worksheet? _worksheet;
|
private Worksheet? _worksheet;
|
||||||
/// <summary>
|
|
||||||
/// Настройка стилей для файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="workbookpart"></param>
|
|
||||||
private static void CreateStyles(WorkbookPart workbookpart)
|
private static void CreateStyles(WorkbookPart workbookpart)
|
||||||
{
|
{
|
||||||
var sp = workbookpart.AddNewPart<WorkbookStylesPart>();
|
var sp = workbookpart.AddNewPart<WorkbookStylesPart>();
|
||||||
sp.Stylesheet = new Stylesheet();
|
sp.Stylesheet = new Stylesheet();
|
||||||
|
|
||||||
var fonts = new Fonts() { Count = 2U, KnownFonts = true };
|
var fonts = new Fonts() { Count = 2U, KnownFonts = true };
|
||||||
|
|
||||||
var fontUsual = new Font();
|
var fontUsual = new Font();
|
||||||
fontUsual.Append(new FontSize() { Val = 12D });
|
fontUsual.Append(new FontSize() { Val = 12D });
|
||||||
fontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
fontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U });
|
||||||
{ Theme = 1U });
|
|
||||||
fontUsual.Append(new FontName() { Val = "Times New Roman" });
|
fontUsual.Append(new FontName() { Val = "Times New Roman" });
|
||||||
fontUsual.Append(new FontFamilyNumbering() { Val = 2 });
|
fontUsual.Append(new FontFamilyNumbering() { Val = 2 });
|
||||||
fontUsual.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
fontUsual.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||||
|
|
||||||
var fontTitle = new Font();
|
var fontTitle = new Font();
|
||||||
fontTitle.Append(new Bold());
|
fontTitle.Append(new Bold());
|
||||||
fontTitle.Append(new FontSize() { Val = 14D });
|
fontTitle.Append(new FontSize() { Val = 14D });
|
||||||
fontTitle.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
fontTitle.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U });
|
||||||
{ Theme = 1U });
|
|
||||||
fontTitle.Append(new FontName() { Val = "Times New Roman" });
|
fontTitle.Append(new FontName() { Val = "Times New Roman" });
|
||||||
fontTitle.Append(new FontFamilyNumbering() { Val = 2 });
|
fontTitle.Append(new FontFamilyNumbering() { Val = 2 });
|
||||||
fontTitle.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
fontTitle.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||||
|
|
||||||
fonts.Append(fontUsual);
|
fonts.Append(fontUsual);
|
||||||
fonts.Append(fontTitle);
|
fonts.Append(fontTitle);
|
||||||
|
|
||||||
var fills = new Fills() { Count = 2U };
|
var fills = new Fills() { Count = 2U };
|
||||||
|
|
||||||
var fill1 = new Fill();
|
var fill1 = new Fill();
|
||||||
fill1.Append(new PatternFill() { PatternType = PatternValues.None });
|
fill1.Append(new PatternFill() { PatternType = PatternValues.None });
|
||||||
|
|
||||||
var fill2 = new Fill();
|
var fill2 = new Fill();
|
||||||
fill2.Append(new PatternFill()
|
fill2.Append(new PatternFill() { PatternType = PatternValues.Gray125 });
|
||||||
{
|
|
||||||
PatternType = PatternValues.Gray125
|
|
||||||
});
|
|
||||||
fills.Append(fill1);
|
fills.Append(fill1);
|
||||||
fills.Append(fill2);
|
fills.Append(fill2);
|
||||||
|
|
||||||
var borders = new Borders() { Count = 2U };
|
var borders = new Borders() { Count = 2U };
|
||||||
|
|
||||||
var borderNoBorder = new Border();
|
var borderNoBorder = new Border();
|
||||||
borderNoBorder.Append(new LeftBorder());
|
borderNoBorder.Append(new LeftBorder());
|
||||||
borderNoBorder.Append(new RightBorder());
|
borderNoBorder.Append(new RightBorder());
|
||||||
borderNoBorder.Append(new TopBorder());
|
borderNoBorder.Append(new TopBorder());
|
||||||
borderNoBorder.Append(new BottomBorder());
|
borderNoBorder.Append(new BottomBorder());
|
||||||
borderNoBorder.Append(new DiagonalBorder());
|
borderNoBorder.Append(new DiagonalBorder());
|
||||||
|
|
||||||
var borderThin = new Border();
|
var borderThin = new Border();
|
||||||
|
|
||||||
var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
|
var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
|
||||||
leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||||
{ Indexed = 64U });
|
|
||||||
var rightBorder = new RightBorder()
|
var rightBorder = new RightBorder() { Style = BorderStyleValues.Thin };
|
||||||
{
|
rightBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||||
Style = BorderStyleValues.Thin
|
|
||||||
};
|
|
||||||
rightBorder.Append(new
|
|
||||||
DocumentFormat.OpenXml.Office2010.Excel.Color()
|
|
||||||
{ Indexed = 64U });
|
|
||||||
var topBorder = new TopBorder() { Style = BorderStyleValues.Thin };
|
var topBorder = new TopBorder() { Style = BorderStyleValues.Thin };
|
||||||
topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
|
topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||||
{ Indexed = 64U });
|
|
||||||
var bottomBorder = new BottomBorder()
|
var bottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin };
|
||||||
{
|
bottomBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||||
Style =
|
|
||||||
BorderStyleValues.Thin
|
|
||||||
};
|
|
||||||
bottomBorder.Append(new
|
|
||||||
DocumentFormat.OpenXml.Office2010.Excel.Color()
|
|
||||||
{ Indexed = 64U });
|
|
||||||
borderThin.Append(leftBorder);
|
borderThin.Append(leftBorder);
|
||||||
borderThin.Append(rightBorder);
|
borderThin.Append(rightBorder);
|
||||||
borderThin.Append(topBorder);
|
borderThin.Append(topBorder);
|
||||||
borderThin.Append(bottomBorder);
|
borderThin.Append(bottomBorder);
|
||||||
borderThin.Append(new DiagonalBorder());
|
borderThin.Append(new DiagonalBorder());
|
||||||
|
|
||||||
borders.Append(borderNoBorder);
|
borders.Append(borderNoBorder);
|
||||||
borders.Append(borderThin);
|
borders.Append(borderThin);
|
||||||
|
|
||||||
var cellStyleFormats = new CellStyleFormats() { Count = 1U };
|
var cellStyleFormats = new CellStyleFormats() { Count = 1U };
|
||||||
var cellFormatStyle = new CellFormat()
|
var cellFormatStyle = new CellFormat() { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U };
|
||||||
{
|
|
||||||
NumberFormatId = 0U,
|
|
||||||
FontId
|
|
||||||
= 0U,
|
|
||||||
FillId = 0U,
|
|
||||||
BorderId = 0U
|
|
||||||
};
|
|
||||||
cellStyleFormats.Append(cellFormatStyle);
|
cellStyleFormats.Append(cellFormatStyle);
|
||||||
|
|
||||||
var cellFormats = new CellFormats() { Count = 3U };
|
var cellFormats = new CellFormats() { Count = 3U };
|
||||||
var cellFormatFont = new CellFormat()
|
var cellFormatFont = new CellFormat() { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U, FormatId = 0U, ApplyFont = true };
|
||||||
{
|
var cellFormatFontAndBorder = new CellFormat() { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 1U, FormatId = 0U, ApplyFont = true, ApplyBorder = true };
|
||||||
NumberFormatId = 0U,
|
var cellFormatTitle = new CellFormat() { NumberFormatId = 0U, FontId = 1U, FillId = 0U, BorderId = 0U, FormatId = 0U, Alignment = new Alignment() { Vertical = VerticalAlignmentValues.Center, WrapText = true, Horizontal = HorizontalAlignmentValues.Center }, ApplyFont = true };
|
||||||
FontId =
|
|
||||||
0U,
|
|
||||||
FillId = 0U,
|
|
||||||
BorderId = 0U,
|
|
||||||
FormatId = 0U,
|
|
||||||
ApplyFont = true
|
|
||||||
};
|
|
||||||
var cellFormatFontAndBorder = new CellFormat()
|
|
||||||
{
|
|
||||||
NumberFormatId = 0U,
|
|
||||||
FontId = 0U,
|
|
||||||
FillId = 0U,
|
|
||||||
BorderId = 1U,
|
|
||||||
FormatId = 0U,
|
|
||||||
ApplyFont = true,
|
|
||||||
ApplyBorder = true
|
|
||||||
};
|
|
||||||
var cellFormatTitle = new CellFormat()
|
|
||||||
{
|
|
||||||
NumberFormatId = 0U,
|
|
||||||
FontId
|
|
||||||
= 1U,
|
|
||||||
FillId = 0U,
|
|
||||||
BorderId = 0U,
|
|
||||||
FormatId = 0U,
|
|
||||||
Alignment = new Alignment()
|
|
||||||
{
|
|
||||||
Vertical = VerticalAlignmentValues.Center,
|
|
||||||
WrapText = true,
|
|
||||||
Horizontal =
|
|
||||||
HorizontalAlignmentValues.Center
|
|
||||||
},
|
|
||||||
ApplyFont = true
|
|
||||||
};
|
|
||||||
cellFormats.Append(cellFormatFont);
|
cellFormats.Append(cellFormatFont);
|
||||||
cellFormats.Append(cellFormatFontAndBorder);
|
cellFormats.Append(cellFormatFontAndBorder);
|
||||||
cellFormats.Append(cellFormatTitle);
|
cellFormats.Append(cellFormatTitle);
|
||||||
var cellStyles = new CellStyles() { Count = 1U };
|
|
||||||
cellStyles.Append(new CellStyle()
|
|
||||||
{
|
|
||||||
Name = "Normal",
|
|
||||||
FormatId = 0U,
|
|
||||||
BuiltinId = 0U
|
|
||||||
});
|
|
||||||
var differentialFormats = new
|
|
||||||
DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats()
|
|
||||||
{ Count = 0U };
|
|
||||||
|
|
||||||
var tableStyles = new TableStyles()
|
var cellStyles = new CellStyles() { Count = 1U };
|
||||||
{
|
|
||||||
Count = 0U,
|
cellStyles.Append(new CellStyle() { Name = "Normal", FormatId = 0U, BuiltinId = 0U });
|
||||||
DefaultTableStyle = "TableStyleMedium2",
|
|
||||||
DefaultPivotStyle = "PivotStyleLight16"
|
var differentialFormats = new DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats() { Count = 0U };
|
||||||
};
|
|
||||||
|
var tableStyles = new TableStyles() { Count = 0U, DefaultTableStyle = "TableStyleMedium2", DefaultPivotStyle = "PivotStyleLight16" };
|
||||||
|
|
||||||
var stylesheetExtensionList = new StylesheetExtensionList();
|
var stylesheetExtensionList = new StylesheetExtensionList();
|
||||||
var stylesheetExtension1 = new StylesheetExtension()
|
|
||||||
{
|
var stylesheetExtension1 = new StylesheetExtension() { Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" };
|
||||||
Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"
|
|
||||||
};
|
|
||||||
stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
||||||
stylesheetExtension1.Append(new SlicerStyles()
|
stylesheetExtension1.Append(new SlicerStyles() { DefaultSlicerStyle = "SlicerStyleLight1" });
|
||||||
{
|
|
||||||
DefaultSlicerStyle = "SlicerStyleLight1"
|
var stylesheetExtension2 = new StylesheetExtension() { Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}" };
|
||||||
});
|
|
||||||
var stylesheetExtension2 = new StylesheetExtension()
|
|
||||||
{
|
|
||||||
Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}"
|
|
||||||
};
|
|
||||||
stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
|
stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
|
||||||
stylesheetExtension2.Append(new TimelineStyles()
|
stylesheetExtension2.Append(new TimelineStyles() { DefaultTimelineStyle = "TimeSlicerStyleLight1" });
|
||||||
{
|
|
||||||
DefaultTimelineStyle = "TimeSlicerStyleLight1"
|
|
||||||
});
|
|
||||||
stylesheetExtensionList.Append(stylesheetExtension1);
|
stylesheetExtensionList.Append(stylesheetExtension1);
|
||||||
stylesheetExtensionList.Append(stylesheetExtension2);
|
stylesheetExtensionList.Append(stylesheetExtension2);
|
||||||
|
|
||||||
sp.Stylesheet.Append(fonts);
|
sp.Stylesheet.Append(fonts);
|
||||||
sp.Stylesheet.Append(fills);
|
sp.Stylesheet.Append(fills);
|
||||||
sp.Stylesheet.Append(borders);
|
sp.Stylesheet.Append(borders);
|
||||||
@@ -185,11 +128,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
sp.Stylesheet.Append(tableStyles);
|
sp.Stylesheet.Append(tableStyles);
|
||||||
sp.Stylesheet.Append(stylesheetExtensionList);
|
sp.Stylesheet.Append(stylesheetExtensionList);
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Получение номера стиля из типа
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="styleInfo"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static uint GetStyleValue(ExcelStyleInfoType styleInfo)
|
private static uint GetStyleValue(ExcelStyleInfoType styleInfo)
|
||||||
{
|
{
|
||||||
return styleInfo switch
|
return styleInfo switch
|
||||||
@@ -200,40 +139,44 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
_ => 0U,
|
_ => 0U,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
protected override void CreateExcel(ExcelInfo info)
|
|
||||||
|
protected override void CreateExcel(IDocument info)
|
||||||
{
|
{
|
||||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName,
|
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
|
||||||
SpreadsheetDocumentType.Workbook);
|
// Создаем книгу (в ней хранятся листы)
|
||||||
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
|
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
|
||||||
workbookpart.Workbook = new Workbook();
|
workbookpart.Workbook = new Workbook();
|
||||||
|
|
||||||
CreateStyles(workbookpart);
|
CreateStyles(workbookpart);
|
||||||
_shareStringPart =
|
|
||||||
_spreadsheetDocument.WorkbookPart!.GetPartsOfType<SharedStringTablePart>().Any()
|
// Получаем/создаем хранилище текстов для книги
|
||||||
?
|
_shareStringPart = _spreadsheetDocument.WorkbookPart!.GetPartsOfType<SharedStringTablePart>().Any()
|
||||||
_spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First()
|
? _spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First()
|
||||||
:
|
: _spreadsheetDocument.WorkbookPart.AddNewPart<SharedStringTablePart>();
|
||||||
_spreadsheetDocument.WorkbookPart.AddNewPart<SharedStringTablePart>();
|
|
||||||
// Создаем SharedStringTable, если его нет
|
// Создаем SharedStringTable, если его нет
|
||||||
if (_shareStringPart.SharedStringTable == null)
|
if (_shareStringPart.SharedStringTable == null)
|
||||||
{
|
{
|
||||||
_shareStringPart.SharedStringTable = new SharedStringTable();
|
_shareStringPart.SharedStringTable = new SharedStringTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Создаем лист в книгу
|
// Создаем лист в книгу
|
||||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||||
worksheetPart.Worksheet = new Worksheet(new SheetData());
|
worksheetPart.Worksheet = new Worksheet(new SheetData());
|
||||||
|
|
||||||
// Добавляем лист в книгу
|
// Добавляем лист в книгу
|
||||||
var sheets =
|
var sheets = _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
|
||||||
_spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
|
|
||||||
var sheet = new Sheet()
|
var sheet = new Sheet()
|
||||||
{
|
{
|
||||||
Id =
|
Id = _spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||||
_spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
|
||||||
SheetId = 1,
|
SheetId = 1,
|
||||||
Name = "Лист"
|
Name = "Лист"
|
||||||
};
|
};
|
||||||
sheets.Append(sheet);
|
sheets.Append(sheet);
|
||||||
|
|
||||||
_worksheet = worksheetPart.Worksheet;
|
_worksheet = worksheetPart.Worksheet;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void InsertCellInWorksheet(ExcelCellParameters excelParams)
|
protected override void InsertCellInWorksheet(ExcelCellParameters excelParams)
|
||||||
{
|
{
|
||||||
if (_worksheet == null || _shareStringPart == null)
|
if (_worksheet == null || _shareStringPart == null)
|
||||||
@@ -245,6 +188,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ищем строку, либо добавляем ее
|
// Ищем строку, либо добавляем ее
|
||||||
Row row;
|
Row row;
|
||||||
if (sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).Any())
|
if (sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).Any())
|
||||||
@@ -256,7 +200,8 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
row = new Row() { RowIndex = excelParams.RowIndex };
|
row = new Row() { RowIndex = excelParams.RowIndex };
|
||||||
sheetData.Append(row);
|
sheetData.Append(row);
|
||||||
}
|
}
|
||||||
// Ищем нужную ячейку
|
|
||||||
|
// Ищем нужную ячейку
|
||||||
Cell cell;
|
Cell cell;
|
||||||
if (row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).Any())
|
if (row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).Any())
|
||||||
{
|
{
|
||||||
@@ -275,20 +220,22 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var newCell = new Cell()
|
|
||||||
{
|
var newCell = new Cell() { CellReference = excelParams.CellReference };
|
||||||
CellReference = excelParams.CellReference
|
|
||||||
};
|
|
||||||
row.InsertBefore(newCell, refCell);
|
row.InsertBefore(newCell, refCell);
|
||||||
|
|
||||||
cell = newCell;
|
cell = newCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
// вставляем новый текст
|
// вставляем новый текст
|
||||||
_shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(excelParams.Text)));
|
_shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(excelParams.Text)));
|
||||||
_shareStringPart.SharedStringTable.Save();
|
_shareStringPart.SharedStringTable.Save();
|
||||||
|
|
||||||
cell.CellValue = new CellValue((_shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count() - 1).ToString());
|
cell.CellValue = new CellValue((_shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count() - 1).ToString());
|
||||||
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
|
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
|
||||||
cell.StyleIndex = GetStyleValue(excelParams.StyleInfo);
|
cell.StyleIndex = GetStyleValue(excelParams.StyleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void MergeCells(ExcelMergeParameters excelParams)
|
protected override void MergeCells(ExcelMergeParameters excelParams)
|
||||||
{
|
{
|
||||||
if (_worksheet == null)
|
if (_worksheet == null)
|
||||||
@@ -296,6 +243,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MergeCells mergeCells;
|
MergeCells mergeCells;
|
||||||
|
|
||||||
if (_worksheet.Elements<MergeCells>().Any())
|
if (_worksheet.Elements<MergeCells>().Any())
|
||||||
{
|
{
|
||||||
mergeCells = _worksheet.Elements<MergeCells>().First();
|
mergeCells = _worksheet.Elements<MergeCells>().First();
|
||||||
@@ -303,24 +251,25 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
mergeCells = new MergeCells();
|
mergeCells = new MergeCells();
|
||||||
|
|
||||||
if (_worksheet.Elements<CustomSheetView>().Any())
|
if (_worksheet.Elements<CustomSheetView>().Any())
|
||||||
{
|
{
|
||||||
_worksheet.InsertAfter(mergeCells,
|
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<CustomSheetView>().First());
|
||||||
_worksheet.Elements<CustomSheetView>().First());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_worksheet.InsertAfter(mergeCells,
|
_worksheet.InsertAfter(mergeCells, _worksheet.Elements<SheetData>().First());
|
||||||
_worksheet.Elements<SheetData>().First());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mergeCell = new MergeCell()
|
var mergeCell = new MergeCell()
|
||||||
{
|
{
|
||||||
Reference = new StringValue(excelParams.Merge)
|
Reference = new StringValue(excelParams.Merge)
|
||||||
};
|
};
|
||||||
mergeCells.Append(mergeCell);
|
mergeCells.Append(mergeCell);
|
||||||
}
|
}
|
||||||
protected override void SaveExcel(ExcelInfo info)
|
|
||||||
|
protected override void SaveExcel(IDocument info)
|
||||||
{
|
{
|
||||||
if (_spreadsheetDocument == null)
|
if (_spreadsheetDocument == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
private Document? _document;
|
private Document? _document;
|
||||||
private Section? _section;
|
private Section? _section;
|
||||||
private Table? _table;
|
private Table? _table;
|
||||||
|
|
||||||
private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type)
|
private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type)
|
||||||
{
|
{
|
||||||
return type switch
|
return type switch
|
||||||
@@ -21,24 +22,25 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
_ => ParagraphAlignment.Justify,
|
_ => ParagraphAlignment.Justify,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Создание стилей для документа
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="document"></param>
|
|
||||||
private static void DefineStyles(Document document)
|
private static void DefineStyles(Document document)
|
||||||
{
|
{
|
||||||
var style = document.Styles["Normal"];
|
var style = document.Styles["Normal"];
|
||||||
style.Font.Name = "Times New Roman";
|
style.Font.Name = "Times New Roman";
|
||||||
style.Font.Size = 14;
|
style.Font.Size = 14;
|
||||||
|
|
||||||
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
||||||
style.Font.Bold = true;
|
style.Font.Bold = true;
|
||||||
}
|
}
|
||||||
protected override void CreatePdf(PdfInfo info)
|
|
||||||
|
protected override void CreatePdf(IDocument info)
|
||||||
{
|
{
|
||||||
_document = new Document();
|
_document = new Document();
|
||||||
DefineStyles(_document);
|
DefineStyles(_document);
|
||||||
|
|
||||||
_section = _document.AddSection();
|
_section = _document.AddSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void CreateParagraph(PdfParagraph pdfParagraph)
|
protected override void CreateParagraph(PdfParagraph pdfParagraph)
|
||||||
{
|
{
|
||||||
if (_section == null)
|
if (_section == null)
|
||||||
@@ -50,6 +52,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
||||||
paragraph.Style = pdfParagraph.Style;
|
paragraph.Style = pdfParagraph.Style;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void CreateTable(List<string> columns)
|
protected override void CreateTable(List<string> columns)
|
||||||
{
|
{
|
||||||
if (_document == null)
|
if (_document == null)
|
||||||
@@ -57,11 +60,13 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_table = _document.LastSection.AddTable();
|
_table = _document.LastSection.AddTable();
|
||||||
|
|
||||||
foreach (var elem in columns)
|
foreach (var elem in columns)
|
||||||
{
|
{
|
||||||
_table.AddColumn(elem);
|
_table.AddColumn(elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void CreateRow(PdfRowParameters rowParameters)
|
protected override void CreateRow(PdfRowParameters rowParameters)
|
||||||
{
|
{
|
||||||
if (_table == null)
|
if (_table == null)
|
||||||
@@ -72,20 +77,25 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
for (int i = 0; i < rowParameters.Texts.Count; ++i)
|
for (int i = 0; i < rowParameters.Texts.Count; ++i)
|
||||||
{
|
{
|
||||||
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
|
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(rowParameters.Style))
|
if (!string.IsNullOrEmpty(rowParameters.Style))
|
||||||
{
|
{
|
||||||
row.Cells[i].Style = rowParameters.Style;
|
row.Cells[i].Style = rowParameters.Style;
|
||||||
}
|
}
|
||||||
|
|
||||||
Unit borderWidth = 0.5;
|
Unit borderWidth = 0.5;
|
||||||
|
|
||||||
row.Cells[i].Borders.Left.Width = borderWidth;
|
row.Cells[i].Borders.Left.Width = borderWidth;
|
||||||
row.Cells[i].Borders.Right.Width = borderWidth;
|
row.Cells[i].Borders.Right.Width = borderWidth;
|
||||||
row.Cells[i].Borders.Top.Width = borderWidth;
|
row.Cells[i].Borders.Top.Width = borderWidth;
|
||||||
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
||||||
|
|
||||||
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
||||||
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override void SavePdf(PdfInfo info)
|
|
||||||
|
protected override void SavePdf(IDocument info)
|
||||||
{
|
{
|
||||||
var renderer = new PdfDocumentRenderer(true)
|
var renderer = new PdfDocumentRenderer(true)
|
||||||
{
|
{
|
||||||
@@ -95,4 +105,4 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
renderer.PdfDocument.Save(info.FileName);
|
renderer.PdfDocument.Save(info.FileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,13 +11,8 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
{
|
{
|
||||||
private WordprocessingDocument? _wordDocument;
|
private WordprocessingDocument? _wordDocument;
|
||||||
private Body? _docBody;
|
private Body? _docBody;
|
||||||
/// <summary>
|
|
||||||
/// Получение типа выравнивания
|
private static JustificationValues GetJustificationValues(WordJustificationType type)
|
||||||
/// </summary>
|
|
||||||
/// <param name="type"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static JustificationValues
|
|
||||||
GetJustificationValues(WordJustificationType type)
|
|
||||||
{
|
{
|
||||||
return type switch
|
return type switch
|
||||||
{
|
{
|
||||||
@@ -26,59 +21,60 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
_ => JustificationValues.Left,
|
_ => JustificationValues.Left,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Настройки страницы
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static SectionProperties CreateSectionProperties()
|
private static SectionProperties CreateSectionProperties()
|
||||||
{
|
{
|
||||||
var properties = new SectionProperties();
|
var properties = new SectionProperties();
|
||||||
|
|
||||||
var pageSize = new PageSize
|
var pageSize = new PageSize
|
||||||
{
|
{
|
||||||
Orient = PageOrientationValues.Portrait
|
Orient = PageOrientationValues.Portrait
|
||||||
};
|
};
|
||||||
|
|
||||||
properties.AppendChild(pageSize);
|
properties.AppendChild(pageSize);
|
||||||
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Задание форматирования для абзаца
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="paragraphProperties"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties)
|
private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties)
|
||||||
{
|
{
|
||||||
if (paragraphProperties == null)
|
if (paragraphProperties == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var properties = new ParagraphProperties();
|
var properties = new ParagraphProperties();
|
||||||
|
|
||||||
properties.AppendChild(new Justification()
|
properties.AppendChild(new Justification()
|
||||||
{
|
{
|
||||||
Val = GetJustificationValues(paragraphProperties.JustificationType)
|
Val = GetJustificationValues(paragraphProperties.JustificationType)
|
||||||
});
|
});
|
||||||
|
|
||||||
properties.AppendChild(new SpacingBetweenLines
|
properties.AppendChild(new SpacingBetweenLines
|
||||||
{
|
{
|
||||||
LineRule = LineSpacingRuleValues.Auto
|
LineRule = LineSpacingRuleValues.Auto
|
||||||
});
|
});
|
||||||
|
|
||||||
properties.AppendChild(new Indentation());
|
properties.AppendChild(new Indentation());
|
||||||
|
|
||||||
var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
|
var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
|
||||||
if (!string.IsNullOrEmpty(paragraphProperties.Size))
|
if (!string.IsNullOrEmpty(paragraphProperties.Size))
|
||||||
{
|
{
|
||||||
paragraphMarkRunProperties.AppendChild(new FontSize
|
paragraphMarkRunProperties.AppendChild(new FontSize { Val = paragraphProperties.Size });
|
||||||
{
|
|
||||||
Val = paragraphProperties.Size
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
properties.AppendChild(paragraphMarkRunProperties);
|
properties.AppendChild(paragraphMarkRunProperties);
|
||||||
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
protected override void CreateWord(WordInfo info)
|
|
||||||
|
protected override void CreateWord(IDocument info)
|
||||||
{
|
{
|
||||||
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
||||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||||
mainPart.Document = new Document();
|
mainPart.Document = new Document();
|
||||||
_docBody = mainPart.Document.AppendChild(new Body());
|
_docBody = mainPart.Document.AppendChild(new Body());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void CreateParagraph(WordParagraph paragraph)
|
protected override void CreateParagraph(WordParagraph paragraph)
|
||||||
{
|
{
|
||||||
if (_docBody == null || paragraph == null)
|
if (_docBody == null || paragraph == null)
|
||||||
@@ -88,9 +84,11 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
var docParagraph = new Paragraph();
|
var docParagraph = new Paragraph();
|
||||||
|
|
||||||
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
|
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
|
||||||
|
|
||||||
foreach (var run in paragraph.Texts)
|
foreach (var run in paragraph.Texts)
|
||||||
{
|
{
|
||||||
var docRun = new Run();
|
var docRun = new Run();
|
||||||
|
|
||||||
var properties = new RunProperties();
|
var properties = new RunProperties();
|
||||||
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
||||||
if (run.Item2.Bold)
|
if (run.Item2.Bold)
|
||||||
@@ -98,24 +96,97 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
|
|||||||
properties.AppendChild(new Bold());
|
properties.AppendChild(new Bold());
|
||||||
}
|
}
|
||||||
docRun.AppendChild(properties);
|
docRun.AppendChild(properties);
|
||||||
docRun.AppendChild(new Text
|
|
||||||
{
|
docRun.AppendChild(new Text { Text = run.Item1, Space = SpaceProcessingModeValues.Preserve });
|
||||||
Text = run.Item1,
|
|
||||||
Space = SpaceProcessingModeValues.Preserve
|
|
||||||
});
|
|
||||||
docParagraph.AppendChild(docRun);
|
docParagraph.AppendChild(docRun);
|
||||||
}
|
}
|
||||||
|
|
||||||
_docBody.AppendChild(docParagraph);
|
_docBody.AppendChild(docParagraph);
|
||||||
}
|
}
|
||||||
protected override void SaveWord(WordInfo info)
|
|
||||||
|
protected override void SaveWord(IDocument info)
|
||||||
{
|
{
|
||||||
if (_docBody == null || _wordDocument == null)
|
if (_docBody == null || _wordDocument == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_docBody.AppendChild(CreateSectionProperties());
|
_docBody.AppendChild(CreateSectionProperties());
|
||||||
|
|
||||||
_wordDocument.MainDocumentPart!.Document.Save();
|
_wordDocument.MainDocumentPart!.Document.Save();
|
||||||
_wordDocument.Dispose();
|
_wordDocument.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Table? _lastTable;
|
||||||
|
protected override void CreateTable(List<string> columns)
|
||||||
|
{
|
||||||
|
if (_docBody == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_lastTable = new Table();
|
||||||
|
|
||||||
|
var tableProp = new TableProperties();
|
||||||
|
tableProp.AppendChild(new TableLayout { Type = TableLayoutValues.Fixed });
|
||||||
|
tableProp.AppendChild(new TableBorders(
|
||||||
|
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 }
|
||||||
|
));
|
||||||
|
tableProp.AppendChild(new TableWidth { Type = TableWidthUnitValues.Auto });
|
||||||
|
_lastTable.AppendChild(tableProp);
|
||||||
|
|
||||||
|
TableGrid tableGrid = new TableGrid();
|
||||||
|
foreach (var column in columns)
|
||||||
|
{
|
||||||
|
tableGrid.AppendChild(new GridColumn() { Width = column });
|
||||||
|
}
|
||||||
|
_lastTable.AppendChild(tableGrid);
|
||||||
|
|
||||||
|
_docBody.AppendChild(_lastTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void CreateRow(WordRowParameters rowParameters)
|
||||||
|
{
|
||||||
|
if (_docBody == null || _lastTable == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
TableRow docRow = new TableRow();
|
||||||
|
foreach (var column in rowParameters.Texts)
|
||||||
|
{
|
||||||
|
var docParagraph = new Paragraph();
|
||||||
|
WordParagraph paragraph = new WordParagraph
|
||||||
|
{
|
||||||
|
Texts = new List<(string, WordTextProperties)> { (column, rowParameters.TextProperties) },
|
||||||
|
TextProperties = rowParameters.TextProperties
|
||||||
|
};
|
||||||
|
|
||||||
|
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
|
||||||
|
|
||||||
|
foreach (var run in paragraph.Texts)
|
||||||
|
{
|
||||||
|
var docRun = new Run();
|
||||||
|
|
||||||
|
var properties = new RunProperties();
|
||||||
|
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
||||||
|
if (run.Item2.Bold)
|
||||||
|
{
|
||||||
|
properties.AppendChild(new Bold());
|
||||||
|
}
|
||||||
|
docRun.AppendChild(properties);
|
||||||
|
|
||||||
|
docRun.AppendChild(new Text { Text = run.Item1, Space = SpaceProcessingModeValues.Preserve });
|
||||||
|
|
||||||
|
docParagraph.AppendChild(docRun);
|
||||||
|
}
|
||||||
|
|
||||||
|
TableCell docCell = new TableCell();
|
||||||
|
docCell.AppendChild(docParagraph);
|
||||||
|
docRow.AppendChild(docCell);
|
||||||
|
}
|
||||||
|
_lastTable.AppendChild(docRow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,248 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using SushiBarDatabaseImplement;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace SushiBarDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(SushiBarDatabase))]
|
|
||||||
[Migration("20240409140637_InitialCreate_Hard")]
|
|
||||||
partial class InitialCreate_Hard
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "7.0.17")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
|
||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Component", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ComponentName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<double>("Cost")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Components");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreate")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("DateImplement")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<int>("Status")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<double>("Sum")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.Property<int>("SushiId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("SushiId");
|
|
||||||
|
|
||||||
b.ToTable("Orders");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Shop", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("Adress")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<DateTime>("OpeningDate")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.Property<string>("ShopName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<int>("SushiMaxCount")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Shops");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.ShopSushis", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("ShopId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("SushiId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ShopId");
|
|
||||||
|
|
||||||
b.HasIndex("SushiId");
|
|
||||||
|
|
||||||
b.ToTable("ShopSushis");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Sushi", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<double>("Price")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.Property<string>("SushiName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Sushis");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.SushiComponent", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("ComponentId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("SushiId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ComponentId");
|
|
||||||
|
|
||||||
b.HasIndex("SushiId");
|
|
||||||
|
|
||||||
b.ToTable("SushiComponents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi")
|
|
||||||
.WithMany("Orders")
|
|
||||||
.HasForeignKey("SushiId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Sushi");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.ShopSushis", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("SushiBarDatabaseImplement.Models.Shop", "Shop")
|
|
||||||
.WithMany("Sushis")
|
|
||||||
.HasForeignKey("ShopId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("SushiId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Shop");
|
|
||||||
|
|
||||||
b.Navigation("Sushi");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.SushiComponent", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("SushiBarDatabaseImplement.Models.Component", "Component")
|
|
||||||
.WithMany("SushiComponents")
|
|
||||||
.HasForeignKey("ComponentId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi")
|
|
||||||
.WithMany("Components")
|
|
||||||
.HasForeignKey("SushiId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Component");
|
|
||||||
|
|
||||||
b.Navigation("Sushi");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Component", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("SushiComponents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Shop", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Sushis");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Sushi", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Components");
|
|
||||||
|
|
||||||
b.Navigation("Orders");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace SushiBarDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class InitialCreate_Hard : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Shops",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
ShopName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
Adress = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
OpeningDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
||||||
SushiMaxCount = table.Column<int>(type: "int", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Shops", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "ShopSushis",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
SushiId = table.Column<int>(type: "int", nullable: false),
|
|
||||||
ShopId = table.Column<int>(type: "int", nullable: false),
|
|
||||||
Count = table.Column<int>(type: "int", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_ShopSushis", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_ShopSushis_Shops_ShopId",
|
|
||||||
column: x => x.ShopId,
|
|
||||||
principalTable: "Shops",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_ShopSushis_Sushis_SushiId",
|
|
||||||
column: x => x.SushiId,
|
|
||||||
principalTable: "Sushis",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_ShopSushis_ShopId",
|
|
||||||
table: "ShopSushis",
|
|
||||||
column: "ShopId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_ShopSushis_SushiId",
|
|
||||||
table: "ShopSushis",
|
|
||||||
column: "SushiId");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "ShopSushis");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Shops");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -12,8 +12,8 @@ using SushiBarDatabaseImplement;
|
|||||||
namespace SushiBarDatabaseImplement.Migrations
|
namespace SushiBarDatabaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(SushiBarDatabase))]
|
[DbContext(typeof(SushiBarDatabase))]
|
||||||
[Migration("20240409135559_InitialCreate")]
|
[Migration("20240424121819_InitCreate")]
|
||||||
partial class InitialCreate
|
partial class InitCreate
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
namespace SushiBarDatabaseImplement.Migrations
|
namespace SushiBarDatabaseImplement.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class InitialCreate : Migration
|
public partial class InitCreate : Migration
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
@@ -25,7 +25,22 @@ namespace SushiBarDatabaseImplement.Migrations
|
|||||||
table.PrimaryKey("PK_Components", x => x.Id);
|
table.PrimaryKey("PK_Components", x => x.Id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Shops",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ShopName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Adress = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
OpeningDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||||
|
SushiMaxCount = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Shops", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Sushis",
|
name: "Sushis",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
@@ -64,6 +79,33 @@ namespace SushiBarDatabaseImplement.Migrations
|
|||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "ShopSushis",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
SushiId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ShopId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Count = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_ShopSushis", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ShopSushis_Shops_ShopId",
|
||||||
|
column: x => x.ShopId,
|
||||||
|
principalTable: "Shops",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ShopSushis_Sushis_SushiId",
|
||||||
|
column: x => x.SushiId,
|
||||||
|
principalTable: "Sushis",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "SushiComponents",
|
name: "SushiComponents",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
@@ -96,6 +138,16 @@ namespace SushiBarDatabaseImplement.Migrations
|
|||||||
table: "Orders",
|
table: "Orders",
|
||||||
column: "SushiId");
|
column: "SushiId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ShopSushis_ShopId",
|
||||||
|
table: "ShopSushis",
|
||||||
|
column: "ShopId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ShopSushis_SushiId",
|
||||||
|
table: "ShopSushis",
|
||||||
|
column: "SushiId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_SushiComponents_ComponentId",
|
name: "IX_SushiComponents_ComponentId",
|
||||||
table: "SushiComponents",
|
table: "SushiComponents",
|
||||||
@@ -113,9 +165,15 @@ namespace SushiBarDatabaseImplement.Migrations
|
|||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Orders");
|
name: "Orders");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "ShopSushis");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "SushiComponents");
|
name: "SushiComponents");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Shops");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Components");
|
name: "Components");
|
||||||
|
|
||||||
Reference in New Issue
Block a user