예제 #1
0
        private bool IsValidRequest()
        {
            Thread.Sleep(2000);

            if (this.Context == null)
            {
                this.Clients.Caller.getNotification(I18N.AccessIsDenied);
                return(false);
            }

            string tenant  = AppUsers.GetTenant();
            long   loginId = HubAuthorizationManger.GetLoginIdAsync(tenant, this.Context).GetAwaiter().GetResult();
            var    meta    = AppUsers.GetCurrent(tenant, loginId);

            if (loginId <= 0)
            {
                this.Clients.Caller.getNotification(I18N.AccessIsDenied);
                return(false);
            }

            if (!meta.IsAdministrator)
            {
                return(false);
            }

            return(true);
        }
예제 #2
0
        public static string GetDashboardPath()
        {
            string tenant = AppUsers.GetTenant();
            string path   = HostingEnvironment.MapPath(Format(CultureInfo.InvariantCulture, Path, tenant));

            return(path != null && !System.IO.Directory.Exists(path) ? Empty : path);
        }
예제 #3
0
        public static string GetGoogleMapsJavascriptApi()
        {
            string tenant = AppUsers.GetTenant();
            var    google = Google.ConfigurationManager.Get(tenant);

            return(google.MapsJavascriptApiKey);
        }
예제 #4
0
 public static IEnumerable <Content> GetContents()
 {
     using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase())
     {
         return(db.FetchBy <Content>(sql => sql.Where(c => c.IsHomepage)));
     }
 }
예제 #5
0
파일: Menus.cs 프로젝트: Zero-Xiong/frapid
 public static IEnumerable <Menu> GetMenus()
 {
     using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase())
     {
         return(db.FetchBy <Menu>(sql => sql).OrderBy(x => x.Sort).ThenBy(x => x.MenuId));
     }
 }
예제 #6
0
        public static DTO.Reset GetIfActive(string token)
        {
            const string sql =
                "SELECT * FROM account.reset_requests WHERE request_id=@0::uuid AND expires_on >= NOW() AND NOT confirmed;";

            return(Factory.Get <DTO.Reset>(AppUsers.GetTenant(), sql, token).FirstOrDefault());
        }
예제 #7
0
 public static IEnumerable <Role> GetRoles()
 {
     using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase())
     {
         return(db.FetchBy <Role>(sql => sql).OrderByDescending(x => x.RoleId));
     }
 }
예제 #8
0
 public static DTO.Configuration GetDefaultConfiguration()
 {
     using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase())
     {
         return(db.FetchBy <DTO.Configuration>(sql => sql.Where(c => c.IsDefault)).FirstOrDefault());
     }
 }
예제 #9
0
 public static IEnumerable <PublishedContentView> GetAllPublishedContents()
 {
     using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase())
     {
         return(db.FetchBy <PublishedContentView>(sql => sql));
     }
 }
예제 #10
0
 public static IEnumerable <PublishedContentView> GetBlogContents(int limit, int offset)
 {
     using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase())
     {
         return(db.FetchBy <PublishedContentView>(sql => sql.Where(x => x.IsBlog)).Skip(offset).Take(limit));
     }
 }
예제 #11
0
 public static ConfigurationProfile GetActiveProfile()
 {
     using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase())
     {
         return(db.FetchBy <ConfigurationProfile>(sql => sql.Where(u => u.IsActive)).FirstOrDefault());
     }
 }
예제 #12
0
        public ActionResult Get(string resource = "")
        {
            if (string.IsNullOrWhiteSpace(resource))
            {
                return(this.HttpNotFound());
            }

            string directory = "~/Tenants/{0}/Areas/Frapid.Dashboard/Resources/";

            directory = string.Format(CultureInfo.InvariantCulture, directory, AppUsers.GetTenant());
            directory = HostingEnvironment.MapPath(directory);

            if (directory == null)
            {
                return(this.HttpNotFound());
            }

            string path = Path.Combine(directory, resource);

            if (!System.IO.File.Exists(path))
            {
                return(this.HttpNotFound());
            }

            string mimeType = MimeMapping.GetMimeMapping(path);

            return(this.File(path, mimeType));
        }
예제 #13
0
 public static int CountBlogContents()
 {
     using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase())
     {
         return(db.FetchBy <PublishedContentView>(sql => sql.Where(x => x.IsBlog)).Count);
     }
 }
예제 #14
0
        public static void SavePolicy(int officeId, int userId, List <AccessPolicyInfo> policies)
        {
            using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase())
            {
                db.BeginTransaction();

                var sql = new Sql();
                sql.Append("DELETE FROM auth.entity_access_policy");
                sql.Append("WHERE office_id = @0", officeId);
                sql.Append("AND user_id = @0", userId);

                db.Execute(sql);


                foreach (var policy in policies)
                {
                    dynamic poco = new ExpandoObject();
                    poco.entity_name    = policy.EntityName;
                    poco.office_id      = officeId;
                    poco.user_id        = userId;
                    poco.access_type_id = policy.AccessTypeId;
                    poco.allow_access   = policy.AllowAccess;

                    db.Insert("auth.entity_access_policy", "entity_access_policy_id", true, poco);
                }

                db.CompleteTransaction();
            }
        }
예제 #15
0
파일: Menus.cs 프로젝트: Zero-Xiong/frapid
 public static IEnumerable <MenuItemView> GetMenuItems(string menuName)
 {
     using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase())
     {
         return(db.FetchBy <MenuItemView>(sql => sql.Where(c => c.MenuName == menuName)).OrderBy(c => c.Sort));
     }
 }
예제 #16
0
 public static Contact GetContact(int contactId)
 {
     using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase())
     {
         return(db.FetchBy <Contact>(sql => sql.Where(c => c.ContactId.Equals(contactId))).FirstOrDefault());
     }
 }
예제 #17
0
        public static string GetOverridePath()
        {
            string tenant = AppUsers.GetTenant();
            string path   = HostingEnvironment.MapPath(string.Format(CultureInfo.InvariantCulture, Path, tenant));

            return(path != null && !Directory.Exists(path) ? string.Empty : path);
        }
예제 #18
0
 public static IEnumerable <User> GetUsers()
 {
     using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase())
     {
         return(db.FetchBy <User>(sql => sql.Where(x => x.Status)));
     }
 }
예제 #19
0
        public static string GetThemeDirectory()
        {
            string tenant = AppUsers.GetTenant();
            string path   = Path + "Themes";

            return(Format(CultureInfo.InvariantCulture, path, tenant));
        }
예제 #20
0
 public static User Get(string email)
 {
     using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase())
     {
         return(db.FetchBy <User>(sql => sql.Where(u => u.Email == email)).FirstOrDefault());
     }
 }
예제 #21
0
        public static LoginResult SignIn(string email, int officeId, string name, string token, string browser, string ipAddress,
                                         string culture)
        {
            string sql = FrapidDbServer.GetProcedureCommand("account.google_sign_in", new[] { "@0", "@1", "@2", "@3", "@4", "@5", "@6" });

            return(Factory.Get <LoginResult>(AppUsers.GetTenant(), sql, email, officeId, name, token, browser,
                                             ipAddress, culture.Or("en-US")).FirstOrDefault());
        }
예제 #22
0
        public static DTO.Reset Request(ResetInfo model)
        {
            string sql = FrapidDbServer.GetProcedureCommand("account.reset_account", new[] { "@0", "@1", "@2" });

            return
                (Factory.Get <DTO.Reset>(AppUsers.GetTenant(), sql, model.Email, model.Browser, model.IpAddress)
                 .FirstOrDefault());
        }
예제 #23
0
파일: Menus.cs 프로젝트: Zero-Xiong/frapid
 public static IEnumerable <MenuAccessPolicy> GetPolicy(int officeId, int userId)
 {
     using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase())
     {
         return(db.FetchBy <MenuAccessPolicy>
                    (sql => sql.Where(x => x.OfficeId.Equals(officeId) && x.UserId.Equals(userId))));
     }
 }
예제 #24
0
        public static string GetCurrentThemePath()
        {
            string tenant = AppUsers.GetTenant();
            string path   = Path + "Themes/{1}/";
            string theme  = GetDefaultTheme();

            return(Format(CultureInfo.InvariantCulture, path, tenant, theme));
        }
예제 #25
0
 public List <Filter> GetFilters(string database, string filterName)
 {
     using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase())
     {
         return(db.FetchBy <Filter>(sql => sql.Where(u => u.ObjectName.Equals(this.FullyQualifiedObjectName) &&
                                                     u.FilterName.ToUpperInvariant().Equals(filterName.ToUpperInvariant()))));
     }
 }
예제 #26
0
        public async Task <ActionResult> SendEmailAsync(ContactForm model)
        {
            model.Subject = "Contact Form : " + model.Subject;
            string tenant = AppUsers.GetTenant();

            await new ContactUsEmail().SendAsync(tenant, model);
            Thread.Sleep(1000);
            return(this.Json("OK"));
        }
예제 #27
0
        public static object Register(DTO.Registration registration)
        {
            registration.RegistrationId = Guid.NewGuid();
            registration.RegisteredOn   = DateTimeOffset.UtcNow;

            Factory.Insert(AppUsers.GetTenant(), registration, "account.registrations", "registration_id", false);

            return(registration.RegistrationId);
        }
예제 #28
0
 public static PublishedContentView GetDefault()
 {
     using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase())
     {
         return
             (db.FetchBy <PublishedContentView>(sql => sql.Where(c => c.IsHomepage).Limit(1))
              .FirstOrDefault());
     }
 }
예제 #29
0
 public static IEnumerable <Contact> GetContacts()
 {
     using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase())
     {
         return(db.FetchBy <Contact>(sql => sql.Where(c => c.Status))
                .OrderBy(c => c.Sort)
                .ThenBy(c => c.ContactId));
     }
 }
예제 #30
0
파일: Menus.cs 프로젝트: Zero-Xiong/frapid
 public static int[] GetGroupPolicy(int officeId, int roleId)
 {
     using (var db = DbProvider.Get(FrapidDbServer.GetConnectionString(AppUsers.GetTenant())).GetDatabase())
     {
         return(db.FetchBy <GroupMenuAccessPolicy>
                    (sql => sql.Where(x => x.OfficeId.Equals(officeId) && x.RoleId.Equals(roleId)))
                .Select(x => x.MenuId)
                .ToArray());
     }
 }