Exemplo n.º 1
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);
        }
Exemplo n.º 2
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));
                }
            }
        }
Exemplo n.º 3
0
        public string GetPlaceDisplayName(IReadOnlyDbContext db)
        {
            var passive = db.FindById <Passive>(PatchPanel);
            var rack    = db.FindById <Rack>(passive.Place);
            var room    = db.FindById <Room>(rack.Parent);

            StringBuilder sb = new StringBuilder();

            sb.Append("اتاق/سالن ").Append(room.Name).Append(" &lArr; ")
            .Append("راک ").Append(rack.Name).Append(" &lArr; ");
            if (passive.Type == Passive.PassiveTypeEnum.PatchPanel)
            {
                sb.Append("پچ پنل ");
            }
            else if (passive.Type == Passive.PassiveTypeEnum.Transmissional)
            {
                sb.Append("تجهیز انتقال ")
                .Append(DisplayUtils.DisplayName(passive.TransmissionType))
                .Append(" ");
            }
            else
            {
                throw new NotImplementedException();
            }
            sb.Append(passive.Name);

            return(sb.ToString());
        }
Exemplo n.º 4
0
 public static AuthUser GetCurrentUser(this IReadOnlyDbContext db)
 {
     if (HttpContext.Current == null || HttpContext.Current.User == null || HttpContext.Current.User.Identity == null || string.IsNullOrEmpty(HttpContext.Current.User.Identity.Name))
     {
         return(null);
     }
     return(AuthUserDBExtention.GetUserByUsername(db, HttpContext.Current.User.Identity.Name));
 }
Exemplo n.º 5
0
 public string GetCenterId(IReadOnlyDbContext db)
 {
     if (PlaceType == DevicePlaceType.Rack)
     {
         var rack     = db.FindById <Rack>(Place);
         var room     = db.FindById <Room>(rack.Parent);
         var building = db.FindById <Building>(room.Parent);
         return(building.Parent);
     }
     else if (PlaceType == DevicePlaceType.Kafu)
     {
         var kafu = db.FindById <Kafu>(Place);
         return(kafu.CommCenter);
     }
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
        public string GetPlaceDisplay(IReadOnlyDbContext db)
        {
            StringBuilder sb = new StringBuilder();

            if (PlaceType == DevicePlaceType.Rack)
            {
                var rack     = db.FindById <Rack>(Place);
                var room     = db.FindById <Room>(rack.Parent);
                var building = db.FindById <Building>(room.Parent);
                var center   = db.FindById <CommCenter>(building.Parent);
                var city     = db.FindById <City>(center.City);

                sb.Append(city.Name).Append(" &lArr; ")
                .Append("مرکز ").Append(center.Name).Append(" &lArr; ")
                .Append("ساختمان ").Append(building.Name).Append(" &lArr; ")
                .Append("اتاق/سالن ").Append(room.Name).Append(" &lArr; ")
                .Append("راک ").Append(rack.Name).Append(" &lArr; ")
                .Append("دستگاه ").Append(ToString());
            }
            else if (PlaceType == DevicePlaceType.Kafu)
            {
                var kafu   = db.FindById <Kafu>(Place);
                var center = db.FindById <CommCenter>(kafu.CommCenter);
                var city   = db.FindById <City>(center.City);

                sb.Append(city.Name).Append(" &lArr; ")
                .Append("مرکز ").Append(center.Name).Append(" &lArr; ")
                .Append("کافو ").Append(DisplayUtils.DisplayName(kafu.Type))
                .Append(" \"").Append(kafu.Name).Append("\"");
            }
            else
            {
                throw new NotImplementedException();
            }

            return(sb.ToString());
        }
 public ReadOnlyOrderService(IReadOnlyDbContext dbContext, IMapper mapper)
     : base(dbContext, mapper)
 {
 }
Exemplo n.º 8
0
 protected ReadOnlyEntityService(IReadOnlyDbContext dbContext, IMapper mapper)
 {
     DbContext = dbContext;
     _mapper   = mapper;
 }
 protected GetEntityByIdQueryHandler(IReadOnlyDbContext dbContext, IMapper mapper)
 {
     _dbContext = dbContext;
     _mapper    = mapper;
 }
Exemplo n.º 10
0
 public GetOrderResultByIdQueryHandler(IReadOnlyDbContext dbContext, IMapper mapper)
 {
     _dbContext = dbContext;
     _mapper    = mapper;
 }
Exemplo n.º 11
0
 public static AuthUserX GetByUsername(IReadOnlyDbContext db, string username)
 {
     return(db.Find <AuthUserX>(u => u.Username == username).FirstOrDefault());
 }
Exemplo n.º 12
0
 public GetOrderByIdQueryHandler(IReadOnlyDbContext dbContext, IMapper mapper) : base(dbContext, mapper)
 {
 }
Exemplo n.º 13
0
 protected DataTableFactory(IReadOnlyDbContext db, Type thisType)
 {
     this.db       = db;
     this.thisType = thisType;
 }
Exemplo n.º 14
0
 public DataTableFactory(IReadOnlyDbContext db)
 {
     this.db  = db;
     thisType = typeof(DataTableFactory);
 }
Exemplo n.º 15
0
        public static City GetMainCity(IReadOnlyDbContext db)
        {
            var mainCitySettings = db.FindFirst <Settings>(s => s.Key == "MainCity");

            return(db.FindById <City>(mainCitySettings.Value));
        }
Exemplo n.º 16
0
 public Handler(IReadOnlyDbContext dbContext, IMapper mapper)
 {
     this.dbContext = dbContext;
     this.mapper    = mapper;
 }
Exemplo n.º 17
0
 public DataTable Create <T>(IReadOnlyDbContext db, bool convertDateToPersian = true, bool includeTimeInDates = true, bool addIndexColumn = false,
                             string[] excludeColumns = null, Dictionary <string, Dictionary <ObjectId, string> > valuesReferenceReplacement = null) where T : MongoEntity
 {
     return(Create(db.All <T>(), convertDateToPersian, includeTimeInDates, addIndexColumn, excludeColumns, valuesReferenceReplacement));
 }
 public ReadOnlyProductService(IReadOnlyDbContext dbContext, IMapper mapper)
     : base(dbContext, mapper)
 {
 }
Exemplo n.º 19
0
 public static AuthUserX FindByUsername(this IReadOnlyDbContext db, string username)
 {
     return(db.FindFirst <AuthUserX>(u => u.Username == username));
 }
Exemplo n.º 20
0
        public string GetPlaceDisplay(IReadOnlyDbContext db)
        {
            var device = db.FindById <Device>(Device);

            return(device.GetPlaceDisplay(db));
        }
Exemplo n.º 21
0
 public string GetPlaceDisplay(IReadOnlyDbContext db)
 {
     return(Mapper.Map <Passive>(this).GetPlaceDisplay(db));
 }
Exemplo n.º 22
0
 public ReadOnlyEntityService(IReadOnlyDbContext dbContext, IMapper mapper)
 {
     _dbContext = dbContext;
     _mapper    = mapper;
 }