예제 #1
0
        /// <summary>
        /// Check is user has permission to invoke action on an application
        /// </summary>
        /// <param name="user"></param>
        /// <param name="action"></param>
        /// <param name="settings"></param>
        /// <returns></returns>
        public static bool Check(SystemUser user, ActionType action, Settings settings) {

            // TODO: check action type
            if (user == null) {
                //TODO: an anonymouse user can have access to some functions
                return false;
            }

            return false;
        }
예제 #2
0
        /// <summary>
        /// Prepare and check env
        /// </summary>
        static void PrepareEnv() {

            // Assure admin has admin rights
            Utils.AssureAdminSystemUserGroupAndPermissions();

            // Assure Settings
            Settings settings = Settings.GetSettings();
            if (settings == null) {
                Db.Transact(() => {
                    settings = new Settings();
                    settings.SetDefault();
                });
            }


            // TODO: Add hardcoded host services, Make gui in settings
            HostService hostService = Db.SQL<HostService>("SELECT o FROM Warehouse.HostService o").First;
            if(hostService == null) {
                Db.Transact(() => {
                    new HostService() { DomainName = "starcounter.host", Port = 8080 };
                    new HostService() { DomainName = "cooltech.net", Port = 8080 };
                });
            }

            if (!string.IsNullOrEmpty(settings.PublicFolder)) {
                if (!Directory.Exists(settings.PublicFolder)) {
                    Directory.CreateDirectory(settings.PublicFolder);
                }
                Starcounter.Internal.AppsBootstrapper.AddStaticFileDirectory(settings.PublicFolder);
            }

            // Prepare default images
            // TODO:If PublicFolder changes this code below also need to be executed 
            try {
                string destinationFolder = Path.Combine(settings.PublicFolder, "warehouse\\images");
                if (!Directory.Exists(destinationFolder)) {
                    Directory.CreateDirectory(destinationFolder);
                }

                string sourceFolder = Directory.GetParent(Application.Current.FilePath).FullName;
                File.Copy(Path.Combine(sourceFolder, "app.svg"), Path.Combine(destinationFolder, Path.GetFileName("app.svg")), true);
                File.Copy(Path.Combine(sourceFolder, "folder.svg"), Path.Combine(destinationFolder, Path.GetFileName("folder.svg")), true);
            }
            catch (Exception) { }
        }