Esempio n. 1
0
        public void CreateTextEditorProject(string mainScriptName, string mainScriptPath)
        {
            try
            {
                _mainFileName = ScriptProject.Main;
                switch (ScriptProject.ProjectType)
                {
                case ProjectType.Python:
                    File.WriteAllText(mainScriptPath, _helloWorldTextPython);
                    File.Create(Path.Combine(new FileInfo(mainScriptPath).Directory.FullName, "requirements.txt")).Close();

                    //assign pythonVersion and mainFunction arguments
                    var mainFunctionArgument = new ProjectArgument
                    {
                        ArgumentName  = "--MainFunction",
                        ArgumentType  = typeof(string),
                        ArgumentValue = "main"
                    };
                    ScriptProject.ProjectArguments.Add(mainFunctionArgument);

                    var pythonVersionArgument = new ProjectArgument
                    {
                        ArgumentName = "--PythonVersion",
                        ArgumentType = typeof(string),
                    };
                    ScriptProject.ProjectArguments.Add(pythonVersionArgument);
                    break;

                case ProjectType.TagUI:
                    File.WriteAllText(mainScriptPath, _helloWorldTextTagUI);

                    var reportArgument = new ProjectArgument
                    {
                        ArgumentName = "-report",
                        ArgumentType = typeof(string),
                    };
                    ScriptProject.ProjectArguments.Add(reportArgument);
                    break;

                case ProjectType.CSScript:
                    File.WriteAllText(mainScriptPath, _helloWorldTextCSScript);
                    break;

                case ProjectType.PowerShell:
                    File.WriteAllText(mainScriptPath, _helloWorldTextPowerShell);
                    break;
                }

                OpenTextEditorFile(mainScriptPath, ScriptProject.ProjectType);
            }
            catch (Exception ex)
            {
                Notify("An Error Occurred: " + ex.Message, Color.Red);
            }
        }
Esempio n. 2
0
        public static void Main()
        {
            DataContainer data = CreateDataContainer();

            QueryableEntity Person = new QueryableEntity(data.EntityRelationshipModel.FindByName("Person"));
            QueryableEntity Car    = new QueryableEntity(data.EntityRelationshipModel.FindByName("Car"));
            Relationship    Drives = (Relationship)data.EntityRelationshipModel.FindByName("Drives");
            ModelMapping    Map    = data.ERMongoMapping;

            QueryableEntity Garage = new QueryableEntity(data.EntityRelationshipModel.FindByName("Garage"));

            RelationshipJoinOperator RJoinDrives = new RelationshipJoinOperator(
                Person,
                Drives,
                new List <QueryableEntity>()
            {
                Car
            },
                Map);

            CartesianProductOperator CartesianOp = new CartesianProductOperator(
                Person,
                Garage,
                Map);

            ProjectArgument ProjectArg1 = new ProjectArgument(Person.GetAttribute("name"), Person, new BooleanExpr(true));
            ProjectArgument ProjectArg2 = new ProjectArgument(Person.GetAttribute("surname"), Person, new BooleanExpr(true));
            ProjectArgument ProjectArg3 = new ProjectArgument(Car.GetAttribute("reg_no"), Car, new BooleanExpr(true));

            ProjectStage ProjectOp = new ProjectStage(new ProjectArgument[] { ProjectArg1, ProjectArg2, ProjectArg3 }, RJoinDrives.ComputeVirtualMap());

            MapRule        PersonRule = Map.FindMainRule(Person.Element);
            SelectArgument SelectArg  = new SelectArgument(new EqExpr($"${PersonRule.GetRuleValueForAttribute( Person.GetAttribute( "surname" ) )}", "Smith"));
            SelectStage    SelectOp   = new SelectStage(SelectArg, Map);

            //List<MongoDBOperator> Operations = RJoinDrives.Run().Commands;

            //foreach ( MongoDBOperator Op in Operations )
            //{
            //    Console.WriteLine( Op.GetType().Name );
            //    Console.WriteLine( Op.ToString() );
            //    Console.WriteLine( Op.ToJavaScript() );

            //    if ( Op is LookupOperator )
            //    {
            //        LookupOperator OpAsLookup = (LookupOperator)Op;
            //        foreach ( MongoDBOperator PipelineOp in OpAsLookup.Pipeline )
            //        {
            //            Console.WriteLine( PipelineOp.GetType().Name );
            //            Console.WriteLine( PipelineOp.ToString() );
            //            Console.WriteLine( PipelineOp.ToJavaScript() );
            //        }
            //    }
            //}

            QueryGenerator QueryGen = new QueryGenerator(new FromArgument(Person, Map), new List <AlgebraOperator>()
            {
                SelectOp
            });
            string Query = QueryGen.Run();

            Console.WriteLine($"Query: {Environment.NewLine}{Query}");

            Console.Read();
        }