Example #1
0
        public void Init(ParsingContext context, ParseTreeNode parseNode)
        {
            var _GraphQL = context.Parser.Language.Grammar;

            if (HasChildNodes(parseNode))
            {
                var _Terminal = parseNode.ChildNodes[0].Token.Terminal;

                if (_Terminal == _GraphQL.ToTerm("ALL"))
                {
                    DumpType = DumpTypes.GDDL | DumpTypes.GDML;
                }
                else if (_Terminal == _GraphQL.ToTerm("GDDL"))
                {
                    DumpType = DumpTypes.GDDL;
                }
                else if (_Terminal == _GraphQL.ToTerm("GDML"))
                {
                    DumpType = DumpTypes.GDML;
                }
                else
                {
                    throw new InvalidDumpTypeException(_Terminal.ToString(), "");
                }
            }
            else
            {
                DumpType = DumpTypes.GDDL | DumpTypes.GDML;
            }
        }
Example #2
0
        /// <summary>
        /// This will write the output lines to the destination. Only one output for each <paramref name="myDumpType"/> is allowed.
        /// </summary>
        /// <param name="myDumpType"></param>
        /// <param name="lines"></param>
        public void Write(DumpTypes myDumpType, IEnumerable <String> lines)
        {
            if (_DumpReadout.ContainsKey(myDumpType.ToString()))
            {
                throw new ArgumentException(myDumpType.ToString() + " already added");
            }

            switch (_TypeOfOutputDestination)
            {
            case TypeOfOutputDestination.QueryResult:
                _DumpReadout.Add(myDumpType.ToString(), lines);

                break;

            default:
                _DumpReadout.Add(myDumpType.ToString(), _Destination);

                foreach (var line in lines)
                {
                    if (!line.IsNullOrEmpty())
                    {
                        _Stream.WriteLine(line);
                    }
                }
                break;
            }
        }
Example #3
0
        public override void GetContent(CompilerContext context, ParseTreeNode parseNode)
        {
            #region Get the optional type list

            if (parseNode.ChildNodes[1].HasChildNodes())
            {
                _TypesToDump = ((parseNode.ChildNodes[1].ChildNodes[1].AstNode as TypeListNode).Types).Select(tlnode => tlnode.TypeName).ToList();
            }

            #endregion

            _DumpType           = (parseNode.ChildNodes[2].AstNode as DumpTypeNode).DumpType;
            _DumpFormat         = (parseNode.ChildNodes[3].AstNode as DumpFormatNode).DumpFormat;
            _DumpableGrammar    = context.Compiler.Language.Grammar as IDumpable;

            if (_DumpableGrammar == null)
            {
                throw new GraphDBException(new Error_NotADumpableGrammar(context.Compiler.Language.Grammar.GetType().ToString()));
            }

            if (parseNode.ChildNodes[4].HasChildNodes())
            {
                _DumpDestination = parseNode.ChildNodes[4].ChildNodes[1].Token.ValueString;
            }
        }
Example #4
0
        public void Init(ParsingContext context, ParseTreeNode parseNode)
        {
            #region Get the optional type list

            if (HasChildNodes(parseNode.ChildNodes[1]))
            {
                _TypesToDump = ((parseNode.ChildNodes[1].ChildNodes[1].AstNode as VertexTypeListNode).Types)
                               .Select(tlnode => tlnode.TypeName).ToList();
            }

            #endregion

            _DumpType        = (parseNode.ChildNodes[2].AstNode as DumpTypeNode).DumpType;
            _DumpFormat      = (parseNode.ChildNodes[3].AstNode as DumpFormatNode).DumpFormat;
            _DumpableGrammar = context.Parser.Language.Grammar as IDumpable;

            if (_DumpableGrammar == null)
            {
                throw new NotADumpableGrammarException(context.Parser.Language.Grammar.GetType().ToString(), "");
            }

            if (HasChildNodes(parseNode.ChildNodes[4]))
            {
                _DumpDestination = parseNode.ChildNodes[4].ChildNodes[1].Token.ValueString;
            }
        }
Example #5
0
        public void Init(ParsingContext context, ParseTreeNode parseNode)
        {
            var _GraphQL = context.Parser.Language.Grammar;

            if (HasChildNodes(parseNode))
            {

                var _Terminal = parseNode.ChildNodes[0].Token.Terminal;

                if (_Terminal == _GraphQL.ToTerm("ALL"))
                {
                    DumpType = DumpTypes.GDDL | DumpTypes.GDML;
                }
                else if (_Terminal == _GraphQL.ToTerm("GDDL"))
                {
                    DumpType = DumpTypes.GDDL;
                }
                else if (_Terminal == _GraphQL.ToTerm("GDML"))
                {
                    DumpType = DumpTypes.GDML;
                }
                else
                {
                    throw new InvalidDumpTypeException(_Terminal.ToString(), "");
                }

            }
            else
            {
                DumpType = DumpTypes.GDDL | DumpTypes.GDML;
            }
        }
Example #6
0
        public void GetContent(CompilerContext context, ParseTreeNode parseNode)
        {
            var _GraphQL = GetGraphQLGrammar(context);

            if (parseNode.HasChildNodes())
            {

                var _Terminal = parseNode.ChildNodes[0].Token.Terminal;

                if (_Terminal      == _GraphQL.S_ALL)
                {
                    DumpType = DumpTypes.GDDL | DumpTypes.GDML;
                }
                else if (_Terminal == _GraphQL.S_GDDL)
                {
                    DumpType = DumpTypes.GDDL;
                }
                else if (_Terminal == _GraphQL.S_GDML)
                {
                    DumpType = DumpTypes.GDML;
                }
                else
                {
                    throw new GraphDBException(new Errors.Error_InvalidDumpType(_Terminal.DisplayName));
                }

            }
            else
            {
                DumpType = DumpTypes.GDDL | DumpTypes.GDML;
            }
        }
        private static DumpModel dump(
            string path, DumpTypes type, Func <string, int, bool> callback)
        {
            int index      = 0;
            var terminated = false;
            var msg        = string.Empty;
            var aapt       = new AAPTool();
            var output     = new List <string>();

            switch (type)
            {
            case DumpTypes.Manifest:
                aapt.Start($"{command} {manifest} \"{path}\"");
                break;

            case DumpTypes.Resources:
                aapt.Start($"{command} {resources} \"{path}\"");
                break;

            case DumpTypes.ManifestTree:
                aapt.Start($"{command} {manifestTree} \"{path}\" AndroidManifest.xml");
                break;
                //default:
                //    return new DumpModel(path, false, output);
            }

            while (!aapt.StandardOutput.EndOfStream && !terminated)
            {
                msg = aapt.StandardOutput.ReadLine();

                if (callback(msg, index))
                {
                    terminated = true;
                    try {
                        aapt.Kill();
                    }
                    catch { }
                }
                if (!terminated)
                {
                    index++;
                }
                output.Add(msg);
            }

            while (!aapt.StandardError.EndOfStream)
            {
                output.Add(aapt.StandardError.ReadLine());
            }

            try {
                aapt.WaitForExit();
                aapt.Close();
                aapt.Dispose();
            }
            catch { }

            return(new DumpModel(path, output.Count > 2, output));
        }
Example #8
0
        private IEnumerable <IVertexView> Export(IDumpable myGrammar,
                                                 IGraphDB myGraphDB,
                                                 IGraphQL myGraphQL,
                                                 SecurityToken mySecurityToken,
                                                 Int64 myTransactionToken,
                                                 IEnumerable <IVertexType> myVertexTypes,
                                                 IEnumerable <IEdgeType> myEdgeTypes,
                                                 DumpTypes myDumpType)
        {
            var dumpReadout = new Dictionary <String, Object>();

            #region dump gddl
            if ((myDumpType & DumpTypes.GDDL) == DumpTypes.GDDL)
            {
                var graphDDL = myGrammar.ExportGraphDDL(DumpFormats.GQL,
                                                        myVertexTypes,
                                                        myEdgeTypes);

                if (graphDDL == null)
                {
                    throw new ExportFailedException(myDumpType.ToString(), "");
                }

                dumpReadout.Add("GDDL", new ListCollectionWrapper(graphDDL));

                Write(DumpTypes.GDDL, graphDDL);
            }
            #endregion

            #region dump gdml
            if ((myDumpType & DumpTypes.GDML) == DumpTypes.GDML)
            {
                var graphDML = myGrammar.ExportGraphDML(DumpFormats.GQL,
                                                        myVertexTypes,
                                                        mySecurityToken,
                                                        myTransactionToken);

                if (graphDML == null)
                {
                    throw new ExportFailedException(myDumpType.ToString(), "");
                }

                dumpReadout.Add("GDML", new ListCollectionWrapper(graphDML));

                Write(DumpTypes.GDML, graphDML);
            }
            #endregion

            return(new IVertexView[] { new VertexView(dumpReadout, null) });
        }
Example #9
0
        public IEnumerable <IVertexView> Export(string destination,
                                                IDumpable myGrammar,
                                                IGraphDB myGraphDB,
                                                IGraphQL myGraphQL,
                                                SecurityToken mySecurityToken,
                                                Int64 myTransactionToken,
                                                IEnumerable <String> myVertexTypes,
                                                IEnumerable <String> myEdgeTypes,
                                                DumpTypes myDumpType)
        {
            _Destination = destination;

            try
            {
                #region Open destination

                OpenStream(destination);

                #endregion

                #region Start export using the AGraphDBExport implementation

                return(Export(myGrammar,
                              myGraphDB,
                              myGraphQL,
                              mySecurityToken,
                              myTransactionToken,
                              GetVertexTypes(myGraphDB,
                                             mySecurityToken,
                                             myTransactionToken,
                                             myVertexTypes),
                              GetEdgeTypes(myGraphDB,
                                           mySecurityToken,
                                           myTransactionToken,
                                           myEdgeTypes),
                              myDumpType));

                #endregion
            }
            finally
            {
                #region Close destination

                CloseStream();

                #endregion
            }
        }
Example #10
0
        public override Exceptional Export(DBContext myDBContext, IDumpable myGrammar, IEnumerable<TypeManagement.GraphDBType> myTypes, DumpTypes myDumpType, VerbosityTypes verbosityType = VerbosityTypes.Errors)
        {
            var dumpReadout = new Dictionary<String, Object>();

            if ((myDumpType & DumpTypes.GDDL) == DumpTypes.GDDL)
            {

                var graphDDL = myGrammar.ExportGraphDDL(DumpFormats.GQL, myDBContext, myTypes);

                if (!graphDDL.Success())
                {
                    return new Exceptional(graphDDL);
                }

                //dumpReadout.Add("GDDL", graphDDL.Value);
                var writeResult = Write(DumpTypes.GDDL, graphDDL.Value);
                if (!writeResult.Success())
                {
                    return writeResult;
                }

            }

            if ((myDumpType & DumpTypes.GDML) == DumpTypes.GDML)
            {

                var graphDML = myGrammar.ExportGraphDML(DumpFormats.GQL, myDBContext, myTypes);

                if (!graphDML.Success())
                {
                    return new Exceptional(graphDML);
                }

                //dumpReadout.Add("GDML", _GraphDML.Value);
                var writeResult = Write(DumpTypes.GDML, graphDML.Value);
                if (!writeResult.Success())
                {
                    return writeResult;
                }

            }

            return Exceptional.OK;
        }
Example #11
0
        public void Init(ParsingContext context, ParseTreeNode parseNode)
        {
            #region Get the optional type list

            if (HasChildNodes(parseNode.ChildNodes[1]))
            {
                _TypesToDump = ((parseNode.ChildNodes[1].ChildNodes[1].AstNode as VertexTypeListNode).Types)
                                .Select(tlnode => tlnode.TypeName).ToList();
            }

            #endregion

            _DumpType = (parseNode.ChildNodes[2].AstNode as DumpTypeNode).DumpType;
            _DumpFormat = (parseNode.ChildNodes[3].AstNode as DumpFormatNode).DumpFormat;
            _DumpableGrammar = context.Parser.Language.Grammar as IDumpable;

            if (_DumpableGrammar == null)
                throw new NotADumpableGrammarException(context.Parser.Language.Grammar.GetType().ToString(), "");

            if (HasChildNodes(parseNode.ChildNodes[4]))
                _DumpDestination = parseNode.ChildNodes[4].ChildNodes[1].Token.ValueString;
        }
Example #12
0
        public QueryResult Export(String destination, DBContext myDBContext, IDumpable myGrammar, IEnumerable<String> myTypes, DumpTypes myDumpType, VerbosityTypes verbosityType = VerbosityTypes.Errors)
        {
            _Destination = destination;

            #region Open destination

            var openStreamResult = OpenStream(destination);
            if (!openStreamResult.Success())
            {
                return new QueryResult(openStreamResult);
            }

            #endregion

            #region Start export using the AGraphDBImport implementation

            var result = Export(myDBContext, myGrammar, GetTypes(myDBContext, myTypes), myDumpType, verbosityType);

            #endregion

            #region Close destination

            var closeStreamResult = CloseStream();
            if (!closeStreamResult.Success())
            {
                return new QueryResult(openStreamResult);
            }

            #endregion

            if (!result.Success())
            {
                return new QueryResult(result);
            }

            return new QueryResult(new List<Vertex>() { new Vertex(_DumpReadout) });
        }
Example #13
0
        private IEnumerable<IVertexView> Export(IDumpable myGrammar, 
            IGraphDB myGraphDB,
            IGraphQL myGraphQL,
            SecurityToken mySecurityToken,
            Int64 myTransactionToken,
            IEnumerable<IVertexType> myVertexTypes,
            IEnumerable<IEdgeType> myEdgeTypes,
            DumpTypes myDumpType)
        {
            var dumpReadout = new Dictionary<String, Object>();

            #region dump gddl
            if ((myDumpType & DumpTypes.GDDL) == DumpTypes.GDDL)
            {

                var graphDDL = myGrammar.ExportGraphDDL(DumpFormats.GQL,
                                                        myVertexTypes,
                                                        myEdgeTypes);

                if (graphDDL == null)
                {
                    throw new ExportFailedException(myDumpType.ToString(), "");

                }

                dumpReadout.Add("GDDL", new ListCollectionWrapper(graphDDL));

                Write(DumpTypes.GDDL, graphDDL);

            }
            #endregion

            #region dump gdml
            if ((myDumpType & DumpTypes.GDML) == DumpTypes.GDML)
            {

                var graphDML = myGrammar.ExportGraphDML(DumpFormats.GQL,
                                                        myVertexTypes,
                                                        mySecurityToken,
                                                        myTransactionToken);

                if (graphDML == null)
                {
                    throw new ExportFailedException(myDumpType.ToString(), "");
                }

                dumpReadout.Add("GDML", new ListCollectionWrapper(graphDML));

                Write(DumpTypes.GDML, graphDML);

            }
            #endregion

            return new IVertexView[] { new VertexView(dumpReadout, null) };
        }
Example #14
0
 public abstract Exceptional Export(DBContext myDBContext, IDumpable myGrammar, IEnumerable<GraphDBType> myTypes, DumpTypes myDumpType, VerbosityTypes verbosityType = VerbosityTypes.Errors);
Example #15
0
        public QueryResult Export(string destination, IDumpable myGrammar, IGraphDB myGraphDB, IGraphQL myGraphQL, SecurityToken mySecurityToken, TransactionToken myTransactionToken, IEnumerable<String> myTypes, DumpTypes myDumpType)
        {
            _Destination = destination;
            ASonesException error = null;

            #region Open destination

            try
            {
                OpenStream(destination);

            }
            catch (ASonesException e)
            {
                error = e;
            }

            #endregion

            #region Start export using the AGraphDBExport implementation

            var result = Export(myGrammar, myGraphDB, myGraphQL, mySecurityToken, myTransactionToken, GetTypes(ref myGraphDB, ref mySecurityToken, ref myTransactionToken, myTypes), myDumpType);

            #endregion

            #region Close destination

            try
            {
                CloseStream();
            }
            catch (ASonesException e)
            {
                error = e;
            }

            #endregion

            if(error != null)
                return new QueryResult("", ExportFormat, 0L, ResultType.Failed, result.Vertices, error);
            else
                return new QueryResult("", ExportFormat, 0L, result.TypeOfResult, result.Vertices);
        }
Example #16
0
        /// <summary>
        /// This will write the output lines to the destination. Only one output for each <paramref name="myDumpType"/> is allowed.
        /// </summary>
        /// <param name="myDumpType"></param>
        /// <param name="lines"></param>
        protected Exceptional Write(DumpTypes myDumpType, IEnumerable<String> lines)
        {
            if (_DumpReadout.ContainsKey(myDumpType.ToString()))
            {
                return new Exceptional(new Error_ArgumentException(myDumpType.ToString() + " already added"));
            }

            switch (_TypeOfOutputDestination)
            {

                case TypeOfOutputDestination.QueryResult:
                    _DumpReadout.Add(myDumpType.ToString(), lines);

                    break;

                default:
                    _DumpReadout.Add(myDumpType.ToString(), _Destination);

                    foreach (var line in lines)
                    {
                        _Stream.WriteLine(line);
                    }
                    break;
            }

            return Exceptional.OK;
        }
Example #17
0
        private QueryResult Export(IDumpable myGrammar, IGraphDB myGraphDB, IGraphQL myGraphQL, SecurityToken mySecurityToken, TransactionToken myTransactionToken, IEnumerable<IVertexType> myTypes, DumpTypes myDumpType)
        {
            var dumpReadout = new Dictionary<String, Object>();
            ASonesException error = null;

            #region dump gddl
            if ((myDumpType & DumpTypes.GDDL) == DumpTypes.GDDL)
            {

                var graphDDL = myGrammar.ExportGraphDDL(DumpFormats.GQL, myTypes);

                if (graphDDL == null)
                {
                    throw new ExportFailedException(myDumpType.ToString(), "");

                }

                dumpReadout.Add("GDDL", new ListCollectionWrapper(graphDDL));

                try
                {
                    Write(DumpTypes.GDDL, graphDDL);
                }
                catch (ASonesException e)
                {
                    error = e;
                }

            }
            #endregion

            #region dump gdml
            if ((myDumpType & DumpTypes.GDML) == DumpTypes.GDML)
            {

                var graphDML = myGrammar.ExportGraphDML(DumpFormats.GQL, myTypes, mySecurityToken, myTransactionToken);

                if (graphDML == null)
                {
                    throw new ExportFailedException(myDumpType.ToString(), "");
                }

                dumpReadout.Add("GDML", new ListCollectionWrapper(graphDML));

                try
                {
                    Write(DumpTypes.GDML, graphDML);
                }
                catch (ASonesException e)
                {
                    error = e;
                }

            }
            #endregion

            return new QueryResult("", ExportFormat, 0L, ResultType.Successful, new List<IVertexView> { new VertexView(dumpReadout, null) }, error);
        }
Example #18
0
        public IEnumerable<IVertexView> Export(string destination, 
            IDumpable myGrammar,
            IGraphDB myGraphDB,
            IGraphQL myGraphQL,
            SecurityToken mySecurityToken,
            Int64 myTransactionToken,
            IEnumerable<String> myVertexTypes,
            IEnumerable<String> myEdgeTypes,
            DumpTypes myDumpType)
        {
            _Destination = destination;

            try
            {
                #region Open destination

                OpenStream(destination);

                #endregion

                #region Start export using the AGraphDBExport implementation

                return Export(myGrammar,
                                myGraphDB,
                                myGraphQL,
                                mySecurityToken,
                                myTransactionToken,
                                GetVertexTypes(myGraphDB,
                                                mySecurityToken,
                                                myTransactionToken,
                                                myVertexTypes),
                                GetEdgeTypes(myGraphDB,
                                                mySecurityToken,
                                                myTransactionToken,
                                                myEdgeTypes),
                                myDumpType);

                #endregion
            }
            finally
            {
                #region Close destination

                CloseStream();

                #endregion
            }
        }
 private static extern bool MiniDumpWriteDump([In] IntPtr hProcess, uint ProcessId, SafeFileHandle hFile, DumpTypes DumpType, [In] IntPtr ExceptionParam, [In] IntPtr UserStreamParam, [In] IntPtr CallbackParam);
 public static void WriteDumpForProcess(Process argProcess, FileStream argFileStream, DumpTypes argDumpType)
 {
     if (!MiniDumpWriteDump(Process.GetCurrentProcess().Handle, (uint)argProcess.Id, argFileStream.SafeFileHandle, argDumpType, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero))
         throw new Win32Exception(Marshal.GetLastWin32Error(), "Error calling MiniDump.");
 }
Example #21
0
        /// <summary>
        /// This will write the output lines to the destination. Only one output for each <paramref name="myDumpType"/> is allowed.
        /// </summary>
        /// <param name="myDumpType"></param>
        /// <param name="lines"></param>
        public void Write(DumpTypes myDumpType, IEnumerable<String> lines)
        {
            if (_DumpReadout.ContainsKey(myDumpType.ToString()))
            {
                throw new ArgumentException(myDumpType.ToString() + " already added");
            }

            switch (_TypeOfOutputDestination)
            {
                case TypeOfOutputDestination.QueryResult:
                    _DumpReadout.Add(myDumpType.ToString(), lines);

                    break;

                default:
                    _DumpReadout.Add(myDumpType.ToString(), _Destination);

                    foreach (var line in lines)
                    {
                        if(!line.IsNullOrEmpty())
                            _Stream.WriteLine(line);
                    }
                    break;
            }
        }