コード例 #1
0
ファイル: JobResult.cs プロジェクト: ghostunit/munc
 internal JobResult(int jobID, LoadFile loadFile, ModifiedFile modifiedFile, WriteFile writeFile)
 {
     this.jobID = jobID;
       this.originalPath = loadFile.Path;
       this.newPath = writeFile.Path;
       this.loadFileResult = loadFile.Result;
       this.modifiedFileResult = modifiedFile.Result;
       this.writeFileResult = writeFile.Result;
 }
コード例 #2
0
ファイル: StlInterpreter.cs プロジェクト: drt-ftl/VAME
 public void endloop(string _line, LoadFile _loadFile)
 {
     try
     {
         var mm = GameObject.Find("MESH").GetComponent<MakeMesh>();
         mm.AddTriangle(LoadFile.currentVertices[0], LoadFile.currentVertices[1], LoadFile.currentVertices[2], Normal);
         LoadFile.currentVertices.Clear ();
     }
     catch{}
 }
コード例 #3
0
 private void SaveAs_Click(object sender, RoutedEventArgs e)
 {
     Logic.SaveAs(objectXML);
     if (PathXML != null && PathXML != "")
         Title = PathXML;
     if (PathXML == null || PathXML == "") return;
     LoadFile fileload = new LoadFile(Logic.ReadXml);
     IAsyncResult result = fileload.BeginInvoke(PathXML, null, null);
     ForCompareXML = fileload.EndInvoke(result);
     result = fileload.BeginInvoke(PathXML, null, null);
     objectXML = fileload.EndInvoke(result);
 }
コード例 #4
0
        private async void SaveClick(object sender, RoutedEventArgs e)
        {
            MessageDialogStyle stylo = MessageDialogStyle.AffirmativeAndNegative;
            MessageDialogResult saveConfirm = await this.ShowMessageAsync("Save Changes?","Save Changes?",stylo);
            switch (saveConfirm)
            {
                case MessageDialogResult.Affirmative:
                    {
                        if (PathXML != null && PathXML != "")
                        {
                            if (!Logic.WriteXml(objectXML, PathXML))
                            {
                                LoadFile fileload = new LoadFile(Logic.ReadXml);
                                IAsyncResult result = fileload.BeginInvoke(PathXML, null, null);
                                ForCompareXML = fileload.EndInvoke(result);
                                result = fileload.BeginInvoke(PathXML, null, null);
                                objectXML = fileload.EndInvoke(result);
                            }
                            return;
                        }
                        else
                        {
                            Logic.SaveAs(objectXML);
                            if (PathXML != null && PathXML != "")
                            {
                                Title = PathXML;
                                LoadFile fileload = new LoadFile(Logic.ReadXml);
                                IAsyncResult result = fileload.BeginInvoke(PathXML, null, null);
                                ForCompareXML = fileload.EndInvoke(result);
                                result = fileload.BeginInvoke(PathXML, null, null);
                                objectXML = fileload.EndInvoke(result);
                            }
                            return;
                        }
                    }
                case MessageDialogResult.Negative:
                    return;
            }

        }
コード例 #5
0
        public void ChooseEditButtonClick(object sender, EventArgs e)
        {
            if (!Logic.CompareXml(objectXML, ForCompareXML))
                return;

            PathXML = null;

            OpenFileDialog myDialog = new OpenFileDialog();

            myDialog.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*";
            myDialog.CheckFileExists = true;
            myDialog.Multiselect = false;
            myDialog.ShowDialog();

            PathXML = myDialog.FileName;

            if (PathXML == null || PathXML == "") return;

            try
            {
                LastActiveCoords.rowCoord = 0;
                LastActiveCoords.colCoord = 0;
                LoadFile fileload = new LoadFile(Logic.ReadXml);
                IAsyncResult result = fileload.BeginInvoke(PathXML, null, null);
                objectXML = fileload.EndInvoke(result);

                result = fileload.BeginInvoke(PathXML, null, null);
                ForCompareXML = fileload.EndInvoke(result);

                EditCell.Visibility = Visibility.Collapsed;
                EditHeader.Visibility = Visibility.Collapsed;
                ListBox1.Items.Clear();
                Logic.DisplayXML(ListBox1, objectXML);

                AddColBtn.Visibility = Visibility.Visible;
                AddRowBtn.Visibility = Visibility.Visible;
                DelColBtn.Visibility = Visibility.Visible;
                DelRowBtn.Visibility = Visibility.Visible;
                SaveAsBtn.Visibility = Visibility.Visible;
                SaveBtn.Visibility = Visibility.Visible;

                SaveAsMenuBtn.IsEnabled = true;
                SaveMenuBtn.IsEnabled = true;

                Adapter.Visibility = Visibility.Collapsed;

                Title = PathXML;
                Logic.ClearControls(this);
            }
            catch (XmlException)
            {
                Logic.FileErrorDialog(this);
            }
            
        }
コード例 #6
0
ファイル: LoadFile.cs プロジェクト: woosub/TMJ
 // Use this for initialization
 void Start()
 {
     m_this = this;
 }
コード例 #7
0
ファイル: WatService.cs プロジェクト: Astn/ekati
        public override async Task Query(QueryRequest request, IServerStreamWriter <QueryResponse> responseStream, ServerCallContext context)
        {
            var operationQueue = new Queue <Task>();

            Func <Task, Task> queueIt = (Task t) =>
            {
                operationQueue.Enqueue(t);
                return(t);
            };

            var parser = new AHGHEEParser(ParserUtils.makeStream(request.QueryText));

            parser.BuildParseTree = true;
            parser.AddParseListener(listener: new Listener(async(nodes) =>
            {
                // Handle inserting of nodes via a Put command
                var tcs = new TaskCompletionSource <short>();
                try
                {
                    // todo: Should we batch in chucks of these nodes?
                    await queueIt(tcs.Task);
                    foreach (var node in nodes)
                    {
                        await queueIt(_db.AddNoQueue(node));
                    }
                    tcs.SetResult(1);
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"ex {ex} stack: {ex.StackTrace}");
                    tcs.SetException(ex);
                }
            }, async(nids) =>
            {
                // Handle querying nodes
                var gr = new GetRequest();
                gr.Iris.AddRange(nids.Select(nid => nid.Iri));
                await queueIt(Get(gr, responseStream, context));
            }, () => { },
                                                           async(loadType, path) =>
            {
                var lf  = new LoadFile();
                lf.Type = loadType;
                lf.Path = path.Trim('\"');
                await queueIt(Load(lf, responseStream, context));
            }));
            parser.AddErrorListener(new ErrorListener());
            AHGHEEParser.CommandContext cc = null;

            var sw = Stopwatch.StartNew();

            Console.WriteLine("-- Parsing started --");
            for (; ; cc = parser.command())
            {
                if (cc?.exception != null)
                {
                    Console.WriteLine($"{cc.exception.Message} - found {cc.exception.OffendingToken.Text} at Line {cc.exception.OffendingToken.Line} offset at {cc.exception.OffendingToken.StartIndex}");
                }

                if (parser.CurrentToken.Type == TokenConstants.Eof)
                {
                    break;
                }
            }
            sw.Stop();
            Console.WriteLine($"-- Parsing finished in {sw.ElapsedMilliseconds}ms");
            sw.Restart();
            try
            {
                await Task.WhenAll(operationQueue);
            }
            finally
            {
                sw.Stop();
                Console.WriteLine($"-- Operation queue finished in another {sw.ElapsedMilliseconds}ms");
            }
        }
コード例 #8
0
ファイル: WatService.cs プロジェクト: Astn/ekati
        public override async Task Load(LoadFile request, IServerStreamWriter <QueryResponse> responseStream, ServerCallContext context)
        {
            if (request.Type == "nt")
            {
                Console.WriteLine($"Loading file: {request.Path}");
                try
                {
                    Stream data                  = null;
                    var    TotalLength           = 0L;
                    var    TotalProgress         = 0L;
                    var    totalLengthDetermined = false;
                    if (!File.Exists(request.Path))
                    {
                        var wc   = new WebClient();
                        var file = Path.GetTempFileName();
                        await wc.DownloadFileTaskAsync(request.Path, file);

                        data                  = File.OpenRead(file);
                        TotalLength           = data.Length;
                        totalLengthDetermined = true;
                    }
                    else
                    {
                        data                  = File.OpenRead(request.Path);
                        TotalLength           = data.Length;
                        totalLengthDetermined = true;
                    }

                    var timer = Stopwatch.StartNew();
                    await using var cleanup = data;
                    await using var bs      = new BufferedStream(data, 4096);
                    {
                        var lastNewLinePosition = 0;
                        var memoryWritePos      = 0L;
                        var unReadBytes         = 0L;
                        var memory = new byte[81920];
                        await using var mainView = new MemoryStream(memory);
                        do
                        {
                            var newBytesAdded = await bs.ReadAsync(memory, (int)memoryWritePos, (int)(memory.Length - memoryWritePos));

                            if (!totalLengthDetermined)
                            {
                                TotalLength += newBytesAdded;
                            }
                            var newBytesEndPos = memoryWritePos + newBytesAdded;
                            if (newBytesAdded == 0)
                            {
                                break;
                            }
                            // move back to beginning
                            mainView.Seek(0, SeekOrigin.Begin);

                            // find good place to stop
                            //var endOfLastTriple = await ParseNTStreamNoTree(new MemoryStream(memory, 0,(int)newBytesEndPos));
                            var endOfLastTriple = ParseForNewLine(new Span <byte>(memory, 0, (int)newBytesEndPos));
                            // just incase we have have reached the end, we want to make sure we try to read the last bit...
                            if (endOfLastTriple == 0 && newBytesEndPos > 0)
                            {
                                unReadBytes = newBytesEndPos;
                            }
                            else
                            {
                                unReadBytes = newBytesEndPos - endOfLastTriple;
                            }

                            // create a vew up to that position;
                            var pageView = new MemoryStream(memory, 0, endOfLastTriple);

                            // run the parser on that pageView.
                            await ParseNTriplesStream(pageView);

                            // move the end of the stream that we didn't read back to the beginning
                            //Console.WriteLine($"BBC: endoflastTriple:{endOfLastTriple}, unReadBytes:{unReadBytes}, urb32:{Convert.ToInt32(unReadBytes)}");
                            Buffer.BlockCopy(memory, endOfLastTriple, memory, 0, Convert.ToInt32(unReadBytes));
                            memoryWritePos = unReadBytes;
                            TotalProgress += endOfLastTriple;
                            if (timer.Elapsed > TimeSpan.FromSeconds(1))
                            {
                                var qr = new QueryResponse();
                                qr.LoadFileResponse = new LoadFileResponse
                                {
                                    Progress = TotalProgress,
                                    Length   = TotalLength
                                };

                                await responseStream.WriteAsync(qr);
                            }

                            if (context.CancellationToken.IsCancellationRequested)
                            {
                                Console.WriteLine($"Cancel requested for file load. {request.Path }");
                                break;
                            }
                        } while (unReadBytes > 0);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }
            else if (request.Type == "graphml")
            {
                Console.WriteLine($"Loading file: {request.Path}");
                try
                {
                    var sw    = Stopwatch.StartNew();
                    var nodes = TinkerPop.buildNodesFromFile(request.Path);
                    await _db.AddMany(nodes).ContinueWith(adding =>
                    {
                        if (adding.IsCompletedSuccessfully)
                        {
                            sw.Stop();
                            Console.WriteLine(
                                $"\nstatus> put done in {sw.ElapsedMilliseconds}ms");
                        }
                        else
                        {
                            Console.WriteLine(
                                $"\nstatus> put err({adding?.Exception?.InnerException?.Message})");
                        }
                    });
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }
        }