Exemplo n.º 1
0
 public SQLFileAccessOperations(string connectionString, string tableName, SQLFileAccessInfo rule, int rootNodeId = 1)
 {
     connectionStr = connectionString;
     AccessRules   = rule;
     TableName     = tableName;
     RootNode      = rootNodeId;
     Connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings[connectionString].ConnectionString;
     Connection.Open();
     operation = new SQLFileExplorerOperations(connectionString, tableName);
 }
Exemplo n.º 2
0
        public SQLFileAccessInfo SQLGetRules()
        {
            SQLFileAccessInfo rules            = new SQLFileAccessInfo();
            SqlDataReader     myReader         = null;
            string            connectionString = "FileExplorerConnection";
            SqlConnection     Connection       = new SqlConnection();

            Connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings[connectionString].ConnectionString;
            Connection.Open();
            SqlCommand myCommand = new SqlCommand("select * from Permission", Connection);

            myReader = myCommand.ExecuteReader();
            List <SQLAccessRule> datas = new List <SQLAccessRule>();

            while (myReader.Read())
            {
                SQLAccessRule data = new SQLAccessRule();
                data.Copy = (Permission)Enum.Parse(typeof(Permission), myReader["Copy"].ToString(), true);
                if (!string.IsNullOrEmpty(myReader["Download"].ToString()))
                {
                    data.Download = (Permission)Enum.Parse(typeof(Permission), myReader["Download"].ToString(), true);
                }
                data.Edit = (Permission)Enum.Parse(typeof(Permission), myReader["Edit"].ToString(), true);
                data.Read = (Permission)Enum.Parse(typeof(Permission), myReader["Read"].ToString(), true);
                if (!string.IsNullOrEmpty(myReader["EditContents"].ToString()))
                {
                    data.EditContents = (Permission)Enum.Parse(typeof(Permission), myReader["EditContents"].ToString(), true);
                }
                if (!string.IsNullOrEmpty(myReader["Upload"].ToString()))
                {
                    data.Upload = (Permission)Enum.Parse(typeof(Permission), myReader["Upload"].ToString(), true);
                }
                data.Path = myReader["Path"].ToString();
                data.Role = myReader["Role"].ToString();
                datas.Add(data);
            }
            rules.Rules = datas;
            rules.Role  = Session["Role"].ToString();
            if (isLocal)
            {
                rules.RootPath = "~/localFolder/";
            }
            else
            {
                rules.RootPath = "~/Products/";
            }
            return(rules);
        }