Exemplo n.º 1
0
        private object OnRemovePathFromProtection( object message )
        {
            var packet = ( RemovePathFromProtectionMessage )message;
            var ret = new OperationResult();

            if ( !this.CheckSession( packet.SessionKey ) )
            {
                ret.Value = false;
                return ret;
            }

            bool removeResult;

            bool result = DevIoCore.IoRemovePathFromProtection( packet.UniqueKey, out removeResult );

            if ( result && removeResult )
            {
                string path = this.GetPathByUniqueKey( packet.UniqueKey );

                if ( path != null )
                {
                    PathManager pathManager = new PathManager();
                    result = pathManager.DeletePath( path );
                }
                else
                {
                    ret.Value = false;
                    return ret;
                }
            }

            if ( result && removeResult )
            {
                result = this.paths.Remove( packet.UniqueKey );
            }

            ret.Value = result && removeResult;
            return ret;
        }
Exemplo n.º 2
0
        private bool ReloadPaths()
        {
            PathManager pathManager = new PathManager();

            var list = pathManager.GetAllPaths();

            bool result = DevIoCore.IoRemoveAllPathsFromProtection();

            this.paths.Clear();
            this.sessions.Clear();

            if ( result )
            {
                foreach ( var path in list )
                {
                    uint uniqueKey;

                    result = this.SafeAddPathForProtection( path.Key, path.Value, out uniqueKey );

                    if ( result )
                    {
                        this.paths.Add( uniqueKey, path.Key );
                    }
                    else
                    {
                        break;
                    }
                }
            }

            return result;
        }
Exemplo n.º 3
0
        private object OnAddPathForProtection( object message )
        {
            var packet = ( AddPathForProtectionMessage )message;
            var ret = new OperationResult();

            if ( !this.CheckSession( packet.SessionKey ) )
            {
                ret.Value = false;
                return ret;
            }

            PathManager pathManager = new PathManager();

            if ( pathManager.ExistsPath( packet.Path ) )
            {
                ret.Value = false;
                return ret;
            }

            bool result = true;

            result = pathManager.InsertPath( packet.Path, packet.WeakProtection );

            /* TODO: check correct path */

            uint uniqueKey = 0;

            if ( result )
            {
                result = this.SafeAddPathForProtection( packet.Path, packet.WeakProtection, out uniqueKey );
            }

            if ( result )
            {
                paths.Add( uniqueKey, packet.Path );
            }

            ret.Value = result;
            return ret;
        }