Beispiel #1
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            ObjectLocation _DirectoryObjectLocation = null;

            try
            {
                _DirectoryObjectLocation = new ObjectLocation(ObjectLocation.ParseString(myCurrentPath), myOptions.ElementAt(1).Value[0].Option);
            }
            catch (Exception e)
            {
                WriteLine(e.Message);
                return Exceptional.OK;
            }

            try
            {
                myAGraphDSSharp.CreateDirectoryObject(_DirectoryObjectLocation);
            }

            catch (Exception e)
            {
                WriteLine(e.Message);
            }

            return Exceptional.OK;
        }
Beispiel #2
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            var _GetExtendedDirectoryListingExceptional = myAGraphDSSharp.GetExtendedDirectoryListing(ObjectLocation.ParseString(myCurrentPath));

            if (_GetExtendedDirectoryListingExceptional.Success() && _GetExtendedDirectoryListingExceptional.Value != null)
            {
                foreach (var _DirectoryEntry in _GetExtendedDirectoryListingExceptional.Value)
                {

                    String _ObjectStreamInfo = null;

                    foreach (var _ObjectStream in _DirectoryEntry.Streams)
                        if (_ObjectStreamInfo != null)
                            _ObjectStreamInfo = _ObjectStreamInfo + ", " + _ObjectStream;
                        else
                            _ObjectStreamInfo = _ObjectStream;

                    WriteLine("{0,-30} {1}", _DirectoryEntry.Name, _ObjectStreamInfo);

                }
            }

            else
            {
                foreach (var _IError in _GetExtendedDirectoryListingExceptional.IErrors)
                    WriteLine(_IError.Message);
            }

            WriteLine();

            return Exceptional.OK;
        }
Beispiel #3
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            var _HttpSecurity = new HTTPSecurity()
            {
                // Include: System.ServiceModel
                CredentialType            = HttpClientCredentialType.Basic,
                UserNamePasswordValidator = new PassValidator()
            };

            // Initialize REST service
            var _HttpWebServer = new HTTPServer<GraphDSREST_Service>(
                9975,
                new GraphDSREST_Service(myAGraphDSSharp),
                myAutoStart: true)
            {
                HTTPSecurity = _HttpSecurity,
            };

            // Register the REST service within the list of services
            // to stop before shutting down the GraphDSSharp instance
            myAGraphDSSharp.ShutdownEvent += new GraphDSSharp.ShutdownEventHandler((o, e) =>
            {
                _HttpWebServer.StopAndWait();
            });

            return Exceptional.OK;
        }
Beispiel #4
0
        private Boolean ExecuteAQuery(AGraphDSSharp myAGraphDSSharp, String myQueryString)
        {
            if (myQueryString.Length != 0)
            {

                var myQueryResult = QueryDB(myAGraphDSSharp, myQueryString);

                WriteLine(myQueryString);

                HandleQueryResult(myQueryResult, false);

                if (myQueryResult.ResultType != ResultType.Successful)
                {
                    WriteLine(myQueryResult.GetIErrorsAsString());
                    return false;
                }

                else
                {
                    return true;
                }

            }

            else
            {
                return true;
            }
        }
Beispiel #5
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            var _Content        = myOptions.ElementAt(1).Value[0].Option;
            var _FileLocation   = new ObjectLocation(ObjectLocation.ParseString(myCurrentPath), myOptions.ElementAt(2).Value[0].Option);

            if (myAGraphDSSharp.ObjectExists(_FileLocation).Value != Trinary.TRUE)
            {

                try
                {
                    AFSObject _FileObject = new FileObject() { ObjectLocation = _FileLocation, ObjectData = Encoding.UTF8.GetBytes(_Content)};
                    myAGraphDSSharp.StoreFSObject(_FileObject, true);
                }
                catch (Exception e)
                {
                    WriteLine(e.Message);
                }

            }

            else
            {

                if (myAGraphDSSharp.ObjectStreamExists(_FileLocation, FSConstants.INLINEDATA).Value)
                {

                }

            }

            return Exceptional.OK;
        }
Beispiel #6
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            _CancelCommand = false;

            WriteLine(Environment.NewLine + "Used space on the following devices:" + Environment.NewLine);

            var Size     = myAGraphDSSharp.GetNumberOfBytes(ObjectLocation.ParseString(FSPathConstants.PathDelimiter));
            var UsedSize = myAGraphDSSharp.GetNumberOfBytes(ObjectLocation.ParseString(FSPathConstants.PathDelimiter)) - myAGraphDSSharp.GetNumberOfFreeBytes(ObjectLocation.ParseString(FSPathConstants.PathDelimiter));
            var Procent  = (((Double)UsedSize) / ((Double)Size)) * (Double)100;
            WriteLine("{0,-12} {1,15} ({2:0.#}%)", FSPathConstants.PathDelimiter, UsedSize.ToByteFormattedString(2), Procent);

            foreach (var _Mountpoint in myAGraphDSSharp.GetChildFileSystemMountpoints(true))
            {
                Size     = myAGraphDSSharp.GetNumberOfBytes(_Mountpoint);
                UsedSize = myAGraphDSSharp.GetNumberOfBytes(_Mountpoint) - myAGraphDSSharp.GetNumberOfFreeBytes(_Mountpoint);
                Procent  = (((Double)UsedSize) / ((Double)Size)) * (Double)100;
                WriteLine("{0,-12} {1,15} ({2:0.#}%)", _Mountpoint, UsedSize.ToByteFormattedString(2), Procent);
            }

            WriteLine(Environment.NewLine);

            return Exceptional.OK;
        }
Beispiel #7
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            //lulu

            return Exceptional.OK;
        }
Beispiel #8
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            _CancelCommand = false;

            var QueryInputString = myInputString.Replace("'", "");

            HandleQueryResult(QueryDB(myAGraphDSSharp, QueryInputString), true);

            return Exceptional.OK;
        }
Beispiel #9
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            //var _IndividualCDCommands = myOptions.ElementAt(1).Value[0].Option.Split(new String[] { FSPathConstants.PathDelimiter }, StringSplitOptions.None);

            //if (_IndividualCDCommands[0].Equals(""))
            //    _IndividualCDCommands[0] = FSPathConstants.PathDelimiter;

            WriteLine("Hello world!");

            return Exceptional.OK;
        }
Beispiel #10
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            _CancelCommand = false;

            QueryResult _QueryResult;

            myInputString = Regex.Replace(myInputString, "[INSERT|insert]+ [INTO|into]+ (\')(.*?)(\') [VALUES|values]+", "INSERT INTO $2 VALUES");
            myInputString = Regex.Replace(myInputString, "([\\(|,]+)(\\s*)(\')(.*?)(\')(\\s*)=", "$1 $4 =");

            _QueryResult = QueryDB(myAGraphDSSharp, myInputString);

            return Exceptional.OK;
        }
Beispiel #11
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            var _IndividualCDCommands = myOptions.ElementAt(1).Value[0].Option.Split(new String[] { FSPathConstants.PathDelimiter }, StringSplitOptions.None);

            if (_IndividualCDCommands[0].Equals(""))
                _IndividualCDCommands[0] = FSPathConstants.PathDelimiter;

            foreach (var _ActualCDCommand in _IndividualCDCommands)
            {
                if (!_ActualCDCommand.Equals("."))
                    if (!(myCurrentPath.Equals(FSPathConstants.PathDelimiter) && _ActualCDCommand.Equals("..")))
                        CD_private(myAGraphDSSharp, ref myCurrentPath, _ActualCDCommand);
            }

            return Exceptional.OK;
        }
Beispiel #12
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            _CancelCommand = false;

            if (myOptions.ElementAt(1).Value[0].Option.Equals(StartSymbol.DisplayName))
            {
                //we have a start
                if (myAGraphDSSharp != null)
                {
                    if (myAGraphDSSharp.IGraphDBSession == null)
                    {
                        var internalGraphDB = new GraphDB2(new UUID(), new ObjectLocation(myOptions.ElementAt(2).Value[0].Option), myAGraphDSSharp, true);
                        var DB = new GraphDBSession(internalGraphDB, myAGraphDSSharp.SessionToken.SessionInfo.Username);
                    }
                    else
                    {
                        Console.WriteLine("GraphDB instance could not be started, because you already started a GraphDB.");
                    }
                }
                else
                {
                    Console.WriteLine("GraphDB instance could not be started, because you do not have a GraphVFS mounted.");
                }
            }

            else
            {

                if (myAGraphDSSharp.IGraphDBSession != null)
                {
                    myAGraphDSSharp.IGraphDBSession.Shutdown();
                }
                else
                {
                    Console.WriteLine("No GraphDB instance started...");
                }
            }

            return Exceptional.OK;
        }
Beispiel #13
0
        protected QueryResult QueryDB(AGraphDSSharp myGraphDSSharp, String myQueryString, Boolean myWithOutput = true)
        {
            if (myWithOutput)
                Write(myQueryString + " => ");

            var GQLQuery = new GraphQLQuery(myGraphDSSharp.IGraphDBSession.DBPluginManager);
            var _QueryResult = GQLQuery.Query(myQueryString, myGraphDSSharp.IGraphDBSession);

            if (myWithOutput)
                WriteLine(_QueryResult.ResultType.ToString());

            if (_QueryResult == null)
                WriteLine("The QueryResult is invalid!\n\n");

            else if (_QueryResult.ResultType != ResultType.Successful)
                foreach (var aError in _QueryResult.Errors)
                    WriteLine(aError.GetType().ToString() + ": " + aError.ToString() + "\n\n");

            return _QueryResult;
        }
Beispiel #14
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            var sw = new Stopwatch();
            var locale = myOptions.ElementAt(1).Value[0].Option;

            try
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(locale);
            }
            catch
            {
            }

            Console.WriteLine("Current Thread-Culture is: "+System.Threading.Thread.CurrentThread.CurrentCulture);

            return Exceptional.OK;
        }
Beispiel #15
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            _CancelCommand = false;

            QueryResult _QueryResult;

            if (CLI_Output == CLI_Output.Standard)
                _QueryResult = QueryDB(myAGraphDSSharp, myOptions.ElementAt(1).Value[0].Option);
            else
                _QueryResult = QueryDB(myAGraphDSSharp, myOptions.ElementAt(1).Value[0].Option, false);

            Write(_QueryResult.ToTEXT());

            if (CLI_Output == CLI_Output.Standard)
                WriteLine();

            return Exceptional.OK;
        }
Beispiel #16
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            _CancelCommand = false;

            WriteLine(Environment.NewLine + "Total disc size of the following devices:" + Environment.NewLine);

            var Size = myAGraphDSSharp.GetNumberOfBytes(ObjectLocation.Root);
            WriteLine("{0,-12} {1,15} Bytes", FSPathConstants.PathDelimiter, Size.ToByteFormattedString(2));

            foreach (var _Mountpoint in myAGraphDSSharp.GetChildFileSystemMountpoints(true))
            {
                Size = myAGraphDSSharp.GetNumberOfBytes(_Mountpoint);
                WriteLine("{0,-12} {1,15} ", _Mountpoint, Size.ToByteFormattedString(2));
            }

            WriteLine(Environment.NewLine);

            return Exceptional.OK;
        }
Beispiel #17
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            _CancelCommand = false;

            // 1 parameter -> Print the target of the symlink
            if (myOptions.Count == 2)
            {

                var SymlinkLocation = new ObjectLocation(ObjectLocation.ParseString(myCurrentPath), myOptions.ElementAt(1).Value[0].Option);

                if (myAGraphDSSharp.isSymlink(SymlinkLocation).Value == Trinary.TRUE)
                    WriteLine(" -> " + myAGraphDSSharp.GetSymlink(SymlinkLocation));

                else
                    WriteLine("Symlink does not exist!");

            }

            // 2 parameters -> Create new symlink
            else
            {

                var SymlinkLocation = new ObjectLocation(ObjectLocation.ParseString(myCurrentPath), myOptions.ElementAt(1).Value[0].Option);
                var SymlinkTarget   = new ObjectLocation(ObjectLocation.ParseString(myCurrentPath), myOptions.ElementAt(2).Value[0].Option);

                myAGraphDSSharp.AddSymlink(SymlinkLocation, SymlinkTarget);

                WriteLine(SymlinkLocation.ToString() + " -> " + SymlinkTarget.ToString());

            }

            return Exceptional.OK;
        }
        public override List<String> Complete(AGraphDSSharp myGraphDSSharp, ref String CurrentPath, string CurrentStringLiteral)
        {
            var possibleGraphTypes = new List<String>();

            if (myGraphDSSharp.IGraphDBSession != null)
            {

                using (var transaction = myGraphDSSharp.IGraphDBSession.BeginTransaction())
                {

                    foreach (var _GraphType in ((DBContext)transaction.GetDBContext()).DBTypeManager.GetAllTypes())
                    {
                        if (_GraphType.Name.StartsWith(CurrentStringLiteral))
                        {
                            possibleGraphTypes.Add(_GraphType.Name);
                        }
                    }

                }

            }

            return possibleGraphTypes;
        }
Beispiel #19
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            var gqlQuery = new GraphQLQuery(myAGraphDSSharp.IGraphDBSession.DBPluginManager);

            Boolean isSuccessful = true;
            int numberOfStatement = 1;
            Stopwatch sw = new Stopwatch();
            String ScriptFile = myOptions.ElementAt(1).Value[0].Option;

            //((FSSessionInfo)_IGraphFS2Session.SessionToken.SessionInfo).FSSettings.AutoCommitAfterNumberOfPendingTransactions = 1000;

            String line = "";
            try
            {
                StreamReader reader = new StreamReader(ScriptFile);

                //_IGraphFS2Session.BeginTransaction();

                sw.Start();
                while ((line = reader.ReadLine()) != null)
                {
                    if (!ExecuteAQuery(line.Trim(), myAGraphDSSharp.IGraphDBSession, gqlQuery))
                    {
                        WriteLine("Error while executing query: \"" + line + "\"");

                        isSuccessful= false;
                        break;
                    }

                    if (line.Length != 0)
                    {
                        numberOfStatement++;
                    }

                    if (_CancelCommand)
                    {
                        Console.WriteLine("... parsing stopped.");
                        break;
                    }

                }

                sw.Stop();
                reader.Close();

            }
            catch
            {
                // Fehler beim Öffnen der Datei
            }

            if (isSuccessful)
            {
                WriteLine("\nSuccessfully executed " + numberOfStatement + " statements in " + sw.Elapsed.Seconds + " seconds.");
                //_IGraphFS2Session.CommitTransaction();
            }
            else
            {
                //_IGraphFS2Session.RollbackTransaction();
            }

            return Exceptional.OK;
        }
Beispiel #20
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            _CancelCommand = false;

            var typeInterestedIn = myOptions.ElementAt(1).Value[0].Option;

            using (var transaction = myAGraphDSSharp.IGraphDBSession.BeginTransaction())
            {

                var _ActualType = ((DBContext)transaction.GetDBContext()).DBTypeManager.GetTypeByName(typeInterestedIn);

                while (_ActualType != null)
                {

                    if (_ActualType.UUID.ToString().Length > 4)
                        WriteLine("(by " + _ActualType.Name + " [UUID: " + _ActualType.UUID.ToString().Substring(0, 4) + "..])");
                    else
                        WriteLine("(by " + _ActualType.Name + " [UUID: " + _ActualType.UUID.ToString() + "])");

                    if (!_ActualType.Attributes.Count.Equals(0))
                    {
                        var maxLengthName = _ActualType.Attributes.Values.Max(a => a.Name.Length);
                        foreach (var _TypeAttribute in _ActualType.Attributes.Values)
                        {
                            StringBuilder sb = new StringBuilder();

                            sb.Append(_TypeAttribute.Name.PadRight(maxLengthName + 3));
                            sb.Append("");

                            if (_TypeAttribute.TypeCharacteristics.IsBackwardEdge)
                            {
                                sb.Append("BACKWARDEDGE<");
                                var beTypeAttr = ((DBContext)transaction.GetDBContext()).DBTypeManager.GetTypeAttributeByEdge(_TypeAttribute.BackwardEdgeDefinition);
                                sb.Append(beTypeAttr.GetRelatedType(((DBContext)transaction.GetDBContext()).DBTypeManager).Name + "." + beTypeAttr.Name);
                                sb.Append(">");
                            }
                            else
                            {

                                if (_TypeAttribute.KindOfType == KindsOfType.ListOfNoneReferences)
                                    sb.Append("LIST<");

                                if (_TypeAttribute.KindOfType == KindsOfType.SetOfReferences || _TypeAttribute.KindOfType == KindsOfType.SetOfNoneReferences)
                                    sb.Append("SET<");

                                sb.Append(((DBContext)transaction.GetDBContext()).DBTypeManager.GetTypeByUUID(_TypeAttribute.DBTypeUUID).Name);

                                if (_TypeAttribute.KindOfType == KindsOfType.ListOfNoneReferences || _TypeAttribute.KindOfType == KindsOfType.SetOfNoneReferences || _TypeAttribute.KindOfType == KindsOfType.SetOfReferences)
                                    sb.Append(">");
                            }

                            sb.Append(" ");
                            sb.Append(_TypeAttribute.TypeCharacteristics.ToString());

                            sb.Append(" [UUID: ");
                            sb.Append(_TypeAttribute.UUID.ToString().Substring(0, 4));
                            sb.Append("..]");

                            WriteLine(sb.ToString());
                        }
                    }

                    else
                        WriteLine("No myAttributes for this type.");

                    WriteLine(Environment.NewLine);

                    if (_ActualType.ParentTypeUUID == null)
                        break;

                    _ActualType = ((DBContext)transaction.GetDBContext()).DBTypeManager.GetTypeByUUID(_ActualType.ParentTypeUUID);

                }
            }

            return Exceptional.OK;
        }
Beispiel #21
0
 public GraphDSREST_Service(AGraphDSSharp myAGraphDSSharp)
 {
     _AGraphDSSharp    = myAGraphDSSharp;
     _GraphQLQuery     = new GraphQLQuery(_AGraphDSSharp.IGraphDBSession.DBPluginManager);
     //            _SessionSonesCLIs = new Dictionary<String, sonesCLI>();
 }
Beispiel #22
0
        public GraphCLI(AGraphDSSharp myGraphDSSharp, String myDatabasePath, Stream myStream, CLI_Output myCLI_Output, params Type[] myCommandTypes)
        {
            _GraphDSSharp = myGraphDSSharp;
            CurrentPath = myDatabasePath;
            _StreamWriter = new StreamWriter(myStream);
            _StreamReader = new StreamReader(myStream);
            _CLI_Output = myCLI_Output;

            initCli(myCommandTypes);
        }
Beispiel #23
0
        /// <summary>
        /// This methods starts a GraphCLI using the given GraphFS and myPath
        /// </summary>
        /// <param name="myGraphDSSharp">an already defined virtual file system</param>
        /// <param name="myPath">the location/myPath within the file system</param>
        public GraphCLI(AGraphDSSharp myGraphDSSharp, String myPath)
            : this()
        {

            _GraphDSSharp  = myGraphDSSharp;
            CurrentPath = myPath;
            ShutDownOnExit = false;
            PrintStartupInformation();

        }
Beispiel #24
0
 public GraphDSWebDAV_Service(AGraphDSSharp myAGraphDSSharp)
 {
     _AGraphDSSharp = myAGraphDSSharp;
 }
        public override List<String> Complete(AGraphDSSharp myGraphDSSharp, ref String CurrentPath, string CurrentStringLiteral)
        {
            #region Data

            List<String>        _PossibleFSEntries  = new List<String>();
            IEnumerable<String> _DirectoryElements  = null;

            #endregion

            if (CurrentStringLiteral.Length.Equals(0))
            {
                try
                {
                    _DirectoryElements = myGraphDSSharp.GetDirectoryListing(ObjectLocation.ParseString(CurrentPath)).Value;
                }
                catch
                {
                    //do nothing
                }

                if (_DirectoryElements != null)
                {
                    _PossibleFSEntries.AddRange(_DirectoryElements);
                }
            }
            else
            {
                #region extract dir prefix from CurrentStringLiteral

                int indexOfLastPathDelimitter = CurrentStringLiteral.LastIndexOf(FSPathConstants.PathDelimiter);
                String PrefixDir = CurrentStringLiteral.Substring(0, indexOfLastPathDelimitter + 1);

                if (CurrentStringLiteral.StartsWith(FSPathConstants.PathDelimiter))
                {
                    Boolean directoryExists = false;
                    try
                    {
                        directoryExists = myGraphDSSharp.isIDirectoryObject(ObjectLocation.ParseString(SimplifyObjectLocation(PrefixDir))).Value == Trinary.TRUE;
                    }
                    catch
                    {
                        //do nothing
                    }
                    if (directoryExists)
                    {

                        try
                        {
                            _DirectoryElements = myGraphDSSharp.GetDirectoryListing(ObjectLocation.ParseString(SimplifyObjectLocation(PrefixDir))).Value;
                        }
                        catch
                        {
                            //do nothing
                        }

                        if (_DirectoryElements != null)
                        {

                            foreach (String aDirElement in _DirectoryElements)
                            {
                                _PossibleFSEntries.Add(PrefixDir + aDirElement);
                            }

                        }
                    }
                }
                else
                {
                    if (PrefixDir.Length.Equals(0))
                    {
                        try
                        {
                            _DirectoryElements = myGraphDSSharp.GetDirectoryListing(ObjectLocation.ParseString(CurrentPath)).Value;
                        }
                        catch
                        {
                            //do nothing
                        }

                        if (_DirectoryElements != null)
                        {
                            _PossibleFSEntries.AddRange(_DirectoryElements);
                        }
                    }
                    else
                    {
                        try
                        {
                            _DirectoryElements = myGraphDSSharp.GetDirectoryListing(ObjectLocation.ParseString(SimplifyObjectLocation(CurrentPath + FSPathConstants.PathDelimiter + PrefixDir))).Value;
                        }
                        catch
                        {
                            //do nothing
                        }

                        if (_DirectoryElements != null)
                        {
                            foreach (String aDirElement in _DirectoryElements)
                            {
                                _PossibleFSEntries.Add(PrefixDir + aDirElement);
                            }
                        }
                    }
                }

                #endregion
            }

            return _PossibleFSEntries;
        }
Beispiel #26
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            _CancelCommand = false;

            var            _tmpObjectLocation              = new ObjectLocation(ObjectLocation.ParseString(myCurrentPath), myOptions.ElementAt(1).Value[0].Option);
            ObjectLocation _ObjectLocation;
            var            _ObjectStreamDelimiterPosition  = _tmpObjectLocation.IndexOf(FSConstants.ObjectStreamDelimiter);
            var            _ObjectStreamTypes              = new List<String>();

            if (_ObjectStreamDelimiterPosition > 0)
            {
                _ObjectLocation     = ObjectLocation.ParseString(_tmpObjectLocation.Substring(0, _ObjectStreamDelimiterPosition));
                _ObjectStreamTypes.Add(_tmpObjectLocation.Substring(_ObjectStreamDelimiterPosition + FSConstants.ObjectStreamDelimiter.Length));
            }

            else
            {
                _ObjectLocation     = _tmpObjectLocation;
                _ObjectStreamTypes  = new List<String>(myAGraphDSSharp.GetObjectStreams(_ObjectLocation).Value);
            }

            foreach (var _ObjectStream in _ObjectStreamTypes)
            {

                WriteLine(_ObjectStream + ":");
                WriteLine("");

                switch (_ObjectStream)
                {

                    #region SYSTEMMETADATASTREAM

                    //case FSConstants.SYSTEMMETADATASTREAM:
                    //    foreach (var _KeyValuePair in myAGraphDSSharp.GetSystemMetadata(new ObjectLocation(_ObjectLocation)))
                    //        foreach (var val in _KeyValuePair.Value)
                    //            WriteLine("{0,-25} = {1}", _KeyValuePair.Key, val);
                    //    break;

                    #endregion

                    #region USERMETADATASTREAM

                    //case FSConstants.USERMETADATASTREAM:
                    //    foreach (var _KeyValuePair in myAGraphDSSharp.GetUserMetadata(new ObjectLocation(_ObjectLocation)).Value)
                    //        foreach (var val in _KeyValuePair.Value)
                    //            WriteLine("{0,-25} = {1}", _KeyValuePair.Key, val);
                    //    break;

                    #endregion

                    #region UNDEFINEDATTRIBUTESSTREAM

                    case "UNDEFINEDATTRIBUTESSTREAM":
                        foreach (var _KeyValuePair in myAGraphDSSharp.GetMetadata<Object>(_ObjectLocation, "UNDEFINEDATTRIBUTESSTREAM", FSConstants.DefaultEdition).Value)
                       //    foreach (var val in _KeyValuePair.Value)
                                WriteLine("{0,-25} = {1}", _KeyValuePair.Key, _KeyValuePair.Value);
                        break;

                    #endregion

                    #region LISTOF_STRINGS

                    case FSConstants.LISTOF_STRINGS:
                        foreach (var _String in myAGraphDSSharp.GetFSObject<ListOfStringsObject>(_ObjectLocation).Value)
                            WriteLine(_String);
                        break;

                    #endregion

                    #region FILESTREAM

                    case FSConstants.FILESTREAM:
                        var FileContent = Encoding.UTF8.GetString(myAGraphDSSharp.GetFSObject<FileObject>(_ObjectLocation, FSConstants.FILESTREAM, null, null, 0, false).Value.ObjectData);
                        WriteLine(FileContent);
                        break;

                    #endregion

                    #region INLINEDATA

                    case FSConstants.INLINEDATA:
                        var _Inlinedata = myAGraphDSSharp.GetFSObject<DirectoryObject>(_ObjectLocation.Path).Value.GetInlineData(_ObjectLocation.Name);

                        if (_ObjectLocation.Name.Equals(FSConstants.DotUUID))
                            WriteLine((new ObjectUUID(_Inlinedata)).ToString());

                        else
                            WriteLine(_Inlinedata.ToString());

                        break;

                    #endregion

                }

                WriteLine();

            }

            return Exceptional.OK;
        }
Beispiel #27
0
        /// <summary>
        /// This methods starts a GraphCLI using the given GraphFS and
        /// myPath loading just the requested command types.
        /// </summary>
        /// <param name="myGraphDSSharp">an already defined virtual file system</param>
        /// <param name="myPath">the location/myPath within the file system</param>
        public GraphCLI(AGraphDSSharp myGraphDSSharp, String myPath, params Type[] myCommandTypes) 
        {

            _GraphDSSharp  = myGraphDSSharp;
            CurrentPath = myPath;

            initCli(myCommandTypes);

        }
Beispiel #28
0
 public CreateIndexQuery(AGraphDSSharp myAGraphDSSharp, String myIndexName = null)
     : base(myAGraphDSSharp)
 {
     Name = myIndexName;
 }
Beispiel #29
0
        public override Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString)
        {
            if (myAGraphDSSharp == null)
                return new Exceptional(new GraphDSError("myAGraphDSSharp must not be null!"));

            _CancelCommand = false;

            var _GetDirectoryListingExceptional = myAGraphDSSharp.GetDirectoryListing(ObjectLocation.ParseString(myCurrentPath));

            if (_GetDirectoryListingExceptional.Success() && _GetDirectoryListingExceptional.Value != null)
            {
                foreach (var _DirectoryEntry in _GetDirectoryListingExceptional.Value)
                {
                    WriteLine(_DirectoryEntry);
                }
            }

            else
            {
                foreach (var _IError in _GetDirectoryListingExceptional.IErrors)
                    WriteLine(_IError.Message);
            }

            WriteLine();

            return Exceptional.OK;
        }
Beispiel #30
0
 public abstract Exceptional Execute(AGraphDSSharp myAGraphDSSharp, ref String myCurrentPath, Dictionary<String, List<AbstractCLIOption>> myOptions, String myInputString);