Exemplo n.º 1
0
        public override void Configure(IConfigSectionNode config)
        {
            base.Configure(config);

            if (config == null || !config.Exists)
            {
                return;
            }

            //Make File System
            var fsNode = config[CONFIG_CONTENT_FS_SECTION];

            var fs = FactoryUtils.MakeAndConfigure <FileSystem>(fsNode,
                                                                typeof(NFX.IO.FileSystem.Local.LocalFileSystem),
                                                                args: new object[] { GetType().Name, fsNode });
            var fsPNode = fsNode[CONFIG_FS_CONNECT_PARAMS_SECTION];

            FileSystemSessionConnectParams fsc;

            if (fsPNode.Exists)
            {
                fsc = FileSystemSessionConnectParams.Make <FileSystemSessionConnectParams>(fsPNode);
            }
            else
            {
                fsc = new FileSystemSessionConnectParams()
                {
                    User = NFX.Security.User.Fake
                };
            }

            var fsp = fsNode.AttrByName(CONFIG_FS_ROOT_PATH_ATTR).Value;

            BindFS(fs, fsc, fsp);
        }
Exemplo n.º 2
0
 public void BindFS(FileSystem fs, FileSystemSessionConnectParams fsConnectParams, string fsRootPath)
 {
     lock (m_FSLock)
     {
         m_FS = fs;
         m_FSConnectParams = fsConnectParams;
         m_FSRootPath      = fsRootPath;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Override to perform custom configuration
        /// </summary>
        protected virtual void DoConfigure(IConfigSectionNode node)
        {
            if (node == null)
            {
                return;
            }
            var sessionSection = node[CONFIG_DEFAULT_SESSION_CONNECT_PARAMS_SECTION];

            m_DefaultSessionConnectParams = MakeSessionConfigParams(sessionSection);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Override to perform custom configuration
        /// </summary>
        protected virtual void DoConfigure(IConfigSectionNode node)
        {
            if (node != null)
            {
                var sessionSection = node[CONFIG_DEFAULT_SESSION_CONNECT_PARAMS_SECTION];
                m_DefaultSessionConnectParams = MakeSessionConfigParams(sessionSection);
            }

            ConfigAttribute.Apply(this, node);
        }
Exemplo n.º 5
0
 public DeleteFilesJob(
     IEventTimer timer,
     string name               = null,
     TimeSpan?interval         = null,
     IConfigSectionNode config = null,
     FileSystem fs             = null,
     FileSystemSessionConnectParams fsConnectParams = null,
     string fsRootPath = null
     ) : base(timer, name, null, interval, config, EventBodyAsyncModel.LongRunningAsyncTask)
 {
     if (fs != null)
     {
         m_FS = fs;
     }
     if (fsConnectParams != null)
     {
         m_FSConnectParams = fsConnectParams;
     }
     if (fsRootPath.IsNotNullOrWhiteSpace())
     {
         m_FSRootPath = fsRootPath;
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Creates a new session for the user. This method is thread-safe, however the returned FileSystemSession object is not.
 /// Every thread must obtain its own session via this method
 /// </summary>
 public abstract FileSystemSession StartSession(FileSystemSessionConnectParams cParams = null);
Exemplo n.º 7
0
        /// <summary>
        /// Starts new file system session
        /// </summary>
        protected internal FileSystemSession(FileSystem fs, IFileSystemHandle handle, FileSystemSessionConnectParams cParams)
        {
            if (fs == null || cParams == null)
            {
                throw new NFXIOException(StringConsts.FS_SESSION_BAD_PARAMS_ERROR.Args(GetType().FullName));
            }

            ValidateConnectParams(cParams);


            m_FileSystem = fs;
            m_Handle     = handle;
            m_User       = cParams.User ?? User.Fake;
            m_Items      = new List <FileSystemSessionItem>();
            var name = cParams.Name;

            m_Name = name.IsNullOrWhiteSpace() ? "{0}.{1}".Args(m_User.Name, Guid.NewGuid()) : name;

            lock (m_FileSystem.m_Sessions)
                m_FileSystem.m_Sessions.Add(this);
        }
Exemplo n.º 8
0
 protected virtual void ValidateConnectParams(FileSystemSessionConnectParams cParams)
 {
 }