Esempio n. 1
0
        private static void AddBatterySheet(IReadOnlyDbContext db, ExcelPackage pkg, Dictionary <string, string> centerNames)
        {
            var sheet = pkg.Workbook.Worksheets.Add("Batteries");
            var data  = db.Find <RectifierAndBattery>(rb => rb.Deleted != true)
                        .Project(rb => new { rb.Center, rb.Batteries }).ToList();

            sheet.SetValue(1, 1, "مرکز");
            for (int i = 0; i < data.Max(d => d.Batteries.Count); i++)
            {
                sheet.SetValue(1, i * 6 + 2, (i + 1) + ". مدل");
                sheet.SetValue(1, i * 6 + 3, (i + 1) + ". ظرفیت");
                sheet.SetValue(1, i * 6 + 4, (i + 1) + ". نوع");
                sheet.SetValue(1, i * 6 + 5, (i + 1) + ". تعداد سلول ها");
                sheet.SetValue(1, i * 6 + 6, (i + 1) + ". تاریخ تولید");
                sheet.SetValue(1, i * 6 + 7, (i + 1) + ". تاریخ نصب");
            }
            for (int row = 0; row < data.Count; row++)
            {
                if (centerNames.ContainsKey(data[row].Center))
                {
                    sheet.SetValue(row + 2, 1, centerNames[data[row].Center]);
                }
                for (int i = 0; i < data[row].Batteries.Count; i++)
                {
                    sheet.SetValue(row + 2, i * 6 + 2, data[row].Batteries[i].Model);
                    sheet.SetValue(row + 2, i * 6 + 3, data[row].Batteries[i].Capacity);
                    sheet.SetValue(row + 2, i * 6 + 4, data[row].Batteries[i].Type);
                    sheet.SetValue(row + 2, i * 6 + 5, (int)data[row].Batteries[i].CellsCount);
                    sheet.SetValue(row + 2, i * 6 + 6, PersianDateUtils.GetPersianDateString(data[row].Batteries[i].ProductionDate));
                    sheet.SetValue(row + 2, i * 6 + 7, PersianDateUtils.GetPersianDateString(data[row].Batteries[i].InstallationDate));
                }
            }
        }
Esempio n. 2
0
        private void AddSheetForProvinceData <T>(IReadOnlyDbContext db, ExcelPackage pkg, Dictionary <string, string> centerNames, params string[] excludes) where T : Equipment
        {
            var sheet = pkg.Workbook.Worksheets.Add(typeof(T).Name);
            var table = CreateDataTable(db.Find <T>(t => t.Deleted != true).ToEnumerable(), centerNames, excludes);

            sheet.Cells["A1"].LoadFromDataTable(table, true);
        }
Esempio n. 3
0
 public static AuthUserX GetByUsername(IReadOnlyDbContext db, string username)
 {
     return(db.Find <AuthUserX>(u => u.Username == username).FirstOrDefault());
 }