Beispiel #1
0
        public override async ValueTask DisposeAsync()
        {
            if (ApplicationReader != null && ApplicationWriter != null)
            {
                await ApplicationWriter.CompleteAsync().ConfigureAwait(false);

                await ApplicationReader.CompleteAsync().ConfigureAwait(false);
            }

            // Completing these loops will cause ExecuteAsync to Dispose the socket.
        }
        public void WriteApplicationDefinition_EnsureNameGetsWrittenCorrectly()
        {
            //ARRANGE
            var application = new Application();

            application.Name = "appName";
            application.Guid = "635c6cbe-e370-49e8-be45-059fa5979ad5";

            //ACT
            var writer = new ApplicationWriter();
            var text   = writer.WriteApplicationDefinition(application);

            //ASSERT
            var props = ParseTestHelper.GetClassDefinition(text).Members.ToArray();

            Assert.Equal("public const string Name = \"appName\";", props[0].ToString(), ignoreWhiteSpaceDifferences: true);
            Assert.Equal("public const string Guid = \"635c6cbe-e370-49e8-be45-059fa5979ad5\";", props[1].ToString(), ignoreWhiteSpaceDifferences: true);
        }
Beispiel #3
0
        private static void Main(string[] args)
        {
            var wsbFile                        = args.Length >= 1 ? args[0] : "Schema.mic";
            var basePathToSolution             = args.Length >= 2 ? args[1] : "../";
            var domainNameSpace                = "Domain";
            var applicationNameSpace           = "Application";
            var sqlAdapterNameSpace            = "SqlAdapter";
            var webAdapterNameSpace            = "HttpAdapter";
            var domainBasePath                 = $"{basePathToSolution}{domainNameSpace}/Generated/";
            var applicationBasePath            = $"{basePathToSolution}{applicationNameSpace}/Generated/";
            var applicationRealClassesBasePath = $"{basePathToSolution}{applicationNameSpace}/";
            var domainRealClassesBasePath      = $"{basePathToSolution}{domainNameSpace}/";
            var sqlAdapterBasePath             = $"{basePathToSolution}{sqlAdapterNameSpace}/Generated/";
            var webAdapterBasePath             = $"{basePathToSolution}{webAdapterNameSpace}/Generated/";
            var asynHostBasePath               = $"{basePathToSolution}AsyncHost";
            var injectionBasePath              = $"{basePathToSolution}Host";

            var tokenizer         = new MicrowaveLanguageTokenizer();
            var parser            = new MicrowaveLanguageParser();
            var domainBuilder     = new DomainWriter(domainBasePath, domainRealClassesBasePath);
            var applicationWriter = new ApplicationWriter(applicationNameSpace, applicationBasePath, applicationRealClassesBasePath);
            var sqlAdapterWriter  = new SqlAdapterWriter(sqlAdapterNameSpace, sqlAdapterBasePath);
            var webAdapterWriter  = new HttpAdapterWriter(webAdapterNameSpace, webAdapterBasePath);
            var dependencyInjectionWriterAsyncHost = new DependencyInjectionBuilderAsyncHost();

            var dependencyInjectionWriter = new DependencyInjectionBuilderHost();

            using (var reader = new StreamReader(wsbFile))
            {
                var content = reader.ReadToEnd();

                var dslParser  = new DslParser(tokenizer, parser);
                var domainTree = dslParser.Parse(content);

                domainBuilder.Write(domainTree, domainBasePath);
                applicationWriter.Write(domainTree);
                sqlAdapterWriter.Write(domainTree);
                webAdapterWriter.Write(domainTree);
                var codeNamespace = dependencyInjectionWriter.Build(domainTree.Classes, domainTree.SynchronousDomainHooks);
                new FileWriter(injectionBasePath).WriteToFile("Base/", codeNamespace);
                var write = dependencyInjectionWriterAsyncHost.Write(domainTree.Classes, domainTree.AsyncDomainHooks);
                new FileWriter(asynHostBasePath).WriteToFile("Base/", write);
            }
        }
        static void Main(string[] args)
        {
            var    myListener        = new MyListener();
            var    desktopFolderName = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            string folderFromArgs    = (args != null) && (args.Length > 0) ? args[0] : null;
            var    sourceFolderName  = folderFromArgs ?? Path.Combine(desktopFolderName, "objects");
            string outputFile        = (args != null) && (args.Length > 1) ? args[1] : null;
            var    codeStyle         = Localization.Localizations.GetLocalizedCodeStyle("NAV2013", "lt-LT", true);

            codeStyle.Localization.DateFormat        = "yy-MM-dd";
            codeStyle.Localization.DateTimeFormat    = "yy-MM-dd HH:mm";
            codeStyle.Localization.ActiveCultureInfo = System.Globalization.CultureInfo.GetCultureInfo("lt-LT");
            Console.WriteLine(codeStyle);
            if (String.IsNullOrEmpty(outputFile))
            {
                var parser = new Parser();
                parser.Listener  = myListener;
                parser.CodeStyle = codeStyle;
                parser.ParseFiles(Directory.GetFiles(sourceFolderName, "*.txt", SearchOption.AllDirectories));
            }
            else
            {
                var application = ApplicationBuilder.ReadFromFolder(sourceFolderName, codeStyle);
                application.CodeStyle.PrintObjectReferenceAsName       = true;
                application.CodeStyle.ExportToNewSyntax                = true;
                application.CodeStyle.Localization.DateFormat          = "yyyyMMdd\\D";
                application.CodeStyle.Localization.TimeFormat          = "HHmmss\\T";
                application.CodeStyle.Localization.LocalizedYes        = "true";
                application.CodeStyle.Localization.LocalizedNo         = "false";
                application.CodeStyle.Localization.FieldNameExceptions = new char[0];
                application.CodeStyle.Localization.TableNameExceptions = new char[0];
                application.CodeStyle.UseQuitesInFieldList             = true;
                ObjectNameCollection nameCollection = new ObjectNameCollection();
                application.CodeStyle.ObjectNameResolvers.Add(nameCollection);

                nameCollection.RegisterObjectName(Common.ObjectType.Codeunit, 396, "NoSeriesManagement");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 156, "Resource");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 225, "Post Code");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 5200, "Employee");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 2000000026, "Integer");

                nameCollection.RegisterObjectName(Common.ObjectType.Codeunit, 17024401, "PAFinUtilsABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Codeunit, 17024403, "PAUtilsABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Codeunit, 17024428, "PAUnusedHolRemManagementABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Codeunit, 17024431, "PAGlobalFilterManagementABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Codeunit, 17024457, "PAFormulaUtilsABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Codeunit, 17024460, "PAIntegrationManagementABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Codeunit, 17024462, "PAColourManagementABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Codeunit, 17024505, "PAGroupingManagementABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Codeunit, 17024584, "PANameConstructorABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Codeunit, 17024663, "PAEmployeeStatusManagementABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Codeunit, 17024808, "PAUserManagementABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024400, "PASetupABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024402, "PAPersonABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024404, "PAAppointmentABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024406, "PAPostCodeExtensionABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024409, "PAFormerEmploymentABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024411, "PAPersonRelativeABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024414, "PAEmplArmyRegistrationABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024434, "PAEmplTranslationABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024445, "PAPersonEducationABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024446, "PAPersonForeignLanguageABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024447, "PAPersonPenaltyEcouragementABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024448, "PAEmplTrainingABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024482, "PAEmplAbsenceABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024488, "PASubstitutionABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024493, "PAPersonDocumentABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024512, "PAPersonDisabilityABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024513, "PAPersonRelAddTaxExemptABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024514, "PAEmplArmyRegistrationABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024530, "PAPermanentAddDedABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024536, "PASumJournalLineABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024546, "PAPaymentPlaceABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024553, "PAEmplIndividualDataABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024579, "PAIntegrationSetupABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024593, "PAPersonMedicalExaminationABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024601, "PASecondaryPositionABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024713, "PATableFieldHistoryABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024714, "PATableOptionFieldStoreABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024715, "PAPersonTradeUnionABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Table, 17024716, "PAWorkRelationABS");
                nameCollection.RegisterObjectName(Common.ObjectType.Page, 17024798, "PAPersonListSimpleABS");

                FieldTypeMappingCollection fieldTypeMappingCollection = new FieldTypeMappingCollection();
                application.CodeStyle.FieldTypeResolvers.Add(fieldTypeMappingCollection);
                fieldTypeMappingCollection.RegisterTableFields("PATableFieldHistoryABS", new Dictionary <string, Common.TableFieldType>()
                {
                    { "Table ID", Common.TableFieldType.Integer },
                    { "Field ID", Common.TableFieldType.Integer }
                });
                fieldTypeMappingCollection.RegisterTableFields("PAEmailIntegrationHistoryABS", new Dictionary <string, Common.TableFieldType>()
                {
                    { "Journal Code", Common.TableFieldType.Code },
                    { "Already Sent", Common.TableFieldType.Boolean },
                });
                fieldTypeMappingCollection.RegisterTableFields("PAActivityCodeABS", new Dictionary <string, Common.TableFieldType>()
                {
                    { "Show", Common.TableFieldType.Boolean },
                    { "Activity Type", Common.TableFieldType.Option },
                });
                fieldTypeMappingCollection.RegisterTableFields("PAWorkScheduleNameABS", new Dictionary <string, Common.TableFieldType>()
                {
                    { "Confirmed", Common.TableFieldType.Boolean },
                });

                ApplicationWriter.WriteToFile(application, outputFile);
            }
        }