Exemple #1
0
        public ActionResult Index()
        {
            var model = new HomePageModel();

            model.CanEdit   = CtsAuthorizeProvider.CanEditUser(User.Identity);
            model.CanDelete = CtsAuthorizeProvider.CanDeleteUser(User.Identity);
            model.Locations = EquipmentProvider.GetUserLocations(db, User.Identity);

            @ViewBag.Title = "Главная страница";
            return(View(model));
        }
        public static bool UserHasAnyReportRole(IIdentity user)
        {
            if (Cacher.Instance.TryRead(user.Name + "CheckUserReportRole") is bool)
            {
                return((bool)Cacher.Instance.TryRead(user.Name + "CheckUserReportRole"));
            }

            var userHasReportRole = CtsAuthorizeProvider.CheckIsInRole(user, GetReprtRoles());

            Cacher.Instance.Write(user.Name + "CheckUserReportRole", userHasReportRole);
            return(userHasReportRole);
        }
        public static bool UserHasLocationRole(IIdentity user, string locationID)
        {
            var cacheKey = user.Name + "UserHasLocationRole" + locationID;

            if (Cacher.Instance.TryRead(cacheKey) is bool)
            {
                return((bool)Cacher.Instance.TryRead(cacheKey));
            }

            var cdb = new CtsDbContext();
            var userHasLocationRole = CtsAuthorizeProvider.CheckIsInRole(user, cdb.Locations.Find(locationID).LocationName);

            Cacher.Instance.Write(cacheKey, userHasLocationRole);
            return(userHasLocationRole);
        }
        public ActionResult Index(int page = 1)
        {
            string userName       = User.Identity.Name ?? "";
            int    pagesize       = 20;
            var    locations      = EquipmentProvider.GetUserLocations(_cdb, User.Identity);
            var    locationsArray = locations.Select(x => x.ID).ToArray();
            var    analysis       = _cdb.MiningAnalyzes.Where(t => locationsArray.Contains(t.LocationID)).Where(v => v.IsValid).ToList();

            @ViewBag.Title = "Анализы по добыче";

            return(View(new MiningAnalysisView
            {
                Locations = locations,
                MiningAnalysis = analysis.OrderByDescending(t => t.AnalysisTimeStamp).ToPagedList(page, pagesize),
                CanEdit = CtsAuthorizeProvider.CanEditUser(User.Identity),
                CanDelete = CtsAuthorizeProvider.CanDeleteUser(User.Identity)
            }));
        }
        public ActionResult Index(int page = 1)
        {
            string userName = User.Identity.Name ?? "";
            int    pagesize = 20;

            var beltScales      = EquipmentProvider.GetUserAuthorizedEquipment <BeltScale>(_cdb, User.Identity);
            var beltScalesArray = beltScales.Select(x => x.ID).ToArray();
            var transfers       = _cdb.InternalTransfers.Where(t => beltScalesArray.Contains((int)t.EquipID))
                                  .Where(v => v.IsValid).Where(d => d.TransferTimeStamp >= DbFunctions.AddDays(System.DateTime.Now, -2));

            @ViewBag.Title = "Анализы для конвейерных весов";

            return(View(new BeltTransfersView
            {
                BeltTransfers = transfers.OrderByDescending(t => t.TransferTimeStamp).ToPagedList(page, pagesize),
                CanEdit = CtsAuthorizeProvider.CanEditUser(User.Identity),
                CanDelete = CtsAuthorizeProvider.CanDeleteUser(User.Identity)
            }));
        }
Exemple #6
0
        public static List <Item> GetItems(CtsDbContext cdb, IIdentity user)
        {
            var userLogin = user.Name.Split(new char[] { '\\' }).Last();
            var domain    = user.Name.Split(new char[] { '\\' }).First();

            if (!(Cacher.Instance.TryRead(domain + userLogin + "Items") is List <Item> items))
            {
                items = new List <Item>();
                var groups = CtsAuthorizeProvider.GetUserRolesFromDb(user).Select(x => x.RoleName).ToArray();
                items.AddRange(cdb.Items.Where(n => groups.Contains(n.Location.DomainName)).ToList());

                if (items.Count > 0)
                {
                    Cacher.Instance.Write(domain + userLogin + "Items", items);
                }
            }

            return(items);
        }
        public ActionResult Index(int page = 1)
        {
            string userName = User.Identity.Name ?? "";
            int    pagesize = 20;

            var wagonScales      = EquipmentProvider.GetUserAuthorizedEquipment <WagonScale>(_cdb, User.Identity);
            var wagonScalesArray = wagonScales.Select(x => x.ID).ToArray();
            var transfers        = _cdb.WagonTransfers.Where(t => wagonScalesArray.Contains((int)t.EquipID))
                                   .Where(d => d.TransferTimeStamp >= DbFunctions.AddDays(System.DateTime.Now, -2));

            @ViewBag.Title = "Данные вагонных весов";

            return(View(new WagonScales_Transfers
            {
                WagonScales = wagonScales,
                Transfers = transfers.OrderByDescending(t => t.TransferTimeStamp).ToPagedList(page, pagesize),
                CanEdit = CtsAuthorizeProvider.CanEditUser(User.Identity),
                CanDelete = CtsAuthorizeProvider.CanDeleteUser(User.Identity)
            }));
        }
        public ActionResult Index(int page = 1)
        {
            string userName = User.Identity.Name ?? "";
            int    pagesize = 20;

            var rockUtils      = EquipmentProvider.GetUserAuthorizedEquipment <RockUtil>(_cdb, User.Identity);
            var rockUtilsArray = rockUtils.Select(x => x.ID).ToArray();
            var transfers      = _cdb.RockUtilTransfers.Where(t => rockUtilsArray.Contains((int)t.EquipID))
                                 .Where(d => d.TransferTimeStamp >= DbFunctions.AddDays(System.DateTime.Now, -2));

            @ViewBag.Title = "Данные утилизации породы";

            return(View(new RockUtil_Transfer
            {
                RockUtils = rockUtils,
                RockUtilTranfers = transfers.OrderByDescending(t => t.TransferTimeStamp).ToPagedList(page, pagesize),
                CanEdit = CtsAuthorizeProvider.CanEditUser(User.Identity),
                CanDelete = CtsAuthorizeProvider.CanDeleteUser(User.Identity)
            }));
        }
        public ActionResult Index(int page = 1)
        {
            string userName = User.Identity.Name ?? "";
            int    pagesize = 20;

            var wagonScales      = EquipmentProvider.GetUserAuthorizedEquipment <WagonScale>(_cdb, User.Identity);
            var wagonScalesArray = wagonScales.Select(x => x.ID).ToArray();
            var transfers        = _cdb.WagonTransfers.Where(t => wagonScalesArray.Contains((int)t.EquipID))
                                   .Where(v => v.IsValid).Where(d => d.TransferTimeStamp >= DbFunctions.AddDays(System.DateTime.Now, -2));

            transfers.OrderByDescending(o => o.TransferTimeStamp);
            var groups = transfers.GroupBy(l => l.LotName).ToList();
            List <WagonBatch> batches = new List <WagonBatch>();

            foreach (var g in groups)
            {
                WagonBatch batch = new WagonBatch();
                float      netto = transfers.Where(b => b.LotName == g.Key.ToString()).Sum(s => s.Brutto) - transfers.Where(b => b.LotName == g.Key.ToString()).Sum(s => s.Tare);

                batch.LotName           = g.Key.ToString();
                batch.TransferTimeStamp = g.First().TransferTimeStamp;
                batch.WagonQuantity     = g.Count();
                batch.FromDest          = g.First().FromDest.LocationName;
                batch.ToDest            = g.First().ToDest;
                batch.Item            = g.First().Item.Name;
                batch.Netto           = netto;
                batch.WagonAnalysisID = g.First().AnalysisID;
                batch.WagonAnalysis   = g.First().Analysis;

                batches.Add(batch);
            }

            @ViewBag.Title = "Анализы для вагонных весов";

            return(View(new WagonBatchView
            {
                WagonBatches = batches.ToPagedList(page, pagesize),
                CanEdit = CtsAuthorizeProvider.CanEditUser(User.Identity),
                CanDelete = CtsAuthorizeProvider.CanDeleteUser(User.Identity)
            }));
        }
        public ActionResult Index(int page = 1)
        {
            string userName = User.Identity.Name ?? "";
            int    pagesize = 20;

            var skips      = EquipmentProvider.GetUserAuthorizedEquipment <Skip>(_cdb, User.Identity);
            var skipsArray = skips.Select(x => x.ID).ToArray();
            var transfers  = _cdb.SkipTransfers.Where(t => skipsArray.Contains((int)t.EquipID))
                             .Where(d => d.TransferTimeStamp >= DbFunctions.AddDays(System.DateTime.Now, -2));

            @ViewBag.Title = "Данные скиповых подъемов";

            return(View(new SkipsAndTransfersModel
            {
                Skips = skips,
                SkipTransfers = transfers.OrderByDescending(t => t.TransferTimeStamp).ToPagedList(page, pagesize),
                Counters = new Dictionary <string, string>(),
                CanEdit = CtsAuthorizeProvider.CanEditUser(User.Identity),
                CanDelete = CtsAuthorizeProvider.CanDeleteUser(User.Identity)
            }));
        }
Exemple #11
0
        public static List <Location> GetUserLocations(CtsDbContext cdb, IIdentity user)
        {
            var userLogin = user.Name.Split(new char[] { '\\' }).Last();
            var domain    = user.Name.Split(new char[] { '\\' }).First();

            if (!(Cacher.Instance.TryRead(domain + userLogin + "Locations") is List <Location> locations))
            {
                locations = new List <Location>();
#if DEBUG
                return(cdb.Locations.ToList());
#endif
                var groups = CtsAuthorizeProvider.GetUserRolesFromDb(user).Select(x => x.RoleName).ToArray();
                locations.AddRange(cdb.Locations.Where(n => groups.Contains(n.LocationName)).ToList());
                if (locations.Count > 0)
                {
                    Cacher.Instance.Write(domain + userLogin + "Locations", locations);
                }
            }

            return(locations);
        }