Пример #1
0
        public ActionResult Index()
        {
            var folderPath  = "~/UserRecords";
            var appSettings = _appSettingService.Queryable().ToList();

            if (!appSettings.Any())
            {
                var settingsPath = Server.MapPath(folderPath);
                var newAppSeting = new AppSetting {
                    Id = EntityIdGenerator.GenerateEntityId(), BiometricTemplatePath = folderPath
                };
                if (!Directory.Exists(settingsPath))
                {
                    Directory.CreateDirectory(settingsPath);
                    var dInfo     = new DirectoryInfo(settingsPath);
                    var dSecurity = dInfo.GetAccessControl();
                    dSecurity.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.NoPropagateInherit, AccessControlType.Allow));
                    dInfo.SetAccessControl(dSecurity);
                }

                _appSettingService.Insert(newAppSeting);
                _unitOfWork.SaveChanges();
            }

            var projects = _projectService.Queryable().ToList();

            if (!projects.Any())
            {
                return(RedirectToAction("SiteActivation", "SiteActivator"));
            }

            var sessionProject = GetProjectInSession();

            if (sessionProject == null)
            {
                return(RedirectToAction("ProjectOptions", "Home"));
            }

            if (string.IsNullOrEmpty(sessionProject.ProjectCode))
            {
                return(RedirectToAction("ProjectOptions", "Home"));
            }
            var project = projects.Where(p => p.ProjectCode == sessionProject.ProjectCode).ToList()[0];

            if (string.IsNullOrEmpty(project?.ProjectCode))
            {
                return(RedirectToAction("ProjectOptions", "Home"));
            }

            if (project.LicenseExpiryDate < DateTime.Today)
            {
                Session["siteStatus"] = "expired";
                return(RedirectToAction("SiteActivation", "SiteActivator", new RouteValueDictionary(new KeyValuePair <string, string>("ProjectExpired", "true"))));
            }

            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }

            return(View());
        }