예제 #1
0
        private void ExecuteAsSingleThread(IEnumerable <String> myLines,
                                           IGraphQL myIGraphQL,
                                           SecurityToken mySecurityToken,
                                           Int64 myTransactionToken,
                                           VerbosityTypes myVerbosityType,
                                           IEnumerable <String> comments = null)
        {
            _logger.Log(Level.INFO, "Started GQL import.");

            #region data

            Int64 numberOfLine = 0;

            #endregion

            #region check lines and execute query

            Stopwatch sw = new Stopwatch();

            foreach (var _Line in myLines)
            {
                numberOfLine++;

                if (String.IsNullOrWhiteSpace(_Line))
                {
                    continue;
                }

                #region Skip comments

                if (IsComment(_Line, comments))
                {
                    continue;
                }

                #endregion

                #region execute query
                _logger.Log(Level.INFO, String.Format("Executing query {0}: {1}", _numberOfStatements, _Line));

                sw.Reset();
                sw.Start();

                var tempResult = myIGraphQL.Query(mySecurityToken, myTransactionToken, _Line);
                Interlocked.Increment(ref _numberOfStatements);

                sw.Stop();

                _logger.Log(Level.INFO, String.Format("Took {0}ms.", sw.Elapsed.TotalMilliseconds));

                #endregion

                #region Add errors and break execution

                if (tempResult.TypeOfResult == ResultType.Failed)
                {
                    if (tempResult.Error.Message.Equals("Mal-formed  string literal - cannot find termination symbol."))
                    {
                        string error = "Query at line [" + numberOfLine + "] [" + _Line + "] failed with " + tempResult.Error.ToString() + " add next line...";
                        Debug.WriteLine(error);
                        _logger.Log(Level.WARNING, error);
                    }
                    if (myVerbosityType == VerbosityTypes.Errors)
                    {
                        if (tempResult.Error != null)
                        {
                            _logger.Log(Level.SEVERE, tempResult.Error.ToString());
                        }
                        else
                        {
                            _logger.Log(Level.SEVERE, "Import failed because of unknown exception");
                        }
                    }
                }

                #endregion
            }


            #endregion

            _logger.Log(Level.INFO, String.Format("Finished GQL import and executed {0} statements", _numberOfStatements));
        }
예제 #2
0
 private IQueryResult ExecuteQuery(String myQuery, IGraphQL myGraphQL, SecurityToken mySecurityToken, Int64 myTransactionToken)
 {
     return(myGraphQL.Query(mySecurityToken, myTransactionToken, myQuery));
 }
예제 #3
0
 private QueryResult ExecuteQuery(String myQuery, IGraphQL myGraphQL, SecurityToken mySecurityToken, TransactionToken myTransactionToken)
 {
     return myGraphQL.Query(mySecurityToken, myTransactionToken, myQuery);
 }
예제 #4
0
        private QueryResult ExecuteAsSingleThread(IEnumerable<String> myLines, IGraphQL myIGraphQL, SecurityToken mySecurityToken, TransactionToken myTransactionToken, VerbosityTypes myVerbosityType, IEnumerable<String> comments = null)
        {
            #region data

            QueryResult queryResult = null;
            Int64 numberOfLine = 0;
            var aggregatedResults = new List<IEnumerable<IVertexView>>();
            Stopwatch StopWatchLines = new Stopwatch();

            #endregion

            #region check lines and execute query

            StopWatchLines.Reset();
            StopWatchLines.Start();

            foreach (var _Line in myLines)
            {
                numberOfLine++;

                if (String.IsNullOrWhiteSpace(_Line))
                {
                    continue;
                }

                #region Skip comments

                if (IsComment(_Line, comments))
                    continue;

                #endregion

                #region execute query

                var tempResult = myIGraphQL.Query(mySecurityToken, myTransactionToken, _Line);

                #endregion

                #region Add errors and break execution

                if (tempResult.TypeOfResult == ResultType.Failed)
                {
                    if (tempResult.Error.Message.Equals("Mal-formed  string literal - cannot find termination symbol."))
                        Debug.WriteLine("Query at line [" + numberOfLine + "] [" + _Line + "] failed with " + tempResult.Error.ToString() + " add next line...");

                    if (myVerbosityType == VerbosityTypes.Errors)
                    {
                        queryResult = new QueryResult(_Line, ImportFormat, 0L, ResultType.Failed, tempResult.Vertices, tempResult.Error);

                        break;
                    }
                }

                aggregatedResults.Add(tempResult.Vertices);

                #endregion
            }

            StopWatchLines.Stop();

            #endregion

            //add the results of each query into the queryResult
            if(queryResult != null)
                queryResult = new QueryResult(myLines.ToString(), ImportFormat, Convert.ToUInt64(StopWatchLines.ElapsedMilliseconds), queryResult.TypeOfResult, AggregateListOfListOfVertices(aggregatedResults), queryResult.Error);
            else
                queryResult = new QueryResult(myLines.ToString(), ImportFormat, Convert.ToUInt64(StopWatchLines.ElapsedMilliseconds), ResultType.Successful, AggregateListOfListOfVertices(aggregatedResults));

            return queryResult;
        }
예제 #5
0
        private IEnumerable<IEnumerable<IVertexView>> ExecuteAsSingleThread(IEnumerable<String> myLines,
            IGraphQL myIGraphQL,
            SecurityToken mySecurityToken,
            Int64 myTransactionToken,
            VerbosityTypes myVerbosityType,
            IEnumerable<String> comments = null)
        {
            #region data

            Int64 numberOfLine = 0;
            var aggregatedResults = new List<IEnumerable<IVertexView>>();

            #endregion

            #region check lines and execute query

            foreach (var _Line in myLines)
            {
                numberOfLine++;

                if (String.IsNullOrWhiteSpace(_Line))
                {
                    continue;
                }

                #region Skip comments

                if (IsComment(_Line, comments))
                    continue;

                #endregion

                #region execute query

                var tempResult = myIGraphQL.Query(mySecurityToken, myTransactionToken, _Line);

                #endregion

                #region Add errors and break execution

                if (tempResult.TypeOfResult == ResultType.Failed)
                {
                    if (tempResult.Error.Message.Equals("Mal-formed  string literal - cannot find termination symbol."))
                        Debug.WriteLine("Query at line [" + numberOfLine + "] [" + _Line + "] failed with " + tempResult.Error.ToString() + " add next line...");

                    if (myVerbosityType == VerbosityTypes.Errors)
                    {
                        if (tempResult.Error != null)
                            throw tempResult.Error;
                        else
                            throw new ImportFailedException(new UnknownException());
                    }
                }

                aggregatedResults.Add(tempResult.Vertices);

                #endregion
            }

            return aggregatedResults;

            #endregion
        }
예제 #6
0
        private void ExecuteAsSingleThread(IEnumerable<String> myLines,
                                                    IGraphQL myIGraphQL,
                                                    SecurityToken mySecurityToken,
                                                    Int64 myTransactionToken,
                                                    VerbosityTypes myVerbosityType,
                                                    IEnumerable<String> comments = null)
        {
            _logger.Log (Level.INFO, "Started GQL import.");

            #region data

            Int64 numberOfLine = 0;

            #endregion

            #region check lines and execute query

            Stopwatch sw = new Stopwatch ();

            foreach (var _Line in myLines) {
                numberOfLine++;

                if (String.IsNullOrWhiteSpace (_Line)) {
                    continue;
                }

                #region Skip comments

                if (IsComment (_Line, comments))
                    continue;

                #endregion

                #region execute query
                _logger.Log (Level.INFO, String.Format ("Executing query {0}: {1}", _numberOfStatements, _Line));

                sw.Reset ();
                sw.Start ();

                var tempResult = myIGraphQL.Query (mySecurityToken, myTransactionToken, _Line);
                Interlocked.Increment (ref _numberOfStatements);

                sw.Stop ();

                _logger.Log (Level.INFO, String.Format ("Took {0}ms.", sw.Elapsed.TotalMilliseconds));

                #endregion

                #region Add errors and break execution

                if (tempResult.TypeOfResult == ResultType.Failed) {
                    if (tempResult.Error.Message.Equals ("Mal-formed  string literal - cannot find termination symbol.")) {

                        string error = "Query at line [" + numberOfLine + "] [" + _Line + "] failed with " + tempResult.Error.ToString () + " add next line...";
                        Debug.WriteLine (error);
                        _logger.Log (Level.WARNING, error);
                    }
                    if (myVerbosityType == VerbosityTypes.Errors) {
                        if (tempResult.Error != null) {
                            _logger.Log (Level.SEVERE, tempResult.Error.ToString ());
                        } else {
                            _logger.Log (Level.SEVERE, "Import failed because of unknown exception");
                        }
                    }
                }

                #endregion
            }

            #endregion

            _logger.Log (Level.INFO, String.Format ("Finished GQL import and executed {0} statements", _numberOfStatements));
        }
예제 #7
0
        private IEnumerable <IEnumerable <IVertexView> > ExecuteAsSingleThread(IEnumerable <String> myLines,
                                                                               IGraphQL myIGraphQL,
                                                                               SecurityToken mySecurityToken,
                                                                               Int64 myTransactionToken,
                                                                               VerbosityTypes myVerbosityType,
                                                                               IEnumerable <String> comments = null)
        {
            #region data

            Int64 numberOfLine      = 0;
            var   aggregatedResults = new List <IEnumerable <IVertexView> >();

            #endregion

            #region check lines and execute query

            foreach (var _Line in myLines)
            {
                numberOfLine++;

                if (String.IsNullOrWhiteSpace(_Line))
                {
                    continue;
                }

                #region Skip comments

                if (IsComment(_Line, comments))
                {
                    continue;
                }

                #endregion

                #region execute query

                var tempResult = myIGraphQL.Query(mySecurityToken, myTransactionToken, _Line);

                #endregion

                #region Add errors and break execution

                if (tempResult.TypeOfResult == ResultType.Failed)
                {
                    if (tempResult.Error.Message.Equals("Mal-formed  string literal - cannot find termination symbol."))
                    {
                        Debug.WriteLine("Query at line [" + numberOfLine + "] [" + _Line + "] failed with " + tempResult.Error.ToString() + " add next line...");
                    }

                    if (myVerbosityType == VerbosityTypes.Errors)
                    {
                        if (tempResult.Error != null)
                        {
                            throw tempResult.Error;
                        }
                        else
                        {
                            throw new ImportFailedException(new UnknownException());
                        }
                    }
                }

                aggregatedResults.Add(tempResult.Vertices);

                #endregion
            }


            return(aggregatedResults);

            #endregion
        }