private void RunExample(object sender, MouseEventArgs e)
        {
            try
            {
                TreeNode node = examplesView.SelectedNode;

                if (node == null || !(node is ExampleTreeNode))
                {
                    throw new Exception("Please select an example program.");
                }

                if (currentExample != null)
                {
                    throw new Exception("Stop the current example before running a new example.");
                }

                currentExample = (ExampleTreeNode)node;
                Arguments args = ParseArguments();
                thread = new Thread(RunExampleThread);
                thread.Start(args);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 private void RunExampleThread(object data)
 {
     try
     {
         currentExample.Run((Arguments)data);
     }
     catch (Exception ex)
     {
         console.Error(Util.GetErrorMessage(ex));
         //MessageBox.Show(ex.Message);
     }
     finally
     {
         currentExample = null;
     }
 }
        private void ExampleSelected(object sender, TreeViewEventArgs e)
        {
            try
            {
                TreeNode node = examplesView.SelectedNode;

                if (node == null || !(node is ExampleTreeNode))
                {
                    return;
                }

                codeBox.Clear();
                ExampleTreeNode example = (ExampleTreeNode)node;

                if (example.IsBenchmark())
                {
                    if (example.IsBenchmarkInitialize())
                    {
                        initializePanel.Visible = true;
                        workloadPanel.Visible   = false;
                    }
                    else
                    {
                        initializePanel.Visible = false;
                        workloadPanel.Visible   = true;
                    }
                    benchmarkPanel.Visible = true;
                    codeBox.Visible        = false;
                }
                else
                {
                    codeBox.Visible        = true;
                    benchmarkPanel.Visible = false;
                    codeBox.Text           = example.Read();
                    HighlightSourceCode();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void FormInit()
        {
            try
            {
                codeBox.Font          = new Font("Consolas", 10.0f);
                codeBox.SelectionTabs = new int[] { 25, 50, 75, 100, 125 };

                binTypeBox.Items.Add(BinType.Integer);
                binTypeBox.Items.Add(BinType.String);
                binTypeBox.Items.Add(BinType.Byte);
                binTypeBox.SelectedItem = BinType.Integer;

                replicaBox.Items.Add(Replica.SEQUENCE);
                replicaBox.Items.Add(Replica.MASTER);
                replicaBox.Items.Add(Replica.MASTER_PROLES);
                replicaBox.Items.Add(Replica.RANDOM);
                replicaBox.SelectedItem = Replica.SEQUENCE;

                readModeAPBox.Items.Add(ReadModeAP.ONE);
                readModeAPBox.Items.Add(ReadModeAP.ALL);
                readModeAPBox.SelectedItem = ReadModeAP.ONE;

                readModeSCBox.Items.Add(ReadModeSC.SESSION);
                readModeSCBox.Items.Add(ReadModeSC.LINEARIZE);
                readModeSCBox.Items.Add(ReadModeSC.ALLOW_REPLICA);
                readModeSCBox.Items.Add(ReadModeSC.ALLOW_UNAVAILABLE);
                readModeSCBox.SelectedItem = ReadModeSC.SESSION;

                ReadDefaults();

                console = new ConsoleBox(consoleBox);
                Log.SetLevel(Log.Level.INFO);
                Log.SetCallback(LogCallback);

                TreeNode info = new ExampleTreeNode("Server Info", new ServerInfo(console));

                TreeNode examples = new TreeNode("Examples", new TreeNode[] {
                    info,
                    new ExampleTreeNode("Put/Get", new PutGet(console)),
                    new ExampleTreeNode("Replace", new Replace(console)),
                    new ExampleTreeNode("Add", new Add(console)),
                    new ExampleTreeNode("Append", new Append(console)),
                    new ExampleTreeNode("Prepend", new Prepend(console)),
                    new ExampleTreeNode("Batch", new Batch(console)),
                    new ExampleTreeNode("Generation", new Generation(console)),
                    new ExampleTreeNode("Serialize", new Serialize(console)),
                    new ExampleTreeNode("Expire", new Expire(console)),
                    new ExampleTreeNode("Touch", new Touch(console)),
                    new ExampleTreeNode("Operate", new Operate(console)),
                    new ExampleTreeNode("OperateBit", new OperateBit(console)),
                    new ExampleTreeNode("OperateList", new OperateList(console)),
                    new ExampleTreeNode("OperateMap", new OperateMap(console)),
                    new ExampleTreeNode("Delete Bin", new DeleteBin(console)),
                    new ExampleTreeNode("Join", new GetAndJoin(console)),
                    new ExampleTreeNode("Scan Parallel", new ScanParallel(console)),
                    new ExampleTreeNode("Scan Series", new ScanSeries(console)),
                    new ExampleTreeNode("Async PutGet", new AsyncPutGet(console)),
                    new ExampleTreeNode("Async Batch", new AsyncBatch(console)),
                    new ExampleTreeNode("Async Scan", new AsyncScan(console)),
                    new ExampleTreeNode("Async Query", new AsyncQuery(console)),
                    new ExampleTreeNode("Async UDF", new AsyncUserDefinedFunction(console)),
                    new ExampleTreeNode("List/Map", new ListMap(console)),
                    new ExampleTreeNode("User Defined Function", new UserDefinedFunction(console)),
                    new ExampleTreeNode("Query Integer", new QueryInteger(console)),
                    new ExampleTreeNode("Query String", new QueryString(console)),
                    new ExampleTreeNode("Query List", new QueryList(console)),
                    new ExampleTreeNode("Query Region", new QueryRegion(console)),
                    new ExampleTreeNode("Query Region Filter", new QueryRegionFilter(console)),
                    new ExampleTreeNode("Query Filter", new QueryFilter(console)),
                    new ExampleTreeNode("Query PredExp", new QueryPredExp(console)),
                    new ExampleTreeNode("Query Sum", new QuerySum(console)),
                    new ExampleTreeNode("Query Average", new QueryAverage(console)),
                    new ExampleTreeNode("Query Execute", new QueryExecute(console)),
                    new ExampleTreeNode("Query Geo Collection", new QueryGeoCollection(console))
                });
                TreeNode benchmarks = new TreeNode("Benchmarks", new TreeNode[] {
                    new ExampleTreeNode("Initialize", new BenchmarkInitialize(console)),
                    new ExampleTreeNode("Read/Write", new BenchmarkReadWrite(console))
                });

                examplesView.Nodes.Add(examples);
                examplesView.Nodes.Add(benchmarks);
                examplesView.SelectedNode = info;
                examplesView.ExpandAll();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 5
0
        private void FormInit()
        {
            try
            {
                codeBox.Font          = new Font("Consolas", 10.0f);
                codeBox.SelectionTabs = new int[] { 25, 50, 75, 100, 125 };

                binTypeBox.Items.Add(BinType.Integer);
                binTypeBox.Items.Add(BinType.String);
                binTypeBox.Items.Add(BinType.Byte);
                binTypeBox.SelectedItem = BinType.Integer;

                ReadDefaults();

                console = new ConsoleBox(consoleBox);
                Log.SetLevel(Log.Level.INFO);
                Log.SetCallback(LogCallback);

                TreeNode info = new ExampleTreeNode("Server Info", new ServerInfo(console));

                TreeNode examples = new TreeNode("Examples", new TreeNode[] {
                    info,
                    new ExampleTreeNode("Put/Get", new PutGet(console)),
                    new ExampleTreeNode("Replace", new Replace(console)),
                    new ExampleTreeNode("Add", new Add(console)),
                    new ExampleTreeNode("Append", new Append(console)),
                    new ExampleTreeNode("Prepend", new Prepend(console)),
                    new ExampleTreeNode("Batch", new Batch(console)),
                    new ExampleTreeNode("Generation", new Generation(console)),
                    new ExampleTreeNode("Serialize", new Serialize(console)),
                    new ExampleTreeNode("Expire", new Expire(console)),
                    new ExampleTreeNode("Touch", new Touch(console)),
                    new ExampleTreeNode("Operate", new Operate(console)),
                    new ExampleTreeNode("Delete Bin", new DeleteBin(console)),
                    new ExampleTreeNode("Join", new GetAndJoin(console)),
                    new ExampleTreeNode("Scan Parallel", new ScanParallel(console)),
                    new ExampleTreeNode("Scan Series", new ScanSeries(console)),
                    new ExampleTreeNode("Async PutGet", new AsyncPutGet(console)),
                    new ExampleTreeNode("Async Batch", new AsyncBatch(console)),
                    new ExampleTreeNode("Async Scan", new AsyncScan(console)),
                    new ExampleTreeNode("List/Map", new ListMap(console)),
                    new ExampleTreeNode("User Defined Function", new UserDefinedFunction(console)),
                    new ExampleTreeNode("Large List", new LargeList(console)),
                    new ExampleTreeNode("Large Set", new LargeSet(console)),
                    new ExampleTreeNode("Large Stack", new LargeStack(console)),
                    new ExampleTreeNode("Query Integer", new QueryInteger(console)),
                    new ExampleTreeNode("Query String", new QueryString(console)),
                    new ExampleTreeNode("Query Filter", new QueryFilter(console)),
                    new ExampleTreeNode("Query Sum", new QuerySum(console)),
                    new ExampleTreeNode("Query Average", new QueryAverage(console)),
                    new ExampleTreeNode("Query Execute", new QueryExecute(console))
                });
                TreeNode benchmarks = new TreeNode("Benchmarks", new TreeNode[] {
                    new ExampleTreeNode("Initialize", new BenchmarkInitialize(console)),
                    new ExampleTreeNode("Read/Write", new BenchmarkReadWrite(console))
                });

                examplesView.Nodes.Add(examples);
                examplesView.Nodes.Add(benchmarks);
                examplesView.SelectedNode = info;
                examplesView.ExpandAll();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 private void RunExampleThread(object data)
 {
     try
     {
         currentExample.Run((Arguments)data);
     }
     catch (Exception ex)
     {
         console.Error(Util.GetErrorMessage(ex));
         //MessageBox.Show(ex.Message);
     }
     finally
     {
         currentExample = null;
     }
 }
        private void RunExample(object sender, MouseEventArgs e)
        {
            try
            {
                TreeNode node = examplesView.SelectedNode;

                if (node == null || ! (node is ExampleTreeNode))
                    throw new Exception("Please select an example program.");

                if (currentExample != null)
                    throw new Exception("Stop the current example before running a new example.");

                currentExample = (ExampleTreeNode)node;
                Arguments args = ParseArguments();
                thread = new Thread(RunExampleThread);
                thread.Start(args);
            }
            catch (Exception ex)
            {
                currentExample = null;
                MessageBox.Show(ex.Message);
            }
        }
        private void FormInit()
        {
            try
            {
                codeBox.Font = new Font("Consolas", 10.0f);
                codeBox.SelectionTabs = new int[] { 25, 50, 75, 100, 125 };

                binTypeBox.Items.Add(BinType.Integer);
                binTypeBox.Items.Add(BinType.String);
                binTypeBox.Items.Add(BinType.Byte);
                binTypeBox.SelectedItem = BinType.Integer;

                ReadDefaults();

                console = new ConsoleBox(consoleBox);
                Log.SetLevel(Log.Level.INFO);
                Log.SetCallback(LogCallback);

                TreeNode info = new ExampleTreeNode("Server Info", new ServerInfo(console));

                TreeNode examples = new TreeNode("Examples", new TreeNode[] {
                    info,
                    new ExampleTreeNode("Put/Get", new PutGet(console)),
                    new ExampleTreeNode("Replace", new Replace(console)),
                    new ExampleTreeNode("Add", new Add(console)),
                    new ExampleTreeNode("Append", new Append(console)),
                    new ExampleTreeNode("Prepend", new Prepend(console)),
                    new ExampleTreeNode("Batch", new Batch(console)),
                    new ExampleTreeNode("Generation", new Generation(console)),
                    new ExampleTreeNode("Serialize", new Serialize(console)),
                    new ExampleTreeNode("Expire", new Expire(console)),
                    new ExampleTreeNode("Touch", new Touch(console)),
                    new ExampleTreeNode("Operate", new Operate(console)),
                    new ExampleTreeNode("OperateList", new OperateList(console)),
                    new ExampleTreeNode("Delete Bin", new DeleteBin(console)),
                    new ExampleTreeNode("Join", new GetAndJoin(console)),
                    new ExampleTreeNode("Scan Parallel", new ScanParallel(console)),
                    new ExampleTreeNode("Scan Series", new ScanSeries(console)),
                    new ExampleTreeNode("Async PutGet", new AsyncPutGet(console)),
                    new ExampleTreeNode("Async Batch", new AsyncBatch(console)),
                    new ExampleTreeNode("Async Scan", new AsyncScan(console)),
                    new ExampleTreeNode("Async Query", new AsyncQuery(console)),
                    new ExampleTreeNode("Async UDF", new AsyncUserDefinedFunction(console)),
                    new ExampleTreeNode("List/Map", new ListMap(console)),
                    new ExampleTreeNode("User Defined Function", new UserDefinedFunction(console)),
                    new ExampleTreeNode("Large List", new LargeList(console)),
                    new ExampleTreeNode("Large Set", new LargeSet(console)),
                    new ExampleTreeNode("Large Stack", new LargeStack(console)),
                    new ExampleTreeNode("Query Integer", new QueryInteger(console)),
                    new ExampleTreeNode("Query String", new QueryString(console)),
                    new ExampleTreeNode("Query Region", new QueryRegion(console)),
                    new ExampleTreeNode("Query Region Filter", new QueryRegionFilter(console)),
                    new ExampleTreeNode("Query Filter", new QueryFilter(console)),
                    new ExampleTreeNode("Query Sum", new QuerySum(console)),
                    new ExampleTreeNode("Query Average", new QueryAverage(console)),
                    new ExampleTreeNode("Query Execute", new QueryExecute(console))
                });
                TreeNode benchmarks = new TreeNode("Benchmarks", new TreeNode[] {
                    new ExampleTreeNode("Initialize", new BenchmarkInitialize(console)),
                    new ExampleTreeNode("Read/Write", new BenchmarkReadWrite(console))
                });

                examplesView.Nodes.Add(examples);
                examplesView.Nodes.Add(benchmarks);
                examplesView.SelectedNode = info;
                examplesView.ExpandAll();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }