Esempio n. 1
0
        void view_ExecutingCommand(object sender, ExecutingCommandEventArgs e)
        {
            if (e.CommandName.ToLower() == "dokument" || e.CommandName.ToLower() == "sprawa" || e.CommandName.ToLower() == "faktura")
            {
                /*XPathDocument xpd = new XPathDocument(new StringReader(assignedItems));
                 * XPathNavigator xpn = xpd.CreateNavigator();
                 * XPathNodeIterator xpni = xpn.Select(string.Format("/zadania/zadanie[id='{0}']", e.CommandArgument));
                 * if (xpni.MoveNext())
                 *  session["context"] = xpni.Current.OuterXml;*/
                if (e.CommandName.ToLower() == "dokument" || e.CommandName.ToLower() == "faktura")
                {
                    session.Remove("idSprawy");
                    //session["idDokumentu"] = e.CommandArgument.ToString();
                }
                if (e.CommandName.ToLower() == "sprawa")
                {
                    session.Remove("idDokumentu");
                    //session["idSprawy"] = e.CommandArgument.ToString();
                }
                string cmdName = e.CommandName;
                if (e.CommandName.ToLower() == "faktura")
                {
                    cmdName = "Dokument";
                }

                view.TargetView = string.Format("{1}/{0}.aspx?id={2}", cmdName, cmdName == "Sprawa" ? "Sprawy" : "Dokumenty", e.CommandArgument.ToString());
            }
            if (e.CommandName.ToLower() == "dokument_s")
            {
                view.TargetView = string.Format("{1}/{0}.aspx?id={2}", "SkladnikiDokumentu", "Dokumenty", e.CommandArgument.ToString());
            }
        }
 public override void Initialize()
 {
     session.Remove("RedirectListItem");
     view.OrganizationalUnits = service.GetOrganizationalUnits();
     view.Employees           = service.GetEmployees(view.OrganizationalUnitId);
     view.RedirectList        = itemList;
 }
Esempio n. 3
0
        public override void Initialize()
        {
            session.Remove("isRF");
            ((IView)view).ViewTitle = "Edycja pozycji dziennika kancelaryjnego";
            if (session["itemIdRequest"] != null)
            {
                session["registryId"] = session["itemIdRequest"];

                if (session["itemRFRequest"] != null)
                {
                    session["itemId"] = service.AcquireItemID(registryId, ((IView)view).UserID, view.UserName, view.UserFullName, true);
                    session.Remove("itemRFRequest");
                    session["isRF"] = true;
                }
                else
                {
                    session["itemId"] = service.AcquireItemID(registryId, ((IView)view).UserID, view.UserName, view.UserFullName, false);
                }
            }
            view.IsInvoice = IsInvoice;
            if (itemId == 0 || registryId == 0)
            {
                //(view as IView).ErrorMessage = "Nieprawid³owe wywo³anie strony!";
                throw new ArgumentException("Nieprawid³owe wywo³anie strony!");
            }



            if (session["itemIdRequest"] != null)
            {
                view.IsInInsertState = true;
                view.ItemID          = itemId;
                getItemData();
                getDictionaries(false);
                session.Remove("itemIdRequest");
            }
            else
            {
                view.IsInEditState = true;
                view.ItemID        = itemId;
                getItemData();
                getDictionaries(true);
            }

            view.IsDailyLogItemAccessDenied = service.IsGetDailyLogItemAccessDenied(registryId, itemId, ((IView)view).UserID);
        }
Esempio n. 4
0
        public override void Initialize()
        {
            session.Remove("{BB59DB5B-4DDD-4436-87FD-ABEB282D4BE1}");
            getCurrentRegistryItem();
            view.ScanListItems      = service.GetItemsScans(itemId, registryId, view.IsInvoice);
            view.ItemID             = itemId;
            ((IView)view).ViewTitle = "Skany skojarzone z pozycj¹ dziennika kancelaryjnego";

            view.IsDailyLogItemAccessDenied = service.IsGetDailyLogItemAccessDenied(registryId, itemId, ((IView)view).UserID);
        }
        public async Task DehydrateSession()
        {
            // exclude our esssential session variable else we may lose our session
            var essentialSessionVariables = new List <string>()
            {
                SessionConstants.SessionEntity,
                SessionConstants.SessionLogId,
                SessionConstants.IsDebug
            };

            var classToSearch = typeof(SessionConstants);
            var sessionKeys   = classToSearch.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)
                                .Where(fi => fi.IsLiteral && !fi.IsInitOnly &&
                                       !essentialSessionVariables.Contains(fi.Name)).ToList();

            foreach (var key in sessionKeys)
            {
                await _sessionProvider.Remove((string)key.GetRawConstantValue());
            }
        }
Esempio n. 6
0
 public void Clear()
 {
     sessionProvider.Remove(CartContentKey);
 }
 public void Logout()
 {
     _sessionProvider.Remove(SessionConstants.SessionEntity).Wait();
     _httpContextAccessor.HttpContext.SignOutAsync().Wait();
 }
        public async Task <GetSessionResponse> GetSession()
        {
            var response = new GetSessionResponse();

            // get or create a new session
            var session = await _sessionProvider.Get <SessionEntity>(SessionConstants.SessionEntity);

            if (session == null)
            {
                // flush any authenticated cookies in the event the application restarts
                await _httpContextAccessor.HttpContext.SignOutAsync();

                await _sessionProvider.Remove(SessionConstants.User);

                using (var uow = _uowFactory.GetUnitOfWork())
                {
                    session = await uow.SessionRepo.CreateSession(new Infrastructure.Repositories.SessionRepo.Models.CreateSessionRequest()
                    {
                        Created_By = ApplicationConstants.SystemUserId
                    });

                    uow.Commit();

                    await _sessionProvider.Set(SessionConstants.SessionEntity, session);
                }
            }
            response.Id           = session.Id;
            response.SessionLogId = await _sessionProvider.Get <int>(SessionConstants.SessionLogId);

            // get or hydrate user from session
            var user = await _sessionProvider.Get <User>(SessionConstants.User);

            if (user == null &&
                session.User_Id.HasValue)
            {
                using (var uow = _uowFactory.GetUnitOfWork())
                {
                    user        = new User();
                    user.Entity = await uow.UserRepo.GetUserById(new Infrastructure.Repositories.UserRepo.Models.GetUserByIdRequest()
                    {
                        Id = session.User_Id.Value
                    });

                    uow.Commit();

                    var usersRoles = await _cache.UserRoles();

                    var userRoleIds = usersRoles.Where(ur => ur.User_Id == user.Entity.Id).Select(ur => ur.Role_Id);

                    var rolePermissions = await _cache.RolePermissions();

                    var userRolePermissionIds = rolePermissions.Where(rc => userRoleIds.Contains(rc.Role_Id)).Select(rc => rc.Permission_Id);

                    var permissionsLookup = await _cache.Permissions();

                    var userPermissionsData = permissionsLookup.Where(c => userRolePermissionIds.Contains(c.Id));

                    var rolesLookup = await _cache.Roles();

                    var userRolesData = rolesLookup.Where(r => userRoleIds.Contains(r.Id));

                    foreach (var userPermission in userPermissionsData)
                    {
                        user.PermissionKeys.Add(userPermission.Key);
                    }

                    foreach (var userRole in userRolesData)
                    {
                        user.RoleIds.Add(userRole.Id);
                    }

                    await _sessionProvider.Set(SessionConstants.User, user);
                }
            }
            response.User = user;

            return(response);
        }